[Nagiosplug-checkins] nagiosplug/lib getopt_.h,NONE,1.1 getopt_int.h,NONE,1.1 xalloc-die.c,NONE,1.1 Makefile.am,1.24,1.25 cloexec.c,1.1,1.2 cloexec.h,1.1,1.2 error.c,1.2,1.3 error.h,1.2,1.3 exit.h,1.1,1.2 exitfail.c,1.1,1.2 exitfail.h,1.1,1.2 fsusage.c,1.3,1.4 fsusage.h,1.2,1.3 full-read.c,1.1,1.2 full-read.h,1.1,1.2 full-write.c,1.1,1.2 full-write.h,1.1,1.2 getloadavg.c,1.2,1.3 getopt.c,1.2,1.3 getopt1.c,1.2,1.3 gettext.h,1.2,1.3 malloc.c,1.2,1.3 mountlist.c,1.4,1.5 mountlist.h,1.2,1.3 realloc.c,1.2,1.3 safe-read.c,1.1,1.2 safe-read.h,1.1,1.2 safe-write.c,1.1,1.2 safe-write.h,1.1,1.2 stdbool_.h,1.1,1.2 strtod.c,1.2,1.3 unlocked-io.h,1.2,1.3 xalloc.h,1.2,1.3 xmalloc.c,1.2,1.3 getopt.h,1.2,NONE

Ton Voon tonvoon at users.sourceforge.net
Thu May 18 15:06:04 CEST 2006


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

Modified Files:
	Makefile.am cloexec.c cloexec.h error.c error.h exit.h 
	exitfail.c exitfail.h fsusage.c fsusage.h full-read.c 
	full-read.h full-write.c full-write.h getloadavg.c getopt.c 
	getopt1.c gettext.h malloc.c mountlist.c mountlist.h realloc.c 
	safe-read.c safe-read.h safe-write.c safe-write.h stdbool_.h 
	strtod.c unlocked-io.h xalloc.h xmalloc.c 
Added Files:
	getopt_.h getopt_int.h xalloc-die.c 
Removed Files:
	getopt.h 
Log Message:
Synchronise with coreutils 2.95. Gettext now synced with coreutils,
so no longer development platform requirement


Index: Makefile.am
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/Makefile.am,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- Makefile.am	22 Dec 2004 07:24:17 -0000	1.24
+++ Makefile.am	18 May 2006 22:05:42 -0000	1.25
@@ -6,29 +6,28 @@
 libcoreutils_a_SOURCES = \
   cloexec.c cloexec.h \
   exit.h \
-  exitfail.c exitfail.h \
-  fsusage.h \
   full-read.c full-read.h \
   full-write.c full-write.h \
-  getopt.c getopt.h getopt1.c \
   gettext.h \
-  mountlist.h \
   safe-read.c safe-read.h \
-  safe-write.c safe-write.h \
-  unlocked-io.h \
-  xalloc.h \
-  xmalloc.c \
-  xstrdup.c
+  safe-write.c safe-write.h xalloc-die.c
 
 other_coreutils_files = \
   error.c error.h \
   fsusage.c \
-  getloadaavg.c \
+  getloadavg.c \
   malloc.c \
   mountlist.c \
   realloc.c \
-  stdbool_.h \
-  strtod.c
+  strtod.c \
+  exitfail.c exitfail.h \
+  fsusage.h \
+  getopt.c getopt1.c \
+  mountlist.h \
+  unlocked-io.h \
+  xalloc.h \
+  xmalloc.c
+
 
 libcoreutils_a_LIBADD = $(LIBOBJS)
 libcoreutils_a_DEPENDENCIES = $(libcoreutils_a_LIBADD)
@@ -37,6 +36,10 @@
 
 INCLUDES = -I$(srcdir) -I$(top_srcdir)/intl
 
+print_coreutil_files:
+	@echo $(libcoreutils_a_SOURCES) $(other_coreutils_files) $(EXTRA_DIST)
+
+# Below are from coreutil's lib/Makefile.am
 BUILT_SOURCES = $(STDBOOL_H)
 EXTRA_DIST = stdbool_.h
 MOSTLYCLEANFILES = stdbool.h stdbool.ht
@@ -45,3 +48,14 @@
 	sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' $(srcdir)/stdbool_.h > $@t
 	mv $@t $@
 
+BUILT_SOURCES += $(GETOPT_H)
+EXTRA_DIST += getopt_.h getopt_int.h
+
+# We need the following in order to create an <getopt.h> when the system
+# doesn't have one that works with the given compiler.
+all-local $(lib_OBJECTS): $(GETOPT_H)
+getopt.h: getopt_.h
+	cp $(srcdir)/getopt_.h $@-t 
+	mv $@-t $@ 
+MOSTLYCLEANFILES += getopt.h getopt.h-t
+

Index: mountlist.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/mountlist.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mountlist.h	12 Nov 2004 00:49:51 -0000	1.2
+++ mountlist.h	18 May 2006 22:05:42 -0000	1.3
@@ -1,7 +1,7 @@
-/* mountlist.h -- declarations for list of mounted filesystems
+/* mountlist.h -- declarations for list of mounted file systems
 
-   Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003 Free
-   Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 2003, 2004, 2005
+   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
@@ -15,39 +15,27 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef MOUNTLIST_H_
+# define MOUNTLIST_H_
+
+# include <stdbool.h>
+# include <sys/types.h>
 
 /* A mount table entry. */
 struct mount_entry
 {
-  char *me_devname;		/* Device node pathname, including "/dev/". */
-  char *me_mountdir;		/* Mount point directory pathname. */
+  char *me_devname;		/* Device node name, including "/dev/". */
+  char *me_mountdir;		/* Mount point directory name. */
   char *me_type;		/* "nfs", "4.2", etc. */
   dev_t me_dev;			/* Device number of me_mountdir. */
-  unsigned int me_dummy : 1;	/* Nonzero for dummy filesystems. */
+  unsigned int me_dummy : 1;	/* Nonzero for dummy file systems. */
   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)
+struct mount_entry *read_file_system_list (bool need_fs_type);
 
-#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: strtod.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/strtod.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- strtod.c	12 Nov 2004 00:49:51 -0000	1.2
+++ strtod.c	18 May 2006 22:05:42 -0000	1.3
@@ -12,9 +12,9 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 

Index: error.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/error.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- error.c	12 Nov 2004 00:49:51 -0000	1.2
+++ error.c	18 May 2006 22:05:42 -0000	1.3
@@ -1,5 +1,5 @@
 /* Error handler for noninteractive utilities
-   Copyright (C) 1990-1998, 2000-2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1990-1998, 2000-2003, 2004 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
@@ -14,7 +14,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /* Written by David MacKenzie <djm at gnu.ai.mit.edu>.  */
 
@@ -29,9 +29,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef _LIBC
-# include <libintl.h>
-#else
+#if !_LIBC && ENABLE_NLS
 # include "gettext.h"
 #endif
 
@@ -40,7 +38,7 @@
 # define mbsrtowcs __mbsrtowcs
 #endif
 
-#if !_LIBC
+#if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
 
