Browse Source

Make gfsec-split -l output more readable.

When printing the list of available supports, make sure the
descriptions are aligned on the same column.
master
Damien Goutte-Gattat 2 years ago
parent
commit
c1be3e985b
  1. 18
      src/gfsec-split.c

18
src/gfsec-split.c

@ -339,15 +339,25 @@ main(int argc, char **argv)
if ( list_mode ) {
gfsec_supports_list_t *list;
char *schemes[] = { "file", "uuid", "label", "mtp" };
unsigned i;
char fmt[32], name[64];
unsigned i, len, max_len;
list = gfsec_scheme_module_get_supports();
for ( i = max_len = 0; i < list->count; i++ ) {
len = snprintf(NULL, 0, "%s://%s/ ",
schemes[list->supports[i].scheme],
list->supports[i].authority);
if ( len > max_len )
max_len = len;
}
snprintf(fmt, sizeof(fmt), "%%-%ds%%s\n", max_len);
for ( i = 0; i < list->count; i++ ) {
printf("%s://%s/ %s\n",
snprintf(name, sizeof(name), "%s://%s/",
schemes[list->supports[i].scheme],
list->supports[i].authority,
list->supports[i].description);
list->supports[i].authority);
printf(fmt, name, list->supports[i].description);
}
gfsec_support_destroy_list(list);

Loading…
Cancel
Save