--- parser3/src/main/pa_socks.C 2003/07/24 11:31:24 1.19 +++ parser3/src/main/pa_socks.C 2006/04/09 12:25:04 1.24.12.1 @@ -1,11 +1,11 @@ /** @file Parser: socks initialization/finalization. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_SOCKS_C="$Date: 2003/07/24 11:31:24 $"; +static const char * const IDENT_SOCKS_C="$Date: 2006/04/09 12:25:04 $"; #define NO_UNISTD_H #include "pa_config_includes.h" @@ -17,6 +17,7 @@ static const char* IDENT_SOCKS_C="$Date: // in cygwin: for pascal // in MSVC: for everything +#define WINVER 0x0400 #include #ifdef CYGWIN @@ -40,7 +41,7 @@ int PASCAL WSACleanup(void); WSADATA wsaData; -void pa_init_socks() { +void pa_socks_init() { WORD wVersionRequested; int err; wVersionRequested = MAKEWORD( 1, 1 ); @@ -56,7 +57,7 @@ void pa_init_socks() { } } -void pa_done_socks() { +void pa_socks_done() { /* Confirm that the WinSock DLL supports 2.2.*/ /* Note that if the DLL supports versions greater */ /* than 2.2 in addition to 2.2, it will still return */ @@ -69,9 +70,37 @@ void pa_done_socks() { } } +const char* pa_socks_strerr(int no) { + char buf[MAX_STRING]; + buf[0]=0; + size_t error_size=FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + no, + 0, // Default language + (LPTSTR) &buf, + sizeof(buf), + NULL + ); + if(error_size>3) // ".\r\n" + buf[error_size-3]=0; + return buf[0]? pa_strdup(buf): "unknown error"; +} +int pa_socks_errno() { + return WSAGetLastError(); +} + #else -void pa_init_socks() {} -void pa_done_socks() {} +void pa_socks_init() {} +void pa_socks_done() {} + +const char* pa_socks_strerr(int no) { + return strerror(no); +} +int pa_socks_errno() { + return errno; +} #endif