svn commit: samba r19393 - in
branches/SAMBA_4_0/source/lib/replace: . test
jelmer at samba.org
jelmer at samba.org
Wed Oct 18 16:08:22 GMT 2006
Author: jelmer
Date: 2006-10-18 16:08:22 +0000 (Wed, 18 Oct 2006)
New Revision: 19393
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19393
Log:
Add replacement function for socketpair()
Modified:
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/test/testsuite.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/replace.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.c 2006-10-18 14:23:19 UTC (rev 19392)
+++ branches/SAMBA_4_0/source/lib/replace/replace.c 2006-10-18 16:08:22 UTC (rev 19393)
@@ -590,3 +590,24 @@
}
#endif
+#ifndef HAVE_SOCKETPAIR
+int rep_socketpair(int d, int type, int protocol, int sv[2])
+{
+ if (d != AF_UNIX) {
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+
+ if (protocol != 0) {
+ errno = EPROTONOSUPPORT;
+ return -1;
+ }
+
+ if (type != SOCK_STREAM) {
+ errno = EOPNOTSUPP;
+ return -1;
+ }
+
+ return pipe(sock);
+}
+#endif
Modified: branches/SAMBA_4_0/source/lib/replace/replace.h
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.h 2006-10-18 14:23:19 UTC (rev 19392)
+++ branches/SAMBA_4_0/source/lib/replace/replace.h 2006-10-18 16:08:22 UTC (rev 19393)
@@ -209,6 +209,10 @@
int rep_dlclose(void *handle);
#endif
+#ifndef HAVE_SOCKETPAIR
+#define socketpair rep_socketpair
+int rep_socketpair(int d, int type, int protocol, int sv[2]);
+#endif
#ifndef PRINTF_ATTRIBUTE
#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
Modified: branches/SAMBA_4_0/source/lib/replace/test/testsuite.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-10-18 14:23:19 UTC (rev 19392)
+++ branches/SAMBA_4_0/source/lib/replace/test/testsuite.c 2006-10-18 16:08:22 UTC (rev 19393)
@@ -376,6 +376,46 @@
return true;
}
+static bool test_socketpair(void)
+{
+ int sock[2];
+ char buf[20];
+
+ printf("test: socketpair\n");
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) {
+ printf("failure: socketpair [\n"
+ "socketpair() failed\n"
+ "]\n");
+ return false;
+ }
+
+ if (write(sock[0], "automatisch", 12) == -1) {
+ printf("failure: socketpair [\n"
+ "write() failed: %s\n"
+ "]\n", strerror(errno));
+ return false;
+ }
+
+ if (read(sock[1], buf, 12) == -1) {
+ printf("failure: socketpair [\n"
+ "read() failed: %s\n"
+ "]\n", strerror(errno));
+ return false;
+ }
+
+ if (strcmp(buf, "automatisch") != 0) {
+ printf("failure: socketpair [\n"
+ "expected: automatisch, got: %s\n"
+ "]\n", buf);
+ return false;
+ }
+
+ printf("success: socketpair\n");
+
+ return true;
+}
+
struct torture_context;
int main()
@@ -424,6 +464,7 @@
ret &= test_FUNCTION();
ret &= test_MIN();
ret &= test_MAX();
+ ret &= test_socketpair();
if (ret)
return 0;
More information about the samba-cvs
mailing list