|
25 | 25 | *
|
26 | 26 | *
|
27 | 27 | * IDENTIFICATION
|
28 |
| - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.63 2001/11/27 18:21:51 tgl Exp $ |
| 28 | + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.64 2001/11/28 19:40:29 tgl Exp $ |
29 | 29 | *
|
30 | 30 | *-------------------------------------------------------------------------
|
31 | 31 | */
|
|
37 | 37 | #include<time.h>
|
38 | 38 |
|
39 | 39 | #ifdefWIN32
|
| 40 | +#defineWIN32_LEAN_AND_MEAN |
| 41 | +#include<windows.h> |
40 | 42 | #include"win32.h"
|
41 | 43 | #else
|
42 | 44 | #include<unistd.h>
|
@@ -858,41 +860,59 @@ libpq_gettext(const char *msgid)
|
858 | 860 | * If you can verify this working on win9x or have a solution, let us know, ok?
|
859 | 861 | */
|
860 | 862 | constchar*
|
861 |
| -winsock_strerror(DWORDeno) |
| 863 | +winsock_strerror(inteno) |
862 | 864 | {
|
863 |
| -#defineWSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12)/* 12 == "(0x00000000)" */ |
| 865 | +staticcharerr_buf[512]; |
| 866 | +#defineWSSE_MAXLEN (sizeof(err_buf)-1-13)/* 13 == " (0x00000000)" */ |
| 867 | +HINSTANCEnetmsgModule; |
864 | 868 | intlength;
|
865 | 869 |
|
866 | 870 | /* First try the "system table", this works on Win2k pro */
|
867 | 871 |
|
868 | 872 | if (FormatMessage(
|
869 |
| -FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM, |
870 |
| -0,eno,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), |
871 |
| -winsock_strerror_buf,WSSE_MAXLEN,NULL |
872 |
| - )) |
| 873 | +FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM, |
| 874 | +0, |
| 875 | +eno, |
| 876 | +MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), |
| 877 | +err_buf, |
| 878 | +WSSE_MAXLEN, |
| 879 | +NULL)) |
873 | 880 | gotoWSSE_GOODEXIT;
|
874 | 881 |
|
875 | 882 | /* That didn't work, let's try the netmsg.dll */
|
876 | 883 |
|
877 |
| -if (netmsgModule&& |
878 |
| -FormatMessage( |
879 |
| -FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_HMODULE, |
880 |
| -0,eno,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), |
881 |
| -winsock_strerror_buf,WSSE_MAXLEN,NULL |
882 |
| - )) |
883 |
| -gotoWSSE_GOODEXIT; |
| 884 | +netmsgModule=LoadLibraryEx("netmsg.dll", |
| 885 | +NULL, |
| 886 | +LOAD_LIBRARY_AS_DATAFILE); |
| 887 | + |
| 888 | +if (netmsgModule!=NULL) |
| 889 | +{ |
| 890 | +if (FormatMessage( |
| 891 | +FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_HMODULE, |
| 892 | +netmsgModule, |
| 893 | +eno, |
| 894 | +MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), |
| 895 | +err_buf, |
| 896 | +WSSE_MAXLEN, |
| 897 | +NULL)) |
| 898 | +{ |
| 899 | +FreeLibrary(netmsgModule); |
| 900 | +gotoWSSE_GOODEXIT; |
| 901 | +} |
| 902 | +FreeLibrary(netmsgModule); |
| 903 | +} |
884 | 904 |
|
885 | 905 | /* Everything failed, just tell the user that we don't know the desc */
|
886 | 906 |
|
887 |
| -strcpy(winsock_strerror_buf,"Socket error, no description available."); |
| 907 | +strcpy(err_buf,"Socket error, no description available."); |
888 | 908 |
|
889 | 909 | WSSE_GOODEXIT:
|
890 | 910 |
|
891 |
| -length=strlen(winsock_strerror_buf); |
892 |
| -sprintf(winsock_strerror_buf+ (length<WSSE_MAXLEN ?length :WSSE_MAXLEN), |
893 |
| -"(0x%08X)",eno); |
| 911 | +length=strlen(err_buf); |
| 912 | +sprintf(err_buf+ (length<WSSE_MAXLEN ?length :WSSE_MAXLEN), |
| 913 | +"(0x%08X)",eno); |
894 | 914 |
|
895 |
| -returnwinsock_strerror_buf; |
| 915 | +returnerr_buf; |
896 | 916 | }
|
897 | 917 |
|
898 | 918 | #endif
|