if (details_table) {
const char *checkmark, *description, *color = NULL;
- TableCell *cell;
if (badness == UINT64_MAX) {
checkmark = " ";
if (d)
description = d;
- r = table_add_cell_full(details_table, &cell, TABLE_STRING, checkmark, 1, 1, 0, 0, 0);
- if (r < 0)
- return log_error_errno(r, "Failed to add cell to table: %m");
- if (color)
- (void) table_set_color(details_table, cell, color);
-
r = table_add_many(details_table,
+ TABLE_STRING, checkmark,
+ TABLE_SET_MINIMUM_WIDTH, 1,
+ TABLE_SET_MAXIMUM_WIDTH, 1,
+ TABLE_SET_ELLIPSIZE_PERCENT, 0,
+ TABLE_SET_COLOR, color,
TABLE_STRING, a->id, TABLE_SET_URL, a->url,
TABLE_STRING, description,
TABLE_UINT64, a->weight, TABLE_SET_ALIGN_PERCENT, 100,
TABLE_UINT64, a->range, TABLE_SET_ALIGN_PERCENT, 100,
TABLE_EMPTY, TABLE_SET_ALIGN_PERCENT, 100);
if (r < 0)
- return log_error_errno(r, "Failed to add cells to table: %m");
+ return table_log_add_error(r);
}
}
if (overview_table) {
char buf[DECIMAL_STR_MAX(uint64_t) + 1 + DECIMAL_STR_MAX(uint64_t) + 1];
- TableCell *cell;
+ _cleanup_free_ char *url = NULL;
- r = table_add_cell(overview_table, &cell, TABLE_STRING, info->id);
- if (r < 0)
- return log_error_errno(r, "Failed to add cell to table: %m");
if (info->fragment_path) {
- _cleanup_free_ char *url = NULL;
-
r = file_url_from_path(info->fragment_path, &url);
if (r < 0)
return log_error_errno(r, "Failed to generate URL from path: %m");
-
- (void) table_set_url(overview_table, cell, url);
}
xsprintf(buf, "%" PRIu64 ".%" PRIu64, exposure / 10, exposure % 10);
- r = table_add_cell(overview_table, &cell, TABLE_STRING, buf);
- if (r < 0)
- return log_error_errno(r, "Failed to add cell to table: %m");
- (void) table_set_align_percent(overview_table, cell, 100);
-
- r = table_add_cell(overview_table, &cell, TABLE_STRING, badness_table[i].name);
- if (r < 0)
- return log_error_errno(r, "Failed to add cell to table: %m");
- (void) table_set_color(overview_table, cell, strempty(badness_table[i].color));
- r = table_add_cell(overview_table, NULL, TABLE_STRING, special_glyph(badness_table[i].smiley));
+ r = table_add_many(overview_table,
+ TABLE_STRING, info->id,
+ TABLE_SET_URL, url,
+ TABLE_STRING, buf,
+ TABLE_SET_ALIGN_PERCENT, 100,
+ TABLE_STRING, badness_table[i].name,
+ TABLE_SET_COLOR, strempty(badness_table[i].color),
+ TABLE_STRING, special_glyph(badness_table[i].smiley));
if (r < 0)
- return log_error_errno(r, "Failed to add cell to table: %m");
+ return table_log_add_error(r);
}
return 0;
if (u->time <= 0)
continue;
- r = table_add_cell(table, NULL, TABLE_TIMESPAN_MSEC, &u->time);
+ r = table_add_many(table,
+ TABLE_TIMESPAN_MSEC, &u->time,
+ TABLE_STRING, u->name);
if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_STRING, u->name);
- if (r < 0)
- return r;
+ return table_log_add_error(r);
}
(void) pager_open(arg_pager_flags);
TABLE_INT, (int) i,
TABLE_STRING, exit_status_class(i));
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
else
for (int i = 1; i < argc; i++) {
TABLE_INT, status,
TABLE_STRING, exit_status_class(status) ?: "-");
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
(void) pager_open(arg_pager_flags);
if (r < 0)
return r;
- r = table_add_cell(table, NULL, TABLE_STRING, "Original:");
+ r = table_add_many(table,
+ TABLE_STRING, "Original:",
+ TABLE_STRING, *input_timespan);
if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_STRING, *input_timespan);
- if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_add_cell_stringf(table, NULL, "%ss:", special_glyph(SPECIAL_GLYPH_MU));
if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_UINT64, &output_usecs);
- if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_STRING, "Human:");
- if (r < 0)
- return r;
+ return table_log_add_error(r);
- r = table_add_cell(table, &cell, TABLE_TIMESPAN, &output_usecs);
+ r = table_add_many(table,
+ TABLE_UINT64, &output_usecs,
+ TABLE_STRING, "Human:",
+ TABLE_TIMESPAN, &output_usecs,
+ TABLE_SET_COLOR, ansi_highlight());
if (r < 0)
- return r;
-
- r = table_set_color(table, cell, ansi_highlight());
- if (r < 0)
- return r;
+ return table_log_add_error(r);
r = table_print(table, NULL);
if (r < 0)
if (r < 0)
return r;
- r = table_add_cell(table, NULL, TABLE_STRING, "Original form:");
- if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_STRING, p);
- if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_STRING, "Normalized form:");
+ r = table_add_many(table,
+ TABLE_STRING, "Original form:",
+ TABLE_STRING, p,
+ TABLE_STRING, "Normalized form:",
+ TABLE_TIMESTAMP, &usec,
+ TABLE_SET_COLOR, ansi_highlight_blue());
if (r < 0)
- return r;
-
- r = table_add_cell(table, &cell, TABLE_TIMESTAMP, &usec);
- if (r < 0)
- return r;
-
- r = table_set_color(table, cell, ansi_highlight_blue());
- if (r < 0)
- return r;
+ return table_log_add_error(r);
if (!in_utc_timezone()) {
- r = table_add_cell(table, NULL, TABLE_STRING, "(in UTC):");
+ r = table_add_many(table,
+ TABLE_STRING, "(in UTC):",
+ TABLE_TIMESTAMP_UTC, &usec);
if (r < 0)
- return r;
-
- r = table_add_cell(table, &cell, TABLE_TIMESTAMP_UTC, &usec);
- if (r < 0)
- return r;
+ return table_log_add_error(r);
}
r = table_add_cell(table, NULL, TABLE_STRING, "UNIX seconds:");
if (r < 0)
- return r;
+ return table_log_add_error(r);
if (usec % USEC_PER_SEC == 0)
- r = table_add_cell_stringf(table, &cell, "@%"PRI_USEC,
+ r = table_add_cell_stringf(table, NULL, "@%"PRI_USEC,
usec / USEC_PER_SEC);
else
- r = table_add_cell_stringf(table, &cell, "@%"PRI_USEC".%06"PRI_USEC"",
+ r = table_add_cell_stringf(table, NULL, "@%"PRI_USEC".%06"PRI_USEC"",
usec / USEC_PER_SEC,
usec % USEC_PER_SEC);
if (r < 0)
return r;
- r = table_add_cell(table, NULL, TABLE_STRING, "From now:");
+ r = table_add_many(table,
+ TABLE_STRING, "From now:",
+ TABLE_TIMESTAMP_RELATIVE, &usec);
if (r < 0)
- return r;
-
- r = table_add_cell(table, &cell, TABLE_TIMESTAMP_RELATIVE, &usec);
- if (r < 0)
- return r;
+ return table_log_add_error(r);
return table_print(table, NULL);
}
return r;
if (!streq(t, p)) {
- r = table_add_cell(table, NULL, TABLE_STRING, "Original form:");
- if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_STRING, p);
+ r = table_add_many(table,
+ TABLE_STRING, "Original form:",
+ TABLE_STRING, p);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
- r = table_add_cell(table, NULL, TABLE_STRING, "Normalized form:");
- if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_STRING, t);
+ r = table_add_many(table,
+ TABLE_STRING, "Normalized form:",
+ TABLE_STRING, t);
if (r < 0)
- return r;
+ return table_log_add_error(r);
for (unsigned i = 0; i < arg_iterations; i++) {
usec_t next;
r = calendar_spec_next_usec(spec, n, &next);
if (r == -ENOENT) {
if (i == 0) {
- r = table_add_cell(table, NULL, TABLE_STRING, "Next elapse:");
- if (r < 0)
- return r;
-
- r = table_add_cell(table, &cell, TABLE_STRING, "never");
- if (r < 0)
- return r;
-
- r = table_set_color(table, cell, ansi_highlight_yellow());
+ r = table_add_many(table,
+ TABLE_STRING, "Next elapse:",
+ TABLE_STRING, "never",
+ TABLE_SET_COLOR, ansi_highlight_yellow());
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
break;
}
return log_error_errno(r, "Failed to determine next elapse for '%s': %m", p);
if (i == 0) {
- r = table_add_cell(table, NULL, TABLE_STRING, "Next elapse:");
- if (r < 0)
- return r;
-
- r = table_add_cell(table, &cell, TABLE_TIMESTAMP, &next);
- if (r < 0)
- return r;
-
- r = table_set_color(table, cell, ansi_highlight_blue());
+ r = table_add_many(table,
+ TABLE_STRING, "Next elapse:",
+ TABLE_TIMESTAMP, &next,
+ TABLE_SET_COLOR, ansi_highlight_blue());
if (r < 0)
- return r;
+ return table_log_add_error(r);
} else {
int k = DECIMAL_STR_WIDTH(i + 1);
r = table_add_cell_stringf(table, NULL, "Iter. #%u:", i+1);
if (r < 0)
- return r;
-
- r = table_add_cell(table, &cell, TABLE_TIMESTAMP, &next);
- if (r < 0)
- return r;
+ return table_log_add_error(r);
- r = table_set_color(table, cell, ansi_highlight_blue());
+ r = table_add_many(table,
+ TABLE_TIMESTAMP, &next,
+ TABLE_SET_COLOR, ansi_highlight_blue());
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
if (!in_utc_timezone()) {
- r = table_add_cell(table, NULL, TABLE_STRING, "(in UTC):");
- if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_TIMESTAMP_UTC, &next);
+ r = table_add_many(table,
+ TABLE_STRING, "(in UTC):",
+ TABLE_TIMESTAMP_UTC, &next);
if (r < 0)
- return r;
+ return table_log_add_error(r);
}
- r = table_add_cell(table, NULL, TABLE_STRING, "From now:");
+ r = table_add_many(table,
+ TABLE_STRING, "From now:",
+ TABLE_TIMESTAMP_RELATIVE, &next);
if (r < 0)
- return r;
-
- r = table_add_cell(table, NULL, TABLE_TIMESTAMP_RELATIVE, &next);
- if (r < 0)
- return r;
+ return table_log_add_error(r);
n = next;
}