utils: Add uninterrupted_write()

This function lets us transparently handle EAGAIN/EINTR during writes
by retrying, which we want to do any time they pop up. This also has the
added benefit of silencing warnings about unchecked returns for write
calls, in addition to actually checking the return and logging a message
if something goes horribly wrong, which should make debugging easier in
the future.

Signed-off-by: Anton Lofgren <alofgren@op5.com>
Merge pull request #76 from catharsis/handle-write-intrs

utils: Add uninterrupted_write()
shadownaemon: make sure command files are cleaned

sometimes command files are not removed properly. Delete
them after they should have been processed to avoid processing
them over and over.
shadownaemon: close sockets when connect fails

this closes a ressource leak on unavailable remote sites.
shadownaemon: fixed endless loop

when full refreshing data it could happen that the shadownaemon gets stuck in an endless
loop when it trys to skip already syncronized comments or downtimes.
This patch makes sure we iterate over all all comments, even if some are skipped.

Signed-off-by: Sven Nierlein <Sven.Nierlein@consol.de>
configure: Add pkgconfig file

Thus, path discovery becomes mostly a non-issue.

You're supposed to use pkg-config to get the library and include path:
 pkg-config --cflags --libs naemon

(or, using autoconf, PKG_CHECK_MODULES([NAEMON], [naemon]) )

You're then supposed to do
 #include <naemon/naemon.h>
to get all the relevant bits of naemon.

Thanks to the -uninstalled file, you can, as soon as you've configured
this repo, build against uninstalled, in-development code, simply by doing
 ./configure PKG_CONFIG_FILE=../naemon-core
or wherever your clone is.

Yeah, none of these commands/paths are compatible with nagios, so there
goes the "drop-in replacement" - but, then, nothing ever was fully
compatible with nagios. You'll be able to ifdef your way around it, if
you're building modules.

Signed-off-by: Robin Sonefors <ozamosi@flukkost.nu>
pkgconfig: Export the location of the naemon main config

Modules will want to find this file in order to insert themselves during
install, and this means each module doesn't have to guess the path -
they can simply run
 pkg-config --variable=mainconf naemon
and the path shall be revealed.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Add include guards everywhere

If we expose not only all the internal methods and functions, but also
the very file they're in, we'll be stuck forever, unable to improve or
refactor anything.

The guards means that only naemon gets to include naemons specific
header files, and only non-naemon code gets to include naemon.h. Naemon
devs can update naemon code, without angering module devs when they
change things. At least not as often.

Tests can be a bit of a special case - I'd expect unit tests to follow the
naemon convention but perhaps not integration tests. Alas, our tests
have no structure or purpose, so they get to work within the confines of
all the other naemon code.

Obviously, this "block" is easy to get around - just define
NAEMON_COMPILATION - but if you do that, you get to keep both pieces
when your code breaks.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
Merge pull request #86 from ozamosi/pkgconfig

configure: Add pkgconfig file
add pkgfiles to gitignore and cleanfiles

because these files are generated and should be removed
on make clean.

Signed-off-by: Sven Nierlein <Sven.Nierlein@consol.de>