[PATCH] Win32 native fixes after SSL updates (+more)
Hello, i noticed that win32 native stopped working/compiling after the SSL merge.
So i took the opportunity to fix some stuff:
1. Made the thing compile (typos & needed definitions) with the new pqsecure_* stuff, and added fe-secure.c to the win32.mak makefile.
2. Fixed some MULTIBYTE compile errors (when building without MB support).
3. Made it do that you can build with debug info: "nmake -f win32.mak DEBUG=1".
4. Misc small compiler speedup changes.
The resulting .dll has been tested in production, and everything seems ok.
I CC:ed -hackers because i'm not sure about two things:
1. In libpq-int.h I typedef ssize_t as an int because Visual C (v6.0) doesn't define ssize_t. Is that ok, or is there any standard about what type should be used for ssize_t?
2. To keep the .dll api consistent regarding MULTIBYTE I just return -1 in fe-connect.c:PQsetClientEncoding() instead of taking away the whole function. I wonder if i should do any compares with the conn->client_encoding and return 0 if nothing would have changed (if so how do i check that?).
Regards
Magnus Naeslund
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Programmer/Networker [|] Magnus Naeslund
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Attachments:
pgsql_win32.cleanups.1.diffapplication/octet-stream; name=pgsql_win32.cleanups.1.diffDownload
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/fe-auth.c ./fe-auth.c
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/fe-auth.c Thu Jul 18 08:18:24 2002
+++ ./fe-auth.c Thu Jul 18 09:48:28 2002
@@ -714,7 +714,7 @@
char username[128];
DWORD namesize = sizeof(username) - 1;
- if (GetUserNameFromId(username, &namesize))
+ if (GetUserName(username, &namesize))
name = username;
#else
struct passwd *pw = getpwuid(geteuid());
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/fe-connect.c ./fe-connect.c
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/fe-connect.c Thu Jul 18 08:18:24 2002
+++ ./fe-connect.c Thu Jul 18 09:55:52 2002
@@ -2717,6 +2717,9 @@
int
PQsetClientEncoding(PGconn *conn, const char *encoding)
{
+
+#ifdef MULTIBYTE
+
char qbuf[128];
static char query[] = "set client_encoding to '%s'";
PGresult *res;
@@ -2748,6 +2751,9 @@
}
PQclear(res);
return (status);
+#else
+ return -1; /* Multibyte support isn't compiled in */
+#endif
}
void
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/fe-secure.c ./fe-secure.c
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/fe-secure.c Sun Jun 23 22:30:48 2002
+++ ./fe-secure.c Thu Jul 18 09:46:42 2002
@@ -110,7 +110,9 @@
#include "strdup.h"
#endif
+#ifndef WIN32
#include <pwd.h>
+#endif
#include <sys/stat.h>
#ifdef USE_SSL
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/libpq-int.h ./libpq-int.h
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/libpq-int.h Thu Jul 18 08:18:24 2002
+++ ./libpq-int.h Thu Jul 18 11:39:02 2002
@@ -20,6 +20,10 @@
#ifndef LIBPQ_INT_H
#define LIBPQ_INT_H
+#if defined(WIN32) && (!defined(ssize_t))
+ typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast not VC6) */
+#endif
+
/* We assume libpq-fe.h has already been included. */
#include "postgres_fe.h"
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/libpqdll.c ./libpqdll.c
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/libpqdll.c Wed Nov 28 20:40:30 2001
+++ ./libpqdll.c Thu Jul 18 11:22:34 2002
@@ -1,4 +1,5 @@
#define WIN32_LEAN_AND_MEAN
+#include <winsock.h>
#include <windows.h>
#include "win32.h"
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/win32.c ./win32.c
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/win32.c Thu Jul 18 08:21:26 2002
+++ ./win32.c Thu Jul 18 08:58:34 2002
@@ -17,7 +17,14 @@
*
*/
+/* Make stuff compile faster by excluding not used stuff */
+
#define WIN32_LEAN_AND_MEAN
+#define WIN32_EXTRA_LEAN
+#define VC_EXTRALEAN
+#define NOGDI
+#define NOCRYPT
+
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/win32.h ./win32.h
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/win32.h Thu Jul 18 08:20:58 2002
+++ ./win32.h Thu Jul 18 11:21:26 2002
@@ -1,4 +1,5 @@
-#include <winsock.h>
+#ifndef __win32_h_included
+#define __win32_h_included
/*
* strcasecmp() is not in Windows, stricmp is, though
@@ -34,3 +35,6 @@
* support for handling Windows Socket errors
*/
extern const char *winsock_strerror(int eno);
+
+
+#endif
diff -u -x *#* -x *~ ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/win32.mak ./win32.mak
--- ../../../../pgsql_vanilla/pgsql/src/interfaces/libpq/win32.mak Wed Apr 24 13:26:30 2002
+++ ./win32.mak Thu Jul 18 11:10:14 2002
@@ -30,6 +30,15 @@
!ERROR An invalid configuration was specified.
!ENDIF
+!IFDEF DEBUG
+OPT=/Od
+LOPT=/debug
+DEBUGDEF=/D _DEBUG
+!ELSE
+OPT=/O2
+LOPT=
+DEBUGDEF=/D NDEBUG
+!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
@@ -62,6 +71,7 @@
-@erase "$(INTDIR)\fe-lobj.obj"
-@erase "$(INTDIR)\fe-misc.obj"
-@erase "$(INTDIR)\fe-print.obj"
+ -@erase "$(INTDIR)\fe-secure.obj"
-@erase "$(INTDIR)\pqexpbuffer.obj"
-@erase "$(OUTDIR)\libpqdll.obj"
-@erase "$(OUTDIR)\win32.obj"
@@ -80,7 +90,7 @@
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\..\include" /D "FRONTEND" /D "NDEBUG" /D\
+CPP_PROJ=/nologo /MD /W3 /GX $(OPT) /I "..\..\include" /D "FRONTEND" $(DEBUGDEF) /D\
"WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
/Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP"
@@ -95,7 +105,7 @@
CPP_SBRS=.
LIB32=link.exe -lib
-LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libpq.lib"
+LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib"
LIB32_OBJS= \
"$(OUTDIR)\win32.obj" \
"$(INTDIR)\dllist.obj" \
@@ -106,6 +116,7 @@
"$(INTDIR)\fe-lobj.obj" \
"$(INTDIR)\fe-misc.obj" \
"$(INTDIR)\fe-print.obj" \
+ "$(INTDIR)\fe-secure.obj" \
"$(INTDIR)\pqexpbuffer.obj"
!IFDEF MULTIBYTE
@@ -116,7 +127,7 @@
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib\
- /nologo /subsystem:windows /dll /incremental:no\
+ /nologo /subsystem:windows /dll $(LOPT) /incremental:no\
/pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\
/implib:"$(OUTDIR)\libpqdll.lib" /def:libpqdll.def
LINK32_OBJS= \
Your patch has been added to the PostgreSQL unapplied patches list at:
http://candle.pha.pa.us/cgi-bin/pgpatches
I will try to apply it within the next 48 hours.
---------------------------------------------------------------------------
Magnus Naeslund(f) wrote:
Hello, i noticed that win32 native stopped working/compiling after the SSL merge.
So i took the opportunity to fix some stuff:1. Made the thing compile (typos & needed definitions) with the new pqsecure_* stuff, and added fe-secure.c to the win32.mak makefile.
2. Fixed some MULTIBYTE compile errors (when building without MB support).
3. Made it do that you can build with debug info: "nmake -f win32.mak DEBUG=1".
4. Misc small compiler speedup changes.The resulting .dll has been tested in production, and everything seems ok.
I CC:ed -hackers because i'm not sure about two things:1. In libpq-int.h I typedef ssize_t as an int because Visual C (v6.0) doesn't define ssize_t. Is that ok, or is there any standard about what type should be used for ssize_t?
2. To keep the .dll api consistent regarding MULTIBYTE I just return -1 in fe-connect.c:PQsetClientEncoding() instead of taking away the whole function. I wonder if i should do any compares with the conn->client_encoding and return 0 if nothing would have changed (if so how do i check that?).
Regards
Magnus Naeslund
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Programmer/Networker [|] Magnus Naeslund
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[ Attachment, skipping... ]
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Patch applied. Thanks.
---------------------------------------------------------------------------
Magnus Naeslund(f) wrote:
Hello, i noticed that win32 native stopped working/compiling after the SSL merge.
So i took the opportunity to fix some stuff:1. Made the thing compile (typos & needed definitions) with the new pqsecure_* stuff, and added fe-secure.c to the win32.mak makefile.
2. Fixed some MULTIBYTE compile errors (when building without MB support).
3. Made it do that you can build with debug info: "nmake -f win32.mak DEBUG=1".
4. Misc small compiler speedup changes.The resulting .dll has been tested in production, and everything seems ok.
I CC:ed -hackers because i'm not sure about two things:1. In libpq-int.h I typedef ssize_t as an int because Visual C (v6.0) doesn't define ssize_t. Is that ok, or is there any standard about what type should be used for ssize_t?
2. To keep the .dll api consistent regarding MULTIBYTE I just return -1 in fe-connect.c:PQsetClientEncoding() instead of taking away the whole function. I wonder if i should do any compares with the conn->client_encoding and return 0 if nothing would have changed (if so how do i check that?).
Regards
Magnus Naeslund
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Programmer/Networker [|] Magnus Naeslund
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
[ Attachment, skipping... ]
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026