windows-nt/Source/XPSP1/NT/sdktools/sleep/sleep.c
2020-09-26 16:20:57 +08:00

96 lines
1.2 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
ntsleep.c
Abstract:
User mode sleep program. This program simply sleeps for the time
specified on the command line (in seconds).
Author:
Manny Weiser (mannyw) 2-8-91
Revision History:
--*/
#include <stdio.h>
#include <windows.h>
//
// Local definitions
//
VOID
DisplayUsage(
char *ProgramName
);
int
AsciiToInteger(
char *Number
);
int
__cdecl main(
int argc,
char *argv[]
)
{
int time;
if (argc != 2) {
DisplayUsage( argv[0] );
return 1;
}
time = AsciiToInteger( argv[1] );
if (time == -1) {
DisplayUsage( argv[0] );
return 1;
}
//
// No bounds checking here. Live with it.
//
Sleep( time * 1000 );
return 0;
}
VOID
DisplayUsage(
char *ProgramName
)
{
printf( "Usage: %s time-to-sleep-in-seconds\n", ProgramName );
}
int
AsciiToInteger(
char *Number
)
{
int total = 0;
while ( *Number != '\0' ) {
if ( *Number >= '0' && *Number <= '9' ) {
total = total * 10 + *Number - '0';
Number++;
} else {
total = -1;
break;
}
}
return total;
}