e3f150f9116047e3dd61f9dc38ce0dc1009e1ff2
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 #include "config.h"
37 #ifdef HAVE_FEATURES_H
38 #include <features.h>
39 #endif
41 #include <stdio.h> /* obligatory includes */
42 #include <stdlib.h>
43 #include <errno.h>
45 #ifdef HUGE_VAL_NEEDS_MATH_H
46 #include <math.h>
47 #endif
49 #ifdef HAVE_STRINGS_H
50 #include <strings.h>
51 #endif
52 #ifdef HAVE_STRING_H
53 #include <string.h>
54 #endif
56 #ifdef HAVE_UNISTD_H
57 #include <unistd.h>
58 #endif
60 #ifdef TIME_WITH_SYS_TIME
61 # include <sys/time.h>
62 # include <time.h>
63 #else
64 # ifdef HAVE_SYS_TIME_H
65 # include <sys/time.h>
66 # else
67 # include <time.h>
68 # endif
69 #endif
71 #ifdef HAVE_SYS_TYPES_H
72 #include <sys/types.h>
73 #endif
75 #ifdef HAVE_SYS_SOCKET_H
76 #include <sys/socket.h>
77 #endif
79 #ifdef HAVE_SIGNAL_H
80 #include <signal.h>
81 #endif
83 /* TODO: define can be removed when all ifdef in each plugin has been removed */
84 #define HAVE_GETOPT_H
85 #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 /*
120 *
121 * Missing Functions
122 *
123 */
125 #ifndef HAVE_STRTOL
126 # define strtol(a,b,c) atol((a))
127 #endif
129 #ifndef HAVE_STRTOUL
130 # define strtoul(a,b,c) (unsigned long)atol((a))
131 #endif
133 #ifndef HAVE_ASPRINTF
134 int asprintf(char **strp, const char *fmt, ...);
135 #endif
137 #ifndef HAVE_VASPRINTF
138 /* int vasprintf(char **strp, const char *fmt, va_list ap); */
139 #endif
141 #ifndef HAVE_SNPRINTF
142 int snprintf(char *str, size_t size, const char *format, ...);
143 #endif
145 #ifndef HAVE_VSNPRINTF
146 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
147 #endif
149 /*
150 *
151 * Standard Values
152 *
153 */
155 enum {
156 OK = 0,
157 ERROR = -1
158 };
160 /* AIX seems to have this defined somewhere else */
161 #ifndef FALSE
162 enum {
163 FALSE,
164 TRUE
165 };
166 #endif
168 enum {
169 STATE_OK,
170 STATE_WARNING,
171 STATE_CRITICAL,
172 STATE_UNKNOWN,
173 STATE_DEPENDENT
174 };
176 enum {
177 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
178 MAX_INPUT_BUFFER = 1024, /* max size of most buffers we use */
179 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
180 };
182 /*
183 *
184 * Internationalization
185 *
186 */
188 #ifdef ENABLE_NLS
189 # include "gettext.h"
190 # define _(String) gettext (String)
191 # define S_(String) gettext (String)
192 # define gettext_noop(String) String
193 # define N_(String) gettext_noop String
194 #else
195 # define _(String) (String)
196 # define S_(String) (String)
197 # define N_(String) String
198 # define textdomain(Domain)
199 # define bindtextdomain(Package, Directory)
200 #endif
202 /* For non-GNU compilers to ignore __attribute__ */
203 #ifndef __GNUC__
204 # define __attribute__(x) /* do nothing */
205 #endif