home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 21 / CD_ASCQ_21_040595.iso / dos / prg / c / freedos3 / source / jh_utils / pause.c < prev    next >
C/C++ Source or Header  |  1995-01-07  |  2KB  |  80 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 "getopt.h"
  26. #include "freedos.h"
  27.  
  28.  
  29. void usage (void);
  30.  
  31.  
  32. main (int argc, char **argv)
  33. {
  34.   int i, iRtn;
  35.  
  36.   /* Scan the command line */
  37.  
  38.   while ((i = getopt (argc, argv, "rR?")) != EOF)
  39.     {
  40.       switch (i)
  41.     {
  42.     case 'r':
  43.     case 'R':        /* Return the keypress */
  44.       iRtn = 1;
  45.       break;
  46.     default:
  47.       usage ();
  48.     }
  49.     }
  50.  
  51.   /* Print the user's message, if any */
  52.  
  53.   if ((argc - optind) > 0)
  54.     echov (argc, argv, optind, stderr);
  55.  
  56.   else
  57.     fprintf (stderr, "Press any key to continue");
  58.  
  59.   /* Return the keypress */
  60.   /* NOTE: The Beta release of 'pause' returned the keypress by A=1,
  61.      Z=26.  I have changed that here.. it is now the ASCII code. */
  62.  
  63.   if (iRtn)
  64.     exit (getkey ());
  65.  
  66.   else
  67.     {
  68.       getkey ();
  69.       exit (0);
  70.     }
  71. }
  72.  
  73. void 
  74. usage (void)
  75. {
  76.   printp ("PAUSE", "Displays a message and waits for the user to press a key");
  77.   printu ("PAUSE", "[/R] [message..]");
  78.   exit (1);
  79. }
  80.