MCPcopy Create free account
hub / github.com/coreutils/coreutils / decode_output_arg

Function decode_output_arg

src/df.c:429–499  ·  view source on GitHub ↗

Given a string, ARG, containing a comma-separated list of arguments to the --output option, add the appropriate fields to columns. */

Source from the content-addressed store, hash-verified

427/* Given a string, ARG, containing a comma-separated list of arguments
428 to the --output option, add the appropriate fields to columns. */
429static void
430decode_output_arg (char const *arg)
431{
432 char *arg_writable = xstrdup (arg);
433 char *s = arg_writable;
434 do
435 {
436 /* find next comma */
437 char *comma = strchr (s, ',');
438
439 /* If we found a comma, put a NUL in its place and advance. */
440 if (comma)
441 *comma++ = 0;
442
443 /* process S. */
444 display_field_t field = INVALID_FIELD;
445 for (idx_t i = 0; i < countof (field_data); i++)
446 {
447 if (streq (field_data[i].arg, s))
448 {
449 field = i;
450 break;
451 }
452 }
453 if (field == INVALID_FIELD)
454 {
455 error (0, 0, _("option --output: field %s unknown"), quote (s));
456 usage (EXIT_FAILURE);
457 }
458
459 if (field_data[field].used)
460 {
461 /* Prevent the fields from being used more than once. */
462 error (0, 0, _("option --output: field %s used more than once"),
463 quote (field_data[field].arg));
464 usage (EXIT_FAILURE);
465 }
466
467 switch (field)
468 {
469 case SOURCE_FIELD:
470 case FSTYPE_FIELD:
471 case USED_FIELD:
472 case PCENT_FIELD:
473 case ITOTAL_FIELD:
474 case IUSED_FIELD:
475 case IAVAIL_FIELD:
476 case IPCENT_FIELD:
477 case TARGET_FIELD:
478 case FILE_FIELD:
479 alloc_field (field, NULL);
480 break;
481
482 case SIZE_FIELD:
483 alloc_field (field, N_("Size"));
484 break;
485
486 case AVAIL_FIELD:

Callers 2

get_field_listFunction · 0.85
mainFunction · 0.85

Calls 2

alloc_fieldFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected