Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
1.2 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. ntsleep.c
  5. Abstract:
  6. User mode sleep program. This program simply sleeps for the time
  7. specified on the command line (in seconds).
  8. Author:
  9. Manny Weiser (mannyw) 2-8-91
  10. Revision History:
  11. --*/
  12. #include <stdio.h>
  13. #include <windows.h>
  14. //
  15. // Local definitions
  16. //
  17. VOID
  18. DisplayUsage(
  19. char *ProgramName
  20. );
  21. int
  22. AsciiToInteger(
  23. char *Number
  24. );
  25. int
  26. __cdecl main(
  27. int argc,
  28. char *argv[]
  29. )
  30. {
  31. int time;
  32. if (argc != 2) {
  33. DisplayUsage( argv[0] );
  34. return 1;
  35. }
  36. time = AsciiToInteger( argv[1] );
  37. if (time == -1) {
  38. DisplayUsage( argv[0] );
  39. return 1;
  40. }
  41. //
  42. // No bounds checking here. Live with it.
  43. //
  44. Sleep( time * 1000 );
  45. return 0;
  46. }
  47. VOID
  48. DisplayUsage(
  49. char *ProgramName
  50. )
  51. {
  52. printf( "Usage: %s time-to-sleep-in-seconds\n", ProgramName );
  53. }
  54. int
  55. AsciiToInteger(
  56. char *Number
  57. )
  58. {
  59. int total = 0;
  60. while ( *Number != '\0' ) {
  61. if ( *Number >= '0' && *Number <= '9' ) {
  62. total = total * 10 + *Number - '0';
  63. Number++;
  64. } else {
  65. total = -1;
  66. break;
  67. }
  68. }
  69. return total;
  70. }