static int output_sockets_list(struct socket_info *socket_infos, size_t cs) {
_cleanup_(table_unrefp) Table *table = NULL;
- const char *on, *off;
int r;
table = table_new("listen", "type", "unit", "activates");
r = table_add_cell(table, NULL, TABLE_STRV, s->triggered);
if (r < 0)
return table_log_add_error(r);
-
}
-
- on = ansi_highlight();
- off = ansi_normal();
- } else {
- on = ansi_highlight_red();
- off = ansi_normal();
}
r = output_table(table);
return r;
if (arg_legend != 0) {
+ const char *on, *off;
+
+ on = cs > 0 ? ansi_highlight() : ansi_highlight_red();
+ off = ansi_normal();
+
printf("\n%s%zu sockets listed.%s\n", on, cs, off);
if (!arg_all)
printf("Pass --all to see loaded but inactive sockets, too.\n");
static int output_timers_list(struct timer_info *timer_infos, size_t n) {
_cleanup_(table_unrefp) Table *table = NULL;
- const char *on, *off;
int r;
assert(timer_infos || n == 0);
return table_log_add_error(r);
}
- if (n > 0) {
- on = ansi_highlight();
- off = ansi_normal();
- } else {
- on = ansi_highlight_red();
- off = ansi_normal();
- }
-
r = output_table(table);
if (r < 0)
return r;
if (arg_legend != 0) {
+ const char *on, *off;
+
+ on = n > 0 ? ansi_highlight() : ansi_highlight_red();
+ off = ansi_normal();
+
printf("\n%s%zu timers listed.%s\n", on, n, off);
if (!arg_all)
printf("Pass --all to see loaded but inactive timers, too.\n");