Code

Fix to add uintmax_t, for check_disk.c compile
[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 /* This block provides uintmax_t - should be reported to coreutils that this should be added to fsuage.h */
49 #if HAVE_INTTYPES_H
50 # include <inttypes.h>
51 #endif
52 #if HAVE_STDINT_H
53 # include <stdint.h>
54 #endif
55 #include <unistd.h>
56 #ifndef UINTMAX_MAX
57 # define UINTMAX_MAX ((uintmax_t) -1)
58 #endif
60 #include <limits.h>     /* This is assumed true, because coreutils assume it too */
62 #ifdef HAVE_MATH_H
63 #include <math.h>
64 #endif
66 #ifdef HAVE_STRINGS_H
67 #include <strings.h>
68 #endif
69 #ifdef HAVE_STRING_H
70 #include <string.h>
71 #endif
73 #ifdef HAVE_UNISTD_H
74 #include <unistd.h>
75 #endif
77 #ifdef TIME_WITH_SYS_TIME
78 # include <sys/time.h>
79 # include <time.h>
80 #else
81 # ifdef HAVE_SYS_TIME_H
82 #  include <sys/time.h>
83 # else
84 #  include <time.h>
85 # endif
86 #endif
88 #ifdef HAVE_SYS_TYPES_H
89 #include <sys/types.h>
90 #endif
92 #ifdef HAVE_SYS_SOCKET_H
93 #include <sys/socket.h>
94 #endif
96 #ifdef HAVE_SIGNAL_H
97 #include <signal.h>
98 #endif
100 #include <getopt.h>
101 #include <ctype.h>
103 #ifdef HAVE_LWRES_NETDB_H
104 #include <lwres/netdb.h>
105 #else
106 # if !HAVE_GETADDRINFO
107 #  include "getaddrinfo.h"
108 # else
109 #  include <netdb.h>
110 # endif
111 #endif
113 #ifdef HAVE_LOCALE_H
114 #include <locale.h>
115 #endif
117 #ifdef HAVE_DECL_SWAPCTL
118 # ifdef HAVE_SYS_SWAP_H
119 #  include <sys/swap.h>
120 # endif
121 # ifdef HAVE_SYS_STAT_H
122 #  include <sys/stat.h>
123 # endif
124 # ifdef HAVE_SYS_PARAM_H
125 #  include <sys/param.h>
126 # endif
127 #endif
129 #ifndef SWAP_CONVERSION
130 # define SWAP_CONVERSION 1
131 #endif
133 #ifdef HAVE_SYS_POLL_H
134 # include "sys/poll.h"
135 #endif
137 /*
138  *
139  * Missing Functions
140  *
141  */
143 #ifndef HAVE_STRTOL
144 # define strtol(a,b,c) atol((a))
145 #endif
147 #ifndef HAVE_STRTOUL
148 # define strtoul(a,b,c) (unsigned long)atol((a))
149 #endif
151 #ifndef HAVE_ASPRINTF
152 int asprintf(char **strp, const char *fmt, ...);
153 #endif
155 #ifndef HAVE_VASPRINTF
156 /* int vasprintf(char **strp, const char *fmt, va_list ap); */
157 #endif
159 #ifndef HAVE_SNPRINTF
160 int snprintf(char *str, size_t size, const  char  *format, ...);
161 #endif
163 #ifndef HAVE_VSNPRINTF
164 int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
165 #endif
167 /* SSL implementations */
168 #ifdef HAVE_GNUTLS_OPENSSL_H
169 #  include <gnutls/openssl.h>
170 #else
171 #  ifdef HAVE_SSL_H
172 #    include <rsa.h>
173 #    include <crypto.h>
174 #    include <x509.h>
175 #    include <pem.h>
176 #    include <ssl.h>
177 #    include <err.h>
178 #  else
179 #    ifdef HAVE_OPENSSL_SSL_H
180 #      include <openssl/rsa.h>
181 #      include <openssl/crypto.h>
182 #      include <openssl/x509.h>
183 #      include <openssl/pem.h>
184 #      include <openssl/ssl.h>
185 #      include <openssl/err.h>
186 #    endif
187 #  endif
188 #endif
190 /*
191  *
192  * Standard Values
193  *
194  */
196 enum {
197         OK = 0,
198         ERROR = -1
199 };
201 /* AIX seems to have this defined somewhere else */
202 #ifndef FALSE
203 enum {
204         FALSE,
205         TRUE
206 };
207 #endif
209 /* Solaris does not have floorf, but floor works. Should probably be in configure */
210 #if defined(__sun) || defined(__sun__)
211 static inline float floorf (float x) { return floor(x); }
212 #endif
214 enum {
215         STATE_OK,
216         STATE_WARNING,
217         STATE_CRITICAL,
218         STATE_UNKNOWN,
219         STATE_DEPENDENT
220 };
222 enum {
223         DEFAULT_SOCKET_TIMEOUT = 10,     /* timeout after 10 seconds */
224         MAX_INPUT_BUFFER = 1024,             /* max size of most buffers we use */
225         MAX_HOST_ADDRESS_LENGTH = 256    /* max size of a host address */
226 };
228 /*
229  *
230  * Internationalization
231  *
232  */
233 #include "gettext.h"
234 #define _(String) gettext (String)
235 #if ! ENABLE_NLS
236 # undef textdomain
237 # define textdomain(Domainname) /* empty */
238 # undef bindtextdomain
239 # define bindtextdomain(Domainname, Dirname) /* empty */
240 #endif
242 /* For non-GNU compilers to ignore __attribute__ */
243 #ifndef __GNUC__
244 # define __attribute__(x) /* do nothing */
245 #endif
247 #endif /* _COMMON_H_ */