From: Kurt Zeilenga Date: Thu, 22 Oct 1998 23:25:45 +0000 (+0000) Subject: Add in WINSOCK2 ifdefs (ugh). X-Git-Tag: PHP3_TOOL_0_0~40 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5ee53ca8517c5de6d3c1139a1982ccad1488150f;p=openldap Add in WINSOCK2 ifdefs (ugh). --- diff --git a/libraries/libldap/cldap.c b/libraries/libldap/cldap.c index 806a6ce91c..f319c415b5 100644 --- a/libraries/libldap/cldap.c +++ b/libraries/libldap/cldap.c @@ -127,7 +127,7 @@ cldap_open( char *host, int port ) } } - if ( (address = inet_addr( host )) == -1 ) { + if ( inet_aton( host, &address ) == 0 ) { if ( (hp = gethostbyname( host )) == NULL ) { errno = EHOSTUNREACH; continue; diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index 974a45ac04..3d9a7c630c 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -64,9 +64,20 @@ ldap_open( char *host, int port ) #ifdef LDAP_REFERRALS LDAPServer *srv; #endif /* LDAP_REFERRALS */ +#ifdef HAVE_WINSOCK_2 + WORD wVersionRequested; + WSADATA wsaData; +#endif Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 ); +#ifdef HAVE_WINSOCK_2 + wVersionRequested = MAKEWORD( 2, 0 ); + if ( WSAStartup( wVersionRequested, &wsadata ) != 0 ) { + return( NULL ); + } +#endif + if (( ld = ldap_init( host, port )) == NULL ) { return( NULL ); } @@ -76,6 +87,9 @@ ldap_open( char *host, int port ) NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host = strdup( ld->ld_defhost )) == NULL )) { ldap_ld_free( ld, 0 ); +#ifdef HAVE_WINSOCK_2 + WSACleanup(); +#endif return( NULL ); } srv->lsrv_port = ld->ld_defport; @@ -84,6 +98,9 @@ ldap_open( char *host, int port ) if ( ld->ld_defhost != NULL ) free( srv->lsrv_host ); free( (char *)srv ); ldap_ld_free( ld, 0 ); +#ifdef HAVE_WINSOCK_2 + WSACleanup(); +#endif return( NULL ); } ++ld->ld_defconn->lconn_refcnt; /* so it never gets closed/freed */ @@ -92,6 +109,9 @@ ldap_open( char *host, int port ) if ( open_ldap_connection( ld, &ld->ld_sb, ld->ld_defhost, ld->ld_defport, &ld->ld_host, 0 ) < 0 ) { ldap_ld_free( ld, 0 ); +#ifdef HAVE_WINSOCK_2 + WSACleanup(); +#endif return( NULL ); } #endif /* LDAP_REFERRALS */ diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index cc358ceefc..37112bc959 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -96,7 +96,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address, connected = use_hp = 0; - if ( host != NULL && ( address = inet_addr( host )) == -1 ) { + if ( host != NULL && ( inet_aton( host, &address ) == 0 ) ) { if ( (hp = gethostbyname( host )) == NULL ) { errno = EHOSTUNREACH; /* not exactly right, but... */ return( -1 );