From fc47a2c83c4b6c6d47f3c73fd3879fc92eb9c4b3 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 19 Jul 1996 21:41:07 +0000 Subject: updated w32 code by tulloh --- w32/subproc/w32err.c | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'w32/subproc/w32err.c') diff --git a/w32/subproc/w32err.c b/w32/subproc/w32err.c index e4e8835..8abd75b 100644 --- a/w32/subproc/w32err.c +++ b/w32/subproc/w32err.c @@ -1,51 +1,51 @@ -#include -#include "w32err.h" - -/* - * Description: the win32 version of perror() - * - * Returns: a pointer to a static error - * - * Notes/Dependencies: I got this from - * comp.os.ms-windows.programmer.win32 - */ -char * -map_win32_error_to_string (DWORD ercode) { -/* __declspec (thread) necessary if you will use multiple threads */ -__declspec (thread) static char szMessageBuffer[128]; - - /* Fill message buffer with a default message in - * case FormatMessage fails - */ - wsprintf (szMessageBuffer, "Error %ld", ercode); - - /* - * Special code for winsock error handling. - */ - if (ercode > WSABASEERR) { - HMODULE hModule = GetModuleHandle("wsock32"); - if (hModule != NULL) { - FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, - hModule, - ercode, - LANG_NEUTRAL, - szMessageBuffer, - sizeof(szMessageBuffer), - NULL); - FreeLibrary(hModule); - } - } else { - /* - * Default system message handling - */ - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, - NULL, - ercode, - LANG_NEUTRAL, - szMessageBuffer, - sizeof(szMessageBuffer), - NULL); - } - return szMessageBuffer; -} - +#include +#include "w32err.h" + +/* + * Description: the win32 version of perror() + * + * Returns: a pointer to a static error + * + * Notes/Dependencies: I got this from + * comp.os.ms-windows.programmer.win32 + */ +char * +map_win32_error_to_string (DWORD ercode) { +/* __declspec (thread) necessary if you will use multiple threads */ +__declspec (thread) static char szMessageBuffer[128]; + + /* Fill message buffer with a default message in + * case FormatMessage fails + */ + wsprintf (szMessageBuffer, "Error %ld", ercode); + + /* + * Special code for winsock error handling. + */ + if (ercode > WSABASEERR) { + HMODULE hModule = GetModuleHandle("wsock32"); + if (hModule != NULL) { + FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, + hModule, + ercode, + LANG_NEUTRAL, + szMessageBuffer, + sizeof(szMessageBuffer), + NULL); + FreeLibrary(hModule); + } + } else { + /* + * Default system message handling + */ + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + ercode, + LANG_NEUTRAL, + szMessageBuffer, + sizeof(szMessageBuffer), + NULL); + } + return szMessageBuffer; +} + -- cgit v1.2.3