--- parser3/src/main/pa_socks.C 2003/02/04 10:57:16 1.18.2.5 +++ parser3/src/main/pa_socks.C 2004/10/06 10:55:10 1.23 @@ -1,11 +1,11 @@ /** @file Parser: socks initialization/finalization. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_SOCKS_C="$Date: 2003/02/04 10:57:16 $"; +static const char * const IDENT_SOCKS_C="$Date: 2004/10/06 10:55:10 $"; #define NO_UNISTD_H #include "pa_config_includes.h" @@ -40,7 +40,7 @@ int PASCAL WSACleanup(void); WSADATA wsaData; -void pa_init_socks() { +void pa_socks_init() { WORD wVersionRequested; int err; wVersionRequested = MAKEWORD( 1, 1 ); @@ -50,13 +50,13 @@ void pa_init_socks() { /* Tell the user that we could not find a usable */ /* WinSock DLL. */ throw Exception(0, - Exception::undefined_source, + 0, "can not WSAStartup, err=%d", err); } } -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 +69,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