summaryrefslogtreecommitdiff
path: root/src/print_ipv6_addr.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2012-02-16 23:29:29 +0000
committerMichael Stapelberg <michael@stapelberg.de>2012-02-16 23:30:54 +0000
commitd5b4c8e368050cf1b84b03c1379bbbc3c817a713 (patch)
tree2f918d4c5b95a05ebec68bceec35f7d4fa9a0c4e /src/print_ipv6_addr.c
parent7149f6f78e0d105f02d54e1db60db8b191a98acb (diff)
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.
Diffstat (limited to 'src/print_ipv6_addr.c')
-rw-r--r--src/print_ipv6_addr.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/print_ipv6_addr.c b/src/print_ipv6_addr.c
index e96c0d3..3ace6a2 100644
--- a/src/print_ipv6_addr.c
+++ b/src/print_ipv6_addr.c
@@ -9,6 +9,8 @@
#include <string.h>
#include <arpa/inet.h>
+#include "i3status.h"
+
static char *get_sockname(struct addrinfo *addr) {
static char buf[INET6_ADDRSTRLEN+1];
struct sockaddr_storage local;
@@ -111,6 +113,9 @@ void print_ipv6_info(const char *format_up, const char *format_down) {
const char *walk;
char *addr_string = get_ipv6_addr();
+ if (output_format == O_I3BAR)
+ printf("{\"name\":\"ipv6\", \"full_text\":\"");
+
if (addr_string == NULL) {
printf("%s", format_down);
return;
@@ -127,4 +132,7 @@ void print_ipv6_info(const char *format_up, const char *format_down) {
walk += strlen("ip");
}
}
+
+ if (output_format == O_I3BAR)
+ printf("\"}");
}