Changes in uspace/app/nettest1/nettest1.c [2721a75:849ed54] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest1/nettest1.c
r2721a75 r849ed54 40 40 #include <task.h> 41 41 #include <time.h> 42 #include <arg_parse.h>43 42 44 43 #include <in.h> … … 47 46 #include <socket.h> 48 47 #include <net_err.h> 49 #include <socket_parse.h>50 48 51 49 #include "nettest.h" 50 #include "parse.h" 52 51 #include "print_error.h" 53 52 … … 106 105 struct timeval time_after; 107 106 107 // print the program label 108 printf("Task %d - ", task_get_id()); 109 printf("%s\n", NAME); 110 108 111 // parse the command line arguments 109 112 // stop before the last argument if it does not start with the minus sign ('-') … … 114 117 // short options with only one letter 115 118 case 'f': 116 ERROR_PROPAGATE( arg_parse_name_int(argc, argv, &index, &family, 0, socket_parse_protocol_family));119 ERROR_PROPAGATE(parse_parameter_name_int(argc, argv, &index, &family, "protocol family", 0, parse_protocol_family)); 117 120 break; 118 121 case 'h': … … 121 124 break; 122 125 case 'm': 123 ERROR_PROPAGATE( arg_parse_int(argc, argv, &index, &messages, 0));126 ERROR_PROPAGATE(parse_parameter_int(argc, argv, &index, &messages, "message count", 0)); 124 127 break; 125 128 case 'n': 126 ERROR_PROPAGATE( arg_parse_int(argc, argv, &index, &sockets, 0));129 ERROR_PROPAGATE(parse_parameter_int(argc, argv, &index, &sockets, "socket count", 0)); 127 130 break; 128 131 case 'p': 129 ERROR_PROPAGATE( arg_parse_int(argc, argv, &index, &value, 0));132 ERROR_PROPAGATE(parse_parameter_int(argc, argv, &index, &value, "port number", 0)); 130 133 port = (uint16_t) value; 131 134 break; 132 135 case 's': 133 ERROR_PROPAGATE( arg_parse_int(argc, argv, &index, &value, 0));136 ERROR_PROPAGATE(parse_parameter_int(argc, argv, &index, &value, "packet size", 0)); 134 137 size = (value >= 0) ? (size_t) value : 0; 135 138 break; 136 139 case 't': 137 ERROR_PROPAGATE( arg_parse_name_int(argc, argv, &index, &value, 0, socket_parse_socket_type));140 ERROR_PROPAGATE(parse_parameter_name_int(argc, argv, &index, &value, "socket type", 0, parse_socket_type)); 138 141 type = (sock_type_t) value; 139 142 break; … … 144 147 case '-': 145 148 if(str_lcmp(argv[index] + 2, "family=", 7) == 0){ 146 ERROR_PROPAGATE( arg_parse_name_int(argc, argv, &index, &family, 9, socket_parse_protocol_family));149 ERROR_PROPAGATE(parse_parameter_name_int(argc, argv, &index, &family, "protocol family", 9, parse_protocol_family)); 147 150 }else if(str_lcmp(argv[index] + 2, "help", 5) == 0){ 148 151 nettest1_print_help(); 149 152 return EOK; 150 153 }else if(str_lcmp(argv[index] + 2, "messages=", 6) == 0){ 151 ERROR_PROPAGATE( arg_parse_int(argc, argv, &index, &messages, 8));154 ERROR_PROPAGATE(parse_parameter_int(argc, argv, &index, &messages, "message count", 8)); 152 155 }else if(str_lcmp(argv[index] + 2, "sockets=", 6) == 0){ 153 ERROR_PROPAGATE( arg_parse_int(argc, argv, &index, &sockets, 8));156 ERROR_PROPAGATE(parse_parameter_int(argc, argv, &index, &sockets, "socket count", 8)); 154 157 }else if(str_lcmp(argv[index] + 2, "port=", 5) == 0){ 155 ERROR_PROPAGATE( arg_parse_int(argc, argv, &index, &value, 7));158 ERROR_PROPAGATE(parse_parameter_int(argc, argv, &index, &value, "port number", 7)); 156 159 port = (uint16_t) value; 157 160 }else if(str_lcmp(argv[index] + 2, "type=", 5) == 0){ 158 ERROR_PROPAGATE( arg_parse_name_int(argc, argv, &index, &value, 7, socket_parse_socket_type));161 ERROR_PROPAGATE(parse_parameter_name_int(argc, argv, &index, &value, "socket type", 7, parse_socket_type)); 159 162 type = (sock_type_t) value; 160 163 }else if(str_lcmp(argv[index] + 2, "verbose", 8) == 0){ 161 164 verbose = 1; 162 165 }else{ 166 print_unrecognized(index, argv[index] + 2); 163 167 nettest1_print_help(); 164 168 return EINVAL; … … 166 170 break; 167 171 default: 172 print_unrecognized(index, argv[index] + 1); 168 173 nettest1_print_help(); 169 174 return EINVAL; 170 175 } 171 176 }else{ 177 print_unrecognized(index, argv[index]); 172 178 nettest1_print_help(); 173 179 return EINVAL;
Note:
See TracChangeset
for help on using the changeset viewer.