[Nagiosplug-checkins] CVS: nagiosplug/lib exit.h,NONE,1.1 exitfail.c,NONE,1.1 exitfail.h,NONE,1.1 full-read.h,NONE,1.1 onceonly.m4,NONE,1.1 unlocked-io.m4,NONE,1.1 xalloc.m4,NONE,1.1 xstrdup.c,NONE,1.1 Makefile.am,1.18,1.19 error.c,1.1,1.2 error.h,1.1,1.2 error.m4,1.1,1.2 fsusage.c,1.2,1.3 fsusage.h,1.1,1.2 fsusage.m4,1.2,1.3 getloadavg.c,1.1,1.2 getopt.c,1.1,1.2 getopt.h,1.1,1.2 getopt1.c,1.1,1.2 gettext.h,1.1,1.2 ls-mntd-fs.m4,1.4,1.5 malloc.c,1.1,1.2 mountlist.c,1.3,1.4 mountlist.h,1.1,1.2 realloc.c,1.1,1.2 snprintf.c,1.1,1.2 strtod.c,1.1,1.2 unlocked-io.h,1.1,1.2 xalloc.h,1.1,1.2 xmalloc.c,1.1,1.2

Ton Voon tonvoon at users.sourceforge.net
Thu Nov 11 16:51:00 CET 2004


Update of /cvsroot/nagiosplug/nagiosplug/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4035/lib

Modified Files:
	Makefile.am error.c error.h error.m4 fsusage.c fsusage.h 
	fsusage.m4 getloadavg.c getopt.c getopt.h getopt1.c gettext.h 
	ls-mntd-fs.m4 malloc.c mountlist.c mountlist.h realloc.c 
	snprintf.c strtod.c unlocked-io.h xalloc.h xmalloc.c 
Added Files:
	exit.h exitfail.c exitfail.h full-read.h onceonly.m4 
	unlocked-io.m4 xalloc.m4 xstrdup.c 
Log Message:
Update to using coreutils 5.2.1 libraries and snprintf.c from samba 3.0.8


--- NEW FILE ---
/* exit() function.
   Copyright (C) 1995, 2001 Free Software Foundation, Inc.

   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.  */

#ifndef _EXIT_H
#define _EXIT_H

/* Get exit() declaration.  */
#include <stdlib.h>

/* Some systems do not define EXIT_*, even with STDC_HEADERS.  */
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif

#endif /* _EXIT_H */

--- NEW FILE ---
/* Failure exit status

   Copyright (C) 2002, 2003 Free Software Foundation, Inc.

   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; see the file COPYING.
   If not, write to the Free Software Foundation,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#if HAVE_CONFIG_H
# include <config.h>
#endif

#include "exitfail.h"
#include "exit.h"

int volatile exit_failure = EXIT_FAILURE;

--- NEW FILE ---
/* Failure exit status

   Copyright (C) 2002 Free Software Foundation, Inc.

   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; see the file COPYING.
   If not, write to the Free Software Foundation,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

extern int volatile exit_failure;

--- NEW FILE ---
/* An interface to read() that reads all it is asked to read.

   Copyright (C) 2002 Free Software Foundation, Inc.

   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, read to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#include <stddef.h>

/* Read COUNT bytes at BUF to descriptor FD, retrying if interrupted
   or if partial reads occur.  Return the number of bytes successfully
   read, setting errno if that is less than COUNT.  errno = 0 means EOF.  */
extern size_t full_read (int fd, void *buf, size_t count);

--- NEW FILE ---
# onceonly.m4 serial 3 (gettext-0.12)
dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License.  As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.

dnl This file defines some "once only" variants of standard autoconf macros.
dnl   AC_CHECK_HEADERS_ONCE         like  AC_CHECK_HEADERS
dnl   AC_CHECK_FUNCS_ONCE           like  AC_CHECK_FUNCS
dnl   AC_CHECK_DECLS_ONCE           like  AC_CHECK_DECLS
dnl   AC_REQUIRE([AC_HEADER_STDC])  like  AC_HEADER_STDC
dnl The advantage is that the check for each of the headers/functions/decls
dnl will be put only once into the 'configure' file. It keeps the size of
dnl the 'configure' file down, and avoids redundant output when 'configure'
dnl is run.
dnl The drawback is that the checks cannot be conditionalized. If you write
dnl   if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
dnl empty, and the check will be inserted before the body of the AC_DEFUNed
dnl function.

dnl Autoconf version 2.57 or newer is recommended.
AC_PREREQ(2.54)

# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
  :
  AC_FOREACH([gl_HEADER_NAME], [$1], [
    AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(m4_defn([gl_HEADER_NAME]),
                                                 [-./], [___])), [
      AC_CHECK_HEADERS(gl_HEADER_NAME)
    ])
    AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
                                                   [-./], [___])))
  ])
])

# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
  :
  AC_FOREACH([gl_FUNC_NAME], [$1], [
    AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
      AC_CHECK_FUNCS(m4_defn([gl_FUNC_NAME]))
    ])
    AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
  ])
])

# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
# AC_CHECK_DECLS(DECL1, DECL2, ...).
AC_DEFUN([AC_CHECK_DECLS_ONCE], [
  :
  AC_FOREACH([gl_DECL_NAME], [$1], [
    AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
      AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
    ])
    AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
  ])
])

--- NEW FILE ---
#serial 8 -*- autoconf -*-

dnl From Jim Meyering.
dnl
dnl See if the glibc *_unlocked I/O macros or functions are available.
dnl Use only those *_unlocked macros or functions that are declared
dnl (because some of them were declared in Solaris 2.5.1 but were removed
dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
dnl on Solaris 2.6).

AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO],
[
  dnl Persuade glibc and Solaris <stdio.h> to declare
  dnl fgets_unlocked(), fputs_unlocked() etc.
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])

  AC_CHECK_DECLS_ONCE(
     [clearerr_unlocked feof_unlocked ferror_unlocked
      fflush_unlocked fgets_unlocked fputc_unlocked fputs_unlocked
      fread_unlocked fwrite_unlocked getc_unlocked
      getchar_unlocked putc_unlocked putchar_unlocked])
])

--- NEW FILE ---
# xalloc.m4 serial 8
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License.  As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.

AC_DEFUN([gl_XALLOC],
[
  gl_PREREQ_XALLOC
  gl_PREREQ_XMALLOC
  gl_PREREQ_XSTRDUP
])

# Prerequisites of lib/xalloc.h.
AC_DEFUN([gl_PREREQ_XALLOC], [
  :
])

# Prerequisites of lib/xmalloc.c.
AC_DEFUN([gl_PREREQ_XMALLOC], [
  AC_REQUIRE([AC_C_INLINE])
  AC_REQUIRE([jm_FUNC_MALLOC])
  AC_REQUIRE([jm_FUNC_REALLOC])
  :
])

# Prerequisites of lib/xstrdup.c.
AC_DEFUN([gl_PREREQ_XSTRDUP], [
  :
])

--- NEW FILE ---
/* xstrdup.c -- copy a string with out of memory checking
   Copyright (C) 1990, 1996, 1998, 2001, 2003 Free Software Foundation, Inc.

   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.  */

#if HAVE_CONFIG_H
# include <config.h>
#endif

/* Specification.  */
#include "xalloc.h"

#include <string.h>

/* Return a newly allocated copy of STRING.  */

char *
xstrdup (const char *string)
{
  return xclone (string, strlen (string) + 1);
}

Index: Makefile.am
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/Makefile.am,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** Makefile.am	24 May 2004 14:21:36 -0000	1.18
--- Makefile.am	12 Nov 2004 00:49:51 -0000	1.19
***************
*** 3,7 ****
  noinst_LIBRARIES = libnagiosplug.a
  
! libnagiosplug_a_SOURCES = getopt.c getopt1.c snprintf.c fsusage.c mountlist.c xmalloc.c
  
  libnagiosplug_a_LIBADD = @LIBOBJS@
--- 3,8 ----
  noinst_LIBRARIES = libnagiosplug.a
  
! libnagiosplug_a_SOURCES = getopt.c getopt1.c fsusage.c snprintf.c mountlist.c \
! 		xmalloc.c xstrdup.c exitfail.c
  
  libnagiosplug_a_LIBADD = @LIBOBJS@
***************
*** 13,17 ****
  		lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 afs.m4 \
  		fstypename.m4 fsusage.m4 ls-mntd-fs.m4 getopt.h gettext.h fsusage.h mountlist.h\
! 		error.m4 error.h error.c getloadavg.c xalloc.h unlocked-io.h malloc.c realloc.c strtod.c
  
  INCLUDES = -I$(srcdir) -I$(top_srcdir)/intl
--- 14,19 ----
  		lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 afs.m4 \
  		fstypename.m4 fsusage.m4 ls-mntd-fs.m4 getopt.h gettext.h fsusage.h mountlist.h\
! 		error.m4 error.h error.c getloadavg.c xalloc.h unlocked-io.h unlocked-io.m4 malloc.c \
! 		onceonly.m4 realloc.c strtod.c exitfail.h full-read.h xstrdup.c xalloc.m4 exit.h
  
  INCLUDES = -I$(srcdir) -I$(top_srcdir)/intl

Index: error.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/error.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** error.c	17 Sep 2003 16:31:38 -0000	1.1
--- error.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,4 ****
  /* Error handler for noninteractive utilities
!    Copyright (C) 1990-1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     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
--- 1,6 ----
  /* Error handler for noninteractive utilities
!    Copyright (C) 1990-1998, 2000-2002, 2003 Free Software Foundation, Inc.
!    This file is part of the GNU C Library.
! 
     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
***************
*** 21,25 ****
--- 23,32 ----
  #endif
  
+ #include "error.h"
+ 
+ #include <stdarg.h>
  #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
  
  #ifdef _LIBC
***************
*** 34,59 ****
  #endif
  
- #if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
- # if __STDC__
- #  include <stdarg.h>
- #  define VA_START(args, lastarg) va_start(args, lastarg)
- # else
- #  include <varargs.h>
- #  define VA_START(args, lastarg) va_start(args)
- # endif
- #else
- # define va_alist a1, a2, a3, a4, a5, a6, a7, a8
- # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
- #endif
- 
- #if STDC_HEADERS || _LIBC
- # include <stdlib.h>
- # include <string.h>
- #else
- void exit ();
- #endif
- 
- #include "error.h"
- 
  #if !_LIBC
  # include "unlocked-io.h"
--- 41,44 ----
***************
*** 67,75 ****
     name, a colon and a space.  Otherwise, error will call this
     function without parameters instead.  */
! void (*error_print_progname) (
! #if __STDC__ - 0
! 			      void
! #endif
! 			      );
  
  /* This variable is incremented each time `error' is called.  */
--- 52,56 ----
     name, a colon and a space.  Otherwise, error will call this
     function without parameters instead.  */
! void (*error_print_progname) (void);
  
  /* This variable is incremented each time `error' is called.  */
***************
*** 99,102 ****
--- 80,85 ----
  # define putc(c, fp) INTUSE(_IO_putc) (c, fp)
  
+ # include <bits/libc-lock.h>
+ 
  #else /* not _LIBC */
  
***************
*** 108,139 ****
  # endif
  
  /* The calling program should define program_name and set it to the
     name of the executing program.  */
! extern char *progname;
  
  # if HAVE_STRERROR_R || defined strerror_r
  #  define __strerror_r strerror_r
! # else
! #  if HAVE_STRERROR
! #   ifndef HAVE_DECL_STRERROR
! "this configure-time declaration test was not run"
! #   endif
! #   if !HAVE_DECL_STRERROR
! char *strerror ();
! #   endif
! #  else
! static char *
! private_strerror (int errnum)
! {
!   extern char *sys_errlist[];
!   extern int sys_nerr;
! 
!   if (errnum > 0 && errnum <= sys_nerr)
!     return _(sys_errlist[errnum]);
!   return _("Unknown system error");
! }
! #   define strerror private_strerror
! #  endif /* HAVE_STRERROR */
! # endif	/* HAVE_STRERROR_R || defined strerror_r */
  #endif	/* not _LIBC */
  
--- 91,105 ----
  # endif
  
+ # ifndef SIZE_MAX
+ #  define SIZE_MAX ((size_t) -1)
+ # endif
+ 
  /* The calling program should define program_name and set it to the
     name of the executing program.  */
! extern char *program_name;
  
  # if HAVE_STRERROR_R || defined strerror_r
  #  define __strerror_r strerror_r
! # endif
  #endif	/* not _LIBC */
  
***************
*** 173,227 ****
  }
  
- #ifdef VA_START
  static void
  error_tail (int status, int errnum, const char *message, va_list args)
  {
! # if HAVE_VPRINTF || _LIBC
! #  if _LIBC
    if (_IO_fwide (stderr, 0) > 0)
      {
! #   define ALLOCA_LIMIT	2000
        size_t len = strlen (message) + 1;
!       wchar_t *wmessage = NULL;
!       mbstate_t st;
!       size_t res;
!       const char *tmp;
  
!       do
  	{
! 	  if (len < ALLOCA_LIMIT)
! 	    wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
! 	  else
! 	    {
! 	      if (wmessage != NULL && len / 2 < ALLOCA_LIMIT)
! 		wmessage = NULL;
! 
! 	      wmessage = (wchar_t *) realloc (wmessage,
! 					      len * sizeof (wchar_t));
! 
! 	      if (wmessage == NULL)
! 		{
! 		  fputws_unlocked (L"out of memory\n", stderr);
! 		  return;
! 		}
! 	    }
! 
  	  memset (&st, '\0', sizeof (st));
! 	  tmp =message;
  	}
-       while ((res = mbsrtowcs (wmessage, &tmp, len, &st)) == len);
- 
-       if (res == (size_t) -1)
- 	/* The string cannot be converted.  */
- 	wmessage = (wchar_t *) L"???";
  
        __vfwprintf (stderr, wmessage, args);
      }
    else
! #  endif
      vfprintf (stderr, message, args);
- # else
-   _doprnt (message, args, stderr);
- # endif
    va_end (args);
  
--- 139,174 ----
  }
  
  static void
  error_tail (int status, int errnum, const char *message, va_list args)
  {
! #if _LIBC
    if (_IO_fwide (stderr, 0) > 0)
      {
! # define ALLOCA_LIMIT 2000
        size_t len = strlen (message) + 1;
!       const wchar_t *wmessage = L"out of memory";
!       wchar_t *wbuf = (len < ALLOCA_LIMIT
! 		       ? alloca (len * sizeof *wbuf)
! 		       : len <= SIZE_MAX / sizeof *wbuf
! 		       ? malloc (len * sizeof *wbuf)
! 		       : NULL);
  
!       if (wbuf)
  	{
! 	  size_t res;
! 	  mbstate_t st;
! 	  const char *tmp = message;
  	  memset (&st, '\0', sizeof (st));
! 	  res = mbsrtowcs (wbuf, &tmp, len, &st);
! 	  wmessage = res == (size_t) -1 ? L"???" : wbuf;
  	}
  
        __vfwprintf (stderr, wmessage, args);
+       if (! (len < ALLOCA_LIMIT))
+ 	free (wbuf);
      }
    else
! #endif
      vfprintf (stderr, message, args);
    va_end (args);
  
***************
*** 229,237 ****
    if (errnum)
      print_errno_message (errnum);
! # if _LIBC
    if (_IO_fwide (stderr, 0) > 0)
      putwc (L'\n', stderr);
    else
! # endif
      putc ('\n', stderr);
    fflush (stderr);
--- 176,184 ----
    if (errnum)
      print_errno_message (errnum);
! #if _LIBC
    if (_IO_fwide (stderr, 0) > 0)
      putwc (L'\n', stderr);
    else
! #endif
      putc ('\n', stderr);
    fflush (stderr);
***************
*** 239,243 ****
      exit (status);
  }
- #endif
  
  
--- 186,189 ----
***************
*** 246,263 ****
     If ERRNUM is nonzero, print its corresponding system error message.
     Exit with status STATUS if it is nonzero.  */
- /* VARARGS */
  void
- #if defined VA_START && __STDC__
  error (int status, int errnum, const char *message, ...)
- #else
- error (status, errnum, message, va_alist)
-      int status;
-      int errnum;
-      char *message;
-      va_dcl
- #endif
  {
- #ifdef VA_START
    va_list args;
  #endif
  
--- 192,206 ----
     If ERRNUM is nonzero, print its corresponding system error message.
     Exit with status STATUS if it is nonzero.  */
  void
  error (int status, int errnum, const char *message, ...)
  {
    va_list args;
+ 
+ #if defined _LIBC && defined __libc_ptf_call
+   /* We do not want this call to be cut short by a thread
+      cancellation.  Therefore disable cancellation for now.  */
+   int state = PTHREAD_CANCEL_ENABLE;
+   __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+ 		   0);
  #endif
  
***************
*** 272,298 ****
  #if _LIBC
        if (_IO_fwide (stderr, 0) > 0)
! 	__fwprintf (stderr, L"%s: ", progname);
        else
  #endif
! 	fprintf (stderr, "%s: ", progname);
      }
  
! #ifdef VA_START
!   VA_START (args, message);
    error_tail (status, errnum, message, args);
- #else
-   fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
- 
-   ++error_message_count;
-   if (errnum)
-     print_errno_message (errnum);
-   putc ('\n', stderr);
-   fflush (stderr);
-   if (status)
-     exit (status);
- #endif
  
  #ifdef _LIBC
    _IO_funlockfile (stderr);
  #endif
  }
--- 215,232 ----
  #if _LIBC
        if (_IO_fwide (stderr, 0) > 0)
! 	__fwprintf (stderr, L"%s: ", program_name);
        else
  #endif
! 	fprintf (stderr, "%s: ", program_name);
      }
  
!   va_start (args, message);
    error_tail (status, errnum, message, args);
  
  #ifdef _LIBC
    _IO_funlockfile (stderr);
+ # ifdef __libc_ptf_call
+   __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+ # endif
  #endif
  }
***************
*** 303,322 ****
  
  void
- #if defined VA_START && __STDC__
  error_at_line (int status, int errnum, const char *file_name,
  	       unsigned int line_number, const char *message, ...)
- #else
- error_at_line (status, errnum, file_name, line_number, message, va_alist)
-      int status;
-      int errnum;
-      const char *file_name;
-      unsigned int line_number;
-      char *message;
-      va_dcl
- #endif
  {
- #ifdef VA_START
    va_list args;
- #endif
  
    if (error_one_per_line)
--- 237,244 ----
***************
*** 335,338 ****
--- 257,268 ----
      }
  
+ #if defined _LIBC && defined __libc_ptf_call
+   /* We do not want this call to be cut short by a thread
+      cancellation.  Therefore disable cancellation for now.  */
+   int state = PTHREAD_CANCEL_ENABLE;
+   __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
+ 		   0);
+ #endif
+ 
    fflush (stdout);
  #ifdef _LIBC
***************
*** 345,352 ****
  #if _LIBC
        if (_IO_fwide (stderr, 0) > 0)
! 	__fwprintf (stderr, L"%s: ", progname);
        else
  #endif
! 	fprintf (stderr, "%s:", progname);
      }
  
--- 275,282 ----
  #if _LIBC
        if (_IO_fwide (stderr, 0) > 0)
! 	__fwprintf (stderr, L"%s: ", program_name);
        else
  #endif
! 	fprintf (stderr, "%s:", program_name);
      }
  
***************
*** 361,381 ****
      }
  
! #ifdef VA_START
!   VA_START (args, message);
    error_tail (status, errnum, message, args);
- #else
-   fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8);
- 
-   ++error_message_count;
-   if (errnum)
-     print_errno_message (errnum);
-   putc ('\n', stderr);
-   fflush (stderr);
-   if (status)
-     exit (status);
- #endif
  
  #ifdef _LIBC
    _IO_funlockfile (stderr);
  #endif
  }
--- 291,302 ----
      }
  
!   va_start (args, message);
    error_tail (status, errnum, message, args);
  
  #ifdef _LIBC
    _IO_funlockfile (stderr);
+ # ifdef __libc_ptf_call
+   __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
+ # endif
  #endif
  }

Index: error.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/error.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** error.h	17 Sep 2003 16:31:38 -0000	1.1
--- error.h	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,13 ****
  /* Declaration for error-reporting function
!    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
  
! 
!    NOTE: The canonical source of this file is maintained with the GNU C Library.
!    Bugs can be reported to bug-glibc at prep.ai.mit.edu.
! 
!    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,
--- 1,10 ----
  /* Declaration for error-reporting function
!    Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
!    This file is part of the GNU C Library.
  
!    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,
***************
*** 16,23 ****
     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.  */
  
  #ifndef _ERROR_H
--- 13,19 ----
     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.  */
  
  #ifndef _ERROR_H
***************
*** 41,55 ****
  #endif
  
- #if defined (__STDC__) && __STDC__
- 
  /* Print a message with `fprintf (stderr, FORMAT, ...)';
     if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
     If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
  
! extern void error (int status, int errnum, const char *format, ...)
       __attribute__ ((__format__ (__printf__, 3, 4)));
  
! extern void error_at_line (int status, int errnum, const char *fname,
! 			   unsigned int lineno, const char *format, ...)
       __attribute__ ((__format__ (__printf__, 5, 6)));
  
--- 37,49 ----
  #endif
  
  /* Print a message with `fprintf (stderr, FORMAT, ...)';
     if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
     If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
  
! extern void error (int __status, int __errnum, const char *__format, ...)
       __attribute__ ((__format__ (__printf__, 3, 4)));
  
! extern void error_at_line (int __status, int __errnum, const char *__fname,
! 			   unsigned int __lineno, const char *__format, ...)
       __attribute__ ((__format__ (__printf__, 5, 6)));
  
***************
*** 59,68 ****
  extern void (*error_print_progname) (void);
  
- #else
- void error ();
- void error_at_line ();
- extern void (*error_print_progname) ();
- #endif
- 
  /* This variable is incremented each time `error' is called.  */
  extern unsigned int error_message_count;
--- 53,56 ----

Index: error.m4
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/error.m4,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** error.m4	17 Sep 2003 16:31:38 -0000	1.1
--- error.m4	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,14 ****
! #serial 5
  
! dnl FIXME: put these prerequisite-only *.m4 files in a separate
! dnl directory -- otherwise, they'll conflict with existing files.
  
! dnl These are the prerequisite macros for GNU's error.c file.
  AC_DEFUN([jm_PREREQ_ERROR],
  [
!   AC_CHECK_FUNCS(strerror vprintf doprnt)
!   AC_CHECK_DECLS([strerror])
!   AC_CHECK_HEADERS([libintl.h])
!   AC_FUNC_STRERROR_R
!   AC_HEADER_STDC
  ])
--- 1,15 ----
! #serial 9
  
! AC_DEFUN([gl_ERROR],
! [
!   AC_FUNC_ERROR_AT_LINE
!   dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]).
!   jm_PREREQ_ERROR
! ])
  
! # Prerequisites of lib/error.c.
  AC_DEFUN([jm_PREREQ_ERROR],
  [
!   AC_REQUIRE([AC_FUNC_STRERROR_R])
!   :
  ])

Index: fsusage.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/fsusage.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** fsusage.c	20 Oct 2003 14:03:17 -0000	1.2
--- fsusage.c	12 Nov 2004 00:49:51 -0000	1.3
***************
*** 1,4 ****
  /* fsusage.c -- return space usage of mounted filesystems
!    Copyright (C) 1991, 1992, 1996, 1998, 1999 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,6 ----
  /* fsusage.c -- return space usage of mounted filesystems
! 
!    Copyright (C) 1991, 1992, 1996, 1998, 1999, 2002, 2003 Free
!    Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 16,36 ****
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
! #include "config.h"
  
  #if HAVE_INTTYPES_H
  # include <inttypes.h>
  #endif
  #include <sys/types.h>
  #include <sys/stat.h>
  #include "fsusage.h"
  
! #if HAVE_LIMITS_H
! # include <limits.h>
! #endif
! #ifndef CHAR_BIT
! # define CHAR_BIT 8
! #endif
! 
! int statfs ();
  
  #if HAVE_SYS_PARAM_H
--- 18,41 ----
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
! #if HAVE_CONFIG_H
! # include <config.h>
! #endif
  
  #if HAVE_INTTYPES_H
  # include <inttypes.h>
+ #else
+ # if HAVE_STDINT_H
+ #  include <stdint.h>
+ # endif
  #endif
+ #ifndef UINTMAX_MAX
+ # define UINTMAX_MAX ((uintmax_t) -1)
+ #endif
+ 
  #include <sys/types.h>
  #include <sys/stat.h>
  #include "fsusage.h"
  
! #include <limits.h>
  
  #if HAVE_SYS_PARAM_H
***************
*** 50,54 ****
  #endif
  
! #if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
  # include <sys/filsys.h>	/* SVR2 */
  #endif
--- 55,59 ----
  #endif
  
! #if defined HAVE_SYS_FILSYS_H && !defined _CRAY
  # include <sys/filsys.h>	/* SVR2 */
  #endif
***************
*** 71,79 ****
  #endif
  
  /* Many space usage primitives use all 1 bits to denote a value that is
     not applicable or unknown.  Propagate this information by returning
!    a uintmax_t value that is all 1 bits if the argument is all 1 bits,
!    even if the argument is unsigned and smaller than uintmax_t.  */
! #define PROPAGATE_ALL_ONES(x) ((x) == -1 ? (uintmax_t) -1 : (uintmax_t) (x))
  
  /* Extract the top bit of X as an uintmax_t value.  */
--- 76,91 ----
  #endif
  
+ #include "full-read.h"
+ 
  /* Many space usage primitives use all 1 bits to denote a value that is
     not applicable or unknown.  Propagate this information by returning
!    a uintmax_t value that is all 1 bits if X is all 1 bits, even if X
!    is unsigned and narrower than uintmax_t.  */
! #define PROPAGATE_ALL_ONES(x) \
!   ((sizeof (x) < sizeof (uintmax_t) \
!     && (~ (x) == (sizeof (x) < sizeof (int) \
! 		  ? - (1 << (sizeof (x) * CHAR_BIT)) \
! 		  : 0))) \
!    ? UINTMAX_MAX : (x))
  
  /* Extract the top bit of X as an uintmax_t value.  */
***************
*** 90,95 ****
  #define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1))
  
- int safe_read ();
- 
  /* Fill in the fields of FSP with information about space usage for
     the filesystem on which PATH resides.
--- 102,105 ----
***************
*** 148,152 ****
      return -1;
    lseek (fd, (off_t) SUPERBOFF, 0);
!   if (safe_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
      {
        close (fd);
--- 158,162 ----
      return -1;
    lseek (fd, (off_t) SUPERBOFF, 0);
!   if (full_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
      {
        close (fd);
***************
*** 161,165 ****
    fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0;
    fsp->fsu_files = (fsd.s_isize == -1
! 		    ? (uintmax_t) -1
  		    : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
    fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
--- 171,175 ----
    fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0;
    fsp->fsu_files = (fsd.s_isize == -1
! 		    ? UINTMAX_MAX
  		    : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
    fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
***************
*** 218,222 ****
       systems seem to always be in terms of 512-byte blocks,
       no matter what value f_bsize has.  */
! # if _AIX || defined(_CRAY)
     fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
  # else
--- 228,232 ----
       systems seem to always be in terms of 512-byte blocks,
       no matter what value f_bsize has.  */
! # if _AIX || defined _CRAY
     fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
  # else
***************
*** 234,243 ****
  
    /* f_frsize isn't guaranteed to be supported.  */
!   fsp->fsu_blocksize =
!     PROPAGATE_ALL_ONES (fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize);
  
  #endif /* STAT_STATVFS */
  
! #if !defined(STAT_STATFS2_FS_DATA) && !defined(STAT_READ_FILSYS)
  				/* !Ultrix && !SVR2 */
  
--- 244,254 ----
  
    /* f_frsize isn't guaranteed to be supported.  */
!   fsp->fsu_blocksize = (fsd.f_frsize
! 			? PROPAGATE_ALL_ONES (fsd.f_frsize)
! 			: PROPAGATE_ALL_ONES (fsd.f_bsize));
  
  #endif /* STAT_STATVFS */
  
! #if !defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS
  				/* !Ultrix && !SVR2 */
  
***************
*** 254,258 ****
  }
  
! #if defined(_AIX) && defined(_I386)
  /* AIX PS/2 does not supply statfs.  */
  
--- 265,269 ----
  }
  
! #if defined _AIX && defined _I386
  /* AIX PS/2 does not supply statfs.  */
  

Index: fsusage.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/fsusage.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** fsusage.h	18 Mar 2003 07:47:37 -0000	1.1
--- fsusage.h	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,4 ****
  /* fsusage.h -- declarations for filesystem space usage info
!    Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,5 ----
  /* fsusage.h -- declarations for filesystem space usage info
! 
!    Copyright (C) 1991, 1992, 1997, 2003 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 32,45 ****
  };
  
! # ifndef PARAMS
! #  if defined PROTOTYPES || (defined __STDC__ && __STDC__)
! #   define PARAMS(Args) Args
! #  else
! #   define PARAMS(Args) ()
! #  endif
! # endif
! 
! int get_fs_usage PARAMS ((const char *path, const char *disk,
! 			  struct fs_usage *fsp));
  
  #endif
--- 33,37 ----
  };
  
! int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp);
  
  #endif

Index: fsusage.m4
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/fsusage.m4,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** fsusage.m4	18 Feb 2004 14:56:39 -0000	1.2
--- fsusage.m4	12 Nov 2004 00:49:51 -0000	1.3
***************
*** 1,6 ****
! #serial 9
  
  # From fileutils/configure.in
  
  # Try to determine how a program can obtain filesystem usage information.
  # If successful, define the appropriate symbol (see fsusage.c) and
--- 1,17 ----
! #serial 11
  
  # From fileutils/configure.in
  
+ AC_DEFUN([gl_FSUSAGE],
+ [
+   AC_CHECK_HEADERS_ONCE(sys/param.h)
+   AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs_types.h)
+   jm_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no])
+   if test $gl_cv_fs_space = yes; then
+     AC_LIBOBJ(fsusage)
+     gl_PREREQ_FSUSAGE_EXTRA
+   fi
+ ])
+ 
  # Try to determine how a program can obtain filesystem usage information.
  # If successful, define the appropriate symbol (see fsusage.c) and
***************
*** 194,199 ****
  fi
  
! dnl AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
! if test $ac_fsusage_space = yes ; then [$1] ; else [$2] ; fi
  
  ])
--- 205,246 ----
  fi
  
! AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
  
  ])
+ 
+ 
+ # Check for SunOS statfs brokenness wrt partitions 2GB and larger.
+ # If <sys/vfs.h> exists and struct statfs has a member named f_spare,
+ # enable the work-around code in fsusage.c.
+ AC_DEFUN([jm_STATFS_TRUNCATES],
+ [
+   AC_MSG_CHECKING([for statfs that truncates block counts])
+   AC_CACHE_VAL(fu_cv_sys_truncating_statfs,
+   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #if !defined(sun) && !defined(__sun)
+ choke -- this is a workaround for a Sun-specific problem
+ #endif
+ #include <sys/types.h>
+ #include <sys/vfs.h>]],
+     [[struct statfs t; long c = *(t.f_spare);]])],
+     [fu_cv_sys_truncating_statfs=yes],
+     [fu_cv_sys_truncating_statfs=no])])
+   if test $fu_cv_sys_truncating_statfs = yes; then
+     AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1,
+       [Define if the block counts reported by statfs may be truncated to 2GB
+        and the correct values may be stored in the f_spare array.
+        (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
+        SunOS 4.1.1 seems not to be affected.)])
+   fi
+   AC_MSG_RESULT($fu_cv_sys_truncating_statfs)
+ ])
+ 
+ 
+ # Prerequisites of lib/fsusage.c not done by jm_FILE_SYSTEM_USAGE.
+ AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
+ [
+   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])
+   AC_CHECK_HEADERS_ONCE(fcntl.h)
+   AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h sys/statvfs.h)
+   jm_STATFS_TRUNCATES
+ ])

Index: getloadavg.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/getloadavg.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** getloadavg.c	19 Feb 2003 00:45:43 -0000	1.1
--- getloadavg.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,5 ****
  /* Get the system load averages.
!    Copyright (C) 1985, 86, 87, 88, 89, 91, 92, 93, 1994, 1995, 1997
!    	Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,9 ----
  /* Get the system load averages.
! 
!    Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994,
!    1995, 1997, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
! 
!    NOTE: The canonical source of this file is maintained with gnulib.
!    Bugs can be reported to bug-gnulib at gnu.org.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 36,45 ****
  				Must be defined unless one of
  				apollo, DGUX, NeXT, or UMAX is defined;
  				otherwise, no load average is available.
     NLIST_STRUCT			Include nlist.h, not a.out.h, and
  				the nlist n_name element is a pointer,
  				not an array.
!    NLIST_NAME_UNION		struct nlist has an n_un member, not n_name.
     LINUX_LDAV_FILE		[__linux__]: File containing load averages.
  
     Specific system predefines this file uses, aside from setting
--- 40,54 ----
  				Must be defined unless one of
  				apollo, DGUX, NeXT, or UMAX is defined;
+                                 or we have libkstat;
  				otherwise, no load average is available.
+    HAVE_NLIST_H                 nlist.h is available.  NLIST_STRUCT defaults
+                                 to this.
     NLIST_STRUCT			Include nlist.h, not a.out.h, and
  				the nlist n_name element is a pointer,
  				not an array.
!    HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'.
     LINUX_LDAV_FILE		[__linux__]: File containing load averages.
+    HAVE_LOCALE_H                locale.h is available.
+    HAVE_SETLOCALE               The `setlocale' function is available.
  
     Specific system predefines this file uses, aside from setting
***************
*** 63,67 ****
     WINDOWS32			No-op for Windows95/NT.
     __linux__			Linux: assumes /proc filesystem mounted.
!    				Support from Michael K. Johnson.
     __NetBSD__			NetBSD: assumes /kern filesystem mounted.
  
--- 72,76 ----
     WINDOWS32			No-op for Windows95/NT.
     __linux__			Linux: assumes /proc filesystem mounted.
! 				Support from Michael K. Johnson.
     __NetBSD__			NetBSD: assumes /kern filesystem mounted.
  
***************
*** 82,86 ****
     configuration files' definitions for the LOAD_AVE_CVT macro (like
     sparc.h's) use macros like FSCALE, defined here.  */
! #ifdef unix
  # include <sys/param.h>
  #endif
--- 91,95 ----
     configuration files' definitions for the LOAD_AVE_CVT macro (like
     sparc.h's) use macros like FSCALE, defined here.  */
! #if defined (unix) || defined (__unix)
  # include <sys/param.h>
  #endif
***************
*** 99,109 ****
  #endif
  
! #if HAVE_LOCALE_H
  # include <locale.h>
  #endif
! #if !HAVE_SETLOCALE
  # define setlocale(Category, Locale) /* empty */
  #endif
  
  #ifndef HAVE_GETLOADAVG
  
--- 108,120 ----
  #endif
  
! #ifdef HAVE_LOCALE_H
  # include <locale.h>
  #endif
! #ifndef HAVE_SETLOCALE
  # define setlocale(Category, Locale) /* empty */
  #endif
  
+ #include "cloexec.h"
+ 
  #ifndef HAVE_GETLOADAVG
  
***************
*** 118,122 ****
     LDAV_CVT directly.  */
  
! # if !defined(LDAV_CVT) && defined(LOAD_AVE_CVT)
  #  define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
  # endif
--- 129,133 ----
     LDAV_CVT directly.  */
  
! # if !defined (LDAV_CVT) && defined (LOAD_AVE_CVT)
  #  define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
  # endif
***************
*** 138,141 ****
--- 149,158 ----
  # endif
  
+ /* Same issues as for NeXT apply to the HURD-based GNU system.  */
+ # ifdef __GNU__
+ #  undef BSD
+ #  undef FSCALE
+ # endif /* __GNU__ */
+ 
  /* Set values that are different from the defaults, which are
     set a little farther down with #ifndef.  */
***************
*** 156,164 ****
  # endif
  
! # if defined(hp300) && !defined(hpux)
  #  define MORE_BSD
  # endif
  
! # if defined(ultrix) && defined(mips)
  #  define decstation
  # endif
--- 173,181 ----
  # endif
  
! # if defined (hp300) && !defined (hpux)
  #  define MORE_BSD
  # endif
  
! # if defined (ultrix) && defined (mips)
  #  define decstation
  # endif
***************
*** 168,172 ****
  # endif
  
! # if (defined(sun) && defined(SVR4)) || defined (SOLARIS2)
  #  define SUNOS_5
  # endif
--- 185,189 ----
  # endif
  
! # if (defined (sun) && defined (SVR4)) || defined (SOLARIS2)
  #  define SUNOS_5
  # endif
***************
*** 240,244 ****
  #  endif
  
! #  if defined(alliant) && defined(i860) /* Alliant FX/2800 */
  #   define LOAD_AVE_TYPE long
  #  endif
--- 257,261 ----
  #  endif
  
! #  if defined (alliant) && defined (i860) /* Alliant FX/2800 */
  #   define LOAD_AVE_TYPE long
  #  endif
***************
*** 264,268 ****
  # endif
  
! # if defined(alliant) && defined(i860) /* Alliant FX/2800 */
  /* <sys/param.h> defines an incorrect value for FSCALE on an
     Alliant FX/2800 Concentrix 2.2, according to ghazi at noc.rutgers.edu.  */
--- 281,285 ----
  # endif
  
! # if defined (alliant) && defined (i860) /* Alliant FX/2800 */
  /* <sys/param.h> defines an incorrect value for FSCALE on an
     Alliant FX/2800 Concentrix 2.2, according to ghazi at noc.rutgers.edu.  */
***************
*** 280,284 ****
  #  endif
  
! #  if defined(MIPS) || defined(SVR4) || defined(decstation)
  #   define FSCALE 256
  #  endif
--- 297,301 ----
  #  endif
  
! #  if defined (MIPS) || defined (SVR4) || defined (decstation)
  #   define FSCALE 256
  #  endif
***************
*** 315,381 ****
  # endif
  
! /* VAX C can't handle multi-line #ifs, or lines longer that 256 characters.  */
! # ifndef NLIST_STRUCT
! 
! #  ifdef MORE_BSD
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef sun
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef decstation
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef hpux
! #   define NLIST_STRUCT
! #  endif
! 
! #  if defined (_SEQUENT_) || defined (sequent)
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef sgi
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef SVR4
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef sony_news
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef OSF_ALPHA
! #   define NLIST_STRUCT
! #  endif
! 
! #  if defined (ardent) && defined (titan)
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef tek4300
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef butterfly
! #   define NLIST_STRUCT
! #  endif
! 
! #  if defined(alliant) && defined(i860) /* Alliant FX/2800 */
! #   define NLIST_STRUCT
! #  endif
! 
! #  ifdef _AIX
! #   define NLIST_STRUCT
! #  endif
! 
! # endif /* defined (NLIST_STRUCT) */
! 
! 
! # if defined(sgi) || (defined(mips) && !defined(BSD))
  #  define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
  # endif
--- 332,336 ----
  # endif
  
! # if defined (sgi) || (defined (mips) && !defined (BSD))
  #  define FIXUP_KERNEL_SYMBOL_ADDR(nl) ((nl)[0].n_value &= ~(1 << 31))
  # endif
***************
*** 390,394 ****
  # endif
  
! # if !defined(KERNEL_FILE) && (defined(_SEQUENT_) || defined(MIPS) || defined(SVR4) || defined(ISC) || defined (sgi) || (defined (ardent) && defined (titan)))
  #  define KERNEL_FILE "/unix"
  # endif
--- 345,349 ----
  # endif
  
! # if !defined (KERNEL_FILE) && (defined (_SEQUENT_) || defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)))
  #  define KERNEL_FILE "/unix"
  # endif
***************
*** 399,403 ****
  # endif
  
! # if !defined(LDAV_SYMBOL) && ((defined(hpux) && !defined(hp9000s300)) || defined(_SEQUENT_) || defined(SVR4) || defined(ISC) || defined(sgi) || (defined (ardent) && defined (titan)) || defined (_AIX))
  #  define LDAV_SYMBOL "avenrun"
  # endif
--- 354,358 ----
  # endif
  
! # if !defined (LDAV_SYMBOL) && ((defined (hpux) && !defined (hp9000s300)) || defined (_SEQUENT_) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)) || defined (_AIX))
  #  define LDAV_SYMBOL "avenrun"
  # endif
***************
*** 411,415 ****
  /* LOAD_AVE_TYPE should only get defined if we're going to use the
     nlist method.  */
! # if !defined(LOAD_AVE_TYPE) && (defined(BSD) || defined(LDAV_CVT) || defined(KERNEL_FILE) || defined(LDAV_SYMBOL))
  #  define LOAD_AVE_TYPE double
  # endif
--- 366,370 ----
  /* LOAD_AVE_TYPE should only get defined if we're going to use the
     nlist method.  */
! # if !defined (LOAD_AVE_TYPE) && (defined (BSD) || defined (LDAV_CVT) || defined (KERNEL_FILE) || defined (LDAV_SYMBOL))
  #  define LOAD_AVE_TYPE double
  # endif
***************
*** 460,464 ****
  # endif /* LOAD_AVE_TYPE */
  
! # if defined(__GNU__) && !defined (NeXT)
  /* Note that NeXT Openstep defines __GNU__ even though it should not.  */
  /* GNU system acts much like NeXT, for load average purposes,
--- 415,419 ----
  # endif /* LOAD_AVE_TYPE */
  
! # if defined (__GNU__) && !defined (NeXT)
  /* Note that NeXT Openstep defines __GNU__ even though it should not.  */
  /* GNU system acts much like NeXT, for load average purposes,
***************
*** 507,511 ****
  # endif
  
! # if defined(HAVE_FCNTL_H) || defined(_POSIX_VERSION)
  #  include <fcntl.h>
  # else
--- 462,466 ----
  # endif
  
! # if defined (HAVE_FCNTL_H) || defined (_POSIX_VERSION)
  #  include <fcntl.h>
  # else
***************
*** 529,533 ****
  # endif /* DGUX */
  
! # ifdef LOAD_AVE_TYPE
  /* File descriptor open to /dev/kmem or VMS load ave driver.  */
  static int channel;
--- 484,488 ----
  # endif /* DGUX */
  
! # if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
  /* File descriptor open to /dev/kmem or VMS load ave driver.  */
  static int channel;
***************
*** 537,541 ****
  static long offset;
  
! #  if !defined(VMS) && !defined(sgi) && !defined(__linux__)
  static struct nlist nl[2];
  #  endif /* Not VMS or sgi */
--- 492,496 ----
  static long offset;
  
! #  if !defined (VMS) && !defined (sgi) && !defined (__linux__)
  static struct nlist nl[2];
  #  endif /* Not VMS or sgi */
***************
*** 545,549 ****
  #  endif /* SUNOS_5 */
  
! # endif /* LOAD_AVE_TYPE */
  
  /* Put the 1 minute, 5 minute and 15 minute load averages
--- 500,504 ----
  #  endif /* SUNOS_5 */
  
! # endif /* LOAD_AVE_TYPE && !HAVE_LIBKSTAT */
  
  /* Put the 1 minute, 5 minute and 15 minute load averages
***************
*** 553,559 ****
  
  int
! getloadavg (loadavg, nelem)
!      double loadavg[];
!      int nelem;
  {
    int elem = 0;			/* Return value.  */
--- 508,512 ----
  
  int
! getloadavg (double loadavg[], int nelem)
  {
    int elem = 0;			/* Return value.  */
***************
*** 578,582 ****
      return -1;
    ksp = kstat_lookup (kc, "unix", 0, "system_misc");
!   if (ksp == 0 )
      return -1;
    if (kstat_read (kc, ksp, 0) == -1)
--- 531,535 ----
      return -1;
    ksp = kstat_lookup (kc, "unix", 0, "system_misc");
!   if (ksp == 0)
      return -1;
    if (kstat_read (kc, ksp, 0) == -1)
***************
*** 593,597 ****
  
    if (nelem >= 1)
!     loadavg[elem++] = (double) kn->value.ul/FSCALE;
  
    if (nelem >= 2)
--- 546,550 ----
  
    if (nelem >= 1)
!     loadavg[elem++] = (double) kn->value.ul / FSCALE;
  
    if (nelem >= 2)
***************
*** 600,604 ****
        if (kn != 0)
  	{
! 	  loadavg[elem++] = (double) kn->value.ul/FSCALE;
  
  	  if (nelem >= 3)
--- 553,557 ----
        if (kn != 0)
  	{
! 	  loadavg[elem++] = (double) kn->value.ul / FSCALE;
  
  	  if (nelem >= 3)
***************
*** 606,610 ****
  	      kn = kstat_data_lookup (ksp, "avenrun_15min");
  	      if (kn != 0)
! 		loadavg[elem++] = (double) kn->value.ul/FSCALE;
  	    }
  	}
--- 559,563 ----
  	      kn = kstat_data_lookup (ksp, "avenrun_15min");
  	      if (kn != 0)
! 		loadavg[elem++] = (double) kn->value.ul / FSCALE;
  	    }
  	}
***************
*** 871,876 ****
      loadavg[elem]
        = (load_ave.tl_lscale == 0
!        ? load_ave.tl_avenrun.d[elem]
!        : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
  # endif /* OSF_ALPHA */
  
--- 824,829 ----
      loadavg[elem]
        = (load_ave.tl_lscale == 0
! 	 ? load_ave.tl_avenrun.d[elem]
! 	 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
  # endif /* OSF_ALPHA */
  
***************
*** 915,919 ****
  # endif /* VMS */
  
! # if !defined (LDAV_DONE) && defined(LOAD_AVE_TYPE) && !defined(VMS)
  
    /* UNIX-specific code -- read the average from /dev/kmem.  */
--- 868,872 ----
  # endif /* VMS */
  
! # if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) && !defined (VMS)
  
    /* UNIX-specific code -- read the average from /dev/kmem.  */
***************
*** 931,941 ****
        strcpy (nl[1].n_name, "");
  #   else /* NLIST_STRUCT */
! #    ifdef NLIST_NAME_UNION
        nl[0].n_un.n_name = LDAV_SYMBOL;
        nl[1].n_un.n_name = 0;
! #    else /* not NLIST_NAME_UNION */
        nl[0].n_name = LDAV_SYMBOL;
        nl[1].n_name = 0;
! #    endif /* not NLIST_NAME_UNION */
  #   endif /* NLIST_STRUCT */
  
--- 884,894 ----
        strcpy (nl[1].n_name, "");
  #   else /* NLIST_STRUCT */
! #    ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
        nl[0].n_un.n_name = LDAV_SYMBOL;
        nl[1].n_un.n_name = 0;
! #    else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
        nl[0].n_name = LDAV_SYMBOL;
        nl[1].n_name = 0;
! #    endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
  #   endif /* NLIST_STRUCT */
  
***************
*** 974,983 ****
  	  /* Set the channel to close on exec, so it does not
  	     litter any child's descriptor table.  */
! #   ifdef FD_SETFD
! #    ifndef FD_CLOEXEC
! #     define FD_CLOEXEC 1
! #    endif
! 	  (void) fcntl (channel, F_SETFD, FD_CLOEXEC);
! #   endif
  	  getloadavg_initialized = 1;
  	}
--- 927,931 ----
  	  /* Set the channel to close on exec, so it does not
  	     litter any child's descriptor table.  */
! 	  set_cloexec_flag (channel, true);
  	  getloadavg_initialized = 1;
  	}
***************
*** 1011,1017 ****
        if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
  	  != sizeof (load_ave))
!         {
!           kvm_close (kd);
!           getloadavg_initialized = 0;
  	}
  #  endif /* SUNOS_5 */
--- 959,965 ----
        if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
  	  != sizeof (load_ave))
! 	{
! 	  kvm_close (kd);
! 	  getloadavg_initialized = 0;
  	}
  #  endif /* SUNOS_5 */
***************
*** 1047,1053 ****
  #ifdef TEST
  void
! main (argc, argv)
!      int argc;
!      char **argv;
  {
    int naptime = 0;
--- 995,999 ----
  #ifdef TEST
  void
! main (int argc, char **argv)
  {
    int naptime = 0;

Index: getopt.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/getopt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** getopt.c	10 Feb 2003 23:32:40 -0000	1.1
--- getopt.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 3,24 ****
     "Keep this file name-space clean" means, talk to drepper at gnu.org
     before changing it!
!    Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002
!    	Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
!    The GNU C Library is free software; you can redistribute it and/or
!    modify it under the terms of the GNU Lesser General Public
!    License as published by the Free Software Foundation; either
!    version 2.1 of the License, or (at your option) any later version.
  
!    The GNU C Library 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
!    Lesser General Public License for more details.
  
!    You should have received a copy of the GNU Lesser General Public
!    License along with the GNU C Library; if not, write to the Free
!    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
!    02111-1307 USA.  */
  
  /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
--- 3,26 ----
     "Keep this file name-space clean" means, talk to drepper at gnu.org
     before changing it!
! 
!    Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
!    1996, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
!    Inc.
! 
     This file is part of the GNU C Library.
  
!    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.  */
  
  /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
***************
*** 32,43 ****
  #endif
  
- #if !defined __STDC__ || !__STDC__
- /* This is a separate conditional since some stdc systems
-    reject `defined (const)'.  */
- # ifndef const
- #  define const
- # endif
- #endif
- 
  #include <stdio.h>
  
--- 34,37 ----
***************
*** 70,93 ****
  #endif	/* GNU C library.  */
  
  #ifdef VMS
  # include <unixlib.h>
- # if HAVE_STRING_H - 0
- #  include <string.h>
- # endif
  #endif
  
! #ifndef _
  /* This is for other GNU distributions with internationalized messages.  */
! # if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
! #  include <libintl.h>
! #  ifndef _
! #   define _(msgid)	gettext (msgid)
! #  endif
! # else
! #  define _(msgid)	(msgid)
! # endif
! # if defined _LIBC && defined USE_IN_LIBIO
! #  include <wchar.h>
! # endif
  #endif
  
--- 64,83 ----
  #endif	/* GNU C library.  */
  
+ #include <string.h>
+ 
  #ifdef VMS
  # include <unixlib.h>
  #endif
  
! #ifdef _LIBC
! # include <libintl.h>
! #else
  /* This is for other GNU distributions with internationalized messages.  */
! # include "gettext.h"
! #endif
! #define _(msgid) gettext (msgid)
! 
! #if defined _LIBC && defined USE_IN_LIBIO
! # include <wchar.h>
  #endif
  
***************
*** 198,215 ****
  static char *posixly_correct;
  
! #ifdef	__GNU_LIBRARY__
! /* We want to avoid inclusion of string.h with non-GNU libraries
!    because there are many ways it can cause trouble.
!    On some systems, it contains special magic macros that don't work
!    in GCC.  */
! # include <string.h>
! # define my_index	strchr
! #else
! 
! # if HAVE_STRING_H
! #  include <string.h>
! # else
! #  include <strings.h>
! # endif
  
  /* Avoid depending on library functions or files
--- 188,192 ----
  static char *posixly_correct;
  
! #ifndef	__GNU_LIBRARY__
  
  /* Avoid depending on library functions or files
***************
*** 220,249 ****
  #endif
  
- static char *
- my_index (str, chr)
-      const char *str;
-      int chr;
- {
-   while (*str)
-     {
-       if (*str == chr)
- 	return (char *) str;
-       str++;
-     }
-   return 0;
- }
- 
- /* If using GCC, we can safely declare strlen this way.
-    If not using GCC, it is ok not to declare it.  */
- #ifdef __GNUC__
- /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
-    That was relevant to code that was here before.  */
- # if (!defined __STDC__ || !__STDC__) && !defined strlen
- /* gcc with -traditional declares the built-in strlen to return int,
-    and has done so at least since version 2.4.5. -- rms.  */
- extern int strlen (const char *);
- # endif /* not __STDC__ */
- #endif /* __GNUC__ */
- 
  #endif /* not __GNU_LIBRARY__ */
  
--- 197,200 ----
***************
*** 299,309 ****
     the new indices of the non-options in ARGV after they are moved.  */
  
- #if defined __STDC__ && __STDC__
- static void exchange (char **);
- #endif
- 
  static void
! exchange (argv)
!      char **argv;
  {
    int bottom = first_nonopt;
--- 250,255 ----
     the new indices of the non-options in ARGV after they are moved.  */
  
  static void
! exchange (char **argv)
  {
    int bottom = first_nonopt;
***************
*** 385,396 ****
  /* Initialize the internal data when the first call is made.  */
  
- #if defined __STDC__ && __STDC__
- static const char *_getopt_initialize (int, char *const *, const char *);
- #endif
  static const char *
! _getopt_initialize (argc, argv, optstring)
!      int argc;
!      char *const *argv;
!      const char *optstring;
  {
    /* Start processing options with ARGV-element 1 (since ARGV-element 0
--- 331,336 ----
  /* Initialize the internal data when the first call is made.  */
  
  static const char *
! _getopt_initialize (int argc, char *const *argv, const char *optstring)
  {
    /* Start processing options with ARGV-element 1 (since ARGV-element 0
***************
*** 511,521 ****
  
  int
! _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
!      int argc;
!      char *const *argv;
!      const char *optstring;
!      const struct option *longopts;
!      int *longind;
!      int long_only;
  {
    int print_errors = opterr;
--- 451,457 ----
  
  int
! _getopt_internal (int argc, char *const *argv,
! 		  const char *optstring, const struct option *longopts,
! 		  int *longind, int long_only)
  {
    int print_errors = opterr;
***************
*** 642,646 ****
    if (longopts != NULL
        && (argv[optind][1] == '-'
! 	  || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
      {
        char *nameend;
--- 578,583 ----
    if (longopts != NULL
        && (argv[optind][1] == '-'
! 	  || (long_only
! 	      && (argv[optind][2] || !strchr (optstring, argv[optind][1])))))
      {
        char *nameend;
***************
*** 827,831 ****
  	 Otherwise interpret it as a short option.  */
        if (!long_only || argv[optind][1] == '-'
! 	  || my_index (optstring, *nextchar) == NULL)
  	{
  	  if (print_errors)
--- 764,768 ----
  	 Otherwise interpret it as a short option.  */
        if (!long_only || argv[optind][1] == '-'
! 	  || strchr (optstring, *nextchar) == NULL)
  	{
  	  if (print_errors)
***************
*** 882,886 ****
    {
      char c = *nextchar++;
!     char *temp = my_index (optstring, c);
  
      /* Increment `optind' when we start to process its last character.  */
--- 819,823 ----
    {
      char c = *nextchar++;
!     char *temp = strchr (optstring, c);
  
      /* Increment `optind' when we start to process its last character.  */
***************
*** 1192,1199 ****
  
  int
! getopt (argc, argv, optstring)
!      int argc;
!      char *const *argv;
!      const char *optstring;
  {
    return _getopt_internal (argc, argv, optstring,
--- 1129,1133 ----
  
  int
! getopt (int argc, char *const *argv, const char *optstring)
  {
    return _getopt_internal (argc, argv, optstring,
***************
*** 1211,1217 ****
  
  int
! main (argc, argv)
!      int argc;
!      char **argv;
  {
    int c;
--- 1145,1149 ----
  
  int
! main (int argc, char **argv)
  {
    int c;

Index: getopt.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/getopt.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** getopt.h	10 Feb 2003 23:32:40 -0000	1.1
--- getopt.h	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,20 ****
  /* Declarations for getopt.
!    Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
!    The GNU C Library is free software; you can redistribute it and/or
!    modify it under the terms of the GNU Lesser General Public
!    License as published by the Free Software Foundation; either
!    version 2.1 of the License, or (at your option) any later version.
  
!    The GNU C Library 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
!    Lesser General Public License for more details.
  
!    You should have received a copy of the GNU Lesser General Public
!    License along with the GNU C Library; if not, write to the Free
!    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
!    02111-1307 USA.  */
  
  #ifndef _GETOPT_H
--- 1,22 ----
  /* Declarations for getopt.
! 
!    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998,
!    1999, 2001, 2003 Free Software Foundation, Inc.
! 
     This file is part of the GNU C Library.
  
!    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.  */
  
  #ifndef _GETOPT_H
***************
*** 79,83 ****
     no_argument		(or 0) if the option does not take an argument,
     required_argument	(or 1) if the option requires an argument,
!    optional_argument 	(or 2) if the option takes an optional argument.
  
     If the field `flag' is not NULL, it points to a variable that is set
--- 81,85 ----
     no_argument		(or 0) if the option does not take an argument,
     required_argument	(or 1) if the option requires an argument,
!    optional_argument	(or 2) if the option takes an optional argument.
  
     If the field `flag' is not NULL, it points to a variable that is set
***************
*** 94,102 ****
  struct option
  {
- # if (defined __STDC__ && __STDC__) || defined __cplusplus
    const char *name;
- # else
-   char *name;
- # endif
    /* has_arg can't be an enum because some compilers complain about
       type mismatches in all the code that assumes it is an int.  */
--- 96,100 ----
***************
*** 138,152 ****
     `getopt'.  */
  
! #if (defined __STDC__ && __STDC__) || defined __cplusplus
! # ifdef __GNU_LIBRARY__
  /* Many other libraries have conflicting prototypes for getopt, with
     differences in the consts, in stdlib.h.  To avoid compilation
     errors, only prototype getopt for the GNU C library.  */
  extern int getopt (int ___argc, char *const *___argv, const char *__shortopts);
! # else /* not __GNU_LIBRARY__ */
  extern int getopt ();
! # endif /* __GNU_LIBRARY__ */
  
! # ifndef __need_getopt
  extern int getopt_long (int ___argc, char *const *___argv,
  			const char *__shortopts,
--- 136,149 ----
     `getopt'.  */
  
! #ifdef __GNU_LIBRARY__
  /* Many other libraries have conflicting prototypes for getopt, with
     differences in the consts, in stdlib.h.  To avoid compilation
     errors, only prototype getopt for the GNU C library.  */
  extern int getopt (int ___argc, char *const *___argv, const char *__shortopts);
! #else /* not __GNU_LIBRARY__ */
  extern int getopt ();
! #endif /* __GNU_LIBRARY__ */
  
! #ifndef __need_getopt
  extern int getopt_long (int ___argc, char *const *___argv,
  			const char *__shortopts,
***************
*** 161,174 ****
  		             const struct option *__longopts, int *__longind,
  			     int __long_only);
! # endif
! #else /* not __STDC__ */
! extern int getopt ();
! # ifndef __need_getopt
! extern int getopt_long ();
! extern int getopt_long_only ();
! 
! extern int _getopt_internal ();
! # endif
! #endif /* __STDC__ */
  
  #ifdef	__cplusplus
--- 158,162 ----
  		             const struct option *__longopts, int *__longind,
  			     int __long_only);
! #endif
  
  #ifdef	__cplusplus

Index: getopt1.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/getopt1.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** getopt1.c	10 Feb 2003 23:32:40 -0000	1.1
--- getopt1.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,21 ****
  /* getopt_long and getopt_long_only entry points for GNU getopt.
!    Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
!      Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
!    The GNU C Library is free software; you can redistribute it and/or
!    modify it under the terms of the GNU Lesser General Public
!    License as published by the Free Software Foundation; either
!    version 2.1 of the License, or (at your option) any later version.
  
!    The GNU C Library 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
!    Lesser General Public License for more details.
  
!    You should have received a copy of the GNU Lesser General Public
!    License along with the GNU C Library; if not, write to the Free
!    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
!    02111-1307 USA.  */
  
  #ifdef HAVE_CONFIG_H
--- 1,22 ----
  /* getopt_long and getopt_long_only entry points for GNU getopt.
! 
!    Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996,
!    1997, 1998, 2003 Free Software Foundation, Inc.
! 
     This file is part of the GNU C Library.
  
!    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.  */
  
  #ifdef HAVE_CONFIG_H
***************
*** 29,40 ****
  #endif
  
- #if !defined __STDC__ || !__STDC__
- /* This is a separate conditional since some stdc systems
-    reject `defined (const)'.  */
- #ifndef const
- #define const
- #endif
- #endif
- 
  #include <stdio.h>
  
--- 30,33 ----
***************
*** 69,78 ****
  
  int
! getopt_long (argc, argv, options, long_options, opt_index)
!      int argc;
!      char *const *argv;
!      const char *options;
!      const struct option *long_options;
!      int *opt_index;
  {
    return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
--- 62,70 ----
  
  int
! getopt_long (int argc,
! 	     char *const *argv,
! 	     const char *options,
! 	     const struct option *long_options,
! 	     int *opt_index)
  {
    return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
***************
*** 85,94 ****
  
  int
! getopt_long_only (argc, argv, options, long_options, opt_index)
!      int argc;
!      char *const *argv;
!      const char *options;
!      const struct option *long_options;
!      int *opt_index;
  {
    return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
--- 77,85 ----
  
  int
! getopt_long_only (int argc,
! 		  char *const *argv,
! 		  const char *options,
! 		  const struct option *long_options,
! 		  int *opt_index)
  {
    return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
***************
*** 107,113 ****
  
  int
! main (argc, argv)
!      int argc;
!      char **argv;
  {
    int c;
--- 98,102 ----
  
  int
! main (int argc, char **argv)
  {
    int c;

Index: gettext.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/gettext.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** gettext.h	26 Jul 2003 04:17:17 -0000	1.1
--- gettext.h	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 2,19 ****
     Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
  
!    This program is free software; you can redistribute it and/or modify it
!    under the terms of the GNU Library 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
!    Library General Public License for more details.
  
!    You should have received a copy of the GNU Library 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.  */
  
  #ifndef _LIBGETTEXT_H
--- 2,18 ----
     Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
  
!    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.  */
  
  #ifndef _LIBGETTEXT_H

Index: ls-mntd-fs.m4
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/ls-mntd-fs.m4,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ls-mntd-fs.m4	24 Mar 2003 01:18:15 -0000	1.4
--- ls-mntd-fs.m4	12 Nov 2004 00:49:51 -0000	1.5
***************
*** 1,3 ****
! #serial 12
  
  dnl From Jim Meyering.
--- 1,3 ----
! #serial 14
  
  dnl From Jim Meyering.
***************
*** 11,15 ****
    [
  AC_CHECK_FUNCS(listmntent getmntinfo)
! AC_CHECK_HEADERS(mntent.h sys/param.h sys/ucred.h sys/mount.h sys/fs_types.h)
      getfsstat_includes="\
  $ac_includes_default
--- 11,21 ----
    [
  AC_CHECK_FUNCS(listmntent getmntinfo)
! AC_CHECK_HEADERS_ONCE(sys/param.h)
! 
! # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
! # NGROUPS (as the array dimension for a struct member) without a definition.
! AC_CHECK_HEADERS(sys/ucred.h, [], [], [#include <grp.h>])
! 
! AC_CHECK_HEADERS(mntent.h sys/mount.h sys/fs_types.h)
      getfsstat_includes="\
  $ac_includes_default
***************
*** 18,21 ****
--- 24,28 ----
  #endif
  #if HAVE_SYS_UCRED_H
+ # include <grp.h> /* needed for definition of NGROUPS */
  # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
  #endif
***************
*** 64,68 ****
      AC_DEFINE(MOUNTED_LISTMNTENT, 1,
        [Define if there is a function named listmntent that can be used to
!    list all mounted filesystems. (UNICOS)])
    fi
  fi
--- 71,75 ----
      AC_DEFINE(MOUNTED_LISTMNTENT, 1,
        [Define if there is a function named listmntent that can be used to
!        list all mounted filesystems. (UNICOS)])
    fi
  fi
***************
*** 80,85 ****
      AC_DEFINE(MOUNTED_VMOUNT, 1,
  	[Define if there is a function named mntctl that can be used to read
!    the list of mounted filesystems, and there is a system header file
!    that declares `struct vmount.'  (AIX)])
    fi
  fi
--- 87,92 ----
      AC_DEFINE(MOUNTED_VMOUNT, 1,
  	[Define if there is a function named mntctl that can be used to read
!          the list of mounted filesystems, and there is a system header file
!          that declares `struct vmount.'  (AIX)])
    fi
  fi
***************
*** 118,124 ****
        ac_list_mounted_fs=found
        AC_DEFINE(MOUNTED_GETMNTENT1, 1,
!   [Define if there is a function named getmntent for reading the list
!    of mounted filesystems, and that function takes a single argument.
!    (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
      fi
    fi
--- 125,131 ----
        ac_list_mounted_fs=found
        AC_DEFINE(MOUNTED_GETMNTENT1, 1,
!         [Define if there is a function named getmntent for reading the list
!          of mounted filesystems, and that function takes a single argument.
!          (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
      fi
    fi
***************
*** 135,140 ****
        ac_list_mounted_fs=found
        AC_DEFINE(MOUNTED_GETMNTENT2, 1,
!   [Define if there is a function named getmntent for reading the list of
!    mounted filesystems, and that function takes two arguments.  (SVR4)])
      fi
    fi
--- 142,147 ----
        ac_list_mounted_fs=found
        AC_DEFINE(MOUNTED_GETMNTENT2, 1,
!         [Define if there is a function named getmntent for reading the list of
!          mounted filesystems, and that function takes two arguments.  (SVR4)])
      fi
    fi
***************
*** 167,171 ****
      AC_DEFINE(MOUNTED_GETFSSTAT, 1,
  	      [Define if there is a function named getfsstat for reading the
!    list of mounted filesystems.  (DEC Alpha running OSF/1)])
    fi
  fi
--- 174,178 ----
      AC_DEFINE(MOUNTED_GETFSSTAT, 1,
  	      [Define if there is a function named getfsstat for reading the
!                list of mounted filesystems.  (DEC Alpha running OSF/1)])
    fi
  fi
***************
*** 185,191 ****
      ac_list_mounted_fs=found
      AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
! [Define if (like SVR2) there is no specific function for reading the
!    list of mounted filesystems, and your system has these header files:
!    <sys/fstyp.h> and <sys/statfs.h>.  (SVR3)])
    fi
  fi
--- 192,198 ----
      ac_list_mounted_fs=found
      AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
!       [Define if (like SVR2) there is no specific function for reading the
!        list of mounted filesystems, and your system has these header files:
!        <sys/fstyp.h> and <sys/statfs.h>.  (SVR3)])
    fi
  fi
***************
*** 205,209 ****
      AC_DEFINE(MOUNTED_GETMNTINFO, 1,
  	      [Define if there is a function named getmntinfo for reading the
!    list of mounted filesystems.  (4.4BSD, Darwin)])
    fi
  fi
--- 212,216 ----
      AC_DEFINE(MOUNTED_GETMNTINFO, 1,
  	      [Define if there is a function named getmntinfo for reading the
!                list of mounted filesystems.  (4.4BSD, Darwin)])
    fi
  fi
***************
*** 223,227 ****
      AC_DEFINE(MOUNTED_GETMNT, 1,
        [Define if there is a function named getmnt for reading the list of
!    mounted filesystems.  (Ultrix)])
    fi
  fi
--- 230,234 ----
      AC_DEFINE(MOUNTED_GETMNT, 1,
        [Define if there is a function named getmnt for reading the list of
!        mounted filesystems.  (Ultrix)])
    fi
  fi
***************
*** 244,248 ****
      AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
        [Define if there are functions named next_dev and fs_stat_dev for
!    reading the list of mounted filesystems.  (BeOS)])
    fi
  fi
--- 251,255 ----
      AC_DEFINE(MOUNTED_FS_STAT_DEV, 1,
        [Define if there are functions named next_dev and fs_stat_dev for
!        reading the list of mounted filesystems.  (BeOS)])
    fi
  fi
***************
*** 260,264 ****
      AC_DEFINE(MOUNTED_FREAD, 1,
  	      [Define if there is no specific function for reading the list of
!    mounted filesystems.  fread will be used to read /etc/mnttab.  (SVR2) ])
    fi
  fi
--- 267,272 ----
      AC_DEFINE(MOUNTED_FREAD, 1,
  	      [Define if there is no specific function for reading the list of
!                mounted filesystems.  fread will be used to read /etc/mnttab.
!                (SVR2) ])
    fi
  fi

Index: malloc.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/malloc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** malloc.c	17 Sep 2003 16:31:38 -0000	1.1
--- malloc.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 23,34 ****
  #undef malloc
  
! #include <sys/types.h>
! 
! char *malloc ();
  
  /* Allocate an N-byte block of memory from the heap.
     If N is zero, allocate a 1-byte block.  */
  
! char *
  rpl_malloc (size_t n)
  {
--- 23,32 ----
  #undef malloc
  
! #include <stdlib.h>
  
  /* Allocate an N-byte block of memory from the heap.
     If N is zero, allocate a 1-byte block.  */
  
! void *
  rpl_malloc (size_t n)
  {

Index: mountlist.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/mountlist.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** mountlist.c	20 Oct 2003 14:03:17 -0000	1.3
--- mountlist.c	12 Nov 2004 00:49:51 -0000	1.4
***************
*** 1,4 ****
  /* mountlist.c -- return a list of mounted filesystems
!    Copyright (C) 1991, 1992, 1997-2000 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,4 ----
  /* mountlist.c -- return a list of mounted filesystems
!    Copyright (C) 1991, 1992, 1997-2004 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 16,34 ****
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
! #include "config.h"
  
  #include <stdio.h>
  #include <sys/types.h>
! #include "mountlist.h"
  
! #ifdef STDC_HEADERS
! # include <stdlib.h>
! #else
! void free ();
! #endif
! #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
! # include <string.h>
! #else
! # include <strings.h>
  #endif
  
--- 16,32 ----
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
! #if HAVE_CONFIG_H
! # include <config.h>
! #endif
  
  #include <stdio.h>
  #include <sys/types.h>
! #include <stdlib.h>
! #include <string.h>
  
! #include "xalloc.h"
! 
! #ifndef SIZE_MAX
! # define SIZE_MAX ((size_t) -1)
  #endif
  
***************
*** 36,42 ****
  char *strstr ();
  #endif
- /* char *xmalloc (); */
- /* char *realloc (); */
- /* char *xstrdup (); */
  
  #include <errno.h>
--- 34,37 ----
***************
*** 57,72 ****
  #endif
  
! #if defined (MOUNTED_GETFSSTAT)	/* __alpha running OSF_1 */
! # include <sys/mount.h>
! # include <sys/fs_types.h>
  #endif /* MOUNTED_GETFSSTAT */
  
  #ifdef MOUNTED_GETMNTENT1	/* 4.3BSD, SunOS, HP-UX, Dynix, Irix.  */
  # include <mntent.h>
! # if !defined(MOUNTED)
! #  if defined(MNT_MNTTAB)	/* HP-UX.  */
  #   define MOUNTED MNT_MNTTAB
  #  endif
! #  if defined(MNTTABNAME)	/* Dynix.  */
  #   define MOUNTED MNTTABNAME
  #  endif
--- 52,84 ----
  #endif
  
! #if defined MOUNTED_GETFSSTAT	/* OSF_1 and Darwin1.3.x */
! # if HAVE_SYS_UCRED_H
! #  include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS,
! 		      NGROUPS is used as an array dimension in ucred.h */
! #  include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
! # endif
! # if HAVE_SYS_MOUNT_H
! #  include <sys/mount.h>
! # endif
! # if HAVE_SYS_FS_TYPES_H
! #  include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
! # endif
! # if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
! #  define FS_TYPE(Ent) ((Ent).f_fstypename)
! # else
! #  define FS_TYPE(Ent) mnt_names[(Ent).f_type]
! # endif
  #endif /* MOUNTED_GETFSSTAT */
  
  #ifdef MOUNTED_GETMNTENT1	/* 4.3BSD, SunOS, HP-UX, Dynix, Irix.  */
  # include <mntent.h>
! # if !defined MOUNTED
! #  if defined _PATH_MOUNTED	/* GNU libc  */
! #   define MOUNTED _PATH_MOUNTED
! #  endif
! #  if defined MNT_MNTTAB	/* HP-UX.  */
  #   define MOUNTED MNT_MNTTAB
  #  endif
! #  if defined MNTTABNAME	/* Dynix.  */
  #   define MOUNTED MNTTABNAME
  #  endif
***************
*** 122,126 ****
  #endif
  
! #if defined (MNTOPT_IGNORE) && defined (HAVE_HASMNTOPT)
  # define MNT_IGNORE(M) hasmntopt ((M), MNTOPT_IGNORE)
  #else
--- 134,139 ----
  #endif
  
! #undef MNT_IGNORE
! #if defined MNTOPT_IGNORE && defined HAVE_HASMNTOPT
  # define MNT_IGNORE(M) hasmntopt ((M), MNTOPT_IGNORE)
  #else
***************
*** 128,131 ****
--- 141,147 ----
  #endif
  
+ #include "mountlist.h"
+ #include "unlocked-io.h"
+ 
  #ifdef MOUNTED_GETMNTENT1	/* 4.3BSD, SunOS, HP-UX, Dynix, Irix.  */
  /* Return the value of the hexadecimal number represented by CP.
***************
*** 304,315 ****
         */
  
!     if(listmntent(&mntlist, KMTAB, NULL, NULL) < 0)
        return NULL;
      for (p = mntlist; p; p = p->next) {
        mnt = p->ment;
!       me = (struct mount_entry*) malloc(sizeof (struct mount_entry));
!       me->me_devname = strdup(mnt->mnt_fsname);
!       me->me_mountdir = strdup(mnt->mnt_dir);
!       me->me_type = strdup(mnt->mnt_type);
        me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
        me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
--- 320,332 ----
         */
  
!     if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0)
        return NULL;
      for (p = mntlist; p; p = p->next) {
        mnt = p->ment;
!       me = xmalloc (sizeof *me);
!       me->me_devname = xstrdup (mnt->mnt_fsname);
!       me->me_mountdir = xstrdup (mnt->mnt_dir);
!       me->me_type = xstrdup (mnt->mnt_type);
!       me->me_type_malloced = 1;
        me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
        me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
***************
*** 318,322 ****
        mtail = &me->me_next;
      }
!     freemntlist(mntlist);
    }
  #endif
--- 335,339 ----
        mtail = &me->me_next;
      }
!     freemntlist (mntlist);
    }
  #endif
***************
*** 335,342 ****
      while ((mnt = getmntent (fp)))
        {
! 	me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
! 	me->me_devname = strdup (mnt->mnt_fsname);
! 	me->me_mountdir = strdup (mnt->mnt_dir);
! 	me->me_type = strdup (mnt->mnt_type);
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
--- 352,360 ----
      while ((mnt = getmntent (fp)))
        {
! 	me = xmalloc (sizeof *me);
! 	me->me_devname = xstrdup (mnt->mnt_fsname);
! 	me->me_mountdir = xstrdup (mnt->mnt_dir);
! 	me->me_type = xstrdup (mnt->mnt_type);
! 	me->me_type_malloced = 1;
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
***************
*** 374,381 ****
  	char *fs_type = fsp_to_string (fsp);
  
! 	me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
! 	me->me_devname = strdup (fsp->f_mntfromname);
! 	me->me_mountdir = strdup (fsp->f_mntonname);
  	me->me_type = fs_type;
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
--- 392,400 ----
  	char *fs_type = fsp_to_string (fsp);
  
! 	me = xmalloc (sizeof *me);
! 	me->me_devname = xstrdup (fsp->f_mntfromname);
! 	me->me_mountdir = xstrdup (fsp->f_mntonname);
  	me->me_type = fs_type;
+ 	me->me_type_malloced = 0;
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
***************
*** 399,406 ****
  			      (char *) 0)))
        {
! 	me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
! 	me->me_devname = strdup (fsd.fd_req.devname);
! 	me->me_mountdir = strdup (fsd.fd_req.path);
  	me->me_type = gt_names[fsd.fd_req.fstype];
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
--- 418,426 ----
  			      (char *) 0)))
        {
! 	me = xmalloc (sizeof *me);
! 	me->me_devname = xstrdup (fsd.fd_req.devname);
! 	me->me_mountdir = xstrdup (fsd.fd_req.path);
  	me->me_type = gt_names[fsd.fd_req.fstype];
+ 	me->me_type_malloced = 0;
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
***************
*** 416,420 ****
  #endif /* MOUNTED_GETMNT. */
  
! #if defined (MOUNTED_FS_STAT_DEV) /* BeOS */
    {
      /* The next_dev() and fs_stat_dev() system calls give the list of
--- 436,440 ----
  #endif /* MOUNTED_GETMNT. */
  
! #if defined MOUNTED_FS_STAT_DEV /* BeOS */
    {
      /* The next_dev() and fs_stat_dev() system calls give the list of
***************
*** 459,466 ****
  
              if (strcmp (d->d_name, ".") == 0)
!               name = strdup ("/");
              else
                {
!                 name = malloc (1 + strlen (d->d_name) + 1);
                  name[0] = '/';
                  strcpy (name + 1, d->d_name);
--- 479,486 ----
  
              if (strcmp (d->d_name, ".") == 0)
!               name = xstrdup ("/");
              else
                {
!                 name = xmalloc (1 + strlen (d->d_name) + 1);
                  name[0] = '/';
                  strcpy (name + 1, d->d_name);
***************
*** 469,475 ****
              if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
                {
!                 struct rootdir_entry *re;
! 
!                 re = (struct rootdir_entry *) malloc (sizeof (struct rootdir_entry));
                  re->name = name;
                  re->dev = statbuf.st_dev;
--- 489,493 ----
              if (lstat (name, &statbuf) >= 0 && S_ISDIR (statbuf.st_mode))
                {
! 		struct rootdir_entry *re = xmalloc (sizeof *re);
                  re->name = name;
                  re->dev = statbuf.st_dev;
***************
*** 497,504 ****
                break;
  
!           me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
!           me->me_devname = strdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
!           me->me_mountdir = strdup (re != NULL ? re->name : fi.fsh_name);
!           me->me_type = strdup (fi.fsh_name);
            me->me_dev = fi.dev;
            me->me_dummy = 0;
--- 515,523 ----
                break;
  
! 	  me = xmalloc (sizeof *me);
!           me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
!           me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
!           me->me_type = xstrdup (fi.fsh_name);
! 	  me->me_type_malloced = 1;
            me->me_dev = fi.dev;
            me->me_dummy = 0;
***************
*** 521,536 ****
  #endif /* MOUNTED_FS_STAT_DEV */
  
! #if defined (MOUNTED_GETFSSTAT)	/* __alpha running OSF_1 */
    {
!     int numsys, counter, bufsize;
      struct statfs *stats;
  
!     numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
      if (numsys < 0)
        return (NULL);
  
!     bufsize = (1 + numsys) * sizeof (struct statfs);
!     stats = (struct statfs *)malloc (bufsize);
!     numsys = getfsstat (stats, bufsize, MNT_WAIT);
  
      if (numsys < 0)
--- 540,558 ----
  #endif /* MOUNTED_FS_STAT_DEV */
  
! #if defined MOUNTED_GETFSSTAT	/* __alpha running OSF_1 */
    {
!     int numsys, counter;
!     size_t bufsize;
      struct statfs *stats;
  
!     numsys = getfsstat ((struct statfs *)0, 0L, MNT_NOWAIT);
      if (numsys < 0)
        return (NULL);
+     if (SIZE_MAX / sizeof *stats <= numsys)
+       xalloc_die ();
  
!     bufsize = (1 + numsys) * sizeof *stats;
!     stats = xmalloc (bufsize);
!     numsys = getfsstat (stats, bufsize, MNT_NOWAIT);
  
      if (numsys < 0)
***************
*** 542,549 ****
      for (counter = 0; counter < numsys; counter++)
        {
! 	me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
! 	me->me_devname = strdup (stats[counter].f_mntfromname);
! 	me->me_mountdir = strdup (stats[counter].f_mntonname);
! 	me->me_type = mnt_names[stats[counter].f_type];
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
--- 564,572 ----
      for (counter = 0; counter < numsys; counter++)
        {
! 	me = xmalloc (sizeof *me);
! 	me->me_devname = xstrdup (stats[counter].f_mntfromname);
! 	me->me_mountdir = xstrdup (stats[counter].f_mntonname);
! 	me->me_type = xstrdup (FS_TYPE (stats[counter]));
! 	me->me_type_malloced = 1;
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
***************
*** 559,563 ****
  #endif /* MOUNTED_GETFSSTAT */
  
! #if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23].  */
    {
      struct mnttab mnt;
--- 582,586 ----
  #endif /* MOUNTED_GETFSSTAT */
  
! #if defined MOUNTED_FREAD || defined MOUNTED_FREAD_FSTYP /* SVR[23].  */
    {
      struct mnttab mnt;
***************
*** 571,585 ****
      while (fread (&mnt, sizeof mnt, 1, fp) > 0)
        {
! 	me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
  # ifdef GETFSTYP			/* SVR3.  */
! 	me->me_devname = strdup (mnt.mt_dev);
  # else
! 	me->me_devname = malloc (strlen (mnt.mt_dev) + 6);
  	strcpy (me->me_devname, "/dev/");
  	strcpy (me->me_devname + 5, mnt.mt_dev);
  # endif
! 	me->me_mountdir = strdup (mnt.mt_filsys);
  	me->me_dev = (dev_t) -1;	/* Magic; means not known yet. */
  	me->me_type = "";
  # ifdef GETFSTYP			/* SVR3.  */
  	if (need_fs_type)
--- 594,609 ----
      while (fread (&mnt, sizeof mnt, 1, fp) > 0)
        {
! 	me = xmalloc (sizeof *me);
  # ifdef GETFSTYP			/* SVR3.  */
! 	me->me_devname = xstrdup (mnt.mt_dev);
  # else
! 	me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
  	strcpy (me->me_devname, "/dev/");
  	strcpy (me->me_devname + 5, mnt.mt_dev);
  # endif
! 	me->me_mountdir = xstrdup (mnt.mt_filsys);
  	me->me_dev = (dev_t) -1;	/* Magic; means not known yet. */
  	me->me_type = "";
+ 	me->me_type_malloced = 0;
  # ifdef GETFSTYP			/* SVR3.  */
  	if (need_fs_type)
***************
*** 590,594 ****
  	    if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
  		&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
! 	      me->me_type = strdup (typebuf);
  	  }
  # endif
--- 614,621 ----
  	    if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
  		&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
! 	      {
! 		me->me_type = xstrdup (typebuf);
! 		me->me_type_malloced = 1;
! 	      }
  	  }
  # endif
***************
*** 603,606 ****
--- 630,634 ----
      if (ferror (fp))
        {
+ 	/* The last fread() call must have failed.  */
  	int saved_errno = errno;
  	fclose (fp);
***************
*** 616,626 ****
  #ifdef MOUNTED_GETMNTTBL	/* DolphinOS goes it's own way */
    {
!     struct mntent **mnttbl=getmnttbl(),**ent;
      for (ent=mnttbl;*ent;ent++)
        {
! 	me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
! 	me->me_devname = strdup ( (*ent)->mt_resource);
! 	me->me_mountdir = strdup( (*ent)->mt_directory);
! 	me->me_type =  strdup ((*ent)->mt_fstype);
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
--- 644,655 ----
  #ifdef MOUNTED_GETMNTTBL	/* DolphinOS goes it's own way */
    {
!     struct mntent **mnttbl = getmnttbl (), **ent;
      for (ent=mnttbl;*ent;ent++)
        {
! 	me = xmalloc (sizeof *me);
! 	me->me_devname = xstrdup ( (*ent)->mt_resource);
! 	me->me_mountdir = xstrdup ( (*ent)->mt_directory);
! 	me->me_type = xstrdup ((*ent)->mt_fstype);
! 	me->me_type_malloced = 1;
  	me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
  	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
***************
*** 631,635 ****
  	mtail = &me->me_next;
        }
!     endmnttbl();
    }
  #endif
--- 660,664 ----
  	mtail = &me->me_next;
        }
!     endmnttbl ();
    }
  #endif
***************
*** 680,687 ****
  	while ((ret = getmntent (fp, &mnt)) == 0)
  	  {
! 	    me = (struct mount_entry *) malloc (sizeof (struct mount_entry));
! 	    me->me_devname = strdup (mnt.mnt_special);
! 	    me->me_mountdir = strdup (mnt.mnt_mountp);
! 	    me->me_type = strdup (mnt.mnt_fstype);
  	    me->me_dummy = MNT_IGNORE (&mnt) != 0;
  	    me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
--- 709,717 ----
  	while ((ret = getmntent (fp, &mnt)) == 0)
  	  {
! 	    me = xmalloc (sizeof *me);
! 	    me->me_devname = xstrdup (mnt.mnt_special);
! 	    me->me_mountdir = xstrdup (mnt.mnt_mountp);
! 	    me->me_type = xstrdup (mnt.mnt_fstype);
! 	    me->me_type_malloced = 1;
  	    me->me_dummy = MNT_IGNORE (&mnt) != 0;
  	    me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
***************
*** 712,730 ****
      char *entries, *thisent;
      struct vmount *vmp;
  
      /* Ask how many bytes to allocate for the mounted filesystem info.  */
!     mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize);
!     entries = malloc (bufsize);
  
      /* Get the list of mounted filesystems.  */
!     mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
  
!     for (thisent = entries; thisent < entries + bufsize;
! 	 thisent += vmp->vmt_length)
        {
  	char *options, *ignore;
  
  	vmp = (struct vmount *) thisent;
! 	me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry));
  	if (vmp->vmt_flags & MNT_REMOTE)
  	  {
--- 742,771 ----
      char *entries, *thisent;
      struct vmount *vmp;
+     int n_entries;
+     int i;
  
      /* Ask how many bytes to allocate for the mounted filesystem info.  */
!     if (mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize) != 0)
!       return NULL;
!     entries = xmalloc (bufsize);
  
      /* Get the list of mounted filesystems.  */
!     n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
!     if (n_entries < 0)
!       {
! 	int saved_errno = errno;
! 	free (entries);
! 	errno = saved_errno;
! 	return NULL;
!       }
  
!     for (i = 0, thisent = entries;
! 	 i < n_entries;
! 	 i++, thisent += vmp->vmt_length)
        {
  	char *options, *ignore;
  
  	vmp = (struct vmount *) thisent;
! 	me = xmalloc (sizeof *me);
  	if (vmp->vmt_flags & MNT_REMOTE)
  	  {
***************
*** 735,739 ****
  	    host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
  	    path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
! 	    me->me_devname = malloc (strlen (host) + strlen (path) + 2);
  	    strcpy (me->me_devname, host);
  	    strcat (me->me_devname, ":");
--- 776,780 ----
  	    host = thisent + vmp->vmt_data[VMT_HOSTNAME].vmt_off;
  	    path = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
! 	    me->me_devname = xmalloc (strlen (host) + strlen (path) + 2);
  	    strcpy (me->me_devname, host);
  	    strcat (me->me_devname, ":");
***************
*** 743,751 ****
  	  {
  	    me->me_remote = 0;
! 	    me->me_devname = strdup (thisent +
  				      vmp->vmt_data[VMT_OBJECT].vmt_off);
  	  }
! 	me->me_mountdir = strdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
! 	me->me_type = strdup (fstype_to_string (vmp->vmt_gfstype));
  	options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
  	ignore = strstr (options, "ignore");
--- 784,793 ----
  	  {
  	    me->me_remote = 0;
! 	    me->me_devname = xstrdup (thisent +
  				      vmp->vmt_data[VMT_OBJECT].vmt_off);
  	  }
! 	me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
! 	me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
! 	me->me_type_malloced = 1;
  	options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
  	ignore = strstr (options, "ignore");
***************
*** 778,782 ****
  	free (mount_list->me_devname);
  	free (mount_list->me_mountdir);
! 	/* FIXME: me_type is not always malloced.  */
  	free (mount_list);
  	mount_list = me;
--- 820,825 ----
  	free (mount_list->me_devname);
  	free (mount_list->me_mountdir);
! 	if (mount_list->me_type_malloced)
! 	  free (mount_list->me_type);
  	free (mount_list);
  	mount_list = me;

Index: mountlist.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/mountlist.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** mountlist.h	18 Mar 2003 07:47:37 -0000	1.1
--- mountlist.h	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,4 ****
  /* mountlist.h -- declarations for list of mounted filesystems
!    Copyright (C) 1991, 1992, 1998, 2000 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,6 ----
  /* mountlist.h -- declarations for list of mounted filesystems
! 
!    Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003 Free
!    Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 25,50 ****
    unsigned int me_dummy : 1;	/* Nonzero for dummy filesystems. */
    unsigned int me_remote : 1;	/* Nonzero for remote fileystems. */
    struct mount_entry *me_next;
  };
  
! #ifndef PARAMS
! # if defined PROTOTYPES || (defined __STDC__ && __STDC__)
! #  define PARAMS(Args) Args
! # else
! #  define PARAMS(Args) ()
! # endif
! #endif
! 
! struct mount_entry *read_filesystem_list PARAMS ((int need_fs_type));
  
  #ifndef ME_DUMMY
! # define ME_DUMMY(fs_name, fs_type) \
!     (!strcmp (fs_type, "auto") \
!      || !strcmp (fs_type, "autofs") \
       /* for Irix 6.5 */ \
!      || !strcmp (fs_type, "ignore"))
  #endif
  
  #ifndef ME_REMOTE
! # define ME_REMOTE(fs_name, fs_type) (strchr (fs_name, ':') != 0)
  #endif
--- 27,53 ----
    unsigned int me_dummy : 1;	/* Nonzero for dummy filesystems. */
    unsigned int me_remote : 1;	/* Nonzero for remote fileystems. */
+   unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
    struct mount_entry *me_next;
  };
  
! struct mount_entry *read_filesystem_list (int need_fs_type);
  
  #ifndef ME_DUMMY
! # define ME_DUMMY(Fs_name, Fs_type) \
!     (!strcmp (Fs_type, "autofs") \
       /* for Irix 6.5 */ \
!      || !strcmp (Fs_type, "ignore"))
  #endif
  
+ #undef STREQ
+ #define STREQ(a, b) (strcmp ((a), (b)) == 0)
+ 
  #ifndef ME_REMOTE
! /* A file system is `remote' if its Fs_name contains a `:'
!    or if (it is of type smbfs and its Fs_name starts with `//').  */
! # define ME_REMOTE(Fs_name, Fs_type)	\
!     (strchr ((Fs_name), ':') != 0	\
!      || ((Fs_name)[0] == '/'		\
! 	 && (Fs_name)[1] == '/'		\
! 	 && STREQ (Fs_type, "smbfs")))
  #endif

Index: realloc.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/realloc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** realloc.c	17 Sep 2003 16:31:38 -0000	1.1
--- realloc.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,4 ****
  /* Work around bug on some systems where realloc (NULL, 0) fails.
!    Copyright (C) 1997 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,4 ----
  /* Work around bug on some systems where realloc (NULL, 0) fails.
!    Copyright (C) 1997, 2003 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 23,30 ****
  #undef realloc
  
! #include <sys/types.h>
! 
! char *malloc ();
! char *realloc ();
  
  /* Change the size of an allocated block of memory P to N bytes,
--- 23,27 ----
  #undef realloc
  
! #include <stdlib.h>
  
  /* Change the size of an allocated block of memory P to N bytes,
***************
*** 32,39 ****
     use malloc.  */
  
! char *
! rpl_realloc (p, n)
!      char *p;
!      size_t n;
  {
    if (n == 0)
--- 29,34 ----
     use malloc.  */
  
! void *
! rpl_realloc (void *p, size_t n)
  {
    if (n == 0)

Index: snprintf.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/snprintf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** snprintf.c	8 Mar 2003 01:59:30 -0000	1.1
--- snprintf.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,3 ****
--- 1,7 ----
  /*
+  * NOTE: If you change this file, please merge it into rsync, samba, etc.
+  */
+ 
+ /*
   * Copyright Patrick Powell 1995
   * This code is based on code written by Patrick Powell (papowell at astart.com)
***************
*** 54,68 ****
   *    added C99 semantics
   *
   **************************************************************/
  
! #ifndef NO_CONFIG_H /* for some tests */
  #include "config.h"
  #else
  #define NULL 0
! #endif
  
  #ifdef TEST_SNPRINTF /* need math library headers for testing */
! #include <math.h>
! #endif
  
  #ifdef HAVE_STRING_H
--- 58,112 ----
   *    added C99 semantics
   *
+  * date: 2002/12/19 19:56:31;  author: herb;  state: Exp;  lines: +2 -0
+  * actually print args for %g and %e
+  * 
+  * date: 2002/06/03 13:37:52;  author: jmcd;  state: Exp;  lines: +8 -0
+  * Since includes.h isn't included here, VA_COPY has to be defined here.  I don't
+  * see any include file that is guaranteed to be here, so I'm defining it
+  * locally.  Fixes AIX and Solaris builds.
+  * 
+  * date: 2002/06/03 03:07:24;  author: tridge;  state: Exp;  lines: +5 -13
+  * put the ifdef for HAVE_VA_COPY in one place rather than in lots of
+  * functions
+  * 
+  * date: 2002/05/17 14:51:22;  author: jmcd;  state: Exp;  lines: +21 -4
+  * Fix usage of va_list passed as an arg.  Use __va_copy before using it
+  * when it exists.
+  * 
+  * date: 2002/04/16 22:38:04;  author: idra;  state: Exp;  lines: +20 -14
+  * Fix incorrect zpadlen handling in fmtfp.
+  * Thanks to Ollie Oldham <ollie.oldham at metro-optix.com> for spotting it.
+  * few mods to make it easier to compile the tests.
+  * addedd the "Ollie" test to the floating point ones.
+  *
+  * Martin Pool (mbp at samba.org) April 2003
+  *    Remove NO_CONFIG_H so that the test case can be built within a source
+  *    tree with less trouble.
+  *    Remove unnecessary SAFE_FREE() definition.
+  *
+  * Martin Pool (mbp at samba.org) May 2003
+  *    Put in a prototype for dummy_snprintf() to quiet compiler warnings.
+  *
+  *    Move #endif to make sure VA_COPY, LDOUBLE, etc are defined even
+  *    if the C library has some snprintf functions already.
   **************************************************************/
  
! #ifndef NO_CONFIG_H
  #include "config.h"
  #else
  #define NULL 0
! #endif 
  
  #ifdef TEST_SNPRINTF /* need math library headers for testing */
! 
! /* In test mode, we pretend that this system doesn't have any snprintf
!  * functions, regardless of what config.h says. */
! #  undef HAVE_SNPRINTF
! #  undef HAVE_VSNPRINTF
! #  undef HAVE_C99_VSNPRINTF
! #  undef HAVE_ASPRINTF
! #  undef HAVE_VASPRINTF
! #  include <math.h>
! #endif /* TEST_SNPRINTF */
  
  #ifdef HAVE_STRING_H
***************
*** 76,85 ****
  #include <ctype.h>
  #endif
- #ifdef HAVE_SYS_TYPES_H
  #include <sys/types.h>
- #endif
- #ifdef HAVE_STDARG_H
  #include <stdarg.h>
- #endif
  #ifdef HAVE_STDLIB_H
  #include <stdlib.h>
--- 120,125 ----
***************
*** 90,95 ****
  #include <stdio.h>
   /* make the compiler happy with an empty file */
   void dummy_snprintf(void) {} 
! #else
  
  #ifdef HAVE_LONG_DOUBLE
--- 130,136 ----
  #include <stdio.h>
   /* make the compiler happy with an empty file */
+  void dummy_snprintf(void);
   void dummy_snprintf(void) {} 
! #endif /* HAVE_SNPRINTF, etc */
  
  #ifdef HAVE_LONG_DOUBLE
***************
*** 105,115 ****
  #endif
  
- /* free memory if the pointer is valid and zero the pointer */
- #ifndef SAFE_FREE
- #define SAFE_FREE(x) do { if ((x) != NULL) {free((x)); (x)=NULL;} } while(0)
- #endif
- 
  #ifndef VA_COPY
  #ifdef HAVE_VA_COPY
  #define VA_COPY(dest, src) __va_copy(dest, src)
  #else
--- 146,154 ----
  #endif
  
  #ifndef VA_COPY
  #ifdef HAVE_VA_COPY
+ #define VA_COPY(dest, src) va_copy(dest, src)
+ #else
+ #ifdef HAVE___VA_COPY
  #define VA_COPY(dest, src) __va_copy(dest, src)
  #else
***************
*** 118,131 ****
  #endif
  
- static size_t dopr(char *buffer, size_t maxlen, const char *format, 
- 		   va_list args_in);
- static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
- 		    char *value, int flags, int min, int max);
- static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
- 		    long value, int base, int min, int max, int flags);
- static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
- 		   LDOUBLE fvalue, int min, int max, int flags);
- static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
- 
  /*
   * dopr(): poor man's version of doprintf
--- 157,160 ----
***************
*** 162,165 ****
--- 191,207 ----
  #endif
  
+ /* yes this really must be a ||. Don't muck with this (tridge) */
+ #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+ 
+ static size_t dopr(char *buffer, size_t maxlen, const char *format, 
+ 		   va_list args_in);
+ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+ 		    char *value, int flags, int min, int max);
+ static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+ 		    long value, int base, int min, int max, int flags);
+ static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
+ 		   LDOUBLE fvalue, int min, int max, int flags);
+ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
+ 
  static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
  {
***************
*** 346,349 ****
--- 388,392 ----
  				else
  					fvalue = va_arg (args, double);
+ 				fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
  				break;
  			case 'G':
***************
*** 354,357 ****
--- 397,401 ----
  				else
  					fvalue = va_arg (args, double);
+ 				fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
  				break;
  			case 'c':
***************
*** 626,630 ****
  	int zpadlen = 0; 
  	int caps = 0;
! 	int index;
  	double intpart;
  	double fracpart;
--- 670,674 ----
  	int zpadlen = 0; 
  	int caps = 0;
! 	int idx;
  	double intpart;
  	double fracpart;
***************
*** 685,693 ****
  		temp = intpart*0.1;
  		my_modf(temp, &intpart);
! 		index = (int) ((temp -intpart +0.05)* 10.0);
! 		/* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
! 		/* printf ("%llf, %f, %x\n", temp, intpart, index); */
  		iconvert[iplace++] =
! 			(caps? "0123456789ABCDEF":"0123456789abcdef")[index];
  	} while (intpart && (iplace < 311));
  	if (iplace == 311) iplace--;
--- 729,737 ----
  		temp = intpart*0.1;
  		my_modf(temp, &intpart);
! 		idx = (int) ((temp -intpart +0.05)* 10.0);
! 		/* idx = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
! 		/* printf ("%llf, %f, %x\n", temp, intpart, idx); */
  		iconvert[iplace++] =
! 			(caps? "0123456789ABCDEF":"0123456789abcdef")[idx];
  	} while (intpart && (iplace < 311));
  	if (iplace == 311) iplace--;
***************
*** 700,708 ****
  			temp = fracpart*0.1;
  			my_modf(temp, &fracpart);
! 			index = (int) ((temp -fracpart +0.05)* 10.0);
! 			/* index = (int) ((((temp/10) -fracpart) +0.05) *10); */
! 			/* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */
  			fconvert[fplace++] =
! 			(caps? "0123456789ABCDEF":"0123456789abcdef")[index];
  		} while(fracpart && (fplace < 311));
  		if (fplace == 311) fplace--;
--- 744,752 ----
  			temp = fracpart*0.1;
  			my_modf(temp, &fracpart);
! 			idx = (int) ((temp -fracpart +0.05)* 10.0);
! 			/* idx = (int) ((((temp/10) -fracpart) +0.05) *10); */
! 			/* printf ("%lf, %lf, %ld\n", temp, fracpart, idx ); */
  			fconvert[fplace++] =
! 			(caps? "0123456789ABCDEF":"0123456789abcdef")[idx];
  		} while(fracpart && (fplace < 311));
  		if (fplace == 311) fplace--;
***************
*** 774,795 ****
  }
  
! /* yes this really must be a ||. Don't muck with this (tridge) */
! #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
!  int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
  {
  	return dopr(str, count, fmt, args);
  }
  #endif
  
! /* yes this really must be a ||. Don't muck wiith this (tridge)
   *
   * The logic for these two is that we need our own definition if the
   * OS *either* has no definition of *sprintf, or if it does have one
!  * that doesn't work properly according to the autoconf test.  Perhaps
!  * these should really be smb_snprintf to avoid conflicts with buggy
!  * linkers? -- mbp
   */
! #if !defined(HAVE_SNPRINTF) /* || !defined(HAVE_C99_SNPRINTF) */
!  int snprintf(char *str,size_t count,const char *fmt,...)
  {
  	size_t ret;
--- 818,836 ----
  }
  
!  int smb_vsnprintf (char *str, size_t count, const char *fmt, va_list args)
  {
  	return dopr(str, count, fmt, args);
  }
+ #define vsnprintf smb_vsnprintf
  #endif
  
! /* yes this really must be a ||. Don't muck with this (tridge)
   *
   * The logic for these two is that we need our own definition if the
   * OS *either* has no definition of *sprintf, or if it does have one
!  * that doesn't work properly according to the autoconf test.
   */
! #if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
! int smb_snprintf(char *str,size_t count,const char *fmt,...)
  {
  	size_t ret;
***************
*** 801,804 ****
--- 842,846 ----
  	return ret;
  }
+ #define snprintf smb_snprintf
  #endif
  
***************
*** 869,874 ****
  		NULL
  	};
! 	double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, 
! 			     0.9996, 1.996, 4.136, 5.030201, 0};
  	char *int_fmt[] = {
  		"%-1.5d",
--- 911,917 ----
  		NULL
  	};
! 	double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 203.9, 0.96, 0.996, 
! 			     0.9996, 1.996, 4.136, 5.030201, 0.00205,
! 			     /* END LIST */ 0};
  	char *int_fmt[] = {
  		"%-1.5d",
***************
*** 978,980 ****
  	return 0;
  }
! #endif /* SNPRINTF_TEST */
--- 1021,1023 ----
  	return 0;
  }
! #endif /* TEST_SNPRINTF */

Index: strtod.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/strtod.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** strtod.c	17 Sep 2003 16:33:17 -0000	1.1
--- strtod.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,3 ****
! /* Copyright (C) 1991, 1992, 1997, 1999 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,3 ----
! /* Copyright (C) 1991, 1992, 1997, 1999, 2003 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 38,57 ****
  #include <math.h>
  
! #if HAVE_FLOAT_H
! # include <float.h>
! #else
! # define DBL_MAX 1.7976931348623159e+308
! # define DBL_MIN 2.2250738585072010e-308
! #endif
! 
! #if STDC_HEADERS
! # include <stdlib.h>
! # include <string.h>
! #else
! # define NULL 0
! # ifndef HUGE_VAL
! #  define HUGE_VAL HUGE
! # endif
! #endif
  
  /* Convert NPTR to a double.  If ENDPTR is not NULL, a pointer to the
--- 38,44 ----
  #include <math.h>
  
! #include <float.h>
! #include <stdlib.h>
! #include <string.h>
  
  /* Convert NPTR to a double.  If ENDPTR is not NULL, a pointer to the

Index: unlocked-io.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/unlocked-io.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** unlocked-io.h	17 Sep 2003 16:31:38 -0000	1.1
--- unlocked-io.h	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,20 ****
  /* Prefer faster, non-thread-safe stdio functions if available.
  
!    Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  
!    This program is free software; you can redistribute it and/or modify it
!    under the terms of the GNU Library 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
!    Library General Public License for more details.
  
!    You should have received a copy of the GNU Library 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.  */
  
  /* Written by Jim Meyering.  */
--- 1,19 ----
  /* Prefer faster, non-thread-safe stdio functions if available.
  
!    Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  
!    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.  */
  
  /* Written by Jim Meyering.  */
***************
*** 29,90 ****
  # if USE_UNLOCKED_IO
  
! /* These are wrappers for functions/macros from GNU libc.
     The standard I/O functions are thread-safe.  These *_unlocked ones are
     more efficient but not thread-safe.  That they're not thread-safe is
!    fine since all of the applications in this package are single threaded.  */
  
  #  if HAVE_DECL_CLEARERR_UNLOCKED
  #   undef clearerr
  #   define clearerr(x) clearerr_unlocked (x)
  #  endif
  #  if HAVE_DECL_FEOF_UNLOCKED
  #   undef feof
  #   define feof(x) feof_unlocked (x)
  #  endif
  #  if HAVE_DECL_FERROR_UNLOCKED
  #   undef ferror
  #   define ferror(x) ferror_unlocked (x)
  #  endif
  #  if HAVE_DECL_FFLUSH_UNLOCKED
  #   undef fflush
  #   define fflush(x) fflush_unlocked (x)
  #  endif
  #  if HAVE_DECL_FGETS_UNLOCKED
  #   undef fgets
  #   define fgets(x,y,z) fgets_unlocked (x,y,z)
  #  endif
  #  if HAVE_DECL_FPUTC_UNLOCKED
  #   undef fputc
  #   define fputc(x,y) fputc_unlocked (x,y)
  #  endif
  #  if HAVE_DECL_FPUTS_UNLOCKED
  #   undef fputs
  #   define fputs(x,y) fputs_unlocked (x,y)
  #  endif
  #  if HAVE_DECL_FREAD_UNLOCKED
  #   undef fread
  #   define fread(w,x,y,z) fread_unlocked (w,x,y,z)
  #  endif
  #  if HAVE_DECL_FWRITE_UNLOCKED
  #   undef fwrite
  #   define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
  #  endif
  #  if HAVE_DECL_GETC_UNLOCKED
  #   undef getc
  #   define getc(x) getc_unlocked (x)
  #  endif
  #  if HAVE_DECL_GETCHAR_UNLOCKED
  #   undef getchar
  #   define getchar() getchar_unlocked ()
  #  endif
  #  if HAVE_DECL_PUTC_UNLOCKED
  #   undef putc
  #   define putc(x,y) putc_unlocked (x,y)
  #  endif
  #  if HAVE_DECL_PUTCHAR_UNLOCKED
  #   undef putchar
  #   define putchar(x) putchar_unlocked (x)
  #  endif
  
  # endif /* USE_UNLOCKED_IO */
  #endif /* UNLOCKED_IO_H */
--- 28,132 ----
  # if USE_UNLOCKED_IO
  
! /* These are wrappers for functions/macros from the GNU C library, and
!    from other C libraries supporting POSIX's optional thread-safe functions.
! 
     The standard I/O functions are thread-safe.  These *_unlocked ones are
     more efficient but not thread-safe.  That they're not thread-safe is
!    fine since all of the applications in this package are single threaded.
! 
!    Also, some code that is shared with the GNU C library may invoke
!    the *_unlocked functions directly.  On hosts that lack those
!    functions, invoke the non-thread-safe versions instead.  */
! 
! #  include <stdio.h>
  
  #  if HAVE_DECL_CLEARERR_UNLOCKED
  #   undef clearerr
  #   define clearerr(x) clearerr_unlocked (x)
+ #  else
+ #   define clearerr_unlocked(x) clearerr (x)
  #  endif
  #  if HAVE_DECL_FEOF_UNLOCKED
  #   undef feof
  #   define feof(x) feof_unlocked (x)
+ #  else
+ #   define feof_unlocked(x) feof (x)
  #  endif
  #  if HAVE_DECL_FERROR_UNLOCKED
  #   undef ferror
  #   define ferror(x) ferror_unlocked (x)
+ #  else
+ #   define ferror_unlocked(x) ferror (x)
  #  endif
  #  if HAVE_DECL_FFLUSH_UNLOCKED
  #   undef fflush
  #   define fflush(x) fflush_unlocked (x)
+ #  else
+ #   define fflush_unlocked(x) fflush (x)
  #  endif
  #  if HAVE_DECL_FGETS_UNLOCKED
  #   undef fgets
  #   define fgets(x,y,z) fgets_unlocked (x,y,z)
+ #  else
+ #   define fgets_unlocked(x,y,z) fgets (x,y,z)
  #  endif
  #  if HAVE_DECL_FPUTC_UNLOCKED
  #   undef fputc
  #   define fputc(x,y) fputc_unlocked (x,y)
+ #  else
+ #   define fputc_unlocked(x,y) fputc (x,y)
  #  endif
  #  if HAVE_DECL_FPUTS_UNLOCKED
  #   undef fputs
  #   define fputs(x,y) fputs_unlocked (x,y)
+ #  else
+ #   define fputs_unlocked(x,y) fputs (x,y)
  #  endif
  #  if HAVE_DECL_FREAD_UNLOCKED
  #   undef fread
  #   define fread(w,x,y,z) fread_unlocked (w,x,y,z)
+ #  else
+ #   define fread_unlocked(w,x,y,z) fread (w,x,y,z)
  #  endif
  #  if HAVE_DECL_FWRITE_UNLOCKED
  #   undef fwrite
  #   define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
+ #  else
+ #   define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
  #  endif
  #  if HAVE_DECL_GETC_UNLOCKED
  #   undef getc
  #   define getc(x) getc_unlocked (x)
+ #  else
+ #   define getc_unlocked(x) getc (x)
  #  endif
  #  if HAVE_DECL_GETCHAR_UNLOCKED
  #   undef getchar
  #   define getchar() getchar_unlocked ()
+ #  else
+ #   define getchar_unlocked() getchar ()
  #  endif
  #  if HAVE_DECL_PUTC_UNLOCKED
  #   undef putc
  #   define putc(x,y) putc_unlocked (x,y)
+ #  else
+ #   define putc_unlocked(x,y) putc (x,y)
  #  endif
  #  if HAVE_DECL_PUTCHAR_UNLOCKED
  #   undef putchar
  #   define putchar(x) putchar_unlocked (x)
+ #  else
+ #   define putchar_unlocked(x) putchar (x)
  #  endif
  
+ #  undef flockfile
+ #  define flockfile(x) ((void) 0)
+ 
+ #  undef ftrylockfile
+ #  define ftrylockfile(x) 0
+ 
+ #  undef funlockfile
+ #  define funlockfile(x) ((void) 0)
+ 
  # endif /* USE_UNLOCKED_IO */
  #endif /* UNLOCKED_IO_H */

Index: xalloc.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/xalloc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** xalloc.h	17 Sep 2003 16:31:38 -0000	1.1
--- xalloc.h	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,4 ****
  /* xalloc.h -- malloc with out-of-memory checking
!    Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,6 ----
  /* xalloc.h -- malloc with out-of-memory checking
! 
!    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2003 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 19,29 ****
  # define XALLOC_H_
  
! # ifndef PARAMS
! #  if defined PROTOTYPES || (defined __STDC__ && __STDC__)
! #   define PARAMS(Args) Args
! #  else
! #   define PARAMS(Args) ()
! #  endif
! # endif
  
  # ifndef __attribute__
--- 21,25 ----
  # define XALLOC_H_
  
! # include <stddef.h>
  
  # ifndef __attribute__
***************
*** 37,48 ****
  # endif
  
- /* Exit value when the requested amount of memory is not available.
-    It is initialized to EXIT_FAILURE, but the caller may set it to
-    some other value.  */
- extern int xalloc_exit_failure;
- 
  /* If this pointer is non-zero, run the specified function upon each
     allocation failure.  It is initialized to zero. */
! extern void (*xalloc_fail_func) PARAMS ((void));
  
  /* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
--- 33,39 ----
  # endif
  
  /* If this pointer is non-zero, run the specified function upon each
     allocation failure.  It is initialized to zero. */
! extern void (*xalloc_fail_func) (void);
  
  /* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
***************
*** 52,87 ****
  
  /* This function is always triggered when memory is exhausted.  It is
!    in charge of honoring the three previous items.  This is the
     function to call when one wants the program to die because of a
     memory allocation failure.  */
! extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN;
! 
! void *xmalloc PARAMS ((size_t n));
! void *xcalloc PARAMS ((size_t n, size_t s));
! void *xrealloc PARAMS ((void *p, size_t n));
! char *xstrdup PARAMS ((const char *str));
! 
! # define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
! # define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
! # define XREALLOC(Ptr, Type, N_items) \
!   ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
! 
! /* Declare and alloc memory for VAR of type TYPE. */
! # define NEW(Type, Var)  Type *(Var) = XMALLOC (Type, 1)
! 
! /* Free VAR only if non NULL. */
! # define XFREE(Var)	\
!    do {                 \
!       if (Var)          \
!         free (Var);     \
!    } while (0)
! 
! /* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
! # define CCLONE(Src, Num) \
!   (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
! 
! /* Return a malloc'ed copy of SRC. */
! # define CLONE(Src) CCLONE (Src, 1)
  
  
  #endif /* !XALLOC_H_ */
--- 43,87 ----
  
  /* This function is always triggered when memory is exhausted.  It is
!    in charge of honoring the two previous items.  It exits with status
!    exit_failure (defined in exitfail.h).  This is the
     function to call when one wants the program to die because of a
     memory allocation failure.  */
! extern void xalloc_die (void) ATTRIBUTE_NORETURN;
  
+ void *xmalloc (size_t s);
+ void *xnmalloc (size_t n, size_t s);
+ void *xzalloc (size_t s);
+ void *xcalloc (size_t n, size_t s);
+ void *xrealloc (void *p, size_t s);
+ void *xnrealloc (void *p, size_t n, size_t s);
+ void *x2realloc (void *p, size_t *pn);
+ void *x2nrealloc (void *p, size_t *pn, size_t s);
+ void *xclone (void const *p, size_t s);
+ char *xstrdup (const char *str);
+ 
+ /* Return 1 if an array of N objects, each of size S, cannot exist due
+    to size arithmetic overflow.  S must be positive and N must be
+    nonnegative.  This is a macro, not an inline function, so that it
+    works correctly even when SIZE_MAX < N.
+ 
+    By gnulib convention, SIZE_MAX represents overflow in size
+    calculations, so the conservative dividend to use here is
+    SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
+    However, malloc (SIZE_MAX) fails on all known hosts where
+    sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
+    exactly-SIZE_MAX allocations on such hosts; this avoids a test and
+    branch when S is known to be 1.  */
+ # define xalloc_oversized(n, s) \
+     ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
+ 
+ /* These macros are deprecated; they will go away soon, and are retained
+    temporarily only to ease conversion to the functions described above.  */
+ # define CCLONE(p, n) xclone (p, (n) * sizeof *(p))
+ # define CLONE(p) xclone (p, sizeof *(p))
+ # define NEW(type, var) type *var = xmalloc (sizeof (type))
+ # define XCALLOC(type, n) xcalloc (n, sizeof (type))
+ # define XMALLOC(type, n) xnmalloc (n, sizeof (type))
+ # define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type))
+ # define XFREE(p) free (p)
  
  #endif /* !XALLOC_H_ */

Index: xmalloc.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/xmalloc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** xmalloc.c	17 Sep 2003 16:31:38 -0000	1.1
--- xmalloc.c	12 Nov 2004 00:49:51 -0000	1.2
***************
*** 1,4 ****
  /* xmalloc.c -- malloc with out of memory checking
!    Copyright (C) 1990-1999, 2000, 2002 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
--- 1,6 ----
  /* xmalloc.c -- malloc with out of memory checking
! 
!    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2003,
!    1999, 2000, 2002, 2003 Free Software Foundation, Inc.
  
     This program is free software; you can redistribute it and/or modify
***************
*** 20,33 ****
  #endif
  
! #include <sys/types.h>
  
! #if STDC_HEADERS
! # include <stdlib.h>
! #else
! void *calloc ();
! void *malloc ();
! void *realloc ();
! void free ();
! #endif
  
  #include "gettext.h"
--- 22,29 ----
  #endif
  
! #include "xalloc.h"
  
! #include <stdlib.h>
! #include <string.h>
  
  #include "gettext.h"
***************
*** 36,47 ****
  
  #include "error.h"
! #include "xalloc.h"
  
! #ifndef EXIT_FAILURE
! # define EXIT_FAILURE 1
  #endif
  
- /* The following tests require AC_PREREQ(2.54).  */
- 
  #ifndef HAVE_MALLOC
  "you must run the autoconf test for a GNU libc compatible malloc"
--- 32,41 ----
  
  #include "error.h"
! #include "exitfail.h"
  
! #ifndef SIZE_MAX
! # define SIZE_MAX ((size_t) -1)
  #endif
  
  #ifndef HAVE_MALLOC
  "you must run the autoconf test for a GNU libc compatible malloc"
***************
*** 52,61 ****
  #endif
  
- /* Exit value when the requested amount of memory is not available.
-    The caller may set it to some other value.  */
- int xalloc_exit_failure = EXIT_FAILURE;
- 
  /* If non NULL, call this function when memory is exhausted. */
! void (*xalloc_fail_func) PARAMS ((void)) = 0;
  
  /* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
--- 46,51 ----
  #endif
  
  /* If non NULL, call this function when memory is exhausted. */
! void (*xalloc_fail_func) (void) = 0;
  
  /* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
***************
*** 68,76 ****
    if (xalloc_fail_func)
      (*xalloc_fail_func) ();
!   error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
    /* The `noreturn' cannot be given to error, since it may return if
       its first argument is 0.  To help compilers understand the
!      xalloc_die does terminate, call exit. */
!   exit (EXIT_FAILURE);
  }
  
--- 58,84 ----
    if (xalloc_fail_func)
      (*xalloc_fail_func) ();
!   error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
    /* The `noreturn' cannot be given to error, since it may return if
       its first argument is 0.  To help compilers understand the
!      xalloc_die does terminate, call abort.  */
!   abort ();
! }
! 
! /* Allocate an array of N objects, each with S bytes of memory,
!    dynamically, with error checking.  S must be nonzero.  */
! 
! static inline void *
! xnmalloc_inline (size_t n, size_t s)
! {
!   void *p;
!   if (xalloc_oversized (n, s) || ! (p = malloc (n * s)))
!     xalloc_die ();
!   return p;
! }
! 
! void *
! xnmalloc (size_t n, size_t s)
! {
!   return xnmalloc_inline (n, s);
  }
  
***************
*** 80,91 ****
  xmalloc (size_t n)
  {
!   void *p;
  
!   p = malloc (n);
!   if (p == 0)
      xalloc_die ();
    return p;
  }
  
  /* Change the size of an allocated block of memory P to N bytes,
     with error checking.  */
--- 88,111 ----
  xmalloc (size_t n)
  {
!   return xnmalloc_inline (n, 1);
! }
! 
! /* Change the size of an allocated block of memory P to an array of N
!    objects each of S bytes, with error checking.  S must be nonzero.  */
  
! static inline void *
! xnrealloc_inline (void *p, size_t n, size_t s)
! {
!   if (xalloc_oversized (n, s) || ! (p = realloc (p, n * s)))
      xalloc_die ();
    return p;
  }
  
+ void *
+ xnrealloc (void *p, size_t n, size_t s)
+ {
+   return xnrealloc_inline (p, n, s);
+ }
+ 
  /* Change the size of an allocated block of memory P to N bytes,
     with error checking.  */
***************
*** 94,104 ****
  xrealloc (void *p, size_t n)
  {
!   p = realloc (p, n);
!   if (p == 0)
!     xalloc_die ();
!   return p;
  }
  
! /* Allocate memory for N elements of S bytes, with error checking.  */
  
  void *
--- 114,236 ----
  xrealloc (void *p, size_t n)
  {
!   return xnrealloc_inline (p, n, 1);
  }
  
! 
! /* If P is null, allocate a block of at least *PN such objects;
!    otherwise, reallocate P so that it contains more than *PN objects
!    each of S bytes.  *PN must be nonzero unless P is null, and S must
!    be nonzero.  Set *PN to the new number of objects, and return the
!    pointer to the new block.  *PN is never set to zero, and the
!    returned pointer is never null.
! 
!    Repeated reallocations are guaranteed to make progress, either by
!    allocating an initial block with a nonzero size, or by allocating a
!    larger block.
! 
!    In the following implementation, nonzero sizes are doubled so that
!    repeated reallocations have O(N log N) overall cost rather than
!    O(N**2) cost, but the specification for this function does not
!    guarantee that sizes are doubled.
! 
!    Here is an example of use:
! 
!      int *p = NULL;
!      size_t used = 0;
!      size_t allocated = 0;
! 
!      void
!      append_int (int value)
!        {
! 	 if (used == allocated)
! 	   p = x2nrealloc (p, &allocated, sizeof *p);
! 	 p[used++] = value;
!        }
! 
!    This causes x2nrealloc to allocate a block of some nonzero size the
!    first time it is called.
! 
!    To have finer-grained control over the initial size, set *PN to a
!    nonzero value before calling this function with P == NULL.  For
!    example:
! 
!      int *p = NULL;
!      size_t used = 0;
!      size_t allocated = 0;
!      size_t allocated1 = 1000;
! 
!      void
!      append_int (int value)
!        {
! 	 if (used == allocated)
! 	   {
! 	     p = x2nrealloc (p, &allocated1, sizeof *p);
! 	     allocated = allocated1;
! 	   }
! 	 p[used++] = value;
!        }
! 
!    */
! 
! static inline void *
! x2nrealloc_inline (void *p, size_t *pn, size_t s)
! {
!   size_t n = *pn;
! 
!   if (! p)
!     {
!       if (! n)
! 	{
! 	  /* The approximate size to use for initial small allocation
! 	     requests, when the invoking code specifies an old size of
! 	     zero.  64 bytes is the largest "small" request for the
! 	     GNU C library malloc.  */
! 	  enum { DEFAULT_MXFAST = 64 };
! 
! 	  n = DEFAULT_MXFAST / s;
! 	  n += !n;
! 	}
!     }
!   else
!     {
!       if (SIZE_MAX / 2 / s < n)
! 	xalloc_die ();
!       n *= 2;
!     }
! 
!   *pn = n;
!   return xrealloc (p, n * s);
! }
! 
! void *
! x2nrealloc (void *p, size_t *pn, size_t s)
! {
!   return x2nrealloc_inline (p, pn, s);
! }
! 
! /* If P is null, allocate a block of at least *PN bytes; otherwise,
!    reallocate P so that it contains more than *PN bytes.  *PN must be
!    nonzero unless P is null.  Set *PN to the new block's size, and
!    return the pointer to the new block.  *PN is never set to zero, and
!    the returned pointer is never null.  */
! 
! void *
! x2realloc (void *p, size_t *pn)
! {
!   return x2nrealloc_inline (p, pn, 1);
! }
! 
! /* Allocate S bytes of zeroed memory dynamically, with error checking.
!    There's no need for xnzalloc (N, S), since it would be equivalent
!    to xcalloc (N, S).  */
! 
! void *
! xzalloc (size_t s)
! {
!   return memset (xmalloc (s), 0, s);
! }
! 
! /* Allocate zeroed memory for N elements of S bytes, with error
!    checking.  S must be nonzero.  */
  
  void *
***************
*** 106,113 ****
  {
    void *p;
! 
!   p = calloc (n, s);
!   if (p == 0)
      xalloc_die ();
    return p;
  }
--- 238,255 ----
  {
    void *p;
!   /* Test for overflow, since some calloc implementations don't have
!      proper overflow checks.  */
!   if (xalloc_oversized (n, s) || ! (p = calloc (n, s)))
      xalloc_die ();
    return p;
  }
+ 
+ /* Clone an object P of size S, with error checking.  There's no need
+    for xnclone (P, N, S), since xclone (P, N * S) works without any
+    need for an arithmetic overflow check.  */
+ 
+ void *
+ xclone (void const *p, size_t s)
+ {
+   return memcpy (xmalloc (s), p, s);
+ }





More information about the Commits mailing list