mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
I'm at the win32 error messages once more. The DLL load thingy doesn't
work on all win9x machines, so i made it go thru a l ookup table instead, using the DLL as last resort. I also moved this out of the fe-misc.c file because of the size of the lookup ta ble. Who knows, we might add more other win32 specific code there in the future. I also fixed a small typo in the pg_config.h.win32 that made the compiler compla in about the gnu snprintf declaration. I tried to make this patch with psql coding style. I've successfully tested this on win2k and win98 and it works fine (i.e. the mes sage shows on win98 too, it didn't with the old implementation). Magnus Naeslund
This commit is contained in:
@ -25,7 +25,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.69 2002/04/15 23:34:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.70 2002/04/24 02:26:06 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -37,8 +37,6 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "win32.h"
|
||||
#else
|
||||
#include <unistd.h>
|
||||
@ -894,46 +892,3 @@ libpq_gettext(const char *msgid)
|
||||
return dgettext("libpq", msgid);
|
||||
}
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
#ifdef WIN32
|
||||
/*
|
||||
* strerror replacement for windows:
|
||||
*
|
||||
* This works on WIN2000 and newer, but we don't know where to find WinSock
|
||||
* error strings on older Windows flavors. If you know, clue us in.
|
||||
*/
|
||||
const char *
|
||||
winsock_strerror(int eno)
|
||||
{
|
||||
static char err_buf[512];
|
||||
#define WSSE_MAXLEN (sizeof(err_buf)-1-13) /* 13 for " (0x00000000)" */
|
||||
int length;
|
||||
|
||||
/* First try the "system table", this works on Win2k and up */
|
||||
|
||||
if (FormatMessage(
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0,
|
||||
eno,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
err_buf,
|
||||
WSSE_MAXLEN,
|
||||
NULL))
|
||||
goto WSSE_GOODEXIT;
|
||||
|
||||
/* Insert other possible lookup methods here ... */
|
||||
|
||||
/* Everything failed, just tell the user that we don't know the desc */
|
||||
|
||||
strcpy(err_buf, "Socket error, no description available.");
|
||||
|
||||
WSSE_GOODEXIT:
|
||||
|
||||
length = strlen(err_buf);
|
||||
sprintf(err_buf + (length < WSSE_MAXLEN ? length : WSSE_MAXLEN),
|
||||
" (0x%08X)", eno);
|
||||
|
||||
return err_buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user