[Nagiosplug-checkins] nagiosplug/lib full-read.c,NONE,1.1 full-write.c,NONE,1.1 full-write.h,NONE,1.1 safe-read.c,NONE,1.1 safe-read.h,NONE,1.1 safe-write.c,NONE,1.1 safe-write.h,NONE,1.1 Makefile.am,1.21,1.22 afs.m4,1.3,NONE error.m4,1.2,NONE exitfail.m4,1.1,NONE fstypename.m4,1.2,NONE fsusage.m4,1.3,NONE getopt.m4,1.1,NONE ls-mntd-fs.m4,1.5,NONE onceonly.m4,1.1,NONE unlocked-io.m4,1.1,NONE xalloc.m4,1.1,NONE

Ton Voon tonvoon at users.sourceforge.net
Wed Dec 15 12:48:02 CET 2004


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

Modified Files:
	Makefile.am 
Added Files:
	full-read.c full-write.c full-write.h safe-read.c safe-read.h 
	safe-write.c safe-write.h 
Removed Files:
	afs.m4 error.m4 exitfail.m4 fstypename.m4 fsusage.m4 getopt.m4 
	ls-mntd-fs.m4 onceonly.m4 unlocked-io.m4 xalloc.m4 
Log Message:
Moving m4 files into m4/. Added extra coreutils files required from 
autoconf tests. Updated Makefile.am to have nagiosplug lib and a separate
coreutils lib


--- xalloc.m4 DELETED ---

Index: Makefile.am
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/Makefile.am,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- Makefile.am	29 Nov 2004 23:52:43 -0000	1.21
+++ Makefile.am	15 Dec 2004 20:47:25 -0000	1.22
@@ -1,20 +1,38 @@
 ## Process this file with automake to produce Makefile.in
 
-noinst_LIBRARIES = libnagiosplug.a
+noinst_LIBRARIES = libcoreutils.a libnagiosplug.a
 
-libnagiosplug_a_SOURCES = getopt.c getopt1.c fsusage.c snprintf.c mountlist.c \
-		xmalloc.c xstrdup.c exitfail.c
+# Will auto pick up fsusage.c mountlist.c
+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
 
-libnagiosplug_a_LIBADD = @LIBOBJS@
-libnagiosplug_a_DEPENDENCIES = $(libnagiosplug_a_LIBADD)
+other_coreutils_files = \
+  error.c error.h \
+  fsusage.c \
+  getloadaavg.c \
+  malloc.c \
+  mountlist.c \
+  realloc.c \
+  strtod.c
 
-# Extra GNU libraries required if target is missing these functions
-EXTRA_DIST = ulonglong.m4 codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 \
-		inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 \
-		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 \
-		cloexec.c cloexec.h getopt.m4 exitfail.m4
+libcoreutils_a_LIBADD = $(LIBOBJS)
+libcoreutils_a_DEPENDENCIES = $(libcoreutils_a_LIBADD)
+
+libnagiosplug_a_SOURCES = snprintf.c
 
 INCLUDES = -I$(srcdir) -I$(top_srcdir)/intl
+

--- fsusage.m4 DELETED ---

--- exitfail.m4 DELETED ---

--- getopt.m4 DELETED ---

--- onceonly.m4 DELETED ---

--- unlocked-io.m4 DELETED ---

--- fstypename.m4 DELETED ---

--- ls-mntd-fs.m4 DELETED ---

--- NEW FILE: full-read.c ---
/* An interface to read that retries after partial reads and interrupts.
   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; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#define FULL_READ
#include "full-write.c"

--- error.m4 DELETED ---

--- NEW FILE: full-write.c ---
/* An interface to read and write that retries (if necessary) until complete.

   Copyright (C) 1993, 1994, 1997-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.  */
#ifdef FULL_READ
# include "full-read.h"
#else
# include "full-write.h"
#endif

#include <errno.h>
#ifndef errno
extern int errno;
#endif

#ifdef FULL_READ
# include "safe-read.h"
# define safe_rw safe_read
# define full_rw full_read
# undef const
# define const /* empty */
#else
# include "safe-write.h"
# define safe_rw safe_write
# define full_rw full_write
#endif

#ifdef FULL_READ
/* Set errno to zero upon EOF.  */
# define ZERO_BYTE_TRANSFER_ERRNO 0
#else
/* Some buggy drivers return 0 when one tries to write beyond
   a device's end.  (Example: Linux 1.2.13 on /dev/fd0.)
   Set errno to ENOSPC so they get a sensible diagnostic.  */
# define ZERO_BYTE_TRANSFER_ERRNO ENOSPC
#endif

/* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if
   interrupted or if a partial write(read) occurs.  Return the number
   of bytes transferred.
   When writing, set errno if fewer than COUNT bytes are written.
   When reading, if fewer than COUNT bytes are read, you must examine
   errno to distinguish failure from EOF (errno == 0).  */
size_t
full_rw (int fd, const void *buf, size_t count)
{
  size_t total = 0;
  const char *ptr = buf;

  while (count > 0)
    {
      size_t n_rw = safe_rw (fd, ptr, count);
      if (n_rw == (size_t) -1)
	break;
      if (n_rw == 0)
	{
	  errno = ZERO_BYTE_TRANSFER_ERRNO;
	  break;
	}
      total += n_rw;
      ptr += n_rw;
      count -= n_rw;
    }

  return total;
}

--- NEW FILE: safe-read.c ---
/* An interface to read and write that retries after interrupts.
   Copyright (C) 1993, 1994, 1998, 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.  */

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

/* Specification.  */
#ifdef SAFE_WRITE
# include "safe-write.h"
#else
# include "safe-read.h"
#endif

/* Get ssize_t.  */
#include <sys/types.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif

#include <errno.h>
#ifndef errno
extern int errno;
#endif

#ifdef EINTR
# define IS_EINTR(x) ((x) == EINTR)
#else
# define IS_EINTR(x) 0
#endif

#include <limits.h>

#ifdef SAFE_WRITE
# define safe_rw safe_write
# define rw write
#else
# define safe_rw safe_read
# define rw read
# undef const
# define const /* empty */
#endif

/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
   interrupted.  Return the actual number of bytes read(written), zero for EOF,
   or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error.  */
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;

  do
    {
      result = rw (fd, buf, count);
    }
  while (result < 0 && IS_EINTR (errno));

  return (size_t) result;
}

--- NEW FILE: safe-write.h ---
/* An interface to write() that retries after interrupts.
   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, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#include <stddef.h>

#define SAFE_WRITE_ERROR ((size_t) -1)

/* Write up to COUNT bytes at BUF to descriptor FD, retrying if interrupted.
   Return the actual number of bytes written, zero for EOF, or SAFE_WRITE_ERROR
   upon error.  */
extern size_t safe_write (int fd, const void *buf, size_t count);

--- afs.m4 DELETED ---

--- NEW FILE: safe-write.c ---
/* An interface to write that retries after interrupts.
   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, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#define SAFE_WRITE
#include "safe-read.c"

--- NEW FILE: safe-read.h ---
/* An interface to read() that retries after interrupts.
   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, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#include <stddef.h>

#define SAFE_READ_ERROR ((size_t) -1)

/* Read up to COUNT bytes at BUF from descriptor FD, retrying if interrupted.
   Return the actual number of bytes read, zero for EOF, or SAFE_READ_ERROR
   upon error.  */
extern size_t safe_read (int fd, void *buf, size_t count);

--- NEW FILE: full-write.h ---
/* An interface to write() that writes all it is asked to write.

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

#include <stddef.h>

/* 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);





More information about the Commits mailing list