Commit 5c296dc0 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Minor changes to support NT.

parent 3449d4b8
......@@ -27,6 +27,8 @@
#include <winsock2.h>
#elif HAVE_WINSOCK
#include <winsock.h>
#else
#define WSACleanup()
#endif
#ifdef HAVE_PCNFS
......@@ -48,7 +50,7 @@
#define tcp_close( s ) netclose( s ); netshut()
#endif /* NCSA */
#ifdef WINSOCK
#define tcp_close( s ) closesocket( s ); WSACleanup();
#define tcp_close( s ) closesocket( s );
#endif /* WINSOCK */
#else /* DOS */
#define tcp_close( s ) close( s )
......
......@@ -111,14 +111,51 @@ ldap_init( char *defhost, int defport )
Debug( LDAP_DEBUG_TRACE, "ldap_init\n", 0, 0, 0 );
#ifdef HAVE_WINSOCK2
{ WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 0 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
/* Tell the user that we couldn't find a usable */
/* WinSock DLL. */
return NULL;
}
/* 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 NULL;
}
} /* The WinSock DLL is acceptable. Proceed. */
#elif HAVE_WINSOCK
if ( WSAStartup( 0x0101, &wsadata ) != 0 ) {
return( NULL );
}
#endif
if ( (ld = (LDAP *) calloc( 1, sizeof(LDAP) )) == NULL ) {
WSACleanup( );
return( NULL );
}
#ifdef LDAP_REFERRALS
if (( ld->ld_selectinfo = ldap_new_select_info()) == NULL ) {
free( (char*)ld );
WSACleanup( );
return( NULL );
}
ld->ld_options = LDAP_OPT_REFERRALS;
......@@ -130,6 +167,7 @@ ldap_init( char *defhost, int defport )
ldap_free_select_info( ld->ld_selectinfo );
#endif /* LDAP_REFERRALS */
free( (char*)ld );
WSACleanup( );
return( NULL );
}
......
......@@ -58,7 +58,11 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
if ( host != NULL && ( address = inet_addr( host )) == -1 ) {
if ( (hp = gethostbyname( host )) == NULL ) {
#ifdef HAVE_WINSOCK
errno = WSAGetLastError();
#else
errno = EHOSTUNREACH; /* not exactly right, but... */
#endif
return( -1 );
}
use_hp = 1;
......@@ -91,6 +95,9 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
rc = 0;
break;
} else {
#ifdef HAVE_WINSOCK
errno = WSAGetLastError();
#endif
#ifdef notyet
#ifdef LDAP_REFERRALS
#ifdef EAGAIN
......@@ -111,7 +118,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
perror( (char *)inet_ntoa( sin.sin_addr ));
}
#endif
close( s );
tcp_close( s );
if ( !use_hp ) {
break;
}
......
......@@ -105,6 +105,8 @@ ldap_ld_free( LDAP *ld, int close )
free( (char *) ld );
WSACleanup();
return( err );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment