]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/sockpair.c
Output from ldif_fetch_url() is expected to be \0-terminated.
[openldap] / libraries / liblutil / sockpair.c
index 6caa3b0aadcf8d7fc25b4bfd0703cbf2420c117f..e831408c4aef65c4ceac1fa642dfea2c9de04963 100644 (file)
@@ -1,10 +1,12 @@
+/* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
 #include "portable.h"
 #include <ac/socket.h>
+#include <ac/unistd.h>
 
 #include <lutil.h>
 
  * this function is best implemented using a single pipe() call.
  */
 
-int lutil_pair( LBER_SOCKET_T sds[2] )
+int lutil_pair( ber_socket_t sds[2] )
 {
 #ifdef USE_PIPE
        return pipe( sds );
 #else
        struct sockaddr_in si;
        int rc, len = sizeof(si);
-       LBER_SOCKET_T sd;
+       ber_socket_t sd;
 
        sd = socket( AF_INET, SOCK_DGRAM, 0 );
-       if ( sd == AC_SOCKET_INVALID )
+       if ( sd == AC_SOCKET_INVALID ) {
                return sd;
+       }
        
-       (void) memset( (void*) &si, 0, len );
+       (void) memset( (void*) &si, '\0', len );
        si.sin_family = AF_INET;
        si.sin_port = 0;
        si.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
@@ -54,7 +57,12 @@ int lutil_pair( LBER_SOCKET_T sds[2] )
                return rc;
        }
 
-       sds[0] = sds[1] = sd;
+       sds[0] = sd;
+#if !HAVE_WINSOCK
+       sds[1] = dup( sds[0] );
+#else
+       sds[1] = sds[0];
+#endif
        return 0;
 #endif
 }