Changeset 2721a75 in mainline for uspace/app/netecho/netecho.c
- Timestamp:
- 2010-04-09T16:29:07Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1ef0fc3
- Parents:
- ddfcfeb2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/netecho/netecho.c
rddfcfeb2 r2721a75 40 40 #include <str.h> 41 41 #include <task.h> 42 #include <arg_parse.h> 42 43 43 44 #include <in.h> … … 46 47 #include <socket.h> 47 48 #include <net_err.h> 48 49 #include "parse.h" 49 #include <socket_parse.h> 50 50 51 #include "print_error.h" 51 52 … … 133 134 switch(argv[index][1]){ 134 135 case 'b': 135 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &backlog, "accepted sockets queue size", 0));136 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &backlog, 0)); 136 137 break; 137 138 case 'c': 138 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &count, "message count", 0));139 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &count, 0)); 139 140 break; 140 141 case 'f': 141 ERROR_PROPAGATE( parse_parameter_name_int(argc, argv, &index, &family, "protocol family", 0,parse_protocol_family));142 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 0, socket_parse_protocol_family)); 142 143 break; 143 144 case 'h': … … 146 147 break; 147 148 case 'p': 148 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &value, "port number", 0));149 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0)); 149 150 port = (uint16_t) value; 150 151 break; 151 152 case 'r': 152 ERROR_PROPAGATE( parse_parameter_string(argc, argv, &index, &reply, "reply string", 0));153 ERROR_PROPAGATE(arg_parse_string(argc, argv, &index, &reply, 0)); 153 154 break; 154 155 case 's': 155 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &value, "receive size", 0));156 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 0)); 156 157 size = (value >= 0) ? (size_t) value : 0; 157 158 break; 158 159 case 't': 159 ERROR_PROPAGATE( parse_parameter_name_int(argc, argv, &index, &value, "socket type", 0,parse_socket_type));160 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 0, socket_parse_socket_type)); 160 161 type = (sock_type_t) value; 161 162 break; … … 166 167 case '-': 167 168 if(str_lcmp(argv[index] + 2, "backlog=", 6) == 0){ 168 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &backlog, "accepted sockets queue size", 8));169 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &backlog, 8)); 169 170 }else if(str_lcmp(argv[index] + 2, "count=", 6) == 0){ 170 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &count, "message count", 8));171 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &count, 8)); 171 172 }else if(str_lcmp(argv[index] + 2, "family=", 7) == 0){ 172 ERROR_PROPAGATE( parse_parameter_name_int(argc, argv, &index, &family, "protocol family", 9,parse_protocol_family));173 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &family, 9, socket_parse_protocol_family)); 173 174 }else if(str_lcmp(argv[index] + 2, "help", 5) == 0){ 174 175 echo_print_help(); 175 176 return EOK; 176 177 }else if(str_lcmp(argv[index] + 2, "port=", 5) == 0){ 177 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &value, "port number", 7));178 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 7)); 178 179 port = (uint16_t) value; 179 180 }else if(str_lcmp(argv[index] + 2, "reply=", 6) == 0){ 180 ERROR_PROPAGATE( parse_parameter_string(argc, argv, &index, &reply, "reply string", 8));181 ERROR_PROPAGATE(arg_parse_string(argc, argv, &index, &reply, 8)); 181 182 }else if(str_lcmp(argv[index] + 2, "size=", 5) == 0){ 182 ERROR_PROPAGATE( parse_parameter_int(argc, argv, &index, &value, "receive size", 7));183 ERROR_PROPAGATE(arg_parse_int(argc, argv, &index, &value, 7)); 183 184 size = (value >= 0) ? (size_t) value : 0; 184 185 }else if(str_lcmp(argv[index] + 2, "type=", 5) == 0){ 185 ERROR_PROPAGATE( parse_parameter_name_int(argc, argv, &index, &value, "socket type", 7,parse_socket_type));186 ERROR_PROPAGATE(arg_parse_name_int(argc, argv, &index, &value, 7, socket_parse_socket_type)); 186 187 type = (sock_type_t) value; 187 188 }else if(str_lcmp(argv[index] + 2, "verbose", 8) == 0){ 188 189 verbose = 1; 189 190 }else{ 190 print_unrecognized(index, argv[index] + 2);191 191 echo_print_help(); 192 192 return EINVAL; … … 194 194 break; 195 195 default: 196 print_unrecognized(index, argv[index] + 1);197 196 echo_print_help(); 198 197 return EINVAL; 199 198 } 200 199 }else{ 201 print_unrecognized(index, argv[index]);202 200 echo_print_help(); 203 201 return EINVAL;
Note:
See TracChangeset
for help on using the changeset viewer.