]> git.sur5r.net Git - openldap/commitdiff
Rework ac/socket.h for HAVE_WINSOCK:
authorKurt Zeilenga <kurt@openldap.org>
Mon, 29 Mar 1999 05:15:59 +0000 (05:15 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 29 Mar 1999 05:15:59 +0000 (05:15 +0000)
  tcp_close -> closesocket
  ioctl -> ioctlsocket
Modify codes to use tcp_close() instead of close() for sockets.
Modify ioctl codes to be compatible with WINSOCK.

clients/gopher/go500.c
clients/gopher/go500gw.c
include/ac/socket.h
libraries/liblber/sockbuf.c
libraries/libldap/cldap.c
servers/ldapd/main.c
servers/slapd/daemon.c

index 1be51161c0dad271f24d83efe46cbc08c0d096a8..5eca20ad11df9f6e725c8fa2ffce3a3e4068e02a 100644 (file)
@@ -254,7 +254,7 @@ main( int argc, char **argv )
 
                switch( pid = fork() ) {
                case 0:         /* child */
-                       close( s );
+                       tcp_close( s );
                        do_queries( ns );
                        break;
 
@@ -263,7 +263,7 @@ main( int argc, char **argv )
                        break;
 
                default:        /* parent */
-                       close( ns );
+                       tcp_close( ns );
                        if ( debug )
                                fprintf( stderr, "forked child %d\n", pid );
                        break;
index b0c1a65d5b2ad8625f74e08ba78855bfb0fe289a..e03bd4b4f821fd3559ecbc940e44857197d31e8e 100644 (file)
@@ -243,7 +243,7 @@ main (int  argc, char **argv )
 
                do_queries( 0 );
 
-               close( 0 );
+               tcp_close( 0 );
 
                exit( 0 );
        }
@@ -280,7 +280,7 @@ main (int  argc, char **argv )
 
                switch( pid = fork() ) {
                case 0:         /* child */
-                       close( s );
+                       tcp_close( s );
                        do_queries( ns );
                        break;
 
@@ -289,7 +289,7 @@ main (int  argc, char **argv )
                        break;
 
                default:        /* parent */
-                       close( ns );
+                       tcp_close( ns );
                        if ( debug )
                                fprintf( stderr, "forked child %d\n", pid );
                        break;
index 415f5a265fc773e67382838ffe8a16a7d0a044c5..466cccd442eea0495dd6b6251d7d3ddfa1a667b6 100644 (file)
 #define MAXHOSTNAMELEN  64
 #endif
 
-#ifdef MACOS
-#define tcp_close( s )         tcpclose( s )
-#else /* MACOS */
-#ifdef DOS
-#ifdef PCNFS
-#define tcp_close( s )         close( s )
-#endif /* PCNFS */
-#ifdef NCSA
-#define tcp_close( s )         netclose( s ); netshut()
-#endif /* NCSA */
-#ifdef WINSOCK
-#define tcp_close( s )         closesocket( s );
-#endif /* WINSOCK */
-#else /* DOS */
-#define tcp_close( s )         close( s )
-#endif /* DOS */
+#ifdef HAVE_WINSOCK
+#      define tcp_close( s )           closesocket( s );
+#      define ioctl( s, c, a )         ioctlsocket( (s), (c), (a) )
+#elif MACOS
+#      define tcp_close( s )           tcpclose( s )
+#elif DOS
+#      ifdef PCNFS
+#              define tcp_close( s )   close( s )
+#      endif /* PCNFS */
+#      ifdef NCSA
+#              define tcp_close( s )   do { netclose( s ); netshut() } while(0)
+#      endif /* NCSA */
+#else
+#      define tcp_close( s )           close( s )
 #endif /* MACOS */
 
 #if !defined(__alpha) || defined(VMS)
index d07926e08e59f6a5953f8425df6e251827fd6c86..1b4adad44d95ba241a644abdc405782602a64aec 100644 (file)
@@ -579,8 +579,9 @@ int lber_pvt_sb_set_nonblock( Sockbuf *sb, int nb )
    }
 #ifdef FIONBIO
    if (lber_pvt_sb_in_use(sb)) {
-      int status = (nb!=0);
-      if (ioctl( lber_pvt_sb_get_desc(sb), FIONBIO, (caddr_t)&status ) == -1 ) {
+          /* WINSOCK requires the status to be a long */
+               u_long status = (nb!=0);
+               if (ioctl( lber_pvt_sb_get_desc(sb), FIONBIO, &status ) == -1 ) {
         return -1;
       }
    }
index 55f1be4fb9faac15ff96755cd9e1ea60ea09f8eb..126e1695b4cbdbb8c13a2f7e554ec649ed4b584b 100644 (file)
@@ -81,11 +81,11 @@ cldap_open( char *host, int port )
     sock.sin_family = AF_INET;
     sock.sin_port = 0;
     if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0)  {
-       close( s );
+       tcp_close( s );
        return( NULL );
     }
     if (( ld = ldap_init( host, port )) == NULL ) {
-       close( s );
+       tcp_close( s );
        return( NULL );
     }
        
index 5e91ec6ea31fea8159093d4234c6986ada064e71..3f0e3d3580a15f4a2294fb559e39a58fb0cc7858 100644 (file)
@@ -418,7 +418,7 @@ main( int argc, char **argv )
                                    inet_ntoa( from.sin_addr ) );
                        }
 
