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

Function args_parse

dpdk/app/test-security-perf/test_security_perf.c:428–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

426}
427
428static void
429args_parse(int argc, char **argv)
430{
431 char **argvopt;
432 int n, opt;
433 int opt_idx;
434
435 static const struct option lgopts[] = {
436 /* Control */
437 { "help", 0, 0, 0 },
438 { "inbound", 0, 0, 0 },
439 { "nb-sess", 1, 0, 0 },
440 { NULL, 0, 0, 0 }
441 };
442
443 argvopt = argv;
444
445 while ((opt = getopt_long(argc, argvopt, "",
446 lgopts, &opt_idx)) != EOF) {
447 switch (opt) {
448 case 0:
449 if (strcmp(lgopts[opt_idx].name, "help") == 0) {
450 usage(argv[0]);
451 exit(EXIT_SUCCESS);
452 }
453
454 if (strcmp(lgopts[opt_idx].name, "nb-sess") == 0) {
455 n = atoi(optarg);
456 if (n >= 0)
457 ctx.nb_sess = n;
458 else
459 rte_exit(EXIT_FAILURE,
460 "nb-sess should be >= 0\n");
461 printf("nb-sess %d / ", ctx.nb_sess);
462 } else if (strcmp(lgopts[opt_idx].name, "inbound") ==
463 0) {
464 ctx.is_inbound = true;
465 printf("inbound / ");
466 }
467
468 break;
469
470 default:
471 usage(argv[0]);
472 rte_exit(EXIT_FAILURE, "Invalid option: %s\n",
473 argv[opt_idx - 1]);
474 break;
475 }
476 }
477
478 printf("\n\n");
479}
480
481int
482main(int argc, char **argv)

Callers 1

mainFunction · 0.70

Calls 5

getopt_longFunction · 0.85
strcmpFunction · 0.85
rte_exitFunction · 0.85
usageFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected