bryner%uiuc.edu 9b12bf288a GNU Make 3.79.1, hacked to use shmsdos. This is necessary because the old
version, based off of 3.74, seems to have problems with NSPR autoconf.

r=cls.


git-svn-id: svn://10.0.0.236/trunk@85225 18797224-902f-48f8-a5cc-f745e15eee43
2001-01-21 08:07:01 +00:00

52 lines
1.2 KiB
C

#include <windows.h>
#include "w32err.h"
/*
* Description: the windows32 version of perror()
*
* Returns: a pointer to a static error
*
* Notes/Dependencies: I got this from
* comp.os.ms-windows.programmer.win32
*/
char *
map_windows32_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;
}