]> git.sur5r.net Git - i3/i3status/commitdiff
add yajl compat code
authorMichael Stapelberg <michael@stapelberg.de>
Sun, 8 Apr 2012 12:05:47 +0000 (14:05 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sun, 8 Apr 2012 12:05:47 +0000 (14:05 +0200)
16 files changed:
Makefile
i3status.c
include/i3status.h
src/print_battery_info.c
src/print_cpu_temperature.c
src/print_cpu_usage.c
src/print_ddate.c
src/print_disk_info.c
src/print_eth_info.c
src/print_ipv6_addr.c
src/print_load.c
src/print_run_watch.c
src/print_time.c
src/print_volume.c
src/print_wireless_info.c
yajl-fallback/yajl/yajl_version.h [new file with mode: 0644]

index da42640ea70c27c54158ffa885ba4a468c46e2ad..807b321f5bf5b3376a82aa887e02f00678f8959f 100644 (file)
--- 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)
 
index b2b1714508cddacd792ed82a8947d0a6aec4638e..de63bc17f48029dde8d38ab220e6614c48fb2915 100644 (file)
@@ -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);
index 43110548ff20f58a9acdea3131ae428f59c38d80..ad54a144c6bd8809fc31728a9476df1b3f4fcd24 100644 (file)
@@ -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>
 
index 3892d359a187b7e1f1871bf184dcfbae3ef7e991..de63e4c6b347a56186926ff563de22427cf0ddd4 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <yajl/yajl_gen.h>
+#include <yajl/yajl_version.h>
 
 #include "i3status.h"
 
index 65fcfae6ae3d8094ee153362d97c04404fdf18d1..25b45f68489bcdef2088309dac50fd443aff67a7 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <yajl/yajl_gen.h>
+#include <yajl/yajl_version.h>
 
 #include "i3status.h"
 
index 24afca7166a95e74c4b6e9030f3a136ba3eb8fc3..7fdd11c50807744bf6a0348c4000686157d79884 100644 (file)
@@ -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>
index ca3ab0efa0ceb283390e3b63e8a68e54005df6e2..edc8e978cbd7ededa500f2f9a5bed55e1050b0cd 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <yajl/yajl_gen.h>
+#include <yajl/yajl_version.h>
 
 #include "i3status.h"
 
index 7235325b926f24aad988014a6f9cdddbfd840a52..9ddffd3e68d17b4c95386c71ab90b71ece4fcfbb 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/mount.h>
 #endif
 #include <yajl/yajl_gen.h>
+#include <yajl/yajl_version.h>
 
 #include "i3status.h"
 
index 1e877c09be710b742f485267f551bad7e76a299d..90005bf5fc0c2199a813d74236948c8b334c33f3 100644 (file)
@@ -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"
 
index 3f1c81d60ef49d0178bf03e969bebe834228d97e..be64ba3ae6acfe8dba02a7d02a22397409327894 100644 (file)
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <arpa/inet.h>
 #include <yajl/yajl_gen.h>
+#include <yajl/yajl_version.h>
 
 #include "i3status.h"
 
index 181773b0e324d62d206251a777dc810c53685340..d0d65f731f27d516248d89e58bf091f15a2d3b6f 100644 (file)
@@ -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;
index f93c3a0e02c3d086c1de3c906bdc993ae31fb87f..893e2cd80f36d8b76cc7da679ab4ef6b65c85c3f 100644 (file)
@@ -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) {
index a1bb34cdf3e089d0a4fef62cd0c3bea05b274910..00a619636decd905bf9b9e40108c055df165bbb1 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <yajl/yajl_gen.h>
+#include <yajl/yajl_version.h>
 
 #include "i3status.h"
 
index 5c34c3e6d16e0e5ef72b5bc7c5e91ec9381550a3..bc14ed878cca21704664a61beb9a943a1fa6c9a9 100644 (file)
@@ -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>
index 642dece5acea7384c90e17e7709cbd7ec8951ba0..a75d28411122736f005406abce8775826a12c2ab 100644 (file)
@@ -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 (file)
index 0000000..c6da442
--- /dev/null
@@ -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