@@ -106,7 +104,7 @@
 static void
 print_errno_message (int errnum)
 {
-  char const *s;
+  char const *s = NULL;
 
 #if defined HAVE_STRERROR_R || _LIBC
   char errbuf[1024];
@@ -115,15 +113,11 @@
 # else
   if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
     s = errbuf;
-  else
-    s = 0;
 # endif
-#else
-  s = strerror (errnum);
 #endif
 
 #if !_LIBC
-  if (! s)
+  if (! s && ! (s = strerror (errnum)))
     s = _("Unknown system error");
 #endif
 

Index: mountlist.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/mountlist.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mountlist.c	12 Nov 2004 00:49:51 -0000	1.4
+++ mountlist.c	18 May 2006 22:05:42 -0000	1.5
@@ -1,5 +1,7 @@
-/* mountlist.c -- return a list of mounted filesystems
-   Copyright (C) 1991, 1992, 1997-2004 Free Software Foundation, Inc.
+/* mountlist.c -- return a list of mounted file systems
+
+   Copyright (C) 1991, 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+   2004, 2005 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
@@ -13,39 +15,29 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
+#include "mountlist.h"
+
 #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
-
 #ifndef strstr
 char *strstr ();
 #endif
 
 #include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
 
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
+#include <fcntl.h>
 
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
 
 #if HAVE_SYS_PARAM_H
 # include <sys/param.h>
@@ -140,42 +132,39 @@
 # define MNT_IGNORE(M) 0
 #endif
 
-#include "mountlist.h"
-#include "unlocked-io.h"
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+#endif
 
-#ifdef MOUNTED_GETMNTENT1	/* 4.3BSD, SunOS, HP-UX, Dynix, Irix.  */
-/* Return the value of the hexadecimal number represented by CP.
-   No prefix (like '0x') or suffix (like 'h') is expected to be
-   part of CP. */
-/* FIXME: this can overflow */
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
 
-static int
-xatoi (char *cp)
-{
-  int val;
+#ifndef ME_DUMMY
+# define ME_DUMMY(Fs_name, Fs_type)		\
+    (strcmp (Fs_type, "autofs") == 0		\
+     || strcmp (Fs_type, "none") == 0		\
+     || strcmp (Fs_type, "proc") == 0		\
+     || strcmp (Fs_type, "subfs") == 0		\
+     /* for Irix 6.5 */				\
+     || strcmp (Fs_type, "ignore") == 0)
+#endif
 
-  val = 0;
-  while (*cp)
-    {
-      if (*cp >= 'a' && *cp <= 'f')
-	val = val * 16 + *cp - 'a' + 10;
-      else if (*cp >= 'A' && *cp <= 'F')
-	val = val * 16 + *cp - 'A' + 10;
-      else if (*cp >= '0' && *cp <= '9')
-	val = val * 16 + *cp - '0';
-      else
-	break;
-      cp++;
-    }
-  return val;
-}
-#endif /* MOUNTED_GETMNTENT1.  */
+#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] == '/'			\
+	 && strcmp (Fs_type, "smbfs") == 0))
+#endif
 
 #if MOUNTED_GETMNTINFO
 
 # if ! HAVE_F_FSTYPENAME_IN_STATFS
 static char *
