Update of /cvsroot/pypgsql/pypgsql
In directory sc8-pr-cvs1:/tmp/cvs-serv8569
Modified Files:
libpqmodule.c libpqmodule.h
Log Message:
16JUN2003 gh On win32, we usually statically link against libpq.
Because of fortunate circumstances, a problem didn't
show up until now: we need to call WSAStartup() to
initialize the socket stuff from Windows *in our
module* in order for the statically linked libpq to
work. I just took the relevant DllMain function from
the libpq sources and put it here.
Index: libpqmodule.c
===================================================================
RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** libpqmodule.c 9 Jun 2003 14:56:58 -0000 1.27
--- libpqmodule.c 16 Jun 2003 11:59:41 -0000 1.28
***************
*** 32,35 ****
--- 32,42 ----
| Date Ini Description |
| --------- --- ------------------------------------------------------- |
+ | 16JUN2003 gh On win32, we usually statically link against libpq. |
+ | Because of fortunate circumstances, a problem didn't |
+ | show up until now: we need to call WSAStartup() to |
+ | initialize the socket stuff from Windows *in our |
+ | module* in order for the statically linked libpq to |
+ | work. I just took the relevant DllMain function from |
+ | the libpq sources and put it here. |
| 09JUN2003 gh Applied patch from Laurent Pinchart: |
| In libPQquoteString, bytea are quoted using as much as |
***************
*** 947,950 ****
--- 954,985 ----
{ NULL, NULL }
};
+
+ #ifdef MS_WIN32
+ BOOL WINAPI
+ DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
+ LPVOID lpReserved)
+ {
+ WSADATA wsaData;
+
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ if (WSAStartup(MAKEWORD(1, 1), &wsaData))
+ {
+ /*
+ * No really good way to do error handling here, since we
+ * don't know how we were loaded
+ */
+ return FALSE;
+ }
+ break;
+ case DLL_PROCESS_DETACH:
+ WSACleanup();
+ break;
+ }
+
+ return TRUE;
+ }
+ #endif
DL_EXPORT(void) initlibpq(void)
Index: libpqmodule.h
===================================================================
RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** libpqmodule.h 2 Oct 2002 04:06:32 -0000 1.9
--- libpqmodule.h 16 Jun 2003 11:59:41 -0000 1.10
***************
*** 40,43 ****
--- 40,50 ----
#include "pgversion.h"
+ #ifdef MS_WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <winsock.h>
+ #include <windows.h>
+ #include "win32.h"
+ #endif
+
#define MODULE_NAME "libpq"
|