core: Make sure configured logfile always trumps default one

Previously we could end up logging to the default location if we
had deprecated variables defined before we defined log_file (which
caused us to write to the log_file set as default at compile time),
but the logging api is clever enough to keep that file open and
won't reopen it unnecessarily.

With this patch, we always close the log_file whenever we run into
the log_file statement, which causes the logging api to reopen it
with the new (and correct) path whenever we want to log something
again.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2698 5f96b256-904b-4d8d-8c98-d829582c6739
core: Log deprecated variables to the 'final' logfile

The previous patch made sure we started writing "real" logmessages
to the right place, but could still cause some logmessages to end up
in the wrong logfile. With this change we protect against that by
adding deprecated variables to a list and printing their warnings
when we're done parsing the entire file (which means we've always
parsed the 'log_file' statement).

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2699 5f96b256-904b-4d8d-8c98-d829582c6739
core: Check timeperiods for circular exclusions

Doing the exclusion logic right means traversing all the exclusions.
If there are circular paths there we might be at it for ever, which
is bad. With this patch we know we don't need to bother checking it
in the timeperiod handling code, which is messy enough as it is.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2700 5f96b256-904b-4d8d-8c98-d829582c6739
cgi: Fix null pointer reference in getcgi.c language selection

Reported as issue 434 to tracker.nagios.org, this only happens on
solaris, where the printf() family functions aren't helpful enough
to replace NULL pointers with the string NULL rather than bombing
out.

While at it, we rename the input parameter so it doesn't collide
with a typename we want to use.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2701 5f96b256-904b-4d8d-8c98-d829582c6739
libfanout: stash next pointer

Stash next pointer for entry when iterating over a linked list in
the "obviously correct" fanout lib.

The next pointer is lost when freeing the entry item in a for loop...
A penny^H^H^H^H^Hpointer saved is a pointer earned, as my grandma used
to say.

Signed-off-by: Max Sikström <msikstrom@op5.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2702 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-runcmd: Make it build with new runcmd flags

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2703 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-nsutils: Update to use the defined functions

Way back I intended to give these utils a common prefix, and the
prefix lived on in the tests but not in the commit that actually
introduced the commit. Bad, bad Andreas...

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2704 5f96b256-904b-4d8d-8c98-d829582c6739
Add lib/test-fanout.c

It's obvious that even obviously correct code sometimes has really
obvious bugs, so obviously we need some sort of testing to make
sure the obviously correct code does the obviously correct thing.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2705 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-kvvec: Add a test for kvvec_capacity

It was the last untested function of the kvvec library, so now we
have full coverage there. Neato.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2706 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-iobroker: Also test iobroker_is_registered()

We run the test on removal and addition, which means we now test
to make sure the iobroker handles internal state exactly as
intended.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2707 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-dkhash: Flesh out with more tests

The counter-functions, among other things.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2708 5f96b256-904b-4d8d-8c98-d829582c6739
lib/test-bitmap: Flesh out bitmap tests a bit

More precise tests for intersections and a lot more coverage, for
example. If bitmap_unset() and bitmap_clear() fail, the config
parsing will be severely fouled up.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2709 5f96b256-904b-4d8d-8c98-d829582c6739
Make sure to set host_ptr for hostscalations

We need it when we post-process the configuration later, so
it had better be set.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2710 5f96b256-904b-4d8d-8c98-d829582c6739
core: Bail out when we fail to read the resource file

It should be a fatal error, so let's make it so.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2711 5f96b256-904b-4d8d-8c98-d829582c6739
cgi/cmd.c: add explicit type for function parameter

Defaulting to int generates warnings. Setting it explicitly is fine.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2712 5f96b256-904b-4d8d-8c98-d829582c6739
Janit patch: Remove redundant declarations

gcc -Wredundant-decls reports a bunch. This gets rid of them,
making the code a bit more maintainable.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2713 5f96b256-904b-4d8d-8c98-d829582c6739
core: Remove debug printf() statement

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2714 5f96b256-904b-4d8d-8c98-d829582c6739
Don't use declarations after statements

It causes compilers that only support C90 to bail out hard and makes
gcc pretty noisy when extra warnings are enabled, so let's avoid it.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2715 5f96b256-904b-4d8d-8c98-d829582c6739
Fix -Wmissing-prototypes warnings

We do this by defining the offending functions as static, thus
removing them from the global scope. This lets the compiler
optimize better, so it's not just about making gcc shut up.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2716 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Count escalations even when using precached objects

Otherwise we'll crash out while reading config from a precached object
file contiaining escalations.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2717 5f96b256-904b-4d8d-8c98-d829582c6739