summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac4
-rw-r--r--grammar/rainerscript.c4
-rw-r--r--plugins/ommongodb/ommongodb.c5
-rw-r--r--runtime/msg.c8
4 files changed, 20 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index ebf35190..30c4559b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,10 @@ PKG_CHECK_MODULES([JSON_C], [json],, [
PKG_CHECK_MODULES([JSON_C], [json-c])
])
+# if int64 is supported, use it
+AC_CHECK_LIB(json-c, json_object_new_object,,)
+AC_CHECK_FUNCS(json_object_new_int64,,)
+
case "${host}" in
*-*-linux*)
AC_DEFINE([OS_LINUX], [1], [Indicator for a Linux OS])
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 4da49798..a2bed2bf 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -1202,7 +1202,11 @@ var2Number(struct var *r, int *bSuccess)
n = es_str2num(r->d.estr, bSuccess);
} else {
if(r->datatype == 'J') {
+#ifdef HAVE_JSON_OBJECT_NEW_INT64
+ n = (r->d.json == NULL) ? 0 : json_object_get_int64(r->d.json);
+#else /* HAVE_JSON_OBJECT_NEW_INT64 */
n = (r->d.json == NULL) ? 0 : json_object_get_int(r->d.json);
+#endif /* HAVE_JSON_OBJECT_NEW_INT64 */
} else {
n = r->d.n;
}
diff --git a/plugins/ommongodb/ommongodb.c b/plugins/ommongodb/ommongodb.c
index ecfd2518..a7c42010 100644
--- a/plugins/ommongodb/ommongodb.c
+++ b/plugins/ommongodb/ommongodb.c
@@ -311,8 +311,11 @@ BSONAppendJSONObject(bson *doc, const gchar *name, struct json_object *json)
case json_type_int: {
int64_t i;
- /* FIXME: the future version will have get_int64 */
+#ifdef HAVE_JSON_OBJECT_NEW_INT64
+ i = json_object_get_int64(json);
+#else /* HAVE_JSON_OBJECT_NEW_INT64 */
i = json_object_get_int(json);
+#endif /* HAVE_JSON_OBJECT_NEW_INT64 */
if (i >= INT32_MIN && i <= INT32_MAX)
return bson_append_int32(doc, name, i);
else
diff --git a/runtime/msg.c b/runtime/msg.c
index e30ff671..9f5bcde2 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -4140,7 +4140,11 @@ jsonDeepCopy(struct json_object *src)
dst = json_object_new_double(json_object_get_double(src));
break;
case json_type_int:
+#ifdef HAVE_JSON_OBJECT_NEW_INT64
+ dst = json_object_new_int64(json_object_get_int64(src));
+#else /* HAVE_JSON_OBJECT_NEW_INT64 */
dst = json_object_new_int(json_object_get_int(src));
+#endif /* HAVE_JSON_OBJECT_NEW_INT64 */
break;
case json_type_string:
dst = json_object_new_string(json_object_get_string(src));
@@ -4183,7 +4187,11 @@ msgSetJSONFromVar(msg_t *pMsg, uchar *varname, struct var *v)
free(cstr);
break;
case 'N':/* number (integer) */
+#ifdef HAVE_JSON_OBJECT_NEW_INT64
+ json = json_object_new_int64(v->d.n);
+#else /* HAVE_JSON_OBJECT_NEW_INT64 */
json = json_object_new_int((int) v->d.n);
+#endif /* HAVE_JSON_OBJECT_NEW_INT64 */
break;
case 'J':/* native JSON */
json = jsonDeepCopy(v->d.json);