nagiostats: Make the -s flag useful once more

It used to be used for reading some format that no longer exists,
but the helptext indicated it was supposed to be used to read a
normal status.log file (and thus just bypass the nagios.cfg).
Since there are no tools to generate the now-dead format, we
simply re-use the -s flag to mean "status.log format".

As a nice side-effect, we can remove quite a lot of dead code.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Revert "Revert "Janitor patch: Fix -Wset-but-unused warnings""

This reverts commit 67cd2417b7bf7b7fe11c2d458e272158796b878e, which
reverted a previous commit where a logical error had snuck in,
causing macro resolution to fail horribly. This fixes all warnings
the original commit was supposed to fix, but without the bug, which
I blame the weird indentation for in order to avoid responsibility
for not testing my own patches ;)

Spotted-by: Ricardo Maraschini <ricardo.maraschini@opservices.com.br>
Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Fix checking of return-value for schedule_new_event()

Since we changed it to return a pointer to a timed_event, we've been
getting compiler warnings from cmd_signal_process().

This patch silences the warning by properly checking the return value
of schedule_new_event() and returning properly based on its result.

We still ignore the result at the original callsite, but at least now
we get rid of the "pointer-to-int conversion" warning gcc used to
throw at us.

Patched-by: Ricardo Maraschini <ricardo.maraschini@opservices.com.br>
Message-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Fix compiler warning about implicit asprintf() declaration

Accordingly to feature_test_macros(7):
  "NOTE: In order to be effective, a feature test macro must be
  defined before including any header files."

As we already define _GNU_SOURCE on config.h, pushing its include up
top will suppress the "implicit declaration of function ‘asprintf’"
warning message during compilation.

Patched-by: Ricardo Maraschini <ricardo.maraschini@opservices.com.br>
Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Avoid 'set-but-unused variable' warning

The temp_buffer in my_system_r() is only ever (really) used when
embedded is compiled in, so we move the declaration to inside the
conditional code from its previous location outside it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/squeue: Remove unused function squeue_foreach()

It's only used in testing, so remove it for now.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Prep for installing nagios headers in system include files

This quite simple patch allows us to put Nagios' header files
from include/ in /usr/include/nagios (for example) and the
headers from lib/ in /usr/include/nagios/lib and everything
will keep on working just fine without any special build-flags
for projects that want to use either the headers or some of
the library parts.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add lib/test-squeue

And also add the infrastructure needed for adding more tests
following the same pattern later.

Signed-off-by: Andreas Ericsson <ae@op5.se>
libnagios: Add key/value vector API

This is a (very) simple and straightforward api used to gather and
managed arrays of key/value pairs in a CPU-efficient manner, which
includes array-to-buffer conversion and buffer-to-array conversion,
making it highly useful for IPC.

Signed-off-by: Andreas Ericsson <ae@op5.se>
libnagios: Add io cache api

It's actually slightly misnamed, as it basically only contains
helpers to read large chunks of data and then partition that data
into the desired bits and pieces. It currently supports getting
either fixed-size chunks or chunks by end-of-message sentinel
byte sequences.

Signed-off-by: Andreas Ericsson <ae@op5.se>
.gitignore library test programs

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/Makefile: Remove test programs when cleaning

Signed-off-by: Andreas Ericsson <ae@op5.se>
libnagios: Add I/O broker library

Severely nifty for watching filedescriptors for input, and a lot
lighter on memory usage and cpu than both libev and libevent,
although only for relatively small sets of watched filedescriptors
and without support for timers, signal watchers and other jazz
that lib{ev,event} bring along and we don't need.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/Makefile: Avoid using test-coverage flags by default

They're nifty when writing tests, but pretty counterproductive for
production code.

Signed-off-by: Andreas Ericsson <ae@op5.se>
libnagios: Add test coverage support to libnagios' Makefile

'make coverage' in the lib directory will now print candidates
for testing. iocache seems to be the primary candidate for
more tests.

Signed-off-by: Andreas Ericsson <ae@op5.se>
libnagios: Add tests for and fix bugs in iobroker_strerror()

Having such easily tested functions untested was just plain dumb,
which was proven quite quickly.

Signed-off-by: Andreas Ericsson <ae@op5.se>
.gitignore gcov files

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/squeue: Avoid name clashes with pqueue()

This lets us include the pqueue.c file directly into tests alongside
squeue.c if we want to.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/test-iobroker: Stop #include'ing iocache.c

It messes up coverage reports for iocache.c, so we'd best avoid it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
lib/Makefile.in: Use debugging flags when building coverage tests

And also make test-suit fail hard if some tests don't pass.

Signed-off-by: Andreas Ericsson <ae@op5.se>