persist-state: added an assertion to check if mapped_counter is managed properly

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoBufferedServer: refactor to make functions smaller

This patch refactors LogProtoBufferedServer a bit to make it easier to
implement multi-line input formats. Among others:

  * it renames fetch_from_buf method to fetch_from_buffer
  * the reading of the input stream is split off to a separate
    fetch_into_buffer() method
  * it gets rid off "flush_the_rest" parameter, a separate function
    is introduced named is_input_closed() that allows the caller to determine
    if there's a chance to read further data into the input stream.
  * a new method named clear_buffer() is introduced that resets the buffer
    to contain nothing.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoBufferedServerState: deprecate buffer_cached_eol member

There are multiple reasons it was a bad idea to stored buffer_cached_eol
in the state structure:
  - the buffer_cached_eol member belongs to LogProtoTextServer in the first
    place
  - the cached_eol is just a cache, it could have been recalculated
    anyway when the state is reloaded, the least concern we have at restart
    time is that we need to relocate the closing EOL mark in our buffer
  - for multi-line support more state would be required.

Since this affects the persist file format the patch needs to work with
old persist files properly. For that reason the member is not completely
removed, but a dummy entry remains. We always set that member to 0, whenever
we load or upgrade a persist entry.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
lib/logproto: move all LogProto files under a subdirectory

Creating a subdirectory to hold all LogProto related files makes things
a bit easier to navigate, especially as I plan to move unit tests
under the respective directories to make them easier to run.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logproto: move unit tests to lib/logproto
test_findeom: fixes compilation warnings about pointer signedness
test_logproto: added testcase to cover the case of actually having an EOL before an EOF
proto_lib.h: introduce PROTO_TESTCASE macro

Instead of calling log_proto_testcase_begin() manually, introduce a macro
that does some housekeeping and removes some cruft from individual
testcases.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
test_logproto: factor out LogProtoServerOptions related testcases to a separate module

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
test_logproto: factor out LogProtoRecordServer related testcases to a separate module
test_logproto: factor out LogProtoTextServer testcases
test_logproto: factor out LogProtoDgramServer testcases
test_logproto: factor out LogProtoFramedServer testcases
mock-transport: add LTM_PADDING value

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoBufferedServer: refactor to make it easier to read

This patch breaks down largish functions in LogProtoBufferedServer
implementation to smaller ones, thus making them easier to grasp.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoTextServer: implement accumulate_line and refactor

This patch introduces a new accumulate_line() method that allows the use of
continuation lines.

Testcases were split to give a better indication of what went wrong in the
code, and a number of new testcases were added.

Functions in the implementation were broken down to smaller ones, to make
the code easier to follow.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProtoIndentedMultilineServer: introduce new indented-multiline protocol

This new protocol implementation allows the use of multiline messages,
by treating indented lines as continuations of the last line. This format
is being introduced in /dev/kmsg.

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