Mk/subdir.mk: add special case for modules/json

modules/json builds libjson-plugin.la instead of simply libjson.la because
of library name clashes (see b9125ddb), however the per-subdirectory
Makefile contained a heuristic to find out what to build at install time.

This heuristic failed for modules/json/ as it didn't meet the convention,
and this patch fixes that.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: rename test_json to test_format_json

As that unit test only covers the $(format-json) template function.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: add libjson-plugin to test_format_json DEPENDENCIES

As the unit tests don't cause the recompile the json plugin.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: add copyright header for test_format_json
json-parser: use LogParser as the return type of the constructor

As we don't use that type for anything but the return type and causes
additional casts on the call sites.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json-parser: fix a segmentation fault in clone

When a json-parser() is referenced from multiple points in the configuration,
it is cloned. However the clone() operation could reference a NULL pointer
if marker was not set.

This patch fixes this issue.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json-parser: fix crash on null values

Old versions of libjson-c used to store C NULL value in the returned
struct json_object, which got dereferenced by json-parser.

Although newer json-c versions seems to have fixed this issue
(0.11 tested here) add a workaround for this case.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: add unit test coverage for json-parser()

This patch implements a unit test for the json-parser() parser object.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json-parser: drop the log_ prefix from the function names

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: rename jsonparser related files to json-parser for consistency

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: remove space between function name and arguments

For consistency with the rest of the syslog-ng codebase.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
Merge pull request #56 from balabit/3.6/f/json-parser-unit-test

3.6/f/json parser unit test