Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2dc9437

Browse files
committed
Enable Win32 to compile libpq again, and enable SSL compiles on that
platform.Andreas Pflug
1 parent1709fde commit2dc9437

File tree

6 files changed

+60
-28
lines changed

6 files changed

+60
-28
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 2 additions & 2 deletions
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.259 2003/08/04 02:40:16 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.260 2003/09/05 02:08:36 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -48,7 +48,7 @@
4848

4949
/* For FNCTL_NONBLOCK */
5050
#if defined(WIN32)|| defined(__BEOS__)
51-
longioctlsocket_ret;
51+
longioctlsocket_ret=1;
5252
#endif
5353

5454
#definePGPASSFILE ".pgpass"

‎src/interfaces/libpq/fe-exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.146 2003/08/27 00:33:34 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.147 2003/09/05 02:08:36 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2304,7 +2304,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
23042304
if (buffer==NULL)
23052305
returnNULL;
23062306

2307-
for (i=j=buflen=0;i<strtextlen;)
2307+
for (i=j=buflen=0;i<(int)strtextlen;)
23082308
{
23092309
switch (strtext[i])
23102310
{

‎src/interfaces/libpq/fe-secure.c

Lines changed: 18 additions & 5 deletions
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.29 2003/08/04 17:25:14 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.30 2003/09/05 02:08:36 momjian Exp $
1515
*
1616
* NOTES
1717
* The client *requires* a valid server certificate. Since
@@ -312,7 +312,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
312312
printfPQExpBuffer(&conn->errorMessage,
313313
libpq_gettext("SSL SYSCALL error: EOF detected\n"));
314314

315-
SOCK_ERRNO=ECONNRESET;
315+
SOCK_ERRNO_SET(ECONNRESET);
316316
n=-1;
317317
}
318318
break;
@@ -322,7 +322,7 @@ pqsecure_read(PGconn *conn, void *ptr, size_t len)
322322
libpq_gettext("SSL error: %s\n"),SSLerrmessage());
323323
/* fall through */
324324
caseSSL_ERROR_ZERO_RETURN:
325-
SOCK_ERRNO=ECONNRESET;
325+
SOCK_ERRNO_SET(ECONNRESET);
326326
n=-1;
327327
break;
328328
default:
@@ -383,7 +383,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
383383
{
384384
printfPQExpBuffer(&conn->errorMessage,
385385
libpq_gettext("SSL SYSCALL error: EOF detected\n"));
386-
SOCK_ERRNO=ECONNRESET;
386+
SOCK_ERRNO_SET(ECONNRESET);
387387
n=-1;
388388
}
389389
break;
@@ -393,7 +393,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
393393
libpq_gettext("SSL error: %s\n"),SSLerrmessage());
394394
/* fall through */
395395
caseSSL_ERROR_ZERO_RETURN:
396-
SOCK_ERRNO=ECONNRESET;
396+
SOCK_ERRNO_SET(ECONNRESET);
397397
n=-1;
398398
break;
399399
default:
@@ -544,6 +544,9 @@ verify_peer(PGconn *conn)
544544
staticDH*
545545
load_dh_file(intkeylength)
546546
{
547+
#ifdefWIN32
548+
returnNULL;
549+
#else
547550
charpwdbuf[BUFSIZ];
548551
structpasswdpwdstr;
549552
structpasswd*pwd=NULL;
@@ -558,6 +561,7 @@ load_dh_file(int keylength)
558561
/* attempt to open file. It's not an error if it doesn't exist. */
559562
snprintf(fnbuf,sizeoffnbuf,"%s/.postgresql/dh%d.pem",
560563
pwd->pw_dir,keylength);
564+
561565
if ((fp=fopen(fnbuf,"r"))==NULL)
562566
returnNULL;
563567

@@ -583,6 +587,7 @@ load_dh_file(int keylength)
583587
}
584588

585589
returndh;
590+
#endif
586591
}
587592