-fstype_to_string (short t)
+fstype_to_string (short int t)
 {
   switch (t)
     {
@@ -296,13 +285,13 @@
 }
 #endif /* MOUNTED_VMOUNT */
 
-/* Return a list of the currently mounted filesystems, or NULL on error.
+/* Return a list of the currently mounted file systems, or NULL on error.
    Add each entry to the tail of the list so that they stay in order.
-   If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
+   If NEED_FS_TYPE is true, ensure that the file system type fields in
    the returned list are valid.  Otherwise, they might not be.  */
 
 struct mount_entry *
-read_filesystem_list (int need_fs_type)
+read_file_system_list (bool need_fs_type)
 {
   struct mount_entry *mount_list;
   struct mount_entry *me;
@@ -360,12 +349,7 @@
 	me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
 	devopt = strstr (mnt->mnt_opts, "dev=");
 	if (devopt)
-	  {
-	    if (devopt[4] == '0' && (devopt[5] == 'x' || devopt[5] == 'X'))
-	      me->me_dev = xatoi (devopt + 6);
-	    else
-	      me->me_dev = xatoi (devopt + 4);
-	  }
+	  me->me_dev = strtoul (devopt + 4, NULL, 16);
 	else
 	  me->me_dev = (dev_t) -1;	/* Magic; means not known yet. */
 
@@ -438,14 +422,14 @@
 #if defined MOUNTED_FS_STAT_DEV /* BeOS */
   {
     /* The next_dev() and fs_stat_dev() system calls give the list of
-       all filesystems, including the information returned by statvfs()
+       all file systems, including the information returned by statvfs()
        (fs type, total blocks, free blocks etc.), but without the mount
-       point. But on BeOS all filesystems except / are mounted in the
+       point. But on BeOS all file systems except / are mounted in the
        rootfs, directly under /.
        The directory name of the mount point is often, but not always,
        identical to the volume name of the device.
        We therefore get the list of subdirectories of /, and the list
-       of all filesystems, and match the two lists.  */
+       of all file systems, and match the two lists.  */
 
     DIR *dirp;
     struct rootdir_entry
@@ -744,12 +728,12 @@
     int n_entries;
     int i;
 
-    /* Ask how many bytes to allocate for the mounted filesystem info.  */
+    /* Ask how many bytes to allocate for the mounted file system info.  */
     if (mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize) != 0)
       return NULL;
     entries = xmalloc (bufsize);
 
-    /* Get the list of mounted filesystems.  */
+    /* Get the list of mounted file systems.  */
     n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries);
     if (n_entries < 0)
       {
@@ -769,16 +753,16 @@
 	me = xmalloc (sizeof *me);
 	if (vmp->vmt_flags & MNT_REMOTE)
 	  {
-	    char *host, *path;
+	    char *host, *dir;
 
 	    me->me_remote = 1;
-	    /* Prepend the remote pathname.  */
+	    /* Prepend the remote dirname.  */
 	    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);
+	    dir = thisent + vmp->vmt_data[VMT_OBJECT].vmt_off;
+	    me->me_devname = xmalloc (strlen (host) + strlen (dir) + 2);
 	    strcpy (me->me_devname, host);
 	    strcat (me->me_devname, ":");
-	    strcat (me->me_devname, path);
+	    strcat (me->me_devname, dir);
 	  }
 	else
 	  {

Index: full-write.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/full-write.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- full-write.c	15 Dec 2004 20:47:25 -0000	1.1
+++ full-write.c	18 May 2006 22:05:42 -0000	1.2
@@ -1,6 +1,7 @@
 /* An interface to read and write that retries (if necessary) until complete.
 
-   Copyright (C) 1993, 1994, 1997-2003 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+   2004 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
@@ -14,9 +15,9 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
@@ -28,9 +29,6 @@
 #endif
 
 #include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
 
 #ifdef FULL_READ
 # include "safe-read.h"

Index: xalloc.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/xalloc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- xalloc.h	12 Nov 2004 00:49:51 -0000	1.2
+++ xalloc.h	18 May 2006 22:05:42 -0000	1.3
@@ -1,7 +1,7 @@
 /* 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.
+   1999, 2000, 2003, 2004 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
@@ -15,13 +15,19 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef XALLOC_H_
 # define XALLOC_H_
 
 # include <stddef.h>
 
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+
 # ifndef __attribute__
 #  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
 #   define __attribute__(x)
@@ -32,18 +38,9 @@
 #  define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
 # 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
-   message is output.  It is translated via gettext.
-   Its value is "memory exhausted".  */
-extern char const xalloc_msg_memory_exhausted[];
-
-/* 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
+/* This function is always triggered when memory is exhausted.
+   It must be defined by the application, either explicitly
+   or by using gnulib's xalloc-die module.  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;
@@ -56,8 +53,8 @@
 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);
+void *xmemdup (void const *p, size_t s);
+char *xstrdup (char const *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
@@ -74,14 +71,9 @@
 # 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)
+# ifdef __cplusplus
+}
+# endif
+
 
 #endif /* !XALLOC_H_ */

Index: getloadavg.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/getloadavg.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- getloadavg.c	12 Nov 2004 00:49:51 -0000	1.2
+++ getloadavg.c	18 May 2006 22:05:42 -0000	1.3
@@ -1,7 +1,7 @@
 /* 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.
+   1995, 1997, 1999, 2000, 2003, 2004, 2005 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.
@@ -18,7 +18,7 @@
 
    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,
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    USA.  */
 
 /* Compile-time symbols that this file uses:
@@ -32,7 +32,7 @@
 				AC_CHECK_FUNCS(pstat_getdynamic) in your
 				configure.in file.
    FIXUP_KERNEL_SYMBOL_ADDR()	Adjust address in returned struct nlist.
-   KERNEL_FILE			Pathname of the kernel to nlist.
+   KERNEL_FILE			Name of the kernel file to nlist.
    LDAV_CVT()			Scale the load average from the kernel.
 				Returns a double.
    LDAV_SYMBOL			Name of kernel symbol giving load average.
@@ -47,9 +47,8 @@
 				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.
+   LINUX_LDAV_FILE		[__linux__, __CYGWIN__]: File containing
+				load averages.
 
    Specific system predefines this file uses, aside from setting
    default values if not emacs:
@@ -70,9 +69,10 @@
    UMAX4_3
    VMS
    WINDOWS32			No-op for Windows95/NT.
-   __linux__			Linux: assumes /proc filesystem mounted.
+   __linux__			Linux: assumes /proc file system mounted.
 				Support from Michael K. Johnson.
-   __NetBSD__			NetBSD: assumes /kern filesystem mounted.
+   __CYGWIN__			Cygwin emulates linux /proc/loadavg.
+   __NetBSD__			NetBSD: assumes /kern file system mounted.
 
    In addition, to avoid nesting many #ifdefs, we internally set
    LDAV_DONE to indicate that the load average has been computed.
@@ -85,38 +85,29 @@
 # include <config.h>
 #endif
 
-#include <sys/types.h>
-
-/* Both the Emacs and non-Emacs sections want this.  Some
-   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
-
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 /* Exclude all the code except the test program at the end
-   if the system has its own `getloadavg' function.
-
-   The declaration of `errno' is needed by the test program
-   as well as the function itself, so it comes first.  */
-
-#include <errno.h>
+   if the system has its own `getloadavg' function.  */
 
-#ifndef errno
-extern int errno;
-#endif
+#ifndef HAVE_GETLOADAVG
 
-#ifdef HAVE_LOCALE_H
-# include <locale.h>
-#endif
-#ifndef HAVE_SETLOCALE
-# define setlocale(Category, Locale) /* empty */
-#endif
+# include <sys/types.h>
 
-#include "cloexec.h"
+/* Both the Emacs and non-Emacs sections want this.  Some
+   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
 
-#ifndef HAVE_GETLOADAVG
+# include "c-strtod.h"
+# include "cloexec.h"
+# include "intprops.h"
+# include "xalloc.h"
 
 /* The existing Emacs configuration files define a macro called
    LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
@@ -357,11 +348,7 @@
 #  define LDAV_SYMBOL "avenrun"
 # endif
 
-# ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-# endif
-
-# include <stdio.h>
+# include <unistd.h>
 
 /* LOAD_AVE_TYPE should only get defined if we're going to use the
    nlist method.  */
@@ -435,7 +422,6 @@
 # endif /* sgi */
 
 # ifdef UMAX
-#  include <stdio.h>
 #  include <signal.h>
 #  include <sys/time.h>
 #  include <sys/wait.h>
@@ -461,17 +447,13 @@
 #  include <sys/dg_sys_info.h>
 # endif
 
-# if defined (HAVE_FCNTL_H) || defined (_POSIX_VERSION)
-#  include <fcntl.h>
-# else
-#  include <sys/file.h>
-# endif
+# include "fcntl--.h"
 
 /* Avoid static vars inside a function since in HPUX they dump as pure.  */
 
 # ifdef NeXT
 static processor_set_t default_set;
-static int getloadavg_initialized;
+static bool getloadavg_initialized;
 # endif /* NeXT */
 
 # ifdef UMAX
@@ -486,8 +468,8 @@
 # if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
 /* File descriptor open to /dev/kmem or VMS load ave driver.  */
 static int channel;
-/* Nonzero iff channel is valid.  */
-static int getloadavg_initialized;
+/* True iff channel is valid.  */
+static bool getloadavg_initialized;
 /* Offset in kmem to seek to read load average, or 0 means invalid.  */
 static long offset;
 
@@ -583,7 +565,7 @@
 
 # endif /* hpux && HAVE_PSTAT_GETDYNAMIC */
 
-# if !defined (LDAV_DONE) && defined (__linux__)
+# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__))
 #  define LDAV_DONE
 #  undef LOAD_AVE_TYPE
 
@@ -591,32 +573,36 @@
 #   define LINUX_LDAV_FILE "/proc/loadavg"
 #  endif
 
-  char ldavgbuf[40];
-  double load_ave[3];
+  char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
+  char const *ptr = ldavgbuf;
   int fd, count;
 
   fd = open (LINUX_LDAV_FILE, O_RDONLY);
   if (fd == -1)
     return -1;
-  count = read (fd, ldavgbuf, 40);
+  count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
   (void) close (fd);
   if (count <= 0)
     return -1;
+  ldavgbuf[count] = '\0';
 
-  /* The following sscanf must use the C locale.  */
-  setlocale (LC_NUMERIC, "C");
-  count = sscanf (ldavgbuf, "%lf %lf %lf",
-		  &load_ave[0], &load_ave[1], &load_ave[2]);
-  setlocale (LC_NUMERIC, "");
-  if (count < 1)
-    return -1;
-
-  for (elem = 0; elem < nelem && elem < count; elem++)
-    loadavg[elem] = load_ave[elem];
+  for (elem = 0; elem < nelem; elem++)
+    {
+      char *endptr;
+      double d = c_strtod (ptr, &endptr);
+      if (ptr == endptr)
+	{
+	  if (elem == 0)
+	    return -1;
+	  break;
+	}
+      loadavg[elem] = d;
+      ptr = endptr;
+    }
 
   return elem;
 
-# endif /* __linux__ */
+# endif /* __linux__ || __CYGWIN__ */
 
 # if !defined (LDAV_DONE) && defined (__NetBSD__)
 #  define LDAV_DONE
@@ -653,7 +639,7 @@
 
   host_t host;
   struct processor_set_basic_info info;
-  unsigned info_count;
+  unsigned int info_count;
 
   /* We only know how to get the 1-minute average for this system,
      so even if the caller asks for more than 1, we only return 1.  */
@@ -661,7 +647,7 @@
   if (!getloadavg_initialized)
     {
       if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
-	getloadavg_initialized = 1;
+	getloadavg_initialized = true;
     }
 
   if (getloadavg_initialized)
@@ -670,7 +656,7 @@
       if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
 			      (processor_set_info_t) &info, &info_count)
 	  != KERN_SUCCESS)
-	getloadavg_initialized = 0;
+	getloadavg_initialized = false;
       else
 	{
 	  if (nelem > 0)
@@ -831,7 +817,7 @@
   /* VMS specific code -- read from the Load Ave driver.  */
 
   LOAD_AVE_TYPE load_ave[3];
-  static int getloadavg_initialized = 0;
+  static bool getloadavg_initialized;
 #  ifdef eunice
   struct
   {
@@ -851,7 +837,7 @@
       $DESCRIPTOR (descriptor, "LAV0:");
 #  endif
       if (sys$assign (&descriptor, &channel, 0, 0) & 1)
-	getloadavg_initialized = 1;
+	getloadavg_initialized = true;
     }
 
   /* Read the load average vector.  */
@@ -860,7 +846,7 @@
 		     load_ave, 12, 0, 0, 0, 0) & 1))
     {
       sys$dassgn (channel);
-      getloadavg_initialized = 0;
+      getloadavg_initialized = false;
     }
 
   if (!getloadavg_initialized)
@@ -913,7 +899,7 @@
 
       ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
       if (ldav_off != -1)
-	offset = (long) ldav_off & 0x7fffffff;
+	offset = (long int) ldav_off & 0x7fffffff;
 #  endif /* sgi */
     }
 
@@ -921,13 +907,13 @@
   if (!getloadavg_initialized)
     {
 #  ifndef SUNOS_5
-      channel = open ("/dev/kmem", 0);
+      channel = open ("/dev/kmem", O_RDONLY);
       if (channel >= 0)
 	{
 	  /* 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;
+	  getloadavg_initialized = true;
 	}
 #  else /* SUNOS_5 */
       /* We pass 0 for the kernel, corefile, and swapfile names
@@ -938,7 +924,7 @@
 	  /* nlist the currently running kernel.  */
 	  kvm_nlist (kd, nl);
 	  offset = nl[0].n_value;
-	  getloadavg_initialized = 1;
+	  getloadavg_initialized = true;
 	}
 #  endif /* SUNOS_5 */
     }
@@ -953,14 +939,14 @@
 	  != sizeof (load_ave))
 	{
 	  close (channel);
-	  getloadavg_initialized = 0;
+	  getloadavg_initialized = false;
 	}
 #  else  /* SUNOS_5 */
       if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
 	  != sizeof (load_ave))
 	{
 	  kvm_close (kd);
-	  getloadavg_initialized = 0;
+	  getloadavg_initialized = false;
 	}
 #  endif /* SUNOS_5 */
     }
@@ -980,20 +966,19 @@
 #  define LDAV_DONE
 # endif /* !LDAV_DONE && LOAD_AVE_TYPE */
 
-# ifdef LDAV_DONE
-  return elem;
-# else
+# if !defined LDAV_DONE
   /* Set errno to zero to indicate that there was no particular error;
      this function just can't work at all on this system.  */
   errno = 0;
-  return -1;
+  elem = -1;
 # endif
+  return elem;
 }
 
 #endif /* ! HAVE_GETLOADAVG */
 
 #ifdef TEST
-void
+int
 main (int argc, char **argv)
 {
   int naptime = 0;
@@ -1011,7 +996,7 @@
       if (loads == -1)
 	{
 	  perror ("Error getting load average");
-	  exit (1);
+	  return EXIT_FAILURE;
 	}
       if (loads > 0)
 	printf ("1-minute: %f  ", avg[0]);
@@ -1027,6 +1012,6 @@
       sleep (naptime);
     }
 
-  exit (0);
+  return EXIT_SUCCESS;
 }
 #endif /* TEST */

Index: gettext.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/gettext.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gettext.h	12 Nov 2004 00:49:51 -0000	1.2
+++ gettext.h	18 May 2006 22:05:42 -0000	1.3
@@ -1,5 +1,5 @@
 /* Convenience header for conditional use of GNU <libintl.h>.
-   Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000-2002, 2004 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
@@ -13,7 +13,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef _LIBGETTEXT_H
 #define _LIBGETTEXT_H 1
@@ -36,6 +36,16 @@
 # include <locale.h>
 #endif
 
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+   <libintl.h>, which chokes if dcgettext is defined as a macro.  So include
+   it now, to make later inclusions of <libintl.h> a NOP.  */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
+#  include <libintl.h>
+# endif
+#endif
+
 /* Disabled NLS.
    The casts to 'const char *' serve the purpose of producing warnings
    for invalid uses of the value returned from these functions.

Index: full-write.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/full-write.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- full-write.h	15 Dec 2004 20:47:25 -0000	1.1
+++ full-write.h	18 May 2006 22:05:42 -0000	1.2
@@ -1,6 +1,6 @@
 /* An interface to write() that writes all it is asked to write.
 
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   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
@@ -14,11 +14,22 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include <stddef.h>
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 /* Write COUNT bytes at BUF to descriptor FD, retrying if interrupted
    or if partial writes occur.  Return the number of bytes successfully
    written, setting errno if that is less than COUNT.  */
 extern size_t full_write (int fd, const void *buf, size_t count);
+
+
+#ifdef __cplusplus
+}
+#endif

Index: error.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/error.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- error.h	12 Nov 2004 00:49:51 -0000	1.2
+++ error.h	18 May 2006 22:05:42 -0000	1.3
@@ -14,7 +14,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef _ERROR_H
 #define _ERROR_H 1

--- NEW FILE: getopt_int.h ---
/* Internal declarations for getopt.
   Copyright (C) 1989-1994,1996-1999,2001,2003,2004
   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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

#ifndef _GETOPT_INT_H
#define _GETOPT_INT_H	1

extern int _getopt_internal (int ___argc, char **___argv,
			     const char *__shortopts,
		             const struct option *__longopts, int *__longind,
			     int __long_only, int __posixly_correct);


/* Reentrant versions which can handle parsing multiple argument
   vectors at the same time.  */

/* Data type for reentrant functions.  */
struct _getopt_data
{
  /* These have exactly the same meaning as the corresponding global
     variables, except that they are used for the reentrant
     versions of getopt.  */
  int optind;
  int opterr;
  int optopt;
  char *optarg;

  /* Internal members.  */

  /* True if the internal members have been initialized.  */
  int __initialized;

  /* The next char to be scanned in the option-element
     in which the last option character we returned was found.
     This allows us to pick up the scan where we left off.

     If this is zero, or a null string, it means resume the scan
     by advancing to the next ARGV-element.  */
  char *__nextchar;

  /* Describe how to deal with options that follow non-option ARGV-elements.

     If the caller did not specify anything,
     the default is REQUIRE_ORDER if the environment variable
     POSIXLY_CORRECT is defined, PERMUTE otherwise.

     REQUIRE_ORDER means don't recognize them as options;
     stop option processing when the first non-option is seen.
     This is what Unix does.
     This mode of operation is selected by either setting the environment
     variable POSIXLY_CORRECT, or using `+' as the first character
     of the list of option characters, or by calling getopt.

     PERMUTE is the default.  We permute the contents of ARGV as we
     scan, so that eventually all the non-options are at the end.
     This allows options to be given in any order, even with programs
     that were not written to expect this.

     RETURN_IN_ORDER is an option available to programs that were
     written to expect options and other ARGV-elements in any order
     and that care about the ordering of the two.  We describe each
     non-option ARGV-element as if it were the argument of an option
     with character code 1.  Using `-' as the first character of the
     list of option characters selects this mode of operation.

     The special argument `--' forces an end of option-scanning regardless
     of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
     `--' can cause `getopt' to return -1 with `optind' != ARGC.  */

  enum
    {
      REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
    } __ordering;

  /* If the POSIXLY_CORRECT environment variable is set
     or getopt was called.  */
  int __posixly_correct;


  /* Handle permutation of arguments.  */

  /* Describe the part of ARGV that contains non-options that have
     been skipped.  `first_nonopt' is the index in ARGV of the first
     of them; `last_nonopt' is the index after the last of them.  */

  int __first_nonopt;
  int __last_nonopt;

#if defined _LIBC && defined USE_NONOPTION_FLAGS
  int __nonoption_flags_max_len;
  int __nonoption_flags_len;
# endif
};

/* The initializer is necessary to set OPTIND and OPTERR to their
   default values and to clear the initialization flag.  */
#define _GETOPT_DATA_INITIALIZER	{ 1, 1 }

extern int _getopt_internal_r (int ___argc, char **___argv,
			       const char *__shortopts,
			       const struct option *__longopts, int *__longind,
			       int __long_only, int __posixly_correct,
			       struct _getopt_data *__data);

extern int _getopt_long_r (int ___argc, char **___argv,
			   const char *__shortopts,
			   const struct option *__longopts, int *__longind,
			   struct _getopt_data *__data);

extern int _getopt_long_only_r (int ___argc, char **___argv,
				const char *__shortopts,
				const struct option *__longopts,
				int *__longind,
				struct _getopt_data *__data);

#endif /* getopt_int.h */

Index: unlocked-io.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/unlocked-io.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- unlocked-io.h	12 Nov 2004 00:49:51 -0000	1.2
+++ unlocked-io.h	18 May 2006 22:05:42 -0000	1.3
@@ -1,6 +1,6 @@
 /* Prefer faster, non-thread-safe stdio functions if available.
 
-   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004 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
@@ -14,19 +14,13 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /* Written by Jim Meyering.  */
 
 #ifndef UNLOCKED_IO_H
 # define UNLOCKED_IO_H 1
 
-# ifndef USE_UNLOCKED_IO
-#  define USE_UNLOCKED_IO 1
-# endif
-
-# 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.
 
@@ -38,95 +32,106 @@
    the *_unlocked functions directly.  On hosts that lack those
    functions, invoke the non-thread-safe versions instead.  */
 
-#  include <stdio.h>
+# 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
+# if HAVE_DECL_CLEARERR_UNLOCKED
+#  undef clearerr
+#  define clearerr(x) clearerr_unlocked (x)
+# else
+#  define clearerr_unlocked(x) clearerr (x)
+# endif
 
-#  undef flockfile
-#  define flockfile(x) ((void) 0)
+# if HAVE_DECL_FEOF_UNLOCKED
+#  undef feof
+#  define feof(x) feof_unlocked (x)
+# else
+#  define feof_unlocked(x) feof (x)
+# endif
 
-#  undef ftrylockfile
-#  define ftrylockfile(x) 0
+# if HAVE_DECL_FERROR_UNLOCKED
+#  undef ferror
+#  define ferror(x) ferror_unlocked (x)
+# else
+#  define ferror_unlocked(x) ferror (x)
+# endif
 
-#  undef funlockfile
-#  define funlockfile(x) ((void) 0)
+# 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: getopt1.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/getopt1.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- getopt1.c	12 Nov 2004 00:49:51 -0000	1.2
+++ getopt1.c	18 May 2006 22:05:42 -0000	1.3
@@ -1,8 +1,6 @@
 /* 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.
-
+   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004
+     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
@@ -17,10 +15,10 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
 #endif
 
 #ifdef _LIBC
@@ -28,28 +26,10 @@
 #else
 # include "getopt.h"
 #endif
+#include "getopt_int.h"
 
 #include <stdio.h>
 
-/* Comment out all this code if we are using the GNU C Library, and are not
-   actually compiling the library itself.  This code is part of the GNU C
-   Library, but also included in many other GNU distributions.  Compiling
-   and linking in this code is a waste when using the GNU C library
-   (especially if it is a shared library).  Rather than having every GNU
-   program understand `configure --with-gnu-libc' and omit the object files,
-   it is simpler to just do this in the source for each such file.  */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-#include <gnu-versions.h>
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
 /* This needs to come after some library #include
    to get __GNU_LIBRARY__ defined.  */
 #ifdef __GNU_LIBRARY__
@@ -61,13 +41,20 @@
 #endif
 
 int
-getopt_long (int argc,
-	     char *const *argv,
-	     const char *options,
-	     const struct option *long_options,
-	     int *opt_index)
+getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
+	     const struct option *long_options, int *opt_index)
 {
-  return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
+  return _getopt_internal (argc, (char **) argv, options, long_options,
+			   opt_index, 0, 0);
+}
+
+int
+_getopt_long_r (int argc, char **argv, const char *options,
+		const struct option *long_options, int *opt_index,
+		struct _getopt_data *d)
+{
+  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+			     0, 0, d);
 }
 
 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
