
/* Batch utility which waits a specified number of seconds, i.e.:   WAIT x    */
/* Exits with errorlevel 1 if a key is pressed or 0 if the wait time expired  */
/* without interruption from the keyboard.  The space bar, however, can be    */
/* used to make the timeout happen right away (thus causing an immediate exit */
/* with errorlevel 0).                                                        */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <process.h>
#include <conio.h>
#include <time.h>
#include <dos.h>       /* Dos-specific functions are used to get date/time. */

#include "common.h"
#include "modem.h"


int seconds_to_wait;
time_t starting_time,ending_time;
char input_character;


/*------------------------------- Main Program -------------------------------*/
int main(int argc, char *argv[])
{
if (argc <= 1)                 /* Our 1 required argument not specified? */
  fatal_error("Missing argument; supply the comm. port number.");
seconds_to_wait = atoi(argv[1]);
starting_time = time(NULL);
ending_time = starting_time + seconds_to_wait + 1;
while (time(NULL) < ending_time)
  {
  if (kbhit())
    {
    input_character = getch();          /* Get character from buffer and exit. */
    if (input_character == ' ')
      return(0);
    return(1);
    }
  };
return(0);
}