588593
/*
@@ -686,6 +691,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength)
686691
staticint
687692
client_cert_cb(SSL*ssl,X509**x509,EVP_PKEY**pkey)
688693
{
694+
#ifdefWIN32
695+
return0;
696+
#else
689697
charpwdbuf[BUFSIZ];
690698
structpasswdpwdstr;
691699
structpasswd*pwd=NULL;
@@ -785,6 +793,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
785793
}
786794

787795
return1;
796+
#endif
788797
}
789798

790799
/*
@@ -793,11 +802,13 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
793802
staticint
794803
initialize_SSL(PGconn*conn)
795804
{
805+
#ifndefWIN32
796806
structstatbuf;
797807
charpwdbuf[BUFSIZ];
798808
structpasswdpwdstr;
799809
structpasswd*pwd=NULL;
800810
charfnbuf[2048];
811+
#endif
801812

802813
if (!SSL_context)
803814
{
@@ -813,6 +824,7 @@ initialize_SSL(PGconn *conn)
813824
}
814825
}
815826

827+
#ifndefWIN32
816828
if (pqGetpwuid(getuid(),&pwdstr,pwdbuf,sizeof(pwdbuf),&pwd)==0)
817829
{
818830
snprintf(fnbuf,sizeoffnbuf,"%s/.postgresql/root.crt",
@@ -849,6 +861,7 @@ initialize_SSL(PGconn *conn)
849861

850862
/* set up mechanism to provide client certificate, if available */
851863
SSL_CTX_set_client_cert_cb(SSL_context,client_cert_cb);
864+
#endif
852865

853866
return0;
854867
}

‎src/interfaces/libpq/libpq-int.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: libpq-int.h,v 1.81 2003/08/13 18:56:21 tgl Exp $
15+
* $Id: libpq-int.h,v 1.82 2003/09/05 02:08:36 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -465,9 +465,11 @@ __attribute__((format_arg(1)));
465465
#ifdefWIN32
466466
#defineSOCK_ERRNO (WSAGetLastError())
467467
#defineSOCK_STRERROR winsock_strerror
468+
#defineSOCK_ERRNO_SET(e) WSASetLastError(e)
468469
#else
469470
#defineSOCK_ERRNO errno
470471
#defineSOCK_STRERROR pqStrerror
472+
#defineSOCK_ERRNO_SET(e) errno=e
471473
#endif
472474

473475
#endif/* LIBPQ_INT_H */

‎src/interfaces/libpq/win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen)
312312
{
313313
strerrbuf[buflen-1]='\0';
314314
offs=strlen(strerrbuf);
315-
if (offs>buflen-64)
315+
if (offs>(int)buflen-64)
316316
offs=buflen-64;
317317
sprintf(strerrbuf+offs," (0x%08X/%lu)",err,err);
318318
}

‎src/interfaces/libpq/win32.mak

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Makefile for Microsoft Visual C++ 5.0 (or compat)
22

3-
# Will build a Win32 static library (non-debug) libpq.lib
4-
# and a Win32 dynamic library (non-debug) libpq.dll with import library libpqdll.lib
3+
# Will build a Win32 static library libpq.lib
4+
# and a Win32 dynamic library libpq.dll with import library libpqdll.lib
5+
# USE_SSL=1 will compile with OpenSSL
6+
# DEBUG=1 compiles with debugging symbols
57

68

79
!MESSAGE Building the Win32 static library...
810
!MESSAGE
911

1012
!IFDEF DEBUG
11-
OPT=/Od
13+
OPT=/Od /Zi
1214
LOPT=/debug
1315
DEBUGDEF=/D _DEBUG
1416
!ELSE
@@ -26,12 +28,16 @@ NULL=nul
2628
CPP=cl.exe
2729
RSC=rc.exe
2830

31+
!IFDEF DEBUG
32+
OUTDIR=.\Debug
33+
INTDIR=.\Debug
34+
CPP_OBJS=.\Debug/
35+
!ELSE
2936
OUTDIR=.\Release
3037
INTDIR=.\Release
38+
CPP_OBJS=.\Release/
39+
!ENDIF
3140