@@ -76,21 +63,23 @@
    instead.  */
 
 int
-getopt_long_only (int argc,
-		  char *const *argv,
+getopt_long_only (int argc, char *__getopt_argv_const *argv,
 		  const char *options,
-		  const struct option *long_options,
-		  int *opt_index)
+		  const struct option *long_options, int *opt_index)
 {
-  return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
+  return _getopt_internal (argc, (char **) argv, options, long_options,
+			   opt_index, 1, 0);
 }
 
-# ifdef _LIBC
-libc_hidden_def (getopt_long)
-libc_hidden_def (getopt_long_only)
-# endif
+int
+_getopt_long_only_r (int argc, char **argv, const char *options,
+		     const struct option *long_options, int *opt_index,
+		     struct _getopt_data *d)
+{
+  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
+			     1, 0, d);
+}
 
-#endif	/* Not ELIDE_CODE.  */
 
 #ifdef TEST
 

Index: safe-read.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/safe-read.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- safe-read.c	15 Dec 2004 20:47:26 -0000	1.1
+++ safe-read.c	18 May 2006 22:05:42 -0000	1.2
@@ -1,5 +1,7 @@
 /* An interface to read and write that retries after interrupts.
-   Copyright (C) 1993, 1994, 1998, 2002-2003 Free Software Foundation, Inc.
+
+   Copyright (C) 1993, 1994, 1998, 2002, 2003, 2004, 2005 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
@@ -13,9 +15,9 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
@@ -28,14 +30,9 @@
 
 /* Get ssize_t.  */
 #include <sys/types.h>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
 
 #include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
 
 #ifdef EINTR
 # define IS_EINTR(x) ((x) == EINTR)
@@ -61,22 +58,23 @@
 size_t
 safe_rw (int fd, void const *buf, size_t count)
 {
-  ssize_t result;
-
-  /* POSIX limits COUNT to SSIZE_MAX, but we limit it further, requiring
-     that COUNT <= INT_MAX, to avoid triggering a bug in Tru64 5.1.
-     When decreasing COUNT, keep the file pointer block-aligned.
-     Note that in any case, read(write) may succeed, yet read(write)
-     fewer than COUNT bytes, so the caller must be prepared to handle
-     partial results.  */
-  if (count > INT_MAX)
-    count = INT_MAX & ~8191;
+  /* Work around a bug in Tru64 5.1.  Attempting to read more than
+     INT_MAX bytes fails with errno == EINVAL.  See
+     <http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
+     When decreasing COUNT, keep it block-aligned.  */
+  enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
 
-  do
+  for (;;)
     {
-      result = rw (fd, buf, count);
-    }
-  while (result < 0 && IS_EINTR (errno));
+      ssize_t result = rw (fd, buf, count);
 
-  return (size_t) result;
+      if (0 <= result)
+	return result;
+      else if (IS_EINTR (errno))
+	continue;
+      else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
+	count = BUGGY_READ_MAXIMUM;
+      else
+	return result;
+    }
 }

--- NEW FILE: getopt_.h ---
/* Declarations for getopt.
   Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005
   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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

#ifndef _GETOPT_H

#ifndef __need_getopt
# define _GETOPT_H 1
#endif

/* Standalone applications should #define __GETOPT_PREFIX to an
   identifier that prefixes the external functions and variables
   defined in this header.  When this happens, include the
   headers that might declare getopt so that they will not cause
   confusion if included after this file.  Then systematically rename
   identifiers so that they do not collide with the system functions
   and variables.  Renaming avoids problems with some compilers and
   linkers.  */
