Create expired cert for testing purposes. Updated tests to check
[monitoring-plugins.git] / plugins / common.h
blobdfc09416453372792334ebb90e8ab9c8dbd8f7a6
1 /*****************************************************************************
2 *
3 * Nagios plugins common include file
4 *
5 * License: GPL
6 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
7 * Copyright (c) 2003-2007 Nagios Plugins Development Team
8 *
9 * Description:
11 * This file contains common include files and defines used in many of
12 * the plugins.
15 * This program is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *****************************************************************************/
31 #ifndef _COMMON_H_
32 #define _COMMON_H_
34 #include "config.h"
36 #ifdef HAVE_FEATURES_H
37 #include <features.h>
38 #endif
40 #include <stdio.h> /* obligatory includes */
41 #include <stdlib.h>
42 #include <errno.h>
44 /* This block provides uintmax_t - should be reported to coreutils that this should be added to fsuage.h */
45 #if HAVE_INTTYPES_H
46 # include <inttypes.h>
47 #endif
48 #if HAVE_STDINT_H
49 # include <stdint.h>
50 #endif
51 #include <unistd.h>
52 #ifndef UINTMAX_MAX
53 # define UINTMAX_MAX ((uintmax_t) -1)
54 #endif
56 #include <limits.h> /* This is assumed true, because coreutils assume it too */
58 #ifdef HAVE_MATH_H
59 #include <math.h>
60 #endif
62 #ifdef HAVE_STRINGS_H
63 #include <strings.h>
64 #endif
65 #ifdef HAVE_STRING_H
66 #include <string.h>
67 #endif
69 #ifdef HAVE_UNISTD_H
70 #include <unistd.h>
71 #endif
73 /* GET_NUMBER_OF_CPUS is a macro to return
74 number of CPUs, if we can get that data.
75 Use configure.in to test for various OS ways of
76 getting that data
77 Will return -1 if cannot get data
79 #ifdef HAVE_SYSCONF__SC_NPROCESSORS_CONF
80 #define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
81 #else
82 #define GET_NUMBER_OF_CPUS() -1
83 #endif
85 #ifdef TIME_WITH_SYS_TIME
86 # include <sys/time.h>
87 # include <time.h>
88 #else
89 # ifdef HAVE_SYS_TIME_H
90 # include <sys/time.h>
91 # else
92 # include <time.h>
93 # endif
94 #endif
96 #ifdef HAVE_SYS_TYPES_H
97 #include <sys/types.h>
98 #endif
100 #ifdef HAVE_SYS_SOCKET_H
101 #include <sys/socket.h>
102 #endif
104 #ifdef HAVE_SIGNAL_H
105 #include <signal.h>
106 #endif
108 /* GNU Libraries */
109 #include <getopt.h>
110 #include "dirname.h"
112 #ifdef HAVE_LOCALE_H
113 #include <locale.h>
114 #endif
116 #ifdef HAVE_SYS_POLL_H
117 # include "sys/poll.h"
118 #endif
122 * Missing Functions
126 #ifndef HAVE_STRTOL
127 # define strtol(a,b,c) atol((a))
128 #endif
130 #ifndef HAVE_STRTOUL
131 # define strtoul(a,b,c) (unsigned long)atol((a))
132 #endif
134 /* SSL implementations */
135 #ifdef HAVE_GNUTLS_OPENSSL_H
136 # include <gnutls/openssl.h>
137 #else
138 # ifdef HAVE_SSL_H
139 # include <rsa.h>
140 # include <crypto.h>
141 # include <x509.h>
142 # include <pem.h>
143 # include <ssl.h>
144 # include <err.h>
145 # else
146 # ifdef HAVE_OPENSSL_SSL_H
147 # include <openssl/rsa.h>
148 # include <openssl/crypto.h>
149 # include <openssl/x509.h>
150 # include <openssl/pem.h>
151 # include <openssl/ssl.h>
152 # include <openssl/err.h>
153 # endif
154 # endif
155 #endif
159 * Standard Values
163 enum {
164 OK = 0,
165 ERROR = -1
168 /* AIX seems to have this defined somewhere else */
169 #ifndef FALSE
170 enum {
171 FALSE,
172 TRUE
174 #endif
176 enum {
177 STATE_OK,
178 STATE_WARNING,
179 STATE_CRITICAL,
180 STATE_UNKNOWN,
181 STATE_DEPENDENT
184 enum {
185 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
186 MAX_INPUT_BUFFER = 8192, /* max size of most buffers we use */
187 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
192 * Internationalization
195 #include "gettext.h"
196 #define _(String) gettext (String)
197 #if ! ENABLE_NLS
198 # undef textdomain
199 # define textdomain(Domainname) /* empty */
200 # undef bindtextdomain
201 # define bindtextdomain(Domainname, Dirname) /* empty */
202 #endif
204 /* For non-GNU compilers to ignore __attribute__ */
205 #ifndef __GNUC__
206 # define __attribute__(x) /* do nothing */
207 #endif
209 #endif /* _COMMON_H_ */