diff options
author | Roger Pau Monne <roger.pau@entel.upc.edu> | 2012-01-31 16:48:06 +0000 |
---|---|---|
committer | Roger Pau Monne <roger.pau@entel.upc.edu> | 2012-01-31 16:48:06 +0000 |
commit | ee65792d9386e7eb538dd09674c1c275f2691abb (patch) | |
tree | 290984b181271a662155c02478b9f0ff9281f6d5 /tools/libxl/libxl_json.c | |
parent | 1a4af67d32b1c39b73e09346203f3e12c00b9e41 (diff) | |
download | xen-ee65792d9386e7eb538dd09674c1c275f2691abb.tar.gz xen-ee65792d9386e7eb538dd09674c1c275f2691abb.tar.bz2 xen-ee65792d9386e7eb538dd09674c1c275f2691abb.zip |
libxl: add support for yajl 2.x
This patch adds support for yajl versions 2.x, while retaining 1.x
compatibility. All the needed ifdefs can be found in libxl_json.h.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_json.c')
-rw-r--r-- | tools/libxl/libxl_json.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/tools/libxl/libxl_json.c b/tools/libxl/libxl_json.c index 6ff2910806..345894b000 100644 --- a/tools/libxl/libxl_json.c +++ b/tools/libxl/libxl_json.c @@ -517,7 +517,7 @@ static bool is_decimal(const char *s, unsigned len) return false; } -static int json_callback_number(void *opaque, const char *s, unsigned int len) +static int json_callback_number(void *opaque, const char *s, libxl_yajl_length len) { libxl__yajl_ctx *ctx = opaque; libxl__json_object *obj = NULL; @@ -574,7 +574,7 @@ out: } static int json_callback_string(void *opaque, const unsigned char *str, - unsigned int len) + libxl_yajl_length len) { libxl__yajl_ctx *ctx = opaque; char *t = NULL; @@ -607,7 +607,7 @@ static int json_callback_string(void *opaque, const unsigned char *str, } static int json_callback_map_key(void *opaque, const unsigned char *str, - unsigned int len) + libxl_yajl_length len) { libxl__yajl_ctx *ctx = opaque; char *t = NULL; @@ -770,17 +770,13 @@ libxl__json_object *libxl__json_parse(libxl__gc *gc, const char *s) DEBUG_GEN_ALLOC(&yajl_ctx); if (yajl_ctx.hand == NULL) { - yajl_parser_config cfg = { - .allowComments = 1, - .checkUTF8 = 1, - }; - yajl_ctx.hand = yajl_alloc(&callbacks, &cfg, NULL, &yajl_ctx); + yajl_ctx.hand = libxl__yajl_alloc(&callbacks, NULL, &yajl_ctx); } status = yajl_parse(yajl_ctx.hand, (const unsigned char *)s, strlen(s)); if (status != yajl_status_ok) goto out; - status = yajl_parse_complete(yajl_ctx.hand); + status = yajl_complete_parse(yajl_ctx.hand); if (status != yajl_status_ok) goto out; @@ -832,14 +828,13 @@ static const char *yajl_gen_status_to_string(yajl_gen_status s) char *libxl__object_to_json(libxl_ctx *ctx, const char *type, libxl__gen_json_callback gen, void *p) { - yajl_gen_config conf = { 1, " " }; const unsigned char *buf; char *ret = NULL; - unsigned int len = 0; + libxl_yajl_length len = 0; yajl_gen_status s; yajl_gen hand; - hand = yajl_gen_alloc(&conf, NULL); + hand = libxl__yajl_gen_alloc(NULL); if (!hand) return NULL; |