#if defined __GETOPT_PREFIX && !defined __need_getopt
# include <stdlib.h>
# include <stdio.h>
# include <unistd.h>
# undef __need_getopt
# undef getopt
# undef getopt_long
# undef getopt_long_only
# undef optarg
# undef opterr
# undef optind
# undef optopt
# define __GETOPT_CONCAT(x, y) x ## y
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
# define getopt __GETOPT_ID (getopt)
# define getopt_long __GETOPT_ID (getopt_long)
# define getopt_long_only __GETOPT_ID (getopt_long_only)
# define optarg __GETOPT_ID (optarg)
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
#endif

/* Standalone applications get correct prototypes for getopt_long and
   getopt_long_only; they declare "char **argv".  libc uses prototypes
   with "char *const *argv" that are incorrect because getopt_long and
   getopt_long_only can permute argv; this is required for backward
   compatibility (e.g., for LSB 2.0.1).

   This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
   but it caused redefinition warnings if both unistd.h and getopt.h were
   included, since unistd.h includes getopt.h having previously defined
   __need_getopt.

   The only place where __getopt_argv_const is used is in definitions
   of getopt_long and getopt_long_only below, but these are visible
   only if __need_getopt is not defined, so it is quite safe to rewrite
   the conditional as follows:
*/
#if !defined __need_getopt
# if defined __GETOPT_PREFIX
#  define __getopt_argv_const /* empty */
# else
#  define __getopt_argv_const const
# endif
#endif

/* If __GNU_LIBRARY__ is not already defined, either we are being used
   standalone, or this is the first header included in the source file.
   If we are being used with glibc, we need to include <features.h>, but
   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
   not defined, include <ctype.h>, which will pull in <features.h> for us
   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
   doesn't flood the namespace with stuff the way some other headers do.)  */
#if !defined __GNU_LIBRARY__
# include <ctype.h>
#endif

#ifndef __THROW
# ifndef __GNUC_PREREQ
#  define __GNUC_PREREQ(maj, min) (0)
# endif
# if defined __cplusplus && __GNUC_PREREQ (2,8)
#  define __THROW	throw ()
# else
#  define __THROW
# endif
#endif

#ifdef	__cplusplus
extern "C" {
#endif

/* For communication from `getopt' to the caller.
   When `getopt' finds an option that takes an argument,
   the argument value is returned here.
   Also, when `ordering' is RETURN_IN_ORDER,
   each non-option ARGV-element is returned here.  */

extern char *optarg;

/* Index in ARGV of the next element to be scanned.
   This is used for communication to and from the caller
   and for communication between successive calls to `getopt'.

   On entry to `getopt', zero means this is the first call; initialize.

   When `getopt' returns -1, this is the index of the first of the
   non-option elements that the caller should itself scan.

   Otherwise, `optind' communicates from one call to the next
   how much of ARGV has been scanned so far.  */

extern int optind;

/* Callers store zero here to inhibit the error message `getopt' prints
   for unrecognized options.  */

extern int opterr;

/* Set to an option character which was unrecognized.  */

extern int optopt;

#ifndef __need_getopt
/* Describe the long-named options requested by the application.
   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
   of `struct option' terminated by an element containing a name which is
   zero.

   The field `has_arg' is:
   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
   to the value given in the field `val' when the option is found, but
   left unchanged if the option is not found.

   To have a long-named option do something other than set an `int' to
   a compiled-in constant, such as set a value from `optarg', set the
   option's `flag' field to zero and its `val' field to a nonzero
   value (the equivalent single-letter option character, if there is
   one).  For long options that have a zero `flag' field, `getopt'
   returns the contents of the `val' field.  */

struct option
{
  const char *name;
  /* has_arg can't be an enum because some compilers complain about
     type mismatches in all the code that assumes it is an int.  */
  int has_arg;
  int *flag;
  int val;
};

/* Names for the values of the `has_arg' field of `struct option'.  */

# define no_argument		0
# define required_argument	1
# define optional_argument	2
#endif	/* need getopt */


/* Get definitions and prototypes for functions to process the
   arguments in ARGV (ARGC of them, minus the program name) for
   options given in OPTS.

   Return the option character from OPTS just read.  Return -1 when
   there are no more options.  For unrecognized options, or options
   missing arguments, `optopt' is set to the option letter, and '?' is
   returned.

   The OPTS string is a list of characters which are recognized option
   letters, optionally followed by colons, specifying that that letter
   takes an argument, to be placed in `optarg'.

   If a letter in OPTS is followed by two colons, its argument is
   optional.  This behavior is specific to the GNU `getopt'.

   The argument `--' causes premature termination of argument
   scanning, explicitly telling `getopt' that there are no more
   options.

   If OPTS begins with `--', then non-option arguments are treated as
   arguments to the option '\0'.  This behavior is specific to the GNU
   `getopt'.  */

extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
       __THROW;

#ifndef __need_getopt
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
			const char *__shortopts,
		        const struct option *__longopts, int *__longind)
       __THROW;
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
			     const char *__shortopts,
		             const struct option *__longopts, int *__longind)
       __THROW;

#endif

#ifdef	__cplusplus
}
#endif

/* Make sure we later can get all the definitions and declarations.  */
#undef __need_getopt

#endif /* getopt.h */

Index: safe-read.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/safe-read.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- safe-read.h	15 Dec 2004 20:47:26 -0000	1.1
+++ safe-read.h	18 May 2006 22:05:42 -0000	1.2
@@ -13,7 +13,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include <stddef.h>
 

Index: full-read.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/full-read.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- full-read.h	12 Nov 2004 00:49:51 -0000	1.1
+++ full-read.h	18 May 2006 22:05:42 -0000	1.2
@@ -14,7 +14,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include <stddef.h>
 

Index: stdbool_.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/stdbool_.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- stdbool_.h	22 Dec 2004 07:24:17 -0000	1.1
+++ stdbool_.h	18 May 2006 22:05:42 -0000	1.2
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
    Written by Bruno Haible <haible at clisp.cons.org>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef _STDBOOL_H
 #define _STDBOOL_H
@@ -54,35 +54,47 @@
 /* 7.16. Boolean type and values */
 
 /* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
-   definitions below, but temporarily we have to #undef them.  */
+   definitions below, which is OK.  */
 #ifdef __BEOS__
 # include <OS.h> /* defines bool but not _Bool */
-# undef false
-# undef true
 #endif
 
-/* For the sake of symbolic names in gdb, we define true and false as
-   enum constants, not only as macros.
-   It is tempting to write
-      typedef enum { false = 0, true = 1 } _Bool;
-   so that gdb prints values of type 'bool' symbolically. But if we do
+/* C++ and BeOS have a reliable bool (and _Bool, if it exists).
+   Otherwise, since this file is being compiled, the system
+   <stdbool.h> is not reliable so assume that the system _Bool is not
+   reliable either.  Under that assumption, it is tempting to write
+
+      typedef enum { false, true } _Bool;
+
+   so that gdb prints values of type 'bool' symbolically.  But if we do
    this, values of type '_Bool' may promote to 'int' or 'unsigned int'
    (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
-   (see ISO C 99 6.3.1.1.(2)).  So we add a negative value to the
-   enum; this ensures that '_Bool' promotes to 'int'.  */
-#if !(defined __cplusplus || defined __BEOS__)
+   (see ISO C 99 6.3.1.1.(2)).  We could instead try this:
+
+      typedef enum { _Bool_dummy = -1, false, true } _Bool;
+
+   as the negative value ensures that '_Bool' promotes to 'int'.
+   However, this runs into some other problems.  First, Sun's C
+   compiler when (__SUNPRO_C < 0x550 || __STDC__ == 1) issues a stupid
+   "warning: _Bool is a keyword in ISO C99".  Second, IBM's AIX cc
+   compiler 6.0.0.0 (and presumably other versions) mishandles
+   subscripts involving _Bool (effectively, _Bool promotes to unsigned
+   int in this case), and we need to redefine _Bool in that case.
+   Third, HP-UX 10.20's C compiler lacks <stdbool.h> but has _Bool and
+   mishandles comparisons of _Bool to int (it promotes _Bool to
+   unsigned int).
+
+   The simplest way to work around these problems is to ignore any
+   existing definition of _Bool and use our own.  */
+
+#if defined __cplusplus || defined __BEOS__
 # if !@HAVE__BOOL@