32-
# Begin Custom Macros
33-
OutDir=.\Release
34-
# End Custom Macros
3541

3642
ALL : "$(OUTDIR)\libpq.lib" "$(OUTDIR)\libpq.dll"
3743

@@ -72,16 +78,20 @@ CPP_PROJ=/nologo /MD /W3 /GX $(OPT) /I "..\..\include" /D "FRONTEND" $(DEBUGDEF)
7278
"WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
7379
/Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP"
7480

75-
CPP_OBJS=.\Release/
81+
!IFDEF USE_SSL
82+
CPP_PROJ=$(CPP_PROJ) /D USE_SSL
83+
SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
84+
!ENDIF
85+
7686
CPP_SBRS=.
7787

7888
LIB32=link.exe -lib
7989
LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib"
8090
LIB32_OBJS=\
81-
"$(OUTDIR)\win32.obj"\
91+
"$(INTDIR)\win32.obj"\
8292
"$(INTDIR)\getaddrinfo.obj"\
8393
"$(INTDIR)\inet_aton.obj"\
84-
"$(INTDIR)\crypt.obj"\
94+
"$(INTDIR)\crypt.obj"\
8595
"$(INTDIR)\path.obj"\
8696
"$(INTDIR)\dllist.obj"\
8797
"$(INTDIR)\md5.obj"\
@@ -94,15 +104,17 @@ LIB32_OBJS= \
94104
"$(INTDIR)\fe-lobj.obj"\
95105
"$(INTDIR)\fe-misc.obj"\
96106
"$(INTDIR)\fe-print.obj"\
107+
"$(INTDIR)\thread.obj"\
97108
"$(INTDIR)\fe-secure.obj"\
98109
"$(INTDIR)\pqexpbuffer.obj"\
99110
"$(INTDIR)\wchar.obj"\
100111
"$(INTDIR)\encnames.obj"
101112

113+
102114
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
103115

104116
LINK32=link.exe
105-
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib\
117+
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib$(SSL_LIBS)\
106118
/nologo /subsystem:windows /dll$(LOPT) /incremental:no\
107119
/pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\
108120
/implib:"$(OUTDIR)\libpqdll.lib" /def:libpqdll.def
@@ -126,38 +138,43 @@ LINK32_OBJS= \
126138
$(LINK32_FLAGS) $(LINK32_OBJS)
127139
<<
128140

129-
"$(OUTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
141+
"$(INTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
130142
$(CPP) @<<
131143
$(CPP_PROJ) ..\..\port\getaddrinfo.c
132144
<<
133145

134-
"$(OUTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
146+
"$(INTDIR)\thread.obj" : ..\..\port\thread.c
147+
$(CPP) @<<
148+
$(CPP_PROJ) ..\..\port\thread.c
149+
<<
150+
151+
"$(INTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
135152
$(CPP) @<<
136153
$(CPP_PROJ) ..\..\port\inet_aton.c
137154
<<
138155

139-
"$(OUTDIR)\crypt.obj" : ..\..\port\crypt.c
156+
"$(INTDIR)\crypt.obj" : ..\..\port\crypt.c
140157
$(CPP) @<<
141158
$(CPP_PROJ) ..\..\port\crypt.c
142159
<<
143160

144-
"$(OUTDIR)\path.obj" : ..\..\port\path.c
161+
"$(INTDIR)\path.obj" : ..\..\port\path.c
145162
$(CPP) @<<
146163
$(CPP_PROJ) ..\..\port\path.c
147164
<<
148165

149-
"$(OUTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
166+
"$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
150167
$(CPP) @<<
151168
$(CPP_PROJ) ..\..\backend\lib\dllist.c
152169
<<
153170

154171

155-
"$(OUTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
172+
"$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
156173
$(CPP) @<<
157174
$(CPP_PROJ) ..\..\backend\libpq\md5.c
158175
<<
159176

160-
"$(OUTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
177+
"$(INTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
161178
$(CPP) @<<
162179
$(CPP_PROJ) ..\..\backend\libpq\ip.c
163180
<<

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp