mirror of
https://github.com/samba-team/samba.git
synced 2025-03-25 14:50:24 +03:00
r18644: bring in libreplace in lib/replace
metze (This used to be commit 596cbe73dd268742acf456fccd8a234376fb0c97)
This commit is contained in:
parent
f2e7b8d144
commit
8f153c6128
source3
Makefile.inaclocal.m4autogen.shconfigure.in
include
lib
replace.c
replace
Makefile.inREADMEaclocal.m4autoconf-2.60.m4autogen.shconfig.guessconfig.subconfigure.acdlfcn.cdlfcn.m4getpass.cgetpass.m4install-shlibreplace.m4libreplace_cc.m4libreplace_macros.m4repdir.m4repdir_getdents.crepdir_getdirentries.creplace.creplace.hsamba.m4snprintf.c
system
READMEcapability.hconfig.m4dir.hfilesys.hglob.hiconv.hkerberos.hlocale.hnetwork.hpasswd.hprinting.hreadline.hselect.hshmem.hsyslog.hterminal.htime.hwait.h
test
timegm.ctimegm.m4win32.m4win32_replace.h@ -193,8 +193,6 @@ VERSION_OBJ = lib/version.o
|
||||
|
||||
DOSERR_OBJ = libsmb/doserr.o
|
||||
|
||||
SNPRINTF_OBJ = lib/snprintf.o
|
||||
|
||||
WBCOMMON_OBJ = nsswitch/wb_common.o
|
||||
|
||||
AFS_OBJ = lib/afs.o
|
||||
@ -219,15 +217,15 @@ RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
|
||||
|
||||
TALLOC_OBJ = lib/talloc.o
|
||||
|
||||
LIB_WITHOUT_PROTO_OBJ = @SOCKET_WRAPPER_OBJS@
|
||||
LIB_WITHOUT_PROTO_OBJ = @LIBREPLACE_OBJS@ @SOCKET_WRAPPER_OBJS@
|
||||
|
||||
LIB_WITH_PROTO_OBJ = $(VERSION_OBJ) lib/charcnv.o lib/debug.o lib/fault.o \
|
||||
lib/getsmbpass.o lib/interface.o lib/md4.o \
|
||||
lib/interfaces.o lib/pidfile.o lib/replace.o lib/replace1.o lib/repdir.o lib/timegm.o \
|
||||
lib/interfaces.o lib/pidfile.o \
|
||||
lib/signal.o lib/system.o lib/sendfile.o lib/time.o \
|
||||
lib/ufc.o lib/genrand.o lib/username.o \
|
||||
lib/util_pw.o lib/access.o lib/smbrun.o \
|
||||
lib/bitmap.o lib/crc32.o $(SNPRINTF_OBJ) lib/dprintf.o \
|
||||
lib/bitmap.o lib/crc32.o lib/dprintf.o \
|
||||
lib/xfile.o lib/wins_srv.o lib/util_reg.o \
|
||||
lib/util_str.o lib/clobber.o lib/util_sid.o lib/util_uuid.o \
|
||||
lib/util_unistr.o lib/util_file.o lib/data_blob.o \
|
||||
@ -558,7 +556,7 @@ RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \
|
||||
$(SMBLDAP_OBJ) $(DCUTIL_OBJ)
|
||||
|
||||
PAM_WINBIND_OBJ = nsswitch/pam_winbind.o $(WBCOMMON_OBJ) \
|
||||
lib/replace1.o $(SNPRINTF_OBJ) @BUILD_INIPARSER@
|
||||
@LIBREPLACE_OBJS@ @BUILD_INIPARSER@
|
||||
|
||||
LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \
|
||||
libsmb/libsmb_cache.o \
|
||||
@ -623,7 +621,7 @@ CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
|
||||
MOUNT_OBJ = client/smbmount.o \
|
||||
$(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ)
|
||||
|
||||
MNT_OBJ = client/smbmnt.o lib/replace.o lib/timegm.o $(VERSION_OBJ) $(SNPRINTF_OBJ) @SOCKET_WRAPPER_OBJS@
|
||||
MNT_OBJ = client/smbmnt.o $(VERSION_OBJ) @LIBREPLACE_OBJS@ @SOCKET_WRAPPER_OBJS@
|
||||
|
||||
UMOUNT_OBJ = client/smbumount.o @SOCKET_WRAPPER_OBJS@
|
||||
|
||||
@ -772,7 +770,7 @@ WINBINDD_OBJ = \
|
||||
WBINFO_OBJ = nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
|
||||
$(SECRETS_OBJ) $(POPT_LIB_OBJ) $(AFS_SETTOKEN_OBJ) $(RPC_PARSE_OBJ1) $(DOSERR_OBJ)
|
||||
|
||||
WINBIND_NSS_OBJ = $(WBCOMMON_OBJ) lib/replace1.o lib/snprintf.o @WINBIND_NSS_EXTRA_OBJS@
|
||||
WINBIND_NSS_OBJ = $(WBCOMMON_OBJ) @LIBREPLACE_OBJS@ @WINBIND_NSS_EXTRA_OBJS@
|
||||
|
||||
POPT_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \
|
||||
popt/popthelp.o popt/poptparse.o
|
||||
@ -780,12 +778,12 @@ POPT_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \
|
||||
INIPARSER_OBJ = iniparser/src/iniparser.o iniparser/src/dictionary.o \
|
||||
iniparser/src/strlib.o
|
||||
|
||||
TDBBACKUP_OBJ = tdb/tools/tdbbackup.o tdb/common/tdbback.o $(SNPRINTF_OBJ) \
|
||||
TDBBACKUP_OBJ = tdb/tools/tdbbackup.o tdb/common/tdbback.o @LIBREPLACE_OBJS@ \
|
||||
$(TDBBASE_OBJ)
|
||||
|
||||
TDBTOOL_OBJ = tdb/tools/tdbtool.o $(TDBBASE_OBJ) $(SNPRINTF_OBJ)
|
||||
TDBTOOL_OBJ = tdb/tools/tdbtool.o $(TDBBASE_OBJ) @LIBREPLACE_OBJS@
|
||||
|
||||
TDBDUMP_OBJ = tdb/tools/tdbdump.o $(TDBBASE_OBJ) $(SNPRINTF_OBJ)
|
||||
TDBDUMP_OBJ = tdb/tools/tdbdump.o $(TDBBASE_OBJ) @LIBREPLACE_OBJS@
|
||||
|
||||
NTLM_AUTH_OBJ1 = utils/ntlm_auth.o utils/ntlm_auth_diagnostics.o
|
||||
|
||||
@ -1515,9 +1513,6 @@ bin/t_doschar@EXEEXT@: bin/libbigballofmud.@SHLIBEXT@ torture/t_doschar.o
|
||||
bin/t_push_ucs2@EXEEXT@: bin/libbigballofmud.@SHLIBEXT@ torture/t_push_ucs2.o
|
||||
$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(DYNEXP) $(LIBS) torture/t_push_ucs2.o -L ./bin -lbigballofmud
|
||||
|
||||
bin/t_snprintf@EXEEXT@: lib/snprintf.c
|
||||
$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(DYNEXP) -DTEST_SNPRINTF lib/snprintf.c -lm
|
||||
|
||||
bin/timelimit@EXEEXT@: script/tests/timelimit.o
|
||||
@echo Linking $@
|
||||
@$(CC) $(FLAGS) @PIE_LDFLAGS@ -o $@ $(DYNEXP) script/tests/timelimit.o
|
||||
|
53
source3/aclocal.m4
vendored
53
source3/aclocal.m4
vendored
@ -1,28 +1,3 @@
|
||||
dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
|
||||
dnl if the cache file is inconsistent with the current host,
|
||||
dnl target and build system types, execute CMD or print a default
|
||||
dnl error message.
|
||||
AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
|
||||
AC_REQUIRE([AC_CANONICAL_SYSTEM])
|
||||
AC_MSG_CHECKING([config.cache system type])
|
||||
if { test x"${ac_cv_host_system_type+set}" = x"set" &&
|
||||
test x"$ac_cv_host_system_type" != x"$host"; } ||
|
||||
{ test x"${ac_cv_build_system_type+set}" = x"set" &&
|
||||
test x"$ac_cv_build_system_type" != x"$build"; } ||
|
||||
{ test x"${ac_cv_target_system_type+set}" = x"set" &&
|
||||
test x"$ac_cv_target_system_type" != x"$target"; }; then
|
||||
AC_MSG_RESULT([different])
|
||||
ifelse($#, 1, [$1],
|
||||
[AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
|
||||
else
|
||||
AC_MSG_RESULT([same])
|
||||
fi
|
||||
ac_cv_host_system_type="$host"
|
||||
ac_cv_build_system_type="$build"
|
||||
ac_cv_target_system_type="$target"
|
||||
])
|
||||
|
||||
|
||||
dnl test whether dirent has a d_off member
|
||||
AC_DEFUN(AC_DIRENT_D_OFF,
|
||||
[AC_CACHE_CHECK([for d_off in dirent], ac_cv_dirent_d_off,
|
||||
@ -78,32 +53,6 @@ AC_DEFUN(SMB_SUBSYSTEM,
|
||||
ifelse([$2], , :, [rm -f $2])
|
||||
])
|
||||
|
||||
dnl AC_PROG_CC_FLAG(flag)
|
||||
AC_DEFUN(AC_PROG_CC_FLAG,
|
||||
[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
|
||||
[echo 'void f(){}' > conftest.c
|
||||
if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
|
||||
ac_cv_prog_cc_$1=yes
|
||||
else
|
||||
ac_cv_prog_cc_$1=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
])])
|
||||
|
||||
dnl see if a declaration exists for a function or variable
|
||||
dnl defines HAVE_function_DECL if it exists
|
||||
dnl AC_HAVE_DECL(var, includes)
|
||||
AC_DEFUN(AC_HAVE_DECL,
|
||||
[
|
||||
AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
|
||||
AC_TRY_COMPILE([$2],[int i = (int)$1],
|
||||
ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
|
||||
if test x"$ac_cv_have_$1_decl" = x"yes"; then
|
||||
AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl AC_LIBTESTFUNC(lib, function, [actions if found], [actions if not found])
|
||||
dnl Check for a function in a library, but don't keep adding the same library
|
||||
dnl to the LIBS variable. Check whether the function is available in the
|
||||
@ -868,3 +817,5 @@ else
|
||||
$2
|
||||
fi
|
||||
])
|
||||
|
||||
m4_include(lib/replace/libreplace.m4)
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
## insert all possible names (only works with
|
||||
## autoconf 2.x
|
||||
TESTAUTOHEADER="autoheader autoheader-2.53 autoheader2.50"
|
||||
TESTAUTOCONF="autoconf autoconf-2.53 autoconf2.50"
|
||||
TESTAUTOHEADER="autoheader autoheader-2.53 autoheader2.50 autoheader259 autoheader253"
|
||||
TESTAUTOCONF="autoconf autoconf-2.53 autoconf2.50 autoconf259 autoconf253"
|
||||
|
||||
AUTOHEADERFOUND="0"
|
||||
AUTOCONFFOUND="0"
|
||||
@ -53,11 +53,13 @@ echo "$0: running script/mkversion.sh"
|
||||
rm -rf autom4te*.cache
|
||||
rm -f configure include/config.h*
|
||||
|
||||
echo "$0: running $AUTOHEADER"
|
||||
$AUTOHEADER || exit 1
|
||||
IPATHS="-I. -Ilib/replace"
|
||||
|
||||
echo "$0: running $AUTOCONF"
|
||||
$AUTOCONF || exit 1
|
||||
echo "$0: running $AUTOHEADER $IPATHS"
|
||||
$AUTOHEADER $IPATHS || exit 1
|
||||
|
||||
echo "$0: running $AUTOCONF $IPATHS"
|
||||
$AUTOCONF $IPATHS || exit 1
|
||||
|
||||
rm -rf autom4te*.cache
|
||||
|
||||
|
@ -5,6 +5,8 @@ AC_PREREQ(2.53)
|
||||
AC_INIT(include/includes.h)
|
||||
AC_CONFIG_HEADER(include/config.h)
|
||||
|
||||
AC_LIBREPLACE_LOCATION_CHECKS
|
||||
|
||||
AC_DISABLE_STATIC
|
||||
AC_ENABLE_SHARED
|
||||
|
||||
@ -228,6 +230,7 @@ done
|
||||
])
|
||||
|
||||
SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include -I. -I${srcdir-.}"
|
||||
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace"
|
||||
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/tdb/include"
|
||||
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
|
||||
SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
|
||||
@ -303,6 +306,19 @@ AC_SUBST(EXTRA_ALL_TARGETS)
|
||||
AC_SUBST(CONFIG_LIBS)
|
||||
AC_SUBST(NSCD_LIBS)
|
||||
|
||||
# compile with optimization and without debugging by default, but
|
||||
# allow people to set their own preference.
|
||||
# do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
|
||||
# if it has no value. This prevent *very* large debug binaries from occurring
|
||||
# by default.
|
||||
if test "x$CFLAGS" = x; then
|
||||
CFLAGS="-O"
|
||||
fi
|
||||
|
||||
CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
|
||||
|
||||
AC_LIBREPLACE_CC_CHECKS
|
||||
|
||||
# Set defaults
|
||||
PIE_CFLAGS=""
|
||||
PIE_LDFLAGS=""
|
||||
@ -371,17 +387,6 @@ AC_ARG_WITH(smbtorture4_path,
|
||||
esac
|
||||
])
|
||||
|
||||
# compile with optimization and without debugging by default, but
|
||||
# allow people to set their own preference.
|
||||
# do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
|
||||
# if it has no value. This prevent *very* large debug binaries from occurring
|
||||
# by default.
|
||||
if test "x$CFLAGS" = x; then
|
||||
CFLAGS="-O"
|
||||
fi
|
||||
|
||||
CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
|
||||
|
||||
AC_ARG_ENABLE(developer, [ --enable-developer Turn on developer warnings and debugging (default=no)],
|
||||
[if eval "test x$enable_developer = xyes"; then
|
||||
developer=yes
|
||||
@ -441,18 +446,6 @@ AC_ARG_WITH(profiling-data,
|
||||
|
||||
dnl Checks for programs.
|
||||
|
||||
##
|
||||
## for some reason this macro resets the CFLAGS
|
||||
## so save and restore
|
||||
##
|
||||
OLD_CFLAGS=${CFLAGS}
|
||||
AC_PROG_CC
|
||||
CFLAGS=${OLD_CFLAGS}
|
||||
|
||||
OLD_CFLAGS=${CFLAGS}
|
||||
AC_PROG_CPP
|
||||
CFLAGS=${OLD_CFLAGS}
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_AWK
|
||||
AC_PATH_PROG(PERL, perl)
|
||||
@ -495,9 +488,6 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl needed before AC_TRY_COMPILE
|
||||
AC_ISC_POSIX
|
||||
|
||||
dnl look for executable suffix
|
||||
AC_EXEEXT
|
||||
|
||||
@ -562,12 +552,10 @@ UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
|
||||
AC_MSG_CHECKING(uname -p)
|
||||
AC_MSG_RESULT(${UNAME_P})
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
dnl Add #include for broken IRIX header files
|
||||
case "$host_os" in
|
||||
*irix6*)
|
||||
AC_ADD_INCLUDE(<standards.h>)
|
||||
#TODO add to libreplace
|
||||
if test x"$ac_cv_prog_gcc" != x"yes" ; then
|
||||
dnl Fix sensible defaults for MIPSPro compilers. The
|
||||
dnl error numbers are valid for the 7.3 compilers,
|
||||
@ -585,8 +573,6 @@ dnl Add #include for broken IRIX header files
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_VALIDATE_CACHE_SYSTEM_TYPE
|
||||
|
||||
DYNEXP=
|
||||
|
||||
dnl Add modules that have to be built by default here
|
||||
@ -609,13 +595,6 @@ fi
|
||||
case "$host_os" in
|
||||
# Try to work out if this is the native HPUX compiler that uses the -Ae flag.
|
||||
*hpux*)
|
||||
|
||||
AC_PROG_CC_FLAG(Ae)
|
||||
# mmap on HPUX is completely broken...
|
||||
AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
|
||||
if test $ac_cv_prog_cc_Ae = yes; then
|
||||
CPPFLAGS="$CPPFLAGS -Ae"
|
||||
fi
|
||||
#
|
||||
# Defines needed for HPUX support.
|
||||
# HPUX has bigcrypt but (sometimes?) doesn't use it for
|
||||
@ -860,11 +839,16 @@ exit(1);
|
||||
|
||||
esac
|
||||
|
||||
AC_INLINE
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_TIME
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_LIBREPLACE_BROKEN_CHECKS
|
||||
|
||||
LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'`
|
||||
|
||||
LIBREPLACE_OBJS=""
|
||||
for obj in ${LIBREPLACEOBJ}; do
|
||||
LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}"
|
||||
done
|
||||
AC_SUBST(LIBREPLACE_OBJS)
|
||||
|
||||
AC_CHECK_HEADERS(aio.h arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
|
||||
AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h)
|
||||
AC_CHECK_HEADERS(limits.h float.h)
|
||||
|
@ -27,7 +27,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef NO_CONFIG_H /* for some tests */
|
||||
#include "config.h"
|
||||
#include "lib/replace/replace.h"
|
||||
#endif
|
||||
|
||||
/* only do the C++ reserved word check when we compile
|
||||
@ -125,6 +125,23 @@
|
||||
#endif
|
||||
#endif /* RELIANTUNIX */
|
||||
|
||||
#include "system/capability.h"
|
||||
#include "system/dir.h"
|
||||
#include "system/filesys.h"
|
||||
#include "system/glob.h"
|
||||
#include "system/iconv.h"
|
||||
#include "system/locale.h"
|
||||
#include "system/network.h"
|
||||
#include "system/passwd.h"
|
||||
#include "system/printing.h"
|
||||
#include "system/readline.h"
|
||||
#include "system/select.h"
|
||||
#include "system/shmem.h"
|
||||
#include "system/syslog.h"
|
||||
#include "system/terminal.h"
|
||||
#include "system/time.h"
|
||||
#include "system/wait.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
@ -939,11 +956,6 @@ extern int errno;
|
||||
#define NGROUPS_MAX 32 /* Guess... */
|
||||
#endif
|
||||
|
||||
#ifdef SOCKET_WRAPPER
|
||||
#define SOCKET_WRAPPER_REPLACE
|
||||
#include "lib/socket_wrapper/socket_wrapper.h"
|
||||
#endif
|
||||
|
||||
/* Our own pstrings and fstrings */
|
||||
#include "pstring.h"
|
||||
|
||||
|
@ -1,452 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
replacement routines for broken systems
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
void replace_dummy(void);
|
||||
void replace_dummy(void) {}
|
||||
|
||||
#ifndef HAVE_FTRUNCATE
|
||||
/*******************************************************************
|
||||
ftruncate for operating systems that don't have it
|
||||
********************************************************************/
|
||||
int ftruncate(int f,SMB_OFF_T l)
|
||||
{
|
||||
#ifdef HAVE_CHSIZE
|
||||
return chsize(f,l);
|
||||
#else
|
||||
struct flock fl;
|
||||
|
||||
fl.l_whence = 0;
|
||||
fl.l_len = 0;
|
||||
fl.l_start = l;
|
||||
fl.l_type = F_WRLCK;
|
||||
return fcntl(f, F_FREESP, &fl);
|
||||
#endif
|
||||
}
|
||||
#endif /* HAVE_FTRUNCATE */
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
/* like strncpy but does not 0 fill the buffer and always null
|
||||
terminates. bufsize is the size of the destination buffer */
|
||||
size_t strlcpy(char *d, const char *s, size_t bufsize)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
size_t ret = len;
|
||||
if (bufsize <= 0) return 0;
|
||||
if (len >= bufsize) len = bufsize-1;
|
||||
memcpy(d, s, len);
|
||||
d[len] = 0;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
/* like strncat but does not 0 fill the buffer and always null
|
||||
terminates. bufsize is the length of the buffer, which should
|
||||
be one more than the maximum resulting string length */
|
||||
size_t strlcat(char *d, const char *s, size_t bufsize)
|
||||
{
|
||||
size_t len1 = strlen(d);
|
||||
size_t len2 = strlen(s);
|
||||
size_t ret = len1 + len2;
|
||||
|
||||
if (len1 >= bufsize) {
|
||||
return 0;
|
||||
}
|
||||
if (len1+len2 >= bufsize) {
|
||||
len2 = bufsize - (len1+1);
|
||||
}
|
||||
if (len2 > 0) {
|
||||
memcpy(d+len1, s, len2);
|
||||
d[len1+len2] = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKTIME
|
||||
/*******************************************************************
|
||||
a mktime() replacement for those who don't have it - contributed by
|
||||
C.A. Lademann <cal@zls.com>
|
||||
Corrections by richard.kettlewell@kewill.com
|
||||
********************************************************************/
|
||||
|
||||
#define MINUTE 60
|
||||
#define HOUR 60*MINUTE
|
||||
#define DAY 24*HOUR
|
||||
#define YEAR 365*DAY
|
||||
time_t mktime(struct tm *t)
|
||||
{
|
||||
struct tm *u;
|
||||
time_t epoch = 0;
|
||||
int n;
|
||||
int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
||||
y, m, i;
|
||||
|
||||
if(t->tm_year < 70) {
|
||||
return((time_t)-1);
|
||||
}
|
||||
|
||||
n = t->tm_year + 1900 - 1;
|
||||
epoch = (t->tm_year - 70) * YEAR + ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY;
|
||||
|
||||
y = t->tm_year + 1900;
|
||||
m = 0;
|
||||
|
||||
for(i = 0; i < t->tm_mon; i++) {
|
||||
epoch += mon [m] * DAY;
|
||||
if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
|
||||
epoch += DAY;
|
||||
}
|
||||
|
||||
if(++m > 11) {
|
||||
m = 0;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
epoch += (t->tm_mday - 1) * DAY;
|
||||
epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec;
|
||||
|
||||
if((u = localtime(&epoch)) != NULL) {
|
||||
t->tm_sec = u->tm_sec;
|
||||
t->tm_min = u->tm_min;
|
||||
t->tm_hour = u->tm_hour;
|
||||
t->tm_mday = u->tm_mday;
|
||||
t->tm_mon = u->tm_mon;
|
||||
t->tm_year = u->tm_year;
|
||||
t->tm_wday = u->tm_wday;
|
||||
t->tm_yday = u->tm_yday;
|
||||
t->tm_isdst = u->tm_isdst;
|
||||
}
|
||||
|
||||
return(epoch);
|
||||
}
|
||||
#endif /* !HAVE_MKTIME */
|
||||
|
||||
|
||||
|
||||
#ifndef HAVE_RENAME
|
||||
/* Rename a file. (from libiberty in GNU binutils) */
|
||||
int rename(const char *zfrom, const char *zto)
|
||||
{
|
||||
if (link (zfrom, zto) < 0) {
|
||||
if (errno != EEXIST) {
|
||||
return -1;
|
||||
}
|
||||
if (unlink (zto) < 0 || link (zfrom, zto) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return unlink (zfrom);
|
||||
}
|
||||
#endif /* HAVE_RENAME */
|
||||
|
||||
|
||||
#ifndef HAVE_INNETGR
|
||||
#if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT)
|
||||
/*
|
||||
* Search for a match in a netgroup. This replaces it on broken systems.
|
||||
*/
|
||||
int innetgr(const char *group,const char *host,const char *user,const char *dom)
|
||||
{
|
||||
char *hst, *usr, *dm;
|
||||
|
||||
setnetgrent(group);
|
||||
while (getnetgrent(&hst, &usr, &dm)) {
|
||||
if (((host == 0) || (hst == 0) || !strcmp(host, hst)) &&
|
||||
((user == 0) || (usr == 0) || !strcmp(user, usr)) &&
|
||||
((dom == 0) || (dm == 0) || !strcmp(dom, dm))) {
|
||||
endnetgrent();
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
endnetgrent();
|
||||
return (0);
|
||||
}
|
||||
#endif /* HAVE_SETNETGRENT HAVE_GETNETGRENT HAVE_ENDNETGRENT */
|
||||
#endif /* HAVE_INNETGR */
|
||||
|
||||
|
||||
|
||||
#ifndef HAVE_INITGROUPS
|
||||
/****************************************************************************
|
||||
some systems don't have an initgroups call
|
||||
****************************************************************************/
|
||||
int initgroups(char *name,gid_t id)
|
||||
{
|
||||
#ifndef HAVE_SETGROUPS
|
||||
static int done;
|
||||
if (!done) {
|
||||
DEBUG(1,("WARNING: running without setgroups\n"));
|
||||
done=1;
|
||||
}
|
||||
/* yikes! no SETGROUPS or INITGROUPS? how can this work? */
|
||||
return(0);
|
||||
#else /* HAVE_SETGROUPS */
|
||||
gid_t *grouplst = NULL;
|
||||
int max_gr = groups_max();
|
||||
int ret;
|
||||
int i,j;
|
||||
struct group *g;
|
||||
char *gr;
|
||||
|
||||
if((grouplst = SMB_MALLOC_ARRAY(gid_t, max_gr)) == NULL) {
|
||||
DEBUG(0,("initgroups: malloc fail !\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
grouplst[0] = id;
|
||||
i = 1;
|
||||
while (i < max_gr && ((g = (struct group *)getgrent()) != (struct group *)NULL)) {
|
||||
if (g->gr_gid == id)
|
||||
continue;
|
||||
j = 0;
|
||||
gr = g->gr_mem[0];
|
||||
while (gr && (*gr != (char)NULL)) {
|
||||
if (strcmp(name,gr) == 0) {
|
||||
grouplst[i] = g->gr_gid;
|
||||
i++;
|
||||
gr = (char *)NULL;
|
||||
break;
|
||||
}
|
||||
gr = g->gr_mem[++j];
|
||||
}
|
||||
}
|
||||
endgrent();
|
||||
ret = sys_setgroups(i,grouplst);
|
||||
SAFE_FREE(grouplst);
|
||||
return ret;
|
||||
#endif /* HAVE_SETGROUPS */
|
||||
}
|
||||
#endif /* HAVE_INITGROUPS */
|
||||
|
||||
|
||||
#if (defined(SecureWare) && defined(SCO))
|
||||
/* This is needed due to needing the nap() function but we don't want
|
||||
to include the Xenix libraries since that will break other things...
|
||||
BTW: system call # 0x0c28 is the same as calling nap() */
|
||||
long nap(long milliseconds) {
|
||||
return syscall(0x0c28, milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
/*******************************************************************
|
||||
safely copies memory, ensuring no overlap problems.
|
||||
this is only used if the machine does not have it's own memmove().
|
||||
this is not the fastest algorithm in town, but it will do for our
|
||||
needs.
|
||||
********************************************************************/
|
||||
void *memmove(void *dest,const void *src,int size)
|
||||
{
|
||||
unsigned long d,s;
|
||||
int i;
|
||||
if (dest==src || !size) return(dest);
|
||||
|
||||
d = (unsigned long)dest;
|
||||
s = (unsigned long)src;
|
||||
|
||||
if ((d >= (s+size)) || (s >= (d+size))) {
|
||||
/* no overlap */
|
||||
memcpy(dest,src,size);
|
||||
return(dest);
|
||||
}
|
||||
|
||||
if (d < s) {
|
||||
/* we can forward copy */
|
||||
if (s-d >= sizeof(int) &&
|
||||
!(s%sizeof(int)) &&
|
||||
!(d%sizeof(int)) &&
|
||||
!(size%sizeof(int))) {
|
||||
/* do it all as words */
|
||||
int *idest = (int *)dest;
|
||||
int *isrc = (int *)src;
|
||||
size /= sizeof(int);
|
||||
for (i=0;i<size;i++) idest[i] = isrc[i];
|
||||
} else {
|
||||
/* simplest */
|
||||
char *cdest = (char *)dest;
|
||||
char *csrc = (char *)src;
|
||||
for (i=0;i<size;i++) cdest[i] = csrc[i];
|
||||
}
|
||||
} else {
|
||||
/* must backward copy */
|
||||
if (d-s >= sizeof(int) &&
|
||||
!(s%sizeof(int)) &&
|
||||
!(d%sizeof(int)) &&
|
||||
!(size%sizeof(int))) {
|
||||
/* do it all as words */
|
||||
int *idest = (int *)dest;
|
||||
int *isrc = (int *)src;
|
||||
size /= sizeof(int);
|
||||
for (i=size-1;i>=0;i--) idest[i] = isrc[i];
|
||||
} else {
|
||||
/* simplest */
|
||||
char *cdest = (char *)dest;
|
||||
char *csrc = (char *)src;
|
||||
for (i=size-1;i>=0;i--) cdest[i] = csrc[i];
|
||||
}
|
||||
}
|
||||
return(dest);
|
||||
}
|
||||
#endif /* HAVE_MEMMOVE */
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
/****************************************************************************
|
||||
duplicate a string
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef strdup
|
||||
#undef strdup
|
||||
#endif
|
||||
|
||||
char *strdup(const char *s)
|
||||
{
|
||||
size_t len;
|
||||
char *ret;
|
||||
|
||||
if (!s) return(NULL);
|
||||
|
||||
len = strlen(s)+1;
|
||||
ret = (char *)SMB_MALLOC(len);
|
||||
if (!ret) return(NULL);
|
||||
memcpy(ret,s,len);
|
||||
return(ret);
|
||||
}
|
||||
#endif /* HAVE_STRDUP */
|
||||
|
||||
#ifdef REPLACE_INET_NTOA
|
||||
char *rep_inet_ntoa(struct in_addr ip)
|
||||
{
|
||||
unsigned char *p = (unsigned char *)&ip.s_addr;
|
||||
static char buf[18];
|
||||
slprintf(buf, 17, "%d.%d.%d.%d",
|
||||
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
|
||||
return buf;
|
||||
}
|
||||
#endif /* REPLACE_INET_NTOA */
|
||||
|
||||
#ifndef HAVE_STRTOUL
|
||||
#ifndef ULONG_MAX
|
||||
#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert a string to an unsigned long integer.
|
||||
* Taken from libg++ - libiberty code.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
unsigned long strtoul(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long acc;
|
||||
int c;
|
||||
unsigned long cutoff;
|
||||
int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else if (c == '+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
|
||||
cutlim = (int)((unsigned long)ULONG_MAX % (unsigned long)base);
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper_ascii(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = ULONG_MAX;
|
||||
errno = ERANGE;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = (char *) (any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
||||
#endif /* HAVE_STRTOUL */
|
||||
|
||||
#ifndef HAVE_STRTOULL
|
||||
unsigned long long int strtoull(const char *str, char **endptr, int base)
|
||||
{
|
||||
#ifdef HAVE_STRTOUQ
|
||||
return strtouq(str, endptr, base);
|
||||
#elif defined(HAVE___STRTOULL)
|
||||
return __strtoull(str, endptr, base);
|
||||
#elif SIZEOF_LONG == SIZEOF_LONG_LONG
|
||||
return (unsigned long long int) strtoul(str, endptr, base);
|
||||
#else
|
||||
# error "You need a strtoull function"
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETLINEBUF
|
||||
int setlinebuf(FILE *stream)
|
||||
{
|
||||
return setvbuf(stream, (char *)NULL, _IOLBF, 0);
|
||||
}
|
||||
#endif /* HAVE_SETLINEBUF */
|
||||
|
||||
#ifndef HAVE_VSYSLOG
|
||||
#ifdef HAVE_SYSLOG
|
||||
void vsyslog (int facility_priority, const char *format, va_list arglist)
|
||||
{
|
||||
char *msg = NULL;
|
||||
vasprintf(&msg, format, arglist);
|
||||
if (!msg)
|
||||
return;
|
||||
syslog(facility_priority, "%s", msg);
|
||||
SAFE_FREE(msg);
|
||||
}
|
||||
#endif /* HAVE_SYSLOG */
|
||||
#endif /* HAVE_VSYSLOG */
|
60
source3/lib/replace/Makefile.in
Normal file
60
source3/lib/replace/Makefile.in
Normal file
@ -0,0 +1,60 @@
|
||||
#!gmake
|
||||
#
|
||||
CC = @CC@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
includedir = @includedir@
|
||||
libdir = @libdir@
|
||||
VPATH = @libreplacedir@
|
||||
srcdir = @srcdir@
|
||||
builddir = @builddir@
|
||||
INSTALL = @INSTALL@
|
||||
|
||||
.PHONY: test
|
||||
|
||||
CFLAGS=-I. -I@libreplacedir@ @CFLAGS@
|
||||
|
||||
OBJS = @LIBREPLACEOBJ@
|
||||
|
||||
all: showflags libreplace.a testsuite
|
||||
|
||||
showflags:
|
||||
@echo 'libreplace will be compiled with flags:'
|
||||
@echo ' CC = $(CC)'
|
||||
@echo ' CFLAGS = $(CFLAGS)'
|
||||
@echo ' LIBS = $(LIBS)'
|
||||
|
||||
install: all
|
||||
mkdir -p $(libdir)
|
||||
$(INSTALL) libreplace.a $(libdir)
|
||||
|
||||
libreplace.a: $(OBJS)
|
||||
ar -rcsv $@ $(OBJS)
|
||||
|
||||
test: all
|
||||
./testsuite
|
||||
|
||||
installcheck: install test
|
||||
|
||||
TEST_OBJS = test/testsuite.o test/os2_delete.o
|
||||
|
||||
testsuite: libreplace.a $(TEST_OBJS)
|
||||
$(CC) -o testsuite $(TEST_OBJS) -L. -lreplace
|
||||
|
||||
.c.o:
|
||||
@echo Compiling $*.c
|
||||
@mkdir -p `dirname $@`
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o test/*.o *.a testsuite
|
||||
rm -f testfile.dat
|
||||
|
||||
distclean: clean
|
||||
rm -f *~ */*~
|
||||
rm -f config.log config.status config.h config.cache
|
||||
rm -f Makefile
|
||||
|
||||
realdistclean: distclean
|
||||
rm -f configure config.h.in
|
80
source3/lib/replace/README
Normal file
80
source3/lib/replace/README
Normal file
@ -0,0 +1,80 @@
|
||||
This subsystem ensures that we can always use a certain core set of
|
||||
functions and types, that are either provided by the OS or by replacement
|
||||
functions / definitions in this subsystem. The aim is to try to stick
|
||||
to POSIX functions in here as much as possible. Convenience functions
|
||||
that are available on no platform at all belong in other subsystems
|
||||
(such as LIBUTIL).
|
||||
|
||||
The following functions are guaranteed:
|
||||
|
||||
ftruncate
|
||||
strlcpy
|
||||
strlcat
|
||||
mktime
|
||||
rename
|
||||
innetgr
|
||||
initgroups
|
||||
memmove
|
||||
strdup
|
||||
inet_ntoa
|
||||
setlinebuf
|
||||
vsyslog
|
||||
timegm
|
||||
setenv
|
||||
strndup
|
||||
strnlen
|
||||
waitpid
|
||||
seteuid
|
||||
setegid
|
||||
asprintf
|
||||
snprintf
|
||||
vasprintf
|
||||
vsnprintf
|
||||
opendir
|
||||
readdir
|
||||
telldir
|
||||
seekdir
|
||||
closedir
|
||||
dlopen
|
||||
dlclose
|
||||
dlsym
|
||||
dlerror
|
||||
chroot
|
||||
bzero
|
||||
strerror
|
||||
errno
|
||||
mkdtemp
|
||||
mkstemp (a secure one!)
|
||||
pread
|
||||
pwrite
|
||||
getpass
|
||||
readline (the library)
|
||||
inet_ntoa
|
||||
strtoll
|
||||
strtoull
|
||||
|
||||
Types:
|
||||
bool
|
||||
socklen_t
|
||||
uint_t
|
||||
uint{8,16,32,64}_t
|
||||
int{8,16,32,64}_t
|
||||
intptr_t
|
||||
|
||||
Constants:
|
||||
PATH_NAME_MAX
|
||||
UINT{16,32,64}_MAX
|
||||
INT32_MAX
|
||||
|
||||
Macros:
|
||||
va_copy
|
||||
__FUNCTION__
|
||||
__STRING
|
||||
MIN
|
||||
MAX
|
||||
|
||||
Prerequisites:
|
||||
memset (for bzero)
|
||||
syslog (for vsyslog)
|
||||
setnetgrent, getnetgrent, endnetgrent (for innetgr)
|
||||
mktemp (for mkstemp and mkdtemp)
|
1
source3/lib/replace/aclocal.m4
vendored
Normal file
1
source3/lib/replace/aclocal.m4
vendored
Normal file
@ -0,0 +1 @@
|
||||
m4_include(libreplace.m4)
|
197
source3/lib/replace/autoconf-2.60.m4
Normal file
197
source3/lib/replace/autoconf-2.60.m4
Normal file
@ -0,0 +1,197 @@
|
||||
# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
|
||||
# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
|
||||
# --------------------------------------------------------------
|
||||
# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
|
||||
# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
|
||||
# try again with each compiler option in the space-separated OPTION-LIST; if one
|
||||
# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
|
||||
# else ACTION-IF-UNAVAILABLE.
|
||||
AC_DEFUN([_AC_C_STD_TRY],
|
||||
[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
|
||||
AC_CACHE_VAL(ac_cv_prog_cc_$1,
|
||||
[ac_cv_prog_cc_$1=no
|
||||
ac_save_CC=$CC
|
||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
|
||||
for ac_arg in '' $4
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
_AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
|
||||
test "x$ac_cv_prog_cc_$1" != "xno" && break
|
||||
done
|
||||
rm -f conftest.$ac_ext
|
||||
CC=$ac_save_CC
|
||||
])# AC_CACHE_VAL
|
||||
case "x$ac_cv_prog_cc_$1" in
|
||||
x)
|
||||
AC_MSG_RESULT([none needed]) ;;
|
||||
xno)
|
||||
AC_MSG_RESULT([unsupported]) ;;
|
||||
*)
|
||||
CC="$CC $ac_cv_prog_cc_$1"
|
||||
AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
|
||||
esac
|
||||
AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
|
||||
])# _AC_C_STD_TRY
|
||||
|
||||
# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
|
||||
# ----------------------------------------------------------------
|
||||
# If the C compiler is not in ISO C99 mode by default, try to add an
|
||||
# option to output variable CC to make it so. This macro tries
|
||||
# various options that select ISO C99 on some system or another. It
|
||||
# considers the compiler to be in ISO C99 mode if it handles mixed
|
||||
# code and declarations, _Bool, inline and restrict.
|
||||
AC_DEFUN([_AC_PROG_CC_C99],
|
||||
[_AC_C_STD_TRY([c99],
|
||||
[[#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct incomplete_array
|
||||
{
|
||||
int datasize;
|
||||
double data[];
|
||||
};
|
||||
|
||||
struct named_init {
|
||||
int number;
|
||||
const wchar_t *name;
|
||||
double average;
|
||||
};
|
||||
|
||||
typedef const char *ccp;
|
||||
|
||||
static inline int
|
||||
test_restrict(ccp restrict text)
|
||||
{
|
||||
// See if C++-style comments work.
|
||||
// Iterate through items via the restricted pointer.
|
||||
// Also check for declarations in for loops.
|
||||
for (unsigned int i = 0; *(text+i) != '\0'; ++i)
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check varargs and va_copy work.
|
||||
static void
|
||||
test_varargs(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
va_list args_copy;
|
||||
va_copy(args_copy, args);
|
||||
|
||||
const char *str;
|
||||
int number;
|
||||
float fnumber;
|
||||
|
||||
while (*format)
|
||||
{
|
||||
switch (*format++)
|
||||
{
|
||||
case 's': // string
|
||||
str = va_arg(args_copy, const char *);
|
||||
break;
|
||||
case 'd': // int
|
||||
number = va_arg(args_copy, int);
|
||||
break;
|
||||
case 'f': // float
|
||||
fnumber = (float) va_arg(args_copy, double);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args_copy);
|
||||
va_end(args);
|
||||
}
|
||||
]],
|
||||
[[
|
||||
// Check bool and long long datatypes.
|
||||
_Bool success = false;
|
||||
long long int bignum = -1234567890LL;
|
||||
unsigned long long int ubignum = 1234567890uLL;
|
||||
|
||||
// Check restrict.
|
||||
if (test_restrict("String literal") != 0)
|
||||
success = true;
|
||||
char *restrict newvar = "Another string";
|
||||
|
||||
// Check varargs.
|
||||
test_varargs("s, d' f .", "string", 65, 34.234);
|
||||
|
||||
// Check incomplete arrays work.
|
||||
struct incomplete_array *ia =
|
||||
malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10));
|
||||
ia->datasize = 10;
|
||||
for (int i = 0; i < ia->datasize; ++i)
|
||||
ia->data[i] = (double) i * 1.234;
|
||||
|
||||
// Check named initialisers.
|
||||
struct named_init ni = {
|
||||
.number = 34,
|
||||
.name = L"Test wide string",
|
||||
.average = 543.34343,
|
||||
};
|
||||
|
||||
ni.number = 58;
|
||||
|
||||
int dynamic_array[ni.number];
|
||||
dynamic_array[43] = 543;
|
||||
|
||||
// work around unused variable warnings
|
||||
return bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x';
|
||||
]],
|
||||
dnl Try
|
||||
dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
|
||||
dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
|
||||
dnl Intel ICC -c99
|
||||
dnl IRIX -c99
|
||||
dnl Solaris (unused because it causes the compiler to assume C99 semantics for
|
||||
dnl library functions, and this is invalid before Solaris 10: -xc99)
|
||||
dnl Tru64 -c99
|
||||
dnl with extended modes being tried first.
|
||||
[[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl
|
||||
])# _AC_PROG_CC_C99
|
||||
|
||||
# AC_PROG_CC_C99
|
||||
# --------------
|
||||
AC_DEFUN([AC_PROG_CC_C99],
|
||||
[ AC_REQUIRE([AC_PROG_CC])dnl
|
||||
_AC_PROG_CC_C99
|
||||
])
|
||||
|
||||
# AC_USE_SYSTEM_EXTENSIONS
|
||||
# ------------------------
|
||||
# Enable extensions on systems that normally disable them,
|
||||
# typically due to standards-conformance issues.
|
||||
AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
|
||||
[
|
||||
AC_BEFORE([$0], [AC_COMPILE_IFELSE])
|
||||
AC_BEFORE([$0], [AC_RUN_IFELSE])
|
||||
|
||||
AC_REQUIRE([AC_GNU_SOURCE])
|
||||
AC_REQUIRE([AC_AIX])
|
||||
AC_REQUIRE([AC_MINIX])
|
||||
|
||||
AH_VERBATIM([__EXTENSIONS__],
|
||||
[/* Enable extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif])
|
||||
AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
|
||||
[ac_cv_safe_to_define___extensions__],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([
|
||||
# define __EXTENSIONS__ 1
|
||||
AC_INCLUDES_DEFAULT])],
|
||||
[ac_cv_safe_to_define___extensions__=yes],
|
||||
[ac_cv_safe_to_define___extensions__=no])])
|
||||
test $ac_cv_safe_to_define___extensions__ = yes &&
|
||||
AC_DEFINE([__EXTENSIONS__])
|
||||
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
|
||||
])
|
13
source3/lib/replace/autogen.sh
Executable file
13
source3/lib/replace/autogen.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -rf autom4te.cache
|
||||
rm -f configure config.h.in
|
||||
|
||||
autoheader || exit 1
|
||||
autoconf || exit 1
|
||||
|
||||
rm -rf autom4te.cache
|
||||
|
||||
echo "Now run ./configure and then make."
|
||||
exit 0
|
||||
|
1466
source3/lib/replace/config.guess
vendored
Executable file
1466
source3/lib/replace/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1579
source3/lib/replace/config.sub
vendored
Executable file
1579
source3/lib/replace/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
22
source3/lib/replace/configure.ac
Normal file
22
source3/lib/replace/configure.ac
Normal file
@ -0,0 +1,22 @@
|
||||
AC_PREREQ(2.50)
|
||||
AC_INIT(replace.c)
|
||||
AC_CONFIG_SRCDIR([replace.c])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
|
||||
AC_LIBREPLACE_ALL_CHECKS
|
||||
|
||||
if test "$ac_cv_prog_gcc" = yes; then
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
CFLAGS="$CFLAGS -W"
|
||||
CFLAGS="$CFLAGS -Wshadow"
|
||||
CFLAGS="$CFLAGS -Wstrict-prototypes"
|
||||
CFLAGS="$CFLAGS -Wpointer-arith"
|
||||
CFLAGS="$CFLAGS -Wcast-qual"
|
||||
CFLAGS="$CFLAGS -Wcast-align"
|
||||
CFLAGS="$CFLAGS -Wwrite-strings"
|
||||
CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
|
||||
CFLAGS="$CFLAGS -Wformat=2"
|
||||
CFLAGS="$CFLAGS -Wno-format-y2k"
|
||||
fi
|
||||
|
||||
AC_OUTPUT(Makefile)
|
54
source3/lib/replace/dlfcn.c
Normal file
54
source3/lib/replace/dlfcn.c
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Samba system utilities
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
Copyright (C) Jeremy Allison 1998-2002
|
||||
|
||||
** NOTE! The following LGPL license applies to the replace
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "replace.h"
|
||||
|
||||
#ifndef HAVE_DLOPEN
|
||||
void *dlopen(const char *name, int flags)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DLSYM
|
||||
void *dlsym(void *handle, const char *symbol)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DLERROR
|
||||
char *dlerror(void)
|
||||
{
|
||||
return "dynamic loading of objects not supported on this platform";
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DLCLOSE
|
||||
int dlclose(void *handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
18
source3/lib/replace/dlfcn.m4
Normal file
18
source3/lib/replace/dlfcn.m4
Normal file
@ -0,0 +1,18 @@
|
||||
dnl dummies provided by dlfcn.c if not available
|
||||
save_LIBS="$LIBS"
|
||||
LIBS=""
|
||||
|
||||
AC_SEARCH_LIBS(dlopen, dl)
|
||||
|
||||
AC_CHECK_HEADERS(dlfcn.h)
|
||||
|
||||
libreplace_dlfcn=no
|
||||
AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_dlfcn=yes])
|
||||
|
||||
if test x"${libreplace_dlfcn}" = x"yes";then
|
||||
LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o"
|
||||
fi
|
||||
|
||||
LIBDL="$LIBS"
|
||||
AC_SUBST(LIBDL)
|
||||
LIBS="$save_LIBS"
|
212
source3/lib/replace/getpass.c
Normal file
212
source3/lib/replace/getpass.c
Normal file
@ -0,0 +1,212 @@
|
||||
/* Copyright (C) 1992-1998 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. */
|
||||
|
||||
/* Modified to use with samba by Jeremy Allison, 8th July 1995. */
|
||||
|
||||
#include "replace.h"
|
||||
|
||||
#if defined(HAVE_TERMIOS_H)
|
||||
/* POSIX terminal handling. */
|
||||
#include <termios.h>
|
||||
#elif defined(HAVE_TERMIO_H)
|
||||
/* Older SYSV terminal handling - don't use if we can avoid it. */
|
||||
#include <termio.h>
|
||||
#elif defined(HAVE_SYS_TERMIO_H)
|
||||
/* Older SYSV terminal handling - don't use if we can avoid it. */
|
||||
#include <sys/termio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define additional missing types
|
||||
*/
|
||||
#ifndef HAVE_SIG_ATOMIC_T_TYPE
|
||||
typedef int sig_atomic_t;
|
||||
#endif
|
||||
|
||||
#ifndef SIGCLD
|
||||
#define SIGCLD SIGCHLD
|
||||
#endif
|
||||
|
||||
#ifndef SIGNAL_CAST
|
||||
#define SIGNAL_CAST (RETSIGTYPE (*)(int))
|
||||
#endif
|
||||
|
||||
#ifdef REPLACE_GETPASS
|
||||
|
||||
#ifdef SYSV_TERMIO
|
||||
|
||||
/* SYSTEM V TERMIO HANDLING */
|
||||
|
||||
static struct termio t;
|
||||
|
||||
#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
|
||||
#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
|
||||
#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
|
||||
|
||||
#ifndef TCSAFLUSH
|
||||
#define TCSAFLUSH 1
|
||||
#endif
|
||||
|
||||
#ifndef TCSANOW
|
||||
#define TCSANOW 0
|
||||
#endif
|
||||
|
||||
static int tcgetattr(int fd, struct termio *_t)
|
||||
{
|
||||
return ioctl(fd, TCGETA, _t);
|
||||
}
|
||||
|
||||
static int tcsetattr(int fd, int flags, struct termio *_t)
|
||||
{
|
||||
if(flags & TCSAFLUSH)
|
||||
ioctl(fd, TCFLSH, TCIOFLUSH);
|
||||
return ioctl(fd, TCSETS, _t);
|
||||
}
|
||||
|
||||
#elif !defined(TCSAFLUSH)
|
||||
|
||||
/* BSD TERMIO HANDLING */
|
||||
|
||||
static struct sgttyb t;
|
||||
|
||||
#define ECHO_IS_ON(t) ((t).sg_flags & ECHO)
|
||||
#define TURN_ECHO_OFF(t) ((t).sg_flags &= ~ECHO)
|
||||
#define TURN_ECHO_ON(t) ((t).sg_flags |= ECHO)
|
||||
|
||||
#define TCSAFLUSH 1
|
||||
#define TCSANOW 0
|
||||
|
||||
static int tcgetattr(int fd, struct sgttyb *_t)
|
||||
{
|
||||
return ioctl(fd, TIOCGETP, (char *)_t);
|
||||
}
|
||||
|
||||
static int tcsetattr(int fd, int flags, struct sgttyb *_t)
|
||||
{
|
||||
return ioctl(fd, TIOCSETP, (char *)_t);
|
||||
}
|
||||
|
||||
#else /* POSIX TERMIO HANDLING */
|
||||
#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
|
||||
#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
|
||||
#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
|
||||
|
||||
static struct termios t;
|
||||
#endif /* SYSV_TERMIO */
|
||||
|
||||
static void catch_signal(int signum,void (*handler)(int ))
|
||||
{
|
||||
#ifdef HAVE_SIGACTION
|
||||
struct sigaction act;
|
||||
struct sigaction oldact;
|
||||
|
||||
memset(&act, 0, sizeof(act));
|
||||
|
||||
act.sa_handler = handler;
|
||||
#ifdef SA_RESTART
|
||||
/*
|
||||
* We *want* SIGALRM to interrupt a system call.
|
||||
*/
|
||||
if(signum != SIGALRM)
|
||||
act.sa_flags = SA_RESTART;
|
||||
#endif
|
||||
sigemptyset(&act.sa_mask);
|
||||
sigaddset(&act.sa_mask,signum);
|
||||
sigaction(signum,&act,&oldact);
|
||||
return oldact.sa_handler;
|
||||
#else /* !HAVE_SIGACTION */
|
||||
/* FIXME: need to handle sigvec and systems with broken signal() */
|
||||
return signal(signum, handler);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *getsmbpass(const char *prompt)
|
||||
{
|
||||
FILE *in, *out;
|
||||
int echo_off;
|
||||
static char buf[256];
|
||||
static size_t bufsize = sizeof(buf);
|
||||
size_t nread;
|
||||
|
||||
/* Catch problematic signals */
|
||||
catch_signal(SIGINT, SIGNAL_CAST SIG_IGN);
|
||||
|
||||
/* Try to write to and read from the terminal if we can.
|
||||
If we can't open the terminal, use stderr and stdin. */
|
||||
|
||||
in = fopen ("/dev/tty", "w+");
|
||||
if (in == NULL)
|
||||
{
|
||||
in = stdin;
|
||||
out = stderr;
|
||||
}
|
||||
else
|
||||
out = in;
|
||||
|
||||
setvbuf(in, NULL, _IONBF, 0);
|
||||
|
||||
/* Turn echoing off if it is on now. */
|
||||
|
||||
if (tcgetattr (fileno (in), &t) == 0)
|
||||
{
|
||||
if (ECHO_IS_ON(t))
|
||||
{
|
||||
TURN_ECHO_OFF(t);
|
||||
echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0;
|
||||
TURN_ECHO_ON(t);
|
||||
}
|
||||
else
|
||||
echo_off = 0;
|
||||
}
|
||||
else
|
||||
echo_off = 0;
|
||||
|
||||
/* Write the prompt. */
|
||||
fputs (prompt, out);
|
||||
fflush (out);
|
||||
|
||||
/* Read the password. */
|
||||
buf[0] = 0;
|
||||
fgets(buf, bufsize, in);
|
||||
nread = strlen(buf);
|
||||
if (buf[nread - 1] == '\n')
|
||||
buf[nread - 1] = '\0';
|
||||
|
||||
/* Restore echoing. */
|
||||
if (echo_off)
|
||||
(void) tcsetattr (fileno (in), TCSANOW, &t);
|
||||
|
||||
if (in != stdin)
|
||||
/* We opened the terminal; now close it. */
|
||||
fclose (in);
|
||||
|
||||
/* Catch problematic signals */
|
||||
catch_signal(SIGINT, SIGNAL_CAST SIG_DFL);
|
||||
|
||||
printf("\n");
|
||||
return buf;
|
||||
}
|
||||
|
||||
#else
|
||||
void getsmbpasswd_dummy(void);
|
||||
void getsmbpasswd_dummy(void) {;}
|
||||
#endif
|
17
source3/lib/replace/getpass.m4
Normal file
17
source3/lib/replace/getpass.m4
Normal file
@ -0,0 +1,17 @@
|
||||
AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
|
||||
SAVE_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS -I$libreplacedir/"
|
||||
AC_TRY_COMPILE([
|
||||
#include "confdefs.h"
|
||||
#define _LIBREPLACE_REPLACE_H
|
||||
#define REPLACE_GETPASS 1
|
||||
#define main dont_declare_main
|
||||
#include "$libreplacedir/getpass.c"
|
||||
#undef main
|
||||
],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
|
||||
CPPFLAGS="$SAVE_CPPFLAGS"
|
||||
])
|
||||
if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
|
||||
AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
|
||||
LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o"
|
||||
fi
|
238
source3/lib/replace/install-sh
Executable file
238
source3/lib/replace/install-sh
Executable file
@ -0,0 +1,238 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
else
|
||||
instcmd=mkdir
|
||||
fi
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
then
|
||||
true
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if [ ! -d "$dstdir" ]; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-${defaultIFS}}"
|
||||
|
||||
oIFS="${IFS}"
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
IFS="${oIFS}"
|
||||
|
||||
pathcomp=''
|
||||
|
||||
while [ $# -ne 0 ] ; do
|
||||
pathcomp="${pathcomp}${1}"
|
||||
shift
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
pathcomp="${pathcomp}/"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
|
||||
fi &&
|
||||
|
||||
|
||||
exit 0
|
358
source3/lib/replace/libreplace.m4
Normal file
358
source3/lib/replace/libreplace.m4
Normal file
@ -0,0 +1,358 @@
|
||||
AC_DEFUN_ONCE(AC_LIBREPLACE_LOCATION_CHECKS,
|
||||
[
|
||||
echo "LIBREPLACE_LOCATION_CHECKS: START"
|
||||
|
||||
dnl find the libreplace sources. This is meant to work both for
|
||||
dnl libreplace standalone builds, and builds of packages using libreplace
|
||||
libreplacedir=""
|
||||
libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace"
|
||||
for d in $libreplacepaths; do
|
||||
if test -f "$d/replace.c"; then
|
||||
libreplacedir="$d"
|
||||
AC_SUBST(libreplacedir)
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if test x"$libreplacedir" = "x"; then
|
||||
AC_MSG_ERROR([cannot find libreplace in $libreplacepaths])
|
||||
fi
|
||||
LIBREPLACEOBJ="replace.o"
|
||||
AC_SUBST(LIBREPLACEOBJ)
|
||||
|
||||
AC_CANONICAL_BUILD
|
||||
AC_CANONICAL_HOST
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
echo "LIBREPLACE_LOCATION_CHECKS: END"
|
||||
]) dnl end AC_LIBREPLACE_LOCATION_CHECKS
|
||||
|
||||
|
||||
AC_DEFUN_ONCE(AC_LIBREPLACE_BROKEN_CHECKS,
|
||||
[
|
||||
echo "LIBREPLACE_BROKEN_CHECKS: START"
|
||||
|
||||
dnl find the libreplace sources. This is meant to work both for
|
||||
dnl libreplace standalone builds, and builds of packages using libreplace
|
||||
libreplacedir=""
|
||||
for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do
|
||||
if test -f "$d/replace.c"; then
|
||||
libreplacedir="$d"
|
||||
AC_SUBST(libreplacedir)
|
||||
break;
|
||||
fi
|
||||
done
|
||||
LIBREPLACEOBJ="replace.o"
|
||||
AC_SUBST(LIBREPLACEOBJ)
|
||||
|
||||
LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o"
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_UID_T
|
||||
AC_TYPE_MODE_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_PID_T
|
||||
AC_STRUCT_ST_RDEV
|
||||
AC_CHECK_TYPE(ino_t,unsigned)
|
||||
AC_CHECK_TYPE(loff_t,off_t)
|
||||
AC_CHECK_TYPE(offset_t,loff_t)
|
||||
|
||||
AC_FUNC_MEMCMP
|
||||
|
||||
AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp)
|
||||
|
||||
AC_CHECK_HEADERS(stdbool.h sys/select.h)
|
||||
|
||||
AC_CHECK_HEADERS(sys/epoll.h)
|
||||
AC_CHECK_FUNCS(epoll_create)
|
||||
|
||||
AC_CHECK_TYPE(bool,
|
||||
[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
|
||||
[
|
||||
AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#endif]
|
||||
)
|
||||
|
||||
AC_CHECK_TYPE(_Bool,
|
||||
[AC_DEFINE(HAVE__Bool, 1, [Whether the _Bool type is available])],,
|
||||
[
|
||||
AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#endif]
|
||||
)
|
||||
|
||||
AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
|
||||
AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"],
|
||||
samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
|
||||
if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
|
||||
AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
|
||||
fi
|
||||
|
||||
|
||||
AC_CHECK_HEADERS(sys/syslog.h syslog.h)
|
||||
AC_CHECK_HEADERS(sys/time.h time.h)
|
||||
AC_CHECK_HEADERS(stdarg.h vararg.h)
|
||||
AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
|
||||
AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
|
||||
AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
|
||||
|
||||
|
||||
dnl we need to check that net/if.h really can be used, to cope with hpux
|
||||
dnl where including it always fails
|
||||
AC_TRY_COMPILE([
|
||||
#include <stdio.h>
|
||||
#if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <stddef.h>
|
||||
#else
|
||||
# if HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
# endif
|
||||
#endif
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif],
|
||||
[#include <net/if.h>],
|
||||
AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h))
|
||||
|
||||
|
||||
AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
main() { struct in_addr ip; ip.s_addr = 0x12345678;
|
||||
if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
|
||||
strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
|
||||
exit(1);}],
|
||||
samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
|
||||
if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
|
||||
AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
|
||||
fi
|
||||
|
||||
dnl Provided by replace.c:
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#include <sys/socket.h>],
|
||||
[socklen_t foo;],,
|
||||
[AC_DEFINE(socklen_t, int,[Socket length type])])
|
||||
|
||||
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
|
||||
AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
|
||||
AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
|
||||
AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
|
||||
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
|
||||
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
|
||||
AC_HAVE_DECL(errno, [#include <errno.h>])
|
||||
|
||||
AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
|
||||
AC_TRY_RUN([#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
main() {
|
||||
struct stat st;
|
||||
char tpl[20]="/tmp/test.XXXXXX";
|
||||
int fd = mkstemp(tpl);
|
||||
if (fd == -1) exit(1);
|
||||
unlink(tpl);
|
||||
if (fstat(fd, &st) != 0) exit(1);
|
||||
if ((st.st_mode & 0777) != 0600) exit(1);
|
||||
exit(0);
|
||||
}],
|
||||
samba_cv_HAVE_SECURE_MKSTEMP=yes,
|
||||
samba_cv_HAVE_SECURE_MKSTEMP=no,
|
||||
samba_cv_HAVE_SECURE_MKSTEMP=cross)])
|
||||
if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
|
||||
AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
|
||||
fi
|
||||
|
||||
dnl Provided by snprintf.c:
|
||||
AC_CHECK_HEADERS(stdio.h strings.h)
|
||||
AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf])
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
|
||||
|
||||
AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
void foo(const char *format, ...) {
|
||||
va_list ap;
|
||||
int len;
|
||||
char buf[20];
|
||||
long long l = 1234567890;
|
||||
l *= 100;
|
||||
|
||||
va_start(ap, format);
|
||||
len = vsnprintf(buf, 0, format, ap);
|
||||
va_end(ap);
|
||||
if (len != 5) exit(1);
|
||||
|
||||
va_start(ap, format);
|
||||
len = vsnprintf(0, 0, format, ap);
|
||||
va_end(ap);
|
||||
if (len != 5) exit(2);
|
||||
|
||||
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
|
||||
|
||||
if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
|
||||
if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
|
||||
if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
|
||||
if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
main() { foo("hello"); }
|
||||
],
|
||||
samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
|
||||
if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
|
||||
AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
|
||||
fi
|
||||
|
||||
|
||||
dnl VA_COPY
|
||||
AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
|
||||
AC_TRY_LINK([#include <stdarg.h>
|
||||
va_list ap1,ap2;], [va_copy(ap1,ap2);],
|
||||
samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
|
||||
if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
|
||||
AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
|
||||
fi
|
||||
|
||||
if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
|
||||
AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
|
||||
AC_TRY_LINK([#include <stdarg.h>
|
||||
va_list ap1,ap2;], [__va_copy(ap1,ap2);],
|
||||
samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
|
||||
if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
|
||||
AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl __FUNCTION__ macro
|
||||
AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
|
||||
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
|
||||
samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
|
||||
if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
|
||||
AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
|
||||
else
|
||||
dnl __func__ macro
|
||||
AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[
|
||||
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
|
||||
samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)])
|
||||
if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then
|
||||
AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS([sys/param.h limits.h])
|
||||
|
||||
AC_CHECK_TYPE(comparison_fn_t,
|
||||
[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
|
||||
|
||||
AC_CHECK_FUNCS(strnlen setenv)
|
||||
AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
|
||||
|
||||
# this test disabled as we don't actually need __VA_ARGS__ yet
|
||||
# AC_TRY_CPP([
|
||||
# #define eprintf(...) fprintf(stderr, __VA_ARGS__)
|
||||
# eprintf("bla", "bar");
|
||||
# ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])])
|
||||
|
||||
# Check prerequisites
|
||||
AC_CHECK_FUNCS([memset printf syslog], [],
|
||||
[ AC_MSG_ERROR([Required function not found])])
|
||||
|
||||
AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
|
||||
AC_TRY_COMPILE([
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#include <signal.h>],[sig_atomic_t i = 0],
|
||||
samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
|
||||
if test x"$samba_cv_sig_atomic_t" = x"yes"; then
|
||||
AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
|
||||
fi
|
||||
|
||||
|
||||
AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[
|
||||
AC_TRY_COMPILE([
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif],
|
||||
[int fd = open("/dev/null", O_DIRECT);],
|
||||
samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)])
|
||||
if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
|
||||
AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT])
|
||||
fi
|
||||
|
||||
|
||||
AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
|
||||
dnl Check whether the compiler can generate precompiled headers
|
||||
touch conftest.h
|
||||
if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
|
||||
precompiled_headers=yes
|
||||
else
|
||||
precompiled_headers=no
|
||||
fi])
|
||||
AC_SUBST(precompiled_headers)
|
||||
|
||||
|
||||
dnl Check if the C compiler understands volatile (it should, being ANSI).
|
||||
AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
|
||||
AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
|
||||
samba_cv_volatile=yes,samba_cv_volatile=no)])
|
||||
if test x"$samba_cv_volatile" = x"yes"; then
|
||||
AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
|
||||
fi
|
||||
|
||||
m4_include(system/config.m4)
|
||||
|
||||
m4_include(dlfcn.m4)
|
||||
m4_include(getpass.m4)
|
||||
m4_include(win32.m4)
|
||||
m4_include(timegm.m4)
|
||||
m4_include(repdir.m4)
|
||||
|
||||
AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
|
||||
[AC_MSG_ERROR([Required function not found])])
|
||||
|
||||
echo "LIBREPLACE_BROKEN_CHECKS: END"
|
||||
]) dnl end AC_LIBREPLACE_BROKEN_CHECKS
|
||||
|
||||
AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START,
|
||||
[
|
||||
#LIBREPLACE_ALL_CHECKS: START"
|
||||
])
|
||||
AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_END,
|
||||
[
|
||||
#LIBREPLACE_ALL_CHECKS: END"
|
||||
])
|
||||
m4_define(AC_LIBREPLACE_ALL_CHECKS,
|
||||
[
|
||||
AC__LIBREPLACE_ALL_CHECKS_START
|
||||
AC_LIBREPLACE_LOCATION_CHECKS
|
||||
AC_LIBREPLACE_CC_CHECKS
|
||||
AC_LIBREPLACE_BROKEN_CHECKS
|
||||
AC__LIBREPLACE_ALL_CHECKS_END
|
||||
])
|
||||
|
||||
m4_include(libreplace_cc.m4)
|
||||
m4_include(libreplace_macros.m4)
|
||||
m4_include(autoconf-2.60.m4)
|
126
source3/lib/replace/libreplace_cc.m4
Normal file
126
source3/lib/replace/libreplace_cc.m4
Normal file
@ -0,0 +1,126 @@
|
||||
|
||||
AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_START,
|
||||
[
|
||||
echo "LIBREPLACE_CC_CHECKS: START"
|
||||
])
|
||||
|
||||
AC_DEFUN_ONCE(AC__LIBREPLACE_ONLY_CC_CHECKS_END,
|
||||
[
|
||||
echo "LIBREPLACE_CC_CHECKS: END"
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl
|
||||
dnl AC_LIBREPLACE_CC_CHECKS
|
||||
dnl
|
||||
dnl Note: we need to use m4_define instead of AC_DEFUN because
|
||||
dnl of the ordering of tests
|
||||
dnl
|
||||
dnl
|
||||
m4_define(AC_LIBREPLACE_CC_CHECKS,
|
||||
[
|
||||
AC__LIBREPLACE_ONLY_CC_CHECKS_START
|
||||
|
||||
dnl stop the C89 attempt by autoconf - if autoconf detects -Ae it will enable it
|
||||
dnl which conflicts with C99 on HPUX
|
||||
ac_cv_prog_cc_Ae=no
|
||||
|
||||
savedCFLAGS=$CFLAGS
|
||||
AC_PROG_CC
|
||||
CFLAGS=$savedCFLAGS
|
||||
AC_PROG_CC_C99
|
||||
if test x"$GCC" = x"yes" ; then
|
||||
AC_MSG_CHECKING([for version of gcc])
|
||||
GCC_VERSION=`$CC -dumpversion`
|
||||
AC_MSG_RESULT(${GCC_VERSION})
|
||||
fi
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_INLINE
|
||||
LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_WARN([c99 structure initializer are not supported])])
|
||||
|
||||
AC_PROG_INSTALL
|
||||
|
||||
AC_ISC_POSIX
|
||||
AC_EXTENSION_FLAG(_XOPEN_SOURCE_EXTENDED)
|
||||
AC_EXTENSION_FLAG(_OSF_SOURCE)
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
dnl Add #include for broken IRIX header files
|
||||
case "$host_os" in
|
||||
*irix6*) AC_ADD_INCLUDE(<standards.h>)
|
||||
;;
|
||||
*hpux*)
|
||||
# mmap on HPUX is completely broken...
|
||||
AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
|
||||
;;
|
||||
*aix*)
|
||||
if test "${GCC}" != "yes"; then
|
||||
## for funky AIX compiler using strncpy()
|
||||
CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
|
||||
fi
|
||||
;;
|
||||
#
|
||||
# VOS may need to have POSIX support and System V compatibility enabled.
|
||||
#
|
||||
*vos*)
|
||||
case "$CFLAGS" in
|
||||
*-D_POSIX_C_SOURCE*);;
|
||||
*)
|
||||
CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
|
||||
AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
|
||||
;;
|
||||
esac
|
||||
case "$CFLAGS" in
|
||||
*-D_SYSV*|*-D_SVID_SOURCE*);;
|
||||
*)
|
||||
CFLAGS="$CFLAGS -D_SYSV"
|
||||
AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
AC_CHECK_HEADERS([standards.h])
|
||||
|
||||
# Solaris needs HAVE_LONG_LONG defined
|
||||
AC_CHECK_TYPES(long long)
|
||||
|
||||
AC_CHECK_TYPE(uint_t, unsigned int)
|
||||
AC_CHECK_TYPE(int8_t, char)
|
||||
AC_CHECK_TYPE(uint8_t, unsigned char)
|
||||
AC_CHECK_TYPE(int16_t, short)
|
||||
AC_CHECK_TYPE(uint16_t, unsigned short)
|
||||
AC_CHECK_TYPE(int32_t, long)
|
||||
AC_CHECK_TYPE(uint32_t, unsigned long)
|
||||
AC_CHECK_TYPE(int64_t, long long)
|
||||
AC_CHECK_TYPE(uint64_t, unsigned long long)
|
||||
|
||||
AC_CHECK_TYPE(size_t, unsigned int)
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(char)
|
||||
AC_CHECK_SIZEOF(short)
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(long long)
|
||||
|
||||
AC_CHECK_SIZEOF(off_t)
|
||||
AC_CHECK_SIZEOF(size_t)
|
||||
AC_CHECK_SIZEOF(ssize_t)
|
||||
|
||||
AC_CHECK_TYPE(intptr_t, unsigned long long)
|
||||
AC_CHECK_TYPE(ptrdiff_t, unsigned long long)
|
||||
|
||||
if test x"$ac_cv_type_long_long" != x"yes";then
|
||||
AC_MSG_ERROR([LIBREPLACE needs type 'long long'])
|
||||
fi
|
||||
if test $ac_cv_sizeof_long_long -lt 8;then
|
||||
AC_MSG_ERROR([LIBREPLACE needs sizeof(long long) >= 8])
|
||||
fi
|
||||
|
||||
AC__LIBREPLACE_ONLY_CC_CHECKS_END
|
||||
]) dnl end AC_LIBREPLACE_CC_CHECKS
|
290
source3/lib/replace/libreplace_macros.m4
Normal file
290
source3/lib/replace/libreplace_macros.m4
Normal file
@ -0,0 +1,290 @@
|
||||
#
|
||||
# This is a collection of useful autoconf macros
|
||||
#
|
||||
|
||||
############################################
|
||||
# Check if the compiler handles c99 struct initialization, and if not try -AC99 and -c99 flags
|
||||
# Usage: LIBREPLACE_C99_STRUCT_INIT(success-action,failure-action)
|
||||
# changes CFLAGS to add -AC99 or -c99 if needed
|
||||
AC_DEFUN([LIBREPLACE_C99_STRUCT_INIT],
|
||||
[
|
||||
saved_CFLAGS="$CFLAGS";
|
||||
c99_init=no
|
||||
if test x"$c99_init" = x"no"; then
|
||||
AC_MSG_CHECKING(for C99 designated initializers)
|
||||
CFLAGS="$saved_CFLAGS";
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[ struct foo {int x;char y;};
|
||||
struct foo bar = { .y = 'X', .x = 1 };
|
||||
],
|
||||
[AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
|
||||
fi
|
||||
if test x"$c99_init" = x"no"; then
|
||||
AC_MSG_CHECKING(for C99 designated initializers with -AC99)
|
||||
CFLAGS="$saved_CFLAGS -AC99";
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[ struct foo {int x;char y;};
|
||||
struct foo bar = { .y = 'X', .x = 1 };
|
||||
],
|
||||
[AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
|
||||
fi
|
||||
if test x"$c99_init" = x"no"; then
|
||||
AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=extc99)
|
||||
CFLAGS="$saved_CFLAGS -qlanglvl=extc99";
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[ struct foo {int x;char y;};
|
||||
struct foo bar = { .y = 'X', .x = 1 };
|
||||
],
|
||||
[AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
|
||||
fi
|
||||
if test x"$c99_init" = x"no"; then
|
||||
AC_MSG_CHECKING(for C99 designated initializers with -qlanglvl=stdc99)
|
||||
CFLAGS="$saved_CFLAGS -qlanglvl=stdc99";
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[ struct foo {int x;char y;};
|
||||
struct foo bar = { .y = 'X', .x = 1 };
|
||||
],
|
||||
[AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
|
||||
fi
|
||||
if test x"$c99_init" = x"no"; then
|
||||
AC_MSG_CHECKING(for C99 designated initializers with -c99)
|
||||
CFLAGS="$saved_CFLAGS -c99"
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[ struct foo {int x;char y;};
|
||||
struct foo bar = { .y = 'X', .x = 1 };
|
||||
],
|
||||
[AC_MSG_RESULT(yes); c99_init=yes],[AC_MSG_RESULT(no)])
|
||||
fi
|
||||
|
||||
if test "`uname`" = "HP-UX"; then
|
||||
if test "$ac_cv_c_compiler_gnu" = no; then
|
||||
# special override for broken HP-UX compiler - I can't find a way to test
|
||||
# this properly (its a compiler bug)
|
||||
CFLAGS="$CFLAGS -AC99";
|
||||
c99_init=yes;
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$c99_init" = x"yes"; then
|
||||
saved_CFLAGS=""
|
||||
$1
|
||||
else
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
saved_CFLAGS=""
|
||||
$2
|
||||
fi
|
||||
])
|
||||
|
||||
dnl AC_PROG_CC_FLAG(flag)
|
||||
AC_DEFUN(AC_PROG_CC_FLAG,
|
||||
[AC_CACHE_CHECK(whether ${CC-cc} accepts -$1, ac_cv_prog_cc_$1,
|
||||
[echo 'void f(){}' > conftest.c
|
||||
if test -z "`${CC-cc} -$1 -c conftest.c 2>&1`"; then
|
||||
ac_cv_prog_cc_$1=yes
|
||||
else
|
||||
ac_cv_prog_cc_$1=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
])])
|
||||
|
||||
AC_DEFUN([AC_EXTENSION_FLAG],
|
||||
[
|
||||
cat >>confdefs.h <<\EOF
|
||||
#ifndef $1
|
||||
# define $1 1
|
||||
#endif
|
||||
EOF
|
||||
AH_VERBATIM([$1], [#ifndef $1
|
||||
# define $1 1
|
||||
#endif])
|
||||
])
|
||||
|
||||
|
||||
dnl see if a declaration exists for a function or variable
|
||||
dnl defines HAVE_function_DECL if it exists
|
||||
dnl AC_HAVE_DECL(var, includes)
|
||||
AC_DEFUN(AC_HAVE_DECL,
|
||||
[
|
||||
AC_CACHE_CHECK([for $1 declaration],ac_cv_have_$1_decl,[
|
||||
AC_TRY_COMPILE([$2],[int i = (int)$1],
|
||||
ac_cv_have_$1_decl=yes,ac_cv_have_$1_decl=no)])
|
||||
if test x"$ac_cv_have_$1_decl" = x"yes"; then
|
||||
AC_DEFINE([HAVE_]translit([$1], [a-z], [A-Z])[_DECL],1,[Whether $1() is available])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
# AC_CHECK_LIB_EXT(LIBRARY, [EXT_LIBS], [FUNCTION],
|
||||
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
|
||||
# [ADD-ACTION-IF-FOUND],[OTHER-LIBRARIES])
|
||||
# ------------------------------------------------------
|
||||
#
|
||||
# Use a cache variable name containing both the library and function name,
|
||||
# because the test really is for library $1 defining function $3, not
|
||||
# just for library $1. Separate tests with the same $1 and different $3s
|
||||
# may have different results.
|
||||
#
|
||||
# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$3])
|
||||
# is asking for trouble, since AC_CHECK_LIB($lib, fun) would give
|
||||
# ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence
|
||||
# the AS_LITERAL_IF indirection.
|
||||
#
|
||||
# FIXME: This macro is extremely suspicious. It DEFINEs unconditionally,
|
||||
# whatever the FUNCTION, in addition to not being a *S macro. Note
|
||||
# that the cache does depend upon the function we are looking for.
|
||||
#
|
||||
# It is on purpose we used `ac_check_lib_ext_save_LIBS' and not just
|
||||
# `ac_save_LIBS': there are many macros which don't want to see `LIBS'
|
||||
# changed but still want to use AC_CHECK_LIB_EXT, so they save `LIBS'.
|
||||
# And ``ac_save_LIBS' is too tempting a name, so let's leave them some
|
||||
# freedom.
|
||||
AC_DEFUN([AC_CHECK_LIB_EXT],
|
||||
[
|
||||
AH_CHECK_LIB_EXT([$1])
|
||||
ac_check_lib_ext_save_LIBS=$LIBS
|
||||
LIBS="-l$1 $$2 $7 $LIBS"
|
||||
AS_LITERAL_IF([$1],
|
||||
[AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1])],
|
||||
[AS_VAR_PUSHDEF([ac_Lib_ext], [ac_cv_lib_ext_$1''])])dnl
|
||||
|
||||
m4_ifval([$3],
|
||||
[
|
||||
AH_CHECK_FUNC_EXT([$3])
|
||||
AS_LITERAL_IF([$1],
|
||||
[AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1_$3])],
|
||||
[AS_VAR_PUSHDEF([ac_Lib_func], [ac_cv_lib_ext_$1''_$3])])dnl
|
||||
AC_CACHE_CHECK([for $3 in -l$1], ac_Lib_func,
|
||||
[AC_TRY_LINK_FUNC($3,
|
||||
[AS_VAR_SET(ac_Lib_func, yes);
|
||||
AS_VAR_SET(ac_Lib_ext, yes)],
|
||||
[AS_VAR_SET(ac_Lib_func, no);
|
||||
AS_VAR_SET(ac_Lib_ext, no)])
|
||||
])
|
||||
AS_IF([test AS_VAR_GET(ac_Lib_func) = yes],
|
||||
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3))])dnl
|
||||
AS_VAR_POPDEF([ac_Lib_func])dnl
|
||||
],[
|
||||
AC_CACHE_CHECK([for -l$1], ac_Lib_ext,
|
||||
[AC_TRY_LINK_FUNC([main],
|
||||
[AS_VAR_SET(ac_Lib_ext, yes)],
|
||||
[AS_VAR_SET(ac_Lib_ext, no)])
|
||||
])
|
||||
])
|
||||
LIBS=$ac_check_lib_ext_save_LIBS
|
||||
|
||||
AS_IF([test AS_VAR_GET(ac_Lib_ext) = yes],
|
||||
[m4_default([$4],
|
||||
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
|
||||
case "$$2" in
|
||||
*-l$1*)
|
||||
;;
|
||||
*)
|
||||
$2="-l$1 $$2"
|
||||
;;
|
||||
esac])
|
||||
[$6]
|
||||
],
|
||||
[$5])dnl
|
||||
AS_VAR_POPDEF([ac_Lib_ext])dnl
|
||||
])# AC_CHECK_LIB_EXT
|
||||
|
||||
# AH_CHECK_LIB_EXT(LIBNAME)
|
||||
# ---------------------
|
||||
m4_define([AH_CHECK_LIB_EXT],
|
||||
[AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
|
||||
[Define to 1 if you have the `]$1[' library (-l]$1[).])])
|
||||
|
||||
dnl AC_SEARCH_LIBS_EXT(FUNCTION, SEARCH-LIBS, EXT_LIBS,
|
||||
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
|
||||
dnl [OTHER-LIBRARIES])
|
||||
dnl --------------------------------------------------------
|
||||
dnl Search for a library defining FUNC, if it's not already available.
|
||||
AC_DEFUN([AC_SEARCH_LIBS_EXT],
|
||||
[AC_CACHE_CHECK([for library containing $1], [ac_cv_search_ext_$1],
|
||||
[
|
||||
ac_func_search_ext_save_LIBS=$LIBS
|
||||
ac_cv_search_ext_$1=no
|
||||
AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
|
||||
[ac_cv_search_ext_$1="none required"])
|
||||
if test "$ac_cv_search_ext_$1" = no; then
|
||||
for ac_lib in $2; do
|
||||
LIBS="-l$ac_lib $$3 $6 $ac_func_search_save_ext_LIBS"
|
||||
AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
|
||||
[ac_cv_search_ext_$1="-l$ac_lib"
|
||||
break])
|
||||
done
|
||||
fi
|
||||
LIBS=$ac_func_search_ext_save_LIBS])
|
||||
AS_IF([test "$ac_cv_search_ext_$1" != no],
|
||||
[test "$ac_cv_search_ext_$1" = "none required" || $3="$ac_cv_search_ext_$1 $$3"
|
||||
$4],
|
||||
[$5])dnl
|
||||
])
|
||||
|
||||
dnl check for a function in a $LIBS and $OTHER_LIBS libraries variable.
|
||||
dnl AC_CHECK_FUNC_EXT(func,OTHER_LIBS,IF-TRUE,IF-FALSE)
|
||||
AC_DEFUN([AC_CHECK_FUNC_EXT],
|
||||
[
|
||||
AH_CHECK_FUNC_EXT($1)
|
||||
ac_check_func_ext_save_LIBS=$LIBS
|
||||
LIBS="$2 $LIBS"
|
||||
AS_VAR_PUSHDEF([ac_var], [ac_cv_func_ext_$1])dnl
|
||||
AC_CACHE_CHECK([for $1], ac_var,
|
||||
[AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
|
||||
[AS_VAR_SET(ac_var, yes)],
|
||||
[AS_VAR_SET(ac_var, no)])])
|
||||
LIBS=$ac_check_func_ext_save_LIBS
|
||||
AS_IF([test AS_VAR_GET(ac_var) = yes],
|
||||
[AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3],
|
||||
[$4])dnl
|
||||
AS_VAR_POPDEF([ac_var])dnl
|
||||
])# AC_CHECK_FUNC
|
||||
|
||||
# AH_CHECK_FUNC_EXT(FUNCNAME)
|
||||
# ---------------------
|
||||
m4_define([AH_CHECK_FUNC_EXT],
|
||||
[AH_TEMPLATE(AS_TR_CPP(HAVE_$1),
|
||||
[Define to 1 if you have the `]$1[' function.])])
|
||||
|
||||
dnl Define an AC_DEFINE with ifndef guard.
|
||||
dnl AC_N_DEFINE(VARIABLE [, VALUE])
|
||||
define(AC_N_DEFINE,
|
||||
[cat >> confdefs.h <<\EOF
|
||||
[#ifndef] $1
|
||||
[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
|
||||
[#endif]
|
||||
EOF
|
||||
])
|
||||
|
||||
dnl Add an #include
|
||||
dnl AC_ADD_INCLUDE(VARIABLE)
|
||||
define(AC_ADD_INCLUDE,
|
||||
[cat >> confdefs.h <<\EOF
|
||||
[#include] $1
|
||||
EOF
|
||||
])
|
||||
|
||||
dnl AS_HELP_STRING is not available in autoconf 2.57, and AC_HELP_STRING is deprecated
|
||||
dnl in autoconf 2.59, so define AS_HELP_STRING to be AC_HELP_STRING unless it is already
|
||||
dnl defined.
|
||||
m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
|
||||
|
||||
dnl check if the prototype in the header matches the given one
|
||||
dnl AC_VERIFY_C_PROTOTYPE(prototype,functionbody,[IF-TRUE].[IF-FALSE],[extraheaders])
|
||||
AC_DEFUN(AC_VERIFY_C_PROTOTYPE,
|
||||
[AC_CACHE_CHECK([for prototype $1], AS_TR_SH([ac_cv_c_prototype_$1]),
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_INCLUDES_DEFAULT
|
||||
$5
|
||||
$1
|
||||
{
|
||||
$2
|
||||
}
|
||||
],[
|
||||
AS_TR_SH([ac_cv_c_prototype_$1])=yes
|
||||
],[
|
||||
AS_TR_SH([ac_cv_c_prototype_$1])=no
|
||||
])
|
||||
)
|
||||
AS_IF([test $AS_TR_SH([ac_cv_c_prototype_$1]) = yes],[$3],[$4])
|
||||
])
|
77
source3/lib/replace/repdir.m4
Normal file
77
source3/lib/replace/repdir.m4
Normal file
@ -0,0 +1,77 @@
|
||||
AC_CACHE_CHECK([for broken readdir],libreplace_READDIR_NEEDED,[
|
||||
AC_TRY_RUN([
|
||||
#define test_readdir_os2_delete main
|
||||
#include "$libreplacedir/test/os2_delete.c"],
|
||||
[libreplace_READDIR_NEEDED=no],
|
||||
[libreplace_READDIR_NEEDED=yes],
|
||||
[libreplace_READDIR_NEEDED="assuming not"])
|
||||
])
|
||||
|
||||
#
|
||||
# try to replace with getdents() if needed
|
||||
#
|
||||
if test x"$libreplace_READDIR_NEEDED" = x"yes"; then
|
||||
AC_CHECK_FUNCS(getdents)
|
||||
AC_CACHE_CHECK([for replacing readdir using getdents()],libreplace_READDIR_GETDENTS,[
|
||||
AC_TRY_RUN([
|
||||
#define _LIBREPLACE_REPLACE_H
|
||||
#include "$libreplacedir/repdir_getdents.c"
|
||||
#define test_readdir_os2_delete main
|
||||
#include "$libreplacedir/test/os2_delete.c"],
|
||||
[libreplace_READDIR_GETDENTS=yes],
|
||||
[libreplace_READDIR_GETDENTS=no])
|
||||
])
|
||||
fi
|
||||
if test x"$libreplace_READDIR_GETDENTS" = x"yes"; then
|
||||
AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
|
||||
AC_DEFINE(REPLACE_READDIR_GETDENTS,1,[replace readdir using getdents()])
|
||||
LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdents.o"
|
||||
libreplace_READDIR_NEEDED=no
|
||||
fi
|
||||
|
||||
#
|
||||
# try to replace with getdirentries() if needed
|
||||
#
|
||||
if test x"$libreplace_READDIR_NEEDED" = x"yes"; then
|
||||
AC_CHECK_FUNCS(getdirentries)
|
||||
AC_VERIFY_C_PROTOTYPE([long telldir(const DIR *dir)],
|
||||
[
|
||||
return 0;
|
||||
],[
|
||||
AC_DEFINE(TELLDIR_TAKES_CONST_DIR, 1, [Whether telldir takes a const pointer])
|
||||
],[],[
|
||||
#include <dirent.h>
|
||||
])
|
||||
|
||||
AC_VERIFY_C_PROTOTYPE([int seekdir(DIR *dir, long ofs)],
|
||||
[
|
||||
return 0;
|
||||
],[
|
||||
AC_DEFINE(SEEKDIR_RETURNS_INT, 1, [Whether seekdir returns an int])
|
||||
],[],[
|
||||
#include <dirent.h>
|
||||
])
|
||||
AC_CACHE_CHECK([for replacing readdir using getdirentries()],libreplace_READDIR_GETDIRENTRIES,[
|
||||
AC_TRY_RUN([
|
||||
#define _LIBREPLACE_REPLACE_H
|
||||
#include "$libreplacedir/repdir_getdirentries.c"
|
||||
#define test_readdir_os2_delete main
|
||||
#include "$libreplacedir/test/os2_delete.c"],
|
||||
[libreplace_READDIR_GETDIRENTRIES=yes],
|
||||
[libreplace_READDIR_GETDIRENTRIES=no])
|
||||
])
|
||||
fi
|
||||
if test x"$libreplace_READDIR_GETDIRENTRIES" = x"yes"; then
|
||||
AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
|
||||
AC_DEFINE(REPLACE_READDIR_GETDIRENTRIES,1,[replace readdir using getdirentries()])
|
||||
LIBREPLACEOBJ="${LIBREPLACEOBJ} repdir_getdirentries.o"
|
||||
libreplace_READDIR_NEEDED=no
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([a usable readdir()])
|
||||
if test x"$libreplace_READDIR_NEEDED" = x"yes"; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_WARN([the provided readdir() is broken])
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
155
source3/lib/replace/repdir_getdents.c
Normal file
155
source3/lib/replace/repdir_getdents.c
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
Copyright (C) Andrew Tridgell 2005
|
||||
|
||||
** NOTE! The following LGPL license applies to the replace
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems
|
||||
|
||||
This is needed because the existing directory handling in FreeBSD
|
||||
and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink()
|
||||
on files in a directory where telldir() has been used. On a block
|
||||
boundary it will occasionally miss a file when seekdir() is used to
|
||||
return to a position previously recorded with telldir().
|
||||
|
||||
This also fixes a severe performance and memory usage problem with
|
||||
telldir() on BSD systems. Each call to telldir() in BSD adds an
|
||||
entry to a linked list, and those entries are cleaned up on
|
||||
closedir(). This means with a large directory closedir() can take an
|
||||
arbitrary amount of time, causing network timeouts as millions of
|
||||
telldir() entries are freed
|
||||
|
||||
Note! This replacement code is not portable. It relies on getdents()
|
||||
always leaving the file descriptor at a seek offset that is a
|
||||
multiple of DIR_BUF_SIZE. If the code detects that this doesn't
|
||||
happen then it will abort(). It also does not handle directories
|
||||
with offsets larger than can be stored in a long,
|
||||
|
||||
This code is available under other free software licenses as
|
||||
well. Contact the author.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#define DIR_BUF_BITS 9
|
||||
#define DIR_BUF_SIZE (1<<DIR_BUF_BITS)
|
||||
|
||||
struct dir_buf {
|
||||
int fd;
|
||||
int nbytes, ofs;
|
||||
off_t seekpos;
|
||||
char buf[DIR_BUF_SIZE];
|
||||
};
|
||||
|
||||
DIR *opendir(const char *dname)
|
||||
{
|
||||
struct dir_buf *d;
|
||||
d = malloc(sizeof(*d));
|
||||
if (d == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
d->fd = open(dname, O_RDONLY);
|
||||
if (d->fd == -1) {
|
||||
free(d);
|
||||
return NULL;
|
||||
}
|
||||
d->ofs = 0;
|
||||
d->seekpos = 0;
|
||||
d->nbytes = 0;
|
||||
return (DIR *)d;
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dir)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
struct dirent *de;
|
||||
|
||||
if (d->ofs >= d->nbytes) {
|
||||
d->seekpos = lseek(d->fd, 0, SEEK_CUR);
|
||||
d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE);
|
||||
d->ofs = 0;
|
||||
}
|
||||
if (d->ofs >= d->nbytes) {
|
||||
return NULL;
|
||||
}
|
||||
de = (struct dirent *)&d->buf[d->ofs];
|
||||
d->ofs += de->d_reclen;
|
||||
return de;
|
||||
}
|
||||
|
||||
long telldir(DIR *dir)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
if (d->ofs >= d->nbytes) {
|
||||
d->seekpos = lseek(d->fd, 0, SEEK_CUR);
|
||||
d->ofs = 0;
|
||||
d->nbytes = 0;
|
||||
}
|
||||
/* this relies on seekpos always being a multiple of
|
||||
DIR_BUF_SIZE. Is that always true on BSD systems? */
|
||||
if (d->seekpos & (DIR_BUF_SIZE-1)) {
|
||||
abort();
|
||||
}
|
||||
return d->seekpos + d->ofs;
|
||||
}
|
||||
|
||||
void seekdir(DIR *dir, long ofs)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET);
|
||||
d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE);
|
||||
d->ofs = 0;
|
||||
while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) {
|
||||
if (readdir(dir) == NULL) break;
|
||||
}
|
||||
}
|
||||
|
||||
void rewinddir(DIR *dir)
|
||||
{
|
||||
seekdir(dir, 0);
|
||||
}
|
||||
|
||||
int closedir(DIR *dir)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
int r = close(d->fd);
|
||||
if (r != 0) {
|
||||
return r;
|
||||
}
|
||||
free(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef dirfd
|
||||
/* darn, this is a macro on some systems. */
|
||||
int dirfd(DIR *dir)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
return d->fd;
|
||||
}
|
||||
#endif
|
172
source3/lib/replace/repdir_getdirentries.c
Normal file
172
source3/lib/replace/repdir_getdirentries.c
Normal file
@ -0,0 +1,172 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
Copyright (C) Andrew Tridgell 2005
|
||||
|
||||
** NOTE! The following LGPL license applies to the replace
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/*
|
||||
a replacement for opendir/readdir/telldir/seekdir/closedir for BSD
|
||||
systems using getdirentries
|
||||
|
||||
This is needed because the existing directory handling in FreeBSD
|
||||
and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink()
|
||||
on files in a directory where telldir() has been used. On a block
|
||||
boundary it will occasionally miss a file when seekdir() is used to
|
||||
return to a position previously recorded with telldir().
|
||||
|
||||
This also fixes a severe performance and memory usage problem with
|
||||
telldir() on BSD systems. Each call to telldir() in BSD adds an
|
||||
entry to a linked list, and those entries are cleaned up on
|
||||
closedir(). This means with a large directory closedir() can take an
|
||||
arbitrary amount of time, causing network timeouts as millions of
|
||||
telldir() entries are freed
|
||||
|
||||
Note! This replacement code is not portable. It relies on
|
||||
getdirentries() always leaving the file descriptor at a seek offset
|
||||
that is a multiple of DIR_BUF_SIZE. If the code detects that this
|
||||
doesn't happen then it will abort(). It also does not handle
|
||||
directories with offsets larger than can be stored in a long,
|
||||
|
||||
This code is available under other free software licenses as
|
||||
well. Contact the author.
|
||||
*/
|
||||
|
||||
#include "replace.h"
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#define DIR_BUF_BITS 9
|
||||
#define DIR_BUF_SIZE (1<<DIR_BUF_BITS)
|
||||
|
||||
struct dir_buf {
|
||||
int fd;
|
||||
int nbytes, ofs;
|
||||
off_t seekpos;
|
||||
char buf[DIR_BUF_SIZE];
|
||||
};
|
||||
|
||||
DIR *opendir(const char *dname)
|
||||
{
|
||||
struct dir_buf *d;
|
||||
d = malloc(sizeof(*d));
|
||||
if (d == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
d->fd = open(dname, O_RDONLY);
|
||||
if (d->fd == -1) {
|
||||
free(d);
|
||||
return NULL;
|
||||
}
|
||||
d->ofs = 0;
|
||||
d->seekpos = 0;
|
||||
d->nbytes = 0;
|
||||
return (DIR *)d;
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dir)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
struct dirent *de;
|
||||
|
||||
if (d->ofs >= d->nbytes) {
|
||||
long pos;
|
||||
d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos);
|
||||
d->seekpos = pos;
|
||||
d->ofs = 0;
|
||||
}
|
||||
if (d->ofs >= d->nbytes) {
|
||||
return NULL;
|
||||
}
|
||||
de = (struct dirent *)&d->buf[d->ofs];
|
||||
d->ofs += de->d_reclen;
|
||||
return de;
|
||||
}
|
||||
|
||||
#ifdef TELLDIR_TAKES_CONST_DIR
|
||||
long telldir(const DIR *dir)
|
||||
#else
|
||||
long telldir(DIR *dir)
|
||||
#endif
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
if (d->ofs >= d->nbytes) {
|
||||
d->seekpos = lseek(d->fd, 0, SEEK_CUR);
|
||||
d->ofs = 0;
|
||||
d->nbytes = 0;
|
||||
}
|
||||
/* this relies on seekpos always being a multiple of
|
||||
DIR_BUF_SIZE. Is that always true on BSD systems? */
|
||||
if (d->seekpos & (DIR_BUF_SIZE-1)) {
|
||||
abort();
|
||||
}
|
||||
return d->seekpos + d->ofs;
|
||||
}
|
||||
|
||||
#ifdef SEEKDIR_RETURNS_INT
|
||||
int seekdir(DIR *dir, long ofs)
|
||||
#else
|
||||
void seekdir(DIR *dir, long ofs)
|
||||
#endif
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
long pos;
|
||||
d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET);
|
||||
d->nbytes = getdirentries(d->fd, d->buf, DIR_BUF_SIZE, &pos);
|
||||
d->ofs = 0;
|
||||
while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) {
|
||||
if (readdir(dir) == NULL) break;
|
||||
}
|
||||
#ifdef SEEKDIR_RETURNS_INT
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void rewinddir(DIR *dir)
|
||||
{
|
||||
seekdir(dir, 0);
|
||||
}
|
||||
|
||||
int closedir(DIR *dir)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
int r = close(d->fd);
|
||||
if (r != 0) {
|
||||
return r;
|
||||
}
|
||||
free(d);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef dirfd
|
||||
/* darn, this is a macro on some systems. */
|
||||
int dirfd(DIR *dir)
|
||||
{
|
||||
struct dir_buf *d = (struct dir_buf *)dir;
|
||||
return d->fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
592
source3/lib/replace/replace.c
Normal file
592
source3/lib/replace/replace.c
Normal file
@ -0,0 +1,592 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
replacement routines for broken systems
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
** NOTE! The following LGPL license applies to the replace
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "replace.h"
|
||||
|
||||
#include "system/filesys.h"
|
||||
#include "system/time.h"
|
||||
#include "system/passwd.h"
|
||||
#include "system/syslog.h"
|
||||
#include "system/network.h"
|
||||
#include "system/locale.h"
|
||||
#include "system/wait.h"
|
||||
|
||||
void replace_dummy(void);
|
||||
void replace_dummy(void) {}
|
||||
|
||||
#ifndef HAVE_FTRUNCATE
|
||||
/*******************************************************************
|
||||
ftruncate for operating systems that don't have it
|
||||
********************************************************************/
|
||||
int rep_ftruncate(int f, off_t l)
|
||||
{
|
||||
#ifdef HAVE_CHSIZE
|
||||
return chsize(f,l);
|
||||
#elif defined(F_FREESP)
|
||||
struct flock fl;
|
||||
|
||||
fl.l_whence = 0;
|
||||
fl.l_len = 0;
|
||||
fl.l_start = l;
|
||||
fl.l_type = F_WRLCK;
|
||||
return fcntl(f, F_FREESP, &fl);
|
||||
#else
|
||||
#error "you must have a ftruncate function"
|
||||
#endif
|
||||
}
|
||||
#endif /* HAVE_FTRUNCATE */
|
||||
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
/* like strncpy but does not 0 fill the buffer and always null
|
||||
terminates. bufsize is the size of the destination buffer */
|
||||
size_t rep_strlcpy(char *d, const char *s, size_t bufsize)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
size_t ret = len;
|
||||
if (bufsize <= 0) return 0;
|
||||
if (len >= bufsize) len = bufsize-1;
|
||||
memcpy(d, s, len);
|
||||
d[len] = 0;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
/* like strncat but does not 0 fill the buffer and always null
|
||||
terminates. bufsize is the length of the buffer, which should
|
||||
be one more than the maximum resulting string length */
|
||||
size_t rep_strlcat(char *d, const char *s, size_t bufsize)
|
||||
{
|
||||
size_t len1 = strlen(d);
|
||||
size_t len2 = strlen(s);
|
||||
size_t ret = len1 + len2;
|
||||
|
||||
if (len1+len2 >= bufsize) {
|
||||
len2 = bufsize - (len1+1);
|
||||
}
|
||||
if (len2 > 0) {
|
||||
memcpy(d+len1, s, len2);
|
||||
d[len1+len2] = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKTIME
|
||||
/*******************************************************************
|
||||
a mktime() replacement for those who don't have it - contributed by
|
||||
C.A. Lademann <cal@zls.com>
|
||||
Corrections by richard.kettlewell@kewill.com
|
||||
********************************************************************/
|
||||
|
||||
#define MINUTE 60
|
||||
#define HOUR 60*MINUTE
|
||||
#define DAY 24*HOUR
|
||||
#define YEAR 365*DAY
|
||||
time_t rep_mktime(struct tm *t)
|
||||
{
|
||||
struct tm *u;
|
||||
time_t epoch = 0;
|
||||
int n;
|
||||
int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
|
||||
y, m, i;
|
||||
|
||||
if(t->tm_year < 70)
|
||||
return((time_t)-1);
|
||||
|
||||
n = t->tm_year + 1900 - 1;
|
||||
epoch = (t->tm_year - 70) * YEAR +
|
||||
((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY;
|
||||
|
||||
y = t->tm_year + 1900;
|
||||
m = 0;
|
||||
|
||||
for(i = 0; i < t->tm_mon; i++) {
|
||||
epoch += mon [m] * DAY;
|
||||
if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
|
||||
epoch += DAY;
|
||||
|
||||
if(++m > 11) {
|
||||
m = 0;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
epoch += (t->tm_mday - 1) * DAY;
|
||||
epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec;
|
||||
|
||||
if((u = localtime(&epoch)) != NULL) {
|
||||
t->tm_sec = u->tm_sec;
|
||||
t->tm_min = u->tm_min;
|
||||
t->tm_hour = u->tm_hour;
|
||||
t->tm_mday = u->tm_mday;
|
||||
t->tm_mon = u->tm_mon;
|
||||
t->tm_year = u->tm_year;
|
||||
t->tm_wday = u->tm_wday;
|
||||
t->tm_yday = u->tm_yday;
|
||||
t->tm_isdst = u->tm_isdst;
|
||||
}
|
||||
|
||||
return(epoch);
|
||||
}
|
||||
#endif /* !HAVE_MKTIME */
|
||||
|
||||
|
||||
#ifndef HAVE_INNETGR
|
||||
#if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT)
|
||||
/*
|
||||
* Search for a match in a netgroup. This replaces it on broken systems.
|
||||
*/
|
||||
int rep_innetgr(const char *group, const char *host, const char *user,
|
||||
const char *dom)
|
||||
{
|
||||
char *hst, *usr, *dm;
|
||||
|
||||
setnetgrent(group);
|
||||
while (getnetgrent(&hst, &usr, &dm)) {
|
||||
if (((host == 0) || (hst == 0) || !strcmp(host, hst)) &&
|
||||
((user == 0) || (usr == 0) || !strcmp(user, usr)) &&
|
||||
((dom == 0) || (dm == 0) || !strcmp(dom, dm))) {
|
||||
endnetgrent();
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
endnetgrent();
|
||||
return (0);
|
||||
}
|
||||
#endif /* HAVE_SETNETGRENT HAVE_GETNETGRENT HAVE_ENDNETGRENT */
|
||||
#endif /* HAVE_INNETGR */
|
||||
|
||||
|
||||
|
||||
#ifndef HAVE_INITGROUPS
|
||||
/****************************************************************************
|
||||
some systems don't have an initgroups call
|
||||
****************************************************************************/
|
||||
int rep_initgroups(char *name, gid_t id)
|
||||
{
|
||||
#ifndef HAVE_SETGROUPS
|
||||
/* yikes! no SETGROUPS or INITGROUPS? how can this work? */
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#else /* HAVE_SETGROUPS */
|
||||
|
||||
#include <grp.h>
|
||||
|
||||
gid_t *grouplst = NULL;
|
||||
int max_gr = 32;
|
||||
int ret;
|
||||
int i,j;
|
||||
struct group *g;
|
||||
char *gr;
|
||||
|
||||
if((grouplst = malloc(sizeof(gid_t) * max_gr)) == NULL) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
grouplst[0] = id;
|
||||
i = 1;
|
||||
while (i < max_gr && ((g = (struct group *)getgrent()) != (struct group *)NULL)) {
|
||||
if (g->gr_gid == id)
|
||||
continue;
|
||||
j = 0;
|
||||
gr = g->gr_mem[0];
|
||||
while (gr && (*gr != (char)NULL)) {
|
||||
if (strcmp(name,gr) == 0) {
|
||||
grouplst[i] = g->gr_gid;
|
||||
i++;
|
||||
gr = (char *)NULL;
|
||||
break;
|
||||
}
|
||||
gr = g->gr_mem[++j];
|
||||
}
|
||||
}
|
||||
endgrent();
|
||||
ret = setgroups(i, grouplst);
|
||||
free(grouplst);
|
||||
return ret;
|
||||
#endif /* HAVE_SETGROUPS */
|
||||
}
|
||||
#endif /* HAVE_INITGROUPS */
|
||||
|
||||
|
||||
#if (defined(SecureWare) && defined(SCO))
|
||||
/* This is needed due to needing the nap() function but we don't want
|
||||
to include the Xenix libraries since that will break other things...
|
||||
BTW: system call # 0x0c28 is the same as calling nap() */
|
||||
long nap(long milliseconds) {
|
||||
return syscall(0x0c28, milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
/*******************************************************************
|
||||
safely copies memory, ensuring no overlap problems.
|
||||
this is only used if the machine does not have it's own memmove().
|
||||
this is not the fastest algorithm in town, but it will do for our
|
||||
needs.
|
||||
********************************************************************/
|
||||
void *rep_memmove(void *dest,const void *src,int size)
|
||||
{
|
||||
unsigned long d,s;
|
||||
int i;
|
||||
if (dest==src || !size) return(dest);
|
||||
|
||||
d = (unsigned long)dest;
|
||||
s = (unsigned long)src;
|
||||
|
||||
if ((d >= (s+size)) || (s >= (d+size))) {
|
||||
/* no overlap */
|
||||
memcpy(dest,src,size);
|
||||
return(dest);
|
||||
}
|
||||
|
||||
if (d < s) {
|
||||
/* we can forward copy */
|
||||
if (s-d >= sizeof(int) &&
|
||||
!(s%sizeof(int)) &&
|
||||
!(d%sizeof(int)) &&
|
||||
!(size%sizeof(int))) {
|
||||
/* do it all as words */
|
||||
int *idest = (int *)dest;
|
||||
int *isrc = (int *)src;
|
||||
size /= sizeof(int);
|
||||
for (i=0;i<size;i++) idest[i] = isrc[i];
|
||||
} else {
|
||||
/* simplest */
|
||||
char *cdest = (char *)dest;
|
||||
char *csrc = (char *)src;
|
||||
for (i=0;i<size;i++) cdest[i] = csrc[i];
|
||||
}
|
||||
} else {
|
||||
/* must backward copy */
|
||||
if (d-s >= sizeof(int) &&
|
||||
!(s%sizeof(int)) &&
|
||||
!(d%sizeof(int)) &&
|
||||
!(size%sizeof(int))) {
|
||||
/* do it all as words */
|
||||
int *idest = (int *)dest;
|
||||
int *isrc = (int *)src;
|
||||
size /= sizeof(int);
|
||||
for (i=size-1;i>=0;i--) idest[i] = isrc[i];
|
||||
} else {
|
||||
/* simplest */
|
||||
char *cdest = (char *)dest;
|
||||
char *csrc = (char *)src;
|
||||
for (i=size-1;i>=0;i--) cdest[i] = csrc[i];
|
||||
}
|
||||
}
|
||||
return(dest);
|
||||
}
|
||||
#endif /* HAVE_MEMMOVE */
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
/****************************************************************************
|
||||
duplicate a string
|
||||
****************************************************************************/
|
||||
char *rep_strdup(const char *s)
|
||||
{
|
||||
size_t len;
|
||||
char *ret;
|
||||
|
||||
if (!s) return(NULL);
|
||||
|
||||
len = strlen(s)+1;
|
||||
ret = (char *)malloc(len);
|
||||
if (!ret) return(NULL);
|
||||
memcpy(ret,s,len);
|
||||
return(ret);
|
||||
}
|
||||
#endif /* HAVE_STRDUP */
|
||||
|
||||
#ifndef WITH_PTHREADS
|
||||
/* REWRITE: not thread safe */
|
||||
#ifdef REPLACE_INET_NTOA
|
||||
char *rep_inet_ntoa(struct in_addr ip)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)&ip.s_addr;
|
||||
static char buf[18];
|
||||
slprintf(buf, 17, "%d.%d.%d.%d",
|
||||
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
|
||||
return buf;
|
||||
}
|
||||
#endif /* REPLACE_INET_NTOA */
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETLINEBUF
|
||||
void rep_setlinebuf(FILE *stream)
|
||||
{
|
||||
setvbuf(stream, (char *)NULL, _IOLBF, 0);
|
||||
}
|
||||
#endif /* HAVE_SETLINEBUF */
|
||||
|
||||
#ifndef HAVE_VSYSLOG
|
||||
#ifdef HAVE_SYSLOG
|
||||
void rep_vsyslog (int facility_priority, char *format, va_list arglist)
|
||||
{
|
||||
char *msg = NULL;
|
||||
vasprintf(&msg, format, arglist);
|
||||
if (!msg)
|
||||
return;
|
||||
syslog(facility_priority, "%s", msg);
|
||||
free(msg);
|
||||
}
|
||||
#endif /* HAVE_SYSLOG */
|
||||
#endif /* HAVE_VSYSLOG */
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
/**
|
||||
Some platforms don't have strnlen
|
||||
**/
|
||||
size_t rep_strnlen(const char *s, size_t max)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
for (len = 0; len < max; len++) {
|
||||
if (s[len] == '\0') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
/**
|
||||
Some platforms don't have strndup.
|
||||
**/
|
||||
char *rep_strndup(const char *s, size_t n)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
n = strnlen(s, n);
|
||||
ret = malloc(n+1);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
memcpy(ret, s, n);
|
||||
ret[n] = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WAITPID
|
||||
int rep_waitpid(pid_t pid,int *status,int options)
|
||||
{
|
||||
return wait4(pid, status, options, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETEUID
|
||||
int rep_seteuid(uid_t euid)
|
||||
{
|
||||
#ifdef HAVE_SETRESUID
|
||||
return setresuid(-1, euid, -1);
|
||||
#else
|
||||
# error "You need a seteuid function"
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETEGID
|
||||
int rep_setegid(gid_t egid)
|
||||
{
|
||||
#ifdef HAVE_SETRESGID
|
||||
return setresgid(-1, egid, -1);
|
||||
#else
|
||||
# error "You need a setegid function"
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************
|
||||
os/2 also doesn't have chroot
|
||||
********************************************************************/
|
||||
#ifndef HAVE_CHROOT
|
||||
int rep_chroot(const char *dname)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************
|
||||
Possibly replace mkstemp if it is broken.
|
||||
*****************************************************************/
|
||||
|
||||
#ifndef HAVE_SECURE_MKSTEMP
|
||||
int rep_mkstemp(char *template)
|
||||
{
|
||||
/* have a reasonable go at emulating it. Hope that
|
||||
the system mktemp() isn't completly hopeless */
|
||||
char *p = mktemp(template);
|
||||
if (!p)
|
||||
return -1;
|
||||
return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKDTEMP
|
||||
char *rep_mkdtemp(char *template)
|
||||
{
|
||||
char *dname;
|
||||
|
||||
if ((dname = mktemp(template))) {
|
||||
if (mkdir(dname, 0700) >= 0) {
|
||||
return dname;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PREAD
|
||||
ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset)
|
||||
{
|
||||
if (lseek(__fd, __offset, SEEK_SET) != __offset) {
|
||||
return -1;
|
||||
}
|
||||
return read(__fd, __buf, __nbytes);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PWRITE
|
||||
ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
|
||||
{
|
||||
if (lseek(__fd, __offset, SEEK_SET) != __offset) {
|
||||
return -1;
|
||||
}
|
||||
return write(__fd, __buf, __nbytes);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
char *rep_strcasestr(const char *haystack, const char *needle)
|
||||
{
|
||||
const char *s;
|
||||
size_t nlen = strlen(needle);
|
||||
for (s=haystack;*s;s++) {
|
||||
if (toupper(*needle) == toupper(*s) &&
|
||||
strncasecmp(s, needle, nlen) == 0) {
|
||||
return (char *)((intptr_t)s);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOK_R
|
||||
/* based on GLIBC version, copyright Free Software Foundation */
|
||||
char *rep_strtok_r(char *s, const char *delim, char **save_ptr)
|
||||
{
|
||||
char *token;
|
||||
|
||||
if (s == NULL) s = *save_ptr;
|
||||
|
||||
s += strspn(s, delim);
|
||||
if (*s == '\0') {
|
||||
*save_ptr = s;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
token = s;
|
||||
s = strpbrk(token, delim);
|
||||
if (s == NULL) {
|
||||
*save_ptr = token + strlen(token);
|
||||
} else {
|
||||
*s = '\0';
|
||||
*save_ptr = s + 1;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOLL
|
||||
long long int rep_strtoll(const char *str, char **endptr, int base)
|
||||
{
|
||||
#ifdef HAVE_STRTOQ
|
||||
return strtoq(str, endptr, base);
|
||||
#elif defined(HAVE___STRTOLL)
|
||||
return __strtoll(str, endptr, base);
|
||||
#elif SIZEOF_LONG == SIZEOF_LONG_LONG
|
||||
return (long long int) strtol(str, endptr, base);
|
||||
#else
|
||||
# error "You need a strtoll function"
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_STRTOULL
|
||||
unsigned long long int rep_strtoull(const char *str, char **endptr, int base)
|
||||
{
|
||||
#ifdef HAVE_STRTOUQ
|
||||
return strtouq(str, endptr, base);
|
||||
#elif defined(HAVE___STRTOULL)
|
||||
return __strtoull(str, endptr, base);
|
||||
#elif SIZEOF_LONG == SIZEOF_LONG_LONG
|
||||
return (unsigned long long int) strtoul(str, endptr, base);
|
||||
#else
|
||||
# error "You need a strtoull function"
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETENV
|
||||
int rep_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
char *p;
|
||||
size_t l1, l2;
|
||||
int ret;
|
||||
|
||||
if (!overwrite && getenv(name)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
l1 = strlen(name);
|
||||
l2 = strlen(value);
|
||||
|
||||
p = malloc(l1+l2+2);
|
||||
if (p == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(p, name, l1);
|
||||
p[l1] = '=';
|
||||
memcpy(p+l1+1, value, l2);
|
||||
p[l1+l2+1] = 0;
|
||||
|
||||
ret = putenv(p);
|
||||
if (ret != 0) {
|
||||
free(p);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
367
source3/lib/replace/replace.h
Normal file
367
source3/lib/replace/replace.h
Normal file
@ -0,0 +1,367 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
macros to go along with the lib/replace/ portability layer code
|
||||
|
||||
Copyright (C) Andrew Tridgell 2005
|
||||
Copyright (C) Jelmer Vernooij 2006
|
||||
|
||||
** NOTE! The following LGPL license applies to the replace
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _LIBREPLACE_REPLACE_H
|
||||
#define _LIBREPLACE_REPLACE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_STANDARDS_H
|
||||
#include <standards.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#include "win32_replace.h"
|
||||
#endif
|
||||
|
||||
#ifdef __COMPAR_FN_T
|
||||
#define QSORT_CAST (__compar_fn_t)
|
||||
#endif
|
||||
|
||||
#ifndef QSORT_CAST
|
||||
#define QSORT_CAST (int (*)(const void *, const void *))
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
/* force off HAVE_INTTYPES_H so that roken doesn't try to include both,
|
||||
which causes a warning storm on irix */
|
||||
#undef HAVE_INTTYPES_H
|
||||
#elif HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
extern char *sys_errlist[];
|
||||
#define strerror(i) sys_errlist[i]
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ERRNO_DECL
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
#define strdup rep_strdup
|
||||
char *rep_strdup(const char *s);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
#define memmove rep_memmove
|
||||
void *rep_memmove(void *dest,const void *src,int size);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM)
|
||||
#include "system/time.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKTIME
|
||||
#define mktime rep_mktime
|
||||
time_t rep_mktime(struct tm *t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_TIMEGM
|
||||
struct tm;
|
||||
#define timegm rep_timegm
|
||||
time_t rep_timegm(struct tm *tm);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#define strlcpy rep_strlcpy
|
||||
size_t rep_strlcpy(char *d, const char *s, size_t bufsize);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
#define strlcat rep_strlcat
|
||||
size_t rep_strlcat(char *d, const char *s, size_t bufsize);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
#define strndup rep_strndup
|
||||
char *rep_strndup(const char *s, size_t n);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
#define strnlen rep_strnlen
|
||||
size_t rep_strnlen(const char *s, size_t n);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETENV
|
||||
#define setenv rep_setenv
|
||||
int rep_setenv(const char *name, const char *value, int overwrite);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETEUID
|
||||
#define seteuid rep_seteuid
|
||||
int rep_seteuid(uid_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETEGID
|
||||
#define setegid rep_setegid
|
||||
int rep_setegid(gid_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SETLINEBUF
|
||||
#define setlinebuf rep_setlinebuf
|
||||
void rep_setlinebuf(FILE *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
#define strcasestr rep_strcasestr
|
||||
char *rep_strcasestr(const char *haystack, const char *needle);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOK_R
|
||||
#define strtok_r rep_strtok_r
|
||||
char *rep_strtok_r(char *s, const char *delim, char **save_ptr);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOLL
|
||||
#define strtoll rep_strtoll
|
||||
long long int rep_strtoll(const char *str, char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOULL
|
||||
#define strtoull rep_strtoull
|
||||
unsigned long long int rep_strtoull(const char *str, char **endptr, int base);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FTRUNCATE
|
||||
#define ftruncate rep_ftruncate
|
||||
int rep_ftruncate(int,off_t);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INITGROUPS
|
||||
#define ftruncate rep_ftruncate
|
||||
int rep_initgroups(char *name, gid_t id);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BZERO) && defined(HAVE_MEMSET)
|
||||
#define bzero(a,b) memset((a),'\0',(b))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DLERROR
|
||||
#define dlerror rep_dlerror
|
||||
char *rep_dlerror(void);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DLOPEN
|
||||
#define dlopen rep_dlopen
|
||||
void *rep_dlopen(const char *name, int flags);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DLSYM
|
||||
#define dlsym rep_dlsym
|
||||
void *rep_dlsym(void *handle, const char *symbol);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_DLCLOSE
|
||||
#define dlclose rep_dlclose
|
||||
int rep_dlclose(void *handle);
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PRINTF_ATTRIBUTE
|
||||
#if __GNUC__ >= 3
|
||||
/** Use gcc attribute to check printf fns. a1 is the 1-based index of
|
||||
* the parameter containing the format, and a2 the index of the first
|
||||
* argument. Note that some gcc 2.x versions don't handle this
|
||||
* properly **/
|
||||
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
|
||||
#else
|
||||
#define PRINTF_ATTRIBUTE(a1, a2)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
#define vasprintf rep_vasprintf
|
||||
int rep_vasprintf(char **ptr, const char *format, va_list ap);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
|
||||
#define snprintf rep_snprintf
|
||||
int rep_snprintf(char *,size_t ,const char *, ...) PRINTF_ATTRIBUTE(3,4);
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
|
||||
#define vsnprintf rep_vsnprintf
|
||||
int rep_vsnprintf(char *,size_t ,const char *, va_list ap);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ASPRINTF
|
||||
#define asprintf rep_asprintf
|
||||
int rep_asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
|
||||
#endif
|
||||
|
||||
|
||||
/* we used to use these fns, but now we have good replacements
|
||||
for snprintf and vsnprintf */
|
||||
#define slprintf snprintf
|
||||
|
||||
|
||||
#ifndef HAVE_VA_COPY
|
||||
#undef va_copy
|
||||
#ifdef HAVE___VA_COPY
|
||||
#define va_copy(dest, src) __va_copy(dest, src)
|
||||
#else
|
||||
#define va_copy(dest, src) (dest) = (src)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VOLATILE
|
||||
#define volatile
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_COMPARISON_FN_T
|
||||
typedef int (*comparison_fn_t)(const void *, const void *);
|
||||
#endif
|
||||
|
||||
/* Load header file for dynamic linking stuff */
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#ifndef RTLD_LAZY
|
||||
#define RTLD_LAZY 0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SECURE_MKSTEMP
|
||||
#define mkstemp(path) rep_mkstemp(path)
|
||||
int rep_mkstemp(char *temp);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKDTEMP
|
||||
#define mkdtemp rep_mkdtemp
|
||||
char *rep_mkdtemp(char *template);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/* The extra casts work around common compiler bugs. */
|
||||
#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
|
||||
It is necessary at least when t == time_t. */
|
||||
#define _TYPE_MINIMUM(t) ((t) (_TYPE_SIGNED (t) \
|
||||
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
|
||||
#define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t)))
|
||||
|
||||
#ifndef HOST_NAME_MAX
|
||||
#define HOST_NAME_MAX 64
|
||||
#endif
|
||||
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX 65535
|
||||
#endif
|
||||
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX (4294967295U)
|
||||
#endif
|
||||
|
||||
#ifndef UINT64_MAX
|
||||
#define UINT64_MAX ((uint64_t)-1)
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
#define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX _TYPE_MAXIMUM(int32_t)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_BOOL)
|
||||
#ifdef HAVE__Bool
|
||||
#define bool _Bool
|
||||
#else
|
||||
#define __bool_true_false_are_defined
|
||||
typedef int bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef true
|
||||
#define true (1)
|
||||
#endif
|
||||
#ifndef false
|
||||
#define false (0)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FUNCTION_MACRO
|
||||
#ifdef HAVE_func_MACRO
|
||||
#define __FUNCTION__ __func__
|
||||
#else
|
||||
#define __FUNCTION__ ("")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef __STRING
|
||||
#define __STRING(x) #x
|
||||
#endif
|
||||
|
||||
#if MMAP_BLACKLIST
|
||||
#undef HAVE_MMAP
|
||||
#endif
|
||||
|
||||
#endif /* _LIBREPLACE_REPLACE_H */
|
23
source3/lib/replace/samba.m4
Normal file
23
source3/lib/replace/samba.m4
Normal file
@ -0,0 +1,23 @@
|
||||
AC_LIBREPLACE_BROKEN_CHECKS
|
||||
|
||||
SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}])
|
||||
SMB_ENABLE(LIBREPLACE_EXT)
|
||||
|
||||
LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'`
|
||||
|
||||
LIBREPLACE_OBJS=""
|
||||
for obj in ${LIBREPLACEOBJ}; do
|
||||
LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}"
|
||||
done
|
||||
|
||||
SMB_SUBSYSTEM(LIBREPLACE,
|
||||
[${LIBREPLACE_OBJS}],
|
||||
[LIBREPLACE_EXT],
|
||||
[-Ilib/replace])
|
||||
|
||||
LIBREPLACE_HOSTCC_OBJS=`echo ${LIBREPLACE_OBJS} |sed -e 's/\.o/\.ho/g'`
|
||||
|
||||
SMB_SUBSYSTEM(LIBREPLACE_HOSTCC,
|
||||
[${LIBREPLACE_HOSTCC_OBJS}],
|
||||
[],
|
||||
[-Ilib/replace])
|
@ -103,11 +103,8 @@
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
#ifndef NO_CONFIG_H
|
||||
#include "config.h"
|
||||
#else
|
||||
#define NULL 0
|
||||
#endif
|
||||
#include "replace.h"
|
||||
#include "system/locale.h"
|
||||
|
||||
#ifdef TEST_SNPRINTF /* need math library headers for testing */
|
||||
|
||||
@ -121,22 +118,6 @@
|
||||
# include <math.h>
|
||||
#endif /* TEST_SNPRINTF */
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
|
||||
/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
|
||||
#include <stdio.h>
|
||||
@ -145,6 +126,9 @@
|
||||
void dummy_snprintf(void) {}
|
||||
#endif /* HAVE_SNPRINTF, etc */
|
||||
|
||||
/* yes this really must be a ||. Don't muck with this (tridge) */
|
||||
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
|
||||
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
#define LDOUBLE long double
|
||||
#else
|
||||
@ -217,9 +201,6 @@
|
||||
#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
|
||||
#endif
|
||||
|
||||
/* yes this really must be a ||. Don't muck with this (tridge) */
|
||||
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
|
||||
|
||||
struct pr_chunk {
|
||||
int type; /* chunk type */
|
||||
int num; /* parameter number */
|
||||
@ -243,7 +224,7 @@ struct pr_chunk_x {
|
||||
int num;
|
||||
};
|
||||
|
||||
static size_t dopr(char *buffer, size_t maxlen, const char *format,
|
||||
static int dopr(char *buffer, size_t maxlen, const char *format,
|
||||
va_list args_in);
|
||||
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max);
|
||||
@ -256,7 +237,7 @@ static struct pr_chunk *new_chunk(void);
|
||||
static int add_cnk_list_entry(struct pr_chunk_x **list,
|
||||
int max_num, struct pr_chunk *chunk);
|
||||
|
||||
static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
|
||||
static int dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
|
||||
{
|
||||
char ch;
|
||||
int state;
|
||||
@ -270,7 +251,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
|
||||
struct pr_chunk *cnk = NULL;
|
||||
struct pr_chunk_x *clist = NULL;
|
||||
int max_pos;
|
||||
size_t ret = -1;
|
||||
int ret = -1;
|
||||
|
||||
VA_COPY(args, args_in);
|
||||
|
||||
@ -638,7 +619,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args
|
||||
break;
|
||||
|
||||
case CNK_PTR:
|
||||
cnk->strvalue = (char *)va_arg (args, void *);
|
||||
cnk->strvalue = va_arg (args, void *);
|
||||
for (i = 1; i < clist[pnum].num; i++) {
|
||||
clist[pnum].chunks[i]->strvalue = cnk->strvalue;
|
||||
}
|
||||
@ -933,7 +914,7 @@ static LLONG ROUND(LDOUBLE value)
|
||||
static double my_modf(double x0, double *iptr)
|
||||
{
|
||||
int i;
|
||||
LLONG l;
|
||||
LLONG l=0;
|
||||
double x = x0;
|
||||
double f = 1.0;
|
||||
|
||||
@ -1203,11 +1184,10 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
|
||||
return max;
|
||||
}
|
||||
|
||||
int smb_vsnprintf (char *str, size_t count, const char *fmt, va_list args)
|
||||
int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
|
||||
{
|
||||
return dopr(str, count, fmt, args);
|
||||
}
|
||||
#define vsnprintf smb_vsnprintf
|
||||
#endif
|
||||
|
||||
/* yes this really must be a ||. Don't muck with this (tridge)
|
||||
@ -1217,7 +1197,7 @@ static int add_cnk_list_entry(struct pr_chunk_x **list,
|
||||
* that doesn't work properly according to the autoconf test.
|
||||
*/
|
||||
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
|
||||
int smb_snprintf(char *str,size_t count,const char *fmt,...)
|
||||
int snprintf(char *str,size_t count,const char *fmt,...)
|
||||
{
|
||||
size_t ret;
|
||||
va_list ap;
|
||||
@ -1227,7 +1207,48 @@ int smb_snprintf(char *str,size_t count,const char *fmt,...)
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
#define snprintf smb_snprintf
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_C99_VSNPRINTF
|
||||
int printf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
char *s;
|
||||
|
||||
s = NULL;
|
||||
va_start(ap, fmt);
|
||||
ret = vasprintf(&s, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (s) {
|
||||
fwrite(s, 1, strlen(s), stdout);
|
||||
}
|
||||
free(s);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_C99_VSNPRINTF
|
||||
int fprintf(FILE *stream, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
char *s;
|
||||
|
||||
s = NULL;
|
||||
va_start(ap, fmt);
|
||||
ret = vasprintf(&s, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (s) {
|
||||
fwrite(s, 1, strlen(s), stream);
|
||||
}
|
||||
free(s);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
4
source3/lib/replace/system/README
Normal file
4
source3/lib/replace/system/README
Normal file
@ -0,0 +1,4 @@
|
||||
This directory contains wrappers around logical groups of system
|
||||
include files. The idea is to avoid #ifdef blocks in the main code,
|
||||
and instead put all the necessary conditional includes in subsystem
|
||||
specific header files in this directory.
|
41
source3/lib/replace/system/capability.h
Normal file
41
source3/lib/replace/system/capability.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef _system_capability_h
|
||||
#define _system_capability_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
capability system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SYS_CAPABILITY_H
|
||||
|
||||
#if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H)
|
||||
#define _I386_STATFS_H
|
||||
#define BROKEN_REDHAT_7_STATFS_WORKAROUND
|
||||
#endif
|
||||
|
||||
#include <sys/capability.h>
|
||||
|
||||
#ifdef BROKEN_REDHAT_7_STATFS_WORKAROUND
|
||||
#undef _I386_STATFS_H
|
||||
#undef BROKEN_REDHAT_7_STATFS_WORKAROUND
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
31
source3/lib/replace/system/config.m4
Normal file
31
source3/lib/replace/system/config.m4
Normal file
@ -0,0 +1,31 @@
|
||||
# filesys
|
||||
AC_HEADER_DIRENT
|
||||
AC_CHECK_HEADERS(fcntl.h sys/fcntl.h sys/acl.h sys/resource.h sys/ioctl.h sys/mode.h sys/filio.h sys/fs/s5param.h sys/filsys.h )
|
||||
|
||||
# select
|
||||
AC_CHECK_HEADERS(sys/select.h)
|
||||
|
||||
# time
|
||||
AC_CHECK_HEADERS(sys/time.h utime.h)
|
||||
AC_HEADER_TIME
|
||||
|
||||
# wait
|
||||
AC_HEADER_SYS_WAIT
|
||||
|
||||
# capability
|
||||
AC_CHECK_HEADERS(sys/capability.h)
|
||||
|
||||
# passwd
|
||||
AC_CHECK_HEADERS(grp.h sys/id.h compat.h shadow.h sys/priv.h pwd.h sys/security.h)
|
||||
|
||||
# locale
|
||||
AC_CHECK_HEADERS(ctype.h locale.h)
|
||||
|
||||
# glob
|
||||
AC_CHECK_HEADERS(fnmatch.h)
|
||||
|
||||
# shmem
|
||||
AC_CHECK_HEADERS(sys/ipc.h sys/mman.h sys/shm.h )
|
||||
|
||||
# terminal
|
||||
AC_CHECK_HEADERS(termios.h termio.h sys/termio.h )
|
64
source3/lib/replace/system/dir.h
Normal file
64
source3/lib/replace/system/dir.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef _system_dir_h
|
||||
#define _system_dir_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
directory system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
# define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
#else
|
||||
# define dirent direct
|
||||
# define NAMLEN(dirent) (dirent)->d_namlen
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MKDIR_MODE
|
||||
#define mkdir(dir, mode) mkdir(dir)
|
||||
#endif
|
||||
|
||||
/* Test whether a file name is the "." or ".." directory entries.
|
||||
* These really should be inline functions.
|
||||
*/
|
||||
#ifndef ISDOT
|
||||
#define ISDOT(path) ( \
|
||||
*((const char *)(path)) == '.' && \
|
||||
*(((const char *)(path)) + 1) == '\0' \
|
||||
)
|
||||
#endif
|
||||
|
||||
#ifndef ISDOTDOT
|
||||
#define ISDOTDOT(path) ( \
|
||||
*((const char *)(path)) == '.' && \
|
||||
*(((const char *)(path)) + 1) == '.' && \
|
||||
*(((const char *)(path)) + 2) == '\0' \
|
||||
)
|
||||
#endif
|
||||
|
||||
#endif
|
170
source3/lib/replace/system/filesys.h
Normal file
170
source3/lib/replace/system/filesys.h
Normal file
@ -0,0 +1,170 @@
|
||||
#ifndef _system_filesys_h
|
||||
#define _system_filesys_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
filesystem system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_MOUNT_H
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_VFS_H
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_ACL_H
|
||||
#include <sys/acl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FS_S5PARAM_H
|
||||
#include <sys/fs/s5param.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SYS_FILSYS_H) && !defined (_CRAY)
|
||||
#include <sys/filsys.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STATFS_H
|
||||
# include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DUSTAT_H
|
||||
#include <sys/dustat.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STATVFS_H
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_FILIO_H
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
#include <sys/file.h>
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_FCNTL_H
|
||||
#include <sys/fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_MODE_H
|
||||
/* apparently AIX needs this for S_ISLNK */
|
||||
#ifndef S_ISLNK
|
||||
#include <sys/mode.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Veritas File System. Often in addition to native.
|
||||
* Quotas different.
|
||||
*/
|
||||
#if defined(HAVE_SYS_FS_VX_QUOTA_H)
|
||||
#define VXFS_QUOTA
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_ATTRIBUTES_H
|
||||
#include <sys/attributes.h>
|
||||
#endif
|
||||
|
||||
/* mutually exclusive (SuSE 8.2) */
|
||||
#if HAVE_ATTR_XATTR_H
|
||||
#include <attr/xattr.h>
|
||||
#elif HAVE_SYS_XATTR_H
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
/* Some POSIX definitions for those without */
|
||||
|
||||
#ifndef S_IFDIR
|
||||
#define S_IFDIR 0x4000
|
||||
#endif
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(mode) ((mode & 0xF000) == S_IFDIR)
|
||||
#endif
|
||||
#ifndef S_IRWXU
|
||||
#define S_IRWXU 00700 /* read, write, execute: owner */
|
||||
#endif
|
||||
#ifndef S_IRUSR
|
||||
#define S_IRUSR 00400 /* read permission: owner */
|
||||
#endif
|
||||
#ifndef S_IWUSR
|
||||
#define S_IWUSR 00200 /* write permission: owner */
|
||||
#endif
|
||||
#ifndef S_IXUSR
|
||||
#define S_IXUSR 00100 /* execute permission: owner */
|
||||
#endif
|
||||
#ifndef S_IRWXG
|
||||
#define S_IRWXG 00070 /* read, write, execute: group */
|
||||
#endif
|
||||
#ifndef S_IRGRP
|
||||
#define S_IRGRP 00040 /* read permission: group */
|
||||
#endif
|
||||
#ifndef S_IWGRP
|
||||
#define S_IWGRP 00020 /* write permission: group */
|
||||
#endif
|
||||
#ifndef S_IXGRP
|
||||
#define S_IXGRP 00010 /* execute permission: group */
|
||||
#endif
|
||||
#ifndef S_IRWXO
|
||||
#define S_IRWXO 00007 /* read, write, execute: other */
|
||||
#endif
|
||||
#ifndef S_IROTH
|
||||
#define S_IROTH 00004 /* read permission: other */
|
||||
#endif
|
||||
#ifndef S_IWOTH
|
||||
#define S_IWOTH 00002 /* write permission: other */
|
||||
#endif
|
||||
#ifndef S_IXOTH
|
||||
#define S_IXOTH 00001 /* execute permission: other */
|
||||
#endif
|
||||
|
||||
#ifndef O_ACCMODE
|
||||
#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 256
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
|
||||
#endif
|
33
source3/lib/replace/system/glob.h
Normal file
33
source3/lib/replace/system/glob.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef _system_glob_h
|
||||
#define _system_glob_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
glob system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
#include <glob.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FNMATCH_H
|
||||
#include <fnmatch.h>
|
||||
#endif
|
||||
|
||||
#endif
|
40
source3/lib/replace/system/iconv.h
Normal file
40
source3/lib/replace/system/iconv.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef _system_iconv_h
|
||||
#define _system_iconv_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
iconv memory system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NATIVE_ICONV
|
||||
#ifdef HAVE_ICONV_H
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
#ifdef HAVE_GICONV_H
|
||||
#include <giconv.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* needed for some systems without iconv. Doesn't really matter
|
||||
what error code we use */
|
||||
#ifndef EILSEQ
|
||||
#define EILSEQ EIO
|
||||
#endif
|
||||
|
||||
#endif
|
133
source3/lib/replace/system/kerberos.h
Normal file
133
source3/lib/replace/system/kerberos.h
Normal file
@ -0,0 +1,133 @@
|
||||
#ifndef _system_kerberos_h
|
||||
#define _system_kerberos_h
|
||||
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
kerberos system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_KRB5
|
||||
/* Whether the krb5_address struct has a addrtype property */
|
||||
/* #undef HAVE_ADDRTYPE_IN_KRB5_ADDRESS */
|
||||
/* Whether the krb5_address struct has a addr_type property */
|
||||
#define HAVE_ADDR_TYPE_IN_KRB5_ADDRESS 1
|
||||
/* Define to 1 if you have the `gsskrb5_extract_authz_data_from_sec_context' */
|
||||
#define HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT 1
|
||||
/* Define to 1 if you have the `gsskrb5_get_initiator_subkey' function. */
|
||||
#define HAVE_GSSKRB5_GET_INITIATOR_SUBKEY 1
|
||||
/* Define to 1 if you have the `gsskrb5_register_acceptor_identity' function. */
|
||||
#define HAVE_GSSKRB5_REGISTER_ACCEPTOR_IDENTITY 1
|
||||
/* Define to 1 if you have the `gss_krb5_ccache_name' function. */
|
||||
#define HAVE_GSS_KRB5_CCACHE_NAME 1
|
||||
/* Define to 1 if you have the `krb5_addlog_func' function. */
|
||||
#define HAVE_KRB5_ADDLOG_FUNC 1
|
||||
/* Define to 1 if you have the `krb5_auth_con_setkey' function. */
|
||||
#define HAVE_KRB5_AUTH_CON_SETKEY 1
|
||||
/* Define to 1 if you have the `krb5_auth_con_setuseruserkey' function. */
|
||||
/* #undef HAVE_KRB5_AUTH_CON_SETUSERUSERKEY */
|
||||
/* Define to 1 if you have the `krb5_c_enctype_compare' function. */
|
||||
#define HAVE_KRB5_C_ENCTYPE_COMPARE 1
|
||||
/* Define to 1 if you have the `krb5_c_verify_checksum' function. */
|
||||
#define HAVE_KRB5_C_VERIFY_CHECKSUM 1
|
||||
/* Whether the type krb5_encrypt_block exists */
|
||||
/* #undef HAVE_KRB5_ENCRYPT_BLOCK */
|
||||
/* Define to 1 if you have the `krb5_encrypt_data' function. */
|
||||
/* #undef HAVE_KRB5_ENCRYPT_DATA */
|
||||
/* Define to 1 if you have the `krb5_enctypes_compatible_keys' function. */
|
||||
#define HAVE_KRB5_ENCTYPES_COMPATIBLE_KEYS 1
|
||||
/* Define to 1 if you have the `krb5_free_data_contents' function. */
|
||||
#define HAVE_KRB5_FREE_DATA_CONTENTS 1
|
||||
/* Define to 1 if you have the `krb5_free_error_string' function. */
|
||||
#define HAVE_KRB5_FREE_ERROR_STRING 1
|
||||
/* Define to 1 if you have the `krb5_free_keytab_entry_contents' function. */
|
||||
/* #undef HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS */
|
||||
/* Define to 1 if you have the `krb5_free_ktypes' function. */
|
||||
/* #undef HAVE_KRB5_FREE_KTYPES */
|
||||
/* Define to 1 if you have the `krb5_free_unparsed_name' function. */
|
||||
/* #undef HAVE_KRB5_FREE_UNPARSED_NAME */
|
||||
/* Define to 1 if you have the `krb5_get_default_in_tkt_etypes' function. */
|
||||
#define HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES 1
|
||||
/* Define to 1 if you have the `krb5_get_error_string' function. */
|
||||
#define HAVE_KRB5_GET_ERROR_STRING 1
|
||||
/* Define to 1 if you have the `krb5_get_permitted_enctypes' function. */
|
||||
/* #undef HAVE_KRB5_GET_PERMITTED_ENCTYPES */
|
||||
/* Define to 1 if you have the `krb5_get_pw_salt' function. */
|
||||
#define HAVE_KRB5_GET_PW_SALT 1
|
||||
/* Define to 1 if you have the <krb5.h> header file. */
|
||||
#define HAVE_KRB5_H 1
|
||||
/* Define to 1 if you have the `krb5_initlog' function. */
|
||||
#define HAVE_KRB5_INITLOG 1
|
||||
/* Define to 1 if you have the `krb5_kdc_default_config' function. */
|
||||
#define HAVE_KRB5_KDC_DEFAULT_CONFIG 1
|
||||
/* Whether the krb5_creds struct has a keyblock property */
|
||||
/* #undef HAVE_KRB5_KEYBLOCK_IN_CREDS */
|
||||
/* Whether the krb5_keyblock struct has a keyvalue property */
|
||||
#define HAVE_KRB5_KEYBLOCK_KEYVALUE 1
|
||||
/* Whether krb5_keytab_entry has key member */
|
||||
/* #undef HAVE_KRB5_KEYTAB_ENTRY_KEY */
|
||||
/* Whether krb5_keytab_entry has keyblock member */
|
||||
#define HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK 1
|
||||
/* Define to 1 if you have the `krb5_krbhst_get_addrinfo' function. */
|
||||
#define HAVE_KRB5_KRBHST_GET_ADDRINFO 1
|
||||
/* Define to 1 if you have the `krb5_kt_compare' function. */
|
||||
#define HAVE_KRB5_KT_COMPARE 1
|
||||
/* Define to 1 if you have the `krb5_kt_free_entry' function. */
|
||||
#define HAVE_KRB5_KT_FREE_ENTRY 1
|
||||
/* Whether the type krb5_log_facility exists */
|
||||
#define HAVE_KRB5_LOG_FACILITY 1
|
||||
/* Define to 1 if you have the `krb5_mk_req_extended' function. */
|
||||
#define HAVE_KRB5_MK_REQ_EXTENDED 1
|
||||
/* Define to 1 if you have the `krb5_principal2salt' function. */
|
||||
/* #undef HAVE_KRB5_PRINCIPAL2SALT */
|
||||
/* Define to 1 if you have the `krb5_principal_get_comp_string' function. */
|
||||
#define HAVE_KRB5_PRINCIPAL_GET_COMP_STRING 1
|
||||
/* Whether krb5_princ_component is available */
|
||||
/* #undef HAVE_KRB5_PRINC_COMPONENT */
|
||||
/* Whether the krb5_creds struct has a session property */
|
||||
#define HAVE_KRB5_SESSION_IN_CREDS 1
|
||||
/* Define to 1 if you have the `krb5_set_default_in_tkt_etypes' function. */
|
||||
#define HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES 1
|
||||
/* Define to 1 if you have the `krb5_set_default_tgs_ktypes' function. */
|
||||
/* #undef HAVE_KRB5_SET_DEFAULT_TGS_KTYPES */
|
||||
/* Define to 1 if you have the `krb5_set_real_time' function. */
|
||||
#define HAVE_KRB5_SET_REAL_TIME 1
|
||||
/* Define to 1 if you have the `krb5_set_warn_dest' function. */
|
||||
#define HAVE_KRB5_SET_WARN_DEST 1
|
||||
/* Define to 1 if you have the `krb5_string_to_key' function. */
|
||||
#define HAVE_KRB5_STRING_TO_KEY 1
|
||||
/* Define to 1 if you have the `krb5_string_to_key_salt' function. */
|
||||
#define HAVE_KRB5_STRING_TO_KEY_SALT 1
|
||||
/* Define to 1 if you have the `krb5_ticket_get_authorization_data_type' */
|
||||
#define HAVE_KRB5_TICKET_GET_AUTHORIZATION_DATA_TYPE 1
|
||||
/* Whether the krb5_ticket struct has a enc_part2 property */
|
||||
/* #undef HAVE_KRB5_TKT_ENC_PART2 */
|
||||
/* Define to 1 if you have the `krb5_use_enctype' function. */
|
||||
/* #undef HAVE_KRB5_USE_ENCTYPE */
|
||||
/* Define to 1 if you have the `krb5_verify_checksum' function. */
|
||||
#define HAVE_KRB5_VERIFY_CHECKSUM 1
|
||||
/* Whether krb5_princ_realm returns krb5_realm or krb5_data */
|
||||
#define KRB5_PRINC_REALM_RETURNS_REALM 1
|
||||
|
||||
#include "heimdal/lib/krb5/krb5.h"
|
||||
#include "heimdal/lib/gssapi/gssapi.h"
|
||||
#include "heimdal/lib/com_err/com_err.h"
|
||||
#endif
|
||||
|
||||
#endif
|
34
source3/lib/replace/system/locale.h
Normal file
34
source3/lib/replace/system/locale.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef _system_locale_h
|
||||
#define _system_locale_h
|
||||
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
locale include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#endif
|
105
source3/lib/replace/system/network.h
Normal file
105
source3/lib/replace/system/network.h
Normal file
@ -0,0 +1,105 @@
|
||||
#ifndef _system_network_h
|
||||
#define _system_network_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
networking system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNIXSOCKET
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_TCP_H
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The next three defines are needed to access the IPTOS_* options
|
||||
* on some systems.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NETINET_IN_SYSTM_H
|
||||
#include <netinet/in_systm.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_IP_H
|
||||
#include <netinet/in_ip.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IP_H
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NET_IF_H
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
#ifdef SOCKET_WRAPPER
|
||||
#ifndef SOCKET_WRAPPER_NOT_REPLACE
|
||||
#define SOCKET_WRAPPER_REPLACE
|
||||
#endif
|
||||
#include "lib/socket_wrapper/socket_wrapper.h"
|
||||
#endif
|
||||
|
||||
#ifdef REPLACE_INET_NTOA
|
||||
char *rep_inet_ntoa(struct in_addr ip);
|
||||
#define inet_ntoa rep_inet_ntoa
|
||||
#endif
|
||||
|
||||
/*
|
||||
* glibc on linux doesn't seem to have MSG_WAITALL
|
||||
* defined. I think the kernel has it though..
|
||||
*/
|
||||
#ifndef MSG_WAITALL
|
||||
#define MSG_WAITALL 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some older systems seem not to have MAXHOSTNAMELEN
|
||||
* defined.
|
||||
*/
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
#define MAXHOSTNAMELEN 254
|
||||
#endif
|
||||
|
||||
#ifndef INADDR_LOOPBACK
|
||||
#define INADDR_LOOPBACK 0x7f000001
|
||||
#endif
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
#endif
|
91
source3/lib/replace/system/passwd.h
Normal file
91
source3/lib/replace/system/passwd.h
Normal file
@ -0,0 +1,91 @@
|
||||
#ifndef _system_passwd_h
|
||||
#define _system_passwd_h
|
||||
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
passwd system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PRIV_H
|
||||
#include <sys/priv.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_ID_H
|
||||
#include <sys/id.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CRYPT_H
|
||||
#include <crypt.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHADOW_H
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SECURITY_H
|
||||
#include <sys/security.h>
|
||||
#include <prot.h>
|
||||
#define PASSWORD_LENGTH 16
|
||||
#endif /* HAVE_SYS_SECURITY_H */
|
||||
|
||||
#ifdef HAVE_GETPWANAM
|
||||
#include <sys/label.h>
|
||||
#include <sys/audit.h>
|
||||
#include <pwdadj.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COMPAT_H
|
||||
#include <compat.h>
|
||||
#endif
|
||||
|
||||
#ifdef REPLACE_GETPASS
|
||||
#define getpass(prompt) getsmbpass((prompt))
|
||||
#endif
|
||||
|
||||
#ifndef NGROUPS_MAX
|
||||
#define NGROUPS_MAX 32 /* Guess... */
|
||||
#endif
|
||||
|
||||
/* what is the longest significant password available on your system?
|
||||
Knowing this speeds up password searches a lot */
|
||||
#ifndef PASSWORD_LENGTH
|
||||
#define PASSWORD_LENGTH 8
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PUTPRPWNAM) && defined(AUTH_CLEARTEXT_SEG_CHARS)
|
||||
#define OSF1_ENH_SEC 1
|
||||
#endif
|
||||
|
||||
#ifndef ALLOW_CHANGE_PASSWORD
|
||||
#if (defined(HAVE_TERMIOS_H) && defined(HAVE_DUP2) && defined(HAVE_SETSID))
|
||||
#define ALLOW_CHANGE_PASSWORD 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CRYPT16) && defined(HAVE_GETAUTHUID)
|
||||
#define ULTRIX_AUTH 1
|
||||
#endif
|
||||
|
||||
#endif
|
46
source3/lib/replace/system/printing.h
Normal file
46
source3/lib/replace/system/printing.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef _system_printing_h
|
||||
#define _system_printing_h
|
||||
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
printing system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef AIX
|
||||
#define DEFAULT_PRINTING PRINT_AIX
|
||||
#define PRINTCAP_NAME "/etc/qconfig"
|
||||
#endif
|
||||
|
||||
#ifdef HPUX
|
||||
#define DEFAULT_PRINTING PRINT_HPUX
|
||||
#endif
|
||||
|
||||
#ifdef QNX
|
||||
#define DEFAULT_PRINTING PRINT_QNX
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_PRINTING
|
||||
#define DEFAULT_PRINTING PRINT_BSD
|
||||
#endif
|
||||
#ifndef PRINTCAP_NAME
|
||||
#define PRINTCAP_NAME "/etc/printcap"
|
||||
#endif
|
||||
|
||||
#endif
|
48
source3/lib/replace/system/readline.h
Normal file
48
source3/lib/replace/system/readline.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef _system_readline_h
|
||||
#define _system_readline_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
readline wrappers
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBREADLINE
|
||||
# ifdef HAVE_READLINE_READLINE_H
|
||||
# include <readline/readline.h>
|
||||
# ifdef HAVE_READLINE_HISTORY_H
|
||||
# include <readline/history.h>
|
||||
# endif
|
||||
# else
|
||||
# ifdef HAVE_READLINE_H
|
||||
# include <readline.h>
|
||||
# ifdef HAVE_HISTORY_H
|
||||
# include <history.h>
|
||||
# endif
|
||||
# else
|
||||
# undef HAVE_LIBREADLINE
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NEW_LIBREADLINE
|
||||
# define RL_COMPLETION_CAST (rl_completion_func_t *)
|
||||
#else
|
||||
/* This type is missing from libreadline<4.0 (approximately) */
|
||||
# define RL_COMPLETION_CAST
|
||||
#endif /* HAVE_NEW_LIBREADLINE */
|
||||
|
||||
#endif
|
@ -1,7 +1,11 @@
|
||||
#ifndef _system_select_h
|
||||
#define _system_select_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
replacement routines for broken systems
|
||||
Copyright (C) Andrew Tridgell 1992-1998
|
||||
|
||||
select system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -18,25 +22,21 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
void replace1_dummy(void);
|
||||
void replace1_dummy(void) {}
|
||||
|
||||
#ifndef HAVE_SETENV
|
||||
int setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
char *p = NULL;
|
||||
int ret = -1;
|
||||
|
||||
asprintf(&p, "%s=%s", name, value);
|
||||
|
||||
if (overwrite || getenv(name)) {
|
||||
if (p) ret = putenv(p);
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#ifndef SELECT_CAST
|
||||
#define SELECT_CAST
|
||||
#endif
|
||||
|
||||
/* use epoll if it is available */
|
||||
#if defined(HAVE_EPOLL_CREATE) && defined(HAVE_SYS_EPOLL_H)
|
||||
#define WITH_EPOLL 1
|
||||
#endif
|
||||
|
||||
#if WITH_EPOLL
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#endif
|
55
source3/lib/replace/system/shmem.h
Normal file
55
source3/lib/replace/system/shmem.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef _system_shmem_h
|
||||
#define _system_shmem_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
shared memory system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_SYS_IPC_H)
|
||||
#include <sys/ipc.h>
|
||||
#endif /* HAVE_SYS_IPC_H */
|
||||
|
||||
#if defined(HAVE_SYS_SHM_H)
|
||||
#include <sys/shm.h>
|
||||
#endif /* HAVE_SYS_SHM_H */
|
||||
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
/* NetBSD doesn't have these */
|
||||
#ifndef SHM_R
|
||||
#define SHM_R 0400
|
||||
#endif
|
||||
|
||||
#ifndef SHM_W
|
||||
#define SHM_W 0200
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
#ifndef MAP_FAILED
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
#endif
|
||||
|
||||
#endif
|
66
source3/lib/replace/system/syslog.h
Normal file
66
source3/lib/replace/system/syslog.h
Normal file
@ -0,0 +1,66 @@
|
||||
#ifndef _system_syslog_h
|
||||
#define _system_syslog_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
syslog system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
#include <syslog.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_SYSLOG_H
|
||||
#include <sys/syslog.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* For sys_adminlog(). */
|
||||
#ifndef LOG_EMERG
|
||||
#define LOG_EMERG 0 /* system is unusable */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_ALERT
|
||||
#define LOG_ALERT 1 /* action must be taken immediately */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_CRIT
|
||||
#define LOG_CRIT 2 /* critical conditions */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_ERR
|
||||
#define LOG_ERR 3 /* error conditions */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_WARNING
|
||||
#define LOG_WARNING 4 /* warning conditions */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_NOTICE
|
||||
#define LOG_NOTICE 5 /* normal but significant condition */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_INFO
|
||||
#define LOG_INFO 6 /* informational */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_DEBUG
|
||||
#define LOG_DEBUG 7 /* debug-level messages */
|
||||
#endif
|
||||
|
||||
#endif
|
42
source3/lib/replace/system/terminal.h
Normal file
42
source3/lib/replace/system/terminal.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef _system_terminal_h
|
||||
#define _system_terminal_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
terminal system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef SUNOS4
|
||||
/* on SUNOS4 termios.h conflicts with sys/ioctl.h */
|
||||
#undef HAVE_TERMIOS_H
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_TERMIOS_H)
|
||||
/* POSIX terminal handling. */
|
||||
#include <termios.h>
|
||||
#elif defined(HAVE_TERMIO_H)
|
||||
/* Older SYSV terminal handling - don't use if we can avoid it. */
|
||||
#include <termio.h>
|
||||
#elif defined(HAVE_SYS_TERMIO_H)
|
||||
/* Older SYSV terminal handling - don't use if we can avoid it. */
|
||||
#include <sys/termio.h>
|
||||
#endif
|
||||
|
||||
#endif
|
40
source3/lib/replace/system/time.h
Normal file
40
source3/lib/replace/system/time.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef _system_time_h
|
||||
#define _system_time_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
time system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UTIME_H
|
||||
#include <utime.h>
|
||||
#endif
|
||||
|
||||
#endif
|
39
source3/lib/replace/system/wait.h
Normal file
39
source3/lib/replace/system/wait.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef _system_wait_h
|
||||
#define _system_wait_h
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
waitpid system include wrappers
|
||||
|
||||
Copyright (C) Andrew Tridgell 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#ifndef SIGCLD
|
||||
#define SIGCLD SIGCHLD
|
||||
#endif
|
||||
|
||||
#ifndef SIGNAL_CAST
|
||||
#define SIGNAL_CAST (RETSIGTYPE (*)(int))
|
||||
#endif
|
||||
|
||||
#endif
|
111
source3/lib/replace/test/os2_delete.c
Normal file
111
source3/lib/replace/test/os2_delete.c
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
test readdir/unlink pattern that OS/2 uses
|
||||
tridge@samba.org July 2005
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define NUM_FILES 700
|
||||
#define READDIR_SIZE 100
|
||||
#define DELETE_SIZE 4
|
||||
|
||||
#define TESTDIR "test.dir"
|
||||
|
||||
static int test_readdir_os2_delete_ret;
|
||||
|
||||
#define FAILED(d) (fprintf(stderr, "Failed for %s - %s\n", d, strerror(errno)), test_readdir_os2_delete_ret = 1, 1)
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
static void cleanup(void)
|
||||
{
|
||||
/* I'm a lazy bastard */
|
||||
system("rm -rf " TESTDIR);
|
||||
mkdir(TESTDIR, 0700) == 0 || FAILED("mkdir");
|
||||
}
|
||||
|
||||
static void create_files(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<NUM_FILES;i++) {
|
||||
char fname[40];
|
||||
sprintf(fname, TESTDIR "/test%u.txt", i);
|
||||
close(open(fname, O_CREAT|O_RDWR, 0600)) == 0 || FAILED("close");
|
||||
}
|
||||
}
|
||||
|
||||
static int os2_delete(DIR *d)
|
||||
{
|
||||
off_t offsets[READDIR_SIZE];
|
||||
int i, j;
|
||||
struct dirent *de;
|
||||
char names[READDIR_SIZE][30];
|
||||
|
||||
/* scan, remembering offsets */
|
||||
for (i=0, de=readdir(d);
|
||||
de && i < READDIR_SIZE;
|
||||
de=readdir(d), i++) {
|
||||
offsets[i] = telldir(d);
|
||||
strcpy(names[i], de->d_name);
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* delete the first few */
|
||||
for (j=0; j<MIN(i, DELETE_SIZE); j++) {
|
||||
char fname[40];
|
||||
sprintf(fname, TESTDIR "/%s", names[j]);
|
||||
unlink(fname) == 0 || FAILED("unlink");
|
||||
}
|
||||
|
||||
/* seek to just after the deletion */
|
||||
seekdir(d, offsets[j-1]);
|
||||
|
||||
/* return number deleted */
|
||||
return j;
|
||||
}
|
||||
|
||||
int test_readdir_os2_delete(void)
|
||||
{
|
||||
int total_deleted = 0;
|
||||
DIR *d;
|
||||
struct dirent *de;
|
||||
|
||||
test_readdir_os2_delete_ret = 0;
|
||||
|
||||
cleanup();
|
||||
create_files();
|
||||
|
||||
d = opendir(TESTDIR);
|
||||
|
||||
/* skip past . and .. */
|
||||
de = readdir(d);
|
||||
strcmp(de->d_name, ".") == 0 || FAILED("match .");
|
||||
de = readdir(d);
|
||||
strcmp(de->d_name, "..") == 0 || FAILED("match ..");
|
||||
|
||||
while (1) {
|
||||
int n = os2_delete(d);
|
||||
if (n == 0) break;
|
||||
total_deleted += n;
|
||||
}
|
||||
closedir(d);
|
||||
|
||||
printf("Deleted %d files of %d\n", total_deleted, NUM_FILES);
|
||||
|
||||
rmdir(TESTDIR) == 0 || FAILED("rmdir");
|
||||
|
||||
return test_readdir_os2_delete_ret;
|
||||
}
|
68
source3/lib/replace/test/shared_mmap.c
Normal file
68
source3/lib/replace/test/shared_mmap.c
Normal file
@ -0,0 +1,68 @@
|
||||
/* this tests whether we can use a shared writeable mmap on a file -
|
||||
as needed for the mmap variant of FAST_SHARE_MODES */
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define DATA "conftest.mmap"
|
||||
|
||||
#ifndef MAP_FILE
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
main()
|
||||
{
|
||||
int *buf;
|
||||
int i;
|
||||
int fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
|
||||
int count=7;
|
||||
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
for (i=0;i<10000;i++) {
|
||||
write(fd,&i,sizeof(i));
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
if (fork() == 0) {
|
||||
fd = open(DATA,O_RDWR);
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
buf = (int *)mmap(NULL, 10000*sizeof(int),
|
||||
(PROT_READ | PROT_WRITE),
|
||||
MAP_FILE | MAP_SHARED,
|
||||
fd, 0);
|
||||
|
||||
while (count-- && buf[9124] != 55732) sleep(1);
|
||||
|
||||
if (count <= 0) exit(1);
|
||||
|
||||
buf[1763] = 7268;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fd = open(DATA,O_RDWR);
|
||||
if (fd == -1) exit(1);
|
||||
|
||||
buf = (int *)mmap(NULL, 10000*sizeof(int),
|
||||
(PROT_READ | PROT_WRITE),
|
||||
MAP_FILE | MAP_SHARED,
|
||||
fd, 0);
|
||||
|
||||
if (buf == (int *)-1) exit(1);
|
||||
|
||||
buf[9124] = 55732;
|
||||
|
||||
while (count-- && buf[1763] != 7268) sleep(1);
|
||||
|
||||
unlink(DATA);
|
||||
|
||||
if (count > 0) exit(0);
|
||||
exit(1);
|
||||
}
|
435
source3/lib/replace/test/testsuite.c
Normal file
435
source3/lib/replace/test/testsuite.c
Normal file
@ -0,0 +1,435 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
|
||||
libreplace tests
|
||||
|
||||
Copyright (C) Jelmer Vernooij 2006
|
||||
|
||||
** NOTE! The following LGPL license applies to the talloc
|
||||
** library. This does NOT imply that all of Samba is released
|
||||
** under the LGPL
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "replace.h"
|
||||
|
||||
/*
|
||||
we include all the system/ include files here so that libreplace tests
|
||||
them in the build farm
|
||||
*/
|
||||
#include "system/capability.h"
|
||||
#include "system/dir.h"
|
||||
#include "system/filesys.h"
|
||||
#include "system/glob.h"
|
||||
#include "system/iconv.h"
|
||||
#include "system/locale.h"
|
||||
#include "system/network.h"
|
||||
#include "system/passwd.h"
|
||||
#include "system/printing.h"
|
||||
#include "system/readline.h"
|
||||
#include "system/select.h"
|
||||
#include "system/shmem.h"
|
||||
#include "system/syslog.h"
|
||||
#include "system/terminal.h"
|
||||
#include "system/time.h"
|
||||
#include "system/wait.h"
|
||||
|
||||
#define TESTFILE "testfile.dat"
|
||||
|
||||
/*
|
||||
test ftruncate() function
|
||||
*/
|
||||
static int test_ftruncate(void)
|
||||
{
|
||||
struct stat st;
|
||||
int fd;
|
||||
const int size = 1234;
|
||||
printf("testing ftruncate\n");
|
||||
unlink(TESTFILE);
|
||||
fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
|
||||
if (fd == -1) {
|
||||
printf("creating '%s' failed - %s\n", TESTFILE, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
if (ftruncate(fd, size) != 0) {
|
||||
printf("ftruncate failed - %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
if (fstat(fd, &st) != 0) {
|
||||
printf("fstat failed - %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
if (st.st_size != size) {
|
||||
printf("ftruncate gave wrong size %d - expected %d\n",
|
||||
(int)st.st_size, size);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
test strlcpy() function.
|
||||
see http://www.gratisoft.us/todd/papers/strlcpy.html
|
||||
*/
|
||||
static int test_strlcpy(void)
|
||||
{
|
||||
char buf[4];
|
||||
const struct {
|
||||
const char *src;
|
||||
int result;
|
||||
} tests[] = {
|
||||
{ "abc", 3 },
|
||||
{ "abcdef", 6 },
|
||||
{ "abcd", 4 },
|
||||
{ "", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
int i;
|
||||
printf("testing strlcpy\n");
|
||||
for (i=0;tests[i].src;i++) {
|
||||
if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
|
||||
printf("strlcpy test %d failed\n", i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_strlcat(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_mktime(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_innetgr(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_initgroups(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_memmove(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_strdup(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_setlinebuf(void)
|
||||
{
|
||||
printf("testing setlinebuf\n");
|
||||
setlinebuf(stdout);
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_vsyslog(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_timegm(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_setenv(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_strndup(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_strnlen(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_waitpid(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_seteuid(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_setegid(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_asprintf(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_snprintf(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_vasprintf(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_vsnprintf(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_opendir(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
extern int test_readdir_os2_delete(void);
|
||||
|
||||
static bool test_readdir(void)
|
||||
{
|
||||
printf("testing readdir\n");
|
||||
if (test_readdir_os2_delete() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_telldir(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_seekdir(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_dlopen(void)
|
||||
{
|
||||
/* FIXME: test dlopen, dlsym, dlclose, dlerror */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int test_chroot(void)
|
||||
{
|
||||
/* FIXME: chroot() */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_bzero(void)
|
||||
{
|
||||
/* FIXME: bzero */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_strerror(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_errno(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_mkdtemp(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_mkstemp(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_pread(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_pwrite(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_getpass(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_inet_ntoa(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_strtoll(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_strtoull(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
FIXME:
|
||||
Types:
|
||||
bool
|
||||
socklen_t
|
||||
uint_t
|
||||
uint{8,16,32,64}_t
|
||||
int{8,16,32,64}_t
|
||||
intptr_t
|
||||
|
||||
Constants:
|
||||
PATH_NAME_MAX
|
||||
UINT{16,32,64}_MAX
|
||||
INT32_MAX
|
||||
*/
|
||||
|
||||
static int test_va_copy(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_FUNCTION(void)
|
||||
{
|
||||
/* FIXME: test __FUNCTION__ macro */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_MIN(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
static int test_MAX(void)
|
||||
{
|
||||
/* FIXME */
|
||||
return true;
|
||||
}
|
||||
|
||||
int torture_local_replace(void *ctx)
|
||||
{
|
||||
int ret = true;
|
||||
ret &= test_ftruncate();
|
||||
ret &= test_strlcpy();
|
||||
ret &= test_strlcat();
|
||||
ret &= test_mktime();
|
||||
ret &= test_innetgr();
|
||||
ret &= test_initgroups();
|
||||
ret &= test_memmove();
|
||||
ret &= test_strdup();
|
||||
ret &= test_setlinebuf();
|
||||
ret &= test_vsyslog();
|
||||
ret &= test_timegm();
|
||||
ret &= test_setenv();
|
||||
ret &= test_strndup();
|
||||
ret &= test_strnlen();
|
||||
ret &= test_waitpid();
|
||||
ret &= test_seteuid();
|
||||
ret &= test_setegid();
|
||||
ret &= test_asprintf();
|
||||
ret &= test_snprintf();
|
||||
ret &= test_vasprintf();
|
||||
ret &= test_vsnprintf();
|
||||
ret &= test_opendir();
|
||||
ret &= test_readdir() ;
|
||||
ret &= test_telldir();
|
||||
ret &= test_seekdir();
|
||||
ret &= test_dlopen();
|
||||
ret &= test_chroot();
|
||||
ret &= test_bzero();
|
||||
ret &= test_strerror();
|
||||
ret &= test_errno();
|
||||
ret &= test_mkdtemp();
|
||||
ret &= test_mkstemp();
|
||||
ret &= test_pread();
|
||||
ret &= test_pwrite();
|
||||
ret &= test_getpass();
|
||||
ret &= test_inet_ntoa();
|
||||
ret &= test_strtoll();
|
||||
ret &= test_strtoll();
|
||||
ret &= test_strtoull();
|
||||
ret &= test_va_copy();
|
||||
ret &= test_FUNCTION();
|
||||
ret &= test_MIN();
|
||||
ret &= test_MAX();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(_SAMBA_BUILD_) || ((SAMBA_VERSION_MAJOR==3)&&(SAMBA_VERSION_MINOR<9))
|
||||
int main(void)
|
||||
{
|
||||
if (!torture_local_replace(NULL)) {
|
||||
printf("ERROR: TESTSUITE FAILED\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@ -35,9 +35,8 @@
|
||||
adapted for Samba4 by Andrew Tridgell
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#ifndef HAVE_TIMEGM
|
||||
#include "replace.h"
|
||||
#include "system/time.h"
|
||||
|
||||
static int is_leap(unsigned y)
|
||||
{
|
||||
@ -67,5 +66,3 @@ time_t timegm(struct tm *tm)
|
||||
res += tm->tm_sec;
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* HAVE_TIMEGM */
|
1
source3/lib/replace/timegm.m4
Normal file
1
source3/lib/replace/timegm.m4
Normal file
@ -0,0 +1 @@
|
||||
AC_CHECK_FUNCS(timegm,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} timegm.o"])
|
20
source3/lib/replace/win32.m4
Normal file
20
source3/lib/replace/win32.m4
Normal file
@ -0,0 +1,20 @@
|
||||
AC_CHECK_HEADERS(direct.h windows.h winsock2.h ws2tcpip.h)
|
||||
|
||||
#######################################
|
||||
# Check for mkdir mode
|
||||
AC_CACHE_CHECK( [whether mkdir supports mode], ac_mkdir_has_mode,
|
||||
AC_TRY_COMPILE([
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#endif],[
|
||||
mkdir("foo",0777);
|
||||
return 0;
|
||||
],
|
||||
ac_mkdir_has_mode="yes",
|
||||
ac_mkdir_has_mode="no") )
|
||||
|
||||
if test "$ac_mkdir_has_mode" = "yes"
|
||||
then
|
||||
AC_DEFINE(HAVE_MKDIR_MODE, 1, [Define if target mkdir supports mode option])
|
||||
fi
|
159
source3/lib/replace/win32_replace.h
Normal file
159
source3/lib/replace/win32_replace.h
Normal file
@ -0,0 +1,159 @@
|
||||
#ifndef _WIN32_REPLACE_H
|
||||
#define _WIN32_REPLACE_H
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* Map BSD Socket errorcodes to the WSA errorcodes (if possible) */
|
||||
|
||||
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
||||
#define ECONNREFUSED WSAECONNREFUSED
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define EMSGSIZE WSAEMSGSIZE
|
||||
#define ENOBUFS WSAENOBUFS
|
||||
#define ENOTSOCK WSAENOTSOCK
|
||||
#define ENETUNREACH WSAENETUNREACH
|
||||
#define ENOPROTOOPT WSAENOPROTOOPT
|
||||
#define ENOTCONN WSAENOTCONN
|
||||
#define ENOTSUP 134
|
||||
|
||||
/* We undefine the following constants due to conflicts with the w32api headers
|
||||
* and the Windows Platform SDK/DDK.
|
||||
*/
|
||||
|
||||
#undef interface
|
||||
|
||||
#undef ERROR_INVALID_PARAMETER
|
||||
#undef ERROR_INSUFFICIENT_BUFFER
|
||||
#undef ERROR_INVALID_DATATYPE
|
||||
|
||||
#undef FILE_GENERIC_READ
|
||||
#undef FILE_GENERIC_WRITE
|
||||
#undef FILE_GENERIC_EXECUTE
|
||||
#undef FILE_ATTRIBUTE_READONLY
|
||||
#undef FILE_ATTRIBUTE_HIDDEN
|
||||
#undef FILE_ATTRIBUTE_SYSTEM
|
||||
#undef FILE_ATTRIBUTE_DIRECTORY
|
||||
#undef FILE_ATTRIBUTE_ARCHIVE
|
||||
#undef FILE_ATTRIBUTE_DEVICE
|
||||
#undef FILE_ATTRIBUTE_NORMAL
|
||||
#undef FILE_ATTRIBUTE_TEMPORARY
|
||||
#undef FILE_ATTRIBUTE_REPARSE_POINT
|
||||
#undef FILE_ATTRIBUTE_COMPRESSED
|
||||
#undef FILE_ATTRIBUTE_OFFLINE
|
||||
#undef FILE_ATTRIBUTE_ENCRYPTED
|
||||
#undef FILE_FLAG_WRITE_THROUGH
|
||||
#undef FILE_FLAG_NO_BUFFERING
|
||||
#undef FILE_FLAG_RANDOM_ACCESS
|
||||
#undef FILE_FLAG_SEQUENTIAL_SCAN
|
||||
#undef FILE_FLAG_DELETE_ON_CLOSE
|
||||
#undef FILE_FLAG_BACKUP_SEMANTICS
|
||||
#undef FILE_FLAG_POSIX_SEMANTICS
|
||||
#undef FILE_TYPE_DISK
|
||||
#undef FILE_TYPE_UNKNOWN
|
||||
#undef FILE_CASE_SENSITIVE_SEARCH
|
||||
#undef FILE_CASE_PRESERVED_NAMES
|
||||
#undef FILE_UNICODE_ON_DISK
|
||||
#undef FILE_PERSISTENT_ACLS
|
||||
#undef FILE_FILE_COMPRESSION
|
||||
#undef FILE_VOLUME_QUOTAS
|
||||
#undef FILE_VOLUME_IS_COMPRESSED
|
||||
#undef FILE_NOTIFY_CHANGE_FILE_NAME
|
||||
#undef FILE_NOTIFY_CHANGE_DIR_NAME
|
||||
#undef FILE_NOTIFY_CHANGE_ATTRIBUTES
|
||||
#undef FILE_NOTIFY_CHANGE_SIZE
|
||||
#undef FILE_NOTIFY_CHANGE_LAST_WRITE
|
||||
#undef FILE_NOTIFY_CHANGE_LAST_ACCESS
|
||||
#undef FILE_NOTIFY_CHANGE_CREATION
|
||||
#undef FILE_NOTIFY_CHANGE_EA
|
||||
#undef FILE_NOTIFY_CHANGE_SECURITY
|
||||
#undef FILE_NOTIFY_CHANGE_STREAM_NAME
|
||||
#undef FILE_NOTIFY_CHANGE_STREAM_SIZE
|
||||
#undef FILE_NOTIFY_CHANGE_STREAM_WRITE
|
||||
#undef FILE_NOTIFY_CHANGE_NAME
|
||||
|
||||
#undef PRINTER_ATTRIBUTE_QUEUED
|
||||
#undef PRINTER_ATTRIBUTE_DIRECT
|
||||
#undef PRINTER_ATTRIBUTE_DEFAULT
|
||||
#undef PRINTER_ATTRIBUTE_SHARED
|
||||
#undef PRINTER_ATTRIBUTE_NETWORK
|
||||
#undef PRINTER_ATTRIBUTE_HIDDEN
|
||||
#undef PRINTER_ATTRIBUTE_LOCAL
|
||||
#undef PRINTER_ATTRIBUTE_ENABLE_DEVQ
|
||||
#undef PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS
|
||||
#undef PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST
|
||||
#undef PRINTER_ATTRIBUTE_WORK_OFFLINE
|
||||
#undef PRINTER_ATTRIBUTE_ENABLE_BIDI
|
||||
#undef PRINTER_ATTRIBUTE_RAW_ONLY
|
||||
#undef PRINTER_ATTRIBUTE_PUBLISHED
|
||||
#undef PRINTER_ENUM_DEFAULT
|
||||
#undef PRINTER_ENUM_LOCAL
|
||||
#undef PRINTER_ENUM_CONNECTIONS
|
||||
#undef PRINTER_ENUM_FAVORITE
|
||||
#undef PRINTER_ENUM_NAME
|
||||
#undef PRINTER_ENUM_REMOTE
|
||||
#undef PRINTER_ENUM_SHARED
|
||||
#undef PRINTER_ENUM_NETWORK
|
||||
#undef PRINTER_ENUM_EXPAND
|
||||
#undef PRINTER_ENUM_CONTAINER
|
||||
#undef PRINTER_ENUM_ICON1
|
||||
#undef PRINTER_ENUM_ICON2
|
||||
#undef PRINTER_ENUM_ICON3
|
||||
#undef PRINTER_ENUM_ICON4
|
||||
#undef PRINTER_ENUM_ICON5
|
||||
#undef PRINTER_ENUM_ICON6
|
||||
#undef PRINTER_ENUM_ICON7
|
||||
#undef PRINTER_ENUM_ICON8
|
||||
#undef PRINTER_STATUS_PAUSED
|
||||
#undef PRINTER_STATUS_ERROR
|
||||
#undef PRINTER_STATUS_PENDING_DELETION
|
||||
#undef PRINTER_STATUS_PAPER_JAM
|
||||
#undef PRINTER_STATUS_PAPER_OUT
|
||||
#undef PRINTER_STATUS_MANUAL_FEED
|
||||
#undef PRINTER_STATUS_PAPER_PROBLEM
|
||||
#undef PRINTER_STATUS_OFFLINE
|
||||
#undef PRINTER_STATUS_IO_ACTIVE
|
||||
#undef PRINTER_STATUS_BUSY
|
||||
#undef PRINTER_STATUS_PRINTING
|
||||
#undef PRINTER_STATUS_OUTPUT_BIN_FULL
|
||||
#undef PRINTER_STATUS_NOT_AVAILABLE
|
||||
#undef PRINTER_STATUS_WAITING
|
||||
#undef PRINTER_STATUS_PROCESSING
|
||||
#undef PRINTER_STATUS_INITIALIZING
|
||||
#undef PRINTER_STATUS_WARMING_UP
|
||||
#undef PRINTER_STATUS_TONER_LOW
|
||||
#undef PRINTER_STATUS_NO_TONER
|
||||
#undef PRINTER_STATUS_PAGE_PUNT
|
||||
#undef PRINTER_STATUS_USER_INTERVENTION
|
||||
#undef PRINTER_STATUS_OUT_OF_MEMORY
|
||||
#undef PRINTER_STATUS_DOOR_OPEN
|
||||
#undef PRINTER_STATUS_SERVER_UNKNOWN
|
||||
#undef PRINTER_STATUS_POWER_SAVE
|
||||
|
||||
#undef DWORD
|
||||
#undef HKEY_CLASSES_ROOT
|
||||
#undef HKEY_CURRENT_USER
|
||||
#undef HKEY_LOCAL_MACHINE
|
||||
#undef HKEY_USERS
|
||||
#undef HKEY_PERFORMANCE_DATA
|
||||
#undef HKEY_CURRENT_CONFIG
|
||||
#undef HKEY_DYN_DATA
|
||||
#undef REG_DWORD
|
||||
#undef REG_QWORD
|
||||
|
||||
#undef SERVICE_STATE_ALL
|
||||
|
||||
#undef SE_GROUP_MANDATORY
|
||||
#undef SE_GROUP_ENABLED_BY_DEFAULT
|
||||
#undef SE_GROUP_ENABLED
|
||||
|
||||
#endif /* _WIN32_REPLACE_H */
|
Loading…
x
Reference in New Issue
Block a user