pqueue.[ch]: Update license (and some comments)

The author of libpqueue, Volkan Yazici, emailed me mentioning
that Tom Callaway of RedHat had pointed out a licence
incompatibility between libpqueue and the rest of the code,
with a suggestion that I update the code accordingly.

Reported-by: Volkan Yazici <volkan.yazici@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
.gitignore test output

Signed-off-by: Andreas Ericsson <ae@op5.se>
Rename <objecttype>_SKIPLIST macros to OBJTYPE_<objecttype>

We retain the old ones for backwards compatibility, but since we don't
really want to use skiplists at all, we don't want to mention them
either, and the algorithm-agnostic names are much nicer to use.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Stop using the <objecttype>_SKIPLIST macros

We implemented OBJTYPE_<objtype> to have something algorithm-agnostic,
so let's use those instead.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Rearrange xodtemplate.c so all functions in it can be declared static

It's a vipernest of horrible code, but all the functions therein
rely on other functions therein being called first, with the exception
of the entry-level one (xodtemplate_read_config_data), so we really
shouldn't expose any of it to modules.

Why it was originally coded upside down (with callers appearing before
the functions they call), I have no idea, but with this patch we can
at least cut the xodtemplate.h file down to its bare minimum and have
the linker warn us about unused functions, as well as optimize the
config parsing code slightly better.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Avoid initializing variables twice

Only for the xodtemplate_free_*_skiplists functions, but it bugged
me so now it's gone.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Don't overallocate hash tables

We have the macro NUM_HASHED_OBJECT_TYPES to mark which objects
we need to hash, so let's use that for object_hash_tables.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add red-black trees to libnaemon

Red-black trees provide fast insert, find and remove, as well as
in-order traversal (also post-order and pre-order, but those are
less important for us), in O(n) storage space and O(log n) time.
They are far superior to skiplists in every way, so we're looking
to replace that horrible algorithm with this nice one instead.

There are also other areas where we can make good use of red-black
trees where skiplists are just horrible to work with.

While at it, we make "NAEMON_{BEGIN,END}_DECL" the default macros
to use to make C++ work, while retaining the NAGIOS_* macros as a
backwards compatibility thing.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Replace skiplists with red-black trees in xodtemplate.c

Red-black trees perform better, use less memory and is not a
laughably stupid algorithm. All tests pass so and the
generated object.cache files are identical to the old code
for a large number of different configurations.

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