diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-07-16 16:03:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-16 16:03:54 +0200 |
commit | c1b71f3a61eccf282f99cc226ae1fcf7ed46c21e (patch) | |
tree | 83e540010537b58cb68970f5400b4947703bcfac /src/shared/format-table.c | |
parent | Merge pull request #13073 from poettering/variety-galore (diff) | |
parent | analyze: port over one part of systemd-analyze to use new table_add_many() co... (diff) | |
download | systemd-c1b71f3a61eccf282f99cc226ae1fcf7ed46c21e.tar.xz systemd-c1b71f3a61eccf282f99cc226ae1fcf7ed46c21e.zip |
Merge pull request #13074 from poettering/format-tree-many
table_add_many() improvements
Diffstat (limited to 'src/shared/format-table.c')
-rw-r--r-- | src/shared/format-table.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 11e4d56729..aede59bf34 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -681,6 +681,7 @@ int table_update(Table *t, TableCell *cell, TableDataType type, const void *data int table_add_many_internal(Table *t, TableDataType first_type, ...) { TableDataType type; va_list ap; + TableCell *last_cell = NULL; int r; assert(t); @@ -776,6 +777,55 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) { data = &buffer.ifindex; break; + case TABLE_SET_MINIMUM_WIDTH: { + size_t w = va_arg(ap, size_t); + + r = table_set_minimum_width(t, last_cell, w); + break; + } + + case TABLE_SET_MAXIMUM_WIDTH: { + size_t w = va_arg(ap, size_t); + r = table_set_maximum_width(t, last_cell, w); + break; + } + + case TABLE_SET_WEIGHT: { + unsigned w = va_arg(ap, unsigned); + r = table_set_weight(t, last_cell, w); + break; + } + + case TABLE_SET_ALIGN_PERCENT: { + unsigned p = va_arg(ap, unsigned); + r = table_set_align_percent(t, last_cell, p); + break; + } + + case TABLE_SET_ELLIPSIZE_PERCENT: { + unsigned p = va_arg(ap, unsigned); + r = table_set_ellipsize_percent(t, last_cell, p); + break; + } + + case TABLE_SET_COLOR: { + const char *c = va_arg(ap, const char*); + r = table_set_color(t, last_cell, c); + break; + } + + case TABLE_SET_URL: { + const char *u = va_arg(ap, const char*); + r = table_set_url(t, last_cell, u); + break; + } + + case TABLE_SET_UPPERCASE: { + int u = va_arg(ap, int); + r = table_set_uppercase(t, last_cell, u); + break; + } + case _TABLE_DATA_TYPE_MAX: /* Used as end marker */ va_end(ap); @@ -785,7 +835,9 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) { assert_not_reached("Uh? Unexpected data type."); } - r = table_add_cell(t, NULL, type, data); + if (type < _TABLE_DATA_TYPE_MAX) + r = table_add_cell(t, &last_cell, type, data); + if (r < 0) { va_end(ap); return r; |