Import NetBSD tools and build.sh
This commit finalizes support for cross compilation. The tools directory are all links to the actual tools and are built on the host system to build Minix. build.sh is the work horse that takes care of all environment settings. It's slightly adjusted for Minix. The /usr/src/Makefile has additional targets needed for cross compilation.
This commit is contained in:
91
tools/compat/Makefile
Normal file
91
tools/compat/Makefile
Normal file
@@ -0,0 +1,91 @@
|
||||
# $NetBSD: Makefile,v 1.56 2012/02/18 17:51:21 njoly Exp $
|
||||
|
||||
HOSTLIB= nbcompat
|
||||
|
||||
SRCS= atoll.c basename.c dirname.c fgetln.c flock.c fparseln.c \
|
||||
fpurge.c getline.c getmode.c getopt_long.c gettemp.c \
|
||||
heapsort.c \
|
||||
issetugid.c lchflags.c lchmod.c lchown.c libyywrap.c \
|
||||
md2.c md2hl.c md4c.c md4hl.c md5c.c md5hl.c \
|
||||
mi_vector_hash.c mkdtemp.c \
|
||||
mkstemp.c pread.c putc_unlocked.c pwcache.c pwrite.c \
|
||||
pw_scan.c \
|
||||
raise_default_signal.c rmd160.c rmd160hl.c \
|
||||
setenv.c setgroupent.c \
|
||||
setpassent.c setprogname.c sha1.c sha1hl.c sha2.c \
|
||||
sha256hl.c sha384hl.c sha512hl.c snprintf.c stat_flags.c \
|
||||
strlcat.c strlcpy.c strmode.c strndup.c strsep.c strsuftoll.c \
|
||||
strtoll.c unvis.c vis.c err.c errx.c verr.c verrx.c \
|
||||
vwarn.c vwarnx.c warn.c warnx.c fts.c glob.c efun.c
|
||||
|
||||
BUILD_OSTYPE!= uname -s
|
||||
|
||||
# Disable use of pre-compiled headers on Darwin.
|
||||
.if ${BUILD_OSTYPE} == "Darwin"
|
||||
CPPFLAGS+= -no-cpp-precomp
|
||||
.endif
|
||||
|
||||
# -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and
|
||||
# other file ops, on many systems, without changing function names.
|
||||
|
||||
CPPFLAGS+= -I. -I./include -I${.CURDIR} -I${.CURDIR}/sys \
|
||||
-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64
|
||||
|
||||
.PATH: ${.CURDIR}/../../lib/libc/gen \
|
||||
${.CURDIR}/../../lib/libc/hash \
|
||||
${.CURDIR}/../../lib/libc/hash/md2 \
|
||||
${.CURDIR}/../../lib/libc/hash/md5 \
|
||||
${.CURDIR}/../../lib/libc/hash/rmd160 \
|
||||
${.CURDIR}/../../lib/libc/hash/sha1 \
|
||||
${.CURDIR}/../../lib/libc/hash/sha2 \
|
||||
${.CURDIR}/../../lib/libc/md \
|
||||
${.CURDIR}/../../lib/libc/stdio \
|
||||
${.CURDIR}/../../lib/libc/stdlib \
|
||||
${.CURDIR}/../../lib/libc/string \
|
||||
${.CURDIR}/../../lib/libutil \
|
||||
${.CURDIR}/../../common/lib/libc/string \
|
||||
${.CURDIR}/../../common/lib/libc/hash/rmd160 \
|
||||
${.CURDIR}/../../common/lib/libc/hash/sha1 \
|
||||
${.CURDIR}/../../common/lib/libc/hash/sha2 \
|
||||
${.CURDIR}/../../common/lib/libc/md \
|
||||
${.CURDIR}/../../common/lib/libc/stdlib \
|
||||
${.CURDIR}/../../external/bsd/flex/dist
|
||||
|
||||
DPSRCS+= defs.mk
|
||||
CLEANFILES+= config.log config.status configure.lineno *.stamp
|
||||
|
||||
# Get components of Berkeley DB.
|
||||
_CURDIR:= ${.CURDIR}
|
||||
.CURDIR:= ${_CURDIR}/../../lib/libc
|
||||
.include "${.CURDIR}/db/Makefile.inc"
|
||||
.CURDIR:= ${_CURDIR}
|
||||
|
||||
SRCS:= ${SRCS:M*.c}
|
||||
|
||||
config.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
|
||||
rm -f ${.TARGET}
|
||||
CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \
|
||||
${HOST_SH} ${.CURDIR}/configure --cache-file=config.cache
|
||||
|
||||
defs.mk: config.cache
|
||||
@touch ${.TARGET}
|
||||
|
||||
# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
|
||||
# configure.ac. See more detailed instructions in configure.ac.
|
||||
regen:
|
||||
cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoconf
|
||||
cd ${.CURDIR} && ${TOOLDIR}/bin/${_TOOL_PREFIX}autoheader
|
||||
|
||||
include/.stamp:
|
||||
mkdir -p include/sys include/machine include/rpc include/arpa
|
||||
@touch ${.TARGET}
|
||||
|
||||
cleandir:
|
||||
-rm -f nbtool_config.h confdefs.h defs.mk
|
||||
-rm -r -f include
|
||||
-rm -f config.cache
|
||||
|
||||
HOST_CPPFLAGS:= ${CPPFLAGS}
|
||||
CPPFLAGS:= # empty
|
||||
|
||||
.include <bsd.hostlib.mk>
|
||||
87
tools/compat/README
Normal file
87
tools/compat/README
Normal file
@@ -0,0 +1,87 @@
|
||||
$NetBSD: README,v 1.12 2005/04/05 00:21:22 jmc Exp $
|
||||
|
||||
Special notes for cross-hosting a NetBSD build on certain platforms.
|
||||
Only those platforms which have been tested to complete a "build.sh" run
|
||||
are listed.
|
||||
|
||||
All hosts must have a POSIX compatible sh. /bin/sh is assumed unless
|
||||
otherwise set. This can be overridden by setting HOST_SH in the environment.
|
||||
|
||||
In addition all hosts must provide the following local tools:
|
||||
|
||||
gzip
|
||||
|
||||
=====
|
||||
|
||||
NetBSD:
|
||||
|
||||
* _NETBSD_SOURCE is *not* to be defined/pulled in during compat/tools builds.
|
||||
compat_defs.h will error out if it finds it defined.
|
||||
|
||||
HP-UX:
|
||||
|
||||
* zlib must be available.
|
||||
This will be fixed in the future to include zlib in libnbcompat.
|
||||
|
||||
=====
|
||||
|
||||
LINUX:
|
||||
|
||||
* Tested on RedHat Linux 7.1 (i386).
|
||||
Tested on RedHat Linux 7.3 (i686) on 16 Sep 2002. Requires "LANG=C"
|
||||
in the environment.
|
||||
|
||||
* Tested on Redhat Linux 8.0 (i686) in Fall 2003. Requires no special settings.
|
||||
|
||||
* Tested on Redhat ES3 and AS3 in spring of 2004. Requires no special settings.
|
||||
|
||||
* The gcc (and libstdc++, if needed) package must be installed, along
|
||||
with the typical system development packages (glibc-devel, etc.).
|
||||
|
||||
* The ncurses-devel package must be installed (for nbinfo).
|
||||
|
||||
* The zlib and zlib-devel packages must be installed. This will be
|
||||
fixed in the future to include zlib in libnbcompat.
|
||||
|
||||
=====
|
||||
|
||||
MACOS
|
||||
Requires a case sensitive filesystem such as UFS
|
||||
|
||||
* Tested on 10.2.8 with Dec 2002 Developer Tools
|
||||
- may require a fix to /usr/bin/join, netbsd's join should work fine
|
||||
* Tested on 10.3 with xcode 1.5
|
||||
- compiles fine out of the box
|
||||
|
||||
=====
|
||||
|
||||
NETBSD (earlier releases):
|
||||
|
||||
* Tested on NetBSD 1.5.2 (machine-independently).
|
||||
|
||||
* Should need no special setup.
|
||||
|
||||
=====
|
||||
|
||||
SOLARIS:
|
||||
|
||||
* Tested on Solaris/x86 8 (5.8) with gcc 2.95.2 and Solaris/sparc 8 (5.8)
|
||||
with gcc 3.2 (not yet tested with SUNWspro).
|
||||
|
||||
* $HOST_CC needs to be set properly (for gcc, it should be set to "gcc",
|
||||
otherwise the improper /usr/ucb/cc may be invoked by accident).
|
||||
|
||||
* The SUNWzlib package (or a built version of zlib visible to $HOST_CC,
|
||||
such as SMCzlib from sunfreeware.com) must be installed. This will be
|
||||
fixed in the future to include zlib in libnbcompat.
|
||||
|
||||
* Needs the following paths, in this order, in $PATH:
|
||||
|
||||
/usr/xpg4/bin
|
||||
/usr/ccs/bin
|
||||
<path to host C and C++ compilers>
|
||||
/usr/bin
|
||||
|
||||
/usr/ucb may optionally be placed before /usr/bin, per your preference,
|
||||
but /usr/ucb *MUST NOT* be before /usr/ccs/bin or before the path to
|
||||
the host C and C++ compilers.
|
||||
1196
tools/compat/compat_defs.h
Normal file
1196
tools/compat/compat_defs.h
Normal file
File diff suppressed because it is too large
Load Diff
17
tools/compat/compat_getopt.h
Normal file
17
tools/compat/compat_getopt.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/* $NetBSD: compat_getopt.h,v 1.2 2007/11/08 20:30:59 christos Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD getopt.h in libnbcompat. */
|
||||
|
||||
#if HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#define option __nbcompat_option
|
||||
#define getopt_long __nbcompat_getopt_long
|
||||
|
||||
#undef no_argument
|
||||
#undef required_argument
|
||||
#undef optional_argument
|
||||
#undef _GETOPT_H_
|
||||
|
||||
#include "../../include/getopt.h"
|
||||
63
tools/compat/compat_pwd.h
Normal file
63
tools/compat/compat_pwd.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/* $NetBSD: compat_pwd.h,v 1.6 2009/01/18 01:44:09 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* 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:
|
||||
* 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.
|
||||
*
|
||||
* 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 _COMPAT_PWD_H_
|
||||
#define _COMPAT_PWD_H_
|
||||
|
||||
/* A very special version of <pwd.h> for pwd_mkdb(8) and __nbcompat_pwscan(3). */
|
||||
|
||||
#include "../../include/pwd.h"
|
||||
|
||||
#define passwd __nbcompat_passwd
|
||||
#define pw_scan __nbcompat_pw_scan
|
||||
#ifdef LOGIN_NAME_MAX
|
||||
#undef LOGIN_NAME_MAX
|
||||
#endif
|
||||
/* Taken from syslimits.h. Need the NetBSD def, not the local system def */
|
||||
#define LOGIN_NAME_MAX 17
|
||||
|
||||
/* All elements exactly sized: */
|
||||
struct passwd {
|
||||
char *pw_name;
|
||||
char *pw_passwd;
|
||||
int32_t pw_uid;
|
||||
int32_t pw_gid;
|
||||
int64_t pw_change;
|
||||
char *pw_class;
|
||||
char *pw_gecos;
|
||||
char *pw_dir;
|
||||
char *pw_shell;
|
||||
int64_t pw_expire;
|
||||
};
|
||||
|
||||
int pw_scan(char *, struct passwd *, int *);
|
||||
|
||||
#endif /* !_PWD_H_ */
|
||||
8442
tools/compat/configure
vendored
Executable file
8442
tools/compat/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
236
tools/compat/configure.ac
Normal file
236
tools/compat/configure.ac
Normal file
@@ -0,0 +1,236 @@
|
||||
# $NetBSD: configure.ac,v 1.74 2011/11/03 14:13:53 joerg Exp $
|
||||
#
|
||||
# Autoconf definition file for libnbcompat.
|
||||
#
|
||||
# When you edit configure.ac:
|
||||
# 0. Create the tools versions of autoconf and autoheader:
|
||||
# cd ${SRCDIR} && build.sh -V MKMAINTAINERTOOLS=yes tools
|
||||
# (This might not work if you try it after editing configure.ac.)
|
||||
# 1. edit configure.ac
|
||||
# 2. Regenerate "configure" and "nbtool_config.h.in" from "configure.ac":
|
||||
# cd ${SRCDIR}/tools/compat && ${TOOLDIR}/bin/nbmake-${MACHINE} regen
|
||||
# (Please don't use a non-tools version of autoconf or autoheader.)
|
||||
# 3. Test that the tools still build:
|
||||
# mv ${TOOLDIR} ${TOOLDIR}.bak
|
||||
# cd ${SRCDIR} && build.sh -V MKMAINTAINERTOOLS=yes tools
|
||||
# 4. cvs commit files that you edited.
|
||||
# 5. Regen again, to pick up changed RCS IDs from the above commit:
|
||||
# cd ${SRCDIR}/tools/compat && ${TOOLDIR}/bin/nbmake-${MACHINE} regen
|
||||
# 6. cvs commit files that were generated.
|
||||
#
|
||||
|
||||
AC_INIT([libnbcompat], [noversion], [lib-bug-people@NetBSD.org])
|
||||
AC_CONFIG_HEADERS(nbtool_config.h)
|
||||
AC_CONFIG_FILES(defs.mk)
|
||||
|
||||
# Autoheader header and footer
|
||||
AH_TOP([/* $][NetBSD$ */
|
||||
|
||||
#ifndef __NETBSD_NBTOOL_CONFIG_H__
|
||||
#define __NETBSD_NBTOOL_CONFIG_H__])
|
||||
|
||||
AH_BOTTOM([#include "compat_defs.h"
|
||||
#endif /* !__NETBSD_NBTOOL_CONFIG_H__ */])
|
||||
|
||||
AC_DEFUN([AC_NETBSD],
|
||||
[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
|
||||
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
|
||||
AC_MSG_CHECKING([for NetBSD])
|
||||
AC_EGREP_CPP(yes,
|
||||
[#ifdef __NetBSD__
|
||||
yes
|
||||
#endif
|
||||
],
|
||||
[AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([_POSIX_SOURCE], 1, [Define for NetBSD headers.])
|
||||
AC_DEFINE([_POSIX_C_SOURCE], 200112L, [Define for NetBSD headers.])
|
||||
AC_DEFINE([_XOPEN_SOURCE], 600, [Define for NetBSD headers.])],
|
||||
[AC_MSG_RESULT([no])])
|
||||
])# AC_NETBSD
|
||||
|
||||
AC_NETBSD
|
||||
AC_PATH_PROG(BSHELL, sh, )
|
||||
if test x"$BSHELL" = x; then
|
||||
AC_MSG_ERROR([sh must be somewhere on \$PATH])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([PATH_BSHELL], "$BSHELL", [Path to sh(1).])
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
AC_HEADER_STDC
|
||||
|
||||
# Confirm existence of zlib. (This is available as a default install
|
||||
# option on many OS's; this could be added as a reachover build in the
|
||||
# future.)
|
||||
AC_CHECK_HEADER(zlib.h,,
|
||||
AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
|
||||
AC_CHECK_LIB(z, gzdopen,,
|
||||
AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
|
||||
|
||||
# Make sure certain required headers are available.
|
||||
# These are not necessarily required by the code, but they are not
|
||||
# currently conditionalized.
|
||||
AC_CHECK_HEADERS(sys/ioctl.h sys/mman.h sys/param.h \
|
||||
sys/socket.h sys/stat.h sys/time.h sys/types.h sys/utsname.h \
|
||||
sys/wait.h assert.h ctype.h errno.h fcntl.h grp.h limits.h locale.h \
|
||||
netdb.h pwd.h signal.h stdarg.h stdio.h stdlib.h string.h \
|
||||
termios.h unistd.h,,
|
||||
AC_MSG_ERROR([standard system header file not found]))
|
||||
|
||||
# Find headers that may not be available.
|
||||
AC_HEADER_DIRENT
|
||||
AC_CHECK_HEADERS(sys/mtio.h sys/sysmacros.h sys/syslimits.h \
|
||||
getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h)
|
||||
AC_CHECK_HEADERS(sys/bswap.h machine/bswap.h sys/cdefs.h machine/endian.h \
|
||||
sys/endian.h sys/featuretest.h err.h inttypes.h libgen.h paths.h \
|
||||
stdint.h util.h resolv.h arpa/nameser.h,,
|
||||
[test -f include/$ac_header || touch include/$ac_header])
|
||||
AC_CHECK_HEADERS(rpc/types.h netconfig.h,,
|
||||
[echo '#include "nbtool_config.h"' >include/$ac_header.new
|
||||
echo '#include "'$srcdir/../../include/$ac_header'"' \
|
||||
>>include/$ac_header.new
|
||||
if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
|
||||
rm -f include/$ac_header.new
|
||||
else
|
||||
mv -f include/$ac_header.new include/$ac_header
|
||||
fi])
|
||||
|
||||
# Typedefs.
|
||||
AC_TYPE_SIZE_T
|
||||
AC_CHECK_TYPES([id_t, long long, u_long, u_char, u_short, u_int, u_quad_t])
|
||||
AC_CHECK_TYPE(socklen_t, [AC_DEFINE([HAVE_SOCKLEN_T], 1,
|
||||
[Define if you have the socklen_t type.])],,
|
||||
[#include <sys/types.h>
|
||||
#include <sys/socket.h>])
|
||||
|
||||
dnl XXX - This is UGLY. Need a better way to homogenize the bitsized types,
|
||||
dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
|
||||
dnl
|
||||
define([NB_CHECK_INTTYPE], [
|
||||
AC_CHECK_TYPE(uint][$1][_t,, [
|
||||
AC_CHECK_TYPE(u_int][$1][_t,
|
||||
AC_DEFINE(uint][$1][_t, u_int][$1][_t, \
|
||||
[Define if you have u_int][$1][_t, but not uint][$1][_t.]),
|
||||
AC_MSG_ERROR([cannot find a suitable type for uint][$1][_t]))
|
||||
])
|
||||
AC_CHECK_TYPE(u_int][$1][_t,, [
|
||||
AC_CHECK_TYPE(uint][$1][_t,
|
||||
AC_DEFINE(u_int][$1][_t, uint][$1][_t, \
|
||||
[Define if you have uint][$1][_t, but not u_int][$1][_t.]),
|
||||
AC_MSG_ERROR([cannot find a suitable type for u_int][$1][_t]))
|
||||
])
|
||||
])
|
||||
|
||||
NB_CHECK_INTTYPE(8)
|
||||
NB_CHECK_INTTYPE(16)
|
||||
NB_CHECK_INTTYPE(32)
|
||||
NB_CHECK_INTTYPE(64)
|
||||
|
||||
# Struct members.
|
||||
AC_CHECK_MEMBERS([DIR.dd_fd, DIR.__dd_fd, struct dirent.d_namlen],,,
|
||||
[#include <sys/types.h>
|
||||
#include <dirent.h>])
|
||||
AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen,
|
||||
struct stat.st_birthtime, struct stat.st_birthtimensec,
|
||||
struct stat.st_atim, struct stat.st_mtimensec],,,
|
||||
[#include <sys/stat.h>])
|
||||
AC_CHECK_MEMBERS(struct statvfs.f_iosize,,, [#include <sys/statvfs.h>])
|
||||
|
||||
# Global variable decls.
|
||||
AC_CHECK_DECLS([optind, optreset],,, [
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
])
|
||||
AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
|
||||
|
||||
# Library functions (where a .h check isn't enough).
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_FUNCS(atoll asprintf asnprintf basename devname dirfd dirname \
|
||||
esetfunc fgetln flock fpurge __fpurge futimes getline \
|
||||
getopt getopt_long group_from_gid gid_from_group \
|
||||
heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \
|
||||
mkdtemp poll pread putc_unlocked pwcache_userdb pwcache_groupdb \
|
||||
pwrite raise_default_signal random setenv \
|
||||
setgroupent setprogname setpassent snprintf strlcat strlcpy strmode \
|
||||
strndup strsep strsuftoll strtoll \
|
||||
user_from_uid uid_from_user vasprintf vasnprintf vsnprintf)
|
||||
|
||||
AC_CHECK_DECLS([user_from_uid, uid_from_user, pwcache_userdb],,,[
|
||||
#include <pwd.h>
|
||||
])
|
||||
AC_CHECK_DECLS([group_from_gid, gid_from_group, pwcache_groupdb],,,[
|
||||
#include <grp.h>
|
||||
])
|
||||
AC_CHECK_DECLS([strndup],,,[#include <string.h>])
|
||||
AC_CHECK_DECLS([strsuftoll],,,[#include <stdlib.h>])
|
||||
AC_CHECK_DECLS([lchflags, lchmod, lchown],,,[
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
])
|
||||
|
||||
AC_CHECK_DECLS([htobe16, htobe32, htobe64, htole16, htole32, htole64,
|
||||
be16toh, be32toh, be64toh, le16toh, le32toh, le64toh],,,
|
||||
[#include <sys/types.h>])
|
||||
|
||||
AC_CHECK_DECLS([bswap16, bswap32, bswap64],,, [#include <machine/bswap.h>])
|
||||
|
||||
AC_CHECK_DECLS([be16enc, le16enc, be16dec, le16dec, be32enc, le32enc,
|
||||
be32dec, le32dec, be64enc, le64enc, be64dec, le64dec],,,
|
||||
[#include <sys/endian.h>])
|
||||
|
||||
AC_CHECK_DECLS([fstatvfs],,, [#include <sys/statvfs.h>])
|
||||
|
||||
AC_CHECK_DECLS([setgroupent, setpassent],,, [
|
||||
#include <sys/types.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
])
|
||||
|
||||
# regcomp() and regexec() are also names of functions in the old V8
|
||||
# regexp package. To avoid them, we need to find out who has regfree().
|
||||
|
||||
dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
|
||||
dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
|
||||
AC_CHECK_LIB(regex, regfree)
|
||||
AC_SEARCH_LIBS(regfree, rx posix)
|
||||
|
||||
AC_CHECK_FUNCS(fparseln, [
|
||||
AC_MSG_CHECKING(if fparseln seems to work)
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#define _NETBSD_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define CONFTEST "conftest.fparseln"
|
||||
#define COMMENT '#'
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
static const char delim[3] = { '\0', '\0', COMMENT };
|
||||
FILE *fp;
|
||||
char *ptr;
|
||||
fp = fopen(CONFTEST, "w+");
|
||||
if (fp != NULL) {
|
||||
unlink(CONFTEST);
|
||||
ungetc(COMMENT, fp);
|
||||
ptr = fparseln(fp, NULL, NULL, delim,
|
||||
FPARSELN_UNESCALL);
|
||||
fclose(fp);
|
||||
if (ptr == NULL)
|
||||
exit(0);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
]])],
|
||||
[AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(no)
|
||||
AC_DEFINE(BROKEN_FPARSELN, 1,
|
||||
[Define to 1 if your `fparseln' function is broken.])],
|
||||
[AC_MSG_WARN([cross compiling: not checking farseln])]
|
||||
)
|
||||
])
|
||||
|
||||
# Variables substituted via @VARNAME@ in defs.mk.in
|
||||
AC_SUBST(HAVE_PTHREAD_H, $ac_cv_header_pthread_h)
|
||||
|
||||
AC_OUTPUT
|
||||
5
tools/compat/crypto/rmd160.h
Normal file
5
tools/compat/crypto/rmd160.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: rmd160.h,v 1.2 2006/10/27 22:32:45 mrg Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD RMD160 in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../sys/sys/rmd160.h"
|
||||
5
tools/compat/crypto/sha2.h
Normal file
5
tools/compat/crypto/sha2.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: sha2.h,v 1.2 2006/10/27 22:32:45 mrg Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD SHA2 in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../../sys/sys/sha2.h"
|
||||
7
tools/compat/db.h
Normal file
7
tools/compat/db.h
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $NetBSD: db.h,v 1.4 2006/10/16 19:44:23 apb Exp $ */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
#ifndef __BIT_TYPES_DEFINED__
|
||||
#define __BIT_TYPES_DEFINED__
|
||||
#endif
|
||||
#include "../../include/db.h"
|
||||
22
tools/compat/defs.mk.in
Normal file
22
tools/compat/defs.mk.in
Normal file
@@ -0,0 +1,22 @@
|
||||
# $NetBSD: defs.mk.in,v 1.10 2011/08/14 20:22:42 apb Exp $
|
||||
|
||||
COMPATOBJ:= ${.PARSEDIR}
|
||||
HOSTEXEEXT= @EXEEXT@
|
||||
|
||||
HOST_BSHELL= @BSHELL@
|
||||
|
||||
BUILD_OSTYPE!= uname -s
|
||||
|
||||
# Disable use of pre-compiled headers on Darwin.
|
||||
.if ${BUILD_OSTYPE} == "Darwin"
|
||||
HOST_CPPFLAGS+= -no-cpp-precomp
|
||||
.endif
|
||||
|
||||
HOST_CPPFLAGS+= -I${COMPATOBJ} -I${COMPATOBJ}/include \
|
||||
-I${.CURDIR}/../compat -DHAVE_NBTOOL_CONFIG_H=1 \
|
||||
-D_FILE_OFFSET_BITS=64
|
||||
|
||||
DPADD+= ${COMPATOBJ}/libnbcompat.a
|
||||
LDADD+= -L${COMPATOBJ} -lnbcompat @LIBS@
|
||||
|
||||
HAVE_PTHREAD_H= @HAVE_PTHREAD_H@
|
||||
106
tools/compat/fgetln.c
Normal file
106
tools/compat/fgetln.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/* $NetBSD: fgetln.c,v 1.9 2008/04/29 06:53:03 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NBTOOL_CONFIG_H
|
||||
#include "nbtool_config.h"
|
||||
#endif
|
||||
|
||||
#if !HAVE_FGETLN
|
||||
#include <stdlib.h>
|
||||
#ifndef HAVE_NBTOOL_CONFIG_H
|
||||
/* These headers are required, but included from nbtool_config.h */
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
fgetln(FILE *fp, size_t *len)
|
||||
{
|
||||
static char *buf = NULL;
|
||||
static size_t bufsiz = 0;
|
||||
char *ptr;
|
||||
|
||||
|
||||
if (buf == NULL) {
|
||||
bufsiz = BUFSIZ;
|
||||
if ((buf = malloc(bufsiz)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fgets(buf, bufsiz, fp) == NULL)
|
||||
return NULL;
|
||||
|
||||
*len = 0;
|
||||
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
||||
size_t nbufsiz = bufsiz + BUFSIZ;
|
||||
char *nbuf = realloc(buf, nbufsiz);
|
||||
|
||||
if (nbuf == NULL) {
|
||||
int oerrno = errno;
|
||||
free(buf);
|
||||
errno = oerrno;
|
||||
buf = NULL;
|
||||
return NULL;
|
||||
} else
|
||||
buf = nbuf;
|
||||
|
||||
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
|
||||
buf[bufsiz] = '\0';
|
||||
*len = strlen(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
*len = bufsiz;
|
||||
bufsiz = nbufsiz;
|
||||
}
|
||||
|
||||
*len = (ptr - buf) + 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
while ((p = fgetln(stdin, &len)) != NULL) {
|
||||
(void)printf("%zu %s", len, p);
|
||||
free(p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
76
tools/compat/flock.c
Normal file
76
tools/compat/flock.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $NetBSD: flock.c,v 1.6 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* 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:
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Emulate flock() with fcntl(), where available.
|
||||
* Otherwise, don't do locking; just pretend success.
|
||||
*/
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_FLOCK
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int flock(int fd, int op) {
|
||||
int rc = 0;
|
||||
|
||||
#if defined(F_SETLK) && defined(F_SETLKW)
|
||||
struct flock fl = {0};
|
||||
|
||||
switch (op & (LOCK_EX|LOCK_SH|LOCK_UN)) {
|
||||
case LOCK_EX:
|
||||
fl.l_type = F_WRLCK;
|
||||
break;
|
||||
|
||||
case LOCK_SH:
|
||||
fl.l_type = F_RDLCK;
|
||||
break;
|
||||
|
||||
case LOCK_UN:
|
||||
fl.l_type = F_UNLCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fl.l_whence = SEEK_SET;
|
||||
rc = fcntl(fd, op & LOCK_NB ? F_SETLK : F_SETLKW, &fl);
|
||||
|
||||
if (rc && (errno == EAGAIN))
|
||||
errno = EWOULDBLOCK;
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
49
tools/compat/fpurge.c
Normal file
49
tools/compat/fpurge.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/* $NetBSD: fpurge.c,v 1.1 2009/06/16 22:35:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pretend...
|
||||
*/
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_FPURGE
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
void
|
||||
fpurge(FILE *fp)
|
||||
{
|
||||
#if HAVE___FPURGE
|
||||
__fpurge(fp);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
5
tools/compat/fts.h
Normal file
5
tools/compat/fts.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: fts.h,v 1.2 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD fts(3) in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../include/fts.h"
|
||||
107
tools/compat/getline.c
Normal file
107
tools/compat/getline.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/* $NetBSD: getline.c,v 1.1 2011/03/20 20:48:57 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NBTOOL_CONFIG_H
|
||||
#include "nbtool_config.h"
|
||||
#endif
|
||||
|
||||
#if !HAVE_GETLINE
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef HAVE_NBTOOL_CONFIG_H
|
||||
/* These headers are required, but included from nbtool_config.h */
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
ssize_t
|
||||
getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
|
||||
{
|
||||
char *ptr, *eptr;
|
||||
|
||||
|
||||
if (*buf == NULL || *bufsiz == 0) {
|
||||
*bufsiz = BUFSIZ;
|
||||
if ((*buf = malloc(*bufsiz)) == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (ptr = *buf, eptr = *buf + *bufsiz;;) {
|
||||
int c = fgetc(fp);
|
||||
if (c == -1) {
|
||||
if (feof(fp))
|
||||
return ptr == *buf ? -1 : ptr - *buf;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
*ptr++ = c;
|
||||
if (c == delimiter) {
|
||||
*ptr = '\0';
|
||||
return ptr - *buf;
|
||||
}
|
||||
if (ptr + 2 >= eptr) {
|
||||
char *nbuf;
|
||||
size_t nbufsiz = *bufsiz * 2;
|
||||
ssize_t d = ptr - *buf;
|
||||
if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
|
||||
return -1;
|
||||
*buf = nbuf;
|
||||
*bufsiz = nbufsiz;
|
||||
eptr = nbuf + nbufsiz;
|
||||
ptr = nbuf + d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t
|
||||
getline(char **buf, size_t *bufsiz, FILE *fp)
|
||||
{
|
||||
return getdelim(buf, bufsiz, '\n', fp);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *p = NULL;
|
||||
ssize_t len;
|
||||
size_t n = 0;
|
||||
|
||||
while ((len = getline(&p, &n, stdin)) != -1)
|
||||
(void)printf("%zd %s", len, p);
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
57
tools/compat/getmode.c
Normal file
57
tools/compat/getmode.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/* $NetBSD: getmode.c,v 1.8 2008/11/04 23:31:32 dbj Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* 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:
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "nbtool_config.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void *
|
||||
setmode(const char *str)
|
||||
{
|
||||
mode_t *mp = malloc(sizeof(mode_t));
|
||||
|
||||
*mp = strtoul(str, NULL, 8);
|
||||
|
||||
return mp;
|
||||
}
|
||||
|
||||
mode_t
|
||||
getmode(const void *mp, mode_t mode)
|
||||
{
|
||||
mode_t m;
|
||||
|
||||
m = *((const mode_t *)mp);
|
||||
|
||||
mode &= ~ALLPERMS; /* input mode less RWX permissions */
|
||||
m &= ALLPERMS; /* new RWX permissions */
|
||||
|
||||
return m | mode;
|
||||
}
|
||||
5
tools/compat/glob.h
Normal file
5
tools/compat/glob.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: glob.h,v 1.2 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD glob(3) in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../include/glob.h"
|
||||
21
tools/compat/issetugid.c
Normal file
21
tools/compat/issetugid.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/* $NetBSD: issetugid.c,v 1.2 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Ben Harris, 2002
|
||||
* This file is in the Public Domain
|
||||
*/
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_ISSETUGID
|
||||
int
|
||||
issetugid(void)
|
||||
{
|
||||
|
||||
/*
|
||||
* Assume that anything linked against libnbcompat will be installed
|
||||
* without special privileges.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
54
tools/compat/lchflags.c
Normal file
54
tools/compat/lchflags.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $NetBSD: lchflags.c,v 1.4 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Luke Mewburn.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Emulate lchflags(2), checking path with lstat(2) first to ensure that
|
||||
* it's not a symlink, and then call chflags(2) */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_LCHFLAGS && HAVE_STRUCT_STAT_ST_FLAGS
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
lchflags(const char *path, u_long flags)
|
||||
{
|
||||
struct stat psb;
|
||||
|
||||
if (lstat(path, &psb) == -1)
|
||||
return -1;
|
||||
if (S_ISLNK(psb.st_mode)) {
|
||||
return 0;
|
||||
}
|
||||
return (chflags(path, flags));
|
||||
}
|
||||
#endif
|
||||
54
tools/compat/lchmod.c
Normal file
54
tools/compat/lchmod.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $NetBSD: lchmod.c,v 1.4 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Luke Mewburn.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Emulate lchmod(2), checking path with lstat(2) first to ensure that
|
||||
* it's not a symlink, and then call chmod(2) */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_LCHMOD
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
lchmod(const char *path, mode_t mode)
|
||||
{
|
||||
struct stat psb;
|
||||
|
||||
if (lstat(path, &psb) == -1)
|
||||
return -1;
|
||||
if (S_ISLNK(psb.st_mode)) {
|
||||
return 0;
|
||||
}
|
||||
return (chmod(path, mode));
|
||||
}
|
||||
#endif
|
||||
54
tools/compat/lchown.c
Normal file
54
tools/compat/lchown.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $NetBSD: lchown.c,v 1.4 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Luke Mewburn.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Emulate lchown(2), checking path with lstat(2) first to ensure that
|
||||
* it's not a symlink, and then call chown(2) */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_LCHOWN
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
lchown(const char *path, uid_t owner, gid_t group)
|
||||
{
|
||||
struct stat psb;
|
||||
|
||||
if (lstat(path, &psb) == -1)
|
||||
return -1;
|
||||
if (S_ISLNK(psb.st_mode)) {
|
||||
return 0;
|
||||
}
|
||||
return (chown(path, owner, group));
|
||||
}
|
||||
#endif
|
||||
5
tools/compat/md2.h
Normal file
5
tools/compat/md2.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: md2.h,v 1.2 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD MD2 in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../include/md2.h"
|
||||
5
tools/compat/md4.h
Normal file
5
tools/compat/md4.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: md4.h,v 1.3 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD MD4 in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../sys/sys/md4.h"
|
||||
5
tools/compat/md5.h
Normal file
5
tools/compat/md5.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: md5.h,v 1.3 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD MD5 in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../sys/sys/md5.h"
|
||||
3
tools/compat/mpool.h
Normal file
3
tools/compat/mpool.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: mpool.h,v 1.1 2002/01/21 20:04:37 tv Exp $ */
|
||||
|
||||
#include "../../include/mpool.h"
|
||||
14
tools/compat/namespace.h
Normal file
14
tools/compat/namespace.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* $NetBSD: namespace.h,v 1.3 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Mainly empty header to make reachover bits of libc happy.
|
||||
*
|
||||
* Since all reachover bits will include this, it's a good place to pull
|
||||
* in nbtool_config.h.
|
||||
*/
|
||||
#include "nbtool_config.h"
|
||||
|
||||
/* No aliases in reachover-based libc sources. */
|
||||
#undef __indr_reference
|
||||
#undef __weak_alias
|
||||
#undef __warn_references
|
||||
643
tools/compat/nbtool_config.h.in
Normal file
643
tools/compat/nbtool_config.h.in
Normal file
@@ -0,0 +1,643 @@
|
||||
/* nbtool_config.h.in. Generated automatically from configure.ac by autoheader. */
|
||||
|
||||
/* $NetBSD: nbtool_config.h.in,v 1.27 2011/11/03 14:13:53 joerg Exp $ */
|
||||
|
||||
#ifndef __NETBSD_NBTOOL_CONFIG_H__
|
||||
#define __NETBSD_NBTOOL_CONFIG_H__
|
||||
|
||||
/* Define to 1 if your `fparseln' function is broken. */
|
||||
#undef BROKEN_FPARSELN
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define if using `alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define if you have `alloca', as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define if you have the <arpa/nameser.h> header file. */
|
||||
#undef HAVE_ARPA_NAMESER_H
|
||||
|
||||
/* Define if you have the `asnprintf' function. */
|
||||
#undef HAVE_ASNPRINTF
|
||||
|
||||
/* Define if you have the `asprintf' function. */
|
||||
#undef HAVE_ASPRINTF
|
||||
|
||||
/* Define if you have the <assert.h> header file. */
|
||||
#undef HAVE_ASSERT_H
|
||||
|
||||
/* Define if you have the `atoll' function. */
|
||||
#undef HAVE_ATOLL
|
||||
|
||||
/* Define if you have the `basename' function. */
|
||||
#undef HAVE_BASENAME
|
||||
|
||||
/* Define if you have the <ctype.h> header file. */
|
||||
#undef HAVE_CTYPE_H
|
||||
|
||||
/* Define to 1 if you have the declaration of `be16dec', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE16DEC
|
||||
|
||||
/* Define to 1 if you have the declaration of `be16enc', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE16ENC
|
||||
|
||||
/* Define to 1 if you have the declaration of `be16toh', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE16TOH
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32dec', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE32DEC
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32enc', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE32ENC
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32toh', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE32TOH
|
||||
|
||||
/* Define to 1 if you have the declaration of `be64dec', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE64DEC
|
||||
|
||||
/* Define to 1 if you have the declaration of `be64enc', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE64ENC
|
||||
|
||||
/* Define to 1 if you have the declaration of `be64toh', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE64TOH
|
||||
|
||||
/* Define to 1 if you have the declaration of `bswap16', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BSWAP16
|
||||
|
||||
/* Define to 1 if you have the declaration of `bswap32', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BSWAP32
|
||||
|
||||
/* Define to 1 if you have the declaration of `bswap64', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BSWAP64
|
||||
|
||||
/* Define to 1 if you have the declaration of `fstatvfs', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_FSTATVFS
|
||||
|
||||
/* Define to 1 if you have the declaration of `gid_from_group', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_GID_FROM_GROUP
|
||||
|
||||
/* Define to 1 if you have the declaration of `group_from_gid', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_GROUP_FROM_GID
|
||||
|
||||
/* Define to 1 if you have the declaration of `htobe16', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_HTOBE16
|
||||
|
||||
/* Define to 1 if you have the declaration of `htobe32', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_HTOBE32
|
||||
|
||||
/* Define to 1 if you have the declaration of `htobe64', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_HTOBE64
|
||||
|
||||
/* Define to 1 if you have the declaration of `htole16', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_HTOLE16
|
||||
|
||||
/* Define to 1 if you have the declaration of `htole32', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_HTOLE32
|
||||
|
||||
/* Define to 1 if you have the declaration of `htole64', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_HTOLE64
|
||||
|
||||
/* Define to 1 if you have the declaration of `lchflags', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LCHFLAGS
|
||||
|
||||
/* Define to 1 if you have the declaration of `lchmod', and to 0 if you don't.
|
||||
*/
|
||||
#undef HAVE_DECL_LCHMOD
|
||||
|
||||
/* Define to 1 if you have the declaration of `lchown', and to 0 if you don't.
|
||||
*/
|
||||
#undef HAVE_DECL_LCHOWN
|
||||
|
||||
/* Define to 1 if you have the declaration of `le16dec', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE16DEC
|
||||
|
||||
/* Define to 1 if you have the declaration of `le16enc', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE16ENC
|
||||
|
||||
/* Define to 1 if you have the declaration of `le16toh', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE16TOH
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32dec', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE32DEC
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32enc', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE32ENC
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32toh', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE32TOH
|
||||
|
||||
/* Define to 1 if you have the declaration of `le64dec', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE64DEC
|
||||
|
||||
/* Define to 1 if you have the declaration of `le64enc', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE64ENC
|
||||
|
||||
/* Define to 1 if you have the declaration of `le64toh', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_LE64TOH
|
||||
|
||||
/* 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 `pwcache_groupdb', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_PWCACHE_GROUPDB
|
||||
|
||||
/* Define to 1 if you have the declaration of `pwcache_userdb', and to 0 if
|
||||
you don't. */
|
||||
#undef HAVE_DECL_PWCACHE_USERDB
|
||||
|
||||
/* Define to 1 if you have the declaration of `setgroupent', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_SETGROUPENT
|
||||
|
||||
/* Define to 1 if you have the declaration of `setpassent', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_SETPASSENT
|
||||
|
||||
/* Define to 1 if you have the declaration of `strndup', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_STRNDUP
|
||||
|
||||
/* Define to 1 if you have the declaration of `strsuftoll', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_STRSUFTOLL
|
||||
|
||||
/* Define to 1 if you have the declaration of `sys_signame', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_SYS_SIGNAME
|
||||
|
||||
/* Define to 1 if you have the declaration of `uid_from_user', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_UID_FROM_USER
|
||||
|
||||
/* Define to 1 if you have the declaration of `user_from_uid', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_USER_FROM_UID
|
||||
|
||||
/* Define if you have the `devname' function. */
|
||||
#undef HAVE_DEVNAME
|
||||
|
||||
/* Define if you have the <dirent.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define if you have the `dirfd' function. */
|
||||
#undef HAVE_DIRFD
|
||||
|
||||
/* Define if you have the `dirname' function. */
|
||||
#undef HAVE_DIRNAME
|
||||
|
||||
/* Define if `dd_fd' is member of `DIR'. */
|
||||
#undef HAVE_DIR_DD_FD
|
||||
|
||||
/* Define if `__dd_fd' is member of `DIR'. */
|
||||
#undef HAVE_DIR___DD_FD
|
||||
|
||||
/* Define if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
/* Define if you have the <err.h> header file. */
|
||||
#undef HAVE_ERR_H
|
||||
|
||||
/* Define if you have the `esetfunc' function. */
|
||||
#undef HAVE_ESETFUNC
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <features.h> header file. */
|
||||
#undef HAVE_FEATURES_H
|
||||
|
||||
/* Define if you have the `fgetln' function. */
|
||||
#undef HAVE_FGETLN
|
||||
|
||||
/* Define if you have the `flock' function. */
|
||||
#undef HAVE_FLOCK
|
||||
|
||||
/* Define if you have the `fparseln' function. */
|
||||
#undef HAVE_FPARSELN
|
||||
|
||||
/* Define if you have the `fpurge' function. */
|
||||
#undef HAVE_FPURGE
|
||||
|
||||
/* Define if you have the `futimes' function. */
|
||||
#undef HAVE_FUTIMES
|
||||
|
||||
/* Define if you have the `getline' function. */
|
||||
#undef HAVE_GETLINE
|
||||
|
||||
/* Define if you have the `getopt' function. */
|
||||
#undef HAVE_GETOPT
|
||||
|
||||
/* Define if you have the <getopt.h> header file. */
|
||||
#undef HAVE_GETOPT_H
|
||||
|
||||
/* Define if you have the `getopt_long' function. */
|
||||
#undef HAVE_GETOPT_LONG
|
||||
|
||||
/* Define if you have the `gid_from_group' function. */
|
||||
#undef HAVE_GID_FROM_GROUP
|
||||
|
||||
/* Define if you have the `group_from_gid' function. */
|
||||
#undef HAVE_GROUP_FROM_GID
|
||||
|
||||
/* Define if you have the <grp.h> header file. */
|
||||
#undef HAVE_GRP_H
|
||||
|
||||
/* Define if you have the `heapsort' function. */
|
||||
#undef HAVE_HEAPSORT
|
||||
|
||||
/* Define if the system has the type `id_t'. */
|
||||
#undef HAVE_ID_T
|
||||
|
||||
/* Define if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define if you have the `isblank' function. */
|
||||
#undef HAVE_ISBLANK
|
||||
|
||||
/* Define if you have the `issetugid' function. */
|
||||
#undef HAVE_ISSETUGID
|
||||
|
||||
/* Define if you have the `lchflags' function. */
|
||||
#undef HAVE_LCHFLAGS
|
||||
|
||||
/* Define if you have the `lchmod' function. */
|
||||
#undef HAVE_LCHMOD
|
||||
|
||||
/* Define if you have the `lchown' function. */
|
||||
#undef HAVE_LCHOWN
|
||||
|
||||
/* Define if you have the <libgen.h> header file. */
|
||||
#undef HAVE_LIBGEN_H
|
||||
|
||||
/* Define if you have the `regex' library (-lregex). */
|
||||
#undef HAVE_LIBREGEX
|
||||
|
||||
/* Define if you have the `z' library (-lz). */
|
||||
#undef HAVE_LIBZ
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define if the system has the type `long long'. */
|
||||
#undef HAVE_LONG_LONG
|
||||
|
||||
/* Define if you have the `lutimes' function. */
|
||||
#undef HAVE_LUTIMES
|
||||
|
||||
/* Define if you have the <machine/bswap.h> header file. */
|
||||
#undef HAVE_MACHINE_BSWAP_H
|
||||
|
||||
/* Define if you have the <machine/endian.h> header file. */
|
||||
#undef HAVE_MACHINE_ENDIAN_H
|
||||
|
||||
/* Define if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define if you have the `mkdtemp' function. */
|
||||
#undef HAVE_MKDTEMP
|
||||
|
||||
/* Define if you have the `mkstemp' function. */
|
||||
#undef HAVE_MKSTEMP
|
||||
|
||||
/* Define if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define if you have the <netconfig.h> header file. */
|
||||
#undef HAVE_NETCONFIG_H
|
||||
|
||||
/* Define if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define if you have the <paths.h> header file. */
|
||||
#undef HAVE_PATHS_H
|
||||
|
||||
/* Define if you have the `poll' function. */
|
||||
#undef HAVE_POLL
|
||||
|
||||
/* Define if you have the `pread' function. */
|
||||
#undef HAVE_PREAD
|
||||
|
||||
/* Define if you have the <pthread.h> header file. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
/* Define if you have the `putc_unlocked' function. */
|
||||
#undef HAVE_PUTC_UNLOCKED
|
||||
|
||||
/* Define if you have the `pwcache_groupdb' function. */
|
||||
#undef HAVE_PWCACHE_GROUPDB
|
||||
|
||||
/* Define if you have the `pwcache_userdb' function. */
|
||||
#undef HAVE_PWCACHE_USERDB
|
||||
|
||||
/* Define if you have the <pwd.h> header file. */
|
||||
#undef HAVE_PWD_H
|
||||
|
||||
/* Define if you have the `pwrite' function. */
|
||||
#undef HAVE_PWRITE
|
||||
|
||||
/* Define if you have the `raise_default_signal' function. */
|
||||
#undef HAVE_RAISE_DEFAULT_SIGNAL
|
||||
|
||||
/* Define if you have the `random' function. */
|
||||
#undef HAVE_RANDOM
|
||||
|
||||
/* Define if you have the <resolv.h> header file. */
|
||||
#undef HAVE_RESOLV_H
|
||||
|
||||
/* Define if you have the <rpc/types.h> header file. */
|
||||
#undef HAVE_RPC_TYPES_H
|
||||
|
||||
/* Define if you have the `setenv' function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define if you have the `setgroupent' function. */
|
||||
#undef HAVE_SETGROUPENT
|
||||
|
||||
/* Define if you have the `setpassent' function. */
|
||||
#undef HAVE_SETPASSENT
|
||||
|
||||
/* Define if you have the `setprogname' function. */
|
||||
#undef HAVE_SETPROGNAME
|
||||
|
||||
/* Define if you have the <signal.h> header file. */
|
||||
#undef HAVE_SIGNAL_H
|
||||
|
||||
/* Define if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define if you have the socklen_t type. */
|
||||
#undef HAVE_SOCKLEN_T
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#undef HAVE_STDARG_H
|
||||
|
||||
/* Define if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
|
||||
/* Define if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define if you have the <stdio.h> header file. */
|
||||
#undef HAVE_STDIO_H
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define if you have the `strlcat' function. */
|
||||
#undef HAVE_STRLCAT
|
||||
|
||||
/* Define if you have the `strlcpy' function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
/* Define if you have the `strmode' function. */
|
||||
#undef HAVE_STRMODE
|
||||
|
||||
/* Define if you have the `strndup' function. */
|
||||
#undef HAVE_STRNDUP
|
||||
|
||||
/* Define if you have the `strsep' function. */
|
||||
#undef HAVE_STRSEP
|
||||
|
||||
/* Define if you have the `strsuftoll' function. */
|
||||
#undef HAVE_STRSUFTOLL
|
||||
|
||||
/* Define if you have the `strtoll' function. */
|
||||
#undef HAVE_STRTOLL
|
||||
|
||||
/* Define if `d_namlen' is member of `struct dirent'. */
|
||||
#undef HAVE_STRUCT_DIRENT_D_NAMLEN
|
||||
|
||||
/* Define if `f_iosize' is member of `struct statvfs'. */
|
||||
#undef HAVE_STRUCT_STATVFS_F_IOSIZE
|
||||
|
||||
/* Define if `st_atim' is member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_ATIM
|
||||
|
||||
/* Define if `st_birthtime' is member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_BIRTHTIME
|
||||
|
||||
/* Define if `st_birthtimensec' is member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
|
||||
|
||||
/* Define if `st_flags' is member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_FLAGS
|
||||
|
||||
/* Define if `st_gen' is member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_GEN
|
||||
|
||||
/* Define if `st_mtimensec' is member of `struct stat'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_MTIMENSEC
|
||||
|
||||
/* Define if you have the <sys/bswap.h> header file. */
|
||||
#undef HAVE_SYS_BSWAP_H
|
||||
|
||||
/* Define if you have the <sys/cdefs.h> header file. */
|
||||
#undef HAVE_SYS_CDEFS_H
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define if you have the <sys/endian.h> header file. */
|
||||
#undef HAVE_SYS_ENDIAN_H
|
||||
|
||||
/* Define if you have the <sys/featuretest.h> header file. */
|
||||
#undef HAVE_SYS_FEATURETEST_H
|
||||
|
||||
/* Define if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
/* Define if you have the <sys/mtio.h> header file. */
|
||||
#undef HAVE_SYS_MTIO_H
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define if you have the <sys/poll.h> header file. */
|
||||
#undef HAVE_SYS_POLL_H
|
||||
|
||||
/* Define if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define if you have the <sys/syslimits.h> header file. */
|
||||
#undef HAVE_SYS_SYSLIMITS_H
|
||||
|
||||
/* Define if you have the <sys/sysmacros.h> header file. */
|
||||
#undef HAVE_SYS_SYSMACROS_H
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define if you have the <sys/utsname.h> header file. */
|
||||
#undef HAVE_SYS_UTSNAME_H
|
||||
|
||||
/* Define if you have the <sys/wait.h> header file. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if you have the <termios.h> header file. */
|
||||
#undef HAVE_TERMIOS_H
|
||||
|
||||
/* Define if you have the `uid_from_user' function. */
|
||||
#undef HAVE_UID_FROM_USER
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the `user_from_uid' function. */
|
||||
#undef HAVE_USER_FROM_UID
|
||||
|
||||
/* Define if you have the <util.h> header file. */
|
||||
#undef HAVE_UTIL_H
|
||||
|
||||
/* Define if the system has the type `u_char'. */
|
||||
#undef HAVE_U_CHAR
|
||||
|
||||
/* Define if the system has the type `u_int'. */
|
||||
#undef HAVE_U_INT
|
||||
|
||||
/* Define if the system has the type `u_long'. */
|
||||
#undef HAVE_U_LONG
|
||||
|
||||
/* Define if the system has the type `u_quad_t'. */
|
||||
#undef HAVE_U_QUAD_T
|
||||
|
||||
/* Define if the system has the type `u_short'. */
|
||||
#undef HAVE_U_SHORT
|
||||
|
||||
/* Define if you have the `vasnprintf' function. */
|
||||
#undef HAVE_VASNPRINTF
|
||||
|
||||
/* Define if you have the `vasprintf' function. */
|
||||
#undef HAVE_VASPRINTF
|
||||
|
||||
/* Define if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define if you have the `__fpurge' function. */
|
||||
#undef HAVE___FPURGE
|
||||
|
||||
/* Path to sh(1). */
|
||||
#undef PATH_BSHELL
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if your processor stores words with the most significant byte first
|
||||
(like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#undef WORDS_BIGENDIAN
|
||||
|
||||
/* Define for NetBSD headers. */
|
||||
#undef _POSIX_C_SOURCE
|
||||
|
||||
/* Define for NetBSD headers. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define for NetBSD headers. */
|
||||
#undef _XOPEN_SOURCE
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define if you have uint16_t, but not u_int16_t. */
|
||||
#undef u_int16_t
|
||||
|
||||
/* Define if you have uint32_t, but not u_int32_t. */
|
||||
#undef u_int32_t
|
||||
|
||||
/* Define if you have uint64_t, but not u_int64_t. */
|
||||
#undef u_int64_t
|
||||
|
||||
/* Define if you have uint8_t, but not u_int8_t. */
|
||||
#undef u_int8_t
|
||||
|
||||
/* Define if you have u_int16_t, but not uint16_t. */
|
||||
#undef uint16_t
|
||||
|
||||
/* Define if you have u_int32_t, but not uint32_t. */
|
||||
#undef uint32_t
|
||||
|
||||
/* Define if you have u_int64_t, but not uint64_t. */
|
||||
#undef uint64_t
|
||||
|
||||
/* Define if you have u_int8_t, but not uint8_t. */
|
||||
#undef uint8_t
|
||||
|
||||
#include "compat_defs.h"
|
||||
#endif /* !__NETBSD_NBTOOL_CONFIG_H__ */
|
||||
7
tools/compat/ndbm.h
Normal file
7
tools/compat/ndbm.h
Normal file
@@ -0,0 +1,7 @@
|
||||
/* $NetBSD: ndbm.h,v 1.1 2010/02/03 15:34:44 roy Exp $ */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
#ifndef DBM_SUFFIX
|
||||
#define DBM_SUFFIX ".db"
|
||||
#endif
|
||||
#include "../../include/ndbm.h"
|
||||
5
tools/compat/nl_types.h
Normal file
5
tools/compat/nl_types.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: nl_types.h,v 1.1 2002/01/29 10:20:32 tv Exp $ */
|
||||
|
||||
#ifdef _NLS_PRIVATE
|
||||
#include "../../include/nl_types.h"
|
||||
#endif
|
||||
55
tools/compat/pread.c
Normal file
55
tools/compat/pread.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $NetBSD: pread.c,v 1.4 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* 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:
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Emulate pread() with lseek()/read()/lseek(). Not thread-safe, of course. */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_PREAD
|
||||
#include <unistd.h>
|
||||
|
||||
ssize_t pread(int d, void *buf, size_t nbytes, off_t offset) {
|
||||
off_t oldoff = lseek(d, offset, SEEK_SET);
|
||||
int olderrno;
|
||||
ssize_t nr;
|
||||
|
||||
if (oldoff < 0)
|
||||
return -1;
|
||||
|
||||
nr = read(d, buf, nbytes);
|
||||
|
||||
olderrno = errno;
|
||||
lseek(d, oldoff, SEEK_SET);
|
||||
errno = olderrno;
|
||||
|
||||
return nr;
|
||||
}
|
||||
#endif
|
||||
47
tools/compat/putc_unlocked.c
Normal file
47
tools/compat/putc_unlocked.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* $NetBSD: putc_unlocked.c,v 1.4 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Emulate putc_unlocked(). */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_PUTC_UNLOCKED
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef putc_unlocked
|
||||
int
|
||||
putc_unlocked(int c, FILE *stream)
|
||||
{
|
||||
|
||||
putc(c, stream);
|
||||
}
|
||||
#endif /* putc_unlocked */
|
||||
#endif
|
||||
55
tools/compat/pwrite.c
Normal file
55
tools/compat/pwrite.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $NetBSD: pwrite.c,v 1.4 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* 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:
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Emulate pwrite() with lseek()/write()/lseek(). Not thread-safe, of course. */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_PWRITE
|
||||
#include <unistd.h>
|
||||
|
||||
ssize_t pwrite(int d, const void *buf, size_t nbytes, off_t offset) {
|
||||
off_t oldoff = lseek(d, offset, SEEK_SET);
|
||||
int olderrno;
|
||||
ssize_t nw;
|
||||
|
||||
if (oldoff < 0)
|
||||
return -1;
|
||||
|
||||
nw = write(d, buf, nbytes);
|
||||
|
||||
olderrno = errno;
|
||||
lseek(d, oldoff, SEEK_SET);
|
||||
errno = olderrno;
|
||||
|
||||
return nw;
|
||||
}
|
||||
#endif
|
||||
50
tools/compat/setenv.c
Normal file
50
tools/compat/setenv.c
Normal file
@@ -0,0 +1,50 @@
|
||||
/* $NetBSD: setenv.c,v 1.4 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* 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:
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Emulate setenv() with getenv()/malloc()/putenv(). */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_SETENV
|
||||
int setenv(const char *name, const char *value, int overwrite) {
|
||||
char *buf;
|
||||
|
||||
if (!overwrite && getenv(name))
|
||||
return 0;
|
||||
|
||||
/* Include sizes plus '=' and trailing null. */
|
||||
if (!(buf = malloc(strlen(name) + strlen(value) + 2)))
|
||||
return -1;
|
||||
|
||||
sprintf(buf, "%s=%s", name, value);
|
||||
putenv(buf);
|
||||
}
|
||||
#endif
|
||||
12
tools/compat/setgroupent.c
Normal file
12
tools/compat/setgroupent.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $NetBSD: setgroupent.c,v 1.4 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_SETGROUPENT || !HAVE_DECL_SETGROUPENT
|
||||
#include <grp.h>
|
||||
|
||||
int setgroupent(int stayopen) {
|
||||
setgrent();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
12
tools/compat/setpassent.c
Normal file
12
tools/compat/setpassent.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/* $NetBSD: setpassent.c,v 1.4 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_SETPASSENT || !HAVE_DECL_SETPASSENT
|
||||
#include <pwd.h>
|
||||
|
||||
int setpassent(int stayopen) {
|
||||
setpwent();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
54
tools/compat/setprogname.c
Normal file
54
tools/compat/setprogname.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $NetBSD: setprogname.c,v 1.5 2008/04/28 20:24:12 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* 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:
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "nbtool_config.h"
|
||||
|
||||
#if !HAVE_SETPROGNAME
|
||||
#include <string.h>
|
||||
|
||||
static const char *__progname = "command line";
|
||||
|
||||
void
|
||||
setprogname(const char *progname)
|
||||
{
|
||||
__progname = strrchr(progname, '/');
|
||||
if (__progname == NULL)
|
||||
__progname = progname;
|
||||
else
|
||||
__progname++;
|
||||
}
|
||||
|
||||
const char *
|
||||
getprogname(void)
|
||||
{
|
||||
return __progname;
|
||||
}
|
||||
#endif
|
||||
663
tools/compat/snprintf.c
Normal file
663
tools/compat/snprintf.c
Normal file
@@ -0,0 +1,663 @@
|
||||
/*
|
||||
* Copyright (c) 1995-2001 Kungliga Tekniska Högskolan
|
||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||
* 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 Institute 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 INSTITUTE 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 INSTITUTE 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.
|
||||
*/
|
||||
|
||||
/* From heimdal lib/roken/snprintf.c. */
|
||||
|
||||
#if HAVE_NBTOOL_CONFIG_H
|
||||
#include "nbtool_config.h"
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
RCSID("$Id: snprintf.c,v 1.3 2003/10/27 00:12:43 lukem Exp $");
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#if 0
|
||||
#include <roken.h>
|
||||
#endif
|
||||
|
||||
#undef min
|
||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||
#undef max
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
|
||||
enum format_flags {
|
||||
minus_flag = 1,
|
||||
plus_flag = 2,
|
||||
space_flag = 4,
|
||||
alternate_flag = 8,
|
||||
zero_flag = 16
|
||||
};
|
||||
|
||||
/*
|
||||
* Common state
|
||||
*/
|
||||
|
||||
struct state {
|
||||
unsigned char *str;
|
||||
unsigned char *s;
|
||||
unsigned char *theend;
|
||||
size_t sz;
|
||||
size_t max_sz;
|
||||
void (*append_char)(struct state *, unsigned char);
|
||||
/* XXX - methods */
|
||||
};
|
||||
|
||||
#if TEST_SNPRINTF
|
||||
#include "snprintf-test.h"
|
||||
#endif /* TEST_SNPRINTF */
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF) || defined(TEST_SNPRINTF)
|
||||
static int
|
||||
sn_reserve (struct state *state, size_t n)
|
||||
{
|
||||
return state->s + n > state->theend;
|
||||
}
|
||||
|
||||
static void
|
||||
sn_append_char (struct state *state, unsigned char c)
|
||||
{
|
||||
if (!sn_reserve (state, 1))
|
||||
*state->s++ = c;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
as_reserve (struct state *state, size_t n)
|
||||
{
|
||||
if (state->s + n > state->theend) {
|
||||
int off = state->s - state->str;
|
||||
unsigned char *tmp;
|
||||
|
||||
if (state->max_sz && state->sz >= state->max_sz)
|
||||
return 1;
|
||||
|
||||
state->sz = max(state->sz * 2, state->sz + n);
|
||||
if (state->max_sz)
|
||||
state->sz = min(state->sz, state->max_sz);
|
||||
tmp = realloc (state->str, state->sz);
|
||||
if (tmp == NULL)
|
||||
return 1;
|
||||
state->str = tmp;
|
||||
state->s = state->str + off;
|
||||
state->theend = state->str + state->sz - 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
as_append_char (struct state *state, unsigned char c)
|
||||
{
|
||||
if(!as_reserve (state, 1))
|
||||
*state->s++ = c;
|
||||
}
|
||||
|
||||
/* longest integer types */
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
typedef unsigned long long u_longest;
|
||||
typedef long long longest;
|
||||
#else
|
||||
typedef unsigned long u_longest;
|
||||
typedef long longest;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* is # supposed to do anything?
|
||||
*/
|
||||
|
||||
static int
|
||||
use_alternative (int flags, u_longest num, unsigned base)
|
||||
{
|
||||
return flags & alternate_flag && (base == 16 || base == 8) && num != 0;
|
||||
}
|
||||
|
||||
static int
|
||||
append_number(struct state *state,
|
||||
u_longest num, unsigned base, char *rep,
|
||||
int width, int prec, int flags, int minusp)
|
||||
{
|
||||
int len = 0;
|
||||
int i;
|
||||
u_longest n = num;
|
||||
|
||||
/* given precision, ignore zero flag */
|
||||
if(prec != -1)
|
||||
flags &= ~zero_flag;
|
||||
else
|
||||
prec = 1;
|
||||
/* zero value with zero precision -> "" */
|
||||
if(prec == 0 && n == 0)
|
||||
return 0;
|
||||
do{
|
||||
(*state->append_char)(state, rep[n % base]);
|
||||
++len;
|
||||
n /= base;
|
||||
} while(n);
|
||||
prec -= len;
|
||||
/* pad with prec zeros */
|
||||
while(prec-- > 0){
|
||||
(*state->append_char)(state, '0');
|
||||
++len;
|
||||
}
|
||||
/* add length of alternate prefix (added later) to len */
|
||||
if(use_alternative(flags, num, base))
|
||||
len += base / 8;
|
||||
/* pad with zeros */
|
||||
if(flags & zero_flag){
|
||||
width -= len;
|
||||
if(minusp || (flags & space_flag) || (flags & plus_flag))
|
||||
width--;
|
||||
while(width-- > 0){
|
||||
(*state->append_char)(state, '0');
|
||||
len++;
|
||||
}
|
||||
}
|
||||
/* add alternate prefix */
|
||||
if(use_alternative(flags, num, base)){
|
||||
if(base == 16)
|
||||
(*state->append_char)(state, rep[10] + 23); /* XXX */
|
||||
(*state->append_char)(state, '0');
|
||||
}
|
||||
/* add sign */
|
||||
if(minusp){
|
||||
(*state->append_char)(state, '-');
|
||||
++len;
|
||||
} else if(flags & plus_flag) {
|
||||
(*state->append_char)(state, '+');
|
||||
++len;
|
||||
} else if(flags & space_flag) {
|
||||
(*state->append_char)(state, ' ');
|
||||
++len;
|
||||
}
|
||||
if(flags & minus_flag)
|
||||
/* swap before padding with spaces */
|
||||
for(i = 0; i < len / 2; i++){
|
||||
char c = state->s[-i-1];
|
||||
state->s[-i-1] = state->s[-len+i];
|
||||
state->s[-len+i] = c;
|
||||
}
|
||||
width -= len;
|
||||
while(width-- > 0){
|
||||
(*state->append_char)(state, ' ');
|
||||
++len;
|
||||
}
|
||||
if(!(flags & minus_flag))
|
||||
/* swap after padding with spaces */
|
||||
for(i = 0; i < len / 2; i++){
|
||||
char c = state->s[-i-1];
|
||||
state->s[-i-1] = state->s[-len+i];
|
||||
state->s[-len+i] = c;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
* return length
|
||||
*/
|
||||
|
||||
static int
|
||||
append_string (struct state *state,
|
||||
const unsigned char *arg,
|
||||
int width,
|
||||
int prec,
|
||||
int flags)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
if(arg == NULL)
|
||||
arg = (const unsigned char*)"(null)";
|
||||
|
||||
if(prec != -1)
|
||||
width -= prec;
|
||||
else
|
||||
width -= strlen((const char *)arg);
|
||||
if(!(flags & minus_flag))
|
||||
while(width-- > 0) {
|
||||
(*state->append_char) (state, ' ');
|
||||
++len;
|
||||
}
|
||||
if (prec != -1) {
|
||||
while (*arg && prec--) {
|
||||
(*state->append_char) (state, *arg++);
|
||||
++len;
|
||||
}
|
||||
} else {
|
||||
while (*arg) {
|
||||
(*state->append_char) (state, *arg++);
|
||||
++len;
|
||||
}
|
||||
}
|
||||
if(flags & minus_flag)
|
||||
while(width-- > 0) {
|
||||
(*state->append_char) (state, ' ');
|
||||
++len;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
append_char(struct state *state,
|
||||
unsigned char arg,
|
||||
int width,
|
||||
int flags)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
while(!(flags & minus_flag) && --width > 0) {
|
||||
(*state->append_char) (state, ' ') ;
|
||||
++len;
|
||||
}
|
||||
(*state->append_char) (state, arg);
|
||||
++len;
|
||||
while((flags & minus_flag) && --width > 0) {
|
||||
(*state->append_char) (state, ' ');
|
||||
++len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This can't be made into a function...
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
|
||||
#define PARSE_INT_FORMAT(res, arg, unsig) \
|
||||
if (long_long_flag) \
|
||||
res = (unsig long long)va_arg(arg, unsig long long); \
|
||||
else if (long_flag) \
|
||||
res = (unsig long)va_arg(arg, unsig long); \
|
||||
else if (short_flag) \
|
||||
res = (unsig short)va_arg(arg, unsig int); \
|
||||
else \
|
||||
res = (unsig int)va_arg(arg, unsig int)
|
||||
|
||||
#else
|
||||
|
||||
#define PARSE_INT_FORMAT(res, arg, unsig) \
|
||||
if (long_flag) \
|
||||
res = (unsig long)va_arg(arg, unsig long); \
|
||||
else if (short_flag) \
|
||||
res = (unsig short)va_arg(arg, unsig int); \
|
||||
else \
|
||||
res = (unsig int)va_arg(arg, unsig int)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* zyxprintf - return length, as snprintf
|
||||
*/
|
||||
|
||||
static int
|
||||
xyzprintf (struct state *state, const char *char_format, va_list ap)
|
||||
{
|
||||
const unsigned char *format = (const unsigned char *)char_format;
|
||||
unsigned char c;
|
||||
int len = 0;
|
||||
|
||||
while((c = *format++)) {
|
||||
if (c == '%') {
|
||||
int flags = 0;
|
||||
int width = 0;
|
||||
int prec = -1;
|
||||
int long_long_flag = 0;
|
||||
int long_flag = 0;
|
||||
int short_flag = 0;
|
||||
|
||||
/* flags */
|
||||
while((c = *format++)){
|
||||
if(c == '-')
|
||||
flags |= minus_flag;
|
||||
else if(c == '+')
|
||||
flags |= plus_flag;
|
||||
else if(c == ' ')
|
||||
flags |= space_flag;
|
||||
else if(c == '#')
|
||||
flags |= alternate_flag;
|
||||
else if(c == '0')
|
||||
flags |= zero_flag;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if((flags & space_flag) && (flags & plus_flag))
|
||||
flags ^= space_flag;
|
||||
|
||||
if((flags & minus_flag) && (flags & zero_flag))
|
||||
flags ^= zero_flag;
|
||||
|
||||
/* width */
|
||||
if (isdigit(c))
|
||||
do {
|
||||
width = width * 10 + c - '0';
|
||||
c = *format++;
|
||||
} while(isdigit(c));
|
||||
else if(c == '*') {
|
||||
width = va_arg(ap, int);
|
||||
c = *format++;
|
||||
}
|
||||
|
||||
/* precision */
|
||||
if (c == '.') {
|
||||
prec = 0;
|
||||
c = *format++;
|
||||
if (isdigit(c))
|
||||
do {
|
||||
prec = prec * 10 + c - '0';
|
||||
c = *format++;
|
||||
} while(isdigit(c));
|
||||
else if (c == '*') {
|
||||
prec = va_arg(ap, int);
|
||||
c = *format++;
|
||||
}
|
||||
}
|
||||
|
||||
/* size */
|
||||
|
||||
if (c == 'h') {
|
||||
short_flag = 1;
|
||||
c = *format++;
|
||||
} else if (c == 'l') {
|
||||
long_flag = 1;
|
||||
c = *format++;
|
||||
if (c == 'l') {
|
||||
long_long_flag = 1;
|
||||
c = *format++;
|
||||
}
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case 'c' :
|
||||
append_char(state, va_arg(ap, int), width, flags);
|
||||
++len;
|
||||
break;
|
||||
case 's' :
|
||||
len += append_string(state,
|
||||
va_arg(ap, unsigned char*),
|
||||
width,
|
||||
prec,
|
||||
flags);
|
||||
break;
|
||||
case 'd' :
|
||||
case 'i' : {
|
||||
longest arg;
|
||||
u_longest num;
|
||||
int minusp = 0;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, signed);
|
||||
|
||||
if (arg < 0) {
|
||||
minusp = 1;
|
||||
num = -arg;
|
||||
} else
|
||||
num = arg;
|
||||
|
||||
len += append_number (state, num, 10, "0123456789",
|
||||
width, prec, flags, minusp);
|
||||
break;
|
||||
}
|
||||
case 'u' : {
|
||||
u_longest arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
len += append_number (state, arg, 10, "0123456789",
|
||||
width, prec, flags, 0);
|
||||
break;
|
||||
}
|
||||
case 'o' : {
|
||||
u_longest arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
len += append_number (state, arg, 010, "01234567",
|
||||
width, prec, flags, 0);
|
||||
break;
|
||||
}
|
||||
case 'x' : {
|
||||
u_longest arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
len += append_number (state, arg, 0x10, "0123456789abcdef",
|
||||
width, prec, flags, 0);
|
||||
break;
|
||||
}
|
||||
case 'X' :{
|
||||
u_longest arg;
|
||||
|
||||
PARSE_INT_FORMAT(arg, ap, unsigned);
|
||||
|
||||
len += append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||
width, prec, flags, 0);
|
||||
break;
|
||||
}
|
||||
case 'p' : {
|
||||
unsigned long arg = (unsigned long)va_arg(ap, void*);
|
||||
|
||||
len += append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||
width, prec, flags, 0);
|
||||
break;
|
||||
}
|
||||
case 'n' : {
|
||||
int *arg = va_arg(ap, int*);
|
||||
*arg = state->s - state->str;
|
||||
break;
|
||||
}
|
||||
case '\0' :
|
||||
--format;
|
||||
/* FALLTHROUGH */
|
||||
case '%' :
|
||||
(*state->append_char)(state, c);
|
||||
++len;
|
||||
break;
|
||||
default :
|
||||
(*state->append_char)(state, '%');
|
||||
(*state->append_char)(state, c);
|
||||
len += 2;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
(*state->append_char) (state, c);
|
||||
++len;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
#if !defined(HAVE_SNPRINTF) || defined(TEST_SNPRINTF)
|
||||
int
|
||||
snprintf (char *str, size_t sz, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
va_start(args, format);
|
||||
ret = vsnprintf (str, sz, format, args);
|
||||
va_end(args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
|
||||
tmp = malloc (sz);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
va_start(args, format);
|
||||
ret2 = vsprintf (tmp, format, args);
|
||||
va_end(args);
|
||||
if (ret != ret2 || strcmp(str, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_ASPRINTF) || defined(TEST_SNPRINTF)
|
||||
int
|
||||
asprintf (char **ret, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int val;
|
||||
|
||||
va_start(args, format);
|
||||
val = vasprintf (ret, format, args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
tmp = malloc (val + 1);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
ret2 = vsprintf (tmp, format, args);
|
||||
if (val != ret2 || strcmp(*ret, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_ASNPRINTF) || defined(TEST_SNPRINTF)
|
||||
int
|
||||
asnprintf (char **ret, size_t max_sz, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
int val;
|
||||
|
||||
va_start(args, format);
|
||||
val = vasnprintf (ret, max_sz, format, args);
|
||||
|
||||
#ifdef PARANOIA
|
||||
{
|
||||
int ret2;
|
||||
char *tmp;
|
||||
tmp = malloc (val + 1);
|
||||
if (tmp == NULL)
|
||||
abort ();
|
||||
|
||||
ret2 = vsprintf (tmp, format, args);
|
||||
if (val != ret2 || strcmp(*ret, tmp))
|
||||
abort ();
|
||||
free (tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_VASPRINTF) || defined(TEST_SNPRINTF)
|
||||
int
|
||||
vasprintf (char **ret, const char *format, va_list args)
|
||||
{
|
||||
return vasnprintf (ret, 0, format, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(HAVE_VASNPRINTF) || defined(TEST_SNPRINTF)
|
||||
int
|
||||
vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
||||
{
|
||||
int st;
|
||||
struct state state;
|
||||
|
||||
state.max_sz = max_sz;
|
||||
state.sz = 1;
|
||||
state.str = malloc(state.sz);
|
||||
if (state.str == NULL) {
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
}
|
||||
state.s = state.str;
|
||||
state.theend = state.s + state.sz - 1;
|
||||
state.append_char = as_append_char;
|
||||
|
||||
st = xyzprintf (&state, format, args);
|
||||
if (st > state.sz) {
|
||||
free (state.str);
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
} else {
|
||||
char *tmp;
|
||||
|
||||
*state.s = '\0';
|
||||
tmp = realloc (state.str, st+1);
|
||||
if (tmp == NULL) {
|
||||
free (state.str);
|
||||
*ret = NULL;
|
||||
return -1;
|
||||
}
|
||||
*ret = tmp;
|
||||
return st;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF) || defined(TEST_SNPRINTF)
|
||||
int
|
||||
vsnprintf (char *str, size_t sz, const char *format, va_list args)
|
||||
{
|
||||
struct state state;
|
||||
int ret;
|
||||
unsigned char *ustr = (unsigned char *)str;
|
||||
|
||||
state.max_sz = 0;
|
||||
state.sz = sz;
|
||||
state.str = ustr;
|
||||
state.s = ustr;
|
||||
state.theend = ustr + sz - (sz > 0);
|
||||
state.append_char = sn_append_char;
|
||||
|
||||
ret = xyzprintf (&state, format, args);
|
||||
if (state.s != NULL)
|
||||
*state.s = '\0';
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
3
tools/compat/sys/null.h
Normal file
3
tools/compat/sys/null.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: null.h,v 1.1 2007/07/19 13:49:12 jmmv Exp $ */
|
||||
|
||||
#include "../../../sys/sys/null.h"
|
||||
3
tools/compat/sys/queue.h
Normal file
3
tools/compat/sys/queue.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: queue.h,v 1.1 2002/01/21 20:04:37 tv Exp $ */
|
||||
|
||||
#include "../../../sys/sys/queue.h"
|
||||
3
tools/compat/sys/rmd160.h
Normal file
3
tools/compat/sys/rmd160.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: rmd160.h,v 1.1 2006/10/27 22:32:45 mrg Exp $ */
|
||||
|
||||
#include "../../../sys/sys/rmd160.h"
|
||||
5
tools/compat/sys/sha1.h
Normal file
5
tools/compat/sys/sha1.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: sha1.h,v 1.1 2006/10/29 06:17:08 dogcow Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD SHA1 in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../sys/sys/sha1.h"
|
||||
3
tools/compat/sys/sha2.h
Normal file
3
tools/compat/sys/sha2.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: sha2.h,v 1.1 2006/10/27 22:32:45 mrg Exp $ */
|
||||
|
||||
#include "../../../sys/sys/sha2.h"
|
||||
3
tools/compat/sys/verified_exec.h
Normal file
3
tools/compat/sys/verified_exec.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: verified_exec.h,v 1.1 2006/12/20 22:03:20 agc Exp $ */
|
||||
|
||||
#include "../../sys/sys/verified_exec.h"
|
||||
3
tools/compat/tzfile.h
Normal file
3
tools/compat/tzfile.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: tzfile.h,v 1.1 2002/01/31 22:43:49 tv Exp $ */
|
||||
|
||||
#include "../../include/tzfile.h"
|
||||
3
tools/compat/ufs/ffs/ffs_extern.h
Normal file
3
tools/compat/ufs/ffs/ffs_extern.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: ffs_extern.h,v 1.1 2003/05/14 00:30:26 dbj Exp $ */
|
||||
|
||||
#include "../../../../sys/ufs/ffs/ffs_extern.h"
|
||||
3
tools/compat/ufs/ffs/fs.h
Normal file
3
tools/compat/ufs/ffs/fs.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: fs.h,v 1.1 2003/05/14 00:30:26 dbj Exp $ */
|
||||
|
||||
#include "../../../../sys/ufs/ffs/fs.h"
|
||||
3
tools/compat/ufs/ufs/dinode.h
Normal file
3
tools/compat/ufs/ufs/dinode.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: dinode.h,v 1.1 2003/05/14 00:30:26 dbj Exp $ */
|
||||
|
||||
#include "../../../../sys/ufs/ufs/dinode.h"
|
||||
3
tools/compat/ufs/ufs/dir.h
Normal file
3
tools/compat/ufs/ufs/dir.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: dir.h,v 1.1 2003/05/14 00:30:27 dbj Exp $ */
|
||||
|
||||
#include "../../../../sys/ufs/ufs/dir.h"
|
||||
3
tools/compat/ufs/ufs/quota.h
Normal file
3
tools/compat/ufs/ufs/quota.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: quota.h,v 1.1 2011/03/07 02:02:36 joerg Exp $ */
|
||||
|
||||
#include "../../../../sys/ufs/ufs/quota.h"
|
||||
3
tools/compat/ufs/ufs/ufs_bswap.h
Normal file
3
tools/compat/ufs/ufs/ufs_bswap.h
Normal file
@@ -0,0 +1,3 @@
|
||||
/* $NetBSD: ufs_bswap.h,v 1.1 2003/05/14 00:30:27 dbj Exp $ */
|
||||
|
||||
#include "../../../../sys/ufs/ufs/ufs_bswap.h"
|
||||
5
tools/compat/vis.h
Normal file
5
tools/compat/vis.h
Normal file
@@ -0,0 +1,5 @@
|
||||
/* $NetBSD: vis.h,v 1.2 2003/10/27 00:12:43 lukem Exp $ */
|
||||
|
||||
/* We unconditionally use the NetBSD vis(3) in libnbcompat. */
|
||||
#include "nbtool_config.h"
|
||||
#include "../../include/vis.h"
|
||||
Reference in New Issue
Block a user