Code

Patch for tru64 using swapctl calls (Sean Finney)
[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  *****************************************************************************/
33 #include "config.h"
35 #ifdef HAVE_FEATURES_H
36 #include <features.h>
37 #endif
39 #include <stdio.h>                                                      /* obligatory includes */
40 #include <stdlib.h>
41 #include <errno.h>
43 #ifdef HUGE_VAL_NEEDS_MATH_H
44 #include <math.h>
45 #endif
47 #ifdef HAVE_STRINGS_H
48 #include <strings.h>
49 #endif
50 #ifdef HAVE_STRING_H
51 #include <string.h>
52 #endif
54 #ifdef HAVE_UNISTD_H
55 #include <unistd.h>
56 #endif
58 #ifdef TIME_WITH_SYS_TIME
59 # include <sys/time.h>
60 # include <time.h>
61 #else
62 # ifdef HAVE_SYS_TIME_H
63 #  include <sys/time.h>
64 # else
65 #  include <time.h>
66 # endif
67 #endif
69 #ifdef HAVE_SYS_TYPES_H
70 #include <sys/types.h>
71 #endif
73 #ifdef HAVE_SYS_SOCKET_H
74 #include <sys/socket.h>
75 #endif
77 #ifdef HAVE_SIGNAL_H
78 #include <signal.h>
79 #endif
81 /* TODO: define can be removed when all ifdef in each plugin has been removed */
82 #define HAVE_GETOPT_H
83 #include <getopt.h>
85 #include <ctype.h>
87 #ifdef HAVE_LWRES_NETDB_H
88 #include <lwres/netdb.h>
89 #else
90 # if !HAVE_GETADDRINFO
91 #  include "getaddrinfo.h"
92 # else
93 #  include <netdb.h>
94 # endif
95 #endif
97 #ifdef HAVE_LOCALE_H
98 #include <locale.h>
99 #endif
101 #ifdef HAVE_DECL_SWAPCTL
102 # ifdef HAVE_SYS_SWAP_H
103 #  include <sys/swap.h>
104 # endif
105 # ifdef HAVE_SYS_STAT_H
106 #  include <sys/stat.h>
107 # endif
108 # ifdef HAVE_SYS_PARAM_H
109 #  include <sys/param.h>
110 # endif
111 #endif
113 /*
114  *
115  * Missing Functions
116  *
117  */
119 #ifndef HAVE_STRTOL
120 # define strtol(a,b,c) atol((a))
121 #endif
123 #ifndef HAVE_STRTOUL
124 # define strtoul(a,b,c) (unsigned long)atol((a))
125 #endif
127 #ifndef HAVE_ASPRINTF
128 int asprintf(char **strp, const char *fmt, ...);
129 #endif
131 #ifndef HAVE_VASPRINTF
132 /* int vasprintf(char **strp, const char *fmt, va_list ap); */
133 #endif
135 #ifndef HAVE_SNPRINTF
136 int snprintf(char *str, size_t size, const  char  *format, ...);
137 #endif
139 #ifndef HAVE_VSNPRINTF
140 int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
141 #endif
143 /*
144  *
145  * Standard Values
146  *
147  */
149 enum {
150         OK = 0,
151         ERROR = -1
152 };
154 /* AIX seems to have this defined somewhere else */
155 #ifndef FALSE
156 enum {
157         FALSE,
158         TRUE
159 };
160 #endif
162 enum {
163         STATE_OK,
164         STATE_WARNING,
165         STATE_CRITICAL,
166         STATE_UNKNOWN,
167         STATE_DEPENDENT
168 };
170 enum {
171         DEFAULT_SOCKET_TIMEOUT = 10,     /* timeout after 10 seconds */
172         MAX_INPUT_BUFFER = 1024,             /* max size of most buffers we use */
173         MAX_HOST_ADDRESS_LENGTH = 256    /* max size of a host address */
174 };
176 /*
177  *
178  * Internationalization
179  *
180  */
182 #ifdef ENABLE_NLS
183 #  include "gettext.h"
184 #  define _(String) gettext (String)
185 #  define S_(String) gettext (String)
186 #  define gettext_noop(String) String
187 #  define N_(String) gettext_noop String
188 #else
189 #  define _(String) (String)
190 #  define S_(String) (String)
191 #  define N_(String) String
192 #  define textdomain(Domain)
193 #  define bindtextdomain(Package, Directory)
194 #endif
196 /* For non-GNU compilers to ignore __attribute__ */
197 #ifndef __GNUC__
198 # define __attribute__(x) /* do nothing */
199 #endif