Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
3312b8ed
Commit
3312b8ed
authored
Nov 28, 2001
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load netmsg.dll locally in winsock_strerror, to avoid actual and
potential problems discussed in pgsql-interfaces.
parent
9d596e0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
29 deletions
+42
-29
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-misc.c
+39
-19
src/interfaces/libpq/libpqdll.c
src/interfaces/libpq/libpqdll.c
+1
-5
src/interfaces/libpq/win32.h
src/interfaces/libpq/win32.h
+2
-5
No files found.
src/interfaces/libpq/fe-misc.c
View file @
3312b8ed
...
...
@@ -25,7 +25,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.6
3 2001/11/27 18:21:51
tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.6
4 2001/11/28 19:40:29
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -37,6 +37,8 @@
#include <time.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "win32.h"
#else
#include <unistd.h>
...
...
@@ -858,41 +860,59 @@ libpq_gettext(const char *msgid)
* If you can verify this working on win9x or have a solution, let us know, ok?
*/
const
char
*
winsock_strerror
(
DWORD
eno
)
winsock_strerror
(
int
eno
)
{
#define WSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12)
/* 12 == "(0x00000000)" */
static
char
err_buf
[
512
];
#define WSSE_MAXLEN (sizeof(err_buf)-1-13)
/* 13 == " (0x00000000)" */
HINSTANCE
netmsgModule
;
int
length
;
/* First try the "system table", this works on Win2k pro */
if
(
FormatMessage
(
FORMAT_MESSAGE_IGNORE_INSERTS
|
FORMAT_MESSAGE_FROM_SYSTEM
,
0
,
eno
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
winsock_strerror_buf
,
WSSE_MAXLEN
,
NULL
))
FORMAT_MESSAGE_IGNORE_INSERTS
|
FORMAT_MESSAGE_FROM_SYSTEM
,
0
,
eno
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
err_buf
,
WSSE_MAXLEN
,
NULL
))
goto
WSSE_GOODEXIT
;
/* That didn't work, let's try the netmsg.dll */
if
(
netmsgModule
&&
FormatMessage
(
FORMAT_MESSAGE_IGNORE_INSERTS
|
FORMAT_MESSAGE_FROM_HMODULE
,
0
,
eno
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
winsock_strerror_buf
,
WSSE_MAXLEN
,
NULL
))
goto
WSSE_GOODEXIT
;
netmsgModule
=
LoadLibraryEx
(
"netmsg.dll"
,
NULL
,
LOAD_LIBRARY_AS_DATAFILE
);
if
(
netmsgModule
!=
NULL
)
{
if
(
FormatMessage
(
FORMAT_MESSAGE_IGNORE_INSERTS
|
FORMAT_MESSAGE_FROM_HMODULE
,
netmsgModule
,
eno
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
err_buf
,
WSSE_MAXLEN
,
NULL
))
{
FreeLibrary
(
netmsgModule
);
goto
WSSE_GOODEXIT
;
}
FreeLibrary
(
netmsgModule
);
}
/* Everything failed, just tell the user that we don't know the desc */
strcpy
(
winsock_strerro
r_buf
,
"Socket error, no description available."
);
strcpy
(
er
r_buf
,
"Socket error, no description available."
);
WSSE_GOODEXIT:
length
=
strlen
(
winsock_strerro
r_buf
);
sprintf
(
winsock_strerro
r_buf
+
(
length
<
WSSE_MAXLEN
?
length
:
WSSE_MAXLEN
),
"(0x%08X)"
,
eno
);
length
=
strlen
(
er
r_buf
);
sprintf
(
er
r_buf
+
(
length
<
WSSE_MAXLEN
?
length
:
WSSE_MAXLEN
),
"
(0x%08X)"
,
eno
);
return
winsock_strerro
r_buf
;
return
er
r_buf
;
}
#endif
src/interfaces/libpq/libpqdll.c
View file @
3312b8ed
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock.h>
#include "win32.h"
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDLL
,
DWORD
fdwReason
,
LPVOID
lpReserved
)
...
...
@@ -20,12 +20,8 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
*/
return
FALSE
;
}
if
(
netmsgModule
==
NULL
)
netmsgModule
=
LoadLibraryEx
(
"netmsg.dll"
,
NULL
,
LOAD_LIBRARY_AS_DATAFILE
);
break
;
case
DLL_PROCESS_DETACH
:
if
(
netmsgModule
!=
NULL
)
FreeLibrary
(
netmsgModule
);
WSACleanup
();
break
;
}
...
...
src/interfaces/libpq/win32.h
View file @
3312b8ed
...
...
@@ -31,9 +31,6 @@
#define EINPROGRESS WSAEINPROGRESS
/*
*
Windows network messaging stuff:
*
support for handling Windows Socket errors
*/
static
HINSTANCE
netmsgModule
=
NULL
;
static
char
winsock_strerror_buf
[
512
];
const
char
*
winsock_strerror
(
DWORD
eno
);
extern
const
char
*
winsock_strerror
(
int
eno
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment