X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=lib%2Fjson_print.c;h=62eeb1f1fb3159ee1984a9d3e0835255e12f6c6c;hb=9091ff0251f8da256d55ca4e994dbd14e32d08ad;hp=fe0705bf6965e33a3fbddee041597eee7a0d959a;hpb=82604d28525aae8d9c5206d5c1d70aee88a7d960;p=mirror_iproute2.git diff --git a/lib/json_print.c b/lib/json_print.c index fe0705bf..62eeb1f1 100644 --- a/lib/json_print.c +++ b/lib/json_print.c @@ -191,11 +191,12 @@ int print_color_string(enum output_type type, * a value to it, you will need to use "is_json_context()" to have different * branch for json and regular output. grep -r "print_bool" for example */ -int print_color_bool(enum output_type type, - enum color_attr color, - const char *key, - const char *fmt, - bool value) +static int __print_color_bool(enum output_type type, + enum color_attr color, + const char *key, + const char *fmt, + bool value, + const char *str) { int ret = 0; @@ -205,13 +206,32 @@ int print_color_bool(enum output_type type, else jsonw_bool(_jw, value); } else if (_IS_FP_CONTEXT(type)) { - ret = color_fprintf(stdout, color, fmt, - value ? "true" : "false"); + ret = color_fprintf(stdout, color, fmt, str); } return ret; } +int print_color_bool(enum output_type type, + enum color_attr color, + const char *key, + const char *fmt, + bool value) +{ + return __print_color_bool(type, color, key, fmt, value, + value ? "true" : "false"); +} + +int print_color_on_off(enum output_type type, + enum color_attr color, + const char *key, + const char *fmt, + bool value) +{ + return __print_color_bool(type, color, key, fmt, value, + value ? "on" : "off"); +} + /* * In JSON context uses hardcode %#x format: 42 -> 0x2a */