Changeset 0aa300d in mainline for uspace/app/sportdmp/sportdmp.c
- Timestamp:
- 2012-07-29T23:08:51Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5ea75f0
- Parents:
- dce39b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sportdmp/sportdmp.c
rdce39b4 r0aa300d 37 37 static void syntax_print(void) 38 38 { 39 fprintf(stderr, "Usage: sportdmp <baud> <device_service>\n");39 fprintf(stderr, "Usage: sportdmp [--baud=<baud>] [device_service]\n"); 40 40 } 41 41 … … 45 45 sysarg_t baud = 9600; 46 46 47 if (argc > 1) { 47 int arg = 1; 48 49 if (argc > arg && str_test_prefix(argv[arg], "--baud=")) { 50 size_t arg_offset = str_lsize(argv[arg], 7); 51 char* arg_str = argv[arg] + arg_offset; 52 if (str_length(arg_str) == 0) { 53 fprintf(stderr, "--baud requires an argument\n"); 54 syntax_print(); 55 return 1; 56 } 48 57 char *endptr; 49 baud = strtol(arg v[1], &endptr, 10);58 baud = strtol(arg_str, &endptr, 10); 50 59 if (*endptr != '\0') { 51 60 fprintf(stderr, "Invalid value for baud\n"); … … 53 62 return 1; 54 63 } 64 arg++; 55 65 } 56 66 57 if (argc > 2) { 58 svc_path = argv[2]; 67 if (argc > arg) { 68 svc_path = argv[arg]; 69 arg++; 59 70 } 60 71 61 if (argc > 3) { 72 if (argc > arg) { 73 fprintf(stderr, "Too many arguments\n"); 62 74 syntax_print(); 63 75 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.