Changeset d8e3467 in mainline
- Timestamp:
- 2010-04-18T00:22:35Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9dae191e
- Parents:
- c39a103
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/ping/ping.c
rc39a103 rd8e3467 132 132 } 133 133 134 static int arg_short_long(const char *arg, const char *ashort,135 const char *along)136 {137 if (str_cmp(arg, ashort) == 0)138 return 0;139 140 if (str_lcmp(arg, along, str_length(along)) == 0)141 return str_length(along);142 143 return -1;144 }145 146 134 static int args_parse(int argc, char *argv[], ping_config_t *config) 147 135 { … … 165 153 166 154 int off; 167 int tmp;168 155 169 156 /* Usage */ 170 if ((off = arg_ short_long(argv[i], "-h", "--help")) != -1)157 if ((off = arg_parse_short_long(argv[i], "-h", "--help")) != -1) 171 158 return CL_USAGE; 172 159 173 160 /* Verbose */ 174 if ((off = arg_ short_long(argv[i], "-v", "--verbose")) != -1) {161 if ((off = arg_parse_short_long(argv[i], "-v", "--verbose")) != -1) { 175 162 config->verbose = true; 176 163 continue; … … 184 171 185 172 /* Count */ 186 if ((off = arg_short_long(argv[i], "-c", "--count=")) != -1) { 173 if ((off = arg_parse_short_long(argv[i], "-c", "--count=")) != -1) { 174 int tmp; 187 175 ret = arg_parse_int(argc, argv, &i, &tmp, off); 188 176 … … 195 183 196 184 /* Outgoing packet size */ 197 if ((off = arg_short_long(argv[i], "-s", "--size=")) != -1) { 185 if ((off = arg_parse_short_long(argv[i], "-s", "--size=")) != -1) { 186 int tmp; 198 187 ret = arg_parse_int(argc, argv, &i, &tmp, off); 199 188 … … 206 195 207 196 /* Reply wait timeout */ 208 if ((off = arg_short_long(argv[i], "-W", "--timeout=")) != -1) { 197 if ((off = arg_parse_short_long(argv[i], "-W", "--timeout=")) != -1) { 198 int tmp; 209 199 ret = arg_parse_int(argc, argv, &i, &tmp, off); 210 200 … … 217 207 218 208 /* Address family */ 219 if ((off = arg_ short_long(argv[i], "-f", "--family=")) != -1) {209 if ((off = arg_parse_short_long(argv[i], "-f", "--family=")) != -1) { 220 210 ret = arg_parse_name_int(argc, argv, &i, &config->af, off, 221 211 socket_parse_address_family); … … 228 218 229 219 /* Type of service */ 230 if ((off = arg_short_long(argv[i], "-Q", "--tos=")) != -1) { 220 if ((off = arg_parse_short_long(argv[i], "-Q", "--tos=")) != -1) { 221 int tmp; 231 222 ret = arg_parse_name_int(argc, argv, &i, &tmp, off, 232 223 socket_parse_address_family); … … 240 231 241 232 /* Time to live */ 242 if ((off = arg_short_long(argv[i], "-t", "--ttl=")) != -1) { 233 if ((off = arg_parse_short_long(argv[i], "-t", "--ttl=")) != -1) { 234 int tmp; 243 235 ret = arg_parse_name_int(argc, argv, &i, &tmp, off, 244 236 socket_parse_address_family); -
uspace/lib/c/generic/arg_parse.c
rc39a103 rd8e3467 34 34 #include <errno.h> 35 35 #include <str.h> 36 37 int arg_parse_short_long(const char *arg, const char *ashort, const char *along) 38 { 39 if (str_cmp(arg, ashort) == 0) 40 return 0; 41 42 if (str_lcmp(arg, along, str_length(along)) == 0) 43 return str_length(along); 44 45 return -1; 46 } 36 47 37 48 /** Parse the next argument as an integer. -
uspace/lib/c/include/arg_parse.h
rc39a103 rd8e3467 38 38 typedef int (*arg_parser)(const char *, int *); 39 39 40 extern int arg_parse_short_long(const char *, const char *, const char *); 40 41 extern int arg_parse_int(int, char **, int *, int *, int); 41 42 extern int arg_parse_name_int(int, char **, int *, int *, int, arg_parser);
Note:
See TracChangeset
for help on using the changeset viewer.