logthrdestdrv: make the thread ivykis based.

It is easier to add timer, task, event etc. to the threaded destination,
and this re-factorizing eliminates the locking and waiting for conditions.
And the throttle timeout handling is also added to logthreaded destination.

Make this code is more maintainable.

Signed-off-by: Juhász Viktor <viktor.juhasz@balabit.com>
logreader: Memory leak fix

Free poll_events in log_reader_free().

Signed-off-by: Tibor Benke <tibor.benke@balabit.com>
afsocket: Memory leak fix

If the configuration stays the same during a reload, log_reader_set_peer_addr()
is already called and log_reader_set_peer_addr() doesn't unref its previous
peer_addr.

Signed-off-by: Tibor Benke <ihrwein@gmail.com>
json: json-c 0.12+ compatibility

In order to be able to build with both json-c 0.9 and 0.12+, we need
some compatibility shims, to replace deprecated functions. This patch
adds just that, surrounded with appropriate ifdefs. Based on a patch by
Balazs Scheidler <bazsi@balabit.hu>; this fixes #153.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Merge branch 'h/json-c-0.12'
Merge pull request #160 from juhaszviktor/logthrdestrefact

logthrdestdrv: make the thread ivykis based.
Merge pull request #166 from ihrwein/f/afsocket-memory-leak-fix

afsocket: Memory leak fix
logwriter: still free the unconsumed item during reloading configuration

Otherwise we have no chance to free this stuff.

Reported-by: Xufeng Zhang <xufeng.zhang@windriver.com>
Signed-off-by: Tusa Viktor <tusavik@gmail.com>
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
socket: Various leak fixes in afsocket module.

TransportMapper and SocketOptions structures are not embedded ones, so
they should be freed up, when freeing up drivers.

Reported-by: Xufeng Zhang <xufeng.zhang@windriver.com>
Signed-off-by: Viktor Tusa <tusavik@gmail.com>
Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
templates.h: add inclusion of plugin.h

Macros in templates.h may use the plugin API, which is thus a dependency,
include that so that the call-site doesn't need to.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg-grammar.y: allow additional top-level blocks parsed by plugins
system-source: parse @cim marked messages by json-parser automatically

This allows any local applications to submit JSON formatted messages
through the syslog() API, which will automatically be parsed. A ".cim."
prefix will be added to the fields extracted.

The same values can be reconstructed using a value-pairs expression,
something like:

  $(format-json --key .cim.* --shift 5)

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg.c: create separate method for registering builtin plugins

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg-tree: add cfg_tree_template_exists() function
test_template_compile: create get_template_function_ops()

This new function makes it easier to describe LTE_FUNC elements.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
templates.c: extract log_template_prepare_function_call()

In order to make log_template_add_func_elem() easier to read (and to prepare
a new feature there), extract log_template_prepare_function_call()
that sets up the template function invocation given the implementing
plugin.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
templates.c: extract log_template_lookup_and_setup_function_call()

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>