Code

Gettext fixes to sync with coreutils
[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 HAVE_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 #include <getopt.h>
87 #include <ctype.h>
89 #ifdef HAVE_LWRES_NETDB_H
90 #include <lwres/netdb.h>
91 #else
92 # if !HAVE_GETADDRINFO
93 #  include "getaddrinfo.h"
94 # else
95 #  include <netdb.h>
96 # endif
97 #endif
99 #ifdef HAVE_LOCALE_H
100 #include <locale.h>
101 #endif
103 #ifdef HAVE_DECL_SWAPCTL
104 # ifdef HAVE_SYS_SWAP_H
105 #  include <sys/swap.h>
106 # endif
107 # ifdef HAVE_SYS_STAT_H
108 #  include <sys/stat.h>
109 # endif
110 # ifdef HAVE_SYS_PARAM_H
111 #  include <sys/param.h>
112 # endif
113 #endif
115 #ifndef SWAP_CONVERSION
116 # define SWAP_CONVERSION 1
117 #endif
119 #ifdef HAVE_SYS_POLL_H
120 # include "sys/poll.h"
121 #endif
123 /*
124  *
125  * Missing Functions
126  *
127  */
129 #ifndef HAVE_STRTOL
130 # define strtol(a,b,c) atol((a))
131 #endif
133 #ifndef HAVE_STRTOUL
134 # define strtoul(a,b,c) (unsigned long)atol((a))
135 #endif
137 #ifndef HAVE_ASPRINTF
138 int asprintf(char **strp, const char *fmt, ...);
139 #endif
141 #ifndef HAVE_VASPRINTF
142 /* int vasprintf(char **strp, const char *fmt, va_list ap); */
143 #endif
145 #ifndef HAVE_SNPRINTF
146 int snprintf(char *str, size_t size, const  char  *format, ...);
147 #endif
149 #ifndef HAVE_VSNPRINTF
150 int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
151 #endif
153 /* SSL implementations */
154 #ifdef HAVE_GNUTLS_OPENSSL_H
155 #  include <gnutls/openssl.h>
156 #else
157 #  ifdef HAVE_SSL_H
158 #    include <rsa.h>
159 #    include <crypto.h>
160 #    include <x509.h>
161 #    include <pem.h>
162 #    include <ssl.h>
163 #    include <err.h>
164 #  else
165 #    ifdef HAVE_OPENSSL_SSL_H
166 #      include <openssl/rsa.h>
167 #      include <openssl/crypto.h>
168 #      include <openssl/x509.h>
169 #      include <openssl/pem.h>
170 #      include <openssl/ssl.h>
171 #      include <openssl/err.h>
172 #    endif
173 #  endif
174 #endif
176 /*
177  *
178  * Standard Values
179  *
180  */
182 enum {
183         OK = 0,
184         ERROR = -1
185 };
187 /* AIX seems to have this defined somewhere else */
188 #ifndef FALSE
189 enum {
190         FALSE,
191         TRUE
192 };
193 #endif
195 /* Solaris does not have floorf, but floor works. Should probably be in configure */
196 #if defined(__sun) || defined(__sun__)
197 static inline float floorf (float x) { return floor(x); }
198 #endif
200 enum {
201         STATE_OK,
202         STATE_WARNING,
203         STATE_CRITICAL,
204         STATE_UNKNOWN,
205         STATE_DEPENDENT
206 };
208 enum {
209         DEFAULT_SOCKET_TIMEOUT = 10,     /* timeout after 10 seconds */
210         MAX_INPUT_BUFFER = 1024,             /* max size of most buffers we use */
211         MAX_HOST_ADDRESS_LENGTH = 256    /* max size of a host address */
212 };
214 /*
215  *
216  * Internationalization
217  *
218  */
219 #include "gettext.h"
220 #define _(String) gettext (String)
221 #if ! ENABLE_NLS
222 # undef textdomain
223 # define textdomain(Domainname) /* empty */
224 # undef bindtextdomain
225 # define bindtextdomain(Domainname, Dirname) /* empty */
226 #endif
228 /* For non-GNU compilers to ignore __attribute__ */
229 #ifndef __GNUC__
230 # define __attribute__(x) /* do nothing */
231 #endif
233 #endif /* _COMMON_H_ */