MCPcopy Index your code
hub / github.com/F-Stack/f-stack / setformat

Function setformat

tools/ifconfig/ifconfig.c:374–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374static void setformat(char *input)
375{
376 char *formatstr, *category, *modifier;
377
378 formatstr = strdup(input);
379 while ((category = strsep(&formatstr, ",")) != NULL) {
380 modifier = strchr(category, ':');
381 if (modifier == NULL || modifier[1] == '\0') {
382 warnx("Skipping invalid format specification: %s\n",
383 category);
384 continue;
385 }
386
387 /* Split the string on the separator, then seek past it */
388 modifier[0] = '\0';
389 modifier++;
390
391 if (strcmp(category, "addr") == 0)
392 f_addr = strdup(modifier);
393 else if (strcmp(category, "ether") == 0)
394 f_ether = strdup(modifier);
395 else if (strcmp(category, "inet") == 0)
396 f_inet = strdup(modifier);
397 else if (strcmp(category, "inet6") == 0)
398 f_inet6 = strdup(modifier);
399 }
400 free(formatstr);
401}
402
403#undef ORDERS_SIZE
404

Callers 1

mainFunction · 0.85

Calls 5

strdupFunction · 0.85
strsepFunction · 0.85
strchrFunction · 0.85
strcmpFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected