diff --git a/plugins/common.h b/plugins/common.h
index 56d5376123775711d28cd190aa1e87476b43c04b..dfc09416453372792334ebb90e8ab9c8dbd8f7a6 100644 (file)
--- a/plugins/common.h
+++ b/plugins/common.h
-/******************************************************************************
- *
- * Nagios plugins common include file
- *
- * License: GPL
- * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
- *
- * Last Modified: 11-05-1999
- *
- * Description:
- *
- * This file contains common include files and defines used in many of
- * the plugins.
- *
- * License Information:
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *****************************************************************************/
+/*****************************************************************************
+*
+* Nagios plugins common include file
+*
+* License: GPL
+* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
+* Copyright (c) 2003-2007 Nagios Plugins Development Team
+*
+* Description:
+*
+* This file contains common include files and defines used in many of
+* the plugins.
+*
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+*
+*****************************************************************************/
+
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#include "config.h"
+
+#ifdef HAVE_FEATURES_H
+#include <features.h>
+#endif
#include <stdio.h> /* obligatory includes */
#include <stdlib.h>
#include <errno.h>
-#include "config.h"
+/* This block provides uintmax_t - should be reported to coreutils that this should be added to fsuage.h */
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#include <unistd.h>
+#ifndef UINTMAX_MAX
+# define UINTMAX_MAX ((uintmax_t) -1)
+#endif
+
+#include <limits.h> /* This is assumed true, because coreutils assume it too */
+
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#include <unistd.h>
#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 <sys/time.h>
# include <time.h>
#include <signal.h>
#endif
-/* TODO: define can be removed when all ifdef in each plugin has been removed */
-#define HAVE_GETOPT_H
+/* GNU Libraries */
#include <getopt.h>
+#include "dirname.h"
-#include <ctype.h>
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
-#if HAVE_LWRES_NETDB_H
-#include <lwres/netdb.h>
-#elif !HAVE_GETADDRINFO
-#include "getaddrinfo.h"
-#else
-#include <netdb.h>
+#ifdef HAVE_SYS_POLL_H
+# include "sys/poll.h"
#endif
/*
# 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 <gnutls/openssl.h>
+#else
+# ifdef HAVE_SSL_H
+# include <rsa.h>
+# include <crypto.h>
+# include <x509.h>
+# include <pem.h>
+# include <ssl.h>
+# include <err.h>
+# else
+# ifdef HAVE_OPENSSL_SSL_H
+# include <openssl/rsa.h>
+# include <openssl/crypto.h>
+# include <openssl/x509.h>
+# include <openssl/pem.h>
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+# endif
+# endif
#endif
/*
*
*/
-#define OK 0
-#define ERROR -1
-
-#define TRUE 1
-#define FALSE 0
-
-#define STATE_CRITICAL 2 /* service state return codes */
-#define STATE_WARNING 1
-#define STATE_OK 0
-#define STATE_UNKNOWN 3
-#define STATE_DEPENDENT 4
-
-#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */
-
-#define MAX_INPUT_BUFFER 1024 /* max size of most buffers we use */
+enum {
+ OK = 0,
+ ERROR = -1
+};
+
+/* AIX seems to have this defined somewhere else */
+#ifndef FALSE
+enum {
+ FALSE,
+ TRUE
+};
+#endif
-#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */
+enum {
+ STATE_OK,
+ STATE_WARNING,
+ STATE_CRITICAL,
+ STATE_UNKNOWN,
+ STATE_DEPENDENT
+};
+enum {
+ DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
+ MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
+ MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
+};
-#ifndef HAVE_SNPRINTF
/*
-int snprintf (char *str, size_t n, const char *fmt, ...);
-int snprintf (char *str, size_t n, const char *fmt, ...)
-{
- char *buf;
- int i;
- int j=0;
- va_list ap;
- int d;
- char c, *p, *s;
-
- if((buf=malloc(n))==NULL){
- puts("could not malloc snprintf buffer\n");
- exit(-1);
- }
- va_start(ap,fmt);
- i=strlen(fmt);
- while((jj=index(&fmt[j],'%'))){
- j+=jj+1;
- switch fmt[j]
- {
- case 's':
- s = va_arg(ap, char *);
- i+=strlen(s);
- break;
- case 'd':
- d = va_arg(ap, int);
- i++;
- if (d<0) i++;
- while((d=d/10)>0) i++;
- break;
- case 'c':
- c = va_arg(ap, char);
- i++;
- break;
- }
- }
- va_end(ap);
- vsprintf(buf,fmt,ap);
- strcpy(str,buf[1:n-1]);
- exit(result);
-}
-*/
+ *
+ * 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
+
+#endif /* _COMMON_H_ */