-#  if defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1)
-    /* Avoid stupid "warning: _Bool is a keyword in ISO C99".  */
-#   define _Bool signed char
-enum { false = 0, true = 1 };
-#  else
-typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
-#  endif
+typedef bool _Bool;
 # endif
 #else
-typedef bool _Bool;
+# define _Bool signed char
 #endif
+
 #define bool _Bool
 
 /* The other macros must be usable in preprocessor directives.  */

Index: exitfail.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/exitfail.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- exitfail.c	12 Nov 2004 00:49:51 -0000	1.1
+++ exitfail.c	18 May 2006 22:05:42 -0000	1.2
@@ -15,9 +15,9 @@
    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.  */
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 

Index: full-read.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/full-read.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- full-read.c	15 Dec 2004 20:47:25 -0000	1.1
+++ full-read.c	18 May 2006 22:05:42 -0000	1.2
@@ -13,7 +13,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #define FULL_READ
 #include "full-write.c"

--- NEW FILE: xalloc-die.c ---
/* Report a memory allocation failure and exit.

   Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

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

#include "xalloc.h"

#include <stdlib.h>

#include "error.h"
#include "exitfail.h"

#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid

void
xalloc_die (void)
{
  error (exit_failure, 0, "%s", _("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 not return, call abort.  Also, the abort is a
     safety feature if exit_failure is 0 (which shouldn't happen).  */
  abort ();
}

Index: getopt.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/getopt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- getopt.c	12 Nov 2004 00:49:51 -0000	1.2
+++ getopt.c	18 May 2006 22:05:42 -0000	1.3
@@ -2,11 +2,8 @@
    NOTE: getopt is now part of the C library, so if you don't know what
    "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.
-
+   Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004
+	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
[...1116 lines suppressed...]
+enum { POSIXLY_CORRECT = 0 };
+#else
+enum { POSIXLY_CORRECT = 1 };
+#endif
+
+int
 getopt (int argc, char *const *argv, const char *optstring)
 {
-  return _getopt_internal (argc, argv, optstring,
-			   (const struct option *) 0,
-			   (int *) 0,
-			   0);
+  return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
+			   POSIXLY_CORRECT);
 }
 
-#endif	/* Not ELIDE_CODE.  */
 
 #ifdef TEST
 

Index: malloc.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/malloc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- malloc.c	12 Nov 2004 00:49:51 -0000	1.2
+++ malloc.c	18 May 2006 22:05:42 -0000	1.3
@@ -1,4 +1,4 @@
-/* Work around bug on some systems where malloc (0) fails.
+/* malloc() function that is glibc compatible.
    Copyright (C) 1997, 1998 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -13,11 +13,11 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /* written by Jim Meyering */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 #undef malloc

--- getopt.h DELETED ---

Index: xmalloc.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/xmalloc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- xmalloc.c	12 Nov 2004 00:49:51 -0000	1.2
+++ xmalloc.c	18 May 2006 22:05:42 -0000	1.3
@@ -1,7 +1,7 @@
 /* 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.
+   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000, 2002, 2003, 2004, 2005 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
@@ -15,9 +15,9 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
@@ -26,44 +26,19 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-#define N_(msgid) msgid
-
-#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"
-#endif
-
-#ifndef HAVE_REALLOC
-"you must run the autoconf test for a GNU libc compatible realloc"
+/* 1 if calloc is known to be compatible with GNU calloc.  This
+   matters if we are not also using the calloc module, which defines
+   HAVE_CALLOC and supports the GNU API even on non-GNU platforms.  */
+#if defined HAVE_CALLOC || defined __GLIBC__
+enum { HAVE_GNU_CALLOC = 1 };
+#else
+enum { HAVE_GNU_CALLOC = 0 };
 #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
-   before exiting when memory is exhausted.  Goes through gettext. */
-char const xalloc_msg_memory_exhausted[] = N_("memory exhausted");
-
-void
-xalloc_die (void)
-{
-  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.  */
 
@@ -71,7 +46,7 @@
 xnmalloc_inline (size_t n, size_t s)
 {
   void *p;
-  if (xalloc_oversized (n, s) || ! (p = malloc (n * s)))
+  if (xalloc_oversized (n, s) || (! (p = malloc (n * s)) && n != 0))
     xalloc_die ();
   return p;
 }
@@ -96,7 +71,7 @@
 static inline void *
 xnrealloc_inline (void *p, size_t n, size_t s)
 {
-  if (xalloc_oversized (n, s) || ! (p = realloc (p, n * s)))
+  if (xalloc_oversized (n, s) || (! (p = realloc (p, n * s)) && n != 0))
     xalloc_die ();
   return p;
 }
@@ -238,18 +213,29 @@
 {
   void *p;
   /* Test for overflow, since some calloc implementations don't have
-     proper overflow checks.  */
-  if (xalloc_oversized (n, s) || ! (p = calloc (n, s)))
+     proper overflow checks.  But omit overflow and size-zero tests if
+     HAVE_GNU_CALLOC, since GNU calloc catches overflow and never
+     returns NULL if successful.  */
+  if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s))
+      || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0)))
     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
+   for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
    need for an arithmetic overflow check.  */
 
 void *
-xclone (void const *p, size_t s)
+xmemdup (void const *p, size_t s)
 {
   return memcpy (xmalloc (s), p, s);
 }
+
+/* Clone STRING.  */
+
+char *
+xstrdup (char const *string)
+{
+  return xmemdup (string, strlen (string) + 1);
+}

Index: fsusage.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/fsusage.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- fsusage.h	12 Nov 2004 00:49:51 -0000	1.2
+++ fsusage.h	18 May 2006 22:05:42 -0000	1.3
@@ -1,6 +1,7 @@
-/* fsusage.h -- declarations for filesystem space usage info
+/* fsusage.h -- declarations for file system space usage info
 
-   Copyright (C) 1991, 1992, 1997, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1997, 2003, 2004, 2005 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
@@ -14,24 +15,26 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-/* Space usage statistics for a filesystem.  Blocks are 512-byte. */
+/* Space usage statistics for a file system.  Blocks are 512-byte. */
 
 #if !defined FSUSAGE_H_
 # define FSUSAGE_H_
 
+# include <stdbool.h>
+
 struct fs_usage
 {
-  int fsu_blocksize;		/* Size of a block.  */
+  uintmax_t fsu_blocksize;	/* Size of a block.  */
   uintmax_t fsu_blocks;		/* Total blocks. */
   uintmax_t fsu_bfree;		/* Free blocks available to superuser. */
   uintmax_t fsu_bavail;		/* Free blocks available to non-superuser. */
-  int fsu_bavail_top_bit_set;	/* 1 if fsu_bavail represents a value < 0.  */
+  bool fsu_bavail_top_bit_set;	/* 1 if fsu_bavail represents a value < 0.  */
   uintmax_t fsu_files;		/* Total file nodes. */
   uintmax_t fsu_ffree;		/* Free file nodes. */
 };
 
