diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2004-12-15 20:47:26 (GMT) |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2004-12-15 20:47:26 (GMT) |
commit | 82d1989d3245791c9fac22ca848f5497f261c10b (patch) | |
tree | 240017a6fcdcf7ecb5cfb2cbefb57de24de8b7c7 /lib | |
parent | 953a933e4d5900ec3c497781dab26066fef1e78b (diff) | |
download | monitoring-plugins-82d1989d3245791c9fac22ca848f5497f261c10b.tar.gz |
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
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1027 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile.am | 44 | ||||
-rw-r--r-- | lib/afs.m4 | 13 | ||||
-rw-r--r-- | lib/error.m4 | 15 | ||||
-rw-r--r-- | lib/exitfail.m4 | 13 | ||||
-rw-r--r-- | lib/fstypename.m4 | 32 | ||||
-rw-r--r-- | lib/fsusage.m4 | 246 | ||||
-rw-r--r-- | lib/full-read.c | 19 | ||||
-rw-r--r-- | lib/full-write.c | 85 | ||||
-rw-r--r-- | lib/full-write.h | 24 | ||||
-rw-r--r-- | lib/getopt.m4 | 13 | ||||
-rw-r--r-- | lib/ls-mntd-fs.m4 | 282 | ||||
-rw-r--r-- | lib/onceonly.m4 | 63 | ||||
-rw-r--r-- | lib/safe-read.c | 82 | ||||
-rw-r--r-- | lib/safe-read.h | 25 | ||||
-rw-r--r-- | lib/safe-write.c | 19 | ||||
-rw-r--r-- | lib/safe-write.h | 25 | ||||
-rw-r--r-- | lib/unlocked-io.m4 | 22 | ||||
-rw-r--r-- | lib/xalloc.m4 | 32 |
18 files changed, 310 insertions, 744 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 3250cdb..80f3e62 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am | |||
@@ -1,20 +1,38 @@ | |||
1 | ## Process this file with automake to produce Makefile.in | 1 | ## Process this file with automake to produce Makefile.in |
2 | 2 | ||
3 | noinst_LIBRARIES = libnagiosplug.a | 3 | noinst_LIBRARIES = libcoreutils.a libnagiosplug.a |
4 | 4 | ||
5 | libnagiosplug_a_SOURCES = getopt.c getopt1.c fsusage.c snprintf.c mountlist.c \ | 5 | # Will auto pick up fsusage.c mountlist.c |
6 | xmalloc.c xstrdup.c exitfail.c | 6 | libcoreutils_a_SOURCES = \ |
7 | cloexec.c cloexec.h \ | ||
8 | exit.h \ | ||
9 | exitfail.c exitfail.h \ | ||
10 | fsusage.h \ | ||
11 | full-read.c full-read.h \ | ||
12 | full-write.c full-write.h \ | ||
13 | getopt.c getopt.h getopt1.c \ | ||
14 | gettext.h \ | ||
15 | mountlist.h \ | ||
16 | safe-read.c safe-read.h \ | ||
17 | safe-write.c safe-write.h \ | ||
18 | unlocked-io.h \ | ||
19 | xalloc.h \ | ||
20 | xmalloc.c \ | ||
21 | xstrdup.c | ||
7 | 22 | ||
8 | libnagiosplug_a_LIBADD = @LIBOBJS@ | 23 | other_coreutils_files = \ |
9 | libnagiosplug_a_DEPENDENCIES = $(libnagiosplug_a_LIBADD) | 24 | error.c error.h \ |
25 | fsusage.c \ | ||
26 | getloadaavg.c \ | ||
27 | malloc.c \ | ||
28 | mountlist.c \ | ||
29 | realloc.c \ | ||
30 | strtod.c | ||
10 | 31 | ||
11 | # Extra GNU libraries required if target is missing these functions | 32 | libcoreutils_a_LIBADD = $(LIBOBJS) |
12 | EXTRA_DIST = ulonglong.m4 codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 \ | 33 | libcoreutils_a_DEPENDENCIES = $(libcoreutils_a_LIBADD) |
13 | inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 \ | 34 | |
14 | lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 afs.m4 \ | 35 | libnagiosplug_a_SOURCES = snprintf.c |
15 | fstypename.m4 fsusage.m4 ls-mntd-fs.m4 getopt.h gettext.h fsusage.h mountlist.h\ | ||
16 | error.m4 error.h error.c getloadavg.c xalloc.h unlocked-io.h unlocked-io.m4 malloc.c \ | ||
17 | onceonly.m4 realloc.c strtod.c exitfail.h full-read.h xstrdup.c xalloc.m4 exit.h \ | ||
18 | cloexec.c cloexec.h getopt.m4 exitfail.m4 | ||
19 | 36 | ||
20 | INCLUDES = -I$(srcdir) -I$(top_srcdir)/intl | 37 | INCLUDES = -I$(srcdir) -I$(top_srcdir)/intl |
38 | |||
diff --git a/lib/afs.m4 b/lib/afs.m4 deleted file mode 100644 index 9e7d773..0000000 --- a/lib/afs.m4 +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | #serial 5 | ||
2 | |||
3 | AC_DEFUN([jm_AFS], | ||
4 | [ | ||
5 | AC_MSG_CHECKING(for AFS) | ||
6 | if test -d /afs; then | ||
7 | AC_DEFINE(AFS, 1, [Define if you have the Andrew File System.]) | ||
8 | ac_result=yes | ||
9 | else | ||
10 | ac_result=no | ||
11 | fi | ||
12 | AC_MSG_RESULT($ac_result) | ||
13 | ]) | ||
diff --git a/lib/error.m4 b/lib/error.m4 deleted file mode 100644 index 0bc2e68..0000000 --- a/lib/error.m4 +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | #serial 9 | ||
2 | |||
3 | AC_DEFUN([gl_ERROR], | ||
4 | [ | ||
5 | AC_FUNC_ERROR_AT_LINE | ||
6 | dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]). | ||
7 | jm_PREREQ_ERROR | ||
8 | ]) | ||
9 | |||
10 | # Prerequisites of lib/error.c. | ||
11 | AC_DEFUN([jm_PREREQ_ERROR], | ||
12 | [ | ||
13 | AC_REQUIRE([AC_FUNC_STRERROR_R]) | ||
14 | : | ||
15 | ]) | ||
diff --git a/lib/exitfail.m4 b/lib/exitfail.m4 deleted file mode 100644 index fa5b149..0000000 --- a/lib/exitfail.m4 +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | # exitfail.m4 serial 3 | ||
2 | dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. | ||
3 | dnl This file is free software, distributed under the terms of the GNU | ||
4 | dnl General Public License. As a special exception to the GNU General | ||
5 | dnl Public License, this file may be distributed as part of a program | ||
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | |||
9 | AC_DEFUN([gl_EXITFAIL], | ||
10 | [ | ||
11 | dnl No prerequisites of lib/exitfail.c. | ||
12 | : | ||
13 | ]) | ||
diff --git a/lib/fstypename.m4 b/lib/fstypename.m4 deleted file mode 100644 index 75723a1..0000000 --- a/lib/fstypename.m4 +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | #serial 3 | ||
2 | |||
3 | dnl From Jim Meyering. | ||
4 | dnl | ||
5 | dnl See if struct statfs has the f_fstypename member. | ||
6 | dnl If so, define HAVE_F_FSTYPENAME_IN_STATFS. | ||
7 | dnl | ||
8 | |||
9 | AC_DEFUN([jm_FSTYPENAME], | ||
10 | [ | ||
11 | AC_CACHE_CHECK([for f_fstypename in struct statfs], | ||
12 | fu_cv_sys_f_fstypename_in_statfs, | ||
13 | [ | ||
14 | AC_TRY_COMPILE( | ||
15 | [ | ||
16 | #include <sys/param.h> | ||
17 | #include <sys/types.h> | ||
18 | #include <sys/mount.h> | ||
19 | ], | ||
20 | [struct statfs s; int i = sizeof s.f_fstypename;], | ||
21 | fu_cv_sys_f_fstypename_in_statfs=yes, | ||
22 | fu_cv_sys_f_fstypename_in_statfs=no | ||
23 | ) | ||
24 | ] | ||
25 | ) | ||
26 | |||
27 | if test $fu_cv_sys_f_fstypename_in_statfs = yes; then | ||
28 | AC_DEFINE(HAVE_F_FSTYPENAME_IN_STATFS, 1, | ||
29 | [Define if struct statfs has the f_fstypename member.]) | ||
30 | fi | ||
31 | ] | ||
32 | ) | ||
diff --git a/lib/fsusage.m4 b/lib/fsusage.m4 deleted file mode 100644 index a0ab1e1..0000000 --- a/lib/fsusage.m4 +++ /dev/null | |||
@@ -1,246 +0,0 @@ | |||
1 | #serial 11 | ||
2 | |||
3 | # From fileutils/configure.in | ||
4 | |||
5 | AC_DEFUN([gl_FSUSAGE], | ||
6 | [ | ||
7 | AC_CHECK_HEADERS_ONCE(sys/param.h) | ||
8 | AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs_types.h) | ||
9 | jm_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no]) | ||
10 | if test $gl_cv_fs_space = yes; then | ||
11 | AC_LIBOBJ(fsusage) | ||
12 | gl_PREREQ_FSUSAGE_EXTRA | ||
13 | fi | ||
14 | ]) | ||
15 | |||
16 | # Try to determine how a program can obtain filesystem usage information. | ||
17 | # If successful, define the appropriate symbol (see fsusage.c) and | ||
18 | # execute ACTION-IF-FOUND. Otherwise, execute ACTION-IF-NOT-FOUND. | ||
19 | # | ||
20 | # jm_FILE_SYSTEM_USAGE([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) | ||
21 | |||
22 | AC_DEFUN([jm_FILE_SYSTEM_USAGE], | ||
23 | [ | ||
24 | |||
25 | echo "checking how to get filesystem space usage..." | ||
26 | ac_fsusage_space=no | ||
27 | |||
28 | # Perform only the link test since it seems there are no variants of the | ||
29 | # statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs) | ||
30 | # because that got a false positive on SCO OSR5. Adding the declaration | ||
31 | # of a `struct statvfs' causes this test to fail (as it should) on such | ||
32 | # systems. That system is reported to work fine with STAT_STATFS4 which | ||
33 | # is what it gets when this test fails. | ||
34 | if test $ac_fsusage_space = no; then | ||
35 | # SVR4 | ||
36 | AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs, | ||
37 | [AC_TRY_LINK([#include <sys/types.h> | ||
38 | #ifdef __GLIBC__ | ||
39 | Do not use statvfs on systems with GNU libc, because that function stats | ||
40 | all preceding entries in /proc/mounts, and that makes df hang if even | ||
41 | one of the corresponding file systems is hard-mounted, but not available. | ||
42 | #endif | ||
43 | #include <sys/statvfs.h>], | ||
44 | [struct statvfs fsd; statvfs (0, &fsd);], | ||
45 | fu_cv_sys_stat_statvfs=yes, | ||
46 | fu_cv_sys_stat_statvfs=no)]) | ||
47 | if test $fu_cv_sys_stat_statvfs = yes; then | ||
48 | ac_fsusage_space=yes | ||
49 | AC_DEFINE(STAT_STATVFS, 1, | ||
50 | [ Define if there is a function named statvfs. (SVR4)]) | ||
51 | fi | ||
52 | fi | ||
53 | |||
54 | if test $ac_fsusage_space = no; then | ||
55 | # DEC Alpha running OSF/1 | ||
56 | AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) | ||
57 | AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1, | ||
58 | [AC_TRY_RUN([ | ||
59 | #include <sys/param.h> | ||
60 | #include <sys/types.h> | ||
61 | #include <sys/mount.h> | ||
62 | main () | ||
63 | { | ||
64 | struct statfs fsd; | ||
65 | fsd.f_fsize = 0; | ||
66 | exit (statfs (".", &fsd, sizeof (struct statfs))); | ||
67 | }], | ||
68 | fu_cv_sys_stat_statfs3_osf1=yes, | ||
69 | fu_cv_sys_stat_statfs3_osf1=no, | ||
70 | fu_cv_sys_stat_statfs3_osf1=no)]) | ||
71 | AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1) | ||
72 | if test $fu_cv_sys_stat_statfs3_osf1 = yes; then | ||
73 | ac_fsusage_space=yes | ||
74 | AC_DEFINE(STAT_STATFS3_OSF1, 1, | ||
75 | [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)]) | ||
76 | fi | ||
77 | fi | ||
78 | |||
79 | if test $ac_fsusage_space = no; then | ||
80 | # AIX | ||
81 | AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl | ||
82 | member (AIX, 4.3BSD)]) | ||
83 | AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize, | ||
84 | [AC_TRY_RUN([ | ||
85 | #ifdef HAVE_SYS_PARAM_H | ||
86 | #include <sys/param.h> | ||
87 | #endif | ||
88 | #ifdef HAVE_SYS_MOUNT_H | ||
89 | #include <sys/mount.h> | ||
90 | #endif | ||
91 | #ifdef HAVE_SYS_VFS_H | ||
92 | #include <sys/vfs.h> | ||
93 | #endif | ||
94 | main () | ||
95 | { | ||
96 | struct statfs fsd; | ||
97 | fsd.f_bsize = 0; | ||
98 | exit (statfs (".", &fsd)); | ||
99 | }], | ||
100 | fu_cv_sys_stat_statfs2_bsize=yes, | ||
101 | fu_cv_sys_stat_statfs2_bsize=no, | ||
102 | fu_cv_sys_stat_statfs2_bsize=no)]) | ||
103 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize) | ||
104 | if test $fu_cv_sys_stat_statfs2_bsize = yes; then | ||
105 | ac_fsusage_space=yes | ||
106 | AC_DEFINE(STAT_STATFS2_BSIZE, 1, | ||
107 | [ Define if statfs takes 2 args and struct statfs has a field named f_bsize. | ||
108 | (4.3BSD, SunOS 4, HP-UX, AIX PS/2)]) | ||
109 | fi | ||
110 | fi | ||
111 | |||
112 | if test $ac_fsusage_space = no; then | ||
113 | # SVR3 | ||
114 | AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) | ||
115 | AC_CACHE_VAL(fu_cv_sys_stat_statfs4, | ||
116 | [AC_TRY_RUN([#include <sys/types.h> | ||
117 | #include <sys/statfs.h> | ||
118 | main () | ||
119 | { | ||
120 | struct statfs fsd; | ||
121 | exit (statfs (".", &fsd, sizeof fsd, 0)); | ||
122 | }], | ||
123 | fu_cv_sys_stat_statfs4=yes, | ||
124 | fu_cv_sys_stat_statfs4=no, | ||
125 | fu_cv_sys_stat_statfs4=no)]) | ||
126 | AC_MSG_RESULT($fu_cv_sys_stat_statfs4) | ||
127 | if test $fu_cv_sys_stat_statfs4 = yes; then | ||
128 | ac_fsusage_space=yes | ||
129 | AC_DEFINE(STAT_STATFS4, 1, | ||
130 | [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)]) | ||
131 | fi | ||
132 | fi | ||
133 | |||
134 | if test $ac_fsusage_space = no; then | ||
135 | # 4.4BSD and NetBSD | ||
136 | AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl | ||
137 | member (4.4BSD and NetBSD)]) | ||
138 | AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize, | ||
139 | [AC_TRY_RUN([#include <sys/types.h> | ||
140 | #ifdef HAVE_SYS_PARAM_H | ||
141 | #include <sys/param.h> | ||
142 | #endif | ||
143 | #ifdef HAVE_SYS_MOUNT_H | ||
144 | #include <sys/mount.h> | ||
145 | #endif | ||
146 | main () | ||
147 | { | ||
148 | struct statfs fsd; | ||
149 | fsd.f_fsize = 0; | ||
150 | exit (statfs (".", &fsd)); | ||
151 | }], | ||
152 | fu_cv_sys_stat_statfs2_fsize=yes, | ||
153 | fu_cv_sys_stat_statfs2_fsize=no, | ||
154 | fu_cv_sys_stat_statfs2_fsize=no)]) | ||
155 | AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize) | ||
156 | if test $fu_cv_sys_stat_statfs2_fsize = yes; then | ||
157 | ac_fsusage_space=yes | ||
158 | AC_DEFINE(STAT_STATFS2_FSIZE, 1, | ||
159 | [ Define if statfs takes 2 args and struct statfs has a field named f_fsize. | ||
160 | (4.4BSD, NetBSD)]) | ||
161 | fi | ||
162 | fi | ||
163 | |||
164 | if test $ac_fsusage_space = no; then | ||
165 | # Ultrix | ||
166 | AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) | ||
167 | AC_CACHE_VAL(fu_cv_sys_stat_fs_data, | ||
168 | [AC_TRY_RUN([#include <sys/types.h> | ||
169 | #ifdef HAVE_SYS_PARAM_H | ||
170 | #include <sys/param.h> | ||
171 | #endif | ||
172 | #ifdef HAVE_SYS_MOUNT_H | ||
173 | #include <sys/mount.h> | ||
174 | #endif | ||
175 | #ifdef HAVE_SYS_FS_TYPES_H | ||
176 | #include <sys/fs_types.h> | ||
177 | #endif | ||
178 | main () | ||
179 | { | ||
180 | struct fs_data fsd; | ||
181 | /* Ultrix's statfs returns 1 for success, | ||
182 | 0 for not mounted, -1 for failure. */ | ||
183 | exit (statfs (".", &fsd) != 1); | ||
184 | }], | ||
185 | fu_cv_sys_stat_fs_data=yes, | ||
186 | fu_cv_sys_stat_fs_data=no, | ||
187 | fu_cv_sys_stat_fs_data=no)]) | ||
188 | AC_MSG_RESULT($fu_cv_sys_stat_fs_data) | ||
189 | if test $fu_cv_sys_stat_fs_data = yes; then | ||
190 | ac_fsusage_space=yes | ||
191 | AC_DEFINE(STAT_STATFS2_FS_DATA, 1, | ||
192 | [ Define if statfs takes 2 args and the second argument has | ||
193 | type struct fs_data. (Ultrix)]) | ||
194 | fi | ||
195 | fi | ||
196 | |||
197 | if test $ac_fsusage_space = no; then | ||
198 | # SVR2 | ||
199 | AC_TRY_CPP([#include <sys/filsys.h> | ||
200 | ], | ||
201 | AC_DEFINE(STAT_READ_FILSYS, 1, | ||
202 | [Define if there is no specific function for reading filesystems usage | ||
203 | information and you have the <sys/filsys.h> header file. (SVR2)]) | ||
204 | ac_fsusage_space=yes) | ||
205 | fi | ||
206 | |||
207 | AS_IF([test $ac_fsusage_space = yes], [$1], [$2]) | ||
208 | |||
209 | ]) | ||
210 | |||
211 | |||
212 | # Check for SunOS statfs brokenness wrt partitions 2GB and larger. | ||
213 | # If <sys/vfs.h> exists and struct statfs has a member named f_spare, | ||
214 | # enable the work-around code in fsusage.c. | ||
215 | AC_DEFUN([jm_STATFS_TRUNCATES], | ||
216 | [ | ||
217 | AC_MSG_CHECKING([for statfs that truncates block counts]) | ||
218 | AC_CACHE_VAL(fu_cv_sys_truncating_statfs, | ||
219 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
220 | #if !defined(sun) && !defined(__sun) | ||
221 | choke -- this is a workaround for a Sun-specific problem | ||
222 | #endif | ||
223 | #include <sys/types.h> | ||
224 | #include <sys/vfs.h>]], | ||
225 | [[struct statfs t; long c = *(t.f_spare);]])], | ||
226 | [fu_cv_sys_truncating_statfs=yes], | ||
227 | [fu_cv_sys_truncating_statfs=no])]) | ||
228 | if test $fu_cv_sys_truncating_statfs = yes; then | ||
229 | AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1, | ||
230 | [Define if the block counts reported by statfs may be truncated to 2GB | ||
231 | and the correct values may be stored in the f_spare array. | ||
232 | (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. | ||
233 | SunOS 4.1.1 seems not to be affected.)]) | ||
234 | fi | ||
235 | AC_MSG_RESULT($fu_cv_sys_truncating_statfs) | ||
236 | ]) | ||
237 | |||
238 | |||
239 | # Prerequisites of lib/fsusage.c not done by jm_FILE_SYSTEM_USAGE. | ||
240 | AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], | ||
241 | [ | ||
242 | AC_REQUIRE([jm_AC_TYPE_UINTMAX_T]) | ||
243 | AC_CHECK_HEADERS_ONCE(fcntl.h) | ||
244 | AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h sys/statvfs.h) | ||
245 | jm_STATFS_TRUNCATES | ||
246 | ]) | ||
diff --git a/lib/full-read.c b/lib/full-read.c new file mode 100644 index 0000000..1dc3e37 --- /dev/null +++ b/lib/full-read.c | |||
@@ -0,0 +1,19 @@ | |||
1 | /* An interface to read that retries after partial reads and interrupts. | ||
2 | Copyright (C) 2002, 2003 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | #define FULL_READ | ||
19 | #include "full-write.c" | ||
diff --git a/lib/full-write.c b/lib/full-write.c new file mode 100644 index 0000000..1513705 --- /dev/null +++ b/lib/full-write.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* An interface to read and write that retries (if necessary) until complete. | ||
2 | |||
3 | Copyright (C) 1993, 1994, 1997-2003 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
18 | |||
19 | #if HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | /* Specification. */ | ||
24 | #ifdef FULL_READ | ||
25 | # include "full-read.h" | ||
26 | #else | ||
27 | # include "full-write.h" | ||
28 | #endif | ||
29 | |||
30 | #include <errno.h> | ||
31 | #ifndef errno | ||
32 | extern int errno; | ||
33 | #endif | ||
34 | |||
35 | #ifdef FULL_READ | ||
36 | # include "safe-read.h" | ||
37 | # define safe_rw safe_read | ||
38 | # define full_rw full_read | ||
39 | # undef const | ||
40 | # define const /* empty */ | ||
41 | #else | ||
42 | # include "safe-write.h" | ||
43 | # define safe_rw safe_write | ||
44 | # define full_rw full_write | ||
45 | #endif | ||
46 | |||
47 | #ifdef FULL_READ | ||
48 | /* Set errno to zero upon EOF. */ | ||
49 | # define ZERO_BYTE_TRANSFER_ERRNO 0 | ||
50 | #else | ||
51 | /* Some buggy drivers return 0 when one tries to write beyond | ||
52 | a device's end. (Example: Linux 1.2.13 on /dev/fd0.) | ||
53 | Set errno to ENOSPC so they get a sensible diagnostic. */ | ||
54 | # define ZERO_BYTE_TRANSFER_ERRNO ENOSPC | ||
55 | #endif | ||
56 | |||
57 | /* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if | ||
58 | interrupted or if a partial write(read) occurs. Return the number | ||
59 | of bytes transferred. | ||
60 | When writing, set errno if fewer than COUNT bytes are written. | ||
61 | When reading, if fewer than COUNT bytes are read, you must examine | ||
62 | errno to distinguish failure from EOF (errno == 0). */ | ||
63 | size_t | ||
64 | full_rw (int fd, const void *buf, size_t count) | ||
65 | { | ||
66 | size_t total = 0; | ||
67 | const char *ptr = buf; | ||
68 | |||
69 | while (count > 0) | ||
70 | { | ||
71 | size_t n_rw = safe_rw (fd, ptr, count); | ||
72 | if (n_rw == (size_t) -1) | ||
73 | break; | ||
74 | if (n_rw == 0) | ||
75 | { | ||
76 | errno = ZERO_BYTE_TRANSFER_ERRNO; | ||
77 | break; | ||
78 | } | ||
79 | total += n_rw; | ||
80 | ptr += n_rw; | ||
81 | count -= n_rw; | ||
82 | } | ||
83 | |||
84 | return total; | ||
85 | } | ||
diff --git a/lib/full-write.h b/lib/full-write.h new file mode 100644 index 0000000..8cd2e81 --- /dev/null +++ b/lib/full-write.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* An interface to write() that writes all it is asked to write. | ||
2 | |||
3 | Copyright (C) 2002 Free Software Foundation, Inc. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
18 | |||
19 | #include <stddef.h> | ||
20 | |||
21 | /* Write COUNT bytes at BUF to descriptor FD, retrying if interrupted | ||
22 | or if partial writes occur. Return the number of bytes successfully | ||
23 | written, setting errno if that is less than COUNT. */ | ||
24 | extern size_t full_write (int fd, const void *buf, size_t count); | ||
diff --git a/lib/getopt.m4 b/lib/getopt.m4 deleted file mode 100644 index df602b9..0000000 --- a/lib/getopt.m4 +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | # getopt.m4 serial 2 | ||
2 | dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. | ||
3 | dnl This file is free software, distributed under the terms of the GNU | ||
4 | dnl General Public License. As a special exception to the GNU General | ||
5 | dnl Public License, this file may be distributed as part of a program | ||
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | |||
9 | AC_DEFUN([gl_GETOPT], | ||
10 | [ | ||
11 | dnl Prerequisites of lib/getopt.c. | ||
12 | : | ||
13 | ]) | ||
diff --git a/lib/ls-mntd-fs.m4 b/lib/ls-mntd-fs.m4 deleted file mode 100644 index c28466b..0000000 --- a/lib/ls-mntd-fs.m4 +++ /dev/null | |||
@@ -1,282 +0,0 @@ | |||
1 | #serial 14 | ||
2 | |||
3 | dnl From Jim Meyering. | ||
4 | dnl | ||
5 | dnl This is not pretty. I've just taken the autoconf code and wrapped | ||
6 | dnl it in an AC_DEFUN. | ||
7 | dnl | ||
8 | |||
9 | # jm_LIST_MOUNTED_FILESYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) | ||
10 | AC_DEFUN([jm_LIST_MOUNTED_FILESYSTEMS], | ||
11 | [ | ||
12 | AC_CHECK_FUNCS(listmntent getmntinfo) | ||
13 | AC_CHECK_HEADERS_ONCE(sys/param.h) | ||
14 | |||
15 | # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses | ||
16 | # NGROUPS (as the array dimension for a struct member) without a definition. | ||
17 | AC_CHECK_HEADERS(sys/ucred.h, [], [], [#include <grp.h>]) | ||
18 | |||
19 | AC_CHECK_HEADERS(mntent.h sys/mount.h sys/fs_types.h) | ||
20 | getfsstat_includes="\ | ||
21 | $ac_includes_default | ||
22 | #if HAVE_SYS_PARAM_H | ||
23 | # include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */ | ||
24 | #endif | ||
25 | #if HAVE_SYS_UCRED_H | ||
26 | # include <grp.h> /* needed for definition of NGROUPS */ | ||
27 | # include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */ | ||
28 | #endif | ||
29 | #if HAVE_SYS_MOUNT_H | ||
30 | # include <sys/mount.h> | ||
31 | #endif | ||
32 | #if HAVE_SYS_FS_TYPES_H | ||
33 | # include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */ | ||
34 | #endif | ||
35 | " | ||
36 | AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes]) | ||
37 | |||
38 | # Determine how to get the list of mounted filesystems. | ||
39 | ac_list_mounted_fs= | ||
40 | |||
41 | # If the getmntent function is available but not in the standard library, | ||
42 | # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX). | ||
43 | AC_FUNC_GETMNTENT | ||
44 | |||
45 | # This test must precede the ones for getmntent because Unicos-9 is | ||
46 | # reported to have the getmntent function, but its support is incompatible | ||
47 | # with other getmntent implementations. | ||
48 | |||
49 | # NOTE: Normally, I wouldn't use a check for system type as I've done for | ||
50 | # `CRAY' below since that goes against the whole autoconf philosophy. But | ||
51 | # I think there is too great a chance that some non-Cray system has a | ||
52 | # function named listmntent to risk the false positive. | ||
53 | |||
54 | if test -z "$ac_list_mounted_fs"; then | ||
55 | # Cray UNICOS 9 | ||
56 | AC_MSG_CHECKING([for listmntent of Cray/Unicos-9]) | ||
57 | AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent, | ||
58 | [fu_cv_sys_mounted_cray_listmntent=no | ||
59 | AC_EGREP_CPP(yes, | ||
60 | [#ifdef _CRAY | ||
61 | yes | ||
62 | #endif | ||
63 | ], [test $ac_cv_func_listmntent = yes \ | ||
64 | && fu_cv_sys_mounted_cray_listmntent=yes] | ||
65 | ) | ||
66 | ] | ||
67 | ) | ||
68 | AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent) | ||
69 | if test $fu_cv_sys_mounted_cray_listmntent = yes; then | ||
70 | ac_list_mounted_fs=found | ||
71 | AC_DEFINE(MOUNTED_LISTMNTENT, 1, | ||
72 | [Define if there is a function named listmntent that can be used to | ||
73 | list all mounted filesystems. (UNICOS)]) | ||
74 | fi | ||
75 | fi | ||
76 | |||
77 | if test -z "$ac_list_mounted_fs"; then | ||
78 | # AIX. | ||
79 | AC_MSG_CHECKING([for mntctl function and struct vmount]) | ||
80 | AC_CACHE_VAL(fu_cv_sys_mounted_vmount, | ||
81 | [AC_TRY_CPP([#include <fshelp.h>], | ||
82 | fu_cv_sys_mounted_vmount=yes, | ||
83 | fu_cv_sys_mounted_vmount=no)]) | ||
84 | AC_MSG_RESULT($fu_cv_sys_mounted_vmount) | ||
85 | if test $fu_cv_sys_mounted_vmount = yes; then | ||
86 | ac_list_mounted_fs=found | ||
87 | AC_DEFINE(MOUNTED_VMOUNT, 1, | ||
88 | [Define if there is a function named mntctl that can be used to read | ||
89 | the list of mounted filesystems, and there is a system header file | ||
90 | that declares `struct vmount.' (AIX)]) | ||
91 | fi | ||
92 | fi | ||
93 | |||
94 | if test $ac_cv_func_getmntent = yes; then | ||
95 | |||
96 | # This system has the getmntent function. | ||
97 | # Determine whether it's the one-argument variant or the two-argument one. | ||
98 | |||
99 | if test -z "$ac_list_mounted_fs"; then | ||
100 | # 4.3BSD, SunOS, HP-UX, Dynix, Irix | ||
101 | AC_MSG_CHECKING([for one-argument getmntent function]) | ||
102 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1, | ||
103 | [AC_TRY_COMPILE([ | ||
104 | /* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */ | ||
105 | #include <stdio.h> | ||
106 | |||
107 | #include <mntent.h> | ||
108 | #if !defined MOUNTED | ||
109 | # if defined _PATH_MOUNTED /* GNU libc */ | ||
110 | # define MOUNTED _PATH_MOUNTED | ||
111 | # endif | ||
112 | # if defined MNT_MNTTAB /* HP-UX. */ | ||
113 | # define MOUNTED MNT_MNTTAB | ||
114 | # endif | ||
115 | # if defined MNTTABNAME /* Dynix. */ | ||
116 | # define MOUNTED MNTTABNAME | ||
117 | # endif | ||
118 | #endif | ||
119 | ], | ||
120 | [ struct mntent *mnt = 0; char *table = MOUNTED; ], | ||
121 | fu_cv_sys_mounted_getmntent1=yes, | ||
122 | fu_cv_sys_mounted_getmntent1=no)]) | ||
123 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1) | ||
124 | if test $fu_cv_sys_mounted_getmntent1 = yes; then | ||
125 | ac_list_mounted_fs=found | ||
126 | AC_DEFINE(MOUNTED_GETMNTENT1, 1, | ||
127 | [Define if there is a function named getmntent for reading the list | ||
128 | of mounted filesystems, and that function takes a single argument. | ||
129 | (4.3BSD, SunOS, HP-UX, Dynix, Irix)]) | ||
130 | fi | ||
131 | fi | ||
132 | |||
133 | if test -z "$ac_list_mounted_fs"; then | ||
134 | # SVR4 | ||
135 | AC_MSG_CHECKING([for two-argument getmntent function]) | ||
136 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2, | ||
137 | [AC_EGREP_HEADER(getmntent, sys/mnttab.h, | ||
138 | fu_cv_sys_mounted_getmntent2=yes, | ||
139 | fu_cv_sys_mounted_getmntent2=no)]) | ||
140 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2) | ||
141 | if test $fu_cv_sys_mounted_getmntent2 = yes; then | ||
142 | ac_list_mounted_fs=found | ||
143 | AC_DEFINE(MOUNTED_GETMNTENT2, 1, | ||
144 | [Define if there is a function named getmntent for reading the list of | ||
145 | mounted filesystems, and that function takes two arguments. (SVR4)]) | ||
146 | fi | ||
147 | fi | ||
148 | |||
149 | fi | ||
150 | |||
151 | if test -z "$ac_list_mounted_fs"; then | ||
152 | # DEC Alpha running OSF/1, and Apple Darwin 1.3. | ||
153 | # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h | ||
154 | |||
155 | AC_MSG_CHECKING([for getfsstat function]) | ||
156 | AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat, | ||
157 | [AC_TRY_LINK([ | ||
158 | #include <sys/types.h> | ||
159 | #if HAVE_STRUCT_FSSTAT_F_FSTYPENAME | ||
160 | # define FS_TYPE(Ent) ((Ent).f_fstypename) | ||
161 | #else | ||
162 | # define FS_TYPE(Ent) mnt_names[(Ent).f_type] | ||
163 | #endif | ||
164 | ]$getfsstat_includes | ||
165 | , | ||
166 | [struct statfs *stats; | ||
167 | int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); | ||
168 | char *t = FS_TYPE (*stats); ], | ||
169 | fu_cv_sys_mounted_getfsstat=yes, | ||
170 | fu_cv_sys_mounted_getfsstat=no)]) | ||
171 | AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat) | ||
172 | if test $fu_cv_sys_mounted_getfsstat = yes; then | ||
173 | ac_list_mounted_fs=found | ||
174 | AC_DEFINE(MOUNTED_GETFSSTAT, 1, | ||
175 | [Define if there is a function named getfsstat for reading the | ||
176 | list of mounted filesystems. (DEC Alpha running OSF/1)]) | ||
177 | fi | ||
178 | fi | ||
179 | |||
180 | if test -z "$ac_list_mounted_fs"; then | ||
181 | # SVR3 | ||
182 | AC_MSG_CHECKING([for FIXME existence of three headers]) | ||
183 | AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp, | ||
184 | [AC_TRY_CPP([ | ||
185 | #include <sys/statfs.h> | ||
186 | #include <sys/fstyp.h> | ||
187 | #include <mnttab.h>], | ||
188 | fu_cv_sys_mounted_fread_fstyp=yes, | ||
189 | fu_cv_sys_mounted_fread_fstyp=no)]) | ||
190 | AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp) | ||
191 | if test $fu_cv_sys_mounted_fread_fstyp = yes; then | ||
192 | ac_list_mounted_fs=found | ||
193 | AC_DEFINE(MOUNTED_FREAD_FSTYP, 1, | ||
194 | [Define if (like SVR2) there is no specific function for reading the | ||
195 | list of mounted filesystems, and your system has these header files: | ||
196 | <sys/fstyp.h> and <sys/statfs.h>. (SVR3)]) | ||
197 | fi | ||
198 | fi | ||
199 | |||
200 | if test -z "$ac_list_mounted_fs"; then | ||
201 | # 4.4BSD and DEC OSF/1. | ||
202 | AC_MSG_CHECKING([for getmntinfo function]) | ||
203 | AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo, | ||
204 | [ | ||
205 | test "$ac_cv_func_getmntinfo" = yes \ | ||
206 | && fu_cv_sys_mounted_getmntinfo=yes \ | ||
207 | || fu_cv_sys_mounted_getmntinfo=no | ||
208 | ]) | ||
209 | AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) | ||
210 | if test $fu_cv_sys_mounted_getmntinfo = yes; then | ||
211 | ac_list_mounted_fs=found | ||
212 | AC_DEFINE(MOUNTED_GETMNTINFO, 1, | ||
213 | [Define if there is a function named getmntinfo for reading the | ||
214 | list of mounted filesystems. (4.4BSD, Darwin)]) | ||
215 | fi | ||
216 | fi | ||
217 | |||
218 | if test -z "$ac_list_mounted_fs"; then | ||
219 | # Ultrix | ||
220 | AC_MSG_CHECKING([for getmnt function]) | ||
221 | AC_CACHE_VAL(fu_cv_sys_mounted_getmnt, | ||
222 | [AC_TRY_CPP([ | ||
223 | #include <sys/fs_types.h> | ||
224 | #include <sys/mount.h>], | ||
225 | fu_cv_sys_mounted_getmnt=yes, | ||
226 | fu_cv_sys_mounted_getmnt=no)]) | ||
227 | AC_MSG_RESULT($fu_cv_sys_mounted_getmnt) | ||
228 | if test $fu_cv_sys_mounted_getmnt = yes; then | ||
229 | ac_list_mounted_fs=found | ||
230 | AC_DEFINE(MOUNTED_GETMNT, 1, | ||
231 | [Define if there is a function named getmnt for reading the list of | ||
232 | mounted filesystems. (Ultrix)]) | ||
233 | fi | ||
234 | fi | ||
235 | |||
236 | if test -z "$ac_list_mounted_fs"; then | ||
237 | # BeOS | ||
238 | AC_CHECK_FUNCS(next_dev fs_stat_dev) | ||
239 | AC_CHECK_HEADERS(fs_info.h) | ||
240 | AC_MSG_CHECKING([for BEOS mounted file system support functions]) | ||
241 | if test $ac_cv_header_fs_info_h = yes \ | ||
242 | && test $ac_cv_func_next_dev = yes \ | ||
243 | && test $ac_cv_func_fs_stat_dev = yes; then | ||
244 | fu_result=yes | ||
245 | else | ||
246 | fu_result=no | ||
247 | fi | ||
248 | AC_MSG_RESULT($fu_result) | ||
249 | if test $fu_result = yes; then | ||
250 | ac_list_mounted_fs=found | ||
251 | AC_DEFINE(MOUNTED_FS_STAT_DEV, 1, | ||
252 | [Define if there are functions named next_dev and fs_stat_dev for | ||
253 | reading the list of mounted filesystems. (BeOS)]) | ||
254 | fi | ||
255 | fi | ||
256 | |||
257 | if test -z "$ac_list_mounted_fs"; then | ||
258 | # SVR2 | ||
259 | AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab]) | ||
260 | AC_CACHE_VAL(fu_cv_sys_mounted_fread, | ||
261 | [AC_TRY_CPP([#include <mnttab.h>], | ||
262 | fu_cv_sys_mounted_fread=yes, | ||
263 | fu_cv_sys_mounted_fread=no)]) | ||
264 | AC_MSG_RESULT($fu_cv_sys_mounted_fread) | ||
265 | if test $fu_cv_sys_mounted_fread = yes; then | ||
266 | ac_list_mounted_fs=found | ||
267 | AC_DEFINE(MOUNTED_FREAD, 1, | ||
268 | [Define if there is no specific function for reading the list of | ||
269 | mounted filesystems. fread will be used to read /etc/mnttab. | ||
270 | (SVR2) ]) | ||
271 | fi | ||
272 | fi | ||
273 | |||
274 | if test -z "$ac_list_mounted_fs"; then | ||
275 | AC_MSG_ERROR([could not determine how to read list of mounted filesystems]) | ||
276 | # FIXME -- no need to abort building the whole package | ||
277 | # Can't build mountlist.c or anything that needs its functions | ||
278 | fi | ||
279 | |||
280 | AS_IF([test $ac_list_mounted_fs = found], [$1], [$2]) | ||
281 | |||
282 | ]) | ||
diff --git a/lib/onceonly.m4 b/lib/onceonly.m4 deleted file mode 100644 index 50b33f4..0000000 --- a/lib/onceonly.m4 +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | # onceonly.m4 serial 3 (gettext-0.12) | ||
2 | dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. | ||
3 | dnl This file is free software, distributed under the terms of the GNU | ||
4 | dnl General Public License. As a special exception to the GNU General | ||
5 | dnl Public License, this file may be distributed as part of a program | ||
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | |||
9 | dnl This file defines some "once only" variants of standard autoconf macros. | ||
10 | dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS | ||
11 | dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS | ||
12 | dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS | ||
13 | dnl AC_REQUIRE([AC_HEADER_STDC]) like AC_HEADER_STDC | ||
14 | dnl The advantage is that the check for each of the headers/functions/decls | ||
15 | dnl will be put only once into the 'configure' file. It keeps the size of | ||
16 | dnl the 'configure' file down, and avoids redundant output when 'configure' | ||
17 | dnl is run. | ||
18 | dnl The drawback is that the checks cannot be conditionalized. If you write | ||
19 | dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi | ||
20 | dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to | ||
21 | dnl empty, and the check will be inserted before the body of the AC_DEFUNed | ||
22 | dnl function. | ||
23 | |||
24 | dnl Autoconf version 2.57 or newer is recommended. | ||
25 | AC_PREREQ(2.54) | ||
26 | |||
27 | # AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of | ||
28 | # AC_CHECK_HEADERS(HEADER1 HEADER2 ...). | ||
29 | AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ | ||
30 | : | ||
31 | AC_FOREACH([gl_HEADER_NAME], [$1], [ | ||
32 | AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(m4_defn([gl_HEADER_NAME]), | ||
33 | [-./], [___])), [ | ||
34 | AC_CHECK_HEADERS(gl_HEADER_NAME) | ||
35 | ]) | ||
36 | AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, | ||
37 | [-./], [___]))) | ||
38 | ]) | ||
39 | ]) | ||
40 | |||
41 | # AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of | ||
42 | # AC_CHECK_FUNCS(FUNC1 FUNC2 ...). | ||
43 | AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ | ||
44 | : | ||
45 | AC_FOREACH([gl_FUNC_NAME], [$1], [ | ||
46 | AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ | ||
47 | AC_CHECK_FUNCS(m4_defn([gl_FUNC_NAME])) | ||
48 | ]) | ||
49 | AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) | ||
50 | ]) | ||
51 | ]) | ||
52 | |||
53 | # AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of | ||
54 | # AC_CHECK_DECLS(DECL1, DECL2, ...). | ||
55 | AC_DEFUN([AC_CHECK_DECLS_ONCE], [ | ||
56 | : | ||
57 | AC_FOREACH([gl_DECL_NAME], [$1], [ | ||
58 | AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ | ||
59 | AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) | ||
60 | ]) | ||
61 | AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) | ||
62 | ]) | ||
63 | ]) | ||
diff --git a/lib/safe-read.c b/lib/safe-read.c new file mode 100644 index 0000000..c21d1cf --- /dev/null +++ b/lib/safe-read.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* An interface to read and write that retries after interrupts. | ||
2 | Copyright (C) 1993, 1994, 1998, 2002-2003 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | #if HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | |||
22 | /* Specification. */ | ||
23 | #ifdef SAFE_WRITE | ||
24 | # include "safe-write.h" | ||
25 | #else | ||
26 | # include "safe-read.h" | ||
27 | #endif | ||
28 | |||
29 | /* Get ssize_t. */ | ||
30 | #include <sys/types.h> | ||
31 | #if HAVE_UNISTD_H | ||
32 | # include <unistd.h> | ||
33 | #endif | ||
34 | |||
35 | #include <errno.h> | ||
36 | #ifndef errno | ||
37 | extern int errno; | ||
38 | #endif | ||
39 | |||
40 | #ifdef EINTR | ||
41 | # define IS_EINTR(x) ((x) == EINTR) | ||
42 | #else | ||
43 | # define IS_EINTR(x) 0 | ||
44 | #endif | ||
45 | |||
46 | #include <limits.h> | ||
47 | |||
48 | #ifdef SAFE_WRITE | ||
49 | # define safe_rw safe_write | ||
50 | # define rw write | ||
51 | #else | ||
52 | # define safe_rw safe_read | ||
53 | # define rw read | ||
54 | # undef const | ||
55 | # define const /* empty */ | ||
56 | #endif | ||
57 | |||
58 | /* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if | ||
59 | interrupted. Return the actual number of bytes read(written), zero for EOF, | ||
60 | or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */ | ||
61 | size_t | ||
62 | safe_rw (int fd, void const *buf, size_t count) | ||
63 | { | ||
64 | ssize_t result; | ||
65 | |||
66 | /* POSIX limits COUNT to SSIZE_MAX, but we limit it further, requiring | ||
67 | that COUNT <= INT_MAX, to avoid triggering a bug in Tru64 5.1. | ||
68 | When decreasing COUNT, keep the file pointer block-aligned. | ||
69 | Note that in any case, read(write) may succeed, yet read(write) | ||
70 | fewer than COUNT bytes, so the caller must be prepared to handle | ||
71 | partial results. */ | ||
72 | if (count > INT_MAX) | ||
73 | count = INT_MAX & ~8191; | ||
74 | |||
75 | do | ||
76 | { | ||
77 | result = rw (fd, buf, count); | ||
78 | } | ||
79 | while (result < 0 && IS_EINTR (errno)); | ||
80 | |||
81 | return (size_t) result; | ||
82 | } | ||
diff --git a/lib/safe-read.h b/lib/safe-read.h new file mode 100644 index 0000000..cbe6e0b --- /dev/null +++ b/lib/safe-read.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* An interface to read() that retries after interrupts. | ||
2 | Copyright (C) 2002 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | #include <stddef.h> | ||
19 | |||
20 | #define SAFE_READ_ERROR ((size_t) -1) | ||
21 | |||
22 | /* Read up to COUNT bytes at BUF from descriptor FD, retrying if interrupted. | ||
23 | Return the actual number of bytes read, zero for EOF, or SAFE_READ_ERROR | ||
24 | upon error. */ | ||
25 | extern size_t safe_read (int fd, void *buf, size_t count); | ||
diff --git a/lib/safe-write.c b/lib/safe-write.c new file mode 100644 index 0000000..fbafa7c --- /dev/null +++ b/lib/safe-write.c | |||
@@ -0,0 +1,19 @@ | |||
1 | /* An interface to write that retries after interrupts. | ||
2 | Copyright (C) 2002 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | #define SAFE_WRITE | ||
19 | #include "safe-read.c" | ||
diff --git a/lib/safe-write.h b/lib/safe-write.h new file mode 100644 index 0000000..ab1f45b --- /dev/null +++ b/lib/safe-write.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* An interface to write() that retries after interrupts. | ||
2 | Copyright (C) 2002 Free Software Foundation, Inc. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | #include <stddef.h> | ||
19 | |||
20 | #define SAFE_WRITE_ERROR ((size_t) -1) | ||
21 | |||
22 | /* Write up to COUNT bytes at BUF to descriptor FD, retrying if interrupted. | ||
23 | Return the actual number of bytes written, zero for EOF, or SAFE_WRITE_ERROR | ||
24 | upon error. */ | ||
25 | extern size_t safe_write (int fd, const void *buf, size_t count); | ||
diff --git a/lib/unlocked-io.m4 b/lib/unlocked-io.m4 deleted file mode 100644 index f8e98f1..0000000 --- a/lib/unlocked-io.m4 +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #serial 8 -*- autoconf -*- | ||
2 | |||
3 | dnl From Jim Meyering. | ||
4 | dnl | ||
5 | dnl See if the glibc *_unlocked I/O macros or functions are available. | ||
6 | dnl Use only those *_unlocked macros or functions that are declared | ||
7 | dnl (because some of them were declared in Solaris 2.5.1 but were removed | ||
8 | dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run | ||
9 | dnl on Solaris 2.6). | ||
10 | |||
11 | AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO], | ||
12 | [ | ||
13 | dnl Persuade glibc and Solaris <stdio.h> to declare | ||
14 | dnl fgets_unlocked(), fputs_unlocked() etc. | ||
15 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
16 | |||
17 | AC_CHECK_DECLS_ONCE( | ||
18 | [clearerr_unlocked feof_unlocked ferror_unlocked | ||
19 | fflush_unlocked fgets_unlocked fputc_unlocked fputs_unlocked | ||
20 | fread_unlocked fwrite_unlocked getc_unlocked | ||
21 | getchar_unlocked putc_unlocked putchar_unlocked]) | ||
22 | ]) | ||
diff --git a/lib/xalloc.m4 b/lib/xalloc.m4 deleted file mode 100644 index dec8417..0000000 --- a/lib/xalloc.m4 +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | # xalloc.m4 serial 8 | ||
2 | dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. | ||
3 | dnl This file is free software, distributed under the terms of the GNU | ||
4 | dnl General Public License. As a special exception to the GNU General | ||
5 | dnl Public License, this file may be distributed as part of a program | ||
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | |||
9 | AC_DEFUN([gl_XALLOC], | ||
10 | [ | ||
11 | gl_PREREQ_XALLOC | ||
12 | gl_PREREQ_XMALLOC | ||
13 | gl_PREREQ_XSTRDUP | ||
14 | ]) | ||
15 | |||
16 | # Prerequisites of lib/xalloc.h. | ||
17 | AC_DEFUN([gl_PREREQ_XALLOC], [ | ||
18 | : | ||
19 | ]) | ||
20 | |||
21 | # Prerequisites of lib/xmalloc.c. | ||
22 | AC_DEFUN([gl_PREREQ_XMALLOC], [ | ||
23 | AC_REQUIRE([AC_C_INLINE]) | ||
24 | AC_REQUIRE([jm_FUNC_MALLOC]) | ||
25 | AC_REQUIRE([jm_FUNC_REALLOC]) | ||
26 | : | ||
27 | ]) | ||
28 | |||
29 | # Prerequisites of lib/xstrdup.c. | ||
30 | AC_DEFUN([gl_PREREQ_XSTRDUP], [ | ||
31 | : | ||
32 | ]) | ||