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 >
Wrap
C/C++ Source or Header
|
1995-06-23
|
2KB
|
102 lines
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**********************************************************************
* This program displays a message to the screen and then wait for the
* user to press a key before quitting.
*
* author: James Hall
*/
#include <stdio.h>
#include "freedos.h"
#include "getopt.c"
int bioskey (void);
void usage (void);
main (int argc, char **argv)
{
int i, iRtn, iKeys, iBeep;
char *Keys;
iRtn = 0; iKeys = 0; iBeep = 1;
/* Scan the command line */
while ((i = getopt (argc, argv, "QR?", "K")) != EOF)
{
switch (i)
{
case 'R': /* Return the keypress */
iRtn = 1;
break;
case 'K':
iKeys = 1;
strcpy (Keys, optarg);
break;
case 'Q':
iBeep = 0;
break;
default:
usage ();
}
}
/* Print the user's message, if any */
if ((argc - optind) > 0)
for (i = optind; i < argc; i++)
printf ("%s ", argv[i]);
else
printf ("Press any key to continue...");
/* Return the keypress */
i = bioskey();
while ((iKeys) && ((strchr (Keys, i) == NULL) || (i == 0)))
{
if (iBeep)
beep (500, 100);
i = bioskey();
}
if (iRtn)
exit (i);
else
exit (0);
}
int bioskey (void)
{
_AX_ = 0x0000;
int86 (0x16);
return (_AX_ & 0x00FF);
}
void usage (void)
{
printp ("PAUSE", "Displays a message and waits for a keystroke");
printc ("1995", "James Hall and M. \"Hannibal\" Toal");
printu ("PAUSE", "[/K=keys] [/Q] [/R] [message..]");
printo ("K", "Wait until one of the specified keys is pressed");
printo ("Q", "Silence beep when used with /K");
printo ("R", "Return the ASCII value of the key pressed as ERRORLEVEL");
exit (1);
}