MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lsi_parse_args

Function lsi_parse_args

dpdk/examples/link_status_interrupt/main.c:360–426  ·  view source on GitHub ↗

Parse the argument given in the command line of the application */

Source from the content-addressed store, hash-verified

358
359/* Parse the argument given in the command line of the application */
360static int
361lsi_parse_args(int argc, char **argv)
362{
363 int opt, ret;
364 char **argvopt;
365 int option_index;
366 char *prgname = argv[0];
367 static struct option lgopts[] = {
368 {NULL, 0, 0, 0}
369 };
370
371 timer_period = DEFAULT_TIMER_PERIOD * TIMER_MILLISECOND * 1000;
372
373 argvopt = argv;
374
375 while ((opt = getopt_long(argc, argvopt, "p:q:T:",
376 lgopts, &option_index)) != EOF) {
377
378 switch (opt) {
379 /* portmask */
380 case 'p':
381 lsi_enabled_port_mask = lsi_parse_portmask(optarg);
382 if (lsi_enabled_port_mask == 0) {
383 printf("invalid portmask\n");
384 lsi_usage(prgname);
385 return -1;
386 }
387 break;
388
389 /* nqueue */
390 case 'q':
391 lsi_rx_queue_per_lcore = lsi_parse_nqueue(optarg);
392 if (lsi_rx_queue_per_lcore == 0) {
393 printf("invalid queue number\n");
394 lsi_usage(prgname);
395 return -1;
396 }
397 break;
398
399 /* timer period */
400 case 'T':
401 timer_period = lsi_parse_timer_period(optarg) * 1000 * TIMER_MILLISECOND;
402 if (timer_period < 0) {
403 printf("invalid timer period\n");
404 lsi_usage(prgname);
405 return -1;
406 }
407 break;
408
409 /* long options */
410 case 0:
411 lsi_usage(prgname);
412 return -1;
413
414 default:
415 lsi_usage(prgname);
416 return -1;
417 }

Callers 1

mainFunction · 0.85

Calls 6

getopt_longFunction · 0.85
lsi_parse_portmaskFunction · 0.85
lsi_usageFunction · 0.85
lsi_parse_nqueueFunction · 0.85
lsi_parse_timer_periodFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected