From d5b4c8e368050cf1b84b03c1379bbbc3c817a713 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 16 Feb 2012 23:29:29 +0000 Subject: Implement the i3bar JSON protocol This hardcodes all the JSON parts. Strings are not properly escaped currently. The best/easiest way to fix this is by actually using libyajl. --- src/print_eth_info.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/print_eth_info.c') diff --git a/src/print_eth_info.c b/src/print_eth_info.c index 28ba6c1..4fae191 100644 --- a/src/print_eth_info.c +++ b/src/print_eth_info.c @@ -78,6 +78,9 @@ void print_eth_info(const char *interface, const char *format_up, const char *fo const char *walk; const char *ip_address = get_ip_addr(interface); + if (output_format == O_I3BAR) + printf("{\"name\":\"ethernet\", \"instance\": \"%s\", ", interface); + if (ip_address == NULL) { printf("%s", color("color_bad")); printf("%s", format_down); @@ -87,6 +90,9 @@ void print_eth_info(const char *interface, const char *format_up, const char *fo printf("%s", color("color_good")); } + if (output_format == O_I3BAR) + printf("\"full_text\":\""); + for (walk = format_up; *walk != '\0'; walk++) { if (*walk != '%') { putchar(*walk); @@ -103,4 +109,7 @@ void print_eth_info(const char *interface, const char *format_up, const char *fo } (void)printf("%s", endcolor()); + + if (output_format == O_I3BAR) + printf("\"}"); } -- cgit v1.2.3