diff -urN ../orig.nplg/plugins/common.h ./plugins/common.h --- ../orig.nplg/plugins/common.h 2004-12-10 11:42:00.000000000 +0100 +++ ./plugins/common.h 2005-05-31 14:34:48.000000000 +0200 @@ -32,7 +32,17 @@ * *****************************************************************************/ -#include "config.h" +#ifndef NAGIOSPLUG_COMMON_H +#define NAGIOSPLUG_COMMON_H + +/* For non-GNU compilers to ignore __attribute__ + * This must be here so that imported GNU headers can be used with non-gnu + * compilers and so we can safely (and properly) put prototypes here. */ +#ifndef __GNUC__ +# define __attribute__(x) /* do nothing */ +#endif + +# include "config.h" #ifdef HAVE_FEATURES_H #include @@ -131,19 +141,25 @@ #endif #ifndef HAVE_ASPRINTF -int asprintf(char **strp, const char *fmt, ...); +int asprintf(char **strp, const char *fmt, ...) + __attribute__((__format__(__printf__, 2, 3))); #endif +/* #ifndef HAVE_VASPRINTF -/* int vasprintf(char **strp, const char *fmt, va_list ap); */ +int vasprintf(char **strp, const char *fmt, va_list ap) + __attribute__((__format__(__printf__, 2, 0))); #endif +*/ #ifndef HAVE_SNPRINTF -int snprintf(char *str, size_t size, const char *format, ...); +int snprintf(char *str, size_t size, const char *format, ...) + __attribute__((__format__(__printf__, 3, 4))); #endif #ifndef HAVE_VSNPRINTF -int vsnprintf(char *str, size_t size, const char *format, va_list ap); +int vsnprintf(char *str, size_t size, const char *format, va_list ap) + __attribute__((__format__(__printf__, 3, 0))); #endif /* @@ -152,32 +168,31 @@ * */ -enum { - OK = 0, - ERROR = -1 -}; +/* These should be macros so they never have to be fetched + * from a different data-segment than the code evaluating it (which is + * bizarrely expensive on some weird architectures). It also makes it + * easier to develop and implement additional API's without mucking about + * with the "official" code (#ifdef STATE_CRITICAL etc). + */ +#define OK 0 +#define ERROR -1 /* AIX seems to have this defined somewhere else */ #ifndef FALSE -enum { - FALSE, - TRUE -}; -#endif - -enum { - STATE_OK, - STATE_WARNING, - STATE_CRITICAL, - STATE_UNKNOWN, - STATE_DEPENDENT -}; - -enum { - DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */ - MAX_INPUT_BUFFER = 1024, /* max size of most buffers we use */ - MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */ -}; +# define FALSE 0 +# define TRUE 1 +#endif + +#define STATE_OK 0 +#define STATE_WARNING 1 +#define STATE_CRITICAL 2 +#define STATE_UNKNOWN 3 +#define STATE_DEPENDENT 4 +#define STATE_OOB 5 /* status out of bounds. Must be last */ + +#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */ +#define MAX_INPUT_BUFFER 1024 /* max size of most buffers we use */ +#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */ /* * @@ -187,7 +202,4 @@ #include "gettext.h" #define _(String) gettext (String) -/* For non-GNU compilers to ignore __attribute__ */ -#ifndef __GNUC__ -# define __attribute__(x) /* do nothing */ -#endif +#endif /* NAGIOSPLUG_COMMON_H */