summaryrefslogtreecommitdiff
path: root/pkgtools/libnbcompat
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2004-08-23 03:32:12 +0000
committerjlam <jlam@pkgsrc.org>2004-08-23 03:32:12 +0000
commitf8dd9611442914c779dc2594d00f2334eb959510 (patch)
tree207944b8d6951a04fbda0f135a565faed908b369 /pkgtools/libnbcompat
parent82a2073e0ea3d79db49bc9223f9ac229f3d54955 (diff)
downloadpkgsrc-f8dd9611442914c779dc2594d00f2334eb959510.tar.gz
Update pkgtools/libnbcompat to 20040822. Changes from version 20040814
include: * Rework the way that poll() is detected so that it more closely follows how the rest of the replacement functions are detected. * Split err*() and warn*() functions into separate err.c and warn.c files so that we can more finely isolate the objects files pulled in by the linker. This should fix building textproc/nbsed on Solaris. * Move more definitions from nbcompat.h into nbcompat/*.h. This makes it more clear which NetBSD headers are expected to provide which function declarations and macro definitions. * Clean out nbconfig.h by moving all of the relevant definitions into the correct nbcompat/*.h files. * Update all of the library functions to the latest from src HEAD. Also change the way that sources are modified when imported -- we now include <nbcompat.h> before the first system header, include <nbcompat/*.h> versions of headers instead of system ones where available, and "#if 0" the sections that make no sense when being built outside of the NetBSD source tree. This should make future updates from src HEAD, e.g. for security updates or bug fixes, easier. * Move all private headers into a subdirectory and include the headers from the private directory. This avoids any nameclashes with system headers with the same name.
Diffstat (limited to 'pkgtools/libnbcompat')
-rw-r--r--pkgtools/libnbcompat/Makefile4
-rw-r--r--pkgtools/libnbcompat/PLIST11
-rw-r--r--pkgtools/libnbcompat/buildlink3.mk4
-rw-r--r--pkgtools/libnbcompat/files/Makefile.in15
-rw-r--r--pkgtools/libnbcompat/files/README27
-rw-r--r--pkgtools/libnbcompat/files/__fts13.c78
-rw-r--r--pkgtools/libnbcompat/files/__glob13.c1040
-rw-r--r--pkgtools/libnbcompat/files/__unsetenv13.c124
-rwxr-xr-xpkgtools/libnbcompat/files/configure564
-rw-r--r--pkgtools/libnbcompat/files/configure.ac225
-rw-r--r--pkgtools/libnbcompat/files/err.c89
-rw-r--r--pkgtools/libnbcompat/files/fgetln.c37
-rw-r--r--pkgtools/libnbcompat/files/findenv.c88
-rw-r--r--pkgtools/libnbcompat/files/fnmatch.c30
-rw-r--r--pkgtools/libnbcompat/files/fparseln.c47
-rw-r--r--pkgtools/libnbcompat/files/fts.c12
-rw-r--r--pkgtools/libnbcompat/files/getenv.c81
-rw-r--r--pkgtools/libnbcompat/files/getopt_long.c47
-rw-r--r--pkgtools/libnbcompat/files/gettemp.c180
-rw-r--r--pkgtools/libnbcompat/files/glob.c882
-rw-r--r--pkgtools/libnbcompat/files/isblank.c51
-rw-r--r--pkgtools/libnbcompat/files/lchflags.c9
-rw-r--r--pkgtools/libnbcompat/files/lchmod.c9
-rw-r--r--pkgtools/libnbcompat/files/lchown.c7
-rw-r--r--pkgtools/libnbcompat/files/lutimes.c9
-rw-r--r--pkgtools/libnbcompat/files/md5c.c43
-rw-r--r--pkgtools/libnbcompat/files/md5hl.c122
-rw-r--r--pkgtools/libnbcompat/files/mdXhl.c105
-rw-r--r--pkgtools/libnbcompat/files/mkdtemp.c126
-rw-r--r--pkgtools/libnbcompat/files/mkstemp.c127
-rw-r--r--pkgtools/libnbcompat/files/nbcompat.h104
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/assert.h54
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/cdefs.h95
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/config.h.in169
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/ctype.h54
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/dirent.h65
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/endian.h79
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/err.h25
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/getopt.h11
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/limits.h6
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/param.h57
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/regex.h10
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/stat.h6
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/statvfs.h11
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/stdlib.h8
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/termcap.h59
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/types.h59
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/unistd.h11
-rw-r--r--pkgtools/libnbcompat/files/nbcompat/vis.h17
-rw-r--r--pkgtools/libnbcompat/files/poll.c8
-rw-r--r--pkgtools/libnbcompat/files/private/cclass.h (renamed from pkgtools/libnbcompat/files/cclass.h)2
-rw-r--r--pkgtools/libnbcompat/files/private/cname.h (renamed from pkgtools/libnbcompat/files/cname.h)2
-rw-r--r--pkgtools/libnbcompat/files/private/pwcache.h (renamed from pkgtools/libnbcompat/files/pwcache.h)25
-rw-r--r--pkgtools/libnbcompat/files/private/regex2.h (renamed from pkgtools/libnbcompat/files/regex2.h)2
-rw-r--r--pkgtools/libnbcompat/files/private/utils.h (renamed from pkgtools/libnbcompat/files/utils.h)6
-rw-r--r--pkgtools/libnbcompat/files/pwcache.c87
-rw-r--r--pkgtools/libnbcompat/files/regcomp.c57
-rw-r--r--pkgtools/libnbcompat/files/regerror.c51
-rw-r--r--pkgtools/libnbcompat/files/regexec.c53
-rw-r--r--pkgtools/libnbcompat/files/regfree.c41
-rw-r--r--pkgtools/libnbcompat/files/rmd160.c52
-rw-r--r--pkgtools/libnbcompat/files/rmd160hl.c34
-rw-r--r--pkgtools/libnbcompat/files/setenv.c167
-rw-r--r--pkgtools/libnbcompat/files/setgroupent.c11
-rw-r--r--pkgtools/libnbcompat/files/setmode.c67
-rw-r--r--pkgtools/libnbcompat/files/setpassent.c11
-rw-r--r--pkgtools/libnbcompat/files/setprogname.c79
-rw-r--r--pkgtools/libnbcompat/files/sha1.c43
-rw-r--r--pkgtools/libnbcompat/files/sha1hl.c48
-rw-r--r--pkgtools/libnbcompat/files/snprintf.c8
-rw-r--r--pkgtools/libnbcompat/files/statvfs.c12
-rw-r--r--pkgtools/libnbcompat/files/strdup.c34
-rw-r--r--pkgtools/libnbcompat/files/strerror.c5
-rw-r--r--pkgtools/libnbcompat/files/strlcat.c46
-rw-r--r--pkgtools/libnbcompat/files/strlcpy.c71
-rw-r--r--pkgtools/libnbcompat/files/strmode.c36
-rw-r--r--pkgtools/libnbcompat/files/strsep.c34
-rw-r--r--pkgtools/libnbcompat/files/strtoll.c51
-rw-r--r--pkgtools/libnbcompat/files/unsetenv.c12
-rw-r--r--pkgtools/libnbcompat/files/unvis.c53
-rw-r--r--pkgtools/libnbcompat/files/usleep.c8
-rw-r--r--pkgtools/libnbcompat/files/utimes.c9
-rw-r--r--pkgtools/libnbcompat/files/vis.c195
-rw-r--r--pkgtools/libnbcompat/files/warn.c115
84 files changed, 4024 insertions, 2604 deletions
diff --git a/pkgtools/libnbcompat/Makefile b/pkgtools/libnbcompat/Makefile
index e4bf9883bb0..cc605f0701b 100644
--- a/pkgtools/libnbcompat/Makefile
+++ b/pkgtools/libnbcompat/Makefile
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.39 2004/08/16 17:24:56 jlam Exp $
+# $NetBSD: Makefile,v 1.40 2004/08/23 03:32:12 jlam Exp $
#
# NOTE: If you update this package, it is *mandatory* that you update
# pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual
# list of tested and supported platforms.
#
-DISTNAME= libnbcompat-20040814
+DISTNAME= libnbcompat-20040822
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/libnbcompat/PLIST b/pkgtools/libnbcompat/PLIST
index aba98747f73..29a5a82f7c1 100644
--- a/pkgtools/libnbcompat/PLIST
+++ b/pkgtools/libnbcompat/PLIST
@@ -1,5 +1,10 @@
-@comment $NetBSD: PLIST,v 1.12 2004/08/10 18:47:55 jlam Exp $
+@comment $NetBSD: PLIST,v 1.13 2004/08/23 03:32:12 jlam Exp $
include/nbcompat.h
+include/nbcompat/assert.h
+include/nbcompat/cdefs.h
+include/nbcompat/ctype.h
+include/nbcompat/dirent.h
+include/nbcompat/endian.h
include/nbcompat/err.h
include/nbcompat/fnmatch.h
include/nbcompat/fts.h
@@ -10,10 +15,12 @@ include/nbcompat/limits.h
include/nbcompat/md5.h
include/nbcompat/nbconfig.h
include/nbcompat/nbtypes.h
+include/nbcompat/param.h
include/nbcompat/paths.h
include/nbcompat/poll.h
include/nbcompat/pwd.h
include/nbcompat/queue.h
+include/nbcompat/regex.h
include/nbcompat/rmd160.h
include/nbcompat/sha1.h
include/nbcompat/stat.h
@@ -21,7 +28,9 @@ include/nbcompat/statvfs.h
include/nbcompat/stdio.h
include/nbcompat/stdlib.h
include/nbcompat/string.h
+include/nbcompat/termcap.h
include/nbcompat/time.h
+include/nbcompat/types.h
include/nbcompat/tzfile.h
include/nbcompat/unistd.h
include/nbcompat/util.h
diff --git a/pkgtools/libnbcompat/buildlink3.mk b/pkgtools/libnbcompat/buildlink3.mk
index b4c12ed8aab..29831d5db61 100644
--- a/pkgtools/libnbcompat/buildlink3.mk
+++ b/pkgtools/libnbcompat/buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.10 2004/08/16 17:24:56 jlam Exp $
+# $NetBSD: buildlink3.mk,v 1.11 2004/08/23 03:32:12 jlam Exp $
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
LIBNBCOMPAT_BUILDLINK3_MK:= ${LIBNBCOMPAT_BUILDLINK3_MK}+
@@ -11,7 +11,7 @@ BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Nlibnbcompat}
BUILDLINK_PACKAGES+= libnbcompat
.if !empty(LIBNBCOMPAT_BUILDLINK3_MK:M+)
-BUILDLINK_DEPENDS.libnbcompat+= libnbcompat>=20040814
+BUILDLINK_DEPENDS.libnbcompat+= libnbcompat>=20040822
BUILDLINK_PKGSRCDIR.libnbcompat?= ../../pkgtools/libnbcompat
BUILDLINK_DEPMETHOD.libnbcompat?= build
BUILDLINK_LDADD.libnbcompat= -lnbcompat
diff --git a/pkgtools/libnbcompat/files/Makefile.in b/pkgtools/libnbcompat/files/Makefile.in
index 0ac426a02cf..1f275f141fd 100644
--- a/pkgtools/libnbcompat/files/Makefile.in
+++ b/pkgtools/libnbcompat/files/Makefile.in
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.26 2004/08/21 06:36:13 jlam Exp $
+# $NetBSD: Makefile.in,v 1.27 2004/08/23 03:32:12 jlam Exp $
#
srcdir= @srcdir@
@@ -20,6 +20,11 @@ RANLIB= @RANLIB@
LIB= libnbcompat.a
INCS= nbcompat.h \
+ nbcompat/assert.h \
+ nbcompat/cdefs.h \
+ nbcompat/ctype.h \
+ nbcompat/dirent.h \
+ nbcompat/endian.h \
nbcompat/err.h \
nbcompat/fnmatch.h \
nbcompat/fts.h \
@@ -30,6 +35,7 @@ INCS= nbcompat.h \
nbcompat/md5.h \
nbcompat/nbconfig.h \
nbcompat/nbtypes.h \
+ nbcompat/param.h \
nbcompat/paths.h \
nbcompat/poll.h \
nbcompat/pwd.h \
@@ -42,14 +48,15 @@ INCS= nbcompat.h \
nbcompat/stdio.h \
nbcompat/stdlib.h \
nbcompat/string.h \
+ nbcompat/termcap.h \
nbcompat/time.h \
+ nbcompat/types.h \
nbcompat/tzfile.h \
nbcompat/unistd.h \
nbcompat/util.h \
nbcompat/vis.h
-# always use our local glob() implementation.
-OBJS= glob.o @LIBOBJS@
+OBJS= @LIBOBJS@
LINK= $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@
COMPILE= $(CC) $(CPPFLAGS) $(CFLAGS)
@@ -70,7 +77,7 @@ nbcompat/nbtypes.h: bits
./bits $@
bits: bits.c
- $(CC) -o bits bits.c
+ $(COMPILE) $(DEFS) -o bits bits.c
install:
$(INSTALL) -m 755 -d $(prefix)/lib
diff --git a/pkgtools/libnbcompat/files/README b/pkgtools/libnbcompat/files/README
index c13119bd39b..b342f61a7dc 100644
--- a/pkgtools/libnbcompat/files/README
+++ b/pkgtools/libnbcompat/files/README
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.9 2004/08/20 23:30:30 schmonz Exp $
+$NetBSD: README,v 1.10 2004/08/23 03:32:12 jlam Exp $
0 Introduction
==============
@@ -13,6 +13,7 @@ this includes the following packages:
archivers/pax
pkgtools/mtree
pkgtools/pkg_install
+ textproc/nbsed
A script, src2nbcompat, is also included in the sources that simplifies
importing software from the NetBSD src module into pkgsrc.
@@ -43,22 +44,24 @@ breakage seep in. Proper methodology for updating this package is:
*NOTE* the most recent libnbcompat.
*NOTE*
-libnbcompat-20040814 has been tested to build and install correctly
+libnbcompat-20040822 has been tested to build and install correctly
on the following operating systems:
FreeBSD-4.8/i386 <jlam@NetBSD.org>
- Debian Linux 3.0 (woody) <wiz@NetBSD.org>
- Interix 3.5 <schmonz@NetBSD.org>
+ FreeBSD-5.1/alpha <grant@NetBSD.org>
IRIX 6.5 <schmonz@NetBSD.org>
MacOS X 10.2.8 <jlam@NetBSD.org>
MacOS X 10.3.5 <schmonz@NetBSD.org>
+ MS Interix 3.5 <schmonz@NetBSD.org>
+ NetBSD-1.5/i386 <cgd@NetBSD.org>
NetBSD-1.6.2/i386 <jlam@NetBSD.org>
- NetBSD-2.0_BETA/i386 <wiz@NetBSD.org>
- Red Hat Linux 7.3 <schmonz@NetBSD.org>
- Red Hat Enterprise Linux 3 <schmonz@NetBSD.org>
- Solaris 7/sparc <blsecres@ssdtgsm.com>
- Solaris 8/sparc <roland.illig@gmx.de>
- Solaris 9/sparc <schmonz@NetBSD.org>
+ NetBSD-2.0_BETA/i386 <schmonz@NetBSD.org>
+ Red Hat Linux 6.0/i386 <cgd@NetBSD.org>
+ Red Hat Linux 7.2/i386 <cgd@NetBSD.org>
+ Red Hat Linux 7.3/i386 <cgd@NetBSD.org>
+ Solaris 2.6/sparc <cgd@NetBSD.org>
+ Solaris 8/sparc <cgd@NetBSD.org>
+ Solaris 9/sparc <grant@NetBSD.org>
3 Usage
@@ -68,7 +71,9 @@ This library is intended to simplify porting NetBSD software. To that
end, the changes to NetBSD sources to use libnbcompat are minor. The
procedure is:
- (1) Add #include <nbcompat.h> at the top of the source file.
+ (1) Add #include <nbcompat.h> at the top of the source files that
+ include system headers, but below the inclusion of any
+ "config.h".
(2) Surround each system header file included in the source file
with #if HAVE_<header_name>_H ... #endif.
diff --git a/pkgtools/libnbcompat/files/__fts13.c b/pkgtools/libnbcompat/files/__fts13.c
index ed0457a8b7f..2d1bcff73cf 100644
--- a/pkgtools/libnbcompat/files/__fts13.c
+++ b/pkgtools/libnbcompat/files/__fts13.c
@@ -1,4 +1,4 @@
-/* $NetBSD: __fts13.c,v 1.6 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: __fts13.c,v 1.7 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -29,62 +29,44 @@
* SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#else
-__RCSID("$NetBSD: __fts13.c,v 1.6 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: __fts13.c,v 1.7 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
-
-#if HAVE_DIRENT_H
-#include <dirent.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/param.h>
+#include <nbcompat/stat.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/dirent.h>
#if HAVE_ERRNO_H
#include <errno.h>
#endif
-
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#include <nbcompat/fts.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#include "nbcompat/fts.h"
-
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if !HAVE_CONFIG_H
+#if 0
+#if ! HAVE_NBTOOL_CONFIG_H
#define HAVE_STRUCT_DIRENT_D_NAMLEN 1
#endif
+#endif
#if 0
#ifdef __weak_alias
@@ -104,6 +86,7 @@ __weak_alias(fts_set,_fts_set)
#define STAT stat
#endif
+#if 0
#ifdef __LIBC12_SOURCE__
__warn_references(fts_children,
"warning: reference to compatibility fts_children();"
@@ -121,6 +104,7 @@ __warn_references(fts_set,
"warning: reference to compatibility fts_set();"
" include <fts.h> for correct reference")
#endif
+#endif
static FTSENT *fts_alloc __P((FTS *, const char *, size_t));
static FTSENT *fts_build __P((FTS *, int));
@@ -153,18 +137,6 @@ static int fts_safe_changedir __P((const FTS *, const FTSENT *, int,
#undef FTS_WHITEOUT
#endif
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
-#ifndef MAX
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
FTS *
fts_open(argv, options, compar)
char * const *argv;
@@ -648,14 +620,6 @@ fts_children(sp, instr)
return (sp->fts_child);
}
-#if !defined(HAVE_DIRFD) && !defined(dirfd) && !(defined __GLIBC__ && __GLIBC__ >= 2)
-static int
-dirfd(DIR *dirp)
-{
- return (dirp == NULL) ? -1 : dirp->dd_fd;
-}
-#endif
-
/*
* This is the tricky part -- do not casually change *anything* in here. The
* idea is to build the linked list of entries that are used by fts_children
diff --git a/pkgtools/libnbcompat/files/__glob13.c b/pkgtools/libnbcompat/files/__glob13.c
new file mode 100644
index 00000000000..43f7d3414c8
--- /dev/null
+++ b/pkgtools/libnbcompat/files/__glob13.c
@@ -0,0 +1,1040 @@
+/* $NetBSD: __glob13.c,v 1.1 2004/08/23 03:32:12 jlam Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Guido van Rossum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
+#else
+__RCSID("$NetBSD: __glob13.c,v 1.1 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * glob(3) -- a superset of the one defined in POSIX 1003.2.
+ *
+ * The [!...] convention to negate a range is supported (SysV, Posix, ksh).
+ *
+ * Optional extra services, controlled by flags not defined by POSIX:
+ *
+ * GLOB_MAGCHAR:
+ * Set in gl_flags if pattern contained a globbing character.
+ * GLOB_NOMAGIC:
+ * Same as GLOB_NOCHECK, but it will only append pattern if it did
+ * not contain any magic characters. [Used in csh style globbing]
+ * GLOB_ALTDIRFUNC:
+ * Use alternately specified directory access functions.
+ * GLOB_TILDE:
+ * expand ~user/foo to the /home/dir/of/user/foo
+ * GLOB_BRACE:
+ * expand {1,2}{a,b} to 1a 1b 2a 2b
+ * gl_matchc:
+ * Number of matches in the current invocation of glob.
+ */
+
+#if 0
+#include "namespace.h"
+#endif
+#include <nbcompat/param.h>
+#include <nbcompat/stat.h>
+
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/dirent.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/glob.h>
+#include <nbcompat/pwd.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
+
+#if 0
+#ifdef __weak_alias
+#ifdef __LIBC12_SOURCE__
+__weak_alias(glob,_glob)
+__weak_alias(globfree,_globfree)
+#endif /* __LIBC12_SOURCE__ */
+#endif /* __weak_alias */
+#endif
+
+/*
+ * XXX: For NetBSD 1.4.x compatibility. (kill me l8r)
+ */
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(a)
+#endif
+
+#ifdef __LIBC12_SOURCE__
+#define STAT stat12
+#else
+#define STAT stat
+#endif
+
+#ifdef __LIBC12_SOURCE__
+__warn_references(glob,
+ "warning: reference to compatibility glob(); include <glob.h> for correct reference")
+__warn_references(globfree,
+ "warning: reference to compatibility globfree(); include <glob.h> for correct reference")
+#endif
+
+#define DOLLAR '$'
+#define DOT '.'
+#define EOS '\0'
+#define LBRACKET '['
+#define NOT '!'
+#define QUESTION '?'
+#define QUOTE '\\'
+#define RANGE '-'
+#define RBRACKET ']'
+#define SEP '/'
+#define STAR '*'
+#define TILDE '~'
+#define UNDERSCORE '_'
+#define LBRACE '{'
+#define RBRACE '}'
+#define SLASH '/'
+#define COMMA ','
+
+#ifndef DEBUG
+
+#define M_QUOTE 0x8000
+#define M_PROTECT 0x4000
+#define M_MASK 0xffff
+#define M_ASCII 0x00ff
+
+typedef u_short Char;
+
+#else
+
+#define M_QUOTE 0x80
+#define M_PROTECT 0x40
+#define M_MASK 0xff
+#define M_ASCII 0x7f
+
+typedef char Char;
+
+#endif
+
+
+#define CHAR(c) ((Char)((c)&M_ASCII))
+#define META(c) ((Char)((c)|M_QUOTE))
+#define M_ALL META('*')
+#define M_END META(']')
+#define M_NOT META('!')
+#define M_ONE META('?')
+#define M_RNG META('-')
+#define M_SET META('[')
+#define ismeta(c) (((c)&M_QUOTE) != 0)
+
+
+static int compare __P((const void *, const void *));
+static int g_Ctoc __P((const Char *, char *, size_t));
+static int g_lstat __P((Char *, struct STAT *, glob_t *));
+static DIR *g_opendir __P((Char *, glob_t *));
+static Char *g_strchr __P((const Char *, int));
+static int g_stat __P((Char *, struct STAT *, glob_t *));
+static int glob0 __P((const Char *, glob_t *));
+static int glob1 __P((Char *, glob_t *, size_t *));
+static int glob2 __P((Char *, Char *, Char *, Char *, glob_t *,
+ size_t *));
+static int glob3 __P((Char *, Char *, Char *, Char *, Char *, glob_t *,
+ size_t *));
+static int globextend __P((const Char *, glob_t *, size_t *));
+static const Char *globtilde __P((const Char *, Char *, size_t, glob_t *));
+static int globexp1 __P((const Char *, glob_t *));
+static int globexp2 __P((const Char *, const Char *, glob_t *, int *));
+static int match __P((Char *, Char *, Char *));
+#ifdef DEBUG
+static void qprintf __P((const char *, Char *));
+#endif
+
+int
+glob(pattern, flags, errfunc, pglob)
+ const char *pattern;
+ int flags, (*errfunc) __P((const char *, int));
+ glob_t *pglob;
+{
+ const u_char *patnext;
+ int c;
+ Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
+
+ _DIAGASSERT(pattern != NULL);
+
+ patnext = (const u_char *) pattern;
+ if (!(flags & GLOB_APPEND)) {
+ pglob->gl_pathc = 0;
+ pglob->gl_pathv = NULL;
+ if (!(flags & GLOB_DOOFFS))
+ pglob->gl_offs = 0;
+ }
+ pglob->gl_flags = flags & ~GLOB_MAGCHAR;
+ pglob->gl_errfunc = errfunc;
+ pglob->gl_matchc = 0;
+
+ bufnext = patbuf;
+ bufend = bufnext + MAXPATHLEN;
+ if (flags & GLOB_NOESCAPE) {
+ while (bufnext < bufend && (c = *patnext++) != EOS)
+ *bufnext++ = c;
+ } else {
+ /* Protect the quoted characters. */
+ while (bufnext < bufend && (c = *patnext++) != EOS)
+ if (c == QUOTE) {
+ if ((c = *patnext++) == EOS) {
+ c = QUOTE;
+ --patnext;
+ }
+ *bufnext++ = c | M_PROTECT;
+ }
+ else
+ *bufnext++ = c;
+ }
+ *bufnext = EOS;
+
+ if (flags & GLOB_BRACE)
+ return globexp1(patbuf, pglob);
+ else
+ return glob0(patbuf, pglob);
+}
+
+/*
+ * Expand recursively a glob {} pattern. When there is no more expansion
+ * invoke the standard globbing routine to glob the rest of the magic
+ * characters
+ */
+static int
+globexp1(pattern, pglob)
+ const Char *pattern;
+ glob_t *pglob;
+{
+ const Char* ptr = pattern;
+ int rv;
+
+ _DIAGASSERT(pattern != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ /* Protect a single {}, for find(1), like csh */
+ if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
+ return glob0(pattern, pglob);
+
+ while ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)
+ if (!globexp2(ptr, pattern, pglob, &rv))
+ return rv;
+
+ return glob0(pattern, pglob);
+}
+
+
+/*
+ * Recursive brace globbing helper. Tries to expand a single brace.
+ * If it succeeds then it invokes globexp1 with the new pattern.
+ * If it fails then it tries to glob the rest of the pattern and returns.
+ */
+static int
+globexp2(ptr, pattern, pglob, rv)
+ const Char *ptr, *pattern;
+ glob_t *pglob;
+ int *rv;
+{
+ int i;
+ Char *lm, *ls;
+ const Char *pe, *pm, *pl;
+ Char patbuf[MAXPATHLEN + 1];
+
+ _DIAGASSERT(ptr != NULL);
+ _DIAGASSERT(pattern != NULL);
+ _DIAGASSERT(pglob != NULL);
+ _DIAGASSERT(rv != NULL);
+
+ /* copy part up to the brace */
+ for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)
+ continue;
+ ls = lm;
+
+ /* Find the balanced brace */
+ for (i = 0, pe = ++ptr; *pe; pe++)
+ if (*pe == LBRACKET) {
+ /* Ignore everything between [] */
+ for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
+ continue;
+ if (*pe == EOS) {
+ /*
+ * We could not find a matching RBRACKET.
+ * Ignore and just look for RBRACE
+ */
+ pe = pm;
+ }
+ }
+ else if (*pe == LBRACE)
+ i++;
+ else if (*pe == RBRACE) {
+ if (i == 0)
+ break;
+ i--;
+ }
+
+ /* Non matching braces; just glob the pattern */
+ if (i != 0 || *pe == EOS) {
+ /*
+ * we use `pattern', not `patbuf' here so that that
+ * unbalanced braces are passed to the match
+ */
+ *rv = glob0(pattern, pglob);
+ return 0;
+ }
+
+ for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
+ switch (*pm) {
+ case LBRACKET:
+ /* Ignore everything between [] */
+ for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)
+ continue;
+ if (*pm == EOS) {
+ /*
+ * We could not find a matching RBRACKET.
+ * Ignore and just look for RBRACE
+ */
+ pm = pl;
+ }
+ break;
+
+ case LBRACE:
+ i++;
+ break;
+
+ case RBRACE:
+ if (i) {
+ i--;
+ break;
+ }
+ /* FALLTHROUGH */
+ case COMMA:
+ if (i && *pm == COMMA)
+ break;
+ else {
+ /* Append the current string */
+ for (lm = ls; (pl < pm); *lm++ = *pl++)
+ continue;
+ /*
+ * Append the rest of the pattern after the
+ * closing brace
+ */
+ for (pl = pe + 1; (*lm++ = *pl++) != EOS;)
+ continue;
+
+ /* Expand the current pattern */
+#ifdef DEBUG
+ qprintf("globexp2:", patbuf);
+#endif
+ *rv = globexp1(patbuf, pglob);
+
+ /* move after the comma, to the next string */
+ pl = pm + 1;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ *rv = 0;
+ return 0;
+}
+
+
+
+/*
+ * expand tilde from the passwd file.
+ */
+static const Char *
+globtilde(pattern, patbuf, patsize, pglob)
+ const Char *pattern;
+ Char *patbuf;
+ size_t patsize;
+ glob_t *pglob;
+{
+ struct passwd *pwd;
+ const char *h;
+ const Char *p;
+ Char *b;
+ char *d;
+ Char *pend = &patbuf[patsize / sizeof(Char)];
+
+ pend--;
+
+ _DIAGASSERT(pattern != NULL);
+ _DIAGASSERT(patbuf != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
+ return pattern;
+
+ /* Copy up to the end of the string or / */
+ for (p = pattern + 1, d = (char *)(void *)patbuf;
+ d < (char *)(void *)pend && *p && *p != SLASH;
+ *d++ = *p++)
+ continue;
+
+ if (d == (char *)(void *)pend)
+ return NULL;
+
+ *d = EOS;
+ d = (char *)(void *)patbuf;
+
+ if (*d == EOS) {
+ /*
+ * handle a plain ~ or ~/ by expanding $HOME
+ * first and then trying the password file
+ */
+ if ((h = getenv("HOME")) == NULL) {
+ if ((pwd = getpwuid(getuid())) == NULL)
+ return pattern;
+ else
+ h = pwd->pw_dir;
+ }
+ }
+ else {
+ /*
+ * Expand a ~user
+ */
+ if ((pwd = getpwnam(d)) == NULL)
+ return pattern;
+ else
+ h = pwd->pw_dir;
+ }
+
+ /* Copy the home directory */
+ for (b = patbuf; b < pend && *h; *b++ = *h++)
+ continue;
+
+ if (b == pend)
+ return NULL;
+
+ /* Append the rest of the pattern */
+ while (b < pend && (*b++ = *p++) != EOS)
+ continue;
+
+ if (b == pend)
+ return NULL;
+
+ return patbuf;
+}
+
+
+/*
+ * The main glob() routine: compiles the pattern (optionally processing
+ * quotes), calls glob1() to do the real pattern matching, and finally
+ * sorts the list (unless unsorted operation is requested). Returns 0
+ * if things went well, nonzero if errors occurred. It is not an error
+ * to find no matches.
+ */
+static int
+glob0(pattern, pglob)
+ const Char *pattern;
+ glob_t *pglob;
+{
+ const Char *qpatnext;
+ int c, error, oldpathc;
+ Char *bufnext, patbuf[MAXPATHLEN+1];
+ size_t limit = 0;
+
+ _DIAGASSERT(pattern != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ if ((qpatnext = globtilde(pattern, patbuf, sizeof(patbuf),
+ pglob)) == NULL)
+ return GLOB_ABEND;
+ oldpathc = pglob->gl_pathc;
+ bufnext = patbuf;
+
+ /* We don't need to check for buffer overflow any more. */
+ while ((c = *qpatnext++) != EOS) {
+ switch (c) {
+ case LBRACKET:
+ c = *qpatnext;
+ if (c == NOT)
+ ++qpatnext;
+ if (*qpatnext == EOS ||
+ g_strchr(qpatnext+1, RBRACKET) == NULL) {
+ *bufnext++ = LBRACKET;
+ if (c == NOT)
+ --qpatnext;
+ break;
+ }
+ *bufnext++ = M_SET;
+ if (c == NOT)
+ *bufnext++ = M_NOT;
+ c = *qpatnext++;
+ do {
+ *bufnext++ = CHAR(c);
+ if (*qpatnext == RANGE &&
+ (c = qpatnext[1]) != RBRACKET) {
+ *bufnext++ = M_RNG;
+ *bufnext++ = CHAR(c);
+ qpatnext += 2;
+ }
+ } while ((c = *qpatnext++) != RBRACKET);
+ pglob->gl_flags |= GLOB_MAGCHAR;
+ *bufnext++ = M_END;
+ break;
+ case QUESTION:
+ pglob->gl_flags |= GLOB_MAGCHAR;
+ *bufnext++ = M_ONE;
+ break;
+ case STAR:
+ pglob->gl_flags |= GLOB_MAGCHAR;
+ /* collapse adjacent stars to one,
+ * to avoid exponential behavior
+ */
+ if (bufnext == patbuf || bufnext[-1] != M_ALL)
+ *bufnext++ = M_ALL;
+ break;
+ default:
+ *bufnext++ = CHAR(c);
+ break;
+ }
+ }
+ *bufnext = EOS;
+#ifdef DEBUG
+ qprintf("glob0:", patbuf);
+#endif
+
+ if ((error = glob1(patbuf, pglob, &limit)) != 0)
+ return(error);
+
+ if (pglob->gl_pathc == oldpathc) {
+ /*
+ * If there was no match we are going to append the pattern
+ * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was
+ * specified and the pattern did not contain any magic
+ * characters GLOB_NOMAGIC is there just for compatibility
+ * with csh.
+ */
+ if ((pglob->gl_flags & GLOB_NOCHECK) ||
+ ((pglob->gl_flags & (GLOB_NOMAGIC|GLOB_MAGCHAR))
+ == GLOB_NOMAGIC)) {
+ return globextend(pattern, pglob, &limit);
+ } else {
+ return (GLOB_NOMATCH);
+ }
+ } else if (!(pglob->gl_flags & GLOB_NOSORT)) {
+ qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
+ (size_t)pglob->gl_pathc - oldpathc, sizeof(char *),
+ compare);
+ }
+
+ return(0);
+}
+
+static int
+compare(p, q)
+ const void *p, *q;
+{
+
+ _DIAGASSERT(p != NULL);
+ _DIAGASSERT(q != NULL);
+
+ return(strcoll(*(const char * const *)p, *(const char * const *)q));
+}
+
+static int
+glob1(pattern, pglob, limit)
+ Char *pattern;
+ glob_t *pglob;
+ size_t *limit;
+{
+ Char pathbuf[MAXPATHLEN+1];
+
+ _DIAGASSERT(pattern != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
+ if (*pattern == EOS)
+ return(0);
+ /*
+ * we save one character so that we can use ptr >= limit,
+ * in the general case when we are appending non nul chars only.
+ */
+ return(glob2(pathbuf, pathbuf, pathbuf + sizeof(pathbuf) - 1, pattern,
+ pglob, limit));
+}
+
+/*
+ * The functions glob2 and glob3 are mutually recursive; there is one level
+ * of recursion for each segment in the pattern that contains one or more
+ * meta characters.
+ */
+static int
+glob2(pathbuf, pathend, pathlim, pattern, pglob, limit)
+ Char *pathbuf, *pathend, *pathlim, *pattern;
+ glob_t *pglob;
+ size_t *limit;
+{
+ struct STAT sb;
+ Char *p, *q;
+ int anymeta;
+
+ _DIAGASSERT(pathbuf != NULL);
+ _DIAGASSERT(pathend != NULL);
+ _DIAGASSERT(pattern != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ /*
+ * Loop over pattern segments until end of pattern or until
+ * segment with meta character found.
+ */
+ for (anymeta = 0;;) {
+ if (*pattern == EOS) { /* End of pattern? */
+ *pathend = EOS;
+ if (g_lstat(pathbuf, &sb, pglob))
+ return(0);
+
+ if (((pglob->gl_flags & GLOB_MARK) &&
+ pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) ||
+ (S_ISLNK(sb.st_mode) &&
+ (g_stat(pathbuf, &sb, pglob) == 0) &&
+ S_ISDIR(sb.st_mode)))) {
+ if (pathend >= pathlim)
+ return (GLOB_ABORTED);
+ *pathend++ = SEP;
+ *pathend = EOS;
+ }
+ ++pglob->gl_matchc;
+ return(globextend(pathbuf, pglob, limit));
+ }
+
+ /* Find end of next segment, copy tentatively to pathend. */
+ q = pathend;
+ p = pattern;
+ while (*p != EOS && *p != SEP) {
+ if (ismeta(*p))
+ anymeta = 1;
+ if (q >= pathlim)
+ return GLOB_ABORTED;
+ *q++ = *p++;
+ }
+
+ if (!anymeta) { /* No expansion, do next segment. */
+ pathend = q;
+ pattern = p;
+ while (*pattern == SEP) {
+ if (pathend >= pathlim)
+ return GLOB_ABORTED;
+ *pathend++ = *pattern++;
+ }
+ } else /* Need expansion, recurse. */
+ return(glob3(pathbuf, pathend, pathlim, pattern, p,
+ pglob, limit));
+ }
+ /* NOTREACHED */
+}
+
+static int
+glob3(pathbuf, pathend, pathlim, pattern, restpattern, pglob, limit)
+ Char *pathbuf, *pathend, *pathlim, *pattern, *restpattern;
+ glob_t *pglob;
+ size_t *limit;
+{
+ struct dirent *dp;
+ DIR *dirp;
+ int error;
+ char buf[MAXPATHLEN];
+
+ /*
+ * The readdirfunc declaration can't be prototyped, because it is
+ * assigned, below, to two functions which are prototyped in glob.h
+ * and dirent.h as taking pointers to differently typed opaque
+ * structures.
+ */
+ struct dirent *(*readdirfunc) __P((void *));
+
+ _DIAGASSERT(pathbuf != NULL);
+ _DIAGASSERT(pathend != NULL);
+ _DIAGASSERT(pattern != NULL);
+ _DIAGASSERT(restpattern != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ *pathend = EOS;
+ errno = 0;
+
+ if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
+ if (pglob->gl_errfunc) {
+ if (g_Ctoc(pathbuf, buf, sizeof(buf)))
+ return (GLOB_ABORTED);
+ if (pglob->gl_errfunc(buf, errno) ||
+ pglob->gl_flags & GLOB_ERR)
+ return (GLOB_ABORTED);
+ }
+ /*
+ * Posix/XOpen: glob should return when it encounters a
+ * directory that it cannot open or read
+ * XXX: Should we ignore ENOTDIR and ENOENT though?
+ * I think that Posix had in mind EPERM...
+ */
+ if (pglob->gl_flags & GLOB_ERR)
+ return (GLOB_ABORTED);
+
+ return(0);
+ }
+
+ error = 0;
+
+ /* Search directory for matching names. */
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+ readdirfunc = pglob->gl_readdir;
+ else
+ readdirfunc = (struct dirent *(*)__P((void *))) readdir;
+ while ((dp = (*readdirfunc)(dirp)) != NULL) {
+ u_char *sc;
+ Char *dc;
+
+ /* Initial DOT must be matched literally. */
+ if (dp->d_name[0] == DOT && *pattern != DOT)
+ continue;
+ /*
+ * The resulting string contains EOS, so we can
+ * use the pathlim character, if it is the nul
+ */
+ for (sc = (u_char *) dp->d_name, dc = pathend;
+ dc <= pathlim && (*dc++ = *sc++) != EOS;)
+ continue;
+
+ /*
+ * Have we filled the buffer without seeing EOS?
+ */
+ if (dc > pathlim && *pathlim != EOS) {
+ /*
+ * Abort when requested by caller, otherwise
+ * reset pathend back to last SEP and continue
+ * with next dir entry.
+ */
+ if (pglob->gl_flags & GLOB_ERR) {
+ error = GLOB_ABORTED;
+ break;
+ }
+ else {
+ *pathend = EOS;
+ continue;
+ }
+ }
+
+ if (!match(pathend, pattern, restpattern)) {
+ *pathend = EOS;
+ continue;
+ }
+ error = glob2(pathbuf, --dc, pathlim, restpattern, pglob, limit);
+ if (error)
+ break;
+ }
+
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+ (*pglob->gl_closedir)(dirp);
+ else
+ closedir(dirp);
+
+ /*
+ * Again Posix X/Open issue with regards to error handling.
+ */
+ if ((error || errno) && (pglob->gl_flags & GLOB_ERR))
+ return (GLOB_ABORTED);
+
+ return(error);
+}
+
+
+/*
+ * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
+ * add the new item, and update gl_pathc.
+ *
+ * This assumes the BSD realloc, which only copies the block when its size
+ * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic
+ * behavior.
+ *
+ * Return 0 if new item added, error code if memory couldn't be allocated.
+ *
+ * Invariant of the glob_t structure:
+ * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
+ * gl_pathv points to (gl_offs + gl_pathc + 1) items.
+ */
+static int
+globextend(path, pglob, limit)
+ const Char *path;
+ glob_t *pglob;
+ size_t *limit;
+{
+ char **pathv;
+ int i;
+ size_t newsize, len;
+ char *copy;
+ const Char *p;
+
+ _DIAGASSERT(path != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
+ pathv = pglob->gl_pathv ? realloc(pglob->gl_pathv, newsize) :
+ malloc(newsize);
+ if (pathv == NULL)
+ return(GLOB_NOSPACE);
+
+ if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
+ /* first time around -- clear initial gl_offs items */
+ pathv += pglob->gl_offs;
+ for (i = pglob->gl_offs; --i >= 0; )
+ *--pathv = NULL;
+ }
+ pglob->gl_pathv = pathv;
+
+ for (p = path; *p++;)
+ continue;
+ len = (size_t)(p - path);
+ *limit += len;
+ if ((copy = malloc(len)) != NULL) {
+ if (g_Ctoc(path, copy, len)) {
+ free(copy);
+ return(GLOB_ABORTED);
+ }
+ pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
+ }
+ pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
+
+ if ((pglob->gl_flags & GLOB_LIMIT) && (newsize + *limit) >= ARG_MAX) {
+ errno = 0;
+ return(GLOB_NOSPACE);
+ }
+
+ return(copy == NULL ? GLOB_NOSPACE : 0);
+}
+
+
+/*
+ * pattern matching function for filenames. Each occurrence of the *
+ * pattern causes a recursion level.
+ */
+static int
+match(name, pat, patend)
+ Char *name, *pat, *patend;
+{
+ int ok, negate_range;
+ Char c, k;
+
+ _DIAGASSERT(name != NULL);
+ _DIAGASSERT(pat != NULL);
+ _DIAGASSERT(patend != NULL);
+
+ while (pat < patend) {
+ c = *pat++;
+ switch (c & M_MASK) {
+ case M_ALL:
+ if (pat == patend)
+ return(1);
+ do
+ if (match(name, pat, patend))
+ return(1);
+ while (*name++ != EOS);
+ return(0);
+ case M_ONE:
+ if (*name++ == EOS)
+ return(0);
+ break;
+ case M_SET:
+ ok = 0;
+ if ((k = *name++) == EOS)
+ return(0);
+ if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
+ ++pat;
+ while (((c = *pat++) & M_MASK) != M_END)
+ if ((*pat & M_MASK) == M_RNG) {
+ if (c <= k && k <= pat[1])
+ ok = 1;
+ pat += 2;
+ } else if (c == k)
+ ok = 1;
+ if (ok == negate_range)
+ return(0);
+ break;
+ default:
+ if (*name++ != c)
+ return(0);
+ break;
+ }
+ }
+ return(*name == EOS);
+}
+
+/* Free allocated data belonging to a glob_t structure. */
+void
+globfree(pglob)
+ glob_t *pglob;
+{
+ int i;
+ char **pp;
+
+ _DIAGASSERT(pglob != NULL);
+
+ if (pglob->gl_pathv != NULL) {
+ pp = pglob->gl_pathv + pglob->gl_offs;
+ for (i = pglob->gl_pathc; i--; ++pp)
+ if (*pp)
+ free(*pp);
+ free(pglob->gl_pathv);
+ pglob->gl_pathv = NULL;
+ pglob->gl_pathc = 0;
+ }
+}
+
+static DIR *
+g_opendir(str, pglob)
+ Char *str;
+ glob_t *pglob;
+{
+ char buf[MAXPATHLEN];
+
+ _DIAGASSERT(str != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ if (!*str)
+ (void)strlcpy(buf, ".", sizeof(buf));
+ else {
+ if (g_Ctoc(str, buf, sizeof(buf)))
+ return NULL;
+ }
+
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+ return((*pglob->gl_opendir)(buf));
+
+ return(opendir(buf));
+}
+
+static int
+g_lstat(fn, sb, pglob)
+ Char *fn;
+ struct STAT *sb;
+ glob_t *pglob;
+{
+ char buf[MAXPATHLEN];
+
+ _DIAGASSERT(fn != NULL);
+ _DIAGASSERT(sb != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ if (g_Ctoc(fn, buf, sizeof(buf)))
+ return -1;
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+ return((*pglob->gl_lstat)(buf, sb));
+ return(lstat(buf, sb));
+}
+
+static int
+g_stat(fn, sb, pglob)
+ Char *fn;
+ struct STAT *sb;
+ glob_t *pglob;
+{
+ char buf[MAXPATHLEN];
+
+ _DIAGASSERT(fn != NULL);
+ _DIAGASSERT(sb != NULL);
+ _DIAGASSERT(pglob != NULL);
+
+ if (g_Ctoc(fn, buf, sizeof(buf)))
+ return -1;
+ if (pglob->gl_flags & GLOB_ALTDIRFUNC)
+ return((*pglob->gl_stat)(buf, sb));
+ return(stat(buf, sb));
+}
+
+static Char *
+g_strchr(str, ch)
+ const Char *str;
+ int ch;
+{
+
+ _DIAGASSERT(str != NULL);
+
+ do {
+ if (*str == ch)
+ /* LINTED this is libc's definition! */
+ return (Char *)str;
+ } while (*str++);
+ return NULL;
+}
+
+static int
+g_Ctoc(str, buf, len)
+ const Char *str;
+ char *buf;
+ size_t len;
+{
+ char *dc;
+
+ _DIAGASSERT(str != NULL);
+ _DIAGASSERT(buf != NULL);
+
+ if (len == 0)
+ return 1;
+
+ for (dc = buf; len && (*dc++ = *str++) != EOS; len--)
+ continue;
+
+ return len == 0;
+}
+
+#ifdef DEBUG
+static void
+qprintf(str, s)
+ const char *str;
+ Char *s;
+{
+ Char *p;
+
+ _DIAGASSERT(str != NULL);
+ _DIAGASSERT(s != NULL);
+
+ (void)printf("%s:\n", str);
+ for (p = s; *p; p++)
+ (void)printf("%c", CHAR(*p));
+ (void)printf("\n");
+ for (p = s; *p; p++)
+ (void)printf("%c", *p & M_PROTECT ? '"' : ' ');
+ (void)printf("\n");
+ for (p = s; *p; p++)
+ (void)printf("%c", ismeta(*p) ? '_' : ' ');
+ (void)printf("\n");
+}
+#endif
diff --git a/pkgtools/libnbcompat/files/__unsetenv13.c b/pkgtools/libnbcompat/files/__unsetenv13.c
new file mode 100644
index 00000000000..527d6a9464a
--- /dev/null
+++ b/pkgtools/libnbcompat/files/__unsetenv13.c
@@ -0,0 +1,124 @@
+/* $NetBSD: __unsetenv13.c,v 1.1 2004/08/23 03:32:12 jlam Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "from: @(#)setenv.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: __unsetenv13.c,v 1.1 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if 0
+#include "namespace.h"
+#endif
+
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#if 0
+#include "local.h"
+#include "reentrant.h"
+#endif
+
+char *__findenv __P((const char *, int *));
+
+#if 0
+#ifdef __weak_alias
+#ifdef __LIBC12_SOURCE__
+__weak_alias(unsetenv,_unsetenv)
+#endif
+#endif
+#endif
+
+#if 0
+#ifdef _REENTRANT
+extern rwlock_t __environ_lock;
+#endif
+#endif
+
+#if 0
+#ifdef __LIBC12_SOURCE__
+__warn_references(unsetenv,
+ "warning: reference to compatibility unsetenv();"
+ " include <stdlib.h> for correct reference")
+#endif
+#endif
+
+extern char **environ;
+
+#ifndef rwlock_wrlock
+#define rwlock_wrlock(lock) ((void)0)
+#endif
+#ifndef rwlock_unlock
+#define rwlock_unlock(lock) ((void)0)
+#endif
+
+/*
+ * unsetenv(name) --
+ * Delete environmental variable "name".
+ */
+#ifdef __LIBC12_SOURCE__
+void
+#else
+int
+#endif
+unsetenv(name)
+ const char *name;
+{
+ char **p;
+ int offset;
+
+ _DIAGASSERT(name != NULL);
+
+#ifndef __LIBC12_SOURCE__
+ if (name == NULL || *name == '\0' || strchr(name, '=') != NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+#endif
+
+ rwlock_wrlock(&__environ_lock);
+ while (__findenv(name, &offset)) /* if set multiple times */
+ for (p = &environ[offset];; ++p)
+ if (!(*p = *(p + 1)))
+ break;
+ rwlock_unlock(&__environ_lock);
+
+#ifndef __LIBC12_SOURCE__
+ return (0);
+#endif
+}
diff --git a/pkgtools/libnbcompat/files/configure b/pkgtools/libnbcompat/files/configure
index e72df39d5e8..46a05806fbd 100755
--- a/pkgtools/libnbcompat/files/configure
+++ b/pkgtools/libnbcompat/files/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for libnbcompat 20040814.
+# Generated by GNU Autoconf 2.59 for libnbcompat 20040822.
#
# Report bugs to <grant@NetBSD.org>.
#
@@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='libnbcompat'
PACKAGE_TARNAME='libnbcompat'
-PACKAGE_VERSION='20040814'
-PACKAGE_STRING='libnbcompat 20040814'
+PACKAGE_VERSION='20040822'
+PACKAGE_STRING='libnbcompat 20040822'
PACKAGE_BUGREPORT='grant@NetBSD.org'
# Factoring default headers for most tests.
@@ -779,7 +779,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libnbcompat 20040814 to adapt to many kinds of systems.
+\`configure' configures libnbcompat 20040822 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -845,7 +845,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libnbcompat 20040814:";;
+ short | recursive ) echo "Configuration of libnbcompat 20040822:";;
esac
cat <<\_ACEOF
@@ -957,7 +957,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-libnbcompat configure 20040814
+libnbcompat configure 20040822
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -971,7 +971,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libnbcompat $as_me 20040814, which was
+It was created by libnbcompat $as_me 20040822, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -3446,13 +3446,16 @@ done
-for ac_header in assert.h dirent.h err.h errno.h fcntl.h fnmatch.h fts.h \
- grp.h libutil.h limits.h machine/endian.h memory.h ndir.h paths.h \
- pwd.h stdint.h stdio.h stdlib.h stringlist.h strings.h string.h \
- sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h sys/file.h \
- sys/mkdev.h sys/ndir.h sys/param.h sys/time.h sys/ttycom.h \
- sys/stat.h sys/statfs.h sys/statvfs.h sys/types.h sys/vfs.h \
- termcap.h termios.h time.h tzfile.h unistd.h util.h utmp.h
+
+
+for ac_header in alloca.h assert.h ctype.h dirent.h err.h errno.h fcntl.h \
+ fnmatch.h fts.h grp.h libutil.h limits.h machine/endian.h ndir.h \
+ paths.h pwd.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h \
+ string.h sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h \
+ sys/file.h sys/mkdev.h sys/ndir.h sys/param.h sys/stat.h \
+ sys/statfs.h sys/statvfs.h sys/time.h sys/ttycom.h sys/types.h \
+ sys/uio.h sys/vfs.h termcap.h time.h tzfile.h unistd.h \
+ util.h utime.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -3827,6 +3830,14 @@ _ACEOF
+case $LIBOBJS in
+ "glob.$ac_objext" | \
+ *" glob.$ac_objext" | \
+ "glob.$ac_objext "* | \
+ *" glob.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS glob.$ac_objext" ;;
+esac
+
for ac_header in sys/queue.h
@@ -5453,7 +5464,10 @@ echo "${ECHO_T}$pkg_cv_have_vis_white" >&6
-for ac_func in strunvis strvis strsvis
+
+
+
+for ac_func in strunvis strvis strsvis svis unvis vis
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -5557,7 +5571,10 @@ done
-for ac_func in strunvis strvis strsvis
+
+
+
+for ac_func in strunvis strvis strsvis svis unvis vis
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -8312,10 +8329,13 @@ done
-for ac_func in err fgetln fnmatch fparseln getenv isblank lchflags \
- lchmod lchown lutimes mkstemp mkdtemp setgroupent setpassent \
- setprogname snprintf statvfs strdup strerror strlcat strlcpy \
- strmode strsep strtoll usleep utimes
+
+
+
+for ac_func in err fgetln fnmatch fparseln getenv isblank \
+ lchflags lchmod lchown lutimes mkdtemp mkstemp setenv setgroupent \
+ setpassent setprogname snprintf statvfs strdup strerror strlcat \
+ strlcpy strmode strsep strtoll unsetenv usleep utimes warn
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -8431,9 +8451,7 @@ done
-
-
-for ac_func in bcopy bzero memset memcpy setlocale
+for ac_func in getenv setenv unsetenv
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -8530,13 +8548,26 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
+ :
+else
+
+ case $LIBOBJS in
+ "findenv.$ac_objext" | \
+ *" findenv.$ac_objext" | \
+ "findenv.$ac_objext "* | \
+ *" findenv.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS findenv.$ac_objext" ;;
+esac
+
+ break
fi
done
-for ac_func in getmode setmode
+
+for ac_func in mkdtemp mkstemp
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -8633,13 +8664,29 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
+ :
+else
+
+ case $LIBOBJS in
+ "gettemp.$ac_objext" | \
+ *" gettemp.$ac_objext" | \
+ "gettemp.$ac_objext "* | \
+ *" gettemp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS gettemp.$ac_objext" ;;
+esac
+
+ break
fi
done
-for ac_func in getmode setmode
+
+
+
+
+for ac_func in bcopy bzero memset memcpy setlocale
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -8736,25 +8783,13 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
- :
-else
-
- case $LIBOBJS in
- "setmode.$ac_objext" | \
- *" setmode.$ac_objext" | \
- "setmode.$ac_objext "* | \
- *" setmode.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS setmode.$ac_objext" ;;
-esac
-
- break
fi
done
-for ac_func in setenv unsetenv
+for ac_func in getmode setmode
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -8857,7 +8892,7 @@ done
-for ac_func in setenv unsetenv
+for ac_func in getmode setmode
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -8958,11 +8993,11 @@ _ACEOF
else
case $LIBOBJS in
- "setenv.$ac_objext" | \
- *" setenv.$ac_objext" | \
- "setenv.$ac_objext "* | \
- *" setenv.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS setenv.$ac_objext" ;;
+ "setmode.$ac_objext" | \
+ *" setmode.$ac_objext" | \
+ "setmode.$ac_objext "* | \
+ *" setmode.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS setmode.$ac_objext" ;;
esac
break
@@ -9303,21 +9338,22 @@ _ACEOF
case $LIBOBJS in
- "__fts13.$ac_objext" | \
- *" __fts13.$ac_objext" | \
- "__fts13.$ac_objext "* | \
- *" __fts13.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS __fts13.$ac_objext" ;;
+ "fts.$ac_objext" | \
+ *" fts.$ac_objext" | \
+ "fts.$ac_objext "* | \
+ *" fts.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS fts.$ac_objext" ;;
esac
fi
-# handle Darwin 7 having a poll() compatibility function. be
-# conservative, if we don't find one of poll.h or sys/poll.h, use our
-# local poll() implementation.
-pkg_use_nbcompat_poll=no
+# Handle Darwin 7 having a poll() compatibility function. Be
+# conservative -- if we don't find one of <poll.h> or <sys/poll.h>, then
+# use our own poll() implementation.
+#
+pkg_cv_have_poll_h=no
for ac_header in poll.h sys/poll.h
@@ -9470,12 +9506,160 @@ fi
done
-if test $ac_cv_header_poll_h = no && test $ac_cv_header_sys_poll_h = no; then
- pkg_use_nbcompat_poll=yes
+
+for ac_header in poll.h sys/poll.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
-if test $pkg_use_nbcompat_poll = yes; then
- pkg_cv_POLL_NATIVE=no
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to grant@NetBSD.org ##
+## ------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ pkg_cv_have_poll_h=yes
+fi
+
+done
+
+
+pkg_use_nbcompat_poll=yes
+if test $pkg_cv_have_poll_h = yes; then
+ pkg_use_nbcompat_poll=no
else
echo "$as_me:$LINENO: checking for poll" >&5
echo $ECHO_N "checking for poll... $ECHO_C" >&6
@@ -9572,7 +9756,7 @@ if test $ac_cv_func_poll = yes; then
echo "$as_me:$LINENO: checking if poll() is implemented natively" >&5
echo $ECHO_N "checking if poll() is implemented natively... $ECHO_C" >&6
-if test "${pkg_cv_POLL_NATIVE+set}" = set; then
+if test "${pkg_cv_native_poll+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
@@ -9622,22 +9806,22 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- pkg_cv_POLL_NATIVE=yes
+ pkg_cv_native_poll=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- pkg_cv_POLL_NATIVE=no
+ pkg_cv_native_poll=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
-echo "$as_me:$LINENO: result: $pkg_cv_POLL_NATIVE" >&5
-echo "${ECHO_T}$pkg_cv_POLL_NATIVE" >&6
- if test "x$pkg_cv_POLL_NATIVE" = "xyes"; then
- :
+echo "$as_me:$LINENO: result: $pkg_cv_native_poll" >&5
+echo "${ECHO_T}$pkg_cv_native_poll" >&6
+ if test "x$pkg_cv_native_poll" = "xyes"; then
+ pkg_use_nbcompat_poll=no
else
- :
+ pkg_use_nbcompat_poll=yes
:
fi
@@ -9646,14 +9830,13 @@ fi
fi
-if test $pkg_cv_POLL_NATIVE = yes; then
+if test $pkg_use_nbcompat_poll = yes; then
cat >>confdefs.h <<\_ACEOF
-#define HAVE_POLL 1
+#define HAVE_NBCOMPAT_POLL 1
_ACEOF
-else
case $LIBOBJS in
"poll.$ac_objext" | \
*" poll.$ac_objext" | \
@@ -9662,12 +9845,6 @@ else
*) LIBOBJS="$LIBOBJS poll.$ac_objext" ;;
esac
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_NBCOMPAT_POLL 1
-_ACEOF
-
-
-
fi
@@ -10161,6 +10338,148 @@ else
:
fi
+echo "$as_me:$LINENO: checking for struct dirent.d_namlen" >&5
+echo $ECHO_N "checking for struct dirent.d_namlen... $ECHO_C" >&6
+if test "${ac_cv_member_struct_dirent_d_namlen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+ #include <sys/types.h>
+ #if HAVE_DIRENT_H
+ # include <dirent.h>
+ #else
+ # define dirent direct
+ # if HAVE_SYS_NDIR_H
+ # include <sys/ndir.h>
+ # endif
+ # if HAVE_SYS_DIR_H
+ # include <sys/dir.h>
+ # endif
+ # if HAVE_NDIR_H
+ # include <ndir.h>
+ # endif
+ #endif
+
+int
+main ()
+{
+static struct dirent ac_aggr;
+if (ac_aggr.d_namlen)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_struct_dirent_d_namlen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+ #include <sys/types.h>
+ #if HAVE_DIRENT_H
+ # include <dirent.h>
+ #else
+ # define dirent direct
+ # if HAVE_SYS_NDIR_H
+ # include <sys/ndir.h>
+ # endif
+ # if HAVE_SYS_DIR_H
+ # include <sys/dir.h>
+ # endif
+ # if HAVE_NDIR_H
+ # include <ndir.h>
+ # endif
+ #endif
+
+int
+main ()
+{
+static struct dirent ac_aggr;
+if (sizeof ac_aggr.d_namlen)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_struct_dirent_d_namlen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_struct_dirent_d_namlen=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_dirent_d_namlen" >&5
+echo "${ECHO_T}$ac_cv_member_struct_dirent_d_namlen" >&6
+if test $ac_cv_member_struct_dirent_d_namlen = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_DIRENT_D_NAMLEN 1
+_ACEOF
+
+:
+else
+ :
+fi
+
if test $ac_cv_type_long_long = yes; then
@@ -10397,27 +10716,30 @@ done
fi
-
- echo "$as_me:$LINENO: checking for optarg declaration" >&5
-echo $ECHO_N "checking for optarg declaration... $ECHO_C" >&6
-if test "${ftp_cv_HAVE_OPTARG_D+set}" = set; then
+echo "$as_me:$LINENO: checking whether optind is declared" >&5
+echo $ECHO_N "checking whether optind is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_optind+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
-
- cat >conftest.$ac_ext <<_ACEOF
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+ #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+
int
main ()
{
- char *X = optarg ;
+#ifndef optind
+ char *p = (char *) optind;
+#endif
+
;
return 0;
}
@@ -10444,54 +10766,55 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ftp_cv_HAVE_OPTARG_D=yes
+ ac_cv_have_decl_optind=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ftp_cv_HAVE_OPTARG_D=no
+ac_cv_have_decl_optind=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
fi
-echo "$as_me:$LINENO: result: $ftp_cv_HAVE_OPTARG_D" >&5
-echo "${ECHO_T}$ftp_cv_HAVE_OPTARG_D" >&6
- if test "x$ftp_cv_HAVE_OPTARG_D" = "xyes"; then
- :
- else
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_optind" >&5
+echo "${ECHO_T}$ac_cv_have_decl_optind" >&6
+if test $ac_cv_have_decl_optind = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_OPTARG_D 1
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_OPTIND 1
_ACEOF
+:
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_OPTIND 0
+_ACEOF
-
-
- :
- fi
-
-
-
- echo "$as_me:$LINENO: checking for optind declaration" >&5
-echo $ECHO_N "checking for optind declaration... $ECHO_C" >&6
-if test "${ftp_cv_HAVE_OPTIND_D+set}" = set; then
+:
+fi
+echo "$as_me:$LINENO: checking whether optreset is declared" >&5
+echo $ECHO_N "checking whether optreset is declared... $ECHO_C" >&6
+if test "${ac_cv_have_decl_optreset+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
-
- cat >conftest.$ac_ext <<_ACEOF
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+ #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+
int
main ()
{
- int X = optind ;
+#ifndef optreset
+ char *p = (char *) optreset;
+#endif
+
;
return 0;
}
@@ -10518,31 +10841,32 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ftp_cv_HAVE_OPTIND_D=yes
+ ac_cv_have_decl_optreset=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ftp_cv_HAVE_OPTIND_D=no
+ac_cv_have_decl_optreset=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
fi
-echo "$as_me:$LINENO: result: $ftp_cv_HAVE_OPTIND_D" >&5
-echo "${ECHO_T}$ftp_cv_HAVE_OPTIND_D" >&6
- if test "x$ftp_cv_HAVE_OPTIND_D" = "xyes"; then
- :
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_OPTIND_D 1
-_ACEOF
-
+echo "$as_me:$LINENO: result: $ac_cv_have_decl_optreset" >&5
+echo "${ECHO_T}$ac_cv_have_decl_optreset" >&6
+if test $ac_cv_have_decl_optreset = yes; then
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_OPTRESET 1
+_ACEOF
+:
+else
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_OPTRESET 0
+_ACEOF
- else
+:
+fi
- :
- fi
@@ -10912,7 +11236,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by libnbcompat $as_me 20040814, which was
+This file was extended by libnbcompat $as_me 20040822, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -10972,7 +11296,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-libnbcompat config.status 20040814
+libnbcompat config.status 20040822
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/pkgtools/libnbcompat/files/configure.ac b/pkgtools/libnbcompat/files/configure.ac
index a7721a6dc91..a46be8299a8 100644
--- a/pkgtools/libnbcompat/files/configure.ac
+++ b/pkgtools/libnbcompat/files/configure.ac
@@ -1,8 +1,8 @@
-dnl $NetBSD: configure.ac,v 1.48 2004/08/21 06:36:13 jlam Exp $
+dnl $NetBSD: configure.ac,v 1.49 2004/08/23 03:32:12 jlam Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
-AC_INIT([libnbcompat], [20040814], [grant@NetBSD.org])
+AC_INIT([libnbcompat], [20040822], [grant@NetBSD.org])
AC_CONFIG_HEADER(nbcompat/config.h)
AC_ARG_PROGRAM
@@ -36,13 +36,14 @@ dnl Used by bits.c to check for sizes of integer types
AC_CHECK_HEADERS([inttypes.h sys/types.h sys/bitypes.h bind/bitypes.h \
netinet/in6_machtypes.h])
-AC_CHECK_HEADERS([assert.h dirent.h err.h errno.h fcntl.h fnmatch.h fts.h \
- grp.h libutil.h limits.h machine/endian.h memory.h ndir.h paths.h \
- pwd.h stdint.h stdio.h stdlib.h stringlist.h strings.h string.h \
- sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h sys/file.h \
- sys/mkdev.h sys/ndir.h sys/param.h sys/time.h sys/ttycom.h \
- sys/stat.h sys/statfs.h sys/statvfs.h sys/types.h sys/vfs.h \
- termcap.h termios.h time.h tzfile.h unistd.h util.h utmp.h
+AC_CHECK_HEADERS([alloca.h assert.h ctype.h dirent.h err.h errno.h fcntl.h \
+ fnmatch.h fts.h grp.h libutil.h limits.h machine/endian.h ndir.h \
+ paths.h pwd.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h \
+ string.h sys/byteorder.h sys/cdefs.h sys/dir.h sys/endian.h \
+ sys/file.h sys/mkdev.h sys/ndir.h sys/param.h sys/stat.h \
+ sys/statfs.h sys/statvfs.h sys/time.h sys/ttycom.h sys/types.h \
+ sys/uio.h sys/vfs.h termcap.h time.h tzfile.h unistd.h \
+ util.h utime.h
])
AC_CHECK_HEADERS([sys/mount.h], [:], [:], [
AC_INCLUDES_DEFAULT
@@ -57,6 +58,7 @@ AC_DEFINE(HAVE_NBCOMPAT_GLOB)
AH_TEMPLATE([HAVE_NBCOMPAT_GLOB], [
Define to 1 if the `glob' function is built into the library.
])
+AC_LIBOBJ(glob)
dnl Always use our own queue(3) implementation.
AC_CHECK_HEADERS([sys/queue.h])
@@ -150,8 +152,8 @@ AC_CHECK_HEADERS([vis.h], [
#include <sys/types.h>
#include <vis.h>
], [ int X = VIS_WHITE; ], [
- AC_CHECK_FUNCS([strunvis strvis strsvis])
- AC_CHECK_FUNCS([strunvis strvis strsvis],
+ AC_CHECK_FUNCS([strunvis strvis strsvis svis unvis vis])
+ AC_CHECK_FUNCS([strunvis strvis strsvis svis unvis vis],
[pkg_use_nbcompat_vis=no],
[pkg_use_nbcompat_vis=yes; break])
])
@@ -204,10 +206,20 @@ AC_FUNC_MALLOC
AC_FUNC_STRERROR_R
AC_FUNC_VPRINTF
-AC_REPLACE_FUNCS([err fgetln fnmatch fparseln getenv isblank lchflags \
- lchmod lchown lutimes mkstemp mkdtemp setgroupent setpassent \
- setprogname snprintf statvfs strdup strerror strlcat strlcpy \
- strmode strsep strtoll usleep utimes
+AC_REPLACE_FUNCS([err fgetln fnmatch fparseln getenv isblank \
+ lchflags lchmod lchown lutimes mkdtemp mkstemp setenv setgroupent \
+ setpassent setprogname snprintf statvfs strdup strerror strlcat \
+ strlcpy strmode strsep strtoll unsetenv usleep utimes warn
+])
+
+AC_CHECK_FUNCS([getenv setenv unsetenv], [:], [
+ AC_LIBOBJ(findenv)
+ break
+])
+
+AC_CHECK_FUNCS([mkdtemp mkstemp], [:], [
+ AC_LIBOBJ(gettemp)
+ break
])
AC_CHECK_FUNCS([bcopy bzero memset memcpy setlocale])
@@ -216,11 +228,6 @@ AC_CHECK_FUNCS([getmode setmode], [:], [
AC_LIBOBJ(setmode)
break
])
-AC_CHECK_FUNCS([setenv unsetenv])
-AC_CHECK_FUNCS([setenv unsetenv], [:], [
- AC_LIBOBJ(setenv)
- break
-])
AC_CHECK_FUNCS([gid_from_group group_from_gid pwcache_groupdb \
pwcache_userdb uid_from_user user_from_uid \
@@ -238,25 +245,24 @@ AC_CHECK_FUNC(fts_open, [:], [
Define to 1 if the `fts_*' functions are built into the
library.
])
- AC_LIBOBJ(__fts13)
+ AC_LIBOBJ(fts)
])
-# handle Darwin 7 having a poll() compatibility function. be
-# conservative, if we don't find one of poll.h or sys/poll.h, use our
-# local poll() implementation.
-pkg_use_nbcompat_poll=no
+# Handle Darwin 7 having a poll() compatibility function. Be
+# conservative -- if we don't find one of <poll.h> or <sys/poll.h>, then
+# use our own poll() implementation.
+#
+pkg_cv_have_poll_h=no
AC_CHECK_HEADERS([poll.h sys/poll.h])
+AC_CHECK_HEADERS([poll.h sys/poll.h], [pkg_cv_have_poll_h=yes])
-if test $ac_cv_header_poll_h = no && test $ac_cv_header_sys_poll_h = no; then
- pkg_use_nbcompat_poll=yes
-fi
-
-if test $pkg_use_nbcompat_poll = yes; then
- pkg_cv_POLL_NATIVE=no
+pkg_use_nbcompat_poll=yes
+if test $pkg_cv_have_poll_h = yes; then
+ pkg_use_nbcompat_poll=no
else
AC_CHECK_FUNC(poll, [
AC_MSG_TRY_COMPILE([if poll() is implemented natively],
- pkg_cv_POLL_NATIVE,
+ pkg_cv_native_poll,
[ #if HAVE_POLL_H
#include <poll.h>
#endif
@@ -268,21 +274,17 @@ else
#error "poll() is emulated"
#endif
],
- [:], [:])
+ [pkg_use_nbcompat_poll=no],
+ [pkg_use_nbcompat_poll=yes])
])
fi
-if test $pkg_cv_POLL_NATIVE = yes; then
- AC_DEFINE(HAVE_POLL, 1)
- AH_TEMPLATE([HAVE_POLL], [
- Define to 1 if you have the `poll' function.
- ])
-else
- AC_LIBOBJ(poll)
+if test $pkg_use_nbcompat_poll = yes; then
AC_DEFINE(HAVE_NBCOMPAT_POLL, 1)
AH_TEMPLATE([HAVE_NBCOMPAT_POLL], [
Define to 1 if the `poll' function is built into the library.
])
+ AC_LIBOBJ(poll)
fi
AC_CHECK_FUNCS([getpassphrase getpgrp memmove select])
@@ -293,6 +295,22 @@ AC_CHECK_MEMBERS([struct statfs.f_fsize], [:], [:],
[ #include <sys/statfs.h> ])
AC_CHECK_MEMBERS([struct statfs.f_iosize], [:], [:],
[ #include <sys/statfs.h> ])
+AC_CHECK_MEMBERS([struct dirent.d_namlen], [:], [:],
+ [ #include <sys/types.h>
+ #if HAVE_DIRENT_H
+ # include <dirent.h>
+ #else
+ # define dirent direct
+ # if HAVE_SYS_NDIR_H
+ # include <sys/ndir.h>
+ # endif
+ # if HAVE_SYS_DIR_H
+ # include <sys/dir.h>
+ # endif
+ # if HAVE_NDIR_H
+ # include <ndir.h>
+ # endif
+ #endif ])
if test $ac_cv_type_long_long = yes; then
@@ -349,24 +367,10 @@ dnl support because we don't know how to display it.
fi
-AC_MSG_TRY_COMPILE([for optarg declaration], ftp_cv_HAVE_OPTARG_D, [
+AC_CHECK_DECLS([optind, optreset], [:], [:], [
+ #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-], [ char *X = optarg ], [:], [
- AC_DEFINE(HAVE_OPTARG_D, 1)
- AH_TEMPLATE([HAVE_OPTARG_D], [
- Define to 1 if optarg is declared in <stdlib.h> or <unistd.h>
- ])
-])
-
-AC_MSG_TRY_COMPILE([for optind declaration], ftp_cv_HAVE_OPTIND_D, [
- #include <stdlib.h>
- #include <unistd.h>
-], [ int X = optind ], [:] [
- AC_DEFINE(HAVE_OPTIND_D, 1)
- AH_TEMPLATE([HAVE_OPTIND_D], [
- Define to 1 if optind is declared in <stdlib.h> or <unistd.h>
- ])
])
AH_BOTTOM([
@@ -375,115 +379,6 @@ AH_BOTTOM([
#ifndef HAVE___ATTRIBUTE__
# define __attribute__(x)
#endif
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
-#ifndef __IDSTRING
-# define __IDSTRING(name,string) \
- static const char name[] __attribute__((__unused__)) = string
-#endif
-
-#ifndef __RCSID
-# define __RCSID(_s) __IDSTRING(rcsid,_s)
-#endif
-
-#ifndef __COPYRIGHT
-# define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
-#endif
-
-#ifndef __P
-# if defined(__STDC__) || defined(__cplusplus)
-# define __P(protos) protos /* full-blown ANSI C */
-# else
-# define __P(protos) () /* traditional C preprocessor */
-# endif
-#endif
-
-#ifndef __CONCAT
-# if defined(__STDC__) || defined(__cplusplus)
-# define __CONCAT(x,y) x ## y
-# else
-# define __CONCAT(x,y) x/**/y
-# endif
-#endif
-
-#ifndef __BEGIN_DECLS
-# if defined(__cplusplus)
-# define __BEGIN_DECLS extern "C" {
-# else
-# define __BEGIN_DECLS
-# endif
-#endif
-
-#ifndef __END_DECLS
-# if defined(__cplusplus)
-# define __END_DECLS };
-# else
-# define __END_DECLS
-# endif
-#endif
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#if HAVE_SYS_ENDIAN_H
-#include <sys/endian.h>
-#endif
-
-#if HAVE_MACHINE_ENDIAN_H
-#include <machine/endian.h>
-#endif
-
-#if HAVE_SYS_BYTEORDER_H
-#include <sys/byteorder.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef LITTLE_ENDIAN
-# define LITTLE_ENDIAN 1234
-#endif
-
-#ifndef BIG_ENDIAN
-# define BIG_ENDIAN 4321
-#endif
-
-#ifndef UINT_MAX
-# define UINT_MAX 4294967295U
-#endif
-
-#ifndef BYTE_ORDER
-# if defined(_BIG_ENDIAN)
-# define BYTE_ORDER BIG_ENDIAN
-# elif defined(_LITTE_ENDIAN)
-# define BYTE_ORDER LITTLE_ENDIAN
-# elif defined(WORDS_BIGENDIAN)
-# define BYTE_ORDER BIG_ENDIAN
-# else
-# define BYTE_ORDER LITTLE_ENDIAN
-# endif
-#endif
-
-#if defined(HAVE_MEMSET)
-# define MEMSET_BZERO(p,l) memset((p), 0, (l))
-#elif defined(HAVE_BZERO)
-# define MEMSET_BZERO(p,l) bzero((p), (l))
-#else
-# error You need either memset or bzero
-#endif
-
-#if defined(HAVE_MEMCPY)
-# define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
-#elif defined(HAVE_BCOPY)
-# define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
-#else
-# error You need either memcpy or bcopy
-#endif
])
AC_CONFIG_FILES([Makefile])
diff --git a/pkgtools/libnbcompat/files/err.c b/pkgtools/libnbcompat/files/err.c
index f5abf9f49a3..54938914260 100644
--- a/pkgtools/libnbcompat/files/err.c
+++ b/pkgtools/libnbcompat/files/err.c
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.3 2003/09/15 07:39:34 grant Exp $ */
+/* $NetBSD: err.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright 1997-2000 Luke Mewburn <lukem@netbsd.org>.
@@ -27,7 +27,35 @@
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: err.c,v 1.4 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#ifndef __NO_NAMESPACE_H /* XXX */
+#if 0
+#include "namespace.h"
+#endif
+#endif
+#include <nbcompat/err.h>
+#if HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(err, _err)
+#endif
+#endif
void
err(int eval, const char *fmt, ...)
@@ -91,60 +119,3 @@ verrx(eval, fmt, ap)
(void)fprintf(stderr, "\n");
exit(eval);
}
-
-void
-warn(const char *fmt, ...)
-{
- va_list ap;
- int sverrno;
-
- sverrno = errno;
- (void)fprintf(stderr, "%s: ", getprogname());
- va_start(ap, fmt);
- if (fmt != NULL) {
- (void)vfprintf(stderr, fmt, ap);
- (void)fprintf(stderr, ": ");
- }
- va_end(ap);
- (void)fprintf(stderr, "%s\n", strerror(sverrno));
-}
-
-void
-warnx(const char *fmt, ...)
-{
- va_list ap;
-
- (void)fprintf(stderr, "%s: ", getprogname());
- va_start(ap, fmt);
- if (fmt != NULL)
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- (void)fprintf(stderr, "\n");
-}
-
-void
-vwarn(fmt, ap)
- const char *fmt;
- va_list ap;
-{
- int sverrno;
-
- sverrno = errno;
- (void)fprintf(stderr, "%s: ", getprogname());
- if (fmt != NULL) {
- (void)vfprintf(stderr, fmt, ap);
- (void)fprintf(stderr, ": ");
- }
- (void)fprintf(stderr, "%s\n", strerror(sverrno));
-}
-
-void
-vwarnx(fmt, ap)
- const char *fmt;
- va_list ap;
-{
- (void)fprintf(stderr, "%s: ", getprogname());
- if (fmt != NULL)
- (void)vfprintf(stderr, fmt, ap);
- (void)fprintf(stderr, "\n");
-}
diff --git a/pkgtools/libnbcompat/files/fgetln.c b/pkgtools/libnbcompat/files/fgetln.c
index 195edc5c5e6..df829dd46ac 100644
--- a/pkgtools/libnbcompat/files/fgetln.c
+++ b/pkgtools/libnbcompat/files/fgetln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fgetln.c,v 1.1.1.1 2003/03/31 05:02:43 grant Exp $ */
+/* $NetBSD: fgetln.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -36,8 +36,40 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)fgetline.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: fgetln.c,v 1.2 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+#if 0
+#include "namespace.h"
+#endif
+
+#include <nbcompat/stdio.h>
+
+#if 0
+#include "reentrant.h"
+#include "local.h"
+#endif
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(fgetln,_fgetln)
+#endif
+#endif
+
+/*
+ * Get an input line. The returned pointer often (but not always)
+ * points into a stdio buffer. Fgetline does not alter the text of
+ * the returned line (which is thus not a C string because it will
+ * not necessarily end with '\0'), but does allow callers to modify
+ * it if they wish. Thus, we set __SMOD in case the caller does.
+ */
char *
fgetln(fp, len)
FILE *fp;
@@ -81,4 +113,3 @@ fgetln(fp, len)
*len = (ptr - buf) + 1;
return buf;
}
-
diff --git a/pkgtools/libnbcompat/files/findenv.c b/pkgtools/libnbcompat/files/findenv.c
new file mode 100644
index 00000000000..8c17a2ecc82
--- /dev/null
+++ b/pkgtools/libnbcompat/files/findenv.c
@@ -0,0 +1,88 @@
+/* $NetBSD: findenv.c,v 1.1 2004/08/23 03:32:12 jlam Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)getenv.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: findenv.c,v 1.1 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#if 0
+#include "local.h"
+#include "reentrant.h"
+#endif
+
+#if 0
+#ifdef _REENTRANT
+rwlock_t __environ_lock = RWLOCK_INITIALIZER;
+#endif
+#endif
+extern char **environ;
+
+/*
+ * __findenv --
+ * Returns pointer to value associated with name, if any, else NULL.
+ * Sets offset to be the offset of the name/value combination in the
+ * environmental array, for use by setenv(3) and unsetenv(3).
+ * Explicitly removes '=' in argument name.
+ *
+ * This routine *should* be a static; don't use it.
+ */
+char *
+__findenv(name, offset)
+ const char *name;
+ int *offset;
+{
+ size_t len;
+ const char *np;
+ char **p, *c;
+
+ if (name == NULL || environ == NULL)
+ return (NULL);
+ for (np = name; *np && *np != '='; ++np)
+ continue;
+ len = np - name;
+ for (p = environ; (c = *p) != NULL; ++p)
+ if (strncmp(c, name, len) == 0 && c[len] == '=') {
+ *offset = p - environ;
+ return (c + len + 1);
+ }
+ return (NULL);
+}
diff --git a/pkgtools/libnbcompat/files/fnmatch.c b/pkgtools/libnbcompat/files/fnmatch.c
index cbbe629312f..3a897213b8a 100644
--- a/pkgtools/libnbcompat/files/fnmatch.c
+++ b/pkgtools/libnbcompat/files/fnmatch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fnmatch.c,v 1.2 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: fnmatch.c,v 1.3 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -32,17 +32,13 @@
* SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
-static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
+static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
#else
-__RCSID("$NetBSD: fnmatch.c,v 1.2 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: fnmatch.c,v 1.3 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -51,19 +47,17 @@ __RCSID("$NetBSD: fnmatch.c,v 1.2 2004/08/16 17:24:56 jlam Exp $");
* Compares a filename or pathname to a pattern.
*/
-/* #include "namespace.h" */
+#if 0
+#include "namespace.h"
+#endif
-#include <assert.h>
-#include <ctype.h>
-#include "nbcompat/fnmatch.h"
-#include <string.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/fnmatch.h>
+#include <nbcompat/string.h>
#define EOS '\0'
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
static const char *rangematch(const char *, int, int);
static int
diff --git a/pkgtools/libnbcompat/files/fparseln.c b/pkgtools/libnbcompat/files/fparseln.c
index 380e85798b9..95a37811312 100644
--- a/pkgtools/libnbcompat/files/fparseln.c
+++ b/pkgtools/libnbcompat/files/fparseln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fparseln.c,v 1.2 2003/09/06 23:03:02 grant Exp $ */
+/* $NetBSD: fparseln.c,v 1.3 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -29,7 +29,49 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: fparseln.c,v 1.3 2004/08/23 03:32:12 jlam Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#if 0
+#include "namespace.h"
+#endif
+
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdio.h>
+#include <nbcompat/string.h>
+#include <nbcompat/stdlib.h>
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(fparseln,_fparseln)
+#endif
+#endif
+
+#if ! HAVE_FPARSELN
+
+#if 0
+#ifndef HAVE_NBTOOL_CONFIG_H
+#include "reentrant.h"
+#include "local.h"
+#else
+#define FLOCKFILE(fp)
+#define FUNLOCKFILE(fp)
+#endif
+#endif
+
+#if 0
+#if defined(_REENTRANT) && !HAVE_NBTOOL_CONFIG_H
+#define __fgetln(f, l) __fgetstr(f, l, '\n')
+#else
+#define __fgetln(f, l) fgetln(f, l)
+#endif
+#endif
static int isescaped(const char *, const char *, int);
@@ -204,3 +246,4 @@ line 6
*/
#endif /* TEST */
+#endif /* ! HAVE_FPARSELN */
diff --git a/pkgtools/libnbcompat/files/fts.c b/pkgtools/libnbcompat/files/fts.c
new file mode 100644
index 00000000000..29fd40f4006
--- /dev/null
+++ b/pkgtools/libnbcompat/files/fts.c
@@ -0,0 +1,12 @@
+/* $NetBSD: fts.c,v 1.1 2004/08/23 03:32:12 jlam Exp $ */
+
+/*
+ * Written by Jason R. Thorpe <thorpej@NetBSD.org>, October 21, 1997.
+ * Public domain.
+ */
+
+#if 0
+#define __LIBC12_SOURCE__
+#endif
+
+#include "__fts13.c"
diff --git a/pkgtools/libnbcompat/files/getenv.c b/pkgtools/libnbcompat/files/getenv.c
index 024f494ad40..6ee384eaa1d 100644
--- a/pkgtools/libnbcompat/files/getenv.c
+++ b/pkgtools/libnbcompat/files/getenv.c
@@ -1,8 +1,8 @@
-/* $NetBSD: getenv.c,v 1.3 2003/09/06 23:03:02 grant Exp $ */
+/* $NetBSD: getenv.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,15 +29,42 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)getenv.c 5.8 (Berkeley) 2/23/91";*/
-static char *rcsid = "$Id: getenv.c,v 1.3 2003/09/06 23:03:02 grant Exp $";
+#if 0
+static char sccsid[] = "@(#)getenv.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: getenv.c,v 1.4 2004/08/23 03:32:12 jlam Exp $");
+#endif
#endif /* LIBC_SCCS and not lint */
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/cdefs.h>
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#if 0
+#include "local.h"
+#include "reentrant.h"
+#endif
+
+char *__findenv __P((const char *, int *));
+
+#if 0
+#ifdef _REENTRANT
+rwlock_t __environ_lock = RWLOCK_INITIALIZER;
+#endif
+#endif
+extern char **environ;
+
+#ifndef rwlock_rdlock
+#define rwlock_rdlock(lock) ((void)0)
+#endif
+#ifndef rwlock_unlock
+#define rwlock_unlock(lock) ((void)0)
+#endif
/*
* getenv --
@@ -48,9 +75,14 @@ getenv(name)
const char *name;
{
int offset;
- char *__findenv();
+ char *result;
- return(__findenv(name, &offset));
+ _DIAGASSERT(name != NULL);
+
+ rwlock_rdlock(&__environ_lock);
+ result = __findenv(name, &offset);
+ rwlock_unlock(&__environ_lock);
+ return (result);
}
/*
@@ -64,19 +96,22 @@ getenv(name)
*/
char *
__findenv(name, offset)
- register char *name;
+ const char *name;
int *offset;
{
- extern char **environ;
- register int len;
- register char **P, *C;
+ size_t len;
+ const char *np;
+ char **p, *c;
- for (C = name, len = 0; *C && *C != '='; ++C, ++len);
- for (P = environ; *P; ++P)
- if (!strncmp(*P, name, len))
- if (*(C = *P + len) == '=') {
- *offset = P - environ;
- return(++C);
- }
- return(NULL);
+ if (name == NULL || environ == NULL)
+ return (NULL);
+ for (np = name; *np && *np != '='; ++np)
+ continue;
+ len = np - name;
+ for (p = environ; (c = *p) != NULL; ++p)
+ if (strncmp(c, name, len) == 0 && c[len] == '=') {
+ *offset = p - environ;
+ return (c + len + 1);
+ }
+ return (NULL);
}
diff --git a/pkgtools/libnbcompat/files/getopt_long.c b/pkgtools/libnbcompat/files/getopt_long.c
index 8ff67c79dda..9e7ce1d45ee 100644
--- a/pkgtools/libnbcompat/files/getopt_long.c
+++ b/pkgtools/libnbcompat/files/getopt_long.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getopt_long.c,v 1.7 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: getopt_long.c,v 1.8 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -36,64 +36,57 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: getopt_long.c,v 1.7 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: getopt_long.c,v 1.8 2004/08/23 03:32:12 jlam Exp $");
#endif /* LIBC_SCCS and not lint */
-/* #include "namespace.h" */
-
-#include <assert.h>
-
-#if HAVE_ERR_H
-#include <err.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/err.h>
+#if HAVE_ERRNO_H
#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
#endif
+#if HAVE_NBTOOL_CONFIG_H
+#include "compat_getopt.h"
+#else
+#include <nbcompat/getopt.h>
+#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
-#if HAVE_CONFIG_H && !HAVE_GETOPT_LONG && !HAVE_OPTIND_D
+#if (HAVE_NBTOOL_CONFIG_H && !HAVE_GETOPT_LONG && !HAVE_DECL_OPTIND) || 1
#define REPLACE_GETOPT
#endif
#ifdef REPLACE_GETOPT
#if 0
-#ifndef __ELF__
-#define _getopt getopt
-#else
#ifdef __weak_alias
__weak_alias(getopt,_getopt)
#endif
#endif
-#endif
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt = '?'; /* character checked for validity */
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
-#elif HAVE_CONFIG_H && !HAVE_DECL_OPTRESET
+#elif HAVE_NBTOOL_CONFIG_H && !HAVE_DECL_OPTRESET
static int optreset;
#endif
#if 0
-#ifndef __ELF__
-#define _getopt_long getopt_long
-#else
#ifdef __weak_alias
__weak_alias(getopt_long,_getopt_long)
#endif
#endif
-#endif
#if !HAVE_GETOPT_LONG
#define IGNORE_FIRST (*options == '-' || *options == '+')
diff --git a/pkgtools/libnbcompat/files/gettemp.c b/pkgtools/libnbcompat/files/gettemp.c
new file mode 100644
index 00000000000..2500a7114a0
--- /dev/null
+++ b/pkgtools/libnbcompat/files/gettemp.c
@@ -0,0 +1,180 @@
+/* $NetBSD: gettemp.c,v 1.1 2004/08/23 03:32:12 jlam Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP || !HAVE_MKDTEMP
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: gettemp.c,v 1.1 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <nbcompat/types.h>
+#include <nbcompat/stat.h>
+
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
+
+#if HAVE_NBTOOL_CONFIG_H
+#define GETTEMP gettemp
+#else
+#if 0
+#include "reentrant.h"
+#include "local.h"
+#define GETTEMP __gettemp
+#else
+#define GETTEMP gettemp
+#endif
+#endif
+
+
+int
+GETTEMP(path, doopen, domkdir)
+ char *path;
+ int *doopen;
+ int domkdir;
+{
+ char *start, *trv;
+ struct stat sbuf;
+ u_int pid;
+
+ /* To guarantee multiple calls generate unique names even if
+ the file is not created. 676 different possibilities with 7
+ or more X's, 26 with 6 or less. */
+ static char xtra[2] = "aa";
+ int xcnt = 0;
+
+ _DIAGASSERT(path != NULL);
+ /* doopen may be NULL */
+
+ pid = getpid();
+
+ /* Move to end of path and count trailing X's. */
+ for (trv = path; *trv; ++trv)
+ if (*trv == 'X')
+ xcnt++;
+ else
+ xcnt = 0;
+
+ /* Use at least one from xtra. Use 2 if more than 6 X's. */
+ if (*(trv - 1) == 'X')
+ *--trv = xtra[0];
+ if (xcnt > 6 && *(trv - 1) == 'X')
+ *--trv = xtra[1];
+
+ /* Set remaining X's to pid digits with 0's to the left. */
+ while (*--trv == 'X') {
+ *trv = (pid % 10) + '0';
+ pid /= 10;
+ }
+
+ /* update xtra for next call. */
+ if (xtra[0] != 'z')
+ xtra[0]++;
+ else {
+ xtra[0] = 'a';
+ if (xtra[1] != 'z')
+ xtra[1]++;
+ else
+ xtra[1] = 'a';
+ }
+
+ /*
+ * check the target directory; if you have six X's and it
+ * doesn't exist this runs for a *very* long time.
+ */
+ for (start = trv + 1;; --trv) {
+ if (trv <= path)
+ break;
+ if (*trv == '/') {
+ *trv = '\0';
+ if (stat(path, &sbuf))
+ return (0);
+ if (!S_ISDIR(sbuf.st_mode)) {
+ errno = ENOTDIR;
+ return (0);
+ }
+ *trv = '/';
+ break;
+ }
+ }
+
+ for (;;) {
+ if (doopen) {
+ if ((*doopen =
+ open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)
+ return (1);
+ if (errno != EEXIST)
+ return (0);
+ } else if (domkdir) {
+ if (mkdir(path, 0700) >= 0)
+ return (1);
+ if (errno != EEXIST)
+ return (0);
+ } else if (lstat(path, &sbuf))
+ return (errno == ENOENT ? 1 : 0);
+
+ /* tricky little algorithm for backward compatibility */
+ for (trv = start;;) {
+ if (!*trv)
+ return (0);
+ if (*trv == 'z')
+ *trv++ = 'a';
+ else {
+ if (isdigit((unsigned char)*trv))
+ *trv = 'a';
+ else
+ ++*trv;
+ break;
+ }
+ }
+ }
+ /*NOTREACHED*/
+}
+
+#endif /* !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP || !HAVE_MKDTEMP */
diff --git a/pkgtools/libnbcompat/files/glob.c b/pkgtools/libnbcompat/files/glob.c
index e129ad56003..bfb1cb658a7 100644
--- a/pkgtools/libnbcompat/files/glob.c
+++ b/pkgtools/libnbcompat/files/glob.c
@@ -1,882 +1,12 @@
-/* $NetBSD: glob.c,v 1.3 2003/09/06 23:03:02 grant Exp $ */
+/* $NetBSD: glob.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * Written by Jason R. Thorpe <thorpej@NetBSD.org>, October 21, 1997.
+ * Public domain.
*/
-/*
- * glob(3) -- a superset of the one defined in POSIX 1003.2.
- *
- * The [!...] convention to negate a range is supported (SysV, Posix, ksh).
- *
- * Optional extra services, controlled by flags not defined by POSIX:
- *
- * GLOB_MAGCHAR:
- * Set in gl_flags if pattern contained a globbing character.
- * GLOB_NOMAGIC:
- * Same as GLOB_NOCHECK, but it will only append pattern if it did
- * not contain any magic characters. [Used in csh style globbing]
- * GLOB_ALTDIRFUNC:
- * Use alternately specified directory access functions.
- * GLOB_TILDE:
- * expand ~user/foo to the /home/dir/of/user/foo
- * GLOB_BRACE:
- * expand {1,2}{a,b} to 1a 1b 2a 2b
- * gl_matchc:
- * Number of matches in the current invocation of glob.
- */
-
-#include "nbcompat.h"
-
-#undef TILDE /* XXX: AIX 4.1.5 has this in <sys/ioctl.h> */
-
-#define DOLLAR '$'
-#define DOT '.'
-#define EOS '\0'
-#define LBRACKET '['
-#define NOT '!'
-#define QUESTION '?'
-#define QUOTE '\\'
-#define RANGE '-'
-#define RBRACKET ']'
-#define SEP '/'
-#define STAR '*'
-#define TILDE '~'
-#define UNDERSCORE '_'
-#define LBRACE '{'
-#define RBRACE '}'
-#define SLASH '/'
-#define COMMA ','
-
-#ifndef DEBUG
-
-#define M_QUOTE 0x8000
-#define M_PROTECT 0x4000
-#define M_MASK 0xffff
-#define M_ASCII 0x00ff
-
-typedef u_short Char;
-
-#else
-
-#define M_QUOTE 0x80
-#define M_PROTECT 0x40
-#define M_MASK 0xff
-#define M_ASCII 0x7f
-
-typedef char Char;
-
-#endif
-
-
-#define CHAR(c) ((Char)((c)&M_ASCII))
-#define META(c) ((Char)((c)|M_QUOTE))
-#define M_ALL META('*')
-#define M_END META(']')
-#define M_NOT META('!')
-#define M_ONE META('?')
-#define M_RNG META('-')
-#define M_SET META('[')
-#define ismeta(c) (((c)&M_QUOTE) != 0)
-
-
-static int compare(const void *, const void *);
-static int g_Ctoc(const Char *, char *, size_t);
-static int g_lstat(Char *, struct stat *, glob_t *);
-static DIR *g_opendir(Char *, glob_t *);
-static Char *g_strchr(const Char *, int);
-static int g_stat(Char *, struct stat *, glob_t *);
-static int glob0(const Char *, glob_t *);
-static int glob1(Char *, glob_t *, size_t *);
-static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *);
-static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
- size_t *);
-static int globextend(const Char *, glob_t *, size_t *);
-static const Char *globtilde(const Char *, Char *, size_t, glob_t *);
-static int globexp1(const Char *, glob_t *);
-static int globexp2(const Char *, const Char *, glob_t *, int *);
-static int match(Char *, Char *, Char *);
-#ifdef DEBUG
-static void qprintf(const char *, Char *);
-#endif
-
-int
-glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
- glob_t *pglob)
-{
- const u_char *patnext;
- int c;
- Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
-
- patnext = (const u_char *) pattern;
- if (!(flags & GLOB_APPEND)) {
- pglob->gl_pathc = 0;
- pglob->gl_pathv = NULL;
- if (!(flags & GLOB_DOOFFS))
- pglob->gl_offs = 0;
- }
- pglob->gl_flags = flags & ~GLOB_MAGCHAR;
- pglob->gl_errfunc = errfunc;
- pglob->gl_matchc = 0;
-
- bufnext = patbuf;
- bufend = bufnext + MAXPATHLEN;
- if (flags & GLOB_NOESCAPE) {
- while (bufnext < bufend && (c = *patnext++) != EOS)
- *bufnext++ = c;
- } else {
- /* Protect the quoted characters. */
- while (bufnext < bufend && (c = *patnext++) != EOS)
- if (c == QUOTE) {
- if ((c = *patnext++) == EOS) {
- c = QUOTE;
- --patnext;
- }
- *bufnext++ = c | M_PROTECT;
- }
- else
- *bufnext++ = c;
- }
- *bufnext = EOS;
-
- if (flags & GLOB_BRACE)
- return globexp1(patbuf, pglob);
- else
- return glob0(patbuf, pglob);
-}
-
-/*
- * Expand recursively a glob {} pattern. When there is no more expansion
- * invoke the standard globbing routine to glob the rest of the magic
- * characters
- */
-static int
-globexp1(const Char *pattern, glob_t *pglob)
-{
- const Char* ptr = pattern;
- int rv;
-
- /* Protect a single {}, for find(1), like csh */
- if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
- return glob0(pattern, pglob);
-
- while ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)
- if (!globexp2(ptr, pattern, pglob, &rv))
- return rv;
-
- return glob0(pattern, pglob);
-}
-
-
-/*
- * Recursive brace globbing helper. Tries to expand a single brace.
- * If it succeeds then it invokes globexp1 with the new pattern.
- * If it fails then it tries to glob the rest of the pattern and returns.
- */
-static int
-globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv)
-{
- int i;
- Char *lm, *ls;
- const Char *pe, *pm, *pl;
- Char patbuf[MAXPATHLEN + 1];
-
- /* copy part up to the brace */
- for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)
- continue;
- ls = lm;
-
- /* Find the balanced brace */
- for (i = 0, pe = ++ptr; *pe; pe++)
- if (*pe == LBRACKET) {
- /* Ignore everything between [] */
- for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
- continue;
- if (*pe == EOS) {
- /*
- * We could not find a matching RBRACKET.
- * Ignore and just look for RBRACE
- */
- pe = pm;
- }
- }
- else if (*pe == LBRACE)
- i++;
- else if (*pe == RBRACE) {
- if (i == 0)
- break;
- i--;
- }
-
- /* Non matching braces; just glob the pattern */
- if (i != 0 || *pe == EOS) {
- /*
- * we use `pattern', not `patbuf' here so that that
- * unbalanced braces are passed to the match
- */
- *rv = glob0(pattern, pglob);
- return 0;
- }
-
- for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
- switch (*pm) {
- case LBRACKET:
- /* Ignore everything between [] */
- for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)
- continue;
- if (*pm == EOS) {
- /*
- * We could not find a matching RBRACKET.
- * Ignore and just look for RBRACE
- */
- pm = pl;
- }
- break;
-
- case LBRACE:
- i++;
- break;
-
- case RBRACE:
- if (i) {
- i--;
- break;
- }
- /* FALLTHROUGH */
- case COMMA:
- if (i && *pm == COMMA)
- break;
- else {
- /* Append the current string */
- for (lm = ls; (pl < pm); *lm++ = *pl++)
- continue;
- /*
- * Append the rest of the pattern after the
- * closing brace
- */
- for (pl = pe + 1; (*lm++ = *pl++) != EOS;)
- continue;
-
- /* Expand the current pattern */
-#ifdef DEBUG
- qprintf("globexp2:", patbuf);
-#endif
- *rv = globexp1(patbuf, pglob);
-
- /* move after the comma, to the next string */
- pl = pm + 1;
- }
- break;
-
- default:
- break;
- }
- }
- *rv = 0;
- return 0;
-}
-
-
-
-/*
- * expand tilde from the passwd file.
- */
-static const Char *
-globtilde(const Char *pattern, Char *patbuf, size_t patsize, glob_t *pglob)
-{
- struct passwd *pwd;
- const char *h;
- const Char *p;
- Char *b;
- char *d;
- Char *pend = &patbuf[patsize / sizeof(Char)];
-
- pend--;
-
- if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
- return pattern;
-
- /* Copy up to the end of the string or / */
- for (p = pattern + 1, d = (char *)(void *)patbuf;
- d < (char *)(void *)pend && *p && *p != SLASH;
- *d++ = *p++)
- continue;
-
- if (d == (char *)(void *)pend)
- return NULL;
-
- *d = EOS;
- d = (char *)(void *)patbuf;
-
- if (*d == EOS) {
- /*
- * handle a plain ~ or ~/ by expanding $HOME
- * first and then trying the password file
- */
- if ((h = getenv("HOME")) == NULL) {
- if ((pwd = getpwuid(getuid())) == NULL)
- return pattern;
- else
- h = pwd->pw_dir;
- }
- }
- else {
- /*
- * Expand a ~user
- */
- if ((pwd = getpwnam(d)) == NULL)
- return pattern;
- else
- h = pwd->pw_dir;
- }
-
- /* Copy the home directory */
- for (b = patbuf; b < pend && *h; *b++ = *h++)
- continue;
-
- if (b == pend)
- return NULL;
-
- /* Append the rest of the pattern */
- while (b < pend && (*b++ = *p++) != EOS)
- continue;
-
- if (b == pend)
- return NULL;
-
- return patbuf;
-}
-
-
-/*
- * The main glob() routine: compiles the pattern (optionally processing
- * quotes), calls glob1() to do the real pattern matching, and finally
- * sorts the list (unless unsorted operation is requested). Returns 0
- * if things went well, nonzero if errors occurred. It is not an error
- * to find no matches.
- */
-static int
-glob0(const Char *pattern, glob_t *pglob)
-{
- const Char *qpatnext;
- int c, error, oldpathc;
- Char *bufnext, patbuf[MAXPATHLEN+1];
- size_t limit;
-
- limit = 0;
- if ((qpatnext = globtilde(pattern, patbuf, sizeof(patbuf),
- pglob)) == NULL)
- return GLOB_ABEND;
- oldpathc = pglob->gl_pathc;
- bufnext = patbuf;
-
- /* We don't need to check for buffer overflow any more. */
- while ((c = *qpatnext++) != EOS) {
- switch (c) {
- case LBRACKET:
- c = *qpatnext;
- if (c == NOT)
- ++qpatnext;
- if (*qpatnext == EOS ||
- g_strchr(qpatnext+1, RBRACKET) == NULL) {
- *bufnext++ = LBRACKET;
- if (c == NOT)
- --qpatnext;
- break;
- }
- *bufnext++ = M_SET;
- if (c == NOT)
- *bufnext++ = M_NOT;
- c = *qpatnext++;
- do {
- *bufnext++ = CHAR(c);
- if (*qpatnext == RANGE &&
- (c = qpatnext[1]) != RBRACKET) {
- *bufnext++ = M_RNG;
- *bufnext++ = CHAR(c);
- qpatnext += 2;
- }
- } while ((c = *qpatnext++) != RBRACKET);
- pglob->gl_flags |= GLOB_MAGCHAR;
- *bufnext++ = M_END;
- break;
- case QUESTION:
- pglob->gl_flags |= GLOB_MAGCHAR;
- *bufnext++ = M_ONE;
- break;
- case STAR:
- pglob->gl_flags |= GLOB_MAGCHAR;
- /* collapse adjacent stars to one,
- * to avoid exponential behavior
- */
- if (bufnext == patbuf || bufnext[-1] != M_ALL)
- *bufnext++ = M_ALL;
- break;
- default:
- *bufnext++ = CHAR(c);
- break;
- }
- }
- *bufnext = EOS;
-#ifdef DEBUG
- qprintf("glob0:", patbuf);
+#if 0
+#define __LIBC12_SOURCE__
#endif
- if ((error = glob1(patbuf, pglob, &limit)) != 0)
- return(error);
-
- if (pglob->gl_pathc == oldpathc) {
- /*
- * If there was no match we are going to append the pattern
- * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was
- * specified and the pattern did not contain any magic
- * characters GLOB_NOMAGIC is there just for compatibility
- * with csh.
- */
- if ((pglob->gl_flags & GLOB_NOCHECK) ||
- ((pglob->gl_flags & (GLOB_NOMAGIC|GLOB_MAGCHAR))
- == GLOB_NOMAGIC)) {
- return globextend(pattern, pglob, &limit);
- } else {
- return (GLOB_NOMATCH);
- }
- } else if (!(pglob->gl_flags & GLOB_NOSORT)) {
- qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
- (size_t)pglob->gl_pathc - oldpathc, sizeof(char *),
- compare);
- }
-
- return(0);
-}
-
-static int
-compare(const void *p, const void *q)
-{
-
- return(strcoll(*(const char * const *)p, *(const char * const *)q));
-}
-
-static int
-glob1(Char *pattern, glob_t *pglob, size_t *limit)
-{
- Char pathbuf[MAXPATHLEN+1];
-
- /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
- if (*pattern == EOS)
- return(0);
- /*
- * we save one character so that we can use ptr >= limit,
- * in the general case when we are appending non nul chars only.
- */
- return(glob2(pathbuf, pathbuf, pathbuf + sizeof(pathbuf) - 1, pattern,
- pglob, limit));
-}
-
-/*
- * The functions glob2 and glob3 are mutually recursive; there is one level
- * of recursion for each segment in the pattern that contains one or more
- * meta characters.
- */
-static int
-glob2(Char *pathbuf, Char *pathend, Char *pathlim,
- Char *pattern, glob_t *pglob, size_t *limit)
-{
- struct stat sb;
- Char *p, *q;
- int anymeta;
-
- /*
- * Loop over pattern segments until end of pattern or until
- * segment with meta character found.
- */
- for (anymeta = 0;;) {
- if (*pattern == EOS) { /* End of pattern? */
- *pathend = EOS;
- if (g_lstat(pathbuf, &sb, pglob))
- return(0);
-
- if (((pglob->gl_flags & GLOB_MARK) &&
- pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) ||
- (S_ISLNK(sb.st_mode) &&
- (g_stat(pathbuf, &sb, pglob) == 0) &&
- S_ISDIR(sb.st_mode)))) {
- if (pathend >= pathlim)
- return (GLOB_ABORTED);
- *pathend++ = SEP;
- *pathend = EOS;
- }
- ++pglob->gl_matchc;
- return(globextend(pathbuf, pglob, limit));
- }
-
- /* Find end of next segment, copy tentatively to pathend. */
- q = pathend;
- p = pattern;
- while (*p != EOS && *p != SEP) {
- if (ismeta(*p))
- anymeta = 1;
- if (q >= pathlim)
- return GLOB_ABORTED;
- *q++ = *p++;
- }
-
- if (!anymeta) { /* No expansion, do next segment. */
- pathend = q;
- pattern = p;
- while (*pattern == SEP) {
- if (pathend >= pathlim)
- return GLOB_ABORTED;
- *pathend++ = *pattern++;
- }
- } else /* Need expansion, recurse. */
- return(glob3(pathbuf, pathend, pathlim, pattern, p,
- pglob, limit));
- }
- /* NOTREACHED */
-}
-
-static int
-glob3(Char *pathbuf, Char *pathend, Char *pathlim,
- Char *pattern, Char *restpattern, glob_t *pglob, size_t *limit)
-{
- struct dirent *dp;
- DIR *dirp;
- int error;
- char buf[MAXPATHLEN];
-
- /*
- * The readdirfunc declaration can't be prototyped, because it is
- * assigned, below, to two functions which are prototyped in glob.h
- * and dirent.h as taking pointers to differently typed opaque
- * structures.
- */
- struct dirent *(*readdirfunc)(void *);
-
- *pathend = EOS;
- errno = 0;
-
- if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
- if (pglob->gl_errfunc) {
- if (g_Ctoc(pathbuf, buf, sizeof(buf)))
- return (GLOB_ABORTED);
- if (pglob->gl_errfunc(buf, errno) ||
- pglob->gl_flags & GLOB_ERR)
- return (GLOB_ABORTED);
- }
- /*
- * Posix/XOpen: glob should return when it encounters a
- * directory that it cannot open or read
- * XXX: Should we ignore ENOTDIR and ENOENT though?
- * I think that Posix had in mind EPERM...
- */
- if (pglob->gl_flags & GLOB_ERR)
- return (GLOB_ABORTED);
-
- return(0);
- }
-
- error = 0;
-
- /* Search directory for matching names. */
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- readdirfunc = pglob->gl_readdir;
- else
- readdirfunc = (struct dirent *(*)(void *)) readdir;
- while ((dp = (*readdirfunc)(dirp)) != NULL) {
- u_char *sc;
- Char *dc;
-
- /* Initial DOT must be matched literally. */
- if (dp->d_name[0] == DOT && *pattern != DOT)
- continue;
- /*
- * The resulting string contains EOS, so we can
- * use the pathlim character, if it is the nul
- */
- for (sc = (u_char *) dp->d_name, dc = pathend;
- dc <= pathlim && (*dc++ = *sc++) != EOS;)
- continue;
-
- /*
- * Have we filled the buffer without seeing EOS?
- */
- if (dc > pathlim && *pathlim != EOS) {
- /*
- * Abort when requested by caller, otherwise
- * reset pathend back to last SEP and continue
- * with next dir entry.
- */
- if (pglob->gl_flags & GLOB_ERR) {
- error = GLOB_ABORTED;
- break;
- }
- else {
- *pathend = EOS;
- continue;
- }
- }
-
- if (!match(pathend, pattern, restpattern)) {
- *pathend = EOS;
- continue;
- }
- error = glob2(pathbuf, --dc, pathlim, restpattern, pglob, limit);
- if (error)
- break;
- }
-
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- (*pglob->gl_closedir)(dirp);
- else
- closedir(dirp);
-
- /*
- * Again Posix X/Open issue with regards to error handling.
- */
- if ((error || errno) && (pglob->gl_flags & GLOB_ERR))
- return (GLOB_ABORTED);
-
- return(error);
-}
-
-
-/*
- * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
- * add the new item, and update gl_pathc.
- *
- * This assumes the BSD realloc, which only copies the block when its size
- * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic
- * behavior.
- *
- * Return 0 if new item added, error code if memory couldn't be allocated.
- *
- * Invariant of the glob_t structure:
- * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
- * gl_pathv points to (gl_offs + gl_pathc + 1) items.
- */
-static int
-globextend(const Char *path, glob_t *pglob, size_t *limit)
-{
- char **pathv;
- int i;
- size_t newsize, len;
- char *copy;
- const Char *p;
-
- newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
- pathv = pglob->gl_pathv ? realloc(pglob->gl_pathv, newsize) :
- malloc(newsize);
- if (pathv == NULL)
- return(GLOB_NOSPACE);
-
- if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
- /* first time around -- clear initial gl_offs items */
- pathv += pglob->gl_offs;
- for (i = pglob->gl_offs; --i >= 0; )
- *--pathv = NULL;
- }
- pglob->gl_pathv = pathv;
-
- for (p = path; *p++;)
- continue;
- len = (size_t)(p - path);
- *limit += len;
- if ((copy = malloc(len)) != NULL) {
- if (g_Ctoc(path, copy, len)) {
- free(copy);
- return(GLOB_ABORTED);
- }
- pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
- }
- pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
-
- if ((pglob->gl_flags & GLOB_LIMIT) && (newsize + *limit) >= ARG_MAX) {
- errno = 0;
- return(GLOB_NOSPACE);
- }
-
- return(copy == NULL ? GLOB_NOSPACE : 0);
-}
-
-
-/*
- * pattern matching function for filenames. Each occurrence of the *
- * pattern causes a recursion level.
- */
-static int
-match(Char *name, Char *pat, Char *patend)
-{
- int ok, negate_range;
- Char c, k;
-
- while (pat < patend) {
- c = *pat++;
- switch (c & M_MASK) {
- case M_ALL:
- if (pat == patend)
- return(1);
- do
- if (match(name, pat, patend))
- return(1);
- while (*name++ != EOS);
- return(0);
- case M_ONE:
- if (*name++ == EOS)
- return(0);
- break;
- case M_SET:
- ok = 0;
- if ((k = *name++) == EOS)
- return(0);
- if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
- ++pat;
- while (((c = *pat++) & M_MASK) != M_END)
- if ((*pat & M_MASK) == M_RNG) {
- if (c <= k && k <= pat[1])
- ok = 1;
- pat += 2;
- } else if (c == k)
- ok = 1;
- if (ok == negate_range)
- return(0);
- break;
- default:
- if (*name++ != c)
- return(0);
- break;
- }
- }
- return(*name == EOS);
-}
-
-/* Free allocated data belonging to a glob_t structure. */
-void
-globfree(glob_t *pglob)
-{
- int i;
- char **pp;
-
- if (pglob->gl_pathv != NULL) {
- pp = pglob->gl_pathv + pglob->gl_offs;
- for (i = pglob->gl_pathc; i--; ++pp)
- if (*pp)
- free(*pp);
- free(pglob->gl_pathv);
- pglob->gl_pathv = NULL;
- pglob->gl_pathc = 0;
- }
-}
-
-static DIR *
-g_opendir(Char *str, glob_t *pglob)
-{
- char buf[MAXPATHLEN];
-
- if (!*str)
- (void)strcpy(buf, ".");
- else {
- if (g_Ctoc(str, buf, sizeof(buf)))
- return NULL;
- }
-
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_opendir)(buf));
-
- return(opendir(buf));
-}
-
-static int
-g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
-{
- char buf[MAXPATHLEN];
-
- if (g_Ctoc(fn, buf, sizeof(buf)))
- return -1;
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_lstat)(buf, sb));
- return(lstat(buf, sb));
-}
-
-static int
-g_stat(Char *fn, struct stat *sb, glob_t *pglob)
-{
- char buf[MAXPATHLEN];
-
- if (g_Ctoc(fn, buf, sizeof(buf)))
- return -1;
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_stat)(buf, sb));
- return(stat(buf, sb));
-}
-
-static Char *
-g_strchr(const Char *str, int ch)
-{
- do {
- if (*str == ch)
- /* LINTED this is libc's definition! */
- return (Char *)str;
- } while (*str++);
- return (NULL);
-}
-
-static int
-g_Ctoc(const Char *str, char *buf, size_t len)
-{
- char *dc;
-
- if (len == 0)
- return 1;
-
- for (dc = buf; len && (*dc++ = *str++) != EOS; len--)
- continue;
-
- return len == 0;
-}
-
-#ifdef DEBUG
-static void
-qprintf(const char *str, Char *s)
-{
- Char *p;
-
- (void)printf("%s:\n", str);
- for (p = s; *p; p++)
- (void)printf("%c", CHAR(*p));
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", *p & M_PROTECT ? '"' : ' ');
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", ismeta(*p) ? '_' : ' ');
- (void)printf("\n");
-}
-#endif
+#include "__glob13.c"
diff --git a/pkgtools/libnbcompat/files/isblank.c b/pkgtools/libnbcompat/files/isblank.c
index ad0fb8e1250..0d182359912 100644
--- a/pkgtools/libnbcompat/files/isblank.c
+++ b/pkgtools/libnbcompat/files/isblank.c
@@ -1,6 +1,53 @@
-/* $NetBSD: isblank.c,v 1.4 2003/09/06 23:03:03 grant Exp $ */
+/* $NetBSD: isblank.c,v 1.5 2004/08/23 03:32:12 jlam Exp $ */
-#include "nbcompat.h"
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)isctype.c 5.2 (Berkeley) 6/1/90";
+#else
+__RCSID("$NetBSD: isblank.c,v 1.5 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if 0
+#define _ANSI_LIBRARY
+#endif
+#include <nbcompat/ctype.h>
int
isblank(c)
diff --git a/pkgtools/libnbcompat/files/lchflags.c b/pkgtools/libnbcompat/files/lchflags.c
index d8cfbe2dab5..70f44003848 100644
--- a/pkgtools/libnbcompat/files/lchflags.c
+++ b/pkgtools/libnbcompat/files/lchflags.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lchflags.c,v 1.1.1.1 2003/03/31 05:02:49 grant Exp $ */
+/* $NetBSD: lchflags.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -39,10 +39,9 @@
/* Emulate lchflags(2), checking path with lstat(2) first to ensure that
* it's not a symlink, and then call chflags(2) */
-#include "nbcompat.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
+#include <nbcompat.h>
+#include <nbcompat/stat.h>
+#include <nbcompat/unistd.h>
int
lchflags(const char *path, u_long flags)
diff --git a/pkgtools/libnbcompat/files/lchmod.c b/pkgtools/libnbcompat/files/lchmod.c
index ae25155197d..697de1ed855 100644
--- a/pkgtools/libnbcompat/files/lchmod.c
+++ b/pkgtools/libnbcompat/files/lchmod.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lchmod.c,v 1.1.1.1 2003/03/31 05:02:51 grant Exp $ */
+/* $NetBSD: lchmod.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -39,10 +39,9 @@
/* Emulate lchmod(2), checking path with lstat(2) first to ensure that
* it's not a symlink, and then call chmod(2) */
-#include "nbcompat.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
+#include <nbcompat.h>
+#include <nbcompat/stat.h>
+#include <nbcompat/unistd.h>
int
lchmod(const char *path, mode_t mode)
diff --git a/pkgtools/libnbcompat/files/lchown.c b/pkgtools/libnbcompat/files/lchown.c
index 200b1f63d5f..09fcbbde5f1 100644
--- a/pkgtools/libnbcompat/files/lchown.c
+++ b/pkgtools/libnbcompat/files/lchown.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lchown.c,v 1.1.1.1 2003/03/31 05:02:52 grant Exp $ */
+/* $NetBSD: lchown.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -39,8 +39,9 @@
/* Emulate lchown(2), checking path with lstat(2) first to ensure that
* it's not a symlink, and then call chown(2) */
-#include <sys/stat.h>
-#include <unistd.h>
+#include <nbcompat.h>
+#include <nbcompat/stat.h>
+#include <nbcompat/unistd.h>
int
lchown(const char *path, uid_t owner, gid_t group)
diff --git a/pkgtools/libnbcompat/files/lutimes.c b/pkgtools/libnbcompat/files/lutimes.c
index 9add9ba8a67..e1ff535826f 100644
--- a/pkgtools/libnbcompat/files/lutimes.c
+++ b/pkgtools/libnbcompat/files/lutimes.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lutimes.c,v 1.1.1.1 2003/03/31 05:02:54 grant Exp $ */
+/* $NetBSD: lutimes.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -39,10 +39,9 @@
/* Emulate lutimes(2), checking path with lstat(2) first to ensure that
* it's not a symlink, and then call chmod(2) */
-#include "nbcompat.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
+#include <nbcompat.h>
+#include <nbcompat/stat.h>
+#include <nbcompat/unistd.h>
int
lutimes(const char *path, const struct timeval *times)
diff --git a/pkgtools/libnbcompat/files/md5c.c b/pkgtools/libnbcompat/files/md5c.c
index 4b57ef30424..b3b1ee93441 100644
--- a/pkgtools/libnbcompat/files/md5c.c
+++ b/pkgtools/libnbcompat/files/md5c.c
@@ -1,8 +1,8 @@
-/* $NetBSD: md5c.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: md5c.c,v 1.6 2004/08/23 03:32:12 jlam Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm and has been modifed by Jason R. Thorpe <thorpej@NetBSD.ORG>
+ * Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.org>
* for portability and formatting.
*/
@@ -29,29 +29,36 @@
* documentation and/or software.
*/
-#include "nbcompat/nbconfig.h"
-#include "nbcompat/nbtypes.h"
-
#if defined(_KERNEL) || defined(_STANDALONE)
#include <lib/libkern/libkern.h>
#include <sys/param.h>
#include <sys/md5.h>
#define _DIAGASSERT(x) (void)0
#else
-/* #include "namespace.h" */
-#include <assert.h>
-#include <string.h>
-#include "nbcompat/md5.h"
+#if 0
+#include "namespace.h"
+#endif
+#include <nbcompat.h>
+#include <nbcompat/types.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/string.h>
+#include <nbcompat/md5.h>
#endif /* _KERNEL || _STANDALONE */
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#if !HAVE_MD5_H
+
#if defined(HAVE_MEMSET)
-#define ZEROIZE(d, l) memset((d), 0, (l))
-#else
+#define ZEROIZE(d, l) memset((d), 0, (l))
+#else
# if defined(HAVE_BZERO)
#define ZEROIZE(d, l) bzero((d), (l))
# else
-#error You need either memset or bzero
-# endif
+#error You need either memset or bzero
+# endif
#endif
typedef unsigned char *POINTER;
@@ -86,10 +93,6 @@ __weak_alias(MD5Final,_MD5Final)
#endif
#endif
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
static void MD5Transform __P((UINT4 [4], const unsigned char [64]));
static void Encode __P((unsigned char *, UINT4 *, unsigned int));
@@ -229,7 +232,7 @@ MD5Update(context, input, inputLen)
if (inputLen >= partLen) {
/* LINTED const castaway ok */
memcpy((POINTER)&context->buffer[idx],
- input, partLen);
+ (POINTER)input, partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
@@ -241,7 +244,7 @@ MD5Update(context, input, inputLen)
/* Buffer remaining input */
/* LINTED const castaway ok */
- memcpy((POINTER)&context->buffer[idx], &input[i],
+ memcpy((POINTER)&context->buffer[idx], (POINTER)&input[i],
inputLen - i);
}
@@ -370,3 +373,5 @@ MD5Transform(state, block)
/* Zeroize sensitive information. */
ZEROIZE((POINTER)(void *)x, sizeof (x));
}
+
+#endif /* HAVE_MD5_H */
diff --git a/pkgtools/libnbcompat/files/md5hl.c b/pkgtools/libnbcompat/files/md5hl.c
index c444e005717..64d80fbdf68 100644
--- a/pkgtools/libnbcompat/files/md5hl.c
+++ b/pkgtools/libnbcompat/files/md5hl.c
@@ -1,122 +1,22 @@
-/* $NetBSD: md5hl.c,v 1.6 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: md5hl.c,v 1.7 2004/08/23 03:32:12 jlam Exp $ */
/*
- * Written by Jason R. Thorpe <thorpej@netbsd.org>, April 29, 1997.
+ * Written by Jason R. Thorpe <thorpej@NetBSD.org>, April 29, 1997.
* Public domain.
*/
-#include "nbcompat/nbconfig.h"
-#include "nbcompat/nbtypes.h"
-
-/* #include "namespace.h" */
-
#define MDALGORITHM MD5
-#include "nbcompat/md5.h"
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat.h>
+#include <nbcompat/md5.h>
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * from FreeBSD Id: mdXhl.c,v 1.8 1996/10/25 06:48:12 bde Exp
- */
-
-/*
- * Modifed April 29, 1997 by Jason R. Thorpe <thorpej@netbsd.org>
- */
-
-#include <assert.h>
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
#endif
-#define CONCAT(x,y) __CONCAT(x,y)
-#define MDNAME(x) CONCAT(MDALGORITHM,x)
-
-char *
-MDNAME(End)(ctx, buf)
- MDNAME(_CTX) *ctx;
- char *buf;
-{
- int i;
- unsigned char digest[16];
- static const char hex[]="0123456789abcdef";
-
- _DIAGASSERT(ctx != 0);
-
- if (buf == NULL)
- buf = malloc(33);
- if (buf == NULL)
- return (NULL);
-
- MDNAME(Final)(digest, ctx);
-
- for (i = 0; i < 16; i++) {
- buf[i+i] = hex[(u_int32_t)digest[i] >> 4];
- buf[i+i+1] = hex[digest[i] & 0x0f];
- }
-
- buf[i+i] = '\0';
- return (buf);
-}
-
-char *
-MDNAME(File)(filename, buf)
- const char *filename;
- char *buf;
-{
- unsigned char buffer[BUFSIZ];
- MDNAME(_CTX) ctx;
- int f, i, j;
-
- _DIAGASSERT(filename != 0);
- /* buf may be NULL */
-
- MDNAME(Init)(&ctx);
- f = open(filename, O_RDONLY, 0666);
- if (f < 0)
- return NULL;
-
- while ((i = read(f, buffer, sizeof(buffer))) > 0)
- MDNAME(Update)(&ctx, buffer, (unsigned int)i);
-
- j = errno;
- close(f);
- errno = j;
-
- if (i < 0)
- return NULL;
-
- return (MDNAME(End)(&ctx, buf));
-}
-
-char *
-MDNAME(Data)(data, len, buf)
- const unsigned char *data;
- unsigned int len;
- char *buf;
-{
- MDNAME(_CTX) ctx;
-
- _DIAGASSERT(data != 0);
-
- MDNAME(Init)(&ctx);
- MDNAME(Update)(&ctx, data, len);
- return (MDNAME(End)(&ctx, buf));
-}
+#if !HAVE_MD5_H
+#include "mdXhl.c"
+#endif
diff --git a/pkgtools/libnbcompat/files/mdXhl.c b/pkgtools/libnbcompat/files/mdXhl.c
new file mode 100644
index 00000000000..2fece0841e6
--- /dev/null
+++ b/pkgtools/libnbcompat/files/mdXhl.c
@@ -0,0 +1,105 @@
+/* $NetBSD: mdXhl.c,v 1.1 2004/08/23 03:32:12 jlam Exp $ */
+
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * from FreeBSD Id: mdXhl.c,v 1.8 1996/10/25 06:48:12 bde Exp
+ */
+
+/*
+ * Modifed April 29, 1997 by Jason R. Thorpe <thorpej@NetBSD.org>
+ */
+
+#include <nbcompat.h>
+#include <nbcompat/types.h>
+
+#include <nbcompat/assert.h>
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
+
+#define CONCAT(x,y) __CONCAT(x,y)
+#define MDNAME(x) CONCAT(MDALGORITHM,x)
+
+char *
+MDNAME(End)(ctx, buf)
+ MDNAME(_CTX) *ctx;
+ char *buf;
+{
+ int i;
+ unsigned char digest[16];
+ static const char hex[]="0123456789abcdef";
+
+ _DIAGASSERT(ctx != 0);
+
+ if (buf == NULL)
+ buf = malloc(33);
+ if (buf == NULL)
+ return (NULL);
+
+ MDNAME(Final)(digest, ctx);
+
+ for (i = 0; i < 16; i++) {
+ buf[i+i] = hex[(u_int32_t)digest[i] >> 4];
+ buf[i+i+1] = hex[digest[i] & 0x0f];
+ }
+
+ buf[i+i] = '\0';
+ return (buf);
+}
+
+char *
+MDNAME(File)(filename, buf)
+ const char *filename;
+ char *buf;
+{
+ unsigned char buffer[BUFSIZ];
+ MDNAME(_CTX) ctx;
+ int f, i, j;
+
+ _DIAGASSERT(filename != 0);
+ /* buf may be NULL */
+
+ MDNAME(Init)(&ctx);
+ f = open(filename, O_RDONLY, 0666);
+ if (f < 0)
+ return NULL;
+
+ while ((i = read(f, buffer, sizeof(buffer))) > 0)
+ MDNAME(Update)(&ctx, buffer, (unsigned int)i);
+
+ j = errno;
+ close(f);
+ errno = j;
+
+ if (i < 0)
+ return NULL;
+
+ return (MDNAME(End)(&ctx, buf));
+}
+
+char *
+MDNAME(Data)(data, len, buf)
+ const unsigned char *data;
+ unsigned int len;
+ char *buf;
+{
+ MDNAME(_CTX) ctx;
+
+ _DIAGASSERT(data != 0);
+
+ MDNAME(Init)(&ctx);
+ MDNAME(Update)(&ctx, data, len);
+ return (MDNAME(End)(&ctx, buf));
+}
diff --git a/pkgtools/libnbcompat/files/mkdtemp.c b/pkgtools/libnbcompat/files/mkdtemp.c
index 90fbbea8209..3d9a7a2fd02 100644
--- a/pkgtools/libnbcompat/files/mkdtemp.c
+++ b/pkgtools/libnbcompat/files/mkdtemp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mkdtemp.c,v 1.2 2003/09/04 01:51:16 jlam Exp $ */
+/* $NetBSD: mkdtemp.c,v 1.3 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -29,93 +29,49 @@
* SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
-char *
-mkdtemp(char *path)
-{
- char *start, *trv;
- struct stat sbuf;
- u_int pid;
-
- /* To guarantee multiple calls generate unique names even if
- the file is not created. 676 different possibilities with 7
- or more X's, 26 with 6 or less. */
- static char xtra[2] = "aa";
- int xcnt = 0;
-
- pid = getpid();
-
- /* Move to end of path and count trailing X's. */
- for (trv = path; *trv; ++trv)
- if (*trv == 'X')
- xcnt++;
- else
- xcnt = 0;
+#if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKDTEMP
- /* Use at least one from xtra. Use 2 if more than 6 X's. */
- if (*(trv-1) == 'X')
- *--trv = xtra[0];
- if (xcnt > 6 && *(trv-1) == 'X')
- *--trv = xtra[1];
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: mkdtemp.c,v 1.3 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
- /* Set remaining X's to pid digits with 0's to the left. */
- while (*--trv == 'X') {
- *trv = (pid % 10) + '0';
- pid /= 10;
- }
+#if HAVE_NBTOOL_CONFIG_H
+#define GETTEMP gettemp
+#else
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
+#if 0
+#include "reentrant.h"
+#include "local.h"
+#define GETTEMP __gettemp
+#else
+#define GETTEMP gettemp
+extern int gettemp __P((char *, int *, int));
+#endif
+#endif
- /* update xtra for next call. */
- if (xtra[0] != 'z')
- xtra[0]++;
- else {
- xtra[0] = 'a';
- if (xtra[1] != 'z')
- xtra[1]++;
- else
- xtra[1] = 'a';
- }
-
- /*
- * check the target directory; if you have six X's and it
- * doesn't exist this runs for a *very* long time.
- */
- for (start = trv + 1;; --trv) {
- if (trv <= path)
- break;
- if (*trv == '/') {
- *trv = '\0';
- if (stat(path, &sbuf))
- return (char *)NULL;
- if (!S_ISDIR(sbuf.st_mode)) {
- errno = ENOTDIR;
- return (char *)NULL;
- }
- *trv = '/';
- break;
- }
- }
-
- for (;;) {
- if (mkdir(path, 0700) >= 0)
- return path;
- if (errno != EEXIST)
- return (char *)NULL;
+char *
+mkdtemp(path)
+ char *path;
+{
+ _DIAGASSERT(path != NULL);
- /* tricky little algorithm for backward compatibility */
- for (trv = start;;) {
- if (!*trv)
- return (char *)NULL;
- if (*trv == 'z')
- *trv++ = 'a';
- else {
- if (isdigit((unsigned char)*trv))
- *trv = 'a';
- else
- ++*trv;
- break;
- }
- }
- }
- /*NOTREACHED*/
+ return (GETTEMP(path, (int *)NULL, 1) ? path : (char *)NULL);
}
+
+#endif /* !HAVE_NBTOOL_CONFIG_H || !HAVE_MKDTEMP */
diff --git a/pkgtools/libnbcompat/files/mkstemp.c b/pkgtools/libnbcompat/files/mkstemp.c
index 9eb57dea122..c558d6e8d13 100644
--- a/pkgtools/libnbcompat/files/mkstemp.c
+++ b/pkgtools/libnbcompat/files/mkstemp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mkstemp.c,v 1.3 2003/09/06 23:03:03 grant Exp $ */
+/* $NetBSD: mkstemp.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -29,94 +29,51 @@
* SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
-int
-mkstemp(char *path)
-{
- char *start, *trv;
- struct stat sbuf;
- u_int pid;
- int fd;
-
- /* To guarantee multiple calls generate unique names even if
- the file is not created. 676 different possibilities with 7
- or more X's, 26 with 6 or less. */
- static char xtra[2] = "aa";
- int xcnt = 0;
-
- pid = getpid();
-
- /* Move to end of path and count trailing X's. */
- for (trv = path; *trv; ++trv)
- if (*trv == 'X')
- xcnt++;
- else
- xcnt = 0;
+#if !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP
- /* Use at least one from xtra. Use 2 if more than 6 X's. */
- if (*(trv-1) == 'X')
- *--trv = xtra[0];
- if (xcnt > 6 && *(trv-1) == 'X')
- *--trv = xtra[1];
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: mkstemp.c,v 1.4 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
- /* Set remaining X's to pid digits with 0's to the left. */
- while (*--trv == 'X') {
- *trv = (pid % 10) + '0';
- pid /= 10;
- }
+#if HAVE_NBTOOL_CONFIG_H
+#define GETTEMP gettemp
+#else
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
+#if 0
+#include "reentrant.h"
+#include "local.h"
+#define GETTEMP __gettemp
+#else
+#define GETTEMP gettemp
+extern int gettemp __P((char *, int *, int));
+#endif
+#endif
- /* update xtra for next call. */
- if (xtra[0] != 'z')
- xtra[0]++;
- else {
- xtra[0] = 'a';
- if (xtra[1] != 'z')
- xtra[1]++;
- else
- xtra[1] = 'a';
- }
-
- /*
- * check the target directory; if you have six X's and it
- * doesn't exist this runs for a *very* long time.
- */
- for (start = trv + 1;; --trv) {
- if (trv <= path)
- break;
- if (*trv == '/') {
- *trv = '\0';
- if (stat(path, &sbuf))
- return (-1);
- if (!S_ISDIR(sbuf.st_mode)) {
- errno = ENOTDIR;
- return (-1);
- }
- *trv = '/';
- break;
- }
- }
+int
+mkstemp(path)
+ char *path;
+{
+ int fd;
- for (;;) {
- if ((fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
- return (fd);
- if (errno != EEXIST)
- return (-1);
+ _DIAGASSERT(path != NULL);
- /* tricky little algorithm for backward compatibility */
- for (trv = start;;) {
- if (!*trv)
- return (-1);
- if (*trv == 'z')
- *trv++ = 'a';
- else {
- if (isdigit((unsigned char)*trv))
- *trv = 'a';
- else
- ++*trv;
- break;
- }
- }
- }
- /*NOTREACHED*/
+ return (GETTEMP(path, &fd, 0) ? fd : -1);
}
+
+#endif /* !HAVE_NBTOOL_CONFIG_H || !HAVE_MKSTEMP */
diff --git a/pkgtools/libnbcompat/files/nbcompat.h b/pkgtools/libnbcompat/files/nbcompat.h
index ebef57a033c..903c3cf972f 100644
--- a/pkgtools/libnbcompat/files/nbcompat.h
+++ b/pkgtools/libnbcompat/files/nbcompat.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nbcompat.h,v 1.37 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: nbcompat.h,v 1.38 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,23 +36,30 @@
#include <nbcompat/nbconfig.h>
#include <nbcompat/nbtypes.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
+#include <nbcompat/cdefs.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/endian.h>
+#include <nbcompat/types.h>
+#include <nbcompat/param.h>
-#include <ctype.h>
+#if HAVE_ERRNO_H
#include <errno.h>
-#include <fcntl.h>
-#include <setjmp.h>
-#include <signal.h>
+#endif
+
+#if HAVE_STDARG_H
#include <stdarg.h>
+#endif
+
+#if HAVE_STDDEF_H
#include <stddef.h>
-#include <termios.h>
+#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/dirent.h>
+#include <nbcompat/err.h>
#include <nbcompat/fnmatch.h>
#include <nbcompat/grp.h>
-#include <nbcompat/limits.h>
#include <nbcompat/paths.h>
#include <nbcompat/pwd.h>
#include <nbcompat/queue.h>
@@ -61,30 +68,20 @@
#include <nbcompat/stdlib.h>
#include <nbcompat/stdio.h>
#include <nbcompat/string.h>
+#include <nbcompat/termcap.h>
#include <nbcompat/time.h>
#include <nbcompat/tzfile.h>
#include <nbcompat/unistd.h>
#include <nbcompat/util.h>
-#if !HAVE_POLL
-# undef HAVE_POLL_H
-# undef HAVE_SYS_POLL_H
-# include <nbcompat/poll.h>
-#endif
-
-#if HAVE_DIRENT_H
-# include <dirent.h>
-#else
-# define dirent direct
-# if HAVE_SYS_NDIR_H
-# include <sys/ndir.h>
+#if HAVE_NBCOMPAT_POLL
+# if HAVE_POLL_H
+# undef HAVE_POLL_H
# endif
-# if HAVE_SYS_DIR_H
-# include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-# include <ndir.h>
+# if HAVE_SYS_POLL_H
+# undef HAVE_SYS_POLL_H
# endif
+# include <nbcompat/poll.h>
#endif
#if HAVE_NBCOMPAT_FTS
@@ -94,16 +91,6 @@
# include <nbcompat/fts.h>
#endif
-#if HAVE_ASSERT_H
-# include <assert.h>
-#endif
-
-#if HAVE_ERR_H
-# include <err.h>
-#else
-# include <nbcompat/err.h>
-#endif
-
#if HAVE_NBCOMPAT_GLOB
# if HAVE_GLOB_H
# undef HAVE_GLOB_H
@@ -118,24 +105,6 @@
# include <nbcompat/regex.h>
#endif
-#if HAVE_SYS_MKDEV_H
-# include <sys/mkdev.h>
-# if !defined(makedev) && defined(mkdev)
-# define makedev mkdev
-# endif
-#endif
-
-#if HAVE_TERMCAP_H
-# include <termcap.h>
-#else
-int tgetent(char *, const char *);
-char *tgetstr(const char *, char **);
-int tgetflag(const char *);
-int tgetnum(const char *);
-char *tgoto(const char *, int, int);
-void tputs(const char *, int, int (*)(int));
-#endif
-
#if HAVE_NBCOMPAT_MD5INIT
# if HAVE_MD5_H
# undef HAVE_MD5_H
@@ -176,26 +145,3 @@ void tputs(const char *, int, int (*)(int));
# endif
# include <nbcompat/getopt.h>
#endif
-
-#if !HAVE_D_NAMLEN
-# ifndef DIRENT_MISSING_D_NAMLEN
-# define DIRENT_MISSING_D_NAMLEN
-# endif
-#endif
-
-#if !HAVE_ISBLANK
-int isblank(int);
-#endif
-
-#if HAVE_GETPASSPHRASE
-# ifndef getpass
-# define getpass getpassphrase
-# endif
-#endif
-
-#if !defined(MIN)
-# define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-#if !defined(MAX)
-# define MAX(a, b) ((a) < (b) ? (b) : (a))
-#endif
diff --git a/pkgtools/libnbcompat/files/nbcompat/assert.h b/pkgtools/libnbcompat/files/nbcompat/assert.h
new file mode 100644
index 00000000000..736e0563982
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/assert.h
@@ -0,0 +1,54 @@
+/* $NetBSD: assert.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_ASSERT_H_
+#define _NBCOMPAT_ASSERT_H_
+
+#if HAVE_ASSERT_H
+# include <assert.h>
+#endif
+
+/*
+ * Declare macros and functions that may be missing in <assert.h>.
+ */
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+#endif /* !_NBCOMPAT_ASSERT_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/cdefs.h b/pkgtools/libnbcompat/files/nbcompat/cdefs.h
new file mode 100644
index 00000000000..0149af8667d
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/cdefs.h
@@ -0,0 +1,95 @@
+/* $NetBSD: cdefs.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_SYS_CDEFS_H_
+#define _NBCOMPAT_SYS_CDEFS_H_
+
+#if HAVE_SYS_CDEFS_H
+# include <sys/cdefs.h>
+#endif
+
+/*
+ * Declare macros and functions that may be missing in <sys/cdefs.h>.
+ */
+
+#ifndef __IDSTRING
+# define __IDSTRING(name,string) \
+ static const char name[] __attribute__((__unused__)) = string
+#endif
+
+#ifndef __COPYRIGHT
+# define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
+#endif
+
+#ifndef __RCSID
+# define __RCSID(_s) __IDSTRING(rcsid,_s)
+#endif
+
+#ifndef __P
+# if defined(__STDC__) || defined(__cplusplus)
+# define __P(protos) protos /* full-blown ANSI C */
+# else
+# define __P(protos) () /* traditional C preprocessor */
+# endif
+#endif
+
+#ifndef __CONCAT
+# if defined(__STDC__) || defined(__cplusplus)
+# define __CONCAT(x,y) x ## y
+# else
+# define __CONCAT(x,y) x/**/y
+# endif
+#endif
+
+#ifndef __BEGIN_DECLS
+# if defined(__cplusplus)
+# define __BEGIN_DECLS extern "C" {
+# else
+# define __BEGIN_DECLS
+# endif
+#endif
+
+#ifndef __END_DECLS
+# if defined(__cplusplus)
+# define __END_DECLS };
+# else
+# define __END_DECLS
+# endif
+#endif
+
+#endif /* !_NBCOMPAT_SYS_CDEFS_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/config.h.in b/pkgtools/libnbcompat/files/nbcompat/config.h.in
index 5904fbc6d8e..e60ebfe97e3 100644
--- a/pkgtools/libnbcompat/files/nbcompat/config.h.in
+++ b/pkgtools/libnbcompat/files/nbcompat/config.h.in
@@ -3,6 +3,9 @@
/* Define to 1 if the `getpgrp' function requires zero arguments. */
#undef GETPGRP_VOID
+/* Define to 1 if you have the <alloca.h> header file. */
+#undef HAVE_ALLOCA_H
+
/* Define to 1 if you have the <assert.h> header file. */
#undef HAVE_ASSERT_H
@@ -15,6 +18,17 @@
/* Define to 1 if you have the `bzero' function. */
#undef HAVE_BZERO
+/* Define to 1 if you have the <ctype.h> header file. */
+#undef HAVE_CTYPE_H
+
+/* Define to 1 if you have the declaration of `optind', and to 0 if you don't.
+ */
+#undef HAVE_DECL_OPTIND
+
+/* Define to 1 if you have the declaration of `optreset', and to 0 if you
+ don't. */
+#undef HAVE_DECL_OPTRESET
+
/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
don't. */
#undef HAVE_DECL_STRERROR_R
@@ -191,18 +205,9 @@
/* Define to 1 if you have the <netinet/in6_machtypes.h> header file. */
#undef HAVE_NETINET_IN6_MACHTYPES_H
-/* Define to 1 if optarg is declared in <stdlib.h> or <unistd.h> */
-#undef HAVE_OPTARG_D
-
-/* Define to 1 if optind is declared in <stdlib.h> or <unistd.h> */
-#undef HAVE_OPTIND_D
-
/* Define to 1 if you have the <paths.h> header file. */
#undef HAVE_PATHS_H
-/* Define to 1 if you have the `poll' function. */
-#undef HAVE_POLL
-
/* Define to 1 if you have the <poll.h> header file. */
#undef HAVE_POLL_H
@@ -249,12 +254,21 @@
/* Define to 1 if you have the <sha1.h> header file. */
#undef HAVE_SHA1_H
+/* Define to 1 if you have the <signal.h> header file. */
+#undef HAVE_SIGNAL_H
+
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the `statvfs' function. */
#undef HAVE_STATVFS
+/* Define to 1 if you have the <stdarg.h> header file. */
+#undef HAVE_STDARG_H
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -273,9 +287,6 @@
/* Define to 1 if you have the `strerror_r' function. */
#undef HAVE_STRERROR_R
-/* Define to 1 if you have the <stringlist.h> header file. */
-#undef HAVE_STRINGLIST_H
-
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
@@ -300,6 +311,9 @@
/* Define to 1 if you have the `strtoll' function. */
#undef HAVE_STRTOLL
+/* Define to 1 if `d_namlen' is member of `struct dirent'. */
+#undef HAVE_STRUCT_DIRENT_D_NAMLEN
+
/* Define to 1 if `f_fsize' is member of `struct statfs'. */
#undef HAVE_STRUCT_STATFS_F_FSIZE
@@ -312,6 +326,9 @@
/* Define to 1 if you have the `strvis' function. */
#undef HAVE_STRVIS
+/* Define to 1 if you have the `svis' function. */
+#undef HAVE_SVIS
+
/* Define to 1 if you have the <sys/bitypes.h> header file. */
#undef HAVE_SYS_BITYPES_H
@@ -366,15 +383,15 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#undef HAVE_SYS_UIO_H
+
/* Define to 1 if you have the <sys/vfs.h> header file. */
#undef HAVE_SYS_VFS_H
/* Define to 1 if you have the <termcap.h> header file. */
#undef HAVE_TERMCAP_H
-/* Define to 1 if you have the <termios.h> header file. */
-#undef HAVE_TERMIOS_H
-
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
@@ -402,6 +419,9 @@
/* Define to 1 if you have the `unsetenv' function. */
#undef HAVE_UNSETENV
+/* Define to 1 if you have the `unvis' function. */
+#undef HAVE_UNVIS
+
/* Define to 1 if you have the `user_from_uid' function. */
#undef HAVE_USER_FROM_UID
@@ -414,8 +434,8 @@
/* Define to 1 if you have the `utimes' function. */
#undef HAVE_UTIMES
-/* Define to 1 if you have the <utmp.h> header file. */
-#undef HAVE_UTMP_H
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
/* Define to 1 if the system has the type `u_int16_t'. */
#undef HAVE_U_INT16_T
@@ -429,12 +449,18 @@
/* Define to 1 if the system has the type `u_int8_t'. */
#undef HAVE_U_INT8_T
+/* Define to 1 if you have the `vis' function. */
+#undef HAVE_VIS
+
/* Define to 1 if you have the <vis.h> header file. */
#undef HAVE_VIS_H
/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF
+/* Define to 1 if you have the `warn' function. */
+#undef HAVE_WARN
+
/* Define to 1 if `long long' is supported and sizeof(off_t) >= 8. */
#undef HAVE_WORKING_LONG_LONG
@@ -485,112 +511,3 @@
# define __attribute__(x)
#endif
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
-#ifndef __IDSTRING
-# define __IDSTRING(name,string) \
- static const char name[] __attribute__((__unused__)) = string
-#endif
-
-#ifndef __RCSID
-# define __RCSID(_s) __IDSTRING(rcsid,_s)
-#endif
-
-#ifndef __COPYRIGHT
-# define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
-#endif
-
-#ifndef __P
-# if defined(__STDC__) || defined(__cplusplus)
-# define __P(protos) protos /* full-blown ANSI C */
-# else
-# define __P(protos) () /* traditional C preprocessor */
-# endif
-#endif
-
-#ifndef __CONCAT
-# if defined(__STDC__) || defined(__cplusplus)
-# define __CONCAT(x,y) x ## y
-# else
-# define __CONCAT(x,y) x/**/y
-# endif
-#endif
-
-#ifndef __BEGIN_DECLS
-# if defined(__cplusplus)
-# define __BEGIN_DECLS extern "C" {
-# else
-# define __BEGIN_DECLS
-# endif
-#endif
-
-#ifndef __END_DECLS
-# if defined(__cplusplus)
-# define __END_DECLS };
-# else
-# define __END_DECLS
-# endif
-#endif
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#if HAVE_SYS_ENDIAN_H
-#include <sys/endian.h>
-#endif
-
-#if HAVE_MACHINE_ENDIAN_H
-#include <machine/endian.h>
-#endif
-
-#if HAVE_SYS_BYTEORDER_H
-#include <sys/byteorder.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef LITTLE_ENDIAN
-# define LITTLE_ENDIAN 1234
-#endif
-
-#ifndef BIG_ENDIAN
-# define BIG_ENDIAN 4321
-#endif
-
-#ifndef UINT_MAX
-# define UINT_MAX 4294967295U
-#endif
-
-#ifndef BYTE_ORDER
-# if defined(_BIG_ENDIAN)
-# define BYTE_ORDER BIG_ENDIAN
-# elif defined(_LITTE_ENDIAN)
-# define BYTE_ORDER LITTLE_ENDIAN
-# elif defined(WORDS_BIGENDIAN)
-# define BYTE_ORDER BIG_ENDIAN
-# else
-# define BYTE_ORDER LITTLE_ENDIAN
-# endif
-#endif
-
-#if defined(HAVE_MEMSET)
-# define MEMSET_BZERO(p,l) memset((p), 0, (l))
-#elif defined(HAVE_BZERO)
-# define MEMSET_BZERO(p,l) bzero((p), (l))
-#else
-# error You need either memset or bzero
-#endif
-
-#if defined(HAVE_MEMCPY)
-# define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
-#elif defined(HAVE_BCOPY)
-# define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
-#else
-# error You need either memcpy or bcopy
-#endif
-
diff --git a/pkgtools/libnbcompat/files/nbcompat/ctype.h b/pkgtools/libnbcompat/files/nbcompat/ctype.h
new file mode 100644
index 00000000000..a90bbdc36a4
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/ctype.h
@@ -0,0 +1,54 @@
+/* $NetBSD: ctype.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_CTYPE_H_
+#define _NBCOMPAT_CTYPE_H_
+
+#if HAVE_CTYPE_H
+# include <ctype.h>
+#endif
+
+/*
+ * Declare macros and functions that may be missing in <ctype.h>.
+ */
+
+#if !HAVE_ISBLANK
+int isblank(int);
+#endif
+
+#endif /* !_NBCOMPAT_CTYPE_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/dirent.h b/pkgtools/libnbcompat/files/nbcompat/dirent.h
new file mode 100644
index 00000000000..b23adfc60ec
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/dirent.h
@@ -0,0 +1,65 @@
+/* $NetBSD: dirent.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_DIRENT_H_
+#define _NBCOMPAT_DIRENT_H_
+
+#if HAVE_DIRENT_H
+# include <dirent.h>
+#else
+# define dirent direct
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
+
+/*
+ * Declare functions and macros that may be missing in <dirent.h>.
+ */
+
+#ifndef dirfd
+#define dirfd(dirp) ((dirp)->dd_fd)
+#endif
+
+#endif /* !_NBCOMPAT_DIRENT_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/endian.h b/pkgtools/libnbcompat/files/nbcompat/endian.h
new file mode 100644
index 00000000000..2a6a475552d
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/endian.h
@@ -0,0 +1,79 @@
+/* $NetBSD: endian.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_ENDIAN_H_
+#define _NBCOMPAT_ENDIAN_H_
+
+#if HAVE_SYS_ENDIAN_H
+# include <sys/endian.h>
+#endif
+
+#if HAVE_MACHINE_ENDIAN_H
+# include <machine/endian.h>
+#endif
+
+#if HAVE_SYS_BYTEORDER_H
+# include <sys/byteorder.h>
+#endif
+
+/*
+ * Declare macros that may be missing in <sys/endian.h>, <machine/endian.h>,
+ * and <sys/byteorder.h>
+ */
+
+#ifndef LITTLE_ENDIAN
+# define LITTLE_ENDIAN 1234
+#endif
+
+#ifndef BIG_ENDIAN
+# define BIG_ENDIAN 4321
+#endif
+
+#ifndef BYTE_ORDER
+# if defined(_BIG_ENDIAN)
+# define BYTE_ORDER BIG_ENDIAN
+# elif defined(_LITTE_ENDIAN)
+# define BYTE_ORDER LITTLE_ENDIAN
+# elif defined(WORDS_BIGENDIAN)
+# define BYTE_ORDER BIG_ENDIAN
+# else
+# define BYTE_ORDER LITTLE_ENDIAN
+# endif
+#endif
+
+#endif /* !_NBCOMPAT_ENDIAN_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/err.h b/pkgtools/libnbcompat/files/nbcompat/err.h
index 5aac0839b9c..eb7f0a06bf0 100644
--- a/pkgtools/libnbcompat/files/nbcompat/err.h
+++ b/pkgtools/libnbcompat/files/nbcompat/err.h
@@ -1,4 +1,4 @@
-/* $NetBSD: err.h,v 1.3 2004/08/16 17:24:57 jlam Exp $ */
+/* $NetBSD: err.h,v 1.4 2004/08/23 03:32:13 jlam Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -38,15 +38,22 @@
#ifndef _NBCOMPAT_ERR_H_
#define _NBCOMPAT_ERR_H_
+#if HAVE_ERR_H
+# include <err.h>
+#endif
+
#if !HAVE_ERR
-void err(int, const char *, ...);
-void errx(int, const char *, ...);
-void verr(int, const char *, va_list);
-void verrx(int, const char *, va_list);
-void warn(const char *, ...);
-void warnx(const char *, ...);
-void vwarn(const char *, va_list);
-void vwarnx(const char *, va_list);
+void err __P((int, const char *, ...));
+void errx __P((int, const char *, ...));
+void verr __P((int, const char *, va_list));
+void verrx __P((int, const char *, va_list));
+#endif
+
+#if !HAVE_WARN
+void warn __P((const char *, ...));
+void warnx __P((const char *, ...));
+void vwarn __P((const char *, va_list));
+void vwarnx __P((const char *, va_list));
#endif
#endif /* !_NBCOMPAT_ERR_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/getopt.h b/pkgtools/libnbcompat/files/nbcompat/getopt.h
index 04ed5a6cb76..8af7a9c3896 100644
--- a/pkgtools/libnbcompat/files/nbcompat/getopt.h
+++ b/pkgtools/libnbcompat/files/nbcompat/getopt.h
@@ -1,4 +1,4 @@
-/* $NetBSD: getopt.h,v 1.3 2004/08/16 17:24:57 jlam Exp $ */
+/* $NetBSD: getopt.h,v 1.4 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -39,13 +39,8 @@
#ifndef _NBCOMPAT_GETOPT_H_
#define _NBCOMPAT_GETOPT_H_
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include <nbcompat/cdefs.h>
+#include <nbcompat/unistd.h>
/*
* Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
diff --git a/pkgtools/libnbcompat/files/nbcompat/limits.h b/pkgtools/libnbcompat/files/nbcompat/limits.h
index 51a30f6e1a0..1f060ad90bf 100644
--- a/pkgtools/libnbcompat/files/nbcompat/limits.h
+++ b/pkgtools/libnbcompat/files/nbcompat/limits.h
@@ -1,4 +1,4 @@
-/* $NetBSD: limits.h,v 1.1 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: limits.h,v 1.2 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -47,6 +47,10 @@
* Declare functions and macros that may be missing in <limits.h>.
*/
+#ifndef UINT_MAX
+# define UINT_MAX 4294967295U
+#endif
+
#if !defined(LLONG_MAX)
# if defined(LONG_LONG_MAX)
# define LLONG_MAX LONG_LONG_MAX
diff --git a/pkgtools/libnbcompat/files/nbcompat/param.h b/pkgtools/libnbcompat/files/nbcompat/param.h
new file mode 100644
index 00000000000..e46c221645b
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/param.h
@@ -0,0 +1,57 @@
+/* $NetBSD: param.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_SYS_PARAM_H_
+#define _NBCOMPAT_SYS_PARAM_H_
+
+#if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+/*
+ * Declare macros and functions that may be missing in <sys/param.h>.
+ */
+
+#if !defined(MIN)
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+#if !defined(MAX)
+# define MAX(a, b) ((a) < (b) ? (b) : (a))
+#endif
+
+#endif /* !_NBCOMPAT_SYS_PARAM_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/regex.h b/pkgtools/libnbcompat/files/nbcompat/regex.h
index c4d5cc3fb2f..ed63c0e327e 100644
--- a/pkgtools/libnbcompat/files/nbcompat/regex.h
+++ b/pkgtools/libnbcompat/files/nbcompat/regex.h
@@ -1,4 +1,4 @@
-/* $NetBSD: regex.h,v 1.1 2004/08/16 17:24:57 jlam Exp $ */
+/* $NetBSD: regex.h,v 1.2 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -74,12 +74,8 @@
#ifndef _NBCOMPAT_REGEX_H_
#define _NBCOMPAT_REGEX_H_
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
+#include <nbcompat/cdefs.h>
+#include <nbcompat/types.h>
/* types */
#if 1 /* __LIBC12_SOURCE__ - should go away */
diff --git a/pkgtools/libnbcompat/files/nbcompat/stat.h b/pkgtools/libnbcompat/files/nbcompat/stat.h
index 97f2bf07071..20c2999369a 100644
--- a/pkgtools/libnbcompat/files/nbcompat/stat.h
+++ b/pkgtools/libnbcompat/files/nbcompat/stat.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stat.h,v 1.1 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: stat.h,v 1.2 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -63,4 +63,8 @@ int lchmod(const char *, mode_t);
# define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
#endif
+#if !defined(DEFFILEMODE)
+# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
+#endif
+
#endif /* !_NBCOMPAT_STAT_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/statvfs.h b/pkgtools/libnbcompat/files/nbcompat/statvfs.h
index 0dbc17af20a..6561b06a9f0 100644
--- a/pkgtools/libnbcompat/files/nbcompat/statvfs.h
+++ b/pkgtools/libnbcompat/files/nbcompat/statvfs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: statvfs.h,v 1.2 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: statvfs.h,v 1.3 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -45,13 +45,8 @@
#if !HAVE_STATVFS
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
+#include <nbcompat/types.h>
+#include <nbcompat/param.h>
#if HAVE_SYS_MOUNT_H
#include <sys/mount.h>
diff --git a/pkgtools/libnbcompat/files/nbcompat/stdlib.h b/pkgtools/libnbcompat/files/nbcompat/stdlib.h
index d57623bc430..52da70c2a3e 100644
--- a/pkgtools/libnbcompat/files/nbcompat/stdlib.h
+++ b/pkgtools/libnbcompat/files/nbcompat/stdlib.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stdlib.h,v 1.1 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: stdlib.h,v 1.2 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -42,9 +42,13 @@
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
+#if HAVE_ALLOCA_H
+# include <alloca.h>
+#endif
/*
- * Declare functions and macros that may be missing in <stdlib.h>.
+ * Declare functions and macros that may be missing in <stdlib.h> and
+ * <alloca.h>.
*/
#if !HAVE_MKSTEMP
diff --git a/pkgtools/libnbcompat/files/nbcompat/termcap.h b/pkgtools/libnbcompat/files/nbcompat/termcap.h
new file mode 100644
index 00000000000..11bf60bc853
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/termcap.h
@@ -0,0 +1,59 @@
+/* $NetBSD: termcap.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_TERMCAP_H_
+#define _NBCOMPAT_TERMCAP_H_
+
+#if HAVE_TERMCAP_H
+# include <termcap.h>
+#endif
+
+/*
+ * Declare macros and functions that may be missing in <termcap.h>.
+ */
+
+#if !HAVE_TERMCAP_H
+int tgetent __P((char *, const char *));
+char *tgetstr __P((const char *, char **));
+int tgetflag __P((const char *));
+int tgetnum __P((const char *));
+char *tgoto __P((const char *, int, int));
+void tputs __P((const char *, int, int (*)(int)));
+#endif
+
+#endif /* !_NBCOMPAT_TERMCAP_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/types.h b/pkgtools/libnbcompat/files/nbcompat/types.h
new file mode 100644
index 00000000000..6121bab11ca
--- /dev/null
+++ b/pkgtools/libnbcompat/files/nbcompat/types.h
@@ -0,0 +1,59 @@
+/* $NetBSD: types.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Johnny C. Lam.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _NBCOMPAT_SYS_TYPES_H_
+#define _NBCOMPAT_SYS_TYPES_H_
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+/*
+ * Declare macros and functions that may be missing in <sys/types.h>.
+ */
+
+#if !defined(makedev)
+# if HAVE_SYS_MKDEV_H
+# include <sys/mkdev.h>
+# if defined(mkdev)
+# define makedev mkdev
+# endif
+# endif
+#endif
+
+#endif /* !_NBCOMPAT_SYS_TYPES_H_ */
diff --git a/pkgtools/libnbcompat/files/nbcompat/unistd.h b/pkgtools/libnbcompat/files/nbcompat/unistd.h
index 288120febb7..653722c75af 100644
--- a/pkgtools/libnbcompat/files/nbcompat/unistd.h
+++ b/pkgtools/libnbcompat/files/nbcompat/unistd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: unistd.h,v 1.1 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: unistd.h,v 1.2 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -59,6 +59,15 @@ extern int optind;
char *getpass(const char *);
#endif
+/*
+ * If getpassphrase() exists, then use it in place of getpass().
+ */
+#if HAVE_GETPASSPHRASE
+# ifndef getpass
+# define getpass getpassphrase
+# endif
+#endif
+
#if !HAVE_LCHOWN
int lchown(const char *, uid_t, gid_t);
#endif
diff --git a/pkgtools/libnbcompat/files/nbcompat/vis.h b/pkgtools/libnbcompat/files/nbcompat/vis.h
index 04614595e33..2361de40098 100644
--- a/pkgtools/libnbcompat/files/nbcompat/vis.h
+++ b/pkgtools/libnbcompat/files/nbcompat/vis.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.2 2004/08/16 17:24:57 jlam Exp $ */
+/* $NetBSD: vis.h,v 1.3 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,6 +38,8 @@
#ifndef _NBCOMPAT_VIS_H_
#define _NBCOMPAT_VIS_H_
+#include <nbcompat/types.h>
+
/*
* to select alternate encoding format
*/
@@ -74,18 +76,7 @@
*/
#define UNVIS_END 1 /* no more characters */
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(e)
-#endif
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
-#ifndef __BEGIN_DECLS
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
+#include <nbcompat/cdefs.h>
__BEGIN_DECLS
char *vis (char *, int, int, int);
diff --git a/pkgtools/libnbcompat/files/poll.c b/pkgtools/libnbcompat/files/poll.c
index 3a3e63370c3..ae43a04c8f1 100644
--- a/pkgtools/libnbcompat/files/poll.c
+++ b/pkgtools/libnbcompat/files/poll.c
@@ -1,4 +1,4 @@
-/* $NetBSD: poll.c,v 1.1 2003/09/03 13:35:48 jlam Exp $ */
+/* $NetBSD: poll.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#include <nbcompat.h>
+#include <nbcompat/types.h>
+#include <nbcompat/time.h>
+#include <nbcompat/unistd.h>
+#include <nbcompat/poll.h>
int
poll(struct pollfd *p, nfds_t nfds, int timout)
diff --git a/pkgtools/libnbcompat/files/cclass.h b/pkgtools/libnbcompat/files/private/cclass.h
index 1b72e480b6f..7742a355f0d 100644
--- a/pkgtools/libnbcompat/files/cclass.h
+++ b/pkgtools/libnbcompat/files/private/cclass.h
@@ -1,4 +1,4 @@
-/* $NetBSD: cclass.h,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: cclass.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
diff --git a/pkgtools/libnbcompat/files/cname.h b/pkgtools/libnbcompat/files/private/cname.h
index d4b699f69aa..b16be8d303d 100644
--- a/pkgtools/libnbcompat/files/cname.h
+++ b/pkgtools/libnbcompat/files/private/cname.h
@@ -1,4 +1,4 @@
-/* $NetBSD: cname.h,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: cname.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
diff --git a/pkgtools/libnbcompat/files/pwcache.h b/pkgtools/libnbcompat/files/private/pwcache.h
index 25444af2f50..81d8582c82d 100644
--- a/pkgtools/libnbcompat/files/pwcache.h
+++ b/pkgtools/libnbcompat/files/private/pwcache.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pwcache.h,v 1.4 2004/03/11 13:17:34 grant Exp $ */
+/* $NetBSD: pwcache.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -35,15 +35,12 @@
* @(#)cache.h 8.1 (Berkeley) 5/31/93
*/
-#ifndef _NBCOMPAT_PWCACHE_H
-#define _NBCOMPAT_PWCACHE_H
-
/*
* Constants and data structures used to implement group and password file
* caches. Traditional passwd/group cache routines perform quite poorly with
* archives. The chances of hitting a valid lookup with an archive is quite a
* bit worse than with files already resident on the file system. These misses
- * create a MAJOR performance cost. To adress this problem, these routines
+ * create a MAJOR performance cost. To address this problem, these routines
* cache both hits and misses.
*
* NOTE: name lengths must be as large as those stored in ANY PROTOCOL and
@@ -73,21 +70,3 @@ typedef struct gidc {
char name[GNMLEN]; /* gid name */
gid_t gid; /* cached gid */
} GIDC;
-
-#ifndef HAVE_USER_FROM_UID
-const char *user_from_uid(uid_t, int);
-#endif
-
-#ifndef HAVE_GROUP_FROM_GID
-const char *group_from_gid(gid_t, int);
-#endif
-
-#ifndef HAVE_UID_FROM_USER
-int uid_from_user(const char *, uid_t *);
-#endif
-
-#ifndef HAVE_GID_FROM_GROUP
-int gid_from_group(const char *, gid_t *);
-#endif
-
-#endif /* !_NBCOMPAT_PWCACHE_H */
diff --git a/pkgtools/libnbcompat/files/regex2.h b/pkgtools/libnbcompat/files/private/regex2.h
index 180c50cf3d7..9404bc24e7d 100644
--- a/pkgtools/libnbcompat/files/regex2.h
+++ b/pkgtools/libnbcompat/files/private/regex2.h
@@ -1,4 +1,4 @@
-/* $NetBSD: regex2.h,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: regex2.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
diff --git a/pkgtools/libnbcompat/files/utils.h b/pkgtools/libnbcompat/files/private/utils.h
index 13c1d269b3c..0f359753c86 100644
--- a/pkgtools/libnbcompat/files/utils.h
+++ b/pkgtools/libnbcompat/files/private/utils.h
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.h,v 1.1 2004/08/16 17:24:57 jlam Exp $ */
+/* $NetBSD: utils.h,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -83,9 +83,7 @@ typedef unsigned char uch;
#define NDEBUG /* no assertions please */
#endif
#endif
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
+#include <nbcompat/assert.h>
/*
* Workaround bug in some assert.h. This is okay since we really don't
diff --git a/pkgtools/libnbcompat/files/pwcache.c b/pkgtools/libnbcompat/files/pwcache.c
index 33d5578a3ea..493de4a4b65 100644
--- a/pkgtools/libnbcompat/files/pwcache.c
+++ b/pkgtools/libnbcompat/files/pwcache.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pwcache.c,v 1.7 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: pwcache.c,v 1.8 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@@ -66,38 +66,48 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+/*
+ * XXX Undefine the renames of these functions so that we don't
+ * XXX rename the versions found in the host's <pwd.h> by mistake!
+ */
+#undef group_from_gid
+#undef user_from_uid
#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)cache.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pwcache.c,v 1.7 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: pwcache.c,v 1.8 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-#include <sys/types.h>
-#include <sys/param.h>
+#if 0
+#include "namespace.h"
+#endif
-#include <assert.h>
+#include <nbcompat/types.h>
+#include <nbcompat/param.h>
+
+#include <nbcompat/assert.h>
#include <nbcompat/grp.h>
#include <nbcompat/pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
+
+#if HAVE_NBTOOL_CONFIG_H
+/* XXX Now, re-apply the renaming that we undid above. */
+#define group_from_gid __nbcompat_group_from_gid
+#define user_from_uid __nbcompat_user_from_uid
+#endif
#if 0
-#ifndef __ELF__
-#define _user_from_uid user_from_uid
-#define _group_from_gid group_from_gid
-#define _pwcache_userdb pwcache_userdb
-#define _pwcache_groupdb pwcache_groupdb
-#else
#ifdef __weak_alias
__weak_alias(user_from_uid,_user_from_uid)
__weak_alias(group_from_gid,_group_from_gid)
@@ -105,9 +115,9 @@ __weak_alias(pwcache_userdb,_pwcache_userdb)
__weak_alias(pwcache_groupdb,_pwcache_groupdb)
#endif
#endif
-#endif
-#include "pwcache.h"
+#if !HAVE_PWCACHE_USERDB || HAVE_NBTOOL_CONFIG_H
+#include "private/pwcache.h"
/*
* routines that control user, group, uid and gid caches (for the archive
@@ -151,10 +161,6 @@ static int gidtb_start(void);
static int usrtb_start(void);
static int grptb_start(void);
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
static u_int
st_hash(const char *name, size_t len, int tabsz)
@@ -258,12 +264,12 @@ grptb_start(void)
/*
* user_from_uid()
* caches the name (if any) for the uid. If noname clear, we always
- * return the the stored name (if valid or invalid match).
+ * return the stored name (if valid or invalid match).
* We use a simple hash table.
* Return
* Pointer to stored name (or a empty string)
*/
-#ifndef HAVE_USER_FROM_UID
+#if !HAVE_USER_FROM_UID
const char *
user_from_uid(uid_t uid, int noname)
{
@@ -303,7 +309,7 @@ user_from_uid(uid_t uid, int noname)
if ((pw = (*_pwcache_getpwuid)(uid)) == NULL) {
/*
* no match for this uid in the local password file
- * a string that is the uid in numberic format
+ * a string that is the uid in numeric format
*/
if (ptr == NULL)
return (NULL);
@@ -324,17 +330,17 @@ user_from_uid(uid_t uid, int noname)
}
return (ptr->name);
}
-#endif
+#endif /* !HAVE_USER_FROM_UID */
/*
* group_from_gid()
* caches the name (if any) for the gid. If noname clear, we always
- * return the the stored name (if valid or invalid match).
+ * return the stored name (if valid or invalid match).
* We use a simple hash table.
* Return
* Pointer to stored name (or a empty string)
*/
-#ifndef HAVE_GROUP_FROM_GID
+#if !HAVE_GROUP_FROM_GID
const char *
group_from_gid(gid_t gid, int noname)
{
@@ -395,7 +401,7 @@ group_from_gid(gid_t gid, int noname)
}
return (ptr->name);
}
-#endif
+#endif /* !HAVE_GROUP_FROM_GID */
/*
* uid_from_user()
@@ -403,7 +409,7 @@ group_from_gid(gid_t gid, int noname)
* Return
* the uid (if any) for a user name, or a -1 if no match can be found
*/
-#ifndef HAVE_UID_FROM_USER
+#if !HAVE_UID_FROM_USER
int
uid_from_user(const char *name, uid_t *uid)
{
@@ -461,7 +467,7 @@ uid_from_user(const char *name, uid_t *uid)
*uid = ptr->uid = pw->pw_uid;
return (0);
}
-#endif
+#endif /* !HAVE_UID_FROM_USER */
/*
* gid_from_group()
@@ -469,7 +475,7 @@ uid_from_user(const char *name, uid_t *uid)
* Return
* the gid (if any) for a group name, or a -1 if no match can be found
*/
-#ifndef HAVE_GID_FROM_GROUP
+#if !HAVE_GID_FROM_GROUP
int
gid_from_group(const char *name, gid_t *gid)
{
@@ -528,7 +534,7 @@ gid_from_group(const char *name, gid_t *gid)
*gid = ptr->gid = gr->gr_gid;
return (0);
}
-#endif
+#endif /* !HAVE_GID_FROM_GROUP */
#define FLUSHTB(arr, len, fail) \
do { \
@@ -541,7 +547,7 @@ gid_from_group(const char *name, gid_t *gid)
fail = 0; \
} while (/* CONSTCOND */0);
-#ifndef HAVE_PWCACHE_USERDB
+#if !HAVE_PWCACHE_USERDB
int
pwcache_userdb(
int (*a_setpassent)(int),
@@ -567,9 +573,9 @@ pwcache_userdb(
return (0);
}
-#endif
+#endif /* !HAVE_PWCACHE_USERDB */
-#ifndef HAVE_PWCACHE_GROUPDB
+#if !HAVE_PWCACHE_GROUPDB
int
pwcache_groupdb(
int (*a_setgroupent)(int),
@@ -595,7 +601,7 @@ pwcache_groupdb(
return (0);
}
-#endif
+#endif /* !HAVE_PWCACHE_GROUPDB */
#ifdef TEST_PWCACHE
@@ -659,3 +665,4 @@ main(int argc, char *argv[])
return (0);
}
#endif /* TEST_PWCACHE */
+#endif /* !HAVE_PWCACHE_USERDB */
diff --git a/pkgtools/libnbcompat/files/regcomp.c b/pkgtools/libnbcompat/files/regcomp.c
index dbca3717cf0..b64a85c7aa3 100644
--- a/pkgtools/libnbcompat/files/regcomp.c
+++ b/pkgtools/libnbcompat/files/regcomp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: regcomp.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: regcomp.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -71,45 +71,28 @@
* @(#)regcomp.c 8.5 (Berkeley) 3/20/94
*/
-#include "nbcompat.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: regcomp.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: regcomp.c,v 1.2 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* #include "namespace.h" */
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/types.h>
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
-#if HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#if HAVE_REGEX_H
-#include <regex.h>
-#endif
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/regex.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
#if 0
#ifdef __weak_alias
@@ -117,15 +100,11 @@ __weak_alias(regcomp,_regcomp)
#endif
#endif
-#include "utils.h"
-#include "regex2.h"
-
-#include "cclass.h"
-#include "cname.h"
+#include "private/utils.h"
+#include "private/regex2.h"
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
+#include "private/cclass.h"
+#include "private/cname.h"
/*
* parse structure, passed up and down to avoid global variables and
diff --git a/pkgtools/libnbcompat/files/regerror.c b/pkgtools/libnbcompat/files/regerror.c
index 009bf91b474..aa2e7279af0 100644
--- a/pkgtools/libnbcompat/files/regerror.c
+++ b/pkgtools/libnbcompat/files/regerror.c
@@ -1,4 +1,4 @@
-/* $NetBSD: regerror.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: regerror.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -71,45 +71,28 @@
* @(#)regerror.c 8.4 (Berkeley) 3/20/94
*/
-#include "nbcompat.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: regerror.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: regerror.c,v 1.2 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* #include "namespace.h" */
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/types.h>
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
-#if HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#if HAVE_REGEX_H
-#include <regex.h>
-#endif
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/regex.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
#if 0
#ifdef __weak_alias
@@ -117,11 +100,7 @@ __weak_alias(regerror,_regerror)
#endif
#endif
-#include "utils.h"
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
+#include "private/utils.h"
/* ========= begin header generated by ./mkh ========= */
#ifdef __cplusplus
diff --git a/pkgtools/libnbcompat/files/regexec.c b/pkgtools/libnbcompat/files/regexec.c
index 625ff94f9e4..4eec33063f6 100644
--- a/pkgtools/libnbcompat/files/regexec.c
+++ b/pkgtools/libnbcompat/files/regexec.c
@@ -1,4 +1,4 @@
-/* $NetBSD: regexec.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: regexec.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -71,16 +71,13 @@
* @(#)regexec.c 8.3 (Berkeley) 3/20/94
*/
-#include "nbcompat.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: regexec.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: regexec.c,v 1.2 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -91,32 +88,18 @@ __RCSID("$NetBSD: regexec.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
* macros that code uses. This lets the same code operate on two different
* representations for state sets.
*/
-/* #include "namespace.h" */
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/types.h>
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
-#if HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#if HAVE_REGEX_H
-#include <regex.h>
-#endif
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/regex.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
#if 0
#ifdef __weak_alias
@@ -124,12 +107,8 @@ __weak_alias(regexec,_regexec)
#endif
#endif
-#include "utils.h"
-#include "regex2.h"
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
+#include "private/utils.h"
+#include "private/regex2.h"
/* macros for manipulating states, small version */
#define states unsigned long
diff --git a/pkgtools/libnbcompat/files/regfree.c b/pkgtools/libnbcompat/files/regfree.c
index a6c2534a9d7..98e096272a6 100644
--- a/pkgtools/libnbcompat/files/regfree.c
+++ b/pkgtools/libnbcompat/files/regfree.c
@@ -1,4 +1,4 @@
-/* $NetBSD: regfree.c,v 1.1 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: regfree.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -71,36 +71,25 @@
* @(#)regfree.c 8.3 (Berkeley) 3/20/94
*/
-#include "nbcompat.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: regfree.c,v 1.1 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: regfree.c,v 1.2 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* #include "namespace.h" */
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/types.h>
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
-#if HAVE_REGEX_H
-#include <regex.h>
-#endif
-#if HAVE_STDIO_H
-#include <stdio.h>
-#endif
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/regex.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
#if 0
#ifdef __weak_alias
@@ -108,12 +97,8 @@ __weak_alias(regfree,_regfree)
#endif
#endif
-#include "utils.h"
-#include "regex2.h"
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
+#include "private/utils.h"
+#include "private/regex2.h"
/*
- regfree - free everything
diff --git a/pkgtools/libnbcompat/files/rmd160.c b/pkgtools/libnbcompat/files/rmd160.c
index 0cbae3a6550..e8a34533f97 100644
--- a/pkgtools/libnbcompat/files/rmd160.c
+++ b/pkgtools/libnbcompat/files/rmd160.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rmd160.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: rmd160.c,v 1.6 2004/08/23 03:32:12 jlam Exp $ */
/********************************************************************\
*
@@ -18,36 +18,31 @@
*
\********************************************************************/
-#include "nbcompat/nbconfig.h"
-#include "nbcompat/nbtypes.h"
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rmd160.c,v 1.5 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: rmd160.c,v 1.6 2004/08/23 03:32:12 jlam Exp $");
#endif /* not lint */
/* header files */
+#include <nbcompat/types.h>
+#include <nbcompat/endian.h>
-/* #include "namespace.h" */
-
-#include <assert.h>
-#include "nbcompat/rmd160.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
+#if 0
+#include "namespace.h"
#endif
-#if defined(HAVE_MEMSET)
-#define ZEROIZE(d, l) memset((d), 0, (l))
-#else
-# if defined(HAVE_BZERO)
-#define ZEROIZE(d, l) bzero((d), (l))
-# else
-#error You need either memset or bzero
-# endif
-#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/rmd160.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+
+#if !HAVE_RMD160_H
#if 0
#if !defined(_KERNEL) && defined(__weak_alias)
@@ -58,6 +53,16 @@ __weak_alias(RMD160Final,_RMD160Final)
#endif
#endif
+#if defined(HAVE_MEMSET)
+#define ZEROIZE(d, l) memset((d), 0, (l))
+#else
+# if defined(HAVE_BZERO)
+#define ZEROIZE(d, l) bzero((d), (l))
+# else
+#error You need either memset or bzero
+# endif
+#endif
+
/********************************************************************/
/* macro definitions */
@@ -465,3 +470,4 @@ RMD160Final(u_char digest[20], RMD160_CTX *context)
}
/************************ end of file rmd160.c **********************/
+#endif /* HAVE_RMD160_H */
diff --git a/pkgtools/libnbcompat/files/rmd160hl.c b/pkgtools/libnbcompat/files/rmd160hl.c
index 919acf78b75..aa2d002f07e 100644
--- a/pkgtools/libnbcompat/files/rmd160hl.c
+++ b/pkgtools/libnbcompat/files/rmd160hl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rmd160hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: rmd160hl.c,v 1.6 2004/08/23 03:32:12 jlam Exp $ */
/* rmd160hl.c
* ----------------------------------------------------------------------------
@@ -11,33 +11,35 @@
* from OpenBSD: rmd160hl.c,v 1.2 1999/08/17 09:13:12 millert Exp $
*/
-#include "nbcompat/nbconfig.h"
-#include "nbcompat/nbtypes.h"
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rmd160hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: rmd160hl.c,v 1.6 2004/08/23 03:32:12 jlam Exp $");
#endif /* not lint */
+#include <nbcompat/types.h>
-/* #include "namespace.h" */
+#if 0
+#include "namespace.h"
+#endif
-#include <assert.h>
+#include <nbcompat/assert.h>
#if HAVE_ERRNO_H
#include <errno.h>
#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
-#include "nbcompat/rmd160.h"
-#include <stdio.h>
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include <nbcompat/rmd160.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
+#if !HAVE_RMD160_H
#if 0
#if defined(__weak_alias)
@@ -106,3 +108,5 @@ RMD160Data(const u_char *data, size_t len, char *buf)
RMD160Update(&ctx, data, len);
return(RMD160End(&ctx, buf));
}
+
+#endif /* HAVE_RMD160_H */
diff --git a/pkgtools/libnbcompat/files/setenv.c b/pkgtools/libnbcompat/files/setenv.c
index 3fb64f8b6c7..f2450ec7d93 100644
--- a/pkgtools/libnbcompat/files/setenv.c
+++ b/pkgtools/libnbcompat/files/setenv.c
@@ -1,8 +1,8 @@
-/* $NetBSD: setenv.c,v 1.9 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: setenv.c,v 1.10 2004/08/23 03:32:12 jlam Exp $ */
/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,50 +29,54 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-/*static char *sccsid = "from: @(#)setenv.c 5.6 (Berkeley) 6/4/91";*/
-static char *rcsid = "$Id: setenv.c,v 1.9 2004/08/16 17:24:56 jlam Exp $";
+#if 0
+static char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: setenv.c,v 1.10 2004/08/23 03:32:12 jlam Exp $");
+#endif
#endif /* LIBC_SCCS and not lint */
-#include "nbcompat/nbconfig.h"
+#if 0
+#include "namespace.h"
+#endif
-#if HAVE_STRINGS_H
-#include <strings.h>
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#if 0
+#include "local.h"
+#include "reentrant.h"
#endif
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
+char *__findenv __P((const char *, int *));
-/*
- * __findenv --
- * Returns pointer to value associated with name, if any, else NULL.
- * Sets offset to be the offset of the name/value combination in the
- * environmental array, for use by setenv(3) and unsetenv(3).
- * Explicitly removes '=' in argument name.
- *
- * This routine *should* be a static; don't use it.
- */
-static char *
-__findenv(name, offset)
- register char *name;
- int *offset;
-{
- extern char **environ;
- register int len;
- register char **P, *C;
+#if 0
+#ifdef __weak_alias
+__weak_alias(setenv,_setenv)
+#endif
+#endif
- for (C = name, len = 0; *C && *C != '='; ++C, ++len);
- for (P = environ; *P; ++P)
- if (!strncmp(*P, name, len))
- if (*(C = *P + len) == '=') {
- *offset = P - environ;
- return(++C);
- }
- return(NULL);
-}
+#if 0
+#ifdef _REENTRANT
+extern rwlock_t __environ_lock;
+#endif
+#endif
+
+extern char **environ;
+
+#ifndef rwlock_wrlock
+#define rwlock_wrlock(lock) ((void)0)
+#endif
+#ifndef rwlock_unlock
+#define rwlock_unlock(lock) ((void)0)
+#endif
-#if !HAVE_SETENV
/*
* setenv --
* Set the value of the environmental variable "name" to be
@@ -80,78 +84,69 @@ __findenv(name, offset)
*/
int
setenv(name, value, rewrite)
- register const char *name;
- register const char *value;
+ const char *name;
+ const char *value;
int rewrite;
{
- extern char **environ;
static int alloced; /* if allocated space before */
- register char *C;
- int l_value, offset;
- char *__findenv();
+ char *c;
+ const char *cc;
+ size_t l_value;
+ int offset;
+
+ _DIAGASSERT(name != NULL);
+ _DIAGASSERT(value != NULL);
if (*value == '=') /* no `=' in value */
++value;
l_value = strlen(value);
- if ((C = __findenv(name, &offset))) { /* find if already exists */
- if (!rewrite)
+ rwlock_wrlock(&__environ_lock);
+ /* find if already exists */
+ if ((c = __findenv(name, &offset)) != NULL) {
+ if (!rewrite) {
+ rwlock_unlock(&__environ_lock);
return (0);
- if (strlen(C) >= l_value) { /* old larger; copy over */
- while (*C++ = *value++);
+ }
+ if (strlen(c) >= l_value) { /* old larger; copy over */
+ while ((*c++ = *value++) != '\0');
+ rwlock_unlock(&__environ_lock);
return (0);
}
} else { /* create new slot */
- register int cnt;
- register char **P;
+ int cnt;
+ char **p;
- for (P = environ, cnt = 0; *P; ++P, ++cnt);
+ for (p = environ, cnt = 0; *p; ++p, ++cnt);
if (alloced) { /* just increase size */
- environ = (char **)realloc((char *)environ,
+ environ = realloc(environ,
(size_t)(sizeof(char *) * (cnt + 2)));
- if (!environ)
+ if (!environ) {
+ rwlock_unlock(&__environ_lock);
return (-1);
+ }
}
else { /* get new space */
alloced = 1; /* copy old entries into it */
- P = (char **)malloc((size_t)(sizeof(char *) *
- (cnt + 2)));
- if (!P)
+ p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
+ if (!p) {
+ rwlock_unlock(&__environ_lock);
return (-1);
- bcopy(environ, P, cnt * sizeof(char *));
- environ = P;
+ }
+ memcpy(p, environ, cnt * sizeof(char *));
+ environ = p;
}
environ[cnt + 1] = NULL;
offset = cnt;
}
- for (C = (char *)name; *C && *C != '='; ++C); /* no `=' in name */
+ for (cc = name; *cc && *cc != '='; ++cc)/* no `=' in name */
+ continue;
if (!(environ[offset] = /* name + `=' + value */
- malloc((size_t)((int)(C - name) + l_value + 2))))
+ malloc((size_t)((int)(cc - name) + l_value + 2)))) {
+ rwlock_unlock(&__environ_lock);
return (-1);
- for (C = environ[offset]; (*C = *name++) && *C != '='; ++C)
- ;
- for (*C++ = '='; *C++ = *value++; )
- ;
+ }
+ for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
+ for (*c++ = '='; (*c++ = *value++) != '\0'; );
+ rwlock_unlock(&__environ_lock);
return (0);
}
-#endif /* !HAVE_SETENV */
-
-#if !HAVE_UNSETENV
-/*
- * unsetenv(name) --
- * Delete environmental variable "name".
- */
-void
-unsetenv(name)
- const char *name;
-{
- extern char **environ;
- register char **P;
- int offset;
- char *__findenv();
-
- while (__findenv(name, &offset)) /* if set multiple times */
- for (P = &environ[offset];; ++P)
- if (!(*P = *(P + 1)))
- break;
-}
-#endif /* !HAVE_UNSETENV */
diff --git a/pkgtools/libnbcompat/files/setgroupent.c b/pkgtools/libnbcompat/files/setgroupent.c
index 7131a3e6c44..ca2ce26e329 100644
--- a/pkgtools/libnbcompat/files/setgroupent.c
+++ b/pkgtools/libnbcompat/files/setgroupent.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setgroupent.c,v 1.1 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: setgroupent.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -36,13 +36,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_GRP_H
-#include <grp.h>
-#endif
-
-#include "nbcompat/grp.h"
+#include <nbcompat.h>
+#include <nbcompat/grp.h>
int
setgroupent(int stayopen)
diff --git a/pkgtools/libnbcompat/files/setmode.c b/pkgtools/libnbcompat/files/setmode.c
index 318da248b58..e6fb53d2581 100644
--- a/pkgtools/libnbcompat/files/setmode.c
+++ b/pkgtools/libnbcompat/files/setmode.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setmode.c,v 1.8 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: setmode.c,v 1.9 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -32,54 +32,43 @@
* SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94";
#else
-__RCSID("$NetBSD: setmode.c,v 1.8 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: setmode.c,v 1.9 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* #include "namespace.h" */
-#include <sys/types.h>
-#include <sys/stat.h>
+#if 0
+#include "namespace.h"
+#endif
+#include <nbcompat/types.h>
+#include <nbcompat/stat.h>
-#include <assert.h>
-#include <ctype.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#if HAVE_ERRNO_H
#include <errno.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#ifdef SETMODE_DEBUG
-#include <stdio.h>
#endif
-
-#ifndef S_ISTXT
-#define S_ISTXT S_ISVTX
+#if HAVE_SIGNAL_H
+#include <signal.h>
#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
+#ifdef SETMODE_DEBUG
+#include <nbcompat/stdio.h>
#endif
#if 0
-#ifndef __ELF__
-#define _getmode getmode
-#define _setmode setmode
-#else
#ifdef __weak_alias
__weak_alias(getmode,_getmode)
__weak_alias(setmode,_setmode)
#endif
#endif
-#endif
#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
@@ -96,13 +85,13 @@ typedef struct bitcmd {
#define CMD2_OBITS 0x08
#define CMD2_UBITS 0x10
-static BITCMD *addcmd (BITCMD *, int, int, int, u_int);
-static void compress_mode (BITCMD *);
+static BITCMD *addcmd __P((BITCMD *, int, int, int, u_int));
+static void compress_mode __P((BITCMD *));
#ifdef SETMODE_DEBUG
-static void dumpmode (BITCMD *);
+static void dumpmode __P((BITCMD *));
#endif
-#ifndef HAVE_GETMODE
+#if !HAVE_GETMODE
/*
* Given the old mode and an array of bitcmd structures, apply the operations
* described in the bitcmd structures to the old mode, and return the new mode.
@@ -180,9 +169,8 @@ common: if (set->cmd2 & CMD2_CLR) {
return (newmode);
}
}
-#endif /* HAVE_GETMODE */
+#endif /* !HAVE_GETMODE */
-#ifndef HAVE_SETMODE
#define ADDCMD(a, b, c, d) do { \
if (set >= endset) { \
BITCMD *newset; \
@@ -201,6 +189,7 @@ common: if (set->cmd2 & CMD2_CLR) {
#define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
+#if !HAVE_SETMODE
void *
setmode(p)
const char *p;
@@ -208,7 +197,7 @@ setmode(p)
int perm, who;
char op, *ep;
BITCMD *set, *saveset, *endset;
- sigset_t sigset, sigoset;
+ sigset_t signset, sigoset;
mode_t mask;
int equalopdone = 0; /* pacify gcc */
int permXbits, setlen;
@@ -222,8 +211,8 @@ setmode(p)
* the caller is opening files inside a signal handler, protect them
* as best we can.
*/
- sigfillset(&sigset);
- (void)sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+ sigfillset(&signset);
+ (void)sigprocmask(SIG_BLOCK, &signset, &sigoset);
(void)umask(mask = umask(0));
mask = ~mask;
(void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
@@ -373,6 +362,7 @@ apply: if (!*p)
#endif
return (saveset);
}
+#endif /* !HAVE_SETMODE */
static BITCMD *
addcmd(set, op, who, oparg, mask)
@@ -500,4 +490,3 @@ compress_mode(set)
}
}
}
-#endif /* !HAVE_SETMODE */
diff --git a/pkgtools/libnbcompat/files/setpassent.c b/pkgtools/libnbcompat/files/setpassent.c
index 4897e675495..bc454470cc1 100644
--- a/pkgtools/libnbcompat/files/setpassent.c
+++ b/pkgtools/libnbcompat/files/setpassent.c
@@ -1,4 +1,4 @@
-/* $NetBSD: setpassent.c,v 1.1 2004/08/10 18:47:55 jlam Exp $ */
+/* $NetBSD: setpassent.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -36,13 +36,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_PWD_H
-#include <pwd.h>
-#endif
-
-#include "nbcompat/pwd.h"
+#include <nbcompat.h>
+#include <nbcompat/pwd.h>
int
setpassent(int stayopen)
diff --git a/pkgtools/libnbcompat/files/setprogname.c b/pkgtools/libnbcompat/files/setprogname.c
index 47905570302..3ec12efcdb7 100644
--- a/pkgtools/libnbcompat/files/setprogname.c
+++ b/pkgtools/libnbcompat/files/setprogname.c
@@ -1,12 +1,9 @@
-/* $NetBSD: setprogname.c,v 1.2 2003/09/06 23:03:04 grant Exp $ */
+/* $NetBSD: setprogname.c,v 1.3 2004/08/23 03:32:12 jlam Exp $ */
-/*-
- * Copyright (c) 2001 The NetBSD Foundation, Inc.
+/*
+ * Copyright (c) 2001 Christopher G. Demetriou
* All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Todd Vierling.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -17,41 +14,71 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * This product includes software developed for the
+ * NetBSD Project. See http://www.NetBSD.org/ for
+ * information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
-#include "nbcompat.h"
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: setprogname.c,v 1.3 2004/08/23 03:32:12 jlam Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+/* In NetBSD, the program name is set by crt0. It can't be overridden. */
+#undef REALLY_SET_PROGNAME
+#define REALLY_SET_PROGNAME
+
+#if 0
+#include "namespace.h"
+#endif
+
+#include <nbcompat/stdlib.h>
+
+#ifdef REALLY_SET_PROGNAME
+#include <nbcompat/string.h>
static const char *__progname = "<unset_progname>";
+#endif
+#if 0
+#ifdef __weak_alias
+__weak_alias(getprogname,_getprogname)
+#endif
+#endif
+
+/*ARGSUSED*/
void
setprogname(const char *progname)
{
+
+#ifdef REALLY_SET_PROGNAME
__progname = strrchr(progname, '/');
if (__progname == NULL)
__progname = progname;
else
__progname++;
+#endif
}
const char *
getprogname(void)
{
- return __progname;
+
+ return (__progname);
}
diff --git a/pkgtools/libnbcompat/files/sha1.c b/pkgtools/libnbcompat/files/sha1.c
index 1762ee46e96..e72ca8e5673 100644
--- a/pkgtools/libnbcompat/files/sha1.c
+++ b/pkgtools/libnbcompat/files/sha1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sha1.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: sha1.c,v 1.6 2004/08/23 03:32:12 jlam Exp $ */
/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
/*
@@ -15,27 +15,30 @@
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
-#include "nbcompat/nbconfig.h"
-#include "nbcompat/nbtypes.h"
-
#define SHA1HANDSOFF /* Copies data before messing with it. */
#if defined(_KERNEL) || defined(_STANDALONE)
#include <sys/param.h>
+#include <sys/sha1.h>
#include <sys/systm.h>
#define _DIAGASSERT(x) (void)0
#else
-/* #include "namespace.h" */
-#include <assert.h>
-#include <string.h>
+#if 0
+#include "namespace.h"
+#endif
+#include <nbcompat.h>
+#include <nbcompat/types.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/sha1.h>
+#include <nbcompat/string.h>
#endif
-#include "nbcompat/sha1.h"
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
#endif
+#if !HAVE_SHA1_H
+
/*
* XXX Kludge until there is resolution regarding mem*() functions
* XXX in the kernel.
@@ -70,18 +73,26 @@
#if 0
+#if !defined(_KERNEL) && defined(__weak_alias)
__weak_alias(SHA1Transform,_SHA1Transform)
__weak_alias(SHA1Init,_SHA1Init)
__weak_alias(SHA1Update,_SHA1Update)
__weak_alias(SHA1Final,_SHA1Final)
#endif
+#endif
typedef union {
u_char c[64];
u_int l[16];
} CHAR64LONG16;
-#ifdef __sparc_v9__
+/* old sparc64 gcc could not compile this */
+#undef SPARC64_GCC_WORKAROUND
+#if defined(__sparc64__) && defined(__GNUC__) && __GNUC__ < 3
+#define SPARC64_GCC_WORKAROUND
+#endif
+
+#ifdef SPARC64_GCC_WORKAROUND
void do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
void do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
void do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *);
@@ -165,7 +176,7 @@ void SHA1Transform(state, buffer)
d = state[3];
e = state[4];
-#ifdef __sparc_v9__
+#ifdef SPARC64_GCC_WORKAROUND
do_R01(&a, &b, &c, &d, &e, block);
do_R2(&a, &b, &c, &d, &e, block);
do_R3(&a, &b, &c, &d, &e, block);
@@ -272,9 +283,9 @@ void SHA1Final(digest, context)
finalcount[i] = (u_char)((context->count[(i >= 4 ? 0 : 1)]
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
}
- SHA1Update(context, (const u_char *)"\200", 1);
+ SHA1Update(context, (u_char *)"\200", 1);
while ((context->count[0] & 504) != 448)
- SHA1Update(context, (const u_char *)"\0", 1);
+ SHA1Update(context, (u_char *)"\0", 1);
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
if (digest) {
@@ -283,3 +294,5 @@ void SHA1Final(digest, context)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
}
+
+#endif /* HAVE_SHA1_H */
diff --git a/pkgtools/libnbcompat/files/sha1hl.c b/pkgtools/libnbcompat/files/sha1hl.c
index e8f50dedccc..26591a187a3 100644
--- a/pkgtools/libnbcompat/files/sha1hl.c
+++ b/pkgtools/libnbcompat/files/sha1hl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sha1hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: sha1hl.c,v 1.6 2004/08/23 03:32:12 jlam Exp $ */
/* sha1hl.c
* ----------------------------------------------------------------------------
@@ -9,41 +9,49 @@
* ----------------------------------------------------------------------------
*/
-#include "nbcompat/nbconfig.h"
-#include "nbcompat/nbtypes.h"
-
-/* #include "namespace.h" */
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
+#if 0
+#include "namespace.h"
#endif
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
+#include <nbcompat/types.h>
+#if HAVE_SYS_UIO_H
#include <sys/uio.h>
+#endif
-#include <assert.h>
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
#include <errno.h>
-#include "nbcompat/sha1.h"
-#include <stdio.h>
-#include <stdlib.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#include <nbcompat/sha1.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#if !HAVE_SHA1_H
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sha1hl.c,v 1.5 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: sha1hl.c,v 1.6 2004/08/23 03:32:12 jlam Exp $");
#endif /* LIBC_SCCS and not lint */
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
-
#if 0
+#if defined(__weak_alias)
__weak_alias(SHA1End,_SHA1End)
__weak_alias(SHA1File,_SHA1File)
__weak_alias(SHA1Data,_SHA1Data)
#endif
+#endif
/* ARGSUSED */
char *
@@ -112,3 +120,5 @@ SHA1Data (data, len, buf)
SHA1Update(&ctx, data, len);
return(SHA1End(&ctx, buf));
}
+
+#endif /* HAVE_SHA1_H */
diff --git a/pkgtools/libnbcompat/files/snprintf.c b/pkgtools/libnbcompat/files/snprintf.c
index 839483936cd..c7c64dcded9 100644
--- a/pkgtools/libnbcompat/files/snprintf.c
+++ b/pkgtools/libnbcompat/files/snprintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: snprintf.c,v 1.2 2003/09/06 23:03:04 grant Exp $ */
+/* $NetBSD: snprintf.c,v 1.3 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright Patrick Powell 1995
@@ -57,8 +57,10 @@
*
**************************************************************/
-#include "nbcompat.h"
-
+#include <nbcompat.h>
+#if HAVE_STDARG_H
+#include <stdarg.h>
+#endif
#if HAVE_LONG_DOUBLE
#define LDOUBLE long double
diff --git a/pkgtools/libnbcompat/files/statvfs.c b/pkgtools/libnbcompat/files/statvfs.c
index 76fdb9833a0..d132dd15756 100644
--- a/pkgtools/libnbcompat/files/statvfs.c
+++ b/pkgtools/libnbcompat/files/statvfs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: statvfs.c,v 1.2 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: statvfs.c,v 1.3 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -36,13 +36,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_STRING_H
-#include <string.h> /* memcpy() */
-#endif
-
-#include "nbcompat/statvfs.h"
+#include <nbcompat.h>
+#include <nbcompat/string.h>
+#include <nbcompat/statvfs.h>
static void fs2vfs(struct statvfs *vfs, const struct statfs *sfs);
diff --git a/pkgtools/libnbcompat/files/strdup.c b/pkgtools/libnbcompat/files/strdup.c
index 5758b452685..a756ba2c7f1 100644
--- a/pkgtools/libnbcompat/files/strdup.c
+++ b/pkgtools/libnbcompat/files/strdup.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strdup.c,v 1.3 2003/09/06 23:03:05 grant Exp $ */
+/* $NetBSD: strdup.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -29,14 +29,42 @@
* SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: strdup.c,v 1.4 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if 0
+#include "namespace.h"
+#endif
+
+#include <nbcompat/assert.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(strdup,_strdup)
+#endif
+#endif
char *
-strdup(const char *str)
+strdup(str)
+ const char *str;
{
size_t len;
char *copy;
+ _DIAGASSERT(str != NULL);
+
len = strlen(str) + 1;
if (!(copy = malloc(len)))
return (NULL);
diff --git a/pkgtools/libnbcompat/files/strerror.c b/pkgtools/libnbcompat/files/strerror.c
index 4ff013dbefc..c284ad04d27 100644
--- a/pkgtools/libnbcompat/files/strerror.c
+++ b/pkgtools/libnbcompat/files/strerror.c
@@ -1,6 +1,7 @@
-/* $NetBSD: strerror.c,v 1.1.1.1 2003/03/31 05:02:57 grant Exp $ */
+/* $NetBSD: strerror.c,v 1.2 2004/08/23 03:32:12 jlam Exp $ */
-#include "nbcompat.h"
+#include <nbcompat.h>
+#include <nbcompat/string.h>
char *
strerror(int n)
diff --git a/pkgtools/libnbcompat/files/strlcat.c b/pkgtools/libnbcompat/files/strlcat.c
index 08081b43522..3bf71b544f1 100644
--- a/pkgtools/libnbcompat/files/strlcat.c
+++ b/pkgtools/libnbcompat/files/strlcat.c
@@ -1,6 +1,5 @@
-/* $Id: strlcat.c,v 1.3 2003/12/19 22:26:46 grant Exp $ */
-/* from NetBSD: strlcat.c,v 1.16 2003/10/27 00:12:42 lukem Exp */
-/* from OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp */
+/* $NetBSD: strlcat.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
+/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -18,8 +17,34 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "nbcompat.h"
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: strlcat.c,v 1.4 2004/08/23 03:32:12 jlam Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#if 0
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+#endif
+#include <nbcompat/types.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/string.h>
+
+#if 0
+#ifdef _LIBC
+# ifdef __weak_alias
+__weak_alias(strlcat, _strlcat)
+# endif
+#endif
+#endif
+
+#if !HAVE_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
@@ -28,13 +53,23 @@
* If retval >= siz, truncation occurred.
*/
size_t
-strlcat(char *dst, const char *src, size_t siz)
+#ifdef _LIBC && 0
+_strlcat(dst, src, siz)
+#else
+strlcat(dst, src, siz)
+#endif
+ char *dst;
+ const char *src;
+ size_t siz;
{
char *d = dst;
const char *s = src;
size_t n = siz;
size_t dlen;
+ _DIAGASSERT(dst != NULL);
+ _DIAGASSERT(src != NULL);
+
/* Find the end of dst and adjust bytes left but don't go past end */
while (n-- != 0 && *d != '\0')
d++;
@@ -54,3 +89,4 @@ strlcat(char *dst, const char *src, size_t siz)
return(dlen + (s - src)); /* count does not include NUL */
}
+#endif
diff --git a/pkgtools/libnbcompat/files/strlcpy.c b/pkgtools/libnbcompat/files/strlcpy.c
index 14b1aa6e8a4..f3f5ebf1948 100644
--- a/pkgtools/libnbcompat/files/strlcpy.c
+++ b/pkgtools/libnbcompat/files/strlcpy.c
@@ -1,6 +1,5 @@
-/* $NetBSD: strlcpy.c,v 1.3 2003/12/19 22:27:01 grant Exp $ */
-/* from NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp */
-/* from OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp */
+/* $NetBSD: strlcpy.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
+/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -18,47 +17,56 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: strlcpy.c,v 1.4 2004/08/23 03:32:12 jlam Exp $");
+#endif /* LIBC_SCCS and not lint */
-#include "nbcompat.h"
+#if 0
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+#endif
+#include <nbcompat/types.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/string.h>
+#if 0
+#ifdef _LIBC
+# ifdef __weak_alias
+__weak_alias(strlcpy, _strlcpy)
+# endif
+#endif
+#endif
+
+#if !HAVE_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
-strlcpy(char *dst, const char *src, size_t siz)
+#ifdef _LIBC && 0
+_strlcpy(dst, src, siz)
+#else
+strlcpy(dst, src, siz)
+#endif
+ char *dst;
+ const char *src;
+ size_t siz;
{
char *d = dst;
const char *s = src;
size_t n = siz;
+ _DIAGASSERT(dst != NULL);
+ _DIAGASSERT(src != NULL);
+
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
@@ -77,3 +85,4 @@ strlcpy(char *dst, const char *src, size_t siz)
return(s - src - 1); /* count does not include NUL */
}
+#endif
diff --git a/pkgtools/libnbcompat/files/strmode.c b/pkgtools/libnbcompat/files/strmode.c
index f187e5e48a7..372fb2ed7df 100644
--- a/pkgtools/libnbcompat/files/strmode.c
+++ b/pkgtools/libnbcompat/files/strmode.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strmode.c,v 1.4 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: strmode.c,v 1.5 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -29,33 +29,24 @@
* SUCH DAMAGE.
*/
-#include "nbcompat.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)strmode.c 8.3 (Berkeley) 8/15/94";
#else
-__RCSID("$NetBSD: strmode.c,v 1.4 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: strmode.c,v 1.5 2004/08/23 03:32:12 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
-/* #include "namespace.h" */
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#if HAVE_ASSERT_H
-#include <assert.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/types.h>
+#include <nbcompat/stat.h>
-#include <unistd.h>
-
-#ifndef _DIAGASSERT
-#define _DIAGASSERT(cond) assert(cond)
-#endif
+#include <nbcompat/assert.h>
+#include <nbcompat/unistd.h>
void
strmode(mode, p)
@@ -92,9 +83,11 @@ strmode(mode, p)
case S_IFLNK: /* symbolic link */
*p++ = 'l';
break;
+#ifdef S_IFSOCK
case S_IFSOCK: /* socket */
*p++ = 's';
break;
+#endif
#ifdef S_IFIFO
case S_IFIFO: /* fifo */
*p++ = 'p';
@@ -105,6 +98,11 @@ strmode(mode, p)
*p++ = 'w';
break;
#endif
+#ifdef S_IFDOOR
+ case S_IFDOOR: /* door */
+ *p++ = 'D';
+ break;
+#endif
default: /* unknown */
*p++ = '?';
break;
diff --git a/pkgtools/libnbcompat/files/strsep.c b/pkgtools/libnbcompat/files/strsep.c
index 7c2d4498e7c..cd5e4589144 100644
--- a/pkgtools/libnbcompat/files/strsep.c
+++ b/pkgtools/libnbcompat/files/strsep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strsep.c,v 1.3 2003/09/06 23:03:05 grant Exp $ */
+/* $NetBSD: strsep.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -29,8 +29,30 @@
* SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: strsep.c,v 1.4 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+#if 0
+#include "namespace.h"
+#endif
+
+#include <nbcompat/assert.h>
+#include <nbcompat/string.h>
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(strsep,_strsep)
+#endif
+#endif
+
+#if !HAVE_STRSEP
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
@@ -43,13 +65,18 @@
* If *stringp is NULL, strsep returns NULL.
*/
char *
-strsep(char **stringp, const char *delim)
+strsep(stringp, delim)
+ char **stringp;
+ const char *delim;
{
char *s;
const char *spanp;
int c, sc;
char *tok;
+ _DIAGASSERT(stringp != NULL);
+ _DIAGASSERT(delim != NULL);
+
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
@@ -68,3 +95,4 @@ strsep(char **stringp, const char *delim)
}
/* NOTREACHED */
}
+#endif
diff --git a/pkgtools/libnbcompat/files/strtoll.c b/pkgtools/libnbcompat/files/strtoll.c
index 89666a35edc..a3a23a65ef3 100644
--- a/pkgtools/libnbcompat/files/strtoll.c
+++ b/pkgtools/libnbcompat/files/strtoll.c
@@ -1,5 +1,4 @@
-/* $NetBSD: strtoll.c,v 1.4 2003/12/19 22:40:04 grant Exp $ */
-/* from NetBSD: strtoll.c,v 1.6 2003/10/27 00:12:42 lukem Exp */
+/* $NetBSD: strtoll.c,v 1.5 2004/08/23 03:32:12 jlam Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -30,8 +29,43 @@
* SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "from: @(#)strtoq.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: strtoll.c,v 1.5 2004/08/23 03:32:12 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if 0
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+#endif
+
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <nbcompat/limits.h>
+#include <nbcompat/stdlib.h>
+#if 0
+#ifdef _LIBC
+#ifdef __weak_alias
+__weak_alias(strtoll, _strtoll)
+#endif
+#endif
+#endif
+
+#if !HAVE_STRTOLL
/*
* Convert a string to a long long integer.
*
@@ -40,7 +74,14 @@
*/
/* LONGLONG */
long long int
-strtoll(const char *nptr, char **endptr, int base)
+#ifdef _LIBC && 0
+_strtoll(nptr, endptr, base)
+#else
+strtoll(nptr, endptr, base)
+#endif
+ const char *nptr;
+ char **endptr;
+ int base;
{
const char *s;
/* LONGLONG */
@@ -48,6 +89,7 @@ strtoll(const char *nptr, char **endptr, int base)
int c;
int neg, any, cutlim;
+ _DIAGASSERT(nptr != NULL);
/* endptr may be NULL */
#ifdef __GNUC__
@@ -147,3 +189,4 @@ strtoll(const char *nptr, char **endptr, int base)
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}
+#endif
diff --git a/pkgtools/libnbcompat/files/unsetenv.c b/pkgtools/libnbcompat/files/unsetenv.c
new file mode 100644
index 00000000000..a4e8fad0e2c
--- /dev/null
+++ b/pkgtools/libnbcompat/files/unsetenv.c
@@ -0,0 +1,12 @@
+/* $NetBSD: unsetenv.c,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*
+ * Written by Klaus Klein <kleink@NetBSD.org>, April 1, 2003.
+ * Public domain.
+ */
+
+#if 0
+#define __LIBC12_SOURCE__
+#endif
+
+#include "__unsetenv13.c"
diff --git a/pkgtools/libnbcompat/files/unvis.c b/pkgtools/libnbcompat/files/unvis.c
index 3a9f8d9314e..92ee99070f5 100644
--- a/pkgtools/libnbcompat/files/unvis.c
+++ b/pkgtools/libnbcompat/files/unvis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.6 2004/08/16 17:24:56 jlam Exp $ */
+/* $NetBSD: unvis.c,v 1.7 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -29,31 +29,44 @@
* SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
-
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.6 2004/08/16 17:24:56 jlam Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.7 2004/08/23 03:32:13 jlam Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
+#if 0
#define __LIBC12_SOURCE__
+#endif
-/* #include "namespace.h" */
-#include <sys/types.h>
+#if 0
+#include "namespace.h"
+#endif
+#include <nbcompat/types.h>
+
+#include <nbcompat/assert.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/vis.h>
-#include <assert.h>
-#include <ctype.h>
-#include <stdio.h>
-#include "nbcompat/vis.h"
+#if 0
+#ifdef __weak_alias
+__weak_alias(strunvis,_strunvis)
+__weak_alias(unvis,_unvis)
+#endif
+#endif
+
+#if 0
+#ifdef __warn_references
+__warn_references(unvis,
+ "warning: reference to compatibility unvis(); include <vis.h> for correct reference")
+#endif
+#endif
-#ifndef S_GROUND
/*
* decode driven by state machine
*/
@@ -66,17 +79,10 @@ __RCSID("$NetBSD: unvis.c,v 1.6 2004/08/16 17:24:56 jlam Exp $");
#define S_OCTAL3 6 /* octal digit 3 */
#define S_HEX1 7 /* hex digit */
#define S_HEX2 8 /* hex digit 2 */
-#endif
-#ifndef isoctal
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
-#endif
-
-#ifndef xtod
#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
-#endif
-#if !HAVE_UNVIS
int
unvis(cp, c, astate, flag)
char *cp;
@@ -268,7 +274,6 @@ __unvis13(cp, c, astate, flag)
return (UNVIS_SYNBAD);
}
}
-#endif
/*
* strunvis - decode src into dst
@@ -277,7 +282,6 @@ __unvis13(cp, c, astate, flag)
* Dst is null terminated.
*/
-#if !HAVE_STRUNVIS
int
strunvisx(dst, src, flag)
char *dst;
@@ -320,4 +324,3 @@ strunvis(dst, src)
{
return strunvisx(dst, src, 0);
}
-#endif
diff --git a/pkgtools/libnbcompat/files/usleep.c b/pkgtools/libnbcompat/files/usleep.c
index 3c84e5ea88e..6c7ce86d993 100644
--- a/pkgtools/libnbcompat/files/usleep.c
+++ b/pkgtools/libnbcompat/files/usleep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: usleep.c,v 1.2 2003/09/06 23:03:06 grant Exp $ */
+/* $NetBSD: usleep.c,v 1.3 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 1999-2000 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "nbcompat.h"
+#include <nbcompat.h>
int
usleep(unsigned int usec)
@@ -47,9 +47,7 @@ usleep(unsigned int usec)
tv.tv_sec = 0;
tv.tv_usec = usec;
return (select(1, NULL, NULL, NULL, &tv));
-#elif HAVE_POLL
- return (poll(NULL, 0, usec / 1000);
#else
-# error no way to implement usleep
+ return (poll(NULL, 0, usec / 1000);
#endif
}
diff --git a/pkgtools/libnbcompat/files/utimes.c b/pkgtools/libnbcompat/files/utimes.c
index 6ab08b708d7..3b66e43860d 100644
--- a/pkgtools/libnbcompat/files/utimes.c
+++ b/pkgtools/libnbcompat/files/utimes.c
@@ -1,4 +1,4 @@
-/* $NetBSD: utimes.c,v 1.1 2004/03/11 14:11:04 grant Exp $ */
+/* $NetBSD: utimes.c,v 1.2 2004/08/23 03:32:13 jlam Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -38,10 +38,11 @@
* Emulate utimes(2) using utime(2), but losing sub-second granularity.
*/
-#include "nbcompat.h"
-
-#include <unistd.h>
+#include <nbcompat.h>
+#include <nbcompat/unistd.h>
+#if HAVE_UTIME_H
#include <utime.h>
+#endif
int
utimes(const char *path, const struct timeval *times)
diff --git a/pkgtools/libnbcompat/files/vis.c b/pkgtools/libnbcompat/files/vis.c
index 91cbc065ff7..dd9cc1da1c1 100644
--- a/pkgtools/libnbcompat/files/vis.c
+++ b/pkgtools/libnbcompat/files/vis.c
@@ -1,7 +1,6 @@
-/* $NetBSD: vis.c,v 1.6 2004/08/16 17:24:57 jlam Exp $ */
+/* $NetBSD: vis.c,v 1.7 2004/08/23 03:32:13 jlam Exp $ */
/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -34,36 +33,54 @@
* SUCH DAMAGE.
*/
-#include "nbcompat/nbconfig.h"
-#include "nbcompat/nbtypes.h"
-
-#if HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#endif
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.6 2004/08/16 17:24:57 jlam Exp $");
+__RCSID("$NetBSD: vis.c,v 1.7 2004/08/23 03:32:13 jlam Exp $");
#endif /* LIBC_SCCS and not lint */
-/* #include "namespace.h" */
-#include <sys/types.h>
-
-#if HAVE_ASSERT_H
-#include <assert.h>
+#if 0
+#include "namespace.h"
#endif
+#include <nbcompat/types.h>
-#include "nbcompat/vis.h"
-#include <stdlib.h>
+#include <nbcompat/assert.h>
+#include <nbcompat/vis.h>
+#include <nbcompat/stdlib.h>
#if 0
-#ifndef __ELF__
-#define _strsvis strsvis
-#define _strsvisx strsvisx
-#define _strvis strvis
-#define _strvisx strvisx
-#define _svis svis
-#define _vis vis
-#else
#ifdef __weak_alias
__weak_alias(strsvis,_strsvis)
__weak_alias(strsvisx,_strsvisx)
@@ -73,44 +90,37 @@ __weak_alias(svis,_svis)
__weak_alias(vis,_vis)
#endif
#endif
-#endif
-#include <ctype.h>
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/string.h>
#undef BELL
-#if defined(__STDC__)
#define BELL '\a'
-#else
-#define BELL '\007'
-#endif
-
-static const char empty[] = "";
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
#define xtoa(c) "0123456789abcdef"[c]
-#define MAXEXTRAS 5
+#define MAXEXTRAS 5
#define MAKEEXTRALIST(flag, extra, orig) \
do { \
const char *o = orig; \
- char *e; \
+ char *e; \
while (*o++) \
continue; \
- extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \
+ extra = alloca((size_t)((o - orig) + MAXEXTRAS)); \
for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
continue; \
e--; \
- if (flag & VIS_SP) *e++ = ' '; \
+ if (flag & VIS_SP) *e++ = ' '; \
if (flag & VIS_TAB) *e++ = '\t'; \
- if (flag & VIS_NL) *e++ = '\n'; \
- if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
+ if (flag & VIS_NL) *e++ = '\n'; \
+ if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
*e = '\0'; \
} while (/*CONSTCOND*/0)
@@ -119,7 +129,7 @@ do { \
* This is HVIS, the macro of vis used to HTTP style (RFC 1808)
*/
#define HVIS(dst, c, flag, nextc, extra) \
-do \
+do \
if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
*dst++ = '%'; \
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
@@ -128,7 +138,7 @@ do \
SVIS(dst, c, flag, nextc, extra); \
} \
while (/*CONSTCOND*/0)
-
+
/*
* This is SVIS, the central macro of vis.
* dst: Pointer to the destination buffer
@@ -140,49 +150,53 @@ while (/*CONSTCOND*/0)
*/
#define SVIS(dst, c, flag, nextc, extra) \
do { \
- int isextra, isc; \
+ int isextra; \
isextra = strchr(extra, c) != NULL; \
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
((flag & VIS_SAFE) && issafe(c)))) { \
*dst++ = c; \
break; \
} \
- isc = 0; \
if (flag & VIS_CSTYLE) { \
switch (c) { \
case '\n': \
- isc = 1; *dst++ = '\\'; *dst++ = 'n'; \
- break; \
+ *dst++ = '\\'; *dst++ = 'n'; \
+ continue; \
case '\r': \
- isc = 1; *dst++ = '\\'; *dst++ = 'r'; \
- break; \
+ *dst++ = '\\'; *dst++ = 'r'; \
+ continue; \
case '\b': \
- isc = 1; *dst++ = '\\'; *dst++ = 'b'; \
- break; \
+ *dst++ = '\\'; *dst++ = 'b'; \
+ continue; \
case BELL: \
- isc = 1; *dst++ = '\\'; *dst++ = 'a'; \
- break; \
+ *dst++ = '\\'; *dst++ = 'a'; \
+ continue; \
case '\v': \
- isc = 1; *dst++ = '\\'; *dst++ = 'v'; \
- break; \
+ *dst++ = '\\'; *dst++ = 'v'; \
+ continue; \
case '\t': \
- isc = 1; *dst++ = '\\'; *dst++ = 't'; \
- break; \
+ *dst++ = '\\'; *dst++ = 't'; \
+ continue; \
case '\f': \
- isc = 1; *dst++ = '\\'; *dst++ = 'f'; \
- break; \
+ *dst++ = '\\'; *dst++ = 'f'; \
+ continue; \
case ' ': \
- isc = 1; *dst++ = '\\'; *dst++ = 's'; \
- break; \
+ *dst++ = '\\'; *dst++ = 's'; \
+ continue; \
case '\0': \
- isc = 1; *dst++ = '\\'; *dst++ = '0'; \
+ *dst++ = '\\'; *dst++ = '0'; \
if (isoctal(nextc)) { \
*dst++ = '0'; \
*dst++ = '0'; \
} \
+ continue; \
+ default: \
+ if (isgraph(c)) { \
+ *dst++ = '\\'; *dst++ = c; \
+ continue; \
+ } \
} \
} \
- if (isc) break; \
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
*dst++ = '\\'; \
*dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0'; \
@@ -225,11 +239,10 @@ svis(dst, c, flag, nextc, extra)
else
SVIS(dst, c, flag, nextc, nextra);
*dst = '\0';
- free(nextra);
return(dst);
}
-#ifndef HAVE_STRSVIS
+
/*
* strsvis, strsvisx - visually encode characters from src into dst
*
@@ -237,24 +250,25 @@ svis(dst, c, flag, nextc, extra)
* be encoded, too. These functions are useful e. g. to
* encode strings in such a way so that they are not interpreted
* by a shell.
- *
+ *
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
- * is returned.
+ * is returned.
*
* Strsvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
*/
int
-strsvis(dst, src, flag, extra)
+strsvis(dst, csrc, flag, extra)
char *dst;
- const char *src;
+ const char *csrc;
int flag;
const char *extra;
{
- char c;
+ int c;
char *start;
char *nextra;
+ const unsigned char *src = (const unsigned char *)csrc;
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
@@ -268,22 +282,22 @@ strsvis(dst, src, flag, extra)
SVIS(dst, c, flag, *src, nextra);
}
*dst = '\0';
- free(nextra);
return (dst - start);
}
int
-strsvisx(dst, src, len, flag, extra)
+strsvisx(dst, csrc, len, flag, extra)
char *dst;
- const char *src;
+ const char *csrc;
size_t len;
int flag;
const char *extra;
{
- char c;
+ int c;
char *start;
char *nextra;
+ const unsigned char *src = (const unsigned char *)csrc;
_DIAGASSERT(dst != NULL);
_DIAGASSERT(src != NULL);
@@ -302,11 +316,8 @@ strsvisx(dst, src, len, flag, extra)
}
}
*dst = '\0';
- free(nextra);
return (dst - start);
}
-#endif
-
/*
* vis - visually encode characters
@@ -315,29 +326,28 @@ char *
vis(dst, c, flag, nextc)
char *dst;
int c, flag, nextc;
-
+
{
char *extra;
_DIAGASSERT(dst != NULL);
- MAKEEXTRALIST(flag, extra, empty);
+ MAKEEXTRALIST(flag, extra, "");
if (flag & VIS_HTTPSTYLE)
- HVIS(dst, c, flag, nextc, extra);
+ HVIS(dst, c, flag, nextc, extra);
else
- SVIS(dst, c, flag, nextc, extra);
+ SVIS(dst, c, flag, nextc, extra);
*dst = '\0';
- free(extra);
return (dst);
}
-#if HAVE_STRVIS
+
/*
* strvis, strvisx - visually encode characters from src into dst
- *
+ *
* Dst must be 4 times the size of src to account for possible
* expansion. The length of dst, not including the trailing NULL,
- * is returned.
+ * is returned.
*
* Strvisx encodes exactly len bytes from src into dst.
* This is useful for encoding a block of data.
@@ -349,12 +359,9 @@ strvis(dst, src, flag)
int flag;
{
char *extra;
- int ret;
- MAKEEXTRALIST(flag, extra, empty);
- ret = strsvis(dst, src, flag, extra);
- free(extra);
- return(ret);
+ MAKEEXTRALIST(flag, extra, "");
+ return (strsvis(dst, src, flag, extra));
}
@@ -366,11 +373,7 @@ strvisx(dst, src, len, flag)
int flag;
{
char *extra;
- int ret;
- MAKEEXTRALIST(flag, extra, empty);
- ret = strsvisx(dst, src, len, flag, extra);
- free(extra);
- return(ret);
+ MAKEEXTRALIST(flag, extra, "");
+ return (strsvisx(dst, src, len, flag, extra));
}
-#endif
diff --git a/pkgtools/libnbcompat/files/warn.c b/pkgtools/libnbcompat/files/warn.c
new file mode 100644
index 00000000000..e3522c854d3
--- /dev/null
+++ b/pkgtools/libnbcompat/files/warn.c
@@ -0,0 +1,115 @@
+/* $NetBSD: warn.c,v 1.1 2004/08/23 03:32:13 jlam Exp $ */
+
+/*
+ * Copyright 1997-2000 Luke Mewburn <lukem@netbsd.org>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <nbcompat.h>
+#include <nbcompat/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: warn.c,v 1.1 2004/08/23 03:32:13 jlam Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#ifndef __NO_NAMESPACE_H /* XXX */
+#if 0
+#include "namespace.h"
+#endif
+#endif
+#include <nbcompat/err.h>
+#if HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
+#if 0
+#ifdef __weak_alias
+__weak_alias(warn, _warn)
+#endif
+#endif
+
+void
+warn(const char *fmt, ...)
+{
+ va_list ap;
+ int sverrno;
+
+ sverrno = errno;
+ (void)fprintf(stderr, "%s: ", getprogname());
+ va_start(ap, fmt);
+ if (fmt != NULL) {
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, ": ");
+ }
+ va_end(ap);
+ (void)fprintf(stderr, "%s\n", strerror(sverrno));
+}
+
+void
+warnx(const char *fmt, ...)
+{
+ va_list ap;
+
+ (void)fprintf(stderr, "%s: ", getprogname());
+ va_start(ap, fmt);
+ if (fmt != NULL)
+ (void)vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ (void)fprintf(stderr, "\n");
+}
+
+void
+vwarn(fmt, ap)
+ const char *fmt;
+ va_list ap;
+{
+ int sverrno;
+
+ sverrno = errno;
+ (void)fprintf(stderr, "%s: ", getprogname());
+ if (fmt != NULL) {
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, ": ");
+ }
+ (void)fprintf(stderr, "%s\n", strerror(sverrno));
+}
+
+void
+vwarnx(fmt, ap)
+ const char *fmt;
+ va_list ap;
+{
+ (void)fprintf(stderr, "%s: ", getprogname());
+ if (fmt != NULL)
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, "\n");
+}