From 74d93ac2f862f15ac20ad48e0887e2f7edd0fd04 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 28 Oct 1999 07:17:08 +0000 Subject: [PATCH] Fix Winsock-related warning and/or bugs. See README 1.27 log --- libraries/liblber/sockbuf.c | 17 +++++++++++++++-- libraries/libldap/tmplout.c | 1 + libraries/liblutil/nt_err.c | 11 ++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c index 30bceb6bed..976f9aa56b 100644 --- a/libraries/liblber/sockbuf.c +++ b/libraries/liblber/sockbuf.c @@ -891,9 +891,17 @@ stream_read( Sockbuf *sb, void *buf, ber_len_t len ) { int rc; rc = recv( ber_pvt_sb_get_desc(sb), buf, len, 0 ); + #ifdef HAVE_WINSOCK - if ( rc < 0 ) errno = WSAGetLastError(); + if ( rc < 0 ) + { + int err; + + err = WSAGetLastError(); + errno = err; + } #endif + return rc; } #elif defined( HAVE_NCSA ) @@ -938,7 +946,12 @@ stream_write( Sockbuf *sb, void *buf, ber_len_t len ) int rc; rc = send( ber_pvt_sb_get_desc(sb), buf, len, 0 ); #ifdef HAVE_WINSOCK - if ( rc < 0 ) errno = WSAGetLastError(); + if ( rc < 0 ) + { + int err; + err = WSAGetLastError(); + errno = err; + } #endif return rc; } diff --git a/libraries/libldap/tmplout.c b/libraries/libldap/tmplout.c index 280e762965..e804fe0be7 100644 --- a/libraries/libldap/tmplout.c +++ b/libraries/libldap/tmplout.c @@ -12,6 +12,7 @@ #include +#include #include #include diff --git a/libraries/liblutil/nt_err.c b/libraries/liblutil/nt_err.c index 6d119d2b3d..15c9ec573c 100644 --- a/libraries/liblutil/nt_err.c +++ b/libraries/liblutil/nt_err.c @@ -1,8 +1,10 @@ /* $OpenLDAP$ */ #include "portable.h" -#ifdef HAVE_WINSOCK2 -#include +#include + +#ifdef HAVE_WINSOCK +#include #define __RETSTR( x ) case x: return #x; @@ -57,6 +59,8 @@ char *WSAGetErrorString( int err ) __RETSTR( WSAVERNOTSUPPORTED ) __RETSTR( WSANOTINITIALISED ) __RETSTR( WSAEDISCON ) + +#ifdef HAVE_WINSOCK2 __RETSTR( WSAENOMORE ) __RETSTR( WSAECANCELLED ) __RETSTR( WSAEINVALIDPROCTABLE ) @@ -67,6 +71,7 @@ char *WSAGetErrorString( int err ) __RETSTR( WSA_E_NO_MORE ) __RETSTR( WSA_E_CANCELLED ) __RETSTR( WSAEREFUSED ) +#endif // HAVE_WINSOCK2 __RETSTR( WSAHOST_NOT_FOUND ) __RETSTR( WSATRY_AGAIN ) @@ -83,7 +88,7 @@ char *WSAGetLastErrorString( void ) #undef __RETSTR -#endif /* HAVE_WINSOCK2 */ +#endif /* HAVE_WINSOCK */ char *GetErrorString( int err ) -- 2.39.5