Added SAVED_DATA plugin output part which is any data after '||' coming from plugin output. Rewrote most of parse_check_output function (it no longer uses unsafe strtok) and added HOST_SAVEDDATA and HOSTSAVEDDATA and SERVICESAVEDDATA macros.
Plug a leak in common/objects.c

It seems I forgot to remove the separate object allocation for
serviceescalations when I did the "one allocation" patch. This
remedies that and makes "nagios -v -s" once again leak-free.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2117 5f96b256-904b-4d8d-8c98-d829582c6739
Remove incomplete failure prediction code

Failure prediction analysis is difficult and requires knowledge of
plugin values. One of the very strong points about Nagios is that
it doesn't have to care about plugin output (beyond storing and showing
it), so adding failure prediction on a global scope makes very little
sense. It would be doable by something that recognizes performance data
and can spot trends in such data. That's an excellent task for an
addon, but we'd do better not to riddle the core with such code.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2118 5f96b256-904b-4d8d-8c98-d829582c6739
common/objects.c: Never free() objects taken from pre-allocated lists

Doing so will cause the entire block to be free()'d, and thus
invalid for future references. This was supposed to go in the
one-time allocation patch, but apparently I missed these back then.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2119 5f96b256-904b-4d8d-8c98-d829582c6739
common/objects: Fix freeing contacts

Contacts used the 'i' variable when looping over objects, which
caused the iterator to jump up to seven the first time we iterated,
and then stay there for the remainder of the time. This triggered
a nasty bug where we'd go into "undefined behaviour" (often an
infinite loop or a coredump, as it turns out), when freeing contacts.

This bug only triggered when there was more than seven contacts in
total, which made it pretty hard to find at first.

The fix is simple though. We add a new iterator variable for the
contact addresses and use that when freeing them.

While at it, we remove an invalid free(), which was hidden by the
bug mentioned above.

Many thanks to Mike Guthrie and Ken Menzel who provided me with test
configs, as well as to Mark Frost who fixed the config anonymizer.

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

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

When we have better ways of ensuring uniqueness in a linked list,
we might as well not traverse the entire thing every time we add
something to it, but having this little helper is nifty for those
occasions.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2121 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Fix group recombobulation

Previously we used to strcat() increasingly huge strings together.

With this patch, we create lists immediately instead. We could
actually improve even further upon the config parsing time by
registering group-contained objects before we recombobulate the
groups, but with this patch things seem pretty fast enough.

The one downside is that members are written in reverse order
in the precache and objects.cache files, but nothing (that I
know of) really cares about that, so I won't either. If it turns
out to be a problem, we can use the slow linked-list insertion
sort already present, but that would be slower.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2122 5f96b256-904b-4d8d-8c98-d829582c6739
Make cgi's compile with new group recombobulation code

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2123 5f96b256-904b-4d8d-8c98-d829582c6739
Merge remote-tracking branch 'upstream/master'

Conflicts:
	base/checks.c
	base/config.c
	configure
Merge branch 'master' of https://github.com/willixix/nagios

Conflicts:
	common/macros.c
	include/macros.h
xdata/xodtemplate: Fix host and service dependency counting

Previously we would allocate too little space for dependencies if
they were assigned to groups, since we failed to take into account
the duplicated dependencies. This patch fixes that, avoiding the
invalid writes we issued earlier that lead to (very) undefined
behaviour when we tried to handle whatever data we accidentally
overwrote.

Many thanks to Mark Frost for helping me locate this bug.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2124 5f96b256-904b-4d8d-8c98-d829582c6739
contrib: Make stuff build properly with libnagios

Thanks to Daniel Wittenberg for keeping an eye on me ;)

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2125 5f96b256-904b-4d8d-8c98-d829582c6739
Remove failure_prediction options from test and sample configs

Patched-by: Daniel Wittenberg <dwittenberg2008@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2126 5f96b256-904b-4d8d-8c98-d829582c6739
lib/bitmap: Allow unions between one set and the empty set

Previously we required two valid bitmaps to be passed to bitmap_union
and bitmap_unite, but taking the union of a set and the empty (NULL)
set is a valid operation that yields "the other" set. unioning two
empty sets ofcourse yields the empty set, so we're covered from all
angles.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2127 5f96b256-904b-4d8d-8c98-d829582c6739
base/config: Print number of checked host/service dependencies

We used to do that when we verified the data in them, and now we do
it again when we assure their acyclicity (if that's not a word, it
should be).

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2128 5f96b256-904b-4d8d-8c98-d829582c6739
Revert to old-school group recombobulation

Group recombobulation turned out to be a tad trickier than I first
thought, and while it's broken a lot of people are unable to test
Nagios 4 in any sort of long-running scenarios.

Unortunately, the dfs dependency patch ended up with the first
implementation on one side of the buggy recombobulation patch and
the fix of the first implementation on the other side, meaning
noone could really test any of it properly.

To get a clean revert, we also remove the buildfix for the group
recombobulation patch.

This reverts the following commits:
2059816f862b36598ce5301156f8a3c621712f9a
  Make cgi's compile with new group recombobulation code
abe461837d1a0955ef64d714b318e11a1a19cf18
  xdata/xodtemplate: Fix group recombobulation"

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2129 5f96b256-904b-4d8d-8c98-d829582c6739
base/config: Fix free()'ing of arrays in pre_flight_circular_check()

With high levels of optimization, the compiler would unroll the loop
and could yield code that tries to free() array subscripts with
negative numbers. We restrict the test to make sure the index never
goes below 0 and decrement it before checking to restrict the
compiler not to unroll that particular loop.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2130 5f96b256-904b-4d8d-8c98-d829582c6739
crafting my_free() further to avoid possible issues and make sure compiler notices if you forget semicolon
common/objects: Avoid using uninitialized memory

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2131 5f96b256-904b-4d8d-8c98-d829582c6739
lib/skiplist: Plug a memory leak on duplicate inserts

Previously we used to allocate space for the new entry before we
checked if it was unique. With this patch we can return an error
before we take any memory and thereby avoid leaking it.

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

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