svn commit: samba r18160 - in branches/SAMBA_4_0/source/lib:
replace replace/system replace/test tdb/common
tridge at samba.org
tridge at samba.org
Wed Sep 6 11:31:59 GMT 2006
Author: tridge
Date: 2006-09-06 11:31:59 +0000 (Wed, 06 Sep 2006)
New Revision: 18160
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18160
Log:
- pread and pwrite replacements need to be non-static
- replacing rename() is pointless - all platforms have it (and the
#define of rename breaks some code)
- use system/locale.h in snprintf.c
- fix passwd.h for initgroups
- stdlib is in replace.h, not needed elsewhere
- fix the initgroups replacement
- fix mapping of dl functions to rep_*
Modified:
branches/SAMBA_4_0/source/lib/replace/dlfcn.c
branches/SAMBA_4_0/source/lib/replace/getpass.c
branches/SAMBA_4_0/source/lib/replace/replace.c
branches/SAMBA_4_0/source/lib/replace/replace.h
branches/SAMBA_4_0/source/lib/replace/snprintf.c
branches/SAMBA_4_0/source/lib/replace/system/passwd.h
branches/SAMBA_4_0/source/lib/replace/test/testsuite.c
branches/SAMBA_4_0/source/lib/tdb/common/io.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/dlfcn.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/dlfcn.c 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/replace/dlfcn.c 2006-09-06 11:31:59 UTC (rev 18160)
@@ -24,7 +24,6 @@
*/
#include "replace.h"
-#include <stdlib.h>
#ifndef HAVE_DLOPEN
void *dlopen(const char *name, int flags)
@@ -41,7 +40,7 @@
#endif
#ifndef HAVE_DLERROR
-const char *dlerror(void)
+char *dlerror(void)
{
return "dynamic loading of objects not supported on this platform";
}
Modified: branches/SAMBA_4_0/source/lib/replace/getpass.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/getpass.c 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/replace/getpass.c 2006-09-06 11:31:59 UTC (rev 18160)
@@ -19,7 +19,6 @@
/* Modified to use with samba by Jeremy Allison, 8th July 1995. */
#include "replace.h"
-#include <stdlib.h>
#if defined(HAVE_TERMIOS_H)
/* POSIX terminal handling. */
Modified: branches/SAMBA_4_0/source/lib/replace/replace.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.c 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/replace/replace.c 2006-09-06 11:31:59 UTC (rev 18160)
@@ -30,6 +30,7 @@
#include "system/syslog.h"
#include "system/network.h"
#include "system/locale.h"
+#include "system/wait.h"
void replace_dummy(void);
void replace_dummy(void) {}
@@ -42,7 +43,7 @@
{
#ifdef HAVE_CHSIZE
return chsize(f,l);
-#else
+#elif defined(F_FREESP)
struct flock fl;
fl.l_whence = 0;
@@ -50,6 +51,8 @@
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 */
@@ -151,24 +154,6 @@
#endif /* !HAVE_MKTIME */
-
-#ifndef HAVE_RENAME
-/* Rename a file. (from libiberty in GNU binutils) */
-int rep_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)
/*
@@ -211,7 +196,7 @@
#include <grp.h>
gid_t *grouplst = NULL;
- int max_gr = groups_max();
+ int max_gr = 32;
int ret;
int i,j;
struct group *g;
@@ -481,7 +466,7 @@
#endif
#ifndef HAVE_PREAD
-static ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset)
+ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset)
{
if (lseek(__fd, __offset, SEEK_SET) != __offset) {
return -1;
@@ -491,7 +476,7 @@
#endif
#ifndef HAVE_PWRITE
-static ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
+ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
{
if (lseek(__fd, __offset, SEEK_SET) != __offset) {
return -1;
Modified: branches/SAMBA_4_0/source/lib/replace/replace.h
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.h 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/replace/replace.h 2006-09-06 11:31:59 UTC (rev 18160)
@@ -61,7 +61,6 @@
#include <strings.h>
#endif
-
#ifndef HAVE_STRERROR
extern char *sys_errlist[];
#define strerror(i) sys_errlist[i]
@@ -121,11 +120,6 @@
int rep_setenv(const char *name, const char *value, int overwrite);
#endif
-#ifndef HAVE_RENAME
-#define rename rep_rename
-int rep_rename(const char *zfrom, const char *zto);
-#endif
-
#ifndef HAVE_STRCASESTR
#define strcasestr rep_strcasestr
char *rep_strcasestr(const char *haystack, const char *needle);
@@ -148,14 +142,39 @@
#ifndef HAVE_FTRUNCATE
#define ftruncate rep_ftruncate
-int rep_ftruncate(int f,long l);
+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
@@ -195,6 +214,7 @@
#ifndef HAVE_VA_COPY
+#undef va_copy
#ifdef HAVE___VA_COPY
#define va_copy(dest, src) __va_copy(dest, src)
#else
Modified: branches/SAMBA_4_0/source/lib/replace/snprintf.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/snprintf.c 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/replace/snprintf.c 2006-09-06 11:31:59 UTC (rev 18160)
@@ -104,6 +104,7 @@
**************************************************************/
#include "replace.h"
+#include "system/locale.h"
#ifdef TEST_SNPRINTF /* need math library headers for testing */
@@ -117,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>
Modified: branches/SAMBA_4_0/source/lib/replace/system/passwd.h
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/system/passwd.h 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/replace/system/passwd.h 2006-09-06 11:31:59 UTC (rev 18160)
@@ -88,9 +88,4 @@
#define ULTRIX_AUTH 1
#endif
-
-#ifndef HAVE_INITGROUPS
-int initgroups(char *name,gid_t id);
#endif
-
-#endif
Modified: branches/SAMBA_4_0/source/lib/replace/test/testsuite.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-09-06 11:31:59 UTC (rev 18160)
@@ -120,12 +120,6 @@
return true;
}
-static int test_rename(void)
-{
- /* FIXME */
- return true;
-}
-
static int test_innetgr(void)
{
/* FIXME */
@@ -378,7 +372,6 @@
ret &= test_strlcpy();
ret &= test_strlcat();
ret &= test_mktime();
- ret &= test_rename();
ret &= test_innetgr();
ret &= test_initgroups();
ret &= test_memmove();
Modified: branches/SAMBA_4_0/source/lib/tdb/common/io.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/io.c 2006-09-06 11:20:43 UTC (rev 18159)
+++ branches/SAMBA_4_0/source/lib/tdb/common/io.c 2006-09-06 11:31:59 UTC (rev 18160)
@@ -29,28 +29,6 @@
#include "tdb_private.h"
-#ifndef HAVE_PREAD
- static ssize_t pread(int fd, void *buf, size_t count, off_t offset)
-{
- if (lseek(fd, offset, SEEK_SET) != offset) {
- errno = EIO;
- return -1;
- }
- return read(fd, buf, count);
-}
-#endif
-
-#ifndef HAVE_PWRITE
- static ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
-{
- if (lseek(fd, offset, SEEK_SET) != offset) {
- errno = EIO;
- return -1;
- }
- return write(fd, buf, count);
-}
-#endif
-
/* check for an out of bounds access - if it is out of bounds then
see if the database has been expanded by someone else and expand
if necessary
More information about the samba-cvs
mailing list