From e893d7f021d149803aa85e347e0a8acefde210ac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 2 Jun 2007 09:10:08 +0000 Subject: r23309: sync lib/replace with SAMBA_4_0 metze (This used to be commit 20965d800fcac0c55853fb12cdd36b5836fc7e56) --- source3/lib/replace/Makefile.in | 9 +++++---- source3/lib/replace/configure.ac | 2 ++ source3/lib/replace/dlfcn.c | 4 ++++ source3/lib/replace/dlfcn.m4 | 17 +++++++++++------ source3/lib/replace/libreplace.m4 | 3 ++- source3/lib/replace/replace.c | 26 +++++++++++++++----------- source3/lib/replace/replace.h | 12 ++++++++++++ source3/lib/replace/system/aio.h | 26 +++++++++++++++----------- source3/lib/replace/system/capability.h | 26 +++++++++++++++----------- source3/lib/replace/system/dir.h | 26 +++++++++++++++----------- source3/lib/replace/system/filesys.h | 31 ++++++++++++++++++++----------- source3/lib/replace/system/glob.h | 27 ++++++++++++++++----------- source3/lib/replace/system/iconv.h | 27 ++++++++++++++++----------- source3/lib/replace/system/kerberos.h | 27 ++++++++++++++++----------- source3/lib/replace/system/locale.h | 27 ++++++++++++++++----------- source3/lib/replace/system/network.h | 27 ++++++++++++++++----------- source3/lib/replace/system/passwd.h | 27 ++++++++++++++++----------- source3/lib/replace/system/printing.h | 27 ++++++++++++++++----------- source3/lib/replace/system/readline.h | 29 +++++++++++++++++------------ source3/lib/replace/system/select.h | 31 ++++++++++++++++++++----------- source3/lib/replace/system/shmem.h | 27 ++++++++++++++++----------- source3/lib/replace/system/syslog.h | 27 ++++++++++++++++----------- source3/lib/replace/system/terminal.h | 27 ++++++++++++++++----------- source3/lib/replace/system/time.h | 29 +++++++++++++++++------------ source3/lib/replace/system/wait.h | 29 +++++++++++++++++------------ 25 files changed, 347 insertions(+), 223 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/replace/Makefile.in b/source3/lib/replace/Makefile.in index f4c79749a6..30f39ac6cb 100644 --- a/source3/lib/replace/Makefile.in +++ b/source3/lib/replace/Makefile.in @@ -11,9 +11,10 @@ srcdir = @srcdir@ builddir = @builddir@ INSTALL = @INSTALL@ -.PHONY: test +.PHONY: test all showflags install installcheck clean distclean realdistclean -CFLAGS=-I. -I@libreplacedir@ @CFLAGS@ +CFLAGS=-I. @CFLAGS@ +LDFLAGS=@LDFLAGS@ OBJS = @LIBREPLACEOBJ@ @@ -23,7 +24,7 @@ showflags: @echo 'libreplace will be compiled with flags:' @echo ' CC = $(CC)' @echo ' CFLAGS = $(CFLAGS)' - @echo ' LIBS = $(LIBS)' + @echo ' LDFLAGS= $(LDFLAGS)' install: all mkdir -p $(libdir) @@ -40,7 +41,7 @@ installcheck: install test TEST_OBJS = test/testsuite.o test/os2_delete.o test/strptime.o testsuite: libreplace.a $(TEST_OBJS) - $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace + $(CC) -o testsuite $(TEST_OBJS) -L. -lreplace $(LDFLAGS) .c.o: @echo Compiling $*.c diff --git a/source3/lib/replace/configure.ac b/source3/lib/replace/configure.ac index 48fb7ce259..beeb77e152 100644 --- a/source3/lib/replace/configure.ac +++ b/source3/lib/replace/configure.ac @@ -19,4 +19,6 @@ if test "$ac_cv_prog_gcc" = yes; then CFLAGS="$CFLAGS -Wno-format-y2k" fi +AC_SUBST(LDFLAGS) + AC_OUTPUT(Makefile) diff --git a/source3/lib/replace/dlfcn.c b/source3/lib/replace/dlfcn.c index 22f9f8bf79..55b38bb9eb 100644 --- a/source3/lib/replace/dlfcn.c +++ b/source3/lib/replace/dlfcn.c @@ -26,7 +26,11 @@ #include "replace.h" #ifndef HAVE_DLOPEN +#ifdef DLOPEN_TAKES_UNSIGNED_FLAGS +void *rep_dlopen(const char *name, unsigned int flags) +#else void *rep_dlopen(const char *name, int flags) +#endif { return NULL; } diff --git a/source3/lib/replace/dlfcn.m4 b/source3/lib/replace/dlfcn.m4 index d42409ac63..a1b57d10ec 100644 --- a/source3/lib/replace/dlfcn.m4 +++ b/source3/lib/replace/dlfcn.m4 @@ -5,12 +5,17 @@ LIBS="" libreplace_cv_dlfcn=no AC_SEARCH_LIBS(dlopen, dl) -if test x"${ac_cv_search_dlopen}" = x"no"; then - libreplace_cv_dlfcn=yes -else - AC_CHECK_HEADERS(dlfcn.h) - AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) -fi +AC_CHECK_HEADERS(dlfcn.h) +AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes]) + +AC_VERIFY_C_PROTOTYPE([void *dlopen(const char* filename, unsigned int flags)], + [ + return 0; + ],[ + AC_DEFINE(DLOPEN_TAKES_UNSIGNED_FLAGS, 1, [Whether dlopen takes unsinged int flags]) + ],[],[ + #include + ]) if test x"${libreplace_cv_dlfcn}" = x"yes";then LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o" diff --git a/source3/lib/replace/libreplace.m4 b/source3/lib/replace/libreplace.m4 index e9b19b7cf5..f06d7f83dc 100644 --- a/source3/lib/replace/libreplace.m4 +++ b/source3/lib/replace/libreplace.m4 @@ -99,7 +99,7 @@ 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) - +AC_CHECK_HEADERS(sys/mount.h mntent.h) dnl we need to check that net/if.h really can be used, to cope with hpux dnl where including it always fails @@ -354,6 +354,7 @@ AC_LIBREPLACE_LOCATION_CHECKS AC_LIBREPLACE_CC_CHECKS AC_LIBREPLACE_BROKEN_CHECKS AC__LIBREPLACE_ALL_CHECKS_END +CFLAGS="$CFLAGS -I$libreplacedir" ]) m4_include(libreplace_cc.m4) diff --git a/source3/lib/replace/replace.c b/source3/lib/replace/replace.c index db299130e5..87e73d001c 100644 --- a/source3/lib/replace/replace.c +++ b/source3/lib/replace/replace.c @@ -568,20 +568,24 @@ int rep_unsetenv(const char *name) { extern char **environ; size_t len = strlen(name); - size_t i; - int found = 0; + size_t i, count; - for (i=0; (environ && environ[i]); i++) { - if (found) { - environ[i-1] = environ[i]; - continue; - } + if (environ == NULL || getenv(name) == NULL) { + return 0; + } + for (i=0;environ[i];i++) /* noop */ ; + + count=i; + + for (i=0;i