[syslog-ng] [PATCH 1/7] tfjson: remove json-glib support
Gergely Nagy
algernon at balabit.hu
Fri Sep 14 11:51:55 CEST 2012
There is no point in supporting two json formatters anymore, so drop
support for json-glib.
Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
configure.in | 56 +++++------------------------------------------
modules/tfjson/tfjson.c | 52 -------------------------------------------
2 files changed, 6 insertions(+), 102 deletions(-)
diff --git a/configure.in b/configure.in
index 5c00e0f..8991835 100644
--- a/configure.in
+++ b/configure.in
@@ -26,7 +26,6 @@ OPENSSL_MIN_VERSION="0.9.8"
LIBDBI_MIN_VERSION="0.8.0"
IVYKIS_MIN_VERSION="0.30.1"
JSON_C_MIN_VERSION="0.9"
-JSON_GLIB_MIN_VERSION="0.12"
PCRE_MIN_VERSION="6.1"
LMC_MIN_VERSION="0.1.6"
@@ -169,14 +168,9 @@ AC_ARG_WITH(ivykis,
Link against the system supplied or the built-in ivykis library.]
,,with_ivykis="internal")
-AC_ARG_WITH(json,
- [ --with-json=[json-c/json-glib/auto]
- Use the JSON implementation specified]
- ,,with_json="auto")
-
AC_ARG_ENABLE(json,
[ --disable-json Disable JSON support (default: auto)],
- [case "${enableval}" in yes) with_json="auto";; *) with_json="${enableval}";; esac],with_json="auto")
+ ,,enable_json="auto")
AC_ARG_ENABLE(smtp,
[ --disable-smtp Disable SMTP support (default: auto)],
@@ -616,12 +610,7 @@ fi
dnl ***************************************************************************
dnl json headers/libraries
dnl ***************************************************************************
-if test "x$with_json" = "xauto" || test "x$with_json" = "xjson-c"; then
- PKG_CHECK_MODULES(JSON_C, json >= $JSON_C_MIN_VERSION,, JSON_C_LIBS="")
-fi
-if test "x$with_json" = "xauto" || test "x$with_json" = "xjson-glib"; then
- PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= $JSON_GLIB_MIN_VERSION,, JSON_GLIB_LIBS="")
-fi
+PKG_CHECK_MODULES(JSON_C, json >= $JSON_C_MIN_VERSION,, [JSON_C_LIBS=""; enable_json="no"])
dnl ***************************************************************************
dnl pcre headers/libraries
@@ -900,45 +889,12 @@ if test "x$enable_mongodb" = "xauto"; then
AC_MSG_RESULT([$enable_mongodb])
fi
-if test "x$with_json" != "xjson-glib" -a "x$with_json" != "xjson-c" -a "x$with_json" != "xauto" -a "x$with_json" != "xno"; then
- # unknown --with-json argument
-
- AC_MSG_ERROR([Unknown JSON implementation ($with_json) specified, only json-glib, json-c and auto is known])
-elif test \( "x$with_json" = "xauto" -o "x$with_json" = "xjson-c" \) -a -n "$JSON_C_LIBS" ; then
- # json-c found and user requested json-c or auto
-
+if test "x$enable_json" != "xno"; then
JSON_LIBS=$JSON_C_LIBS
JSON_CFLAGS=$JSON_C_CFLAGS
- AC_DEFINE_UNQUOTED(HAVE_JSON_C, 1, [Have json-c])
- with_json="json-c"
-elif test \( "x$with_json" = "xauto" -o "x$with_json" = "xjson-glib" \) -a -n "$JSON_GLIB_LIBS"; then
- # json-glib found and user requested json-glib or auto
-
- JSON_LIBS=$JSON_GLIB_LIBS
- JSON_CFLAGS=$JSON_GLIB_CFLAGS
- AC_DEFINE_UNQUOTED(HAVE_JSON_GLIB, 1, [Have json-glib])
- with_json="json-glib"
-
-elif test "x$with_json" = "xauto" -o "x$with_json" = "xno"; then
- # nothing found, but autodetect was selected
-
- JSON_LIBS=""
- JSON_CFLAGS=""
- with_json="no"
-elif test "x$with_json" = "xjson-glib"; then
- AC_MSG_ERROR([Cannot find json-glib-1.0 >= $JSON_GLIB_MIN_VERSION: is pkg-config in path?])
-elif test "x$with_json" = "xjson-c"; then
- AC_MSG_ERROR([Cannot find json-c version >= $JSON_C_MIN_VERSION: is pkg-config in path?])
-fi
-
-if test "x$with_json" = "xjson-c"; then
- enable_json_parse="yes"
- enable_json_format="yes"
-fi
-if test "x$with_json" = "xjson-glib"; then
- enable_json_parse="no"
- enable_json_format="yes"
+ enable_json_parse="yes"
+ enable_json_format="yes"
fi
if test "x$enable_systemd" = "xauto"; then
@@ -1237,6 +1193,6 @@ echo " SSL support (module) : ${enable_ssl:=no}"
echo " SQL support (module) : ${enable_sql:=no}"
echo " PACCT module (EXPERIMENTAL) : ${enable_pacct:=no}"
echo " MongoDB destination (module): ${enable_mongodb:=no}"
-echo " JSON support (module) : parser=${enable_json_parse:=no}, formatter=${enable_json_format:=no} (using ${with_json})"
+echo " JSON support (module) : parser=${enable_json_parse:=no}, formatter=${enable_json_format:=no}"
echo " SMTP support (module) : ${enable_smtp:=no}"
diff --git a/modules/tfjson/tfjson.c b/modules/tfjson/tfjson.c
index 16c9d4a..8eb1d42 100644
--- a/modules/tfjson/tfjson.c
+++ b/modules/tfjson/tfjson.c
@@ -25,17 +25,9 @@
#include "cfg.h"
#include "value-pairs.h"
-#include "config.h"
-
-#ifdef HAVE_JSON_C
#include <printbuf.h>
#include <json.h>
#include <json_object_private.h>
-#endif
-
-#ifdef HAVE_JSON_GLIB
-#include <json-glib/json-glib.h>
-#endif
typedef struct _TFJsonState
{
@@ -57,7 +49,6 @@ tf_json_prepare(LogTemplateFunction *self, gpointer s, LogTemplate *parent,
return TRUE;
}
-#if HAVE_JSON_C
static int
tf_json_object_to_string (struct json_object *jso,
struct printbuf *pb)
@@ -112,45 +103,6 @@ tf_json_append(GString *result, ValuePairs *vp, LogMessage *msg)
g_string_append(result, json_object_to_json_string (json));
json_object_put(json);
}
-#endif
-
-#if HAVE_JSON_GLIB
-static gboolean
-tf_json_foreach (const gchar *name, const gchar *value, gpointer user_data)
-{
- JsonBuilder *builder = (JsonBuilder *)user_data;
-
- json_builder_set_member_name(builder, name);
- json_builder_add_string_value(builder, value);
-
- return FALSE;
-}
-
-static void
-tf_json_append(GString *result, ValuePairs *vp, LogMessage *msg)
-{
- JsonBuilder *builder;
- JsonGenerator *gen;
- gchar *str;
-
- builder = json_builder_new();
- json_builder_begin_object(builder);
-
- value_pairs_foreach(vp, tf_json_foreach, msg, 0, builder);
-
- json_builder_end_object(builder);
-
- gen = json_generator_new();
- json_generator_set_root(gen, json_builder_get_root(builder));
- str = json_generator_to_data(gen, NULL);
-
- g_object_unref(gen);
- g_object_unref(builder);
-
- g_string_append(result, str);
- g_free(str);
-}
-#endif
static void
tf_json_call(LogTemplateFunction *self, gpointer s,
@@ -184,10 +136,6 @@ static Plugin builtin_tmpl_func_plugins[] =
gboolean
tfjson_module_init(GlobalConfig *cfg, CfgArgs *args)
{
-#ifdef HAVE_JSON_GLIB
- g_type_init ();
-#endif
-
plugin_register(cfg, builtin_tmpl_func_plugins, G_N_ELEMENTS(builtin_tmpl_func_plugins));
return TRUE;
}
--
1.7.10.4
More information about the syslog-ng
mailing list