]> git.sur5r.net Git - i3/i3/blob - include/yajl_utils.h
simplify yajl related code
[i3/i3] / include / yajl_utils.h
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * yajl_utils.h
8  *
9  */
10 #ifndef I3_YAJL_UTILS_H
11 #define I3_YAJL_UTILS_H
12
13 #include <yajl/yajl_gen.h>
14 #include <yajl/yajl_parse.h>
15 #include <yajl/yajl_version.h>
16
17 /* Shorter names for all those yajl_gen_* functions */
18 #define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
19 #define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))
20
21 #if YAJL_MAJOR >= 2
22 #define ygenalloc() yajl_gen_alloc(NULL)
23 #define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, client)
24 typedef size_t ylength;
25 #else
26 #define ygenalloc() yajl_gen_alloc(NULL, NULL);
27 #define yalloc(callbacks, client) yajl_alloc(callbacks, NULL, NULL, client)
28 typedef unsigned int ylength;
29 #endif
30
31 #endif