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

Function parse_args

dpdk/examples/distributor/main.c:720–766  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

718
719/* Parse the argument given in the command line of the application */
720static int
721parse_args(int argc, char **argv)
722{
723 int opt;
724 char **argvopt;
725 int option_index;
726 char *prgname = argv[0];
727 static struct option lgopts[] = {
728 {NULL, 0, 0, 0}
729 };
730
731 argvopt = argv;
732 enable_lcore_rx_distributor = false;
733 while ((opt = getopt_long(argc, argvopt, "cp:",
734 lgopts, &option_index)) != EOF) {
735
736 switch (opt) {
737 /* portmask */
738 case 'p':
739 enabled_port_mask = parse_portmask(optarg);
740 if (enabled_port_mask == 0) {
741 printf("invalid portmask\n");
742 print_usage(prgname);
743 return -1;
744 }
745 break;
746
747 case 'c':
748 enable_lcore_rx_distributor = true;
749 break;
750
751 default:
752 print_usage(prgname);
753 return -1;
754 }
755 }
756
757 if (optind <= 1) {
758 print_usage(prgname);
759 return -1;
760 }
761
762 argv[optind-1] = prgname;
763
764 optind = 1; /* reset getopt lib */
765 return 0;
766}
767
768/* Main function, does initialization and calls the per-lcore functions */
769int

Callers 1

mainFunction · 0.70

Calls 4

getopt_longFunction · 0.85
parse_portmaskFunction · 0.70
print_usageFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected