common/objects: Add prepend_unique_object_to_objectlist()

This is quite nifty when adding host and servicedependencies, which
can currently be duplicated (with identical values) any number of
times by having hosts join multiple hostgroups and assigning
dependencies to each of them. It might be too slow to bother with,
but services normally don't depend on more than one other service,
so it should be fairly quick.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2199 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Ignore 'n' option dependencies

We don't create dependencies that are missing one (or more) of the
listed options, but we do create dependencies that have the 'n'
option as its sole failure criteria, which is essentially the same
as no criteria, except it's more verbose and more likely that a user
has no idea it will sit in RAM and consume memory while doing
absolutely nothing. With this patch, such dependencies will no longer
be created. This lets us save a smallish amount of time during config
loading.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2200 5f96b256-904b-4d8d-8c98-d829582c6739
commono/objects: Only allow unique dependencies to be registered

"unique" here means differing in at least one byte of their fully
filled out definition, since multiple identical definitions just
wastes both cpu and memory.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2201 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Register dependencies ad-hoc

By registering dependencies as we encounter them, we can ensure
that there are no duplicates and that we never waste memory storing
any duplicates. This comes at the expense of us having to allocate
the objects on the fly (which is slower than chunk-allocating, but a
lot faster than swapping), and not being able to assign id fields
until after all config is read (since we need to compare the deps
with each other).

There's a lot of fallout from this conceptually simple patch, so I
hope I got everything right.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2202 5f96b256-904b-4d8d-8c98-d829582c6739
Kill off long-since dead variables

comment_file and downtime_file haven't been used for a very long
time, so it's about time they start throwing errors.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2203 5f96b256-904b-4d8d-8c98-d829582c6739
core: Initialize object cache files to heap-allocated variables

We free them unconditionally later, so this is necessary to avoid
ye ole "undefined behaviour" in case the user hasn't specified one
of them in nagios.cfg.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2204 5f96b256-904b-4d8d-8c98-d829582c6739
Save extinfo yet a while longer

I was 30 seconds from throwing them far, far away, but I found
the ridiculous little typo just in time. Thank god for valgrind.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2205 5f96b256-904b-4d8d-8c98-d829582c6739
Avoid coredumps when duplicating serviceescalations

Previously we forgot to set the master_servicelist to NULL before
each round of the loop, causing us to bomb out. This patch fixes it.

Thanks to Chris Beattie for sending me test-data to uncover it.

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

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

Previously we overwrote it for each service dependency we created
when dealing with same-host dependencies, which appeared to work
just fine but really didn't.

With this patch we once again assign all dependent services to all
master services for same-host dependencies.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2207 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Reset child list for same-host servicedependencies

Otherwise we should (technically) get an ever-increasing list of
objects to choose from and duplicate servicedependencies as if they
were porn on a torrent site.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2208 5f96b256-904b-4d8d-8c98-d829582c6739
xdata/xodtemplate: Fix serviceescalations on hostgroups

Previously we used to bail out early if there was no host_name set,
but serviceescalations can be assigned to hostgroups too. This patch
restores the old functionality.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2209 5f96b256-904b-4d8d-8c98-d829582c6739
xdata: Add serviceescalations with the host_name from the service

We want to get rid of as much memory as quickly as possible, and
assigning variables is one of the fastest ways to do that. We trust
in valgrind to let us know if we screw up somehow.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2210 5f96b256-904b-4d8d-8c98-d829582c6739
xod: Avoid duplicating serviceescalations we shouldn't register

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2211 5f96b256-904b-4d8d-8c98-d829582c6739
xdata: Let create_service_list callers provide us with a reject_map

It works well pretty much everywhere else, so it should be good
here too. Previously we failed to parse servicedependencies such
as this one (where both A and B have only 4 services each):

  define servicedependency {
      host_name                      A,B
      service_description            *,!PING,!PANG,!PONG
      dependent_service_description  *,!agent
      execution_failure_criteria     w,u,c
      notification_failure_criteria  w,u,c
  }

... but with this patch applied, it works as intended, which is
neat.

To efficiently handle the double-directed servicedependencies (oh
how I hate them...), we introduce the 'parent_map' bitmap globally
to this file, which lets us avoid continuously creating and destroing
a separate bitmap just for that purpose.

While at it, we remove the since-quite-some-time-now unused function
xodtemplate_expand_servicegroups_and_services.

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

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