From b0179cc1fe444058c557be93642b4c8fd583c15f Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 28 Oct 2014 06:33:40 +0100 Subject: [PATCH] 64-bit build fix for YAJL < 2.0 refs #7454 --- lib/base/json.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/base/json.cpp b/lib/base/json.cpp index a5080264e..03dd61789 100644 --- a/lib/base/json.cpp +++ b/lib/base/json.cpp @@ -34,6 +34,12 @@ using namespace icinga; static void Encode(yajl_gen handle, const Value& value); +#ifdef YAJL_MAJOR < 2 +typedef unsigned int yajl_size; +#else /* YAJL_MAJOR */ +typedef size_t yajl_size; +#endif /* YAJL_MAJOR */ + static void EncodeDictionary(yajl_gen handle, const Dictionary::Ptr& dict) { yajl_gen_map_open(handle); @@ -104,7 +110,8 @@ String icinga::JsonEncode(const Value& value) Encode(handle, value); const unsigned char *buf; - size_t len; + yajl_size len; + yajl_gen_get_buf(handle, &buf, &len); String result = String(buf, buf + len); @@ -222,7 +229,7 @@ static int DecodeBoolean(void *ctx, int value) return 1; } -static int DecodeNumber(void *ctx, const char *str, size_t len) +static int DecodeNumber(void *ctx, const char *str, yajl_size len) { JsonContext *context = static_cast(ctx); @@ -237,7 +244,7 @@ static int DecodeNumber(void *ctx, const char *str, size_t len) return 1; } -static int DecodeString(void *ctx, const unsigned char *str, size_t len) +static int DecodeString(void *ctx, const unsigned char *str, yajl_size len) { JsonContext *context = static_cast(ctx);