]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/init.c
Fix extensible filters
[openldap] / libraries / libldap / init.c
index 080cd336d0d7b1598feb98e8a15fe23cb9090a0a..9b5fa84c882c70caa1b511482c842e16d88da4ff 100644 (file)
@@ -365,7 +365,7 @@ static void openldap_ldap_init_w_env(
 }
 
 static void
-ldap_int_destroy_global_options()
+ldap_int_destroy_global_options(void)
 {
        struct ldapoptions *gopts = LDAP_INT_GLOBAL_OPT();
 
@@ -373,6 +373,9 @@ ldap_int_destroy_global_options()
                ldap_free_urllist( gopts->ldo_defludp );
                gopts->ldo_defludp = NULL;
        }
+#if defined(HAVE_WINSOCK) || defined(HAVE_WINSOCK2)
+       WSACleanup( );
+#endif
 }
 
 /* 
@@ -450,6 +453,39 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
        ldap_int_hostname = ldap_pvt_get_fqdn( ldap_int_hostname );
 #endif
 
+#ifdef HAVE_WINSOCK2
+{      WORD wVersionRequested;
+       WSADATA wsaData;
+       wVersionRequested = MAKEWORD( 2, 0 );
+       if ( WSAStartup( wVersionRequested, &wsaData ) != 0 ) {
+               /* Tell the user that we couldn't find a usable */
+               /* WinSock DLL.                                  */
+               return;
+       }
+       /* Confirm that the WinSock DLL supports 2.0.*/
+       /* Note that if the DLL supports versions greater    */
+       /* than 2.0 in addition to 2.0, it will still return */
+       /* 2.0 in wVersion since that is the version we      */
+       /* requested.                                        */
+       if ( LOBYTE( wsaData.wVersion ) != 2 ||
+               HIBYTE( wsaData.wVersion ) != 0 )
+       {
+           /* Tell the user that we couldn't find a usable */
+           /* WinSock DLL.                                  */
+           WSACleanup( );
+           return; 
+       }
+}      /* The WinSock DLL is acceptable. Proceed. */
+#elif HAVE_WINSOCK
+{      WSADATA wsaData;
+       if ( WSAStartup( 0x0101, &wsaData ) != 0 ) {
+           return;
+       }
+}
+#endif
        ldap_int_utils_init();
 
        if ( ldap_int_tblsize == 0 )