diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2012-04-08 14:05:47 +0200 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2012-04-08 14:05:47 +0200 |
commit | 1b3aa404858b476015a2b29d0c42f7dbbed915bc (patch) | |
tree | 4d4baadd7d64dace692c00f90c4c6bab21f0c76d | |
parent | 9d7b69652c0e45014e2934f8a0358b64928539ec (diff) |
add yajl compat code
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | i3status.c | 9 | ||||
-rw-r--r-- | include/i3status.h | 1 | ||||
-rw-r--r-- | src/print_battery_info.c | 1 | ||||
-rw-r--r-- | src/print_cpu_temperature.c | 1 | ||||
-rw-r--r-- | src/print_cpu_usage.c | 1 | ||||
-rw-r--r-- | src/print_ddate.c | 1 | ||||
-rw-r--r-- | src/print_disk_info.c | 1 | ||||
-rw-r--r-- | src/print_eth_info.c | 2 | ||||
-rw-r--r-- | src/print_ipv6_addr.c | 1 | ||||
-rw-r--r-- | src/print_load.c | 1 | ||||
-rw-r--r-- | src/print_run_watch.c | 1 | ||||
-rw-r--r-- | src/print_time.c | 1 | ||||
-rw-r--r-- | src/print_volume.c | 2 | ||||
-rw-r--r-- | src/print_wireless_info.c | 2 | ||||
-rw-r--r-- | yajl-fallback/yajl/yajl_version.h | 7 |
16 files changed, 36 insertions, 0 deletions
@@ -35,6 +35,10 @@ endif CFLAGS+=$(EXTRA_CFLAGS) +# Fallback for libyajl 1 which did not include yajl_version.h. We need +# YAJL_MAJOR from that file to decide which code path should be used. +CFLAGS += -idirafter $(TOPDIR)/yajl-fallback + OBJS:=$(wildcard src/*.c *.c) OBJS:=$(OBJS:.c=.o) @@ -29,6 +29,7 @@ #include <locale.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" @@ -346,7 +347,11 @@ int main(int argc, char *argv[]) { || !valid_color(cfg_getstr(cfg_general, "color_separator"))) die("Bad color format"); +#if YAJL_MAJOR >= 2 yajl_gen json_gen = yajl_gen_alloc(NULL); +#else + yajl_gen json_gen = yajl_gen_alloc(NULL, NULL); +#endif if (output_format == O_I3BAR) { /* Initialize the i3bar protocol. See i3/docs/i3bar-protocol @@ -466,7 +471,11 @@ int main(int argc, char *argv[]) { if (output_format == O_I3BAR) { yajl_gen_array_close(json_gen); const unsigned char *buf; +#if YAJL_MAJOR >= 2 size_t len; +#else + unsigned int len; +#endif yajl_gen_get_buf(json_gen, &buf, &len); write(STDOUT_FILENO, buf, len); yajl_gen_clear(json_gen); diff --git a/include/i3status.h b/include/i3status.h index 4311054..ad54a14 100644 --- a/include/i3status.h +++ b/include/i3status.h @@ -7,6 +7,7 @@ enum { O_DZEN2, O_XMOBAR, O_I3BAR, O_NONE } output_format; #include <confuse.h> #include <time.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include <unistd.h> #include <string.h> diff --git a/src/print_battery_info.c b/src/print_battery_info.c index 3892d35..de63e4c 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -4,6 +4,7 @@ #include <stdlib.h> #include <stdio.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" diff --git a/src/print_cpu_temperature.c b/src/print_cpu_temperature.c index 65fcfae..25b45f6 100644 --- a/src/print_cpu_temperature.c +++ b/src/print_cpu_temperature.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <string.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" diff --git a/src/print_cpu_usage.c b/src/print_cpu_usage.c index 24afca7..7fdd11c 100644 --- a/src/print_cpu_usage.c +++ b/src/print_cpu_usage.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <string.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #ifdef __FreeBSD__ #include <sys/types.h> diff --git a/src/print_ddate.c b/src/print_ddate.c index ca3ab0e..edc8e97 100644 --- a/src/print_ddate.c +++ b/src/print_ddate.c @@ -4,6 +4,7 @@ #include <stdlib.h> #include <string.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" diff --git a/src/print_disk_info.c b/src/print_disk_info.c index 7235325..9ddffd3 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -11,6 +11,7 @@ #include <sys/mount.h> #endif #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" diff --git a/src/print_eth_info.c b/src/print_eth_info.c index 1e877c0..90005bf 100644 --- a/src/print_eth_info.c +++ b/src/print_eth_info.c @@ -8,6 +8,8 @@ #include <net/if.h> #include <netinet/in.h> #include <arpa/inet.h> +#include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" diff --git a/src/print_ipv6_addr.c b/src/print_ipv6_addr.c index 3f1c81d..be64ba3 100644 --- a/src/print_ipv6_addr.c +++ b/src/print_ipv6_addr.c @@ -9,6 +9,7 @@ #include <string.h> #include <arpa/inet.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" diff --git a/src/print_load.c b/src/print_load.c index 181773b..d0d65f7 100644 --- a/src/print_load.c +++ b/src/print_load.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <string.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> void print_load(yajl_gen json_gen, char *buffer, const char *format) { char *outwalk = buffer; diff --git a/src/print_run_watch.c b/src/print_run_watch.c index f93c3a0..893e2cd 100644 --- a/src/print_run_watch.c +++ b/src/print_run_watch.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <string.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const char *pidfile, const char *format) { diff --git a/src/print_time.c b/src/print_time.c index a1bb34c..00a6196 100644 --- a/src/print_time.c +++ b/src/print_time.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <stdlib.h> #include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #include "i3status.h" diff --git a/src/print_volume.c b/src/print_volume.c index 5c34c3e..bc14ed8 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -3,6 +3,8 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> +#include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #ifdef LINUX #include <alsa/asoundlib.h> diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index 642dece..a75d284 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -1,6 +1,8 @@ // vim:ts=8:expandtab #include <stdio.h> #include <string.h> +#include <yajl/yajl_gen.h> +#include <yajl/yajl_version.h> #ifdef LINUX #include <iwlib.h> diff --git a/yajl-fallback/yajl/yajl_version.h b/yajl-fallback/yajl/yajl_version.h new file mode 100644 index 0000000..c6da442 --- /dev/null +++ b/yajl-fallback/yajl/yajl_version.h @@ -0,0 +1,7 @@ +#ifndef YAJL_VERSION_H_ +#define YAJL_VERSION_H_ +/* Fallback for libyajl 1 which does not provide yajl_version.h */ +#define YAJL_MAJOR 1 +#define YAJL_MINOR 0 +#define YAJL_MICRO 0 +#endif |