26.10.2013 15:38, Rainer Gerhards:

Note that this patch requires json-c >= 0.10.

That's NOT shipped by many distros. that's the prime reason we keep with
the old version. But if you can add a configure check, we can support it
where available (maybe a call to maintainers to also update the json-c
package...).

How about this, with configure check?


--
Pavel Levshin

>From bf3794a8f4d321cf0ae9eda32b0e8d968179f44f Mon Sep 17 00:00:00 2001
From: Pavel Levshin <[email protected]>
Date: Sat, 26 Oct 2013 14:57:37 +0400
Subject: [PATCH] Make use of int64 json numbers, if available

---
 configure.ac                  |    4 ++++
 grammar/rainerscript.c        |    4 ++++
 plugins/ommongodb/ommongodb.c |    5 ++++-
 runtime/msg.c                 |    8 ++++++++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 2f23147..f097cdf 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 37f3509..4dee989 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -1192,7 +1192,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 78781c0..af1f5a3 100644
--- a/plugins/ommongodb/ommongodb.c
+++ b/plugins/ommongodb/ommongodb.c
@@ -317,8 +317,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 d173644..1e2e88e 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -4049,7 +4049,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));
@@ -4092,7 +4096,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);
-- 
1.7.9.5

_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to