cfg-grammar: free GError on error paths

In some cases the GError returned by various functions wasn't properly
freed.  Introduce a new macro CHECK_ERROR_GERROR() that reports the
error properly and at the end frees it as well.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoTextServer: make it possible to drop the end of a line in accumulate_line()

This patch introduces LPT_CONSUME_PARTIALLY() macro that piggybacks
the number of characters to be dropped from the end of the line. This
is the processed by LogProtoTextServer right before returning the line.

Note that it is not possible to drop arbitrary line ends, it only works
at the end of the line, as characters are not moved in the input buffer in
any way.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoREMultilineServer: implement regexp based multiline support

This patch implements LogProtoREMultilineServer that can be used to read
multi-line files with syslog-ng PE style, multi-line-prefix() &
multi-line-garbage() options. A subsequent follow-up patch will make this
actually configurable in the affile source.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
affile: added support for regexp based multiline input files

This patch adds multi-line-mode(regexp), multi-line-prefix() and
multi-line-garbage() options to the file source driver.

There are two regexps that define the boundaries of multi-line blocks
within a source file:

  - prefix: starts a new line and is part of the log message
  - garbage: indicates the end of a line and is NOT part of the log message

Such an input:

prefix message
continuation garbage

Becomes this message: "prefix message\ncontinuation" with this definition:

file("..." multi-line-mode(regexp) multi-line-prefix('^prefix') multi-line-garbage(' garbage$'));

Regexps are matched against individual lines as they are read by syslog-ng,
thus ^ matches the beginning of the current line, and $ the end of the
current line.

The buffer of the input is sized according to the log-msg-size() parameter,
and in order to work properly, all physical lines of the multi-line block and
one subsequent physical line must fit into the input buffer. So if
you want N bytes multi-line records maximum, set log-msg-size() to
N + M, where M is the length of your maximum physical lines.

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