From f6cc0cf400832ececffad4e90b693bf2c6471161 Mon Sep 17 00:00:00 2001 From: "Jeremy T. Bouse" Date: Thu, 13 Mar 2003 06:51:18 +0000 Subject: Updated cvs ignore files to reflect changes Moved header files from being ran through configure to standard Removed auto-tools scripts that get added by automake git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@417 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/.cvsignore | 2 +- plugins/Makefile.am | 2 +- plugins/common.h | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/common.h.in | 186 -------------------------------------------------- plugins/netutils.h | 53 ++++++++++++++ plugins/netutils.h.in | 57 ---------------- plugins/popen.h | 9 +++ plugins/popen.h.in | 9 --- plugins/utils.c | 1 - plugins/utils.h | 105 ++++++++++++++++++++++++++++ plugins/utils.h.in | 105 ---------------------------- plugins/version.h.in | 1 - 12 files changed, 355 insertions(+), 361 deletions(-) create mode 100644 plugins/common.h delete mode 100644 plugins/common.h.in create mode 100644 plugins/netutils.h delete mode 100644 plugins/netutils.h.in create mode 100644 plugins/popen.h delete mode 100644 plugins/popen.h.in create mode 100644 plugins/utils.h delete mode 100644 plugins/utils.h.in delete mode 100644 plugins/version.h.in (limited to 'plugins') diff --git a/plugins/.cvsignore b/plugins/.cvsignore index 06fbb6a9..66bad73e 100644 --- a/plugins/.cvsignore +++ b/plugins/.cvsignore @@ -40,7 +40,7 @@ check_dig check_nt negate stamp-h* -*.h +config.h Makefile Makefile.in config.h.in diff --git a/plugins/Makefile.am b/plugins/Makefile.am index bd5b5500..2524e1ac 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -16,7 +16,7 @@ EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ check_tcp_programs = check_ftp check_imap check_nntp check_pop -EXTRA_DIST = t utils.c netutils.c popen.c +EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h PLUGINHDRS = common.h config.h diff --git a/plugins/common.h b/plugins/common.h new file mode 100644 index 00000000..56d53761 --- /dev/null +++ b/plugins/common.h @@ -0,0 +1,186 @@ +/****************************************************************************** + * + * Nagios plugins common include file + * + * License: GPL + * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) + * + * Last Modified: 11-05-1999 + * + * Description: + * + * This file contains common include files and defines used in many of + * the plugins. + * + * License Information: + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + *****************************************************************************/ + +#include /* obligatory includes */ +#include +#include + +#include "config.h" + +#ifdef HAVE_STRINGS_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_SIGNAL_H +#include +#endif + +/* TODO: define can be removed when all ifdef in each plugin has been removed */ +#define HAVE_GETOPT_H +#include + +#include + +#if HAVE_LWRES_NETDB_H +#include +#elif !HAVE_GETADDRINFO +#include "getaddrinfo.h" +#else +#include +#endif + +/* + * + * Missing Functions + * + */ + +#ifndef HAVE_STRTOL +# define strtol(a,b,c) atol((a)) +#endif + +#ifndef HAVE_STRTOUL +# define strtoul(a,b,c) (unsigned long)atol((a)) +#endif + +#ifndef HAVE_ASPRINTF +int asprintf(char **strp, const char *fmt, ...); +#endif + +#ifndef HAVE_VASPRINTF +/* int vasprintf(char **strp, const char *fmt, va_list ap); */ +#endif + +#ifndef HAVE_SNPRINTF +int snprintf(char *str, size_t size, const char *format, ...); +#endif + +#ifndef HAVE_VSNPRINTF +int vsnprintf(char *str, size_t size, const char *format, va_list ap); +#endif + +/* + * + * Standard Values + * + */ + +#define OK 0 +#define ERROR -1 + +#define TRUE 1 +#define FALSE 0 + +#define STATE_CRITICAL 2 /* service state return codes */ +#define STATE_WARNING 1 +#define STATE_OK 0 +#define STATE_UNKNOWN 3 +#define STATE_DEPENDENT 4 + +#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */ + +#define MAX_INPUT_BUFFER 1024 /* max size of most buffers we use */ + +#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */ + + +#ifndef HAVE_SNPRINTF +/* +int snprintf (char *str, size_t n, const char *fmt, ...); +int snprintf (char *str, size_t n, const char *fmt, ...) +{ + char *buf; + int i; + int j=0; + va_list ap; + int d; + char c, *p, *s; + + if((buf=malloc(n))==NULL){ + puts("could not malloc snprintf buffer\n"); + exit(-1); + } + va_start(ap,fmt); + i=strlen(fmt); + while((jj=index(&fmt[j],'%'))){ + j+=jj+1; + switch fmt[j] + { + case 's': + s = va_arg(ap, char *); + i+=strlen(s); + break; + case 'd': + d = va_arg(ap, int); + i++; + if (d<0) i++; + while((d=d/10)>0) i++; + break; + case 'c': + c = va_arg(ap, char); + i++; + break; + } + } + va_end(ap); + vsprintf(buf,fmt,ap); + strcpy(str,buf[1:n-1]); + exit(result); +} +*/ +#endif diff --git a/plugins/common.h.in b/plugins/common.h.in deleted file mode 100644 index 56d53761..00000000 --- a/plugins/common.h.in +++ /dev/null @@ -1,186 +0,0 @@ -/****************************************************************************** - * - * Nagios plugins common include file - * - * License: GPL - * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) - * - * Last Modified: 11-05-1999 - * - * Description: - * - * This file contains common include files and defines used in many of - * the plugins. - * - * License Information: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - -#include /* obligatory includes */ -#include -#include - -#include "config.h" - -#ifdef HAVE_STRINGS_H -#include -#endif -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#ifdef HAVE_SYS_SOCKET_H -#include -#endif - -#ifdef HAVE_SIGNAL_H -#include -#endif - -/* TODO: define can be removed when all ifdef in each plugin has been removed */ -#define HAVE_GETOPT_H -#include - -#include - -#if HAVE_LWRES_NETDB_H -#include -#elif !HAVE_GETADDRINFO -#include "getaddrinfo.h" -#else -#include -#endif - -/* - * - * Missing Functions - * - */ - -#ifndef HAVE_STRTOL -# define strtol(a,b,c) atol((a)) -#endif - -#ifndef HAVE_STRTOUL -# define strtoul(a,b,c) (unsigned long)atol((a)) -#endif - -#ifndef HAVE_ASPRINTF -int asprintf(char **strp, const char *fmt, ...); -#endif - -#ifndef HAVE_VASPRINTF -/* int vasprintf(char **strp, const char *fmt, va_list ap); */ -#endif - -#ifndef HAVE_SNPRINTF -int snprintf(char *str, size_t size, const char *format, ...); -#endif - -#ifndef HAVE_VSNPRINTF -int vsnprintf(char *str, size_t size, const char *format, va_list ap); -#endif - -/* - * - * Standard Values - * - */ - -#define OK 0 -#define ERROR -1 - -#define TRUE 1 -#define FALSE 0 - -#define STATE_CRITICAL 2 /* service state return codes */ -#define STATE_WARNING 1 -#define STATE_OK 0 -#define STATE_UNKNOWN 3 -#define STATE_DEPENDENT 4 - -#define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */ - -#define MAX_INPUT_BUFFER 1024 /* max size of most buffers we use */ - -#define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */ - - -#ifndef HAVE_SNPRINTF -/* -int snprintf (char *str, size_t n, const char *fmt, ...); -int snprintf (char *str, size_t n, const char *fmt, ...) -{ - char *buf; - int i; - int j=0; - va_list ap; - int d; - char c, *p, *s; - - if((buf=malloc(n))==NULL){ - puts("could not malloc snprintf buffer\n"); - exit(-1); - } - va_start(ap,fmt); - i=strlen(fmt); - while((jj=index(&fmt[j],'%'))){ - j+=jj+1; - switch fmt[j] - { - case 's': - s = va_arg(ap, char *); - i+=strlen(s); - break; - case 'd': - d = va_arg(ap, int); - i++; - if (d<0) i++; - while((d=d/10)>0) i++; - break; - case 'c': - c = va_arg(ap, char); - i++; - break; - } - } - va_end(ap); - vsprintf(buf,fmt,ap); - strcpy(str,buf[1:n-1]); - exit(result); -} -*/ -#endif diff --git a/plugins/netutils.h b/plugins/netutils.h new file mode 100644 index 00000000..3ea51663 --- /dev/null +++ b/plugins/netutils.h @@ -0,0 +1,53 @@ +/****************************************************************************** +* +* Nagios plugins net utilities include file +* +* License: GPL +* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) +* +* Last Modified: $Date$ +* +* Description: +* +* This file contains common include files and function definitions +* used in many of the plugins. +* +* License Information: +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +******************************************************************************/ + +#include "config.h" +#include "common.h" +#include +#include + +RETSIGTYPE socket_timeout_alarm_handler (int); + +int process_tcp_request2 (char *address, int port, char *sbuffer, + char *rbuffer, int rsize); +int process_tcp_request (char *address, int port, char *sbuffer, + char *rbuffer, int rsize); +int process_udp_request (char *address, int port, char *sbuffer, + char *rbuffer, int rsize); +int process_request (char *address, int port, char *proto, char *sbuffer, + char *rbuffer, int rsize); + +int my_tcp_connect (char *address, int port, int *sd); +int my_udp_connect (char *address, int port, int *sd); +int my_connect (char *address, int port, int *sd, int proto); + +int socket_timeout = DEFAULT_SOCKET_TIMEOUT; diff --git a/plugins/netutils.h.in b/plugins/netutils.h.in deleted file mode 100644 index 69cf2781..00000000 --- a/plugins/netutils.h.in +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** -* -* Nagios plugins net utilities include file -* -* License: GPL -* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) -* -* Last Modified: $Date$ -* -* Description: -* -* This file contains common include files and function definitions -* used in many of the plugins. -* -* License Information: -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -* -******************************************************************************/ - -#undef STDC_HEADERS -#undef HAVE_STRINGS_H -#undef HAVE_STRING_H - -#include "config.h" -#include "common.h" -#include -#include - -void socket_timeout_alarm_handler (int); - -int process_tcp_request2 (char *address, int port, char *sbuffer, - char *rbuffer, int rsize); -int process_tcp_request (char *address, int port, char *sbuffer, - char *rbuffer, int rsize); -int process_udp_request (char *address, int port, char *sbuffer, - char *rbuffer, int rsize); -int process_request (char *address, int port, char *proto, char *sbuffer, - char *rbuffer, int rsize); - -int my_tcp_connect (char *address, int port, int *sd); -int my_udp_connect (char *address, int port, int *sd); -int my_connect (char *address, int port, int *sd, int proto); - -int socket_timeout = DEFAULT_SOCKET_TIMEOUT; diff --git a/plugins/popen.h b/plugins/popen.h new file mode 100644 index 00000000..a1af4be0 --- /dev/null +++ b/plugins/popen.h @@ -0,0 +1,9 @@ +FILE *spopen (const char *); +int spclose (FILE *); +RETSIGTYPE popen_timeout_alarm_handler (int); + +extern int timeout_interval; +pid_t *childpid; +int *child_stderr_array; +FILE *child_process; +FILE *child_stderr; diff --git a/plugins/popen.h.in b/plugins/popen.h.in deleted file mode 100644 index a1af4be0..00000000 --- a/plugins/popen.h.in +++ /dev/null @@ -1,9 +0,0 @@ -FILE *spopen (const char *); -int spclose (FILE *); -RETSIGTYPE popen_timeout_alarm_handler (int); - -extern int timeout_interval; -pid_t *childpid; -int *child_stderr_array; -FILE *child_process; -FILE *child_stderr; diff --git a/plugins/utils.c b/plugins/utils.c index 9ac5596e..7361323f 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -13,7 +13,6 @@ #include "config.h" #include "common.h" -#include "version.h" #include #include diff --git a/plugins/utils.h b/plugins/utils.h new file mode 100644 index 00000000..89ada6f0 --- /dev/null +++ b/plugins/utils.h @@ -0,0 +1,105 @@ +/* header file for nagios plugins utils.c */ + +/* this file should be included in all plugins */ + +/* The purpose of this package is to provide safer alternantives to C +functions that might otherwise be vulnerable to hacking. This +currently includes a standard suite of validation routines to be sure +that an string argument acually converts to its intended type and a +suite of string handling routine that do their own memory management +in order to resist overflow attacks. In addition, a few functions are +provided to standardize version and error reporting accross the entire +suite of plugins. */ + +/* Standardize version information, termination */ + +char *my_basename (char *); +void support (void); +char *clean_revstring (const char *revstring); +void print_revision (const char *, const char *); +void terminate (int result, char *msg, ...); +extern RETSIGTYPE timeout_alarm_handler (int); + +/* Handle timeouts */ + +time_t start_time, end_time; +int timeout_interval = DEFAULT_SOCKET_TIMEOUT; + +/* Test input types */ + +int is_host (char *); +int is_addr (char *); +int is_inet_addr (char *); +#ifdef USE_IPV6 +int is_inet6_addr (char *); +#endif +int is_hostname (char *); + +int is_integer (char *); +int is_intpos (char *); +int is_intneg (char *); +int is_intnonneg (char *); +int is_intpercent (char *); + +int is_numeric (char *); +int is_positive (char *); +int is_negative (char *); +int is_nonnegative (char *); +int is_percentage (char *); + +int is_option (char *); + +/* generalized timer that will do milliseconds if available */ +#ifndef HAVE_STRUCT_TIMEVAL +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; +#endif + +#ifndef HAVE_GETTIMEOFDAY +int gettimeofday(struct timeval *tv, struct timezone *tz); +#endif + +double delta_time (struct timeval tv); + +/* Handle strings safely */ + +void strip (char *buffer); +char *strscpy (char *dest, char *src); +char *strscat (char *dest, char *src); +char *strnl (char *str); +char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */ +char *strpcpy (char *dest, const char *src, const char *str); +char *strpcat (char *dest, const char *src, const char *str); + +int max_state (int a, int b); + +void usage (char *msg); +void usage2(char *msg, char *arg); +void usage3(char *msg, char arg); + + +#define max(a,b) (((a)>(b))?(a):(b)) + +#define state_text(a) \ +(a)==0?"OK":\ +(a)==1?"WARNING":\ +(a)==2?"CRITICAL":\ +(a)==3?"UNKNOWN":\ +(a)==4?"DEPENDENT":\ +"UNKNOWN" + +/* The idea here is that, although not every plugin will use all of these, + most will or should. Therefore, for consistency, these very common + options should have only these meanings throughout the overall suite */ + +#define STD_LONG_OPTS \ +{"version",no_argument,0,'V'},\ +{"verbose",no_argument,0,'v'},\ +{"help",no_argument,0,'h'},\ +{"timeout",required_argument,0,'t'},\ +{"critical",required_argument,0,'c'},\ +{"warning",required_argument,0,'w'},\ +{"hostname",required_argument,0,'H'} + diff --git a/plugins/utils.h.in b/plugins/utils.h.in deleted file mode 100644 index 89ada6f0..00000000 --- a/plugins/utils.h.in +++ /dev/null @@ -1,105 +0,0 @@ -/* header file for nagios plugins utils.c */ - -/* this file should be included in all plugins */ - -/* The purpose of this package is to provide safer alternantives to C -functions that might otherwise be vulnerable to hacking. This -currently includes a standard suite of validation routines to be sure -that an string argument acually converts to its intended type and a -suite of string handling routine that do their own memory management -in order to resist overflow attacks. In addition, a few functions are -provided to standardize version and error reporting accross the entire -suite of plugins. */ - -/* Standardize version information, termination */ - -char *my_basename (char *); -void support (void); -char *clean_revstring (const char *revstring); -void print_revision (const char *, const char *); -void terminate (int result, char *msg, ...); -extern RETSIGTYPE timeout_alarm_handler (int); - -/* Handle timeouts */ - -time_t start_time, end_time; -int timeout_interval = DEFAULT_SOCKET_TIMEOUT; - -/* Test input types */ - -int is_host (char *); -int is_addr (char *); -int is_inet_addr (char *); -#ifdef USE_IPV6 -int is_inet6_addr (char *); -#endif -int is_hostname (char *); - -int is_integer (char *); -int is_intpos (char *); -int is_intneg (char *); -int is_intnonneg (char *); -int is_intpercent (char *); - -int is_numeric (char *); -int is_positive (char *); -int is_negative (char *); -int is_nonnegative (char *); -int is_percentage (char *); - -int is_option (char *); - -/* generalized timer that will do milliseconds if available */ -#ifndef HAVE_STRUCT_TIMEVAL -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* microseconds */ -}; -#endif - -#ifndef HAVE_GETTIMEOFDAY -int gettimeofday(struct timeval *tv, struct timezone *tz); -#endif - -double delta_time (struct timeval tv); - -/* Handle strings safely */ - -void strip (char *buffer); -char *strscpy (char *dest, char *src); -char *strscat (char *dest, char *src); -char *strnl (char *str); -char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */ -char *strpcpy (char *dest, const char *src, const char *str); -char *strpcat (char *dest, const char *src, const char *str); - -int max_state (int a, int b); - -void usage (char *msg); -void usage2(char *msg, char *arg); -void usage3(char *msg, char arg); - - -#define max(a,b) (((a)>(b))?(a):(b)) - -#define state_text(a) \ -(a)==0?"OK":\ -(a)==1?"WARNING":\ -(a)==2?"CRITICAL":\ -(a)==3?"UNKNOWN":\ -(a)==4?"DEPENDENT":\ -"UNKNOWN" - -/* The idea here is that, although not every plugin will use all of these, - most will or should. Therefore, for consistency, these very common - options should have only these meanings throughout the overall suite */ - -#define STD_LONG_OPTS \ -{"version",no_argument,0,'V'},\ -{"verbose",no_argument,0,'v'},\ -{"help",no_argument,0,'h'},\ -{"timeout",required_argument,0,'t'},\ -{"critical",required_argument,0,'c'},\ -{"warning",required_argument,0,'w'},\ -{"hostname",required_argument,0,'H'} - diff --git a/plugins/version.h.in b/plugins/version.h.in deleted file mode 100644 index 6fd1e107..00000000 --- a/plugins/version.h.in +++ /dev/null @@ -1 +0,0 @@ -#define CVS_DATE "$Date$" -- cgit v1.2.3-74-g34f1