add yajl compat code

This commit is contained in:
Michael Stapelberg 2012-04-08 14:05:47 +02:00
parent 9d7b69652c
commit 1b3aa40485
16 changed files with 36 additions and 0 deletions

View File

@ -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)

View 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);

View 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>

View File

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
#include "i3status.h"

View File

@ -4,6 +4,7 @@
#include <stdio.h>
#include <string.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
#include "i3status.h"

View 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>

View File

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
#include "i3status.h"

View File

@ -11,6 +11,7 @@
#include <sys/mount.h>
#endif
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
#include "i3status.h"

View 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"

View 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"

View 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;

View 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) {

View File

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
#include "i3status.h"

View 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>

View 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>

View File

@ -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