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