-int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp);
+int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp);
 
 #endif

Index: realloc.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/realloc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- realloc.c	12 Nov 2004 00:49:51 -0000	1.2
+++ realloc.c	18 May 2006 22:05:42 -0000	1.3
@@ -1,5 +1,5 @@
-/* Work around bug on some systems where realloc (NULL, 0) fails.
-   Copyright (C) 1997, 2003 Free Software Foundation, Inc.
+/* realloc() function that is glibc compatible.
+   Copyright (C) 1997, 2003, 2004 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
@@ -13,11 +13,11 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /* written by Jim Meyering */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 #undef realloc
@@ -32,8 +32,15 @@
 rpl_realloc (void *p, size_t n)
 {
   if (n == 0)
-    n = 1;
-  if (p == 0)
+    {
+      n = 1;
+
+      /* In theory realloc might fail, so don't rely on it to free.  */
+      free (p);
+      p = NULL;
+    }
+
+  if (p == NULL)
     return malloc (n);
   return realloc (p, n);
 }

Index: exitfail.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/exitfail.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- exitfail.h	12 Nov 2004 00:49:51 -0000	1.1
+++ exitfail.h	18 May 2006 22:05:42 -0000	1.2
@@ -15,6 +15,6 @@
    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.  */
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 extern int volatile exit_failure;

Index: fsusage.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/fsusage.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- fsusage.c	12 Nov 2004 00:49:51 -0000	1.3
+++ fsusage.c	18 May 2006 22:05:42 -0000	1.4
@@ -1,7 +1,7 @@
-/* fsusage.c -- return space usage of mounted filesystems
+/* fsusage.c -- return space usage of mounted file systems
 
-   Copyright (C) 1991, 1992, 1996, 1998, 1999, 2002, 2003 Free
-   Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1996, 1998, 1999, 2002, 2003, 2004, 2005
+   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
@@ -15,19 +15,19 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-#  include <stdint.h>
-# endif
 #endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#include <unistd.h>
 #ifndef UINTMAX_MAX
 # define UINTMAX_MAX ((uintmax_t) -1)
 #endif
@@ -58,9 +58,7 @@
 # include <sys/filsys.h>	/* SVR2 */
 #endif
 
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
+#include <fcntl.h>
 
 #if HAVE_SYS_STATFS_H
 # include <sys/statfs.h>
@@ -72,7 +70,6 @@
 
 #if HAVE_SYS_STATVFS_H		/* SVR4 */
 # include <sys/statvfs.h>
-int statvfs ();
 #endif
 
 #include "full-read.h"
@@ -102,20 +99,20 @@
 #define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1))
 
 /* Fill in the fields of FSP with information about space usage for
-   the filesystem on which PATH resides.
-   DISK is the device on which PATH is mounted, for space-getting
+   the file system on which FILE resides.
+   DISK is the device on which FILE is mounted, for space-getting
    methods that need to know it.
    Return 0 if successful, -1 if not.  When returning -1, ensure that
    ERRNO is either a system error value, or zero if DISK is NULL
    on a system that requires a non-NULL value.  */
 int
-get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
+get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
 {
 #ifdef STAT_STATFS3_OSF1
 
   struct statfs fsd;
 
-  if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
+  if (statfs (file, &fsd, sizeof (struct statfs)) != 0)
     return -1;
 
   fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
@@ -126,7 +123,7 @@
 
   struct fs_data fsd;
 
-  if (statfs (path, &fsd) != 1)
+  if (statfs (file, &fsd) != 1)
     return -1;
 
   fsp->fsu_blocksize = 1024;
@@ -180,7 +177,7 @@
 
   struct statfs fsd;
 
-  if (statfs (path, &fsd) < 0)
+  if (statfs (file, &fsd) < 0)
     return -1;
 
   fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
@@ -206,7 +203,7 @@
 
   struct statfs fsd;
 
-  if (statfs (path, &fsd) < 0)
+  if (statfs (file, &fsd) < 0)
     return -1;
 
   fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
@@ -221,7 +218,7 @@
 
   struct statfs fsd;
 
-  if (statfs (path, &fsd, sizeof fsd, 0) < 0)
+  if (statfs (file, &fsd, sizeof fsd, 0) < 0)
     return -1;
 
   /* Empirically, the block counts on most SVR3 and SVR3-derived
@@ -239,7 +236,7 @@
 
   struct statvfs fsd;
 
-  if (statvfs (path, &fsd) < 0)
+  if (statvfs (file, &fsd) < 0)
     return -1;
 
   /* f_frsize isn't guaranteed to be supported.  */
@@ -268,12 +265,12 @@
 /* AIX PS/2 does not supply statfs.  */
 
 int
-statfs (char *path, struct statfs *fsb)
+statfs (char *file, struct statfs *fsb)
 {
   struct stat stats;
   struct dustat fsd;
 
-  if (stat (path, &stats))
+  if (stat (file, &stats) != 0)
     return -1;
   if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
     return -1;

Index: cloexec.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/cloexec.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cloexec.h	19 Nov 2004 14:22:45 -0000	1.1
+++ cloexec.h	18 May 2006 22:05:42 -0000	1.2
@@ -1,2 +1,2 @@
 #include <stdbool.h>
-bool set_cloexec_flag (int desc, bool value);
+int set_cloexec_flag (int desc, bool value);

Index: safe-write.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/safe-write.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- safe-write.h	15 Dec 2004 20:47:26 -0000	1.1
+++ safe-write.h	18 May 2006 22:05:42 -0000	1.2
@@ -13,7 +13,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #include <stddef.h>
 

Index: exit.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/exit.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- exit.h	12 Nov 2004 00:49:51 -0000	1.1
+++ exit.h	18 May 2006 22:05:42 -0000	1.2
@@ -13,7 +13,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #ifndef _EXIT_H
 #define _EXIT_H

Index: safe-write.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/safe-write.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- safe-write.c	15 Dec 2004 20:47:26 -0000	1.1
+++ safe-write.c	18 May 2006 22:05:42 -0000	1.2
@@ -13,7 +13,7 @@
 
    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.  */
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 #define SAFE_WRITE
 #include "safe-read.c"

Index: cloexec.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/cloexec.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cloexec.c	19 Nov 2004 14:23:00 -0000	1.1
+++ cloexec.c	18 May 2006 22:05:42 -0000	1.2
@@ -1,5 +1,5 @@
 /* closexec.c - set or clear the close-on-exec descriptor flag
-   Copyright (C) 1991, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1991, 2004, 2005 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
@@ -13,23 +13,18 @@
 
    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.
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
    The code is taken from glibc/manual/llio.texi  */
 
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 #include "cloexec.h"
 
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
+#include <unistd.h>
+#include <fcntl.h>
 
 #ifndef FD_CLOEXEC
 # define FD_CLOEXEC 1
@@ -37,27 +32,29 @@
 
 /* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
    or clear the flag if VALUE is false.
-   Return true on success, or false on error with `errno' set. */
+   Return 0 on success, or -1 on error with `errno' set. */
 
-bool
+int
 set_cloexec_flag (int desc, bool value)
 {
 #if defined F_GETFD && defined F_SETFD
 
   int flags = fcntl (desc, F_GETFD, 0);
-  int newflags;
 
-  if (flags < 0)
-    return false;
+  if (0 <= flags)
+    {
+      int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
 
-  newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
+      if (flags == newflags
+	  || fcntl (desc, F_SETFD, newflags) != -1)
+	return 0;
+    }
 
-  return (flags == newflags
-	  || fcntl (desc, F_SETFD, newflags) != -1);
+  return -1;
 
 #else
 
-  return true;
+  return 0;
 
 #endif
 }





More information about the Commits mailing list