1
/******************************************************************************
3
* Nagios plugins common include file
6
* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
8
* Last Modified: 11-05-1999
12
* This file contains common include files and defines used in many of
15
* License Information:
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.
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.
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.
31
*****************************************************************************/
33
#include <stdio.h> /* obligatory includes */
50
#ifdef TIME_WITH_SYS_TIME
51
# include <sys/time.h>
54
# ifdef HAVE_SYS_TIME_H
55
# include <sys/time.h>
61
#ifdef HAVE_SYS_TYPES_H
62
#include <sys/types.h>
69
/* TODO: define can be removed when all ifdef in each plugin has been removed */
83
# define strtol(a,b,c) atol((a))
87
# define strtoul(a,b,c) (unsigned long)atol((a))
91
int asprintf(char **strp, const char *fmt, ...);
94
#ifndef HAVE_VASPRINTF
95
/* int vasprintf(char **strp, const char *fmt, va_list ap); */
99
int snprintf(char *str, size_t size, const char *format, ...);
102
#ifndef HAVE_VSNPRINTF
103
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
118
#define STATE_CRITICAL 2 /* service state return codes */
119
#define STATE_WARNING 1
121
#define STATE_UNKNOWN 3
122
#define STATE_DEPENDENT 4
124
#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */
126
#define MAX_INPUT_BUFFER 1024 /* max size of most buffers we use */
128
#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */
131
#ifndef HAVE_SNPRINTF
133
int snprintf (char *str, size_t n, const char *fmt, ...);
134
int snprintf (char *str, size_t n, const char *fmt, ...)
143
if((buf=malloc(n))==NULL){
144
puts("could not malloc snprintf buffer\n");
149
while((jj=index(&fmt[j],'%'))){
154
s = va_arg(ap, char *);
161
while((d=d/10)>0) i++;
164
c = va_arg(ap, char);
170
vsprintf(buf,fmt,ap);
171
strcpy(str,buf[1:n-1]);