[SCM] Samba Shared Repository - branch v4-0-test updated -
release-4-0-0alpha2-1326-g98ee8c8
Michael Adam
obnox at samba.org
Tue Mar 18 15:35:56 GMT 2008
The branch, v4-0-test has been updated
via 98ee8c84300757d778733a458c6ca3e6022b40ea (commit)
via 1f9ca7eed965904f67cf78fbac007432b8a057fd (commit)
via 974c0c45ad42644348e0b55454715b12158f1028 (commit)
from cca5d6626fe395f08fd4c8b2344e4e43646cb987 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test
- Log -----------------------------------------------------------------
commit 98ee8c84300757d778733a458c6ca3e6022b40ea
Author: Michael Adam <obnox at samba.org>
Date: Tue Mar 18 16:31:15 2008 +0100
libreplace: remove duplicate entry of inet_ntoa from README.
Michael
commit 1f9ca7eed965904f67cf78fbac007432b8a057fd
Author: Michael Adam <obnox at samba.org>
Date: Tue Mar 18 13:10:22 2008 +0100
libreplace: remove trailing white spaces.
Michael
commit 974c0c45ad42644348e0b55454715b12158f1028
Author: Michael Adam <obnox at samba.org>
Date: Tue Mar 18 12:16:47 2008 +0100
libreplace: replace inet_ntoa() when it is missing
...not only replace it when it is broken.
This moves the defintion of rep_inet_ntoa from replace.c
to inet_ntoa.c and adds configure checks for existence
of inet_ntoa(). Checks are moved to an include file of its own.
NOTE: The original rep_inet_ntoa in replace.c was wrapped
into a "#ifndef WITH_PTHREADS" but the prototype in replace.h
and the define in system/network.h were not. I removed that
ifndef since the inet_ntoa() function is usually not thread safe
anyways, since it returns a pointer to a static buffer.
So whoever calls inet_ntoa() should be aware that it is not
thread safe anyways.
Michael
-----------------------------------------------------------------------
Summary of changes:
source/lib/replace/README | 1 -
source/lib/replace/{inet_aton.c => inet_ntoa.c} | 16 +++++++++++-----
source/lib/replace/inet_ntoa.m4 | 19 +++++++++++++++++++
source/lib/replace/libreplace.m4 | 19 +------------------
source/lib/replace/replace.c | 14 --------------
source/lib/replace/replace.h | 2 +-
source/lib/replace/system/network.h | 2 +-
7 files changed, 33 insertions(+), 40 deletions(-)
copy source/lib/replace/{inet_aton.c => inet_ntoa.c} (69%)
create mode 100644 source/lib/replace/inet_ntoa.m4
Changeset truncated at 500 lines:
diff --git a/source/lib/replace/README b/source/lib/replace/README
index aae1ccb..43f7b08 100644
--- a/source/lib/replace/README
+++ b/source/lib/replace/README
@@ -15,7 +15,6 @@ rename
initgroups
memmove
strdup
-inet_ntoa
setlinebuf
vsyslog
timegm
diff --git a/source/lib/replace/inet_aton.c b/source/lib/replace/inet_ntoa.c
similarity index 69%
copy from source/lib/replace/inet_aton.c
copy to source/lib/replace/inet_ntoa.c
index c6b3bb1..e3b80eb 100644
--- a/source/lib/replace/inet_aton.c
+++ b/source/lib/replace/inet_ntoa.c
@@ -1,7 +1,8 @@
/*
* Unix SMB/CIFS implementation.
- * replacement functions
- * Copyright (C) Michael Adam <obnox at samba.org> 2008
+ * replacement routines for broken systems
+ * Copyright (C) Andrew Tridgell 2003
+ * Copyright (C) Michael Adam 2008
*
* ** NOTE! The following LGPL license applies to the replace
* ** library. This does NOT imply that all of Samba is released
@@ -25,9 +26,14 @@
#include "system/network.h"
/**
- * We know that we have inet_pton from earlier libreplace checks.
+ * NOTE: this is not thread safe, but it can't be, either
+ * since it returns a pointer to static memory.
*/
-int rep_inet_aton(const char *src, struct in_addr *dst)
+char *rep_inet_ntoa(struct in_addr ip)
{
- return (inet_pton(AF_INET, src, dst) > 0) ? 1 : 0;
+ 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;
}
diff --git a/source/lib/replace/inet_ntoa.m4 b/source/lib/replace/inet_ntoa.m4
new file mode 100644
index 0000000..5aaa935
--- /dev/null
+++ b/source/lib/replace/inet_ntoa.m4
@@ -0,0 +1,19 @@
+AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"])
+
+AC_CACHE_CHECK([for broken inet_ntoa],libreplace_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);}],
+ libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
+if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
+ AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
+fi
diff --git a/source/lib/replace/libreplace.m4 b/source/lib/replace/libreplace.m4
index e6e7198..3da2a90 100644
--- a/source/lib/replace/libreplace.m4
+++ b/source/lib/replace/libreplace.m4
@@ -120,24 +120,6 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
fi
-AC_CACHE_CHECK([for broken inet_ntoa],libreplace_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);}],
- libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
-if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
- AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
-fi
-
AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
@@ -348,6 +330,7 @@ m4_include(socket.m4)
m4_include(inet_ntop.m4)
m4_include(inet_pton.m4)
m4_include(inet_aton.m4)
+m4_include(inet_ntoa.m4)
m4_include(getaddrinfo.m4)
m4_include(repdir.m4)
m4_include(getifaddrs.m4)
diff --git a/source/lib/replace/replace.c b/source/lib/replace/replace.c
index b2a240e..c16bded 100644
--- a/source/lib/replace/replace.c
+++ b/source/lib/replace/replace.c
@@ -295,20 +295,6 @@ char *rep_strdup(const char *s)
}
#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)
{
diff --git a/source/lib/replace/replace.h b/source/lib/replace/replace.h
index 00c8230..383536d 100644
--- a/source/lib/replace/replace.h
+++ b/source/lib/replace/replace.h
@@ -325,7 +325,7 @@ ssize_t rep_pread(int __fd, void *__buf, size_t __nbytes, off_t __offset);
ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset);
#endif
-#ifdef REPLACE_INET_NTOA
+#if !defined(HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
#define inet_ntoa rep_inet_ntoa
/* prototype is in "system/network.h" */
#endif
diff --git a/source/lib/replace/system/network.h b/source/lib/replace/system/network.h
index 8c606c8..7c23773 100644
--- a/source/lib/replace/system/network.h
+++ b/source/lib/replace/system/network.h
@@ -88,7 +88,7 @@
typedef int socklen_t;
#endif
-#ifdef REPLACE_INET_NTOA
+#if !defined (HAVE_INET_NTOA) || defined(REPLACE_INET_NTOA)
/* define is in "replace.h" */
char *rep_inet_ntoa(struct in_addr ip);
#endif
--
Samba Shared Repository
More information about the samba-cvs
mailing list