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 --- .cvsignore | 3 + configure.in | 4 +- install-sh | 250 ------------------------------------- missing | 336 -------------------------------------------------- mkinstalldirs | 40 ------ 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 - 17 files changed, 360 insertions(+), 989 deletions(-) delete mode 100755 install-sh delete mode 100755 missing delete mode 100755 mkinstalldirs 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 diff --git a/.cvsignore b/.cvsignore index 2c13ae99..54084f13 100644 --- a/.cvsignore +++ b/.cvsignore @@ -10,3 +10,6 @@ Cache.pm build-* aclocal.m4 autom4te-*.cache +install-sh +mkinstalldirs +missing diff --git a/configure.in b/configure.in index 9942d52d..d6ef7d47 100644 --- a/configure.in +++ b/configure.in @@ -10,7 +10,7 @@ AC_SUBST(PACKAGE_VERSION) PACKAGE_RELEASE="${REL}" AC_SUBST(PACKAGE_RELEASE) AM_INIT_AUTOMAKE(nagios-plugins,${PACKAGE_VERSION}) -AM_CONFIG_HEADER(plugins/config.h plugins/common.h plugins/version.h plugins/netutils.h plugins/utils.h plugins/popen.h) +AM_CONFIG_HEADER(plugins/config.h) AC_CANONICAL_HOST AC_PREFIX_DEFAULT(/usr/local/nagios) @@ -1455,7 +1455,7 @@ AC_SUBST(DEPLIBS) AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"${VERSION}",[package version]) -AC_OUTPUT(Makefile subst lib/Makefile plugins/Makefile plugins-scripts/Makefile plugins-scripts/subst plugins-scripts/utils.pm plugins-scripts/utils.sh command.cfg test.pl,echo timestamp > plugins/stamp-h1;echo timestamp > plugins/stamp-h2;echo timestamp > plugins/stamp-h3;echo timestamp > plugins/stamp-h4;echo timestamp > plugins/stamp-h5;echo timestamp > plugins/stamp-h6;PATH=.:..:$PATH subst.sh command.cfg) +AC_OUTPUT(Makefile subst lib/Makefile plugins/Makefile plugins-scripts/Makefile plugins-scripts/subst plugins-scripts/utils.pm plugins-scripts/utils.sh command.cfg test.pl,PATH=.:..:$PATH subst.sh command.cfg) ACX_FEATURE([with],[cgiurl]) ACX_FEATURE([with],[nagios-user]) diff --git a/install-sh b/install-sh deleted file mode 100755 index ebc66913..00000000 --- a/install-sh +++ /dev/null @@ -1,250 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). -# -# Copyright 1991 by the Massachusetts Institute of Technology -# -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/missing b/missing deleted file mode 100755 index 6a37006e..00000000 --- a/missing +++ /dev/null @@ -1,336 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# 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, 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., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -case "$1" in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case "$1" in - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags - yacc create \`y.tab.[ch]', if possible, from existing .[ch]" - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing 0.4 - GNU automake" - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - - aclocal*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case "$f" in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. - You can get \`$1Help2man' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` - test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison|yacc) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if [ ! -f y.tab.h ]; then - echo >y.tab.h - fi - if [ ! -f y.tab.c ]; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex|flex) - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if [ $# -ne 1 ]; then - eval LASTARG="\${$#}" - case "$LASTARG" in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if [ -f "$SRCFILE" ]; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if [ ! -f lex.yy.c ]; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` - fi - if [ -f "$file" ]; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit 1 - fi - ;; - - makeinfo) - if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then - # We have makeinfo, but it failed. - exit 1 - fi - - echo 1>&2 "\ -WARNING: \`$1' is missing on your system. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` - if test -z "$file"; then - file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` - fi - touch $file - ;; - - tar) - shift - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - fi - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case "$firstarg" in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case "$firstarg" in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and you do not seem to have it handy on your - system. You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequirements for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 diff --git a/mkinstalldirs b/mkinstalldirs deleted file mode 100755 index 6b3b5fc5..00000000 --- a/mkinstalldirs +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -# $Id$ - -errstatus=0 - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# mkinstalldirs ends here 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