[syslog-ng] [PATCH 2/7] Merge tfjson & jsonparser
Gergely Nagy
algernon at balabit.hu
Fri Sep 14 11:51:56 CEST 2012
The reason tfjson and jsonparser were separate is because the former
supported two json libs, and they could be compiled separately.
Now that tfjson dropped json-glib support, the separation became
pointless, so this patch merges the two together.
Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
configure.in | 14 ++----
modules/Makefile.am | 2 +-
modules/{jsonparser => json}/Makefile.am | 26 ++++++----
.../jsonparser.h => json/json-plugin.h} | 10 ++--
modules/{jsonparser => json}/jsonparser-grammar.ym | 2 +-
modules/{jsonparser => json}/jsonparser-parser.c | 2 +-
modules/{jsonparser => json}/jsonparser-parser.h | 0
modules/{jsonparser => json}/jsonparser.c | 2 +-
modules/{tfjson => json}/tests/Makefile.am | 4 +-
modules/{tfjson => json}/tests/test_json.c | 2 +-
modules/{tfjson => json}/tfjson.c | 21 +++++---
modules/jsonparser/jsonparser-plugin.c | 53 --------------------
modules/tfjson/Makefile.am | 13 -----
13 files changed, 47 insertions(+), 104 deletions(-)
rename modules/{jsonparser => json}/Makefile.am (50%)
rename modules/{jsonparser/jsonparser.h => json/json-plugin.h} (83%)
rename modules/{jsonparser => json}/jsonparser-grammar.ym (98%)
rename modules/{jsonparser => json}/jsonparser-parser.c (98%)
rename modules/{jsonparser => json}/jsonparser-parser.h (100%)
rename modules/{jsonparser => json}/jsonparser.c (99%)
rename modules/{tfjson => json}/tests/Makefile.am (76%)
rename modules/{tfjson => json}/tests/test_json.c (93%)
rename modules/{tfjson => json}/tfjson.c (87%)
delete mode 100644 modules/jsonparser/jsonparser-plugin.c
delete mode 100644 modules/tfjson/Makefile.am
diff --git a/configure.in b/configure.in
index 8991835..a23c6e8 100644
--- a/configure.in
+++ b/configure.in
@@ -892,9 +892,7 @@ fi
if test "x$enable_json" != "xno"; then
JSON_LIBS=$JSON_C_LIBS
JSON_CFLAGS=$JSON_C_CFLAGS
-
- enable_json_parse="yes"
- enable_json_format="yes"
+ enable_json="yes"
fi
if test "x$enable_systemd" = "xauto"; then
@@ -1070,8 +1068,7 @@ AM_CONDITIONAL(ENABLE_SUN_STREAMS, [test "$enable_sun_streams" = "yes"])
AM_CONDITIONAL(ENABLE_PACCT, [test "$enable_pacct" = "yes"])
AM_CONDITIONAL(ENABLE_MONGODB, [test "$enable_mongodb" = "yes"])
AM_CONDITIONAL(ENABLE_SMTP, [test "$enable_smtp" = "yes"])
-AM_CONDITIONAL(ENABLE_JSON_FORMAT, [test "$enable_json_format" = "yes"])
-AM_CONDITIONAL(ENABLE_JSON_PARSE, [test "$enable_json_parse" = "yes"])
+AM_CONDITIONAL(ENABLE_JSON, [test "$enable_json" = "yes"])
AM_CONDITIONAL(WITH_LIBSYSTEMD, [test "$with_libsystemd" = "yes"])
# substitution into manual pages
@@ -1147,9 +1144,8 @@ AC_OUTPUT(dist.conf
modules/basicfuncs/tests/Makefile
modules/cryptofuncs/Makefile
modules/cryptofuncs/tests/Makefile
- modules/tfjson/Makefile
- modules/tfjson/tests/Makefile
- modules/jsonparser/Makefile
+ modules/json/Makefile
+ modules/json/tests/Makefile
scripts/Makefile
scripts/update-patterndb
doc/Makefile
@@ -1193,6 +1189,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}"
+echo " JSON support (module) : ${enable_json:=no}"
echo " SMTP support (module) : ${enable_smtp:=no}"
diff --git a/modules/Makefile.am b/modules/Makefile.am
index eb9548d..8f9d63b 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -1 +1 @@
-SUBDIRS = afsocket afsql afstreams affile afprog afuser afmongodb afsmtp csvparser confgen system-source syslogformat pacctformat basicfuncs cryptofuncs dbparser tfjson jsonparser
+SUBDIRS = afsocket afsql afstreams affile afprog afuser afmongodb afsmtp csvparser confgen system-source syslogformat pacctformat basicfuncs cryptofuncs dbparser json
diff --git a/modules/jsonparser/Makefile.am b/modules/json/Makefile.am
similarity index 50%
rename from modules/jsonparser/Makefile.am
rename to modules/json/Makefile.am
index 0925f98..4960ca4 100644
--- a/modules/jsonparser/Makefile.am
+++ b/modules/json/Makefile.am
@@ -1,22 +1,26 @@
+SUBDIRS = tests
+
moduledir = @moduledir@
-AM_CPPFLAGS = -I$(top_srcdir)/lib -I../../lib
export top_srcdir
-if ENABLE_JSON_PARSE
-module_LTLIBRARIES := libjsonparser.la
-libjsonparser_la_SOURCES = \
- jsonparser.c jsonparser.h \
+if ENABLE_JSON
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I../../lib
+module_LTLIBRARIES = libjson-plugin.la
+
+libjson_plugin_la_SOURCES = \
+ tfjson.c \
+ jsonparser.c \
jsonparser-grammar.y \
jsonparser-parser.c jsonparser-parser.h \
- jsonparser-plugin.c
+ json-plugin.h
-libjsonparser_la_CPPFLAGS = $(AM_CPPFLAGS)
-libjsonparser_la_CFLAGS = $(JSON_CFLAGS)
-libjsonparser_la_LIBADD = $(MODULE_DEPS_LIBS)
-libjsonparser_la_LDFLAGS = $(MODULE_LDFLAGS) $(JSON_LIBS)
+libjson_plugin_la_CPPFLAGS = $(AM_CPPFLAGS)
+libjson_plugin_la_CFLAGS = $(JSON_CFLAGS)
+libjson_plugin_la_LIBADD = $(MODULE_DEPS_LIBS) $(JSON_LIBS)
+libjson_plugin_la_LDFLAGS = $(MODULE_LDFLAGS)
+endif
BUILT_SOURCES = jsonparser-grammar.y jsonparser-grammar.c jsonparser-grammar.h
EXTRA_DIST = $(BUILT_SOURCES) jsonparser-grammar.ym
-endif
include $(top_srcdir)/build/lex-rules.am
diff --git a/modules/jsonparser/jsonparser.h b/modules/json/json-plugin.h
similarity index 83%
rename from modules/jsonparser/jsonparser.h
rename to modules/json/json-plugin.h
index 15fd27f..e8add05 100644
--- a/modules/jsonparser/jsonparser.h
+++ b/modules/json/json-plugin.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2011 BalaBit IT Ltd, Budapest, Hungary
- * Copyright (c) 2011 Gergely Nagy <algernon at balabit.hu>
+ * Copyright (c) 2011-2012 BalaBit IT Ltd, Budapest, Hungary
+ * Copyright (c) 2011-2012 Gergely Nagy <algernon at balabit.hu>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
@@ -20,8 +20,8 @@
* COPYING for details.
*/
-#ifndef JSONPARSER_H_INCLUDED
-#define JSONPARSER_H_INCLUDED
+#ifndef JSON_PLUGIN_H_INCLUDED
+#define JSON_PLUGIN_H_INCLUDED
#include "logparser.h"
@@ -31,4 +31,6 @@ void log_json_parser_set_prefix(LogParser *p, const gchar *prefix);
void log_json_parser_set_marker(LogParser *p, const gchar *marker);
LogJSONParser *log_json_parser_new(void);
+gboolean tfjson_module_init(GlobalConfig *cfg);
+
#endif
diff --git a/modules/jsonparser/jsonparser-grammar.ym b/modules/json/jsonparser-grammar.ym
similarity index 98%
rename from modules/jsonparser/jsonparser-grammar.ym
rename to modules/json/jsonparser-grammar.ym
index cc2830a..e78b8e4 100644
--- a/modules/jsonparser/jsonparser-grammar.ym
+++ b/modules/json/jsonparser-grammar.ym
@@ -28,7 +28,7 @@
%code {
-#include "jsonparser.h"
+#include "json-plugin.h"
#include "cfg-parser.h"
#include "jsonparser-grammar.h"
#include "syslog-names.h"
diff --git a/modules/jsonparser/jsonparser-parser.c b/modules/json/jsonparser-parser.c
similarity index 98%
rename from modules/jsonparser/jsonparser-parser.c
rename to modules/json/jsonparser-parser.c
index 6a88040..e9dacaf 100644
--- a/modules/jsonparser/jsonparser-parser.c
+++ b/modules/json/jsonparser-parser.c
@@ -20,7 +20,7 @@
* COPYING for details.
*/
-#include "jsonparser.h"
+#include "json-plugin.h"
#include "cfg-parser.h"
#include "jsonparser-grammar.h"
diff --git a/modules/jsonparser/jsonparser-parser.h b/modules/json/jsonparser-parser.h
similarity index 100%
rename from modules/jsonparser/jsonparser-parser.h
rename to modules/json/jsonparser-parser.h
diff --git a/modules/jsonparser/jsonparser.c b/modules/json/jsonparser.c
similarity index 99%
rename from modules/jsonparser/jsonparser.c
rename to modules/json/jsonparser.c
index 3fb2531..21b605d 100644
--- a/modules/jsonparser/jsonparser.c
+++ b/modules/json/jsonparser.c
@@ -20,7 +20,7 @@
* COPYING for details.
*/
-#include "jsonparser.h"
+#include "json-plugin.h"
#include "logparser.h"
#include "scratch-buffers.h"
diff --git a/modules/tfjson/tests/Makefile.am b/modules/json/tests/Makefile.am
similarity index 76%
rename from modules/tfjson/tests/Makefile.am
rename to modules/json/tests/Makefile.am
index a184b69..2424a73 100644
--- a/modules/tfjson/tests/Makefile.am
+++ b/modules/json/tests/Makefile.am
@@ -1,5 +1,5 @@
-AM_CFLAGS = -I$(top_srcdir)/lib -I../../../lib -I$(top_srcdir)/libtest -I../../../libtest -I$(top_srcdir)/modules/tfjson -I..
-AM_LDFLAGS = -dlpreopen ../../syslogformat/libsyslogformat.la -dlpreopen ../libtfjson.la
+AM_CFLAGS = -I$(top_srcdir)/lib -I../../../lib -I$(top_srcdir)/libtest -I../../../libtest -I$(top_srcdir)/modules/json -I..
+AM_LDFLAGS = -dlpreopen ../../syslogformat/libsyslogformat.la -dlpreopen ../libjson-plugin.la
LDADD = $(top_builddir)/lib/libsyslog-ng.la $(top_builddir)/libtest/libsyslog-ng-test.a @TOOL_DEPS_LIBS@
check_PROGRAMS = test_json
diff --git a/modules/tfjson/tests/test_json.c b/modules/json/tests/test_json.c
similarity index 93%
rename from modules/tfjson/tests/test_json.c
rename to modules/json/tests/test_json.c
index bd18203..582b264 100644
--- a/modules/tfjson/tests/test_json.c
+++ b/modules/json/tests/test_json.c
@@ -15,7 +15,7 @@ main(int argc G_GNUC_UNUSED, char *argv[] G_GNUC_UNUSED)
{
app_startup();
init_template_tests();
- plugin_load_module("tfjson", configuration, NULL);
+ plugin_load_module("json-plugin", configuration, NULL);
test_format_json();
diff --git a/modules/tfjson/tfjson.c b/modules/json/tfjson.c
similarity index 87%
rename from modules/tfjson/tfjson.c
rename to modules/json/tfjson.c
index 8eb1d42..8716559 100644
--- a/modules/tfjson/tfjson.c
+++ b/modules/json/tfjson.c
@@ -128,24 +128,31 @@ tf_json_free_state(gpointer s)
TEMPLATE_FUNCTION(TFJsonState, tf_json, tf_json_prepare, NULL, tf_json_call,
tf_json_free_state, NULL);
-static Plugin builtin_tmpl_func_plugins[] =
+extern CfgParser jsonparser_parser;
+
+static Plugin json_plugins[] =
{
+ {
+ .type = LL_CONTEXT_PARSER,
+ .name = "json-parser",
+ .parser = &jsonparser_parser,
+ },
TEMPLATE_FUNCTION_PLUGIN(tf_json, "format_json"),
};
gboolean
-tfjson_module_init(GlobalConfig *cfg, CfgArgs *args)
+json_module_init(GlobalConfig *cfg, CfgArgs *args)
{
- plugin_register(cfg, builtin_tmpl_func_plugins, G_N_ELEMENTS(builtin_tmpl_func_plugins));
+ plugin_register(cfg, json_plugins, G_N_ELEMENTS(json_plugins));
return TRUE;
}
const ModuleInfo module_info =
{
- .canonical_name = "tfjson",
+ .canonical_name = "json",
.version = VERSION,
- .description = "The tfjson module provides a JSON formatting template function for syslog-ng.",
+ .description = "The json module provides JSON parsing & formatting support for syslog-ng.",
.core_revision = SOURCE_REVISION,
- .plugins = builtin_tmpl_func_plugins,
- .plugins_len = G_N_ELEMENTS(builtin_tmpl_func_plugins),
+ .plugins = json_plugins,
+ .plugins_len = G_N_ELEMENTS(json_plugins),
};
diff --git a/modules/jsonparser/jsonparser-plugin.c b/modules/jsonparser/jsonparser-plugin.c
deleted file mode 100644
index 15c4c91..0000000
--- a/modules/jsonparser/jsonparser-plugin.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2011 BalaBit IT Ltd, Budapest, Hungary
- * Copyright (c) 2011 Gergely Nagy <algernon at balabit.hu>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As an additional exemption you are allowed to compile & link against the
- * OpenSSL libraries as published by the OpenSSL project. See the file
- * COPYING for details.
- */
-
-#include "cfg-parser.h"
-#include "plugin.h"
-#include "jsonparser.h"
-
-extern CfgParser jsonparser_parser;
-
-static Plugin jsonparser_plugins[] =
-{
- {
- .type = LL_CONTEXT_PARSER,
- .name = "json-parser",
- .parser = &jsonparser_parser,
- },
-};
-
-gboolean
-jsonparser_module_init(GlobalConfig *cfg, CfgArgs *args)
-{
- plugin_register(cfg, jsonparser_plugins, G_N_ELEMENTS(jsonparser_plugins));
- return TRUE;
-}
-
-const ModuleInfo module_info =
-{
- .canonical_name = "jsonparser",
- .version = VERSION,
- .description = "The jsonparser module provides JSON parsing support for syslog-ng.",
- .core_revision = SOURCE_REVISION,
- .plugins = jsonparser_plugins,
- .plugins_len = G_N_ELEMENTS(jsonparser_plugins),
-};
diff --git a/modules/tfjson/Makefile.am b/modules/tfjson/Makefile.am
deleted file mode 100644
index eecbf70..0000000
--- a/modules/tfjson/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-SUBDIRS = tests
-
-moduledir = @moduledir@
-export top_srcdir
-
-if ENABLE_JSON_FORMAT
-AM_CPPFLAGS = -I$(top_srcdir)/lib -I../../lib $(JSON_CFLAGS)
-module_LTLIBRARIES = libtfjson.la
-
-libtfjson_la_SOURCES = tfjson.c
-libtfjson_la_LIBADD = $(MODULE_DEPS_LIBS) $(JSON_LIBS)
-libtfjson_la_LDFLAGS = $(MODULE_LDFLAGS)
-endif
--
1.7.10.4
More information about the syslog-ng
mailing list