]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/init.c
Fix extensible filters
[openldap] / libraries / libldap / init.c
index e123e06118d36bd84c65e87c1a166204d44ffcb2..9b5fa84c882c70caa1b511482c842e16d88da4ff 100644 (file)
@@ -373,6 +373,9 @@ ldap_int_destroy_global_options(void)
                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 )