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

Function proc_info_preparse_args

dpdk/app/proc-info/main.c:384–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384static int
385proc_info_preparse_args(int argc, char **argv)
386{
387 char *prgname = argv[0];
388 int i;
389
390 for (i = 0; i < argc; i++) {
391 /* Print stats or xstats to STDOUT in collectd format */
392 if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) {
393 enable_collectd_format = 1;
394 stdout_fd = dup(STDOUT_FILENO);
395 close(STDOUT_FILENO);
396 }
397 if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
398 if ((i + 1) == argc) {
399 printf("Invalid host id or not specified\n");
400 proc_info_usage(prgname);
401 return -1;
402 }
403 strlcpy(host_id, argv[i + 1], sizeof(host_id));
404 }
405 }
406
407 if (!strlen(host_id)) {
408 int err = gethostname(host_id, MAX_LONG_OPT_SZ-1);
409
410 if (err)
411 strlcpy(host_id, "unknown", sizeof(host_id));
412 }
413
414 return 0;
415}
416
417/* Parse the argument given in the command line of the application */
418static int

Callers 1

mainFunction · 0.85

Calls 6

strncmpFunction · 0.85
proc_info_usageFunction · 0.85
closeFunction · 0.50
printfFunction · 0.50
strlcpyFunction · 0.50
gethostnameFunction · 0.50

Tested by

no test coverage detected