Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee0ef05

Browse files
committed
Hello, i just reviewed the win32 errno patch and i saw that maybe i didn't
really played it totally safe in my last suggestion, the system table mightpick up the msg but not the netmsg.dll, so better try both.I also added a hex printout of the "errno" appended to all messages, that'snicer.If anyone hate my coding style, or that i'm using goto constructs, just tellme, and i'll rework it into a nested if () thing.Magnus Naeslund(f)
1 parent6c91eef commitee0ef05

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

‎src/interfaces/libpq/fe-misc.c

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
*
2727
* IDENTIFICATION
28-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.54 2001/08/21 20:39:54 momjian Exp $
28+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.55 2001/09/06 02:52:00 momjian Exp $
2929
*
3030
*-------------------------------------------------------------------------
3131
*/
@@ -855,23 +855,46 @@ libpq_gettext(const char *msgid)
855855
#ifdefWIN32
856856
/*
857857
* strerror replacement for windows:
858+
*
859+
* We dont't know a fix for win9x yet, but this whould work for nt4 and win2k.
860+
* If you can verify this working on win9x or have a solution, let us know, ok?
861+
*
858862
*/
859863
constchar*
860864
winsock_strerror(DWORDeno)
861865
{
862-
if (!FormatMessage(
863-
FORMAT_MESSAGE_IGNORE_INSERTS |
864-
FORMAT_MESSAGE_FROM_SYSTEM |/* always consider system table */
865-
((netmsgModule!=NULL) ?FORMAT_MESSAGE_FROM_HMODULE :0),
866-
netmsgModule,/* module to get message from (NULL == system) */
867-
eno,
868-
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
869-
winsock_strerror_buf,sizeof(winsock_strerror_buf)-1,
870-
NULL
871-
)){
872-
sprintf(winsock_strerror_buf,"Unknown socket error(%u)",eno);
873-
}
874-
winsock_strerror_buf[sizeof(winsock_strerror_buf)-1]='\0';
875-
returnwinsock_strerror_buf;
866+
#defineWSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12)/* 12 == "(0x00000000)" */
867+
intlength;
868+
869+
/* First try the "system table", this works on Win2k pro */
870+
871+
if (FormatMessage(
872+
FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,
873+
0,eno,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
874+
winsock_strerror_buf,WSSE_MAXLEN,NULL
875+
))
876+
gotoWSSE_GOODEXIT;
877+
878+
/* That didn't work, let's try the netmsg.dll */
879+
880+
if (netmsgModule&&
881+
FormatMessage(
882+
FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_HMODULE,
883+
0,eno,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
884+
winsock_strerror_buf,WSSE_MAXLEN,NULL
885+
))
886+
gotoWSSE_GOODEXIT;
887+
888+
/* Everything failed, just tell the user that we don't know the desc */
889+
890+
strcat(winsock_strerror_buf,"Socket error, no description available.");
891+
892+
WSSE_GOODEXIT:
893+
894+
length=strlen(winsock_strerror_buf);
895+
sprintf(winsock_strerror_buf+length<WSSE_MAXLEN?length:WSSE_MAXLEN,
896+
"(0x%08X)",eno);
897+
898+
returnwinsock_strerror_buf;
876899
}
877900
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp