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 #elif !HAVE_GETADDRINFO
82 #include "getaddrinfo.h"
83 #else
84 #include <netdb.h>
85 #endif
87 /*
88 *
89 * Missing Functions
90 *
91 */
93 #ifndef HAVE_STRTOL
94 # define strtol(a,b,c) atol((a))
95 #endif
97 #ifndef HAVE_STRTOUL
98 # define strtoul(a,b,c) (unsigned long)atol((a))
99 #endif
101 #ifndef HAVE_ASPRINTF
102 int asprintf(char **strp, const char *fmt, ...);
103 #endif
105 #ifndef HAVE_VASPRINTF
106 /* int vasprintf(char **strp, const char *fmt, va_list ap); */
107 #endif
109 #ifndef HAVE_SNPRINTF
110 int snprintf(char *str, size_t size, const char *format, ...);
111 #endif
113 #ifndef HAVE_VSNPRINTF
114 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
115 #endif
117 /*
118 *
119 * Standard Values
120 *
121 */
123 enum {
124 OK = 0,
125 ERROR = -1
126 };
128 enum {
129 FALSE,
130 TRUE
131 };
133 enum {
134 STATE_OK,
135 STATE_WARNING,
136 STATE_CRITICAL,
137 STATE_UNKNOWN,
138 STATE_DEPENDENT
139 };
141 enum {
142 DEFAULT_SOCKET_TIMEOUT = 10, /* timeout after 10 seconds */
143 MAX_INPUT_BUFFER = 1024, /* max size of most buffers we use */
144 MAX_HOST_ADDRESS_LENGTH = 256 /* max size of a host address */
145 };