/*  @(#) $Header: $
 *
 * Test Philosophy:
 *    Show timedelay performing its task.
 * Author:
 *	Allen Brown  http://brown.armoredpenguin.com/~abrown
 */

#include <stdio.h>
#include <math.h>
#define MAIN
#include "timedelay.h"

int main (void)
{
  int scanfreturn, lineno, returnval;
  char inpline[80];
  int delay, time_ms;

  lineno = 0;
  while( NULL !=		// Check if this is the end of the file.
	 (fgets(inpline, sizeof(inpline), stdin))) // Read a line of text
  {
    lineno++;
    // Parse the input line.
    scanfreturn = sscanf(inpline, "%d", &time_ms);
    if( scanfreturn != 1)
    { // Number of scanned vars must match what we expect.
      printf("timedelay_t: wrong # values line %d: '%s', %d.\n",
	     lineno, inpline, scanfreturn);
    } else {
      if( time_ms )
      { // A new time delay value.
	timedelay_init( &delay, time_ms );
	printf("line %3d: timedelay_init(%d,%d);\n", lineno, delay, time_ms );
      } else {
	returnval = (int) timedelay_update( &delay );
	printf("line %3d: timedelay_update(%d) -> %d;\n", lineno, delay, returnval );
      }
      fflush(stdout);
    } // else
  } // while

  return (0);
} // main
/*
 * $Log: timedelay_t.c,v $
 *
 */

