X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcommon.h;h=752e21fffe4ab2a67a5a5eea0750d4883bb74a1c;hb=02033903c04113f12b80638c91131cbaf4a50a2f;hp=21facfc4138fdcafd84558ae93f2bf246af56152;hpb=35d8e3500946289de2638596bc0f93b044acc42c;p=nagiosplug.git diff --git a/plugins/common.h b/plugins/common.h index 21facfc..752e21f 100644 --- a/plugins/common.h +++ b/plugins/common.h @@ -28,9 +28,20 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * + * $Id$ + * *****************************************************************************/ +#ifndef _COMMON_H_ +#define _COMMON_H_ + #include "config.h" +/* This needs to be removed for Solaris servers, where 64 bit files, but 32 bit architecture + This needs to be done early on because subsequent system includes use _FILE_OFFSET_BITS + Cannot remove from config.h because is included by regex.c from lib/ */ +#if __sun__ && !defined(_LP64) && _FILE_OFFSET_BITS == 64 +#undef _FILE_OFFSET_BITS +#endif #ifdef HAVE_FEATURES_H #include @@ -40,6 +51,24 @@ #include #include +/* This block provides uintmax_t - should be reported to coreutils that this should be added to fsuage.h */ +#if HAVE_INTTYPES_H +# include +#endif +#if HAVE_STDINT_H +# include +#endif +#include +#ifndef UINTMAX_MAX +# define UINTMAX_MAX ((uintmax_t) -1) +#endif + +#include /* This is assumed true, because coreutils assume it too */ + +#ifdef HAVE_MATH_H +#include +#endif + #ifdef HAVE_STRINGS_H #include #endif @@ -51,6 +80,18 @@ #include #endif +/* GET_NUMBER_OF_CPUS is a macro to return + number of CPUs, if we can get that data. + Use configure.in to test for various OS ways of + getting that data + Will return -1 if cannot get data +*/ +#ifdef HAVE_SYSCONF__SC_NPROCESSORS_CONF +#define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF) +#else +#define GET_NUMBER_OF_CPUS() -1 +#endif + #ifdef TIME_WITH_SYS_TIME # include # include @@ -74,20 +115,19 @@ #include #endif -/* TODO: define can be removed when all ifdef in each plugin has been removed */ -#define HAVE_GETOPT_H +/* GNU Libraries */ #include +#include "dirname.h" +#include "vasprintf.h" +#include "snprintf.h" +#include "vsnprintf.h" -#include +#ifdef HAVE_LOCALE_H +#include +#endif -#if HAVE_LWRES_NETDB_H -#include -#else -# if !HAVE_GETADDRINFO -# include "getaddrinfo.h" -# else -# include -# endif +#ifdef HAVE_SYS_POLL_H +# include "sys/poll.h" #endif /* @@ -104,20 +144,27 @@ # define strtoul(a,b,c) (unsigned long)atol((a)) #endif -#ifndef HAVE_ASPRINTF -int asprintf(char **strp, const char *fmt, ...); -#endif - -#ifndef HAVE_VASPRINTF -/* int vasprintf(char **strp, const char *fmt, va_list ap); */ -#endif - -#ifndef HAVE_SNPRINTF -int snprintf(char *str, size_t size, const char *format, ...); -#endif - -#ifndef HAVE_VSNPRINTF -int vsnprintf(char *str, size_t size, const char *format, va_list ap); +/* SSL implementations */ +#ifdef HAVE_GNUTLS_OPENSSL_H +# include +#else +# ifdef HAVE_SSL_H +# include +# include +# include +# include +# include +# include +# else +# ifdef HAVE_OPENSSL_SSL_H +# include +# include +# include +# include +# include +# include +# endif +# endif #endif /* @@ -131,10 +178,18 @@ enum { ERROR = -1 }; +/* AIX seems to have this defined somewhere else */ +#ifndef FALSE enum { FALSE, TRUE }; +#endif + +/* Solaris does not have floorf, but floor works. Should probably be in configure */ +#if defined(__sun) || defined(__sun__) +static inline float floorf (float x) { return floor(x); } +#endif enum { STATE_OK, @@ -146,7 +201,7 @@ enum { enum { DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */ - MAX_INPUT_BUFFER = 1024, /* max size of most buffers we use */ + MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */ MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */ }; @@ -155,8 +210,18 @@ enum { * Internationalization * */ +#include "gettext.h" +#define _(String) gettext (String) +#if ! ENABLE_NLS +# undef textdomain +# define textdomain(Domainname) /* empty */ +# undef bindtextdomain +# define bindtextdomain(Domainname, Dirname) /* empty */ +#endif + +/* For non-GNU compilers to ignore __attribute__ */ +#ifndef __GNUC__ +# define __attribute__(x) /* do nothing */ +#endif -#define _(String) (String) -#define N_(String) String -#define textdomain(Domain) -#define bindtextdomain(Package, Directory) +#endif /* _COMMON_H_ */