]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/init.c
fix non-printable flag detection; improve dn test (passes all but last in http:/...
[openldap] / libraries / libldap / init.c
index e123e06118d36bd84c65e87c1a166204d44ffcb2..46f8f7768a957632851a906fb24b5429f33c55b0 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 #include "portable.h"
@@ -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
 }
 
 /* 
@@ -445,11 +448,44 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
 
        ldap_int_error_init();
 
+#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
+
 #if defined(LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND) \
        || defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
        ldap_int_hostname = ldap_pvt_get_fqdn( ldap_int_hostname );
 #endif
-
        ldap_int_utils_init();
 
        if ( ldap_int_tblsize == 0 )