home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
16
/
FREEDOS.ZIP
/
FD_A4PRE.ZIP
/
SOURCE
/
MICROC.ZIP
/
REBOOT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-04
|
2KB
|
104 lines
/*********************************************************************
* This program reboots the computer, either a cold or warm boot.
*
* Much of the code was written by Mike O'Carroll,
* lena!mike@relay.EU.net, and later adapted by James Hall for use in
* Free-DOS.
*
* Since no copyright was placed on the original code, I am assuming
* that this entire program is in the public domain.
*/
#include <stdio.h>
#include "freedos.h"
#include "getopt.c"
void usage (void);
void confirm (void);
main (int argc, char **argv)
{
int i, cold, verify;
cold = FALSE;
verify = FALSE;
/* Scan the command line */
while ((i = getopt (argc, argv, "CV", NULL)) != EOF)
{
switch (i)
{
case 'C':
cold = TRUE;
break;
case 'V':
verify = TRUE;
break;
default:
usage ();
break;
}
}
if (optind < argc)
usage ();
if (verify)
confirm ();
/* Reboot */
if (cold)
asm
{
MOV AH,0Dh ; Disk RESET function
INT 21h ; Ask DOS
MOV AX,40h ; BIOS data area
MOV ES,AX ; Set ES
MOV WORD PTR ES:72h,0000h ; Indicate cold start
DB 0EAh,0,0,0FFh,0FFh ; JMP FAR FFFF:0
}
else
asm
{
MOV AH,0Dh ; Disk RESET function
INT 21h ; Ask DOS
MOV AX,40h ; BIOS data area
MOV ES,AX ; Set ES
MOV WORD PTR ES:72h,1234h ; Indicate warm start
DB 0EAh,0,0,0FFh,0FFh ; JMP FAR FFFF:0
}
/* Never gets here, but keeps compiler happy */
exit (0);
}
void confirm (void)
{
char ch;
printf ("Confirm system reboot (Y/N)? ");
ch = getchar ();
if ((ch != 'y') && (ch != 'Y'))
exit (1);
}
void usage (void)
{
printp ("REBOOT", "Forces a warm or cold system reboot");
printu ("REBOOT", "[/C] [/V]");
printo ("C", "Cold boot (default is warm boot)");
printo ("V", "Verify reboot");
exit (1);
}