War on #ifdef NSCORE

I was recently bitten (again) by having written a small test-module
that forgot to #define NSCORE in the build-process, causing it to
behave oddly. Removing the '#ifdef NSCORE' statements entirely from
the header-files and replaceing it with the (for our sake) equivalent
'#ifndef NSCGI' takes care of such issues once and for all.

Now modules no longer need to care about macros used only by Nagios'
build process. That's a Good Thing, even if I do say so myself.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2674 5f96b256-904b-4d8d-8c98-d829582c6739
libnagios headers: Janitor patch; Pre-revamp cleanup is Such Fun(tm)

We do rename the CMD_HAS* macros to RUNCMD_HAS* here, but since
they aren't used by any of the larger modules anyway, we might as
well do it before people start using them.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2675 5f96b256-904b-4d8d-8c98-d829582c6739
lib/nsutils: Welcome to the world

This breaks apart the current lib/worker.c and removes some of the
not-really-compatibility macros from lib/lnag-utils.h and puts them
in a file of their own, so we can implement a sane naming standard
for the functions and macros that actually relate to worker
communications.

While at it, we give the newly-homed functions new names, with their
old names as aliases, and provide deprecation notices for them so
our module authors know they'll be gone in 4.1.0.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2676 5f96b256-904b-4d8d-8c98-d829582c6739
core: Publish and augment qh_strerror()

It's generally useful to have other functions be able to grok the
qh-returned error codes and print useful error messages from them,
so let's make that possible.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2677 5f96b256-904b-4d8d-8c98-d829582c6739
core: Handle command file worker without help from the wproc api

It really is a special case, so handling it manually means we can
work a lot more freely with the wproc and worker api's.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2678 5f96b256-904b-4d8d-8c98-d829582c6739
core: Remove wproc_destroy() from the public scope

This is the only place linking the wproc stuff to the worker api.
Removing it gives us a lot more freedom in terms of how we can
modify both worker and wproc api.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2679 5f96b256-904b-4d8d-8c98-d829582c6739
core: Use check-result source as a char pointer if no engine is set

This is probably what I should've done from the start. Since each
check has to come in through some sort of interface anyway, marking
it with a const string at the entry point would've been a lot easier.

Gods damn past me :-/

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2680 5f96b256-904b-4d8d-8c98-d829582c6739
lib/worker: Move spawn_worker() to the wproc tester program

It's the only caller, and we really shouldn't expose or have to
maintain our structures only for the sake of a testing program.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2681 5f96b256-904b-4d8d-8c98-d829582c6739
lib/worker.c: Remove 'struct request'

It's not public and not used, so off it goes.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2682 5f96b256-904b-4d8d-8c98-d829582c6739
base/workers: Fix eventhandler timeout settings

The workers expect to get the timeout in relative time. If we
send it in absolute time the value will overflow when the worker
adds the current time to it, meaning the job times out directly.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2683 5f96b256-904b-4d8d-8c98-d829582c6739
lib/worker: Rename send_kvvec() to worker_send_kvvec()

Getting and using some sort of namespace for the worker code is
nifty. This is at least a step in the right direction. Since the
library is intertwined with the default core worker, that's gonna
be pretty hard, so we'll simply have to take what we can and run
with it.

The patch is bigger than it should have been, since we have to
keep send_kvvec() in both the library and the headers until it's
had its grace deprecation period.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2684 5f96b256-904b-4d8d-8c98-d829582c6739
lib/worker: Add and use routines to parse messages from buffers

This hides the previously public KV_SEP and PAIR_SEP macros from
public viewing and replaces them with opaque interfaces, which means
our callers no longer need to know the internals of how workers
communicate with one another (although it's publicly documentated
so people can write workers in other languages).

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2685 5f96b256-904b-4d8d-8c98-d829582c6739
Rename set_socket_options() to worker_setsockopts()

Same deprecation dance as with send_kvvec() -> worker_send_kvvec()

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2686 5f96b256-904b-4d8d-8c98-d829582c6739
doxy.conf: Help doxygen handle the NAGIOS_DEPRECATED() macro

It doesn't do a very good job of it on its own.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2687 5f96b256-904b-4d8d-8c98-d829582c6739
core: Make nagios_check_engine stop using the worker_process type

It's kinda silly to ship the entire type when it only feeds back
a string from it anyway, when we can just ship the string as-is
and save ourselves some trouble.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2688 5f96b256-904b-4d8d-8c98-d829582c6739
Make the worker_job and worker_process structures opaque

worker_job is really destined for transparency, but for now there's
no real need so we keep it private for the time being.

This means we can modify the worker manager structures at will and
thus paves the way for extending the job-running api as much as we
like.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2689 5f96b256-904b-4d8d-8c98-d829582c6739
lib/wproc: Fix some compiler warnings

printf() int vs long thingies.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2690 5f96b256-904b-4d8d-8c98-d829582c6739
lib/worker: Stop using the deprecated set_socket_options()

Deprecation warnings are neat.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2691 5f96b256-904b-4d8d-8c98-d829582c6739
lib: Make NAGIOS_DEPRECATED work for compilers older than gcc 4.5.0

The optional message argument to the deprecated attribute was added
in gcc 4.5.0, so older versions of gcc fail to build Nagios without
this patch.

As a neat side-effect of how we implement the thing, we also get a
NAGIOS_MKVERSION() macro, which can be used to set API versions for
various parts of Nagios and libnagios, which will come in handy for
handling incompatibilities.

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

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2692 5f96b256-904b-4d8d-8c98-d829582c6739
Macros: fix of invalid free for TOTALHOSTSERVICES* macros

The $TOTALHOSTSERVICES*$ macros were computed all at the same time, with the
result stashed in mac->x using the mkstr method (from worker.c? why worker.c?)

The mkstr uses an static internal buffer of usally 256 strings, of each 32
bytes, for generation of strings, used in macros. When computing
TOTALHOSTSERVICES*, the valuse is, as said, stashed in mac->x[], which is freed
 at cleanup, with some exceptions, and this isn't one of them.

Those needs to be exceptions, so static function variables isn't freed

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@2693 5f96b256-904b-4d8d-8c98-d829582c6739