/*Forrest Heller 2008*/ #include #include #include void print_menu(); int main(int argc, char* argv[]) { unsigned long duration; /*too few arguments*/ if (argc <= 1) { print_menu(); return 0; } if (argc == 2) { /*get duration. Probably has some security vulnerability but honestly I don't care*/ if (sscanf(argv[1],"%u",&duration) != 0) { /*whoo hoo*/ Sleep(duration * 1000); } else { /*you failed to give a number. Maybe I should say something... nope*/ print_menu(); return 0; } } else if (argc == 3) { /*check to see if the p option is specified*/ if (strchr(argv[1],'p') != (char*)0) { /*get duration. Probably has some security vulnerability but honestly I don't care*/ if (sscanf(argv[2],"%u",&duration) != 0) { /*whoo hoo*/ Sleep(duration); } else { /*you failed to give a number. Maybe I should say something... nope*/ print_menu(); return 0; } } } return 0; } void print_menu() { printf("Sleep delays execution until the next command\nUsage:sleep [seconds] OR sleep p [milliseconds]\nExample: sleep 5 sleeps for 5 seconds\n"); printf("Example: sleep p 500 : sleeps for half a second (500 milliseconds)\n"); printf("Forrest Heller - forrest@forrestheller.com\n"); system("PAUSE"); }