afsql: fixed the failure handling branch in afsql

An "address-of" operator was missing from log_queue_push_head() call,
potentially causing crashes when the insertion of a record fails.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
simplify *Options initialization pattern (LogReaderOptions, LogWriterOptions, etc)

The _init() method for various *Options structures were needlessly
complicated with an ugly warning on top of each and every such function.
After giving some thought to why it needs to be so complicated a much
easier pattern could be created, eliminating most of the complexity.

Earlier *_options_init() methods were prepared to be called several times
without a pairing _options_destroy(), e.g. if any memory was allocated
by init, a repeated init should have preserved the allocation (or at least
free the one the previous invocation allocated). This pattern caused
these init methods to actually save a number of variables locally
before commencing on the actual initialization and then restoring
them afterwards.

After giving some thought, this actually addressed an unused use-case:
if the init method is called for the same Options structure with
a changed GlobalConfig instance. In this case init would've inherited
the changed values from GlobalConfig.

However this never happens in reality, options structures may indeed be
initialized multiple times, however in this case the GlobalConfig remains
the same.

Removing this assumption simplifies the code a lot and makes it much more
readable, and finally stops spreading that terrifying comment on the top
as the pattern got implemented in a number of places.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogTransportPlain: use polymorphic classes instead of a large number of branches in code

This patch splits LogTransportPlain to 5 polimorphic classes to make the
code easier to follow, and possibly split the source code to five files
in the future.
libtest: added LogProto testing framework as proto_lib.{c,h}

In a similar vain to template_lib.{c,h} implement a LogProto related
assertions and helper functions. Centralizing this makes it possible to
test various LogProto implementations from different unit tests easily
without having to duplicate code.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProto reorganization to support plugins

This patch is a large-scale refactoring for the LogProto code, it does
a number of things and should probably be split to a number of independent
patches for easier review. For now it is a single patch.

  * split the abstract base class LogProto into
    LogProtoClient & LogProtoServer. These are quite independent
    (one doing fetches the other posts), so no explanation why they should
    be the same.
  * LogProtoOptions is introduced to hold options related to LogProto
    classes. The options parsed by the core is provided by a
    cfg-grammar rule too (to be included in plugin specific grammars)
  * added valiate_options method that checks at _init() time whether the
    options parsed from the config make any sense. That's the only
    error-handling possibility as the constructor may not return NULL.
  * LogProto classes got split into a number of files, they are provided
    by the core as classes and the ones used as network transports
    are also published as a plugin. This way extending LogProto with
    a module-specific behaviour can use the base classes, and standard
    protocols can be instantiated using the plugin interface (to be used
    as the transport() option for the network/syslog drivers).
LogTransportMock: create separate constructors for the various cases

Instead of putting yet-another-boolean-argument to the constructor,
use separate constructors for the different cases. The implementation
is still using a single read function with conditionals though.
Merge remote-tracking branch '3.3/master'

Conflicts:
	.gitmodules
	NEWS
	VERSION
	autogen.sh
	modules/afmongodb/libmongo-client
	modules/afsocket/afsocket.c
	syslog-ng/main.c
templates.h: added TEMPLATE_FUNCTION_DECLARE macro

This macro forward declares the constructor for a template function, so
it becomes possible to separate the template-function and its registration
as a plugin into separate compilation units.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: rearrange compilation units, rename the plugin and make the unit tests pass

Use a separate json-plugin.c instead of adding this to tfjson,
rename tfjson to format-json as it more clearly defines what that
module implements.

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

Since json-c produces libjson.so and linking libjson.so (from json-c)
against libjson.so (from syslog-ng) wouldn't work, we need to rename our
plugin.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
Merge remote-tracking branches 'origin/hotfix/3.4/system-source-typo' and 'origin/hotfix/3.4/crypto-parallel-make-fix' into sandbox/3.4