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 <stdio.h> /* obligatory includes */
34 #include <stdlib.h>
35 #include <errno.h>
37 #include "config.h"
39 #ifdef HAVE_STRINGS_H
40 #include <strings.h>
41 #endif
42 #ifdef HAVE_STRING_H
43 #include <string.h>
44 #endif
46 #ifdef HAVE_UNISTD_H
47 #include <unistd.h>
48 #endif
50 #ifdef TIME_WITH_SYS_TIME
51 # include <sys/time.h>
52 # include <time.h>
53 #else
54 # ifdef HAVE_SYS_TIME_H
55 # include <sys/time.h>
56 # else
57 # include <time.h>
58 # endif
59 #endif
61 #ifdef HAVE_SYS_TYPES_H
62 #include <sys/types.h>
63 #endif
65 #ifdef HAVE_SYS_SOCKET_H
66 #include <sys/socket.h>
67 #endif
69 #ifdef HAVE_SIGNAL_H
70 #include <signal.h>
71 #endif
73 /* TODO: define can be removed when all ifdef in each plugin has been removed */
74 #define HAVE_GETOPT_H
75 #include <getopt.h>
77 #include <ctype.h>
79 #if HAVE_LWRES_NETDB_H
80 #include <lwres/netdb.h>
81 #else
82 # if !HAVE_GETADDRINFO
83 # include "getaddrinfo.h"
84 # else
85 # include <netdb.h>
86 # endif
87 #endif
89 /*
90 *
91 * Missing Functions
92 *
93 */
95 #ifndef HAVE_STRTOL
96 # define strtol(a,b,c) atol((a))
97 #endif
99 #ifndef HAVE_STRTOUL
100 # define strtoul(a,b,c) (unsigned long)atol((a))
101 #endif
103 #ifndef HAVE_ASPRINTF
104 int asprintf(char **strp, const char *fmt, ...);
105 #endif
107 #ifndef HAVE_VASPRINTF
108 /* int vasprintf(char **strp, const char *fmt, va_list ap); */
109 #endif
111 #ifndef HAVE_SNPRINTF
112 int snprintf(char *str, size_t size, const char *format, ...);
113 #endif
115 #ifndef HAVE_VSNPRINTF
116 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
117 #endif
119 /*
120 *
121 * Standard Values
122 *
123 */
125 enum {
126 OK = 0,
127 ERROR = -1
128 };
130 enum {
131 FALSE,
132 TRUE
133 };
135 enum {
136 STATE_OK,
137 STATE_WARNING,
138 STATE_CRITICAL,
139 STATE_UNKNOWN,
140 STATE_DEPENDENT
141 };
143 enum {
144 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
145 MAX_INPUT_BUFFER = 1024, /* max size of most buffers we use */
146 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
147 };