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

Function parse_args

dpdk/examples/vdpa/main.c:55–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55static int
56parse_args(int argc, char **argv)
57{
58 static const char *short_option = "i";
59 static struct option long_option[] = {
60 {"iface", required_argument, NULL, 0},
61 {"interactive", no_argument, &interactive, 1},
62 {"client", no_argument, &client_mode, 1},
63 {NULL, 0, 0, 0},
64 };
65 int opt, idx;
66 char *prgname = argv[0];
67
68 while ((opt = getopt_long(argc, argv, short_option, long_option, &idx))
69 != EOF) {
70 switch (opt) {
71 case 'i':
72 printf("Interactive-mode selected\n");
73 interactive = 1;
74 break;
75 /* long options */
76 case 0:
77 if (strncmp(long_option[idx].name, "iface",
78 MAX_PATH_LEN) == 0) {
79 rte_strscpy(iface, optarg, MAX_PATH_LEN);
80 printf("iface %s\n", iface);
81 }
82 if (!strcmp(long_option[idx].name, "interactive")) {
83 printf("Interactive-mode selected\n");
84 interactive = 1;
85 }
86 break;
87
88 default:
89 vdpa_usage(prgname);
90 return -1;
91 }
92 }
93
94 if (iface[0] == '\0' && interactive == 0) {
95 vdpa_usage(prgname);
96 return -1;
97 }
98
99 return 0;
100}
101
102static int
103new_device(int vid)

Callers 1

mainFunction · 0.70

Calls 6

getopt_longFunction · 0.85
strncmpFunction · 0.85
rte_strscpyFunction · 0.85
strcmpFunction · 0.85
vdpa_usageFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected