Code

starttls support for check_smtp #1041576
[nagiosplug.git] / plugins / common.h
index 56d5376123775711d28cd190aa1e87476b43c04b..e10586bc8f4c7f077ed4de0fa6fd80537e50228b 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
+ * $Id$
+ *
  *****************************************************************************/
 
+#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"
+#ifdef HUGE_VAL_NEEDS_MATH_H
+#include <math.h>
+#endif
 
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
 
 #include <ctype.h>
 
-#if HAVE_LWRES_NETDB_H
+#ifdef HAVE_LWRES_NETDB_H
 #include <lwres/netdb.h>
-#elif !HAVE_GETADDRINFO
-#include "getaddrinfo.h"
 #else
-#include <netdb.h>
+# if !HAVE_GETADDRINFO
+#  include "getaddrinfo.h"
+# else
+#  include <netdb.h>
+# endif
+#endif
+
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+#ifdef HAVE_DECL_SWAPCTL
+# ifdef HAVE_SYS_SWAP_H
+#  include <sys/swap.h>
+# endif
+# ifdef HAVE_SYS_STAT_H
+#  include <sys/stat.h>
+# endif
+# ifdef HAVE_SYS_PARAM_H
+#  include <sys/param.h>
+# endif
+#endif
+
+#ifndef SWAP_CONVERSION
+# define SWAP_CONVERSION 1
 #endif
 
 /*
@@ -120,67 +152,42 @@ int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
  *
  */
 
-#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 = 1024,             /* 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)
+
+/* For non-GNU compilers to ignore __attribute__ */
+#ifndef __GNUC__
+# define __attribute__(x) /* do nothing */
 #endif