diff --git a/Makefile b/Makefile index da42640..807b321 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/i3status.c b/i3status.c index b2b1714..de63bc1 100644 --- a/i3status.c +++ b/i3status.c @@ -29,6 +29,7 @@ #include #include +#include #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 #include #include +#include #include #include 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 #include #include +#include #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 #include #include +#include #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 #include #include +#include #ifdef __FreeBSD__ #include 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 #include #include +#include #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 #endif #include +#include #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 #include #include +#include +#include #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 #include #include +#include #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 #include #include +#include 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 #include #include +#include #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 #include #include +#include #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 #include #include +#include +#include #ifdef LINUX #include 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 #include +#include +#include #ifdef LINUX #include 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