logsource: Fix host_override() and program_override()

LogSourceOptions->program_override_len and ->host_override_len must be
initialised to -1, otherwise host and program overrides will treat the
value as a 0-length string, as automatic length calculation is only
performed when these values are -1.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
json-format: Unbreak $(format-json)

The $(format-json) template function was misbehaving under certain
conditions, namely where we had a sub-object, a simple value, and
another object starting right after: in this case, no comma was placed
between the simple value and the name of the new sub-object.

The fix changes how comma placement is done completely: it is no
longer a mix of prefix_data & user_data magic, but all state is kept
in the user data, with the _obj_start(), _obj_end() and _value()
functions setting it as appropriate:

- When starting a new object, if we need a comma, we'll put one, and
  turn the comma flag off (the first item within an object won't need
  a comma).
- When ending an object, we never add a comma, but the next item will
  need the comma flag set.
- When adding a value, if the comma flag is set, we add one, and in
  the end, set the flag ourselves, as the next one will need a comma
  too.

This is much simpler than the previous hackery, and also results in
correct JSON in every situation.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
json: The test should not depend on the environment's timezone

The $(format-json) test was failing when a timezone was set in the
environment that did not match the tests expectations.

To fix this, explicitly set the timezone to UTC.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
travis: Significant Travis CI control file updates

To fix issues with uninstallable packages, and to follow the official
recommendation, run apt-get update as part of the testing process (and
also install libesmtp-dev). Also, to make testing more reliable,
install into $HOME, so that we do not need sudo for running the tests.

Furthermore, restrict the tested branches to a subset: master,
upstream mirrors, the sandbox and merge-queue branches. While there,
also enable IRC notifications.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afamqp: New AMQP destination driver

This driver implements an AMQP destination (based on the rabbitmq-c
library), supporting persistence, all the exchange types, and uses a
creative way to get messages accross: all the name-value pairs
selected with the value-pairs() syntax will be sent as headers, while
the message payload can be set with the body() option (empty by
default).

Most settings have sensible defaults, except for a few, noted below:

@module afamqp
destination d_amqp {
    amqp(
        vhost("/")
        host("127.0.0.1")
        port(5672)
        username("guest") # mandatory, no default
        password("guest") # mandatory, no default
        exchange("syslog")
        exchange_type("fanout")
        #routing_key("")
        #body("")
        persistent(yes)
        value-pairs(
            scope("selected-macros" "nv-pairs" "sdata")
        )
    );
};

Publishing the name-value pairs as headers makes it possible to use a
headers exchange type and subscribe only to interesting log streams,
in a much more flexible way than using the routing_key() option.

The routing_key() and body() options can contain any template, they
will be expanded before publication.

Signed-off-by: Attila Nagy <bra@fsn.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afamqp: Disable building with system librabbitmq for now

There is no rabbitmq-c release yet that we can support yet, so for
now, error out if the system version was requested.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afamqp: Make the exchange declaration optional

Do not declare the exchange by default, but allow turning this feature
on via the exchange_declare(yes) configuration option.

Signed-off-by: Attila Nagy <bra@fsn.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
affile: Split into source and dest parts

Similar to the afsocket splits, split affile into source and
destination too, on the file level. We do keep affile-common, for
affile_open_file() and a couple of constants.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
autogen.sh: trigger git submodule init even if only one of the submodules  wasn't yet initialized

The recent introduction of the AMQP destination caused a bootstrap problem,
as ivykis and libmongo-client was already bootstrapped in my tree, thus
rabbitmq-c wasn't cloned properly.

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