Code

5eac63e4a00de32ae34a1d47bc5db7cba9389e66
[nagiosplug.git] / plugins / common.h
1 /******************************************************************************
2  *
3  * Nagios plugins common include file
4  *
5  * License: GPL
6  * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
7  *
8  * Last Modified: 11-05-1999
9  *
10  * Description:
11  *
12  * This file contains common include files and defines used in many of
13  * the plugins.
14  *
15  * License Information:
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 2 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30  *
31  * $Id$
32  *
33  *****************************************************************************/
35 #ifndef _COMMON_H_
36 #define _COMMON_H_
38 #include "config.h"
40 #ifdef HAVE_FEATURES_H
41 #include <features.h>
42 #endif
44 #include <stdio.h>                                                      /* obligatory includes */
45 #include <stdlib.h>
46 #include <errno.h>
48 #ifdef HUGE_VAL_NEEDS_MATH_H
49 #include <math.h>
50 #endif
52 #ifdef HAVE_STRINGS_H
53 #include <strings.h>
54 #endif
55 #ifdef HAVE_STRING_H
56 #include <string.h>
57 #endif
59 #ifdef HAVE_UNISTD_H
60 #include <unistd.h>
61 #endif
63 #ifdef TIME_WITH_SYS_TIME
64 # include <sys/time.h>
65 # include <time.h>
66 #else
67 # ifdef HAVE_SYS_TIME_H
68 #  include <sys/time.h>
69 # else
70 #  include <time.h>
71 # endif
72 #endif
74 #ifdef HAVE_SYS_TYPES_H
75 #include <sys/types.h>
76 #endif
78 #ifdef HAVE_SYS_SOCKET_H
79 #include <sys/socket.h>
80 #endif
82 #ifdef HAVE_SIGNAL_H
83 #include <signal.h>
84 #endif
86 /* TODO: define can be removed when all ifdef in each plugin has been removed */
87 #define HAVE_GETOPT_H
88 #include <getopt.h>
90 #include <ctype.h>
92 #ifdef HAVE_LWRES_NETDB_H
93 #include <lwres/netdb.h>
94 #else
95 # if !HAVE_GETADDRINFO
96 #  include "getaddrinfo.h"
97 # else
98 #  include <netdb.h>
99 # endif
100 #endif
102 #ifdef HAVE_LOCALE_H
103 #include <locale.h>
104 #endif
106 #ifdef HAVE_DECL_SWAPCTL
107 # ifdef HAVE_SYS_SWAP_H
108 #  include <sys/swap.h>
109 # endif
110 # ifdef HAVE_SYS_STAT_H
111 #  include <sys/stat.h>
112 # endif
113 # ifdef HAVE_SYS_PARAM_H
114 #  include <sys/param.h>
115 # endif
116 #endif
118 #ifndef SWAP_CONVERSION
119 # define SWAP_CONVERSION 1
120 #endif
122 /*
123  *
124  * Missing Functions
125  *
126  */
128 #ifndef HAVE_STRTOL
129 # define strtol(a,b,c) atol((a))
130 #endif
132 #ifndef HAVE_STRTOUL
133 # define strtoul(a,b,c) (unsigned long)atol((a))
134 #endif
136 #ifndef HAVE_ASPRINTF
137 int asprintf(char **strp, const char *fmt, ...);
138 #endif
140 #ifndef HAVE_VASPRINTF
141 /* int vasprintf(char **strp, const char *fmt, va_list ap); */
142 #endif
144 #ifndef HAVE_SNPRINTF
145 int snprintf(char *str, size_t size, const  char  *format, ...);
146 #endif
148 #ifndef HAVE_VSNPRINTF
149 int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
150 #endif
152 /* SSL implementations */
153 #ifdef HAVE_GNUTLS_OPENSSL_H
154 #  include <gnutls/openssl.h>
155 #else
156 #  ifdef HAVE_SSL_H
157 #    include <rsa.h>
158 #    include <crypto.h>
159 #    include <x509.h>
160 #    include <pem.h>
161 #    include <ssl.h>
162 #    include <err.h>
163 #  else
164 #    ifdef HAVE_OPENSSL_SSL_H
165 #      include <openssl/rsa.h>
166 #      include <openssl/crypto.h>
167 #      include <openssl/x509.h>
168 #      include <openssl/pem.h>
169 #      include <openssl/ssl.h>
170 #      include <openssl/err.h>
171 #    endif
172 #  endif
173 #endif
175 /*
176  *
177  * Standard Values
178  *
179  */
181 enum {
182         OK = 0,
183         ERROR = -1
184 };
186 /* AIX seems to have this defined somewhere else */
187 #ifndef FALSE
188 enum {
189         FALSE,
190         TRUE
191 };
192 #endif
194 enum {
195         STATE_OK,
196         STATE_WARNING,
197         STATE_CRITICAL,
198         STATE_UNKNOWN,
199         STATE_DEPENDENT
200 };
202 enum {
203         DEFAULT_SOCKET_TIMEOUT = 10,     /* timeout after 10 seconds */
204         MAX_INPUT_BUFFER = 1024,             /* max size of most buffers we use */
205         MAX_HOST_ADDRESS_LENGTH = 256    /* max size of a host address */
206 };
208 /*
209  *
210  * Internationalization
211  *
212  */
213 #include "gettext.h"
214 #define _(String) gettext (String)
216 /* For non-GNU compilers to ignore __attribute__ */
217 #ifndef __GNUC__
218 # define __attribute__(x) /* do nothing */
219 #endif
221 #endif /* _COMMON_H_ */