-                       close(ns);
+                       tcp_close(ns);
                        continue;
                }
 #endif /* TCP_WRAPPERS */
@@ -436,7 +436,7 @@ main( int argc, char **argv )
 
 #ifdef VMS
                /* This is for debug on terminal on VMS */
-               close( tcps );
+               tcp_close( tcps );
 #ifdef LDAP_PROCTITLE
                setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
                    hp->h_name );
@@ -450,7 +450,7 @@ main( int argc, char **argv )
 
                switch( pid = fork() ) {
                case 0:         /* child */
-                       close( tcps );
+                       tcp_close( tcps );
 #ifdef LDAP_PROCTITLE
                         sprintf( title, "%s (%d)\n", hp == NULL ?
                                inet_ntoa( from.sin_addr ) : hp->h_name,
@@ -467,14 +467,14 @@ main( int argc, char **argv )
 #ifdef LDAP_DEBUG
                        if ( ldap_debug ) perror( "fork" );
 #endif
-                       close( ns );
+                       tcp_close( ns );
                        syslog( LOG_ERR, "fork failed %m" );
                        /* let things cool off */
                        sleep( 15 );
                        break;
 
                default:        /* parent */
-                       close( ns );
+                       tcp_close( ns );
                        Debug( LDAP_DEBUG_TRACE, "forked child %d\n", pid, 0,
                            0 );
                        break;
index 58954d3026f187619f4a90f1e2b8d7dcbaa5ab93..0f3c859860013d54f15dbb12a2a2faabf722bf71 100644 (file)
@@ -149,7 +149,7 @@ static void slapd_close(int s) {
        slapd_remove(s);
 
        Debug( LDAP_DEBUG_CONNS, "daemon: closing %d\n", s, 0, 0 );
-       close(s);
+       tcp_close(s);
 }
 
 static void *
@@ -357,7 +357,7 @@ slapd_daemon_task(
                                Debug( LDAP_DEBUG_ANY,
                                        "daemon: %d beyond descriptor table size %d\n",
                                        s, dtblsize, 0 );
-                               close(s);
+                               tcp_close(s);
                                continue;
                        }
 #endif
@@ -409,7 +409,7 @@ slapd_daemon_task(
                                        client_addr == NULL ? "unknown" : client_addr,
                                  0, 0 );
 
-                               close(s);
+                               tcp_close(s);
                                continue;
                        }
 #endif /* HAVE_TCPD */
@@ -420,7 +420,7 @@ slapd_daemon_task(
                                        s,
                                        client_name == NULL ? "unknown" : client_name,
                                        client_addr == NULL ? "unknown" : client_addr);
-                               close(s);
+                               tcp_close(s);
                                continue;
                        }
 
@@ -510,7 +510,7 @@ slapd_daemon_task(
        }
 
        if( tcps >= 0 ) {
-               close( tcps );
+               tcp_close( tcps );
        }
 
        ldap_pvt_thread_mutex_lock( &active_threads_mutex );