if (a == native_architecture()) {
c = "native";
- color = ANSI_HIGHLIGHT_GREEN;
+ color = ansi_highlight_green();
} else if (a == uname_architecture()) {
c = "uname";
- color = ANSI_HIGHLIGHT;
+ color = ansi_highlight();
#ifdef ARCHITECTURE_SECONDARY
} else if (a == ARCHITECTURE_SECONDARY) {
c = "secondary";
#endif
} else {
c = "foreign";
- color = ANSI_GREY;
+ color = ansi_grey();
}
r = table_add_many(t,
/* Grey out PCRs that are not sensibly initialized */
if (memeqbyte(0, buf, bufsize) ||
memeqbyte(0xFFU, buf, bufsize))
- color = ANSI_GREY;
+ color = ansi_grey();
}
r = table_add_many(table,
static const struct {
uint64_t exposure;
const char *name;
- const char *color;
+ const char* (*color)(void);
SpecialGlyph smiley;
} badness_table[] = {
- { 100, "DANGEROUS", ANSI_HIGHLIGHT_RED, SPECIAL_GLYPH_DEPRESSED_SMILEY },
- { 90, "UNSAFE", ANSI_HIGHLIGHT_RED, SPECIAL_GLYPH_UNHAPPY_SMILEY },
- { 75, "EXPOSED", ANSI_HIGHLIGHT_YELLOW, SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY },
+ { 100, "DANGEROUS", ansi_highlight_red, SPECIAL_GLYPH_DEPRESSED_SMILEY },
+ { 90, "UNSAFE", ansi_highlight_red, SPECIAL_GLYPH_UNHAPPY_SMILEY },
+ { 75, "EXPOSED", ansi_highlight_yellow, SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY },
{ 50, "MEDIUM", NULL, SPECIAL_GLYPH_NEUTRAL_SMILEY },
- { 10, "OK", ANSI_HIGHLIGHT_GREEN, SPECIAL_GLYPH_SLIGHTLY_HAPPY_SMILEY },
- { 1, "SAFE", ANSI_HIGHLIGHT_GREEN, SPECIAL_GLYPH_HAPPY_SMILEY },
- { 0, "PERFECT", ANSI_HIGHLIGHT_GREEN, SPECIAL_GLYPH_ECSTATIC_SMILEY },
+ { 10, "OK", ansi_highlight_green, SPECIAL_GLYPH_SLIGHTLY_HAPPY_SMILEY },
+ { 1, "SAFE", ansi_highlight_green, SPECIAL_GLYPH_HAPPY_SMILEY },
+ { 0, "PERFECT", ansi_highlight_green, SPECIAL_GLYPH_ECSTATIC_SMILEY },
};
uint64_t badness_sum = 0, weight_sum = 0, exposure;
ansi_highlight(),
name,
ansi_normal(),
- colors_enabled() ? strempty(badness_table[i].color) : "",
+ badness_table[i].color ? badness_table[i].color() : "",
exposure / 10, exposure % 10,
badness_table[i].name,
ansi_normal(),
TABLE_STRING, buf,
TABLE_SET_ALIGN_PERCENT, 100,
TABLE_STRING, badness_table[i].name,
- TABLE_SET_COLOR, strempty(badness_table[i].color),
+ TABLE_SET_COLOR, badness_table[i].color ? badness_table[i].color() : "",
TABLE_STRING, special_glyph(badness_table[i].smiley));
if (r < 0)
return table_log_add_error(r);
[COLOR_COMMENT] = ANSI_GREY,
};
+ static const char* const color_16_table[_COLOR_MAX] = {
+ [COLOR_SYMBOL_TYPE] = ANSI_HIGHLIGHT_GREEN,
+ [COLOR_FIELD_TYPE] = ANSI_HIGHLIGHT_BLUE,
+ [COLOR_IDENTIFIER] = ANSI_NORMAL,
+ [COLOR_MARKS] = ANSI_HIGHLIGHT_MAGENTA,
+ [COLOR_RESET] = ANSI_NORMAL,
+ [COLOR_COMMENT] = ANSI_BRIGHT_BLACK,
+ };
+
static const char* const color_off[_COLOR_MAX] = {
"", "", "", "", "", "",
};
bool use_colors = FLAGS_SET(flags, SD_VARLINK_IDL_FORMAT_COLOR) ||
(FLAGS_SET(flags, SD_VARLINK_IDL_FORMAT_COLOR_AUTO) && colors_enabled());
- const char *const *colors = use_colors ? color_table : color_off;
+ const char *const *colors = use_colors ? (get_color_mode() == COLOR_16 ? color_16_table : color_table) : color_off;
/* First output interface comments */
r = varlink_idl_format_all_symbols(f, interface, _SD_VARLINK_INTERFACE_COMMENT, colors, cols);
for (size_t i = 0; i < el->n_algorithms; i++) {
const char *color;
- color = is_unset_pcr(el->registers[pcr].banks[i].calculated.buffer, el->registers[pcr].banks[i].calculated.size) ? ANSI_GREY : NULL;
+ color = is_unset_pcr(el->registers[pcr].banks[i].calculated.buffer, el->registers[pcr].banks[i].calculated.size) ? ansi_grey() : NULL;
if (el->registers[pcr].banks[i].calculated.size > 0) {
_cleanup_free_ char *hex = NULL;
if (!hex)
return log_oom();
- color = !hash_match ? ANSI_HIGHLIGHT_RED :
- is_unset_pcr(el->registers[pcr].banks[i].observed.buffer, el->registers[pcr].banks[i].observed.size) ? ANSI_GREY : NULL;
+ color = !hash_match ? ansi_highlight_red() :
+ is_unset_pcr(el->registers[pcr].banks[i].observed.buffer, el->registers[pcr].banks[i].observed.size) ? ansi_grey() : NULL;
r = table_add_many(table,
TABLE_STRING, hex,
if (marker) {
r = table_add_many(table,
TABLE_STRING, marker,
- TABLE_SET_COLOR, ANSI_GREY,
+ TABLE_SET_COLOR, ansi_grey(),
TABLE_EMPTY);
if (r < 0)
return table_log_add_error(r);
get_log_colors(priority, &color_on, &color_off, &highlight_on);
if (audit && strempty(color_on)) {
- color_on = ANSI_BLUE;
- color_off = ANSI_NORMAL;
+ color_on = ansi_blue();
+ color_off = ansi_normal();
}
}
timestamp = format_timestamp_style(buf, sizeof buf, usec,
flags & OUTPUT_UTC ? TIMESTAMP_US_UTC : TIMESTAMP_US);
fprintf(f, "%s%s%s %s[%s]%s\n",
- timestamp && (flags & OUTPUT_COLOR) ? ANSI_UNDERLINE : "",
+ timestamp && (flags & OUTPUT_COLOR) ? ansi_underline() : "",
timestamp ?: "(no timestamp)",
- timestamp && (flags & OUTPUT_COLOR) ? ANSI_NORMAL : "",
- (flags & OUTPUT_COLOR) ? ANSI_GREY : "",
+ timestamp && (flags & OUTPUT_COLOR) ? ansi_normal() : "",
+ (flags & OUTPUT_COLOR) ? ansi_grey() : "",
cursor,
- (flags & OUTPUT_COLOR) ? ANSI_NORMAL : "");
+ (flags & OUTPUT_COLOR) ? ansi_grey() : "");
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) {
_cleanup_free_ char *urlified = NULL;
if (flags & OUTPUT_COLOR) {
if (startswith(data, "MESSAGE=")) {
- on = ANSI_HIGHLIGHT;
- off = ANSI_NORMAL;
+ on = ansi_highlight();
+ off = ansi_normal();
} else if (startswith(data, "CONFIG_FILE=")) {
_cleanup_free_ char *u = NULL;
} else if (startswith(data, "_")) {
/* Highlight trusted data as such */
- on = ANSI_GREEN;
- off = ANSI_NORMAL;
+ on = ansi_green();
+ off = ansi_normal();
}
}
size_t c = columns();
flockfile(stdout);
- fputs_unlocked(ANSI_GREY_UNDERLINE, stdout);
+ fputs_unlocked(ansi_grey_underline(), stdout);
for (size_t i = 0; i < c; i++)
fputc_unlocked(' ', stdout);
- fputs_unlocked(ANSI_NORMAL "\n\n", stdout);
+ fputs_unlocked(ansi_normal(), stdout);
+ fputs_unlocked("\n\n", stdout);
funlockfile(stdout);
} else
fputs("\n\n", stdout);