Improve string escape performance a little

Instead of escaping a string, returning a new one and running strlen()
on that, use an output variable to store the length, since we can
easily calculate that during the escape process anyway.

This should shave off a tiny bit of CPU time.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Free up the JSON buffer on exit

This adds a destructor that simply frees up the JSON buffer, so that
to not upset valgrind and similar tools too much.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
NEWS: Finalise for 0.2.0.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
configure.ac: Bump version to 0.2.0

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Properly reset the JSON buffer in all cases.

Previously the JSON buffer was only reset when ul_vformat() was
called, but not everything goes through that, so some messages ended
up being garbled.

The proper thing to do is to reset in _ul_vformat(), as everything
goes through that, and that's the right place to do this anyway.

Reported-by: Peter Czanik <czanik@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Resolve facility & priority properly

The priority passed to the syslog() call can contain a facility
embedded, so we need to extract it to find both the facility and the
priority.

This also means that the facility set at openlog()-time can be
overridden later, so _find_facility() has to take the priority value
into account.

This patch makes libumberlog do just the above: extract both priority
and facility from the priority passed to syslog(), and if facility is
0, use the default set at openlog()-time, if any.

Added a test case to test this expected behaviour.

Reported-by: Peter Czanik <czanik@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Add Travis CI control file

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
travis.yml: Use sudo to install dependencies

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Add a closelog() wrapper to clear the environment

Our openlog() wrapper fills in a couple of variables, and those were
kept around even after a closelog(), and thus, affected ul_format()
calls even after a closelog().

This in turn, made one of the test cases fail, as that was relying on
the default behaviour, which was modified due to an openlog() in an
earlier test case.

We now wrap closelog() aswell, and NULL out our settings to get a
clean state, and add a test case to verify this behaviour aswell.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
.gitingore: Ignore a few more generated files

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Add the build-status link to README.rst

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Preparations for 0.2.1

Bump software and library interface versions, and start adding NEWS
entries.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Convert the test suite to Check

While assert() is a neat tool, it is not really suitable for testing,
as it gives hardly any indication on what part of the test suite
failed, and why.

For this purpose, an existing testing library, such as Check is a much
better option, so lets use that!

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Merge branch 'feature/test-suite/check'
.travis.yml: Install check too

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Generate the manual page if rst2man is present

If rst2man is present at configure time, generate the manual page with
it, which is to be included in the dist tarball too.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Reduce the number of memory allocations

Make the string escape use an ul_buffer_t, to avoid unnecessary memory
allocations. This greatly reduces the number of mallocs made, and thus
results in a noticable increase in speed.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
Mention docutils in the README

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
NEWS: Finalise for 0.2.1

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Merge tag 'libumberlog-0.2.1' into debian

libumberlog 0.2.1 release