Changeset 3d367ee2 in mainline
- Timestamp:
- 2012-04-01T19:38:04Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e4fbccd
- Parents:
- d9faae91
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/sleep/sleep.c
rd9faae91 r3d367ee2 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <stdio.h> 30 31 #include <stdlib.h> 32 #include <unistd.h> 31 33 #include "config.h" 32 34 #include "util.h" … … 41 43 void help_cmd_sleep(unsigned int level) 42 44 { 43 printf("This is the %s help for '%s'.\n", 44 level ? EXT_HELP : SHORT_HELP, cmdname); 45 if (level == HELP_SHORT) { 46 printf("`%s' pauses for a given time interval\n", cmdname); 47 } else { 48 help_cmd_sleep(HELP_SHORT); 49 printf( 50 "Usage: %s <duration>\n" 51 "The duration is an integer number of seconds.\n", 52 cmdname); 53 } 54 45 55 return; 46 56 } … … 49 59 int cmd_sleep(char **argv) 50 60 { 61 int ret; 51 62 unsigned int argc; 52 u nsigned int i;63 uint32_t duration; 53 64 54 65 /* Count the arguments */ 55 for (argc = 0; argv[argc] != NULL; argc ++);66 argc = cli_count_args(argv); 56 67 57 printf("%s %s\n", TEST_ANNOUNCE, cmdname); 58 printf("%d arguments passed to %s", argc - 1, cmdname); 59 60 if (argc < 2) { 61 printf("\n"); 62 return CMD_SUCCESS; 68 if (argc != 2) { 69 printf("%s - incorrect number of arguments. Try `help %s'\n", 70 cmdname, cmdname); 71 return CMD_FAILURE; 63 72 } 64 73 65 printf(":\n"); 66 for (i = 1; i < argc; i++) 67 printf("[%d] -> %s\n", i, argv[i]); 74 ret = str_uint32_t(argv[1], NULL, 10, true, &duration); 75 if (ret != EOK) { 76 printf("%s - invalid duration.\n", cmdname); 77 return CMD_FAILURE; 78 } 79 80 (void) usleep((useconds_t)duration * 1000000); 68 81 69 82 return CMD_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.