Skip to content

Commit b6d2faa

Browse files
committed
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_* s tuff, 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 de fine ssize_t. Is that ok, or is there any standard about what type should be use d 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 not hing would have changed (if so how do i check that?). Regards Magnus Naeslund
1 parent 1430271 commit b6d2faa

File tree

8 files changed

+44
-9
lines changed

8 files changed

+44
-9
lines changed

src/interfaces/libpq/fe-auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.67 2002/06/20 20:29:53 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.68 2002/07/20 05:43:31 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -714,7 +714,7 @@ fe_getauthname(char *PQerrormsg)
714714
char username[128];
715715
DWORD namesize = sizeof(username) - 1;
716716

717-
if (GetUserNameFromId(username, &namesize))
717+
if (GetUserName(username, &namesize))
718718
name = username;
719719
#else
720720
struct passwd *pw = getpwuid(geteuid());

src/interfaces/libpq/fe-connect.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.189 2002/07/18 02:02:30 ishii Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.190 2002/07/20 05:43:31 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2717,6 +2717,9 @@ PQclientEncoding(const PGconn *conn)
27172717
int
27182718
PQsetClientEncoding(PGconn *conn, const char *encoding)
27192719
{
2720+
2721+
#ifdef MULTIBYTE
2722+
27202723
char qbuf[128];
27212724
static char query[] = "set client_encoding to '%s'";
27222725
PGresult *res;
@@ -2748,6 +2751,9 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
27482751
}
27492752
PQclear(res);
27502753
return (status);
2754+
#else
2755+
return -1; /* Multibyte support isn't compiled in */
2756+
#endif
27512757
}
27522758

27532759
void

src/interfaces/libpq/fe-secure.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.9 2002/06/23 20:30:48 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.10 2002/07/20 05:43:31 momjian Exp $
1515
*
1616
* NOTES
1717
* The client *requires* a valid server certificate. Since
@@ -110,7 +110,9 @@
110110
#include "strdup.h"
111111
#endif
112112

113+
#ifndef WIN32
113114
#include <pwd.h>
115+
#endif
114116
#include <sys/stat.h>
115117

116118
#ifdef USE_SSL

src/interfaces/libpq/libpq-int.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: libpq-int.h,v 1.51 2002/06/20 20:29:54 momjian Exp $
15+
* $Id: libpq-int.h,v 1.52 2002/07/20 05:43:31 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
1919

2020
#ifndef LIBPQ_INT_H
2121
#define LIBPQ_INT_H
2222

23+
#if defined(WIN32) && (!defined(ssize_t))
24+
typedef int ssize_t; /* ssize_t doesn't exist in VC (atleast not VC6) */
25+
#endif
26+
2327
/* We assume libpq-fe.h has already been included. */
2428
#include "postgres_fe.h"
2529

src/interfaces/libpq/libpqdll.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#define WIN32_LEAN_AND_MEAN
2+
#include <winsock.h>
23
#include <windows.h>
34
#include "win32.h"
45

src/interfaces/libpq/win32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
*
1818
*/
1919

20+
/* Make stuff compile faster by excluding not used stuff */
21+
2022
#define WIN32_LEAN_AND_MEAN
23+
#define WIN32_EXTRA_LEAN
24+
#define VC_EXTRALEAN
25+
#define NOGDI
26+
#define NOCRYPT
27+
2128
#include <windows.h>
2229
#include <winsock.h>
2330
#include <stdio.h>

src/interfaces/libpq/win32.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include <winsock.h>
1+
#ifndef __win32_h_included
2+
#define __win32_h_included
23

34
/*
45
* strcasecmp() is not in Windows, stricmp is, though
@@ -34,3 +35,6 @@
3435
* support for handling Windows Socket errors
3536
*/
3637
extern const char *winsock_strerror(int eno);
38+
39+
40+
#endif

src/interfaces/libpq/win32.mak

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ CFG=Release
3030
!ERROR An invalid configuration was specified.
3131
!ENDIF
3232

33+
!IFDEF DEBUG
34+
OPT=/Od
35+
LOPT=/debug
36+
DEBUGDEF=/D _DEBUG
37+
!ELSE
38+
OPT=/O2
39+
LOPT=
40+
DEBUGDEF=/D NDEBUG
41+
!ENDIF
3342

3443
!IF "$(OS)" == "Windows_NT"
3544
NULL=
@@ -62,6 +71,7 @@ CLEAN :
6271
-@erase "$(INTDIR)\fe-lobj.obj"
6372
-@erase "$(INTDIR)\fe-misc.obj"
6473
-@erase "$(INTDIR)\fe-print.obj"
74+
-@erase "$(INTDIR)\fe-secure.obj"
6575
-@erase "$(INTDIR)\pqexpbuffer.obj"
6676
-@erase "$(OUTDIR)\libpqdll.obj"
6777
-@erase "$(OUTDIR)\win32.obj"
@@ -80,7 +90,7 @@ CLEAN :
8090
"$(OUTDIR)" :
8191
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
8292

83-
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\..\include" /D "FRONTEND" /D "NDEBUG" /D\
93+
CPP_PROJ=/nologo /MD /W3 /GX $(OPT) /I "..\..\include" /D "FRONTEND" $(DEBUGDEF) /D\
8494
"WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
8595
/Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP"
8696

@@ -95,7 +105,7 @@ CPP_OBJS=.\Release/
95105
CPP_SBRS=.
96106

97107
LIB32=link.exe -lib
98-
LIB32_FLAGS=/nologo /out:"$(OUTDIR)\libpq.lib"
108+
LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib"
99109
LIB32_OBJS= \
100110
"$(OUTDIR)\win32.obj" \
101111
"$(INTDIR)\dllist.obj" \
@@ -106,6 +116,7 @@ LIB32_OBJS= \
106116
"$(INTDIR)\fe-lobj.obj" \
107117
"$(INTDIR)\fe-misc.obj" \
108118
"$(INTDIR)\fe-print.obj" \
119+
"$(INTDIR)\fe-secure.obj" \
109120
"$(INTDIR)\pqexpbuffer.obj"
110121

111122
!IFDEF MULTIBYTE
@@ -116,7 +127,7 @@ RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
116127

117128
LINK32=link.exe
118129
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib\
119-
/nologo /subsystem:windows /dll /incremental:no\
130+
/nologo /subsystem:windows /dll $(LOPT) /incremental:no\
120131
/pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\
121132
/implib:"$(OUTDIR)\libpqdll.lib" /def:libpqdll.def
122133
LINK32_OBJS= \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy