The branch, v3-2-test has been updated
       via  c19f7a0e1004213f95e0bf8db5cd1f6697c7a47b (commit)
      from  622667c0790c0092bfceced8dc6fb05e781ac5e7 (commit)

http://gitweb.samba.org/?samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit c19f7a0e1004213f95e0bf8db5cd1f6697c7a47b
Author: Michael Adam <[EMAIL PROTECTED]>
Date:   Tue Feb 26 13:24:54 2008 +0100

    libreplace: Add tests for connect and gethostbyname.
    
    Provide dummy replacements when a function isnt found.
    The functions are also searched for in certain libraries,
    and variables SOCKET_LIBS and NSL_LIBS are set accordingly.
    
    One purpose of this is to fix the getifaddrs tests on
    systems where e.g. the socket calls require special libs
    for linking.
    
    Michael

-----------------------------------------------------------------------

Summary of changes:
 source/lib/replace/libreplace.m4                   |    1 +
 source/lib/replace/replace.h                       |   10 +++++
 .../transfer_file.h => lib/replace/socket.c}       |   27 +++++++------
 source/lib/replace/socket.m4                       |   40 ++++++++++++++++++++
 source/lib/replace/system/network.h                |   10 +++++
 5 files changed, 76 insertions(+), 12 deletions(-)
 copy source/{include/transfer_file.h => lib/replace/socket.c} (61%)
 create mode 100644 source/lib/replace/socket.m4


Changeset truncated at 500 lines:

diff --git a/source/lib/replace/libreplace.m4 b/source/lib/replace/libreplace.m4
index 2e0cd34..e0cc57f 100644
--- a/source/lib/replace/libreplace.m4
+++ b/source/lib/replace/libreplace.m4
@@ -344,6 +344,7 @@ m4_include(getpass.m4)
 m4_include(strptime.m4)
 m4_include(win32.m4)
 m4_include(timegm.m4)
+m4_include(socket.m4)
 m4_include(inet_ntop.m4)
 m4_include(inet_pton.m4)
 m4_include(getaddrinfo.m4)
diff --git a/source/lib/replace/replace.h b/source/lib/replace/replace.h
index 3f91544..0d16f4f 100644
--- a/source/lib/replace/replace.h
+++ b/source/lib/replace/replace.h
@@ -340,6 +340,16 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t 
__nbytes, off_t __offset)
 /* prototype is in "system/network.h" */
 #endif
 
+#ifndef HAVE_CONNECT
+#define connect rep_connect
+/* prototype is in "system/network.h" */
+#endif
+
+#ifndef HAVE_GETHOSTBYNAME
+#define gethostbyname rep_gethostbyname
+/* prototype is in "system/network.h" */
+#endif
+
 #ifndef HAVE_GETIFADDRS
 #define getifaddrs rep_getifaddrs
 /* prototype is in "system/network.h" */
diff --git a/source/include/transfer_file.h b/source/lib/replace/socket.c
similarity index 61%
copy from source/include/transfer_file.h
copy to source/lib/replace/socket.c
index 79ad9c4..35e975f 100644
--- a/source/include/transfer_file.h
+++ b/source/lib/replace/socket.c
@@ -1,8 +1,9 @@
 /*
  * Unix SMB/CIFS implementation.
- * Utility functions to transfer files.
  *
- * Copyright (C) Michael Adam 2008
+ * Dummy replacements for socket functions.
+ *
+ * Copyright (C) Michael Adam <[EMAIL PROTECTED]> 2008
  *
  * 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,15 +19,17 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __TRANSFER_FILE_H__
-#define __TRANSFER_FILE_H__
-
-ssize_t transfer_file_internal(void *in_file,
-                              void *out_file,
-                              size_t n,
-                              ssize_t (*read_fn)(void *, void *, size_t),
-                              ssize_t (*write_fn)(void *, const void *, 
size_t));
+#include "replace.h"
+#include "system/network.h"
 
-SMB_OFF_T transfer_file(int infd, int outfd, SMB_OFF_T n);
+int rep_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t 
addrlen)
+{
+       errno = ENOSYS;
+       return -1;
+}
 
-#endif /* __TRANSFER_FILE_H__ */
+struct hostent *rep_gethostbyname(const char *name)
+{
+       errno = ENOSYS;
+       return NULL;
+}
diff --git a/source/lib/replace/socket.m4 b/source/lib/replace/socket.m4
new file mode 100644
index 0000000..c0c8f93
--- /dev/null
+++ b/source/lib/replace/socket.m4
@@ -0,0 +1,40 @@
+dnl The following test is roughl taken from the cvs sources.
+dnl
+dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
+dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
+dnl libsocket.so which has a bad implementation of gethostbyname (it
+dnl only looks in /etc/hosts), so we only look for -lsocket if we need
+dnl it.
+AC_CHECK_FUNCS(connect)
+if test x"$ac_cv_func_connect" = x"no"; then
+       AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect)
+       AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect)
+       AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect)
+       AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect)
+       dnl We can't just call AC_CHECK_FUNCS(connect) here,
+       dnl because the value has been cached.
+       if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
+               test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
+               test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
+               test x"$ac_cv_lib_ext_inet_connect" = x"yes"
+       then
+               AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
+       fi
+fi
+
+AC_CHECK_FUNCS(gethostbyname)
+if test x"$ac_cv_func_gethostbyname" = x"no"; then
+       AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname)
+       AC_CHECK_LIB_EXT(nsl, NSL_LIBS, gethostbyname)
+       AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname)
+       dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
+       dnl because the value has been cached.
+       if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
+               test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" ||
+               test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes"
+       then
+               AC_DEFINE(HAVE_GETHOSTBYNAME,1,
+                         [Whether the system has gethostbyname()])
+       fi
+fi
+
diff --git a/source/lib/replace/system/network.h 
b/source/lib/replace/system/network.h
index a84b22e..410c6d7 100644
--- a/source/lib/replace/system/network.h
+++ b/source/lib/replace/system/network.h
@@ -103,6 +103,16 @@ int rep_inet_pton(int af, const char *src, void *dst);
 const char *rep_inet_ntop(int af, const void *src, char *dst, socklen_t size);
 #endif
 
+#ifndef HAVE_CONNECT
+/* define is in "replace.h" */
+int rep_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
+#endif
+
+#ifndef HAVE_GETHOSTBYNAME
+/* define is in "replace.h" */
+struct hostent *rep_gethostbyname(const char *name);
+#endif
+
 #ifdef HAVE_IFADDRS_H
 #include <ifaddrs.h>
 #endif


-- 
Samba Shared Repository

Reply via email to