static void operational_state_to_color(const char *state, const char **on, const char **off) { assert(on); assert(off); if (streq_ptr(state, "routable")) { *on = ansi_highlight_green(); *off = ansi_highlight_off(); } else if (streq_ptr(state, "degraded")) { *on = ansi_highlight_yellow(); *off = ansi_highlight_off(); } else *on = *off = ""; }
static void setup_state_to_color(const char *state, const char **on, const char **off) { assert(on); assert(off); if (streq_ptr(state, "configured")) { *on = ansi_highlight_green(); *off = ansi_highlight_off(); } else if (streq_ptr(state, "configuring")) { *on = ansi_highlight_yellow(); *off = ansi_highlight_off(); } else if (streq_ptr(state, "failed") || streq_ptr(state, "linger")) { *on = ansi_highlight_red(); *off = ansi_highlight_off(); } else *on = *off = ""; }
static int notify_override_extended(const char *top, const char *bottom) { if (!(arg_flags & SHOW_EXTENDED)) return 0; printf("%s%s%s %s → %s\n", ansi_highlight(), "[EXTENDED]", ansi_highlight_off(), top, bottom); return 1; }
static int notify_override_overridden(const char *top, const char *bottom) { if (!(arg_flags & SHOW_OVERRIDDEN)) return 0; printf("%s%s%s %s → %s\n", ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(), top, bottom); return 1; }
static int notify_override_redirected(const char *top, const char *bottom) { if (!(arg_flags & SHOW_REDIRECTED)) return 0; printf("%s%s%s %s → %s\n", ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(), top, bottom); return 1; }
static int notify_override_equivalent(const char *top, const char *bottom) { if (!(arg_flags & SHOW_EQUIVALENT)) return 0; printf("%s%s%s %s → %s\n", ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight_off(), top, bottom); return 1; }
static int notify_override_masked(const char *top, const char *bottom) { if (!(arg_flags & SHOW_MASKED)) return 0; printf("%s%s%s %s → %s\n", ansi_highlight_red(), "[MASKED]", ansi_highlight_off(), top, bottom); return 1; }
static int notify_override_equivalent(const char *top, const char *bottom) { if (!(arg_flags & SHOW_EQUIVALENT)) return 0; printf("%s%s%s %s %s %s\n", ansi_lightgreen(), "[EQUIVALENT]", ansi_highlight_off(), top, draw_special_char(DRAW_ARROW), bottom); return 1; }
static int notify_override_masked(const char *top, const char *bottom) { if (!(arg_flags & SHOW_MASKED)) return 0; printf("%s%s%s %s %s %s\n", ansi_lightred(), "[MASKED]", ansi_highlight_off(), top, draw_special_char(DRAW_ARROW), bottom); return 1; }