gprocess: introduce g_process_get_mode() to query the current execution mode
tags: log_tags_init/deinit renamed to log_tags_global_init/deinit

Rename global init/deinit functions for consistency with other similar
functions.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
stats: fix a failing assertion when stats_level() is changed

When stats-level() is changed and syslog-ng is reloaded, an assertion failed
in the facility counters unregistration. The reason was that
the unregistration used the 'other' category instead of the one assigned
to the given facility code.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
tags: update stats counters at reload time

When a tag is registered, the final value for stats-level() may not
be known. Also, when the stats-level() is decreased with a reload,
already registered counters might need to be unregistered.

This is solved by a log_tags_reinit_stats() function call, that is invoked
at cfg_init() time, this then in turn iterates on all registered
tags and registers/unregisters counters as needed.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
stats: add "snmp" stats source
logproto: remove dead code from test-regexp-multiline-server

As it seems I have left this unit test half-way finished, clean the
remnants of the indented-multiline tests that I used as skeleton.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
gsocket: introduce global init/deinit functions

This patch add a g_socket_global_init()/deinit() functions that allows
explicit initialization of socket related code. It is used to
initialize winsock2 on Windows.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cache: added a new module that encapsulates generic caching of values

This module adds a generic caching implementation that resolves values
on-demand and stores values in a GHashTable. No expiration and size
limits are possible as of now, these can be added later on.

The hash is indexed by a simple string key.

Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
reloc: new module that implements autoconf path expansion

In autoconf the installation layout is controlled by shell variables that
are expanded recursively.

For instance, we have a prefix variable and then this gets referenced in
sysconfdir by having the value '${prefix}/etc'

Earlier, the configure script did the expansion prior to putting these
values in config.h, now this is being pushed to the syslog-ng binary
so it can be relocated after compilation.

The new reloc module implements the shell-like substitution and
a PathResolver class which can be used with a Cache instance to resolve
autoconf-style directory layouts.

Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Tamas Pal <folti@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
reloc: implement relocatable syslog-ng binaries

This patch changes the configure script not to expand the directory
layout variables before pushing them to the C code. Rather,
they will contain ${prefix} style variable references that get
resolved at runtime.

In addition to the configure changes, this patch also changes syslog-ng to
invoke get_installation_path() at the proper places so at runtime
these really get resolved.

With this patch, it is now possible to define SYSLOGNG_PREFIX environment
variable and syslog-ng will look for all its installed parts under
that directory in the layout set by the configure script.

Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Tamas Pal <folti@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
filter-cmp: use scratch buffers for template evaluation
LogRewrite: publish log_rewrite_init_method()

To make it available in descendant classes.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logmatcher: added error quark

This patch adds the boilerplate to generate LogMatcher specific GError
values, which I intend to use in subsequent patches.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
filter-expr-grammar: use CHECK_ERROR_GERROR() in comparison

This makes this code somewhat easier to read.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logmatcher: added LogMatcherOptions struct and related cfg-grammar rules

Whenever a LogMatcher instance was to be created (most notably in filter and
rewrite rules) we had a chicken and egg problem. The flags to be used by
the LogMatcher instance was stored within the LogMatcher instance, however
the kind of LogMatcher instance (posix, pcre, etc) was also parsed together
with flags.

This meant that parsing code had to create a default LogMatcher, which
was replaced when the actual type was parsed. This replacement
was not straightforward though, we had to keep the flags value in case
it had been parsed previously.

This patch delegates LogMatcher parsing to the core cfg-grammar, users
only need to invoke the matcher_option rule and set last_matcher_options
in vein similar to other *Options stuff.

The patch also improves error handling, as flags/regexp compile
errors are propagated back to the grammar, so we get a nice error page. This
required an API change to return a GError in case of failure.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
versioning.h: add 3.6 specific version code, switch default version to 3.6

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
configure.ac: make pcre a hard dependency

This patch removes the ENABLE_PCRE conditional, as well as making the
pcre dependency a requirement.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logmatcher: added store-matches warning to PCRE LogMatcher

As we are changing the default matcher implementation the warning on the
'store-matches' flag should be triggered by the PCRE matcher too. This
patch does exactly that.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logmatcher: change the default matcher to PCRE instead of POSIX

This patch changes the default LogMatcher implementation starting
with syslog-ng 3.6. If the configuration indicates an earlier version
using the @version pragma, it still uses the POSIX implementation and
issues a warning to the user to update her config.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoREMultiLineServer: use pcre instead of posix regexps

Now as PCRE is a hard dependency, we can prefer using that in our
multi-line implementation. It is faster anyway. The patch also
refactors multi-line regexps to a separate object.

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