home *** CD-ROM | disk | FTP | other *** search
/ Zodiac Super OZ / MEDIADEPOT.ISO / FILES / 16 / FREEDOS.ZIP / FD_A4PRE.ZIP / SOURCE / MICROC.ZIP / PAUSE.C < prev    next >
C/C++ Source or Header  |  1995-06-23  |  2KB  |  102 lines

  1. /*
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.  
  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.
  11.  
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program; if not, write to the Free Software
  14.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16.  
  17. /**********************************************************************
  18.  * This program displays a message to the screen and then wait for the
  19.  * user to press a key before quitting.
  20.  *
  21.  * author: James Hall
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include "freedos.h"
  26. #include "getopt.c"
  27.  
  28. int bioskey (void);
  29. void usage (void);
  30.  
  31. main (int argc, char **argv)
  32.  
  33. {
  34.     int i, iRtn, iKeys, iBeep;
  35.     char *Keys;
  36.  
  37.     iRtn = 0; iKeys = 0; iBeep = 1;
  38.  
  39.     /* Scan the command line */
  40.     while ((i = getopt (argc, argv, "QR?", "K")) != EOF)
  41.         {
  42.         switch (i)
  43.             {
  44.             case 'R':        /* Return the keypress */
  45.                 iRtn = 1;
  46.                 break;
  47.             case 'K':
  48.                 iKeys = 1;
  49.                 strcpy (Keys, optarg);
  50.                 break;
  51.             case 'Q':
  52.                 iBeep = 0;
  53.                 break;
  54.             default:
  55.                 usage ();
  56.             }
  57.         }
  58.  
  59.     /* Print the user's message, if any */
  60.     if ((argc - optind) > 0)
  61.         for (i = optind; i < argc; i++)
  62.              printf ("%s ", argv[i]);
  63.     else
  64.         printf ("Press any key to continue...");
  65.  
  66.     /* Return the keypress */
  67.  
  68.     i = bioskey();
  69.     while ((iKeys) && ((strchr (Keys, i) == NULL) || (i == 0)))
  70.         {
  71.         if (iBeep)
  72.             beep (500, 100);
  73.         i = bioskey();
  74.         }
  75.  
  76.     if (iRtn)
  77.         exit (i);
  78.     else
  79.         exit (0);
  80.     }
  81.  
  82. int bioskey (void)
  83.  
  84.     {
  85.     _AX_ = 0x0000;
  86.     int86 (0x16);
  87.     return (_AX_ & 0x00FF);
  88.     }
  89.  
  90. void usage (void)
  91.  
  92.     {
  93.     printp ("PAUSE", "Displays a message and waits for a keystroke");
  94.     printc ("1995", "James Hall and M. \"Hannibal\" Toal");
  95.     printu ("PAUSE", "[/K=keys] [/Q] [/R] [message..]");
  96.     printo ("K", "Wait until one of the specified keys is pressed");
  97.     printo ("Q", "Silence beep when used with /K");
  98.     printo ("R", "Return the ASCII value of the key pressed as ERRORLEVEL");
  99.     exit (1);
  100.     }
  101.  
  102.