Revert "Janitor patch: Fix a bunch of -Wset-but-unused warnings"

This reverts commit 8e6295d295dfeec0f884e5e45a17cb22b05921cd,
which apparently broke macro resolution somehow.

This seems to indicate that gcc did something wrong somehow,
which is pretty worrying in itself, but since I'm currently lazy
and it's far easier to live with compiler warnings than to locate
the one triggering this bug, the extra 100 or so bytes of stack-
space these variables waste will have to be wasted for a while
longer.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Remove 'configure.h' from Nagios' header files

This makes it possible to use the headers in a -devel package
without worrying about conflicts in autoconf generated headers
for eventbroker modules.

Everything compiles and runs just fine with this change, so it's
odd that noone's made this change earlier.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add library code for binary heap implementation of event queue

... and a scheduling queue built on top of the pqueue code.

While we're at it, we also put in the buildsystem boilerplate code
for adding library components later.

The rule for anything entering the library is that it can't depend
on anything outside the lib/ directory, making the code 100%
reusable for addon projects.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Re-generate ./configure

Why do we keep this under version control?

Anyways, when it's a single commit it can be skipped when rebasing,
so it's not *that* much of a hassle.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Add #define NSCGI to all cgi programs

This way we can start getting rid of the #ifdef NSCORE things and
provide header files that don't require eventbroker authors to

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Make the function with the world's longest name thread-safe

delete_downtime_by_hostname_service_description_start_time_comment
previously failed to lock the nagios_downtime_lock. This patch
corrects that, making it safe to use from threads in eventbroker
modules once more.

Signed-off-by: Andreas Ericsson <ae@op5.se>
core: Use priority queue based event queue instead of linked lists

The linked lists have O(n) insertion time, worst case. The theory
is that this worst case scenario shouldn't happen all too often,
since events should, most of the time, be scheduled after all
other events that are already scheduled. In a real-world scenario
with 2500 hosts and 55000 service checks, with all scheck scheduled
at a 5 minute interval, this failed pretty hard due to the linear
behaviour of the old algorithm.

With the new squeue-on-top-of-pqueue implementation, we're
guaranteed O(lg n) behaviour for insertion and removal.

Although pop() (extract next event) moves from O(1) to O(lg n)
due to the need for bubbling of remaining events, we still make
a *huge* win due to this change, and get a far more predictable
behaviour even when we run into larger configurations where
check scheduling may not be a fixed interval for all checks.

The relevant profiling data from two runs of ~5 minutes each
(discrepancies in runtime is due to Nagios shutdown time) is as
follows:

Before:
  %      self              self     total
 time    seconds   calls   s/call   s/call  name
 74.57    47.35    70563     0.00     0.00  add_event

After:
  %      self              self     total
 time    seconds   calls   s/call   s/call  name
  0.00     0.00    76782     0.00     0.00  add_event

From 74.57% of the allotted cpu-time over a 5-minute period to an
immeasurably small amount is pretty good, even if I do say so
myself ;)

For smaller configurations, the benefits will be negligent and
the performance gains become more noticeable the larger the setup.

A downside of this patch is that the sizes and layouts of the two
structs timed_event and scheduled_downtime have changed. Since
none of the four major eventbroker modules (NDOUtils, Livestatus,
mod_gearman and Merlin) use them or are affected in any way, I
really don't care about that at this point in time.

Thanks-to: Volkan Yazici <volkan.yazici@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
Mention libpqueue author Volkan Yazici in THANKS file

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