Commit 2dc94371 authored by Bruce Momjian's avatar Bruce Momjian

Enable Win32 to compile libpq again, and enable SSL compiles on that

platform.

Andreas Pflug
parent 1709fde5
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.259 2003/08/04 02:40:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.260 2003/09/05 02:08:36 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
/* For FNCTL_NONBLOCK */ /* For FNCTL_NONBLOCK */
#if defined(WIN32) || defined(__BEOS__) #if defined(WIN32) || defined(__BEOS__)
long ioctlsocket_ret; long ioctlsocket_ret=1;
#endif #endif
#define PGPASSFILE ".pgpass" #define PGPASSFILE ".pgpass"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.146 2003/08/27 00:33:34 petere Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.147 2003/09/05 02:08:36 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2304,7 +2304,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen) ...@@ -2304,7 +2304,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
if (buffer == NULL) if (buffer == NULL)
return NULL; return NULL;
for (i = j = buflen = 0; i < strtextlen;) for (i = j = buflen = 0; i < (int)strtextlen;)
{ {
switch (strtext[i]) switch (strtext[i])
{ {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.29 2003/08/04 17:25:14 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-secure.c,v 1.30 2003/09/05 02:08:36 momjian Exp $
* *
* NOTES * NOTES
* The client *requires* a valid server certificate. Since * The client *requires* a valid server certificate. Since
...@@ -312,7 +312,7 @@ rloop: ...@@ -312,7 +312,7 @@ rloop:
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("SSL SYSCALL error: EOF detected\n")); libpq_gettext("SSL SYSCALL error: EOF detected\n"));
SOCK_ERRNO = ECONNRESET; SOCK_ERRNO_SET(ECONNRESET);
n = -1; n = -1;
} }
break; break;
...@@ -322,7 +322,7 @@ rloop: ...@@ -322,7 +322,7 @@ rloop:
libpq_gettext("SSL error: %s\n"), SSLerrmessage()); libpq_gettext("SSL error: %s\n"), SSLerrmessage());
/* fall through */ /* fall through */
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
SOCK_ERRNO = ECONNRESET; SOCK_ERRNO_SET(ECONNRESET);
n = -1; n = -1;
break; break;
default: default:
...@@ -383,7 +383,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) ...@@ -383,7 +383,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("SSL SYSCALL error: EOF detected\n")); libpq_gettext("SSL SYSCALL error: EOF detected\n"));
SOCK_ERRNO = ECONNRESET; SOCK_ERRNO_SET(ECONNRESET);
n = -1; n = -1;
} }
break; break;
...@@ -393,7 +393,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len) ...@@ -393,7 +393,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
libpq_gettext("SSL error: %s\n"), SSLerrmessage()); libpq_gettext("SSL error: %s\n"), SSLerrmessage());
/* fall through */ /* fall through */
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
SOCK_ERRNO = ECONNRESET; SOCK_ERRNO_SET(ECONNRESET);
n = -1; n = -1;
break; break;
default: default:
...@@ -544,6 +544,9 @@ verify_peer(PGconn *conn) ...@@ -544,6 +544,9 @@ verify_peer(PGconn *conn)
static DH * static DH *
load_dh_file(int keylength) load_dh_file(int keylength)
{ {
#ifdef WIN32
return NULL;
#else
char pwdbuf[BUFSIZ]; char pwdbuf[BUFSIZ];
struct passwd pwdstr; struct passwd pwdstr;
struct passwd *pwd = NULL; struct passwd *pwd = NULL;
...@@ -558,6 +561,7 @@ load_dh_file(int keylength) ...@@ -558,6 +561,7 @@ load_dh_file(int keylength)
/* attempt to open file. It's not an error if it doesn't exist. */ /* attempt to open file. It's not an error if it doesn't exist. */
snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/dh%d.pem", snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/dh%d.pem",
pwd->pw_dir, keylength); pwd->pw_dir, keylength);
if ((fp = fopen(fnbuf, "r")) == NULL) if ((fp = fopen(fnbuf, "r")) == NULL)
return NULL; return NULL;
...@@ -583,6 +587,7 @@ load_dh_file(int keylength) ...@@ -583,6 +587,7 @@ load_dh_file(int keylength)
} }
return dh; return dh;
#endif
} }
/* /*
...@@ -686,6 +691,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength) ...@@ -686,6 +691,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength)
static int static int
client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
{ {
#ifdef WIN32
return 0;
#else
char pwdbuf[BUFSIZ]; char pwdbuf[BUFSIZ];
struct passwd pwdstr; struct passwd pwdstr;
struct passwd *pwd = NULL; struct passwd *pwd = NULL;
...@@ -785,6 +793,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) ...@@ -785,6 +793,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
} }
return 1; return 1;
#endif
} }
/* /*
...@@ -793,11 +802,13 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) ...@@ -793,11 +802,13 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
static int static int
initialize_SSL(PGconn *conn) initialize_SSL(PGconn *conn)
{ {
#ifndef WIN32
struct stat buf; struct stat buf;
char pwdbuf[BUFSIZ]; char pwdbuf[BUFSIZ];
struct passwd pwdstr; struct passwd pwdstr;
struct passwd *pwd = NULL; struct passwd *pwd = NULL;
char fnbuf[2048]; char fnbuf[2048];
#endif
if (!SSL_context) if (!SSL_context)
{ {
...@@ -813,6 +824,7 @@ initialize_SSL(PGconn *conn) ...@@ -813,6 +824,7 @@ initialize_SSL(PGconn *conn)
} }
} }
#ifndef WIN32
if (pqGetpwuid(getuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) == 0) if (pqGetpwuid(getuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) == 0)
{ {
snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/root.crt", snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/root.crt",
...@@ -849,6 +861,7 @@ initialize_SSL(PGconn *conn) ...@@ -849,6 +861,7 @@ initialize_SSL(PGconn *conn)
/* set up mechanism to provide client certificate, if available */ /* set up mechanism to provide client certificate, if available */
SSL_CTX_set_client_cert_cb(SSL_context, client_cert_cb); SSL_CTX_set_client_cert_cb(SSL_context, client_cert_cb);
#endif
return 0; return 0;
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: libpq-int.h,v 1.81 2003/08/13 18:56:21 tgl Exp $ * $Id: libpq-int.h,v 1.82 2003/09/05 02:08:36 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -465,9 +465,11 @@ __attribute__((format_arg(1))); ...@@ -465,9 +465,11 @@ __attribute__((format_arg(1)));
#ifdef WIN32 #ifdef WIN32
#define SOCK_ERRNO (WSAGetLastError()) #define SOCK_ERRNO (WSAGetLastError())
#define SOCK_STRERROR winsock_strerror #define SOCK_STRERROR winsock_strerror
#define SOCK_ERRNO_SET(e) WSASetLastError(e)
#else #else
#define SOCK_ERRNO errno #define SOCK_ERRNO errno
#define SOCK_STRERROR pqStrerror #define SOCK_STRERROR pqStrerror
#define SOCK_ERRNO_SET(e) errno=e
#endif #endif
#endif /* LIBPQ_INT_H */ #endif /* LIBPQ_INT_H */
...@@ -312,7 +312,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen) ...@@ -312,7 +312,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen)
{ {
strerrbuf[buflen - 1] = '\0'; strerrbuf[buflen - 1] = '\0';
offs = strlen(strerrbuf); offs = strlen(strerrbuf);
if (offs > buflen - 64) if (offs > (int)buflen - 64)
offs = buflen - 64; offs = buflen - 64;
sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err); sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err);
} }
......
# Makefile for Microsoft Visual C++ 5.0 (or compat) # Makefile for Microsoft Visual C++ 5.0 (or compat)
# Will build a Win32 static library (non-debug) libpq.lib # Will build a Win32 static library libpq.lib
# and a Win32 dynamic library (non-debug) libpq.dll with import library libpqdll.lib # and a Win32 dynamic library libpq.dll with import library libpqdll.lib
# USE_SSL=1 will compile with OpenSSL
# DEBUG=1 compiles with debugging symbols
!MESSAGE Building the Win32 static library... !MESSAGE Building the Win32 static library...
!MESSAGE !MESSAGE
!IFDEF DEBUG !IFDEF DEBUG
OPT=/Od OPT=/Od /Zi
LOPT=/debug LOPT=/debug
DEBUGDEF=/D _DEBUG DEBUGDEF=/D _DEBUG
!ELSE !ELSE
...@@ -26,12 +28,16 @@ NULL=nul ...@@ -26,12 +28,16 @@ NULL=nul
CPP=cl.exe CPP=cl.exe
RSC=rc.exe RSC=rc.exe
!IFDEF DEBUG
OUTDIR=.\Debug
INTDIR=.\Debug
CPP_OBJS=.\Debug/
!ELSE
OUTDIR=.\Release OUTDIR=.\Release
INTDIR=.\Release INTDIR=.\Release
CPP_OBJS=.\Release/
!ENDIF
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\libpq.lib" "$(OUTDIR)\libpq.dll" ALL : "$(OUTDIR)\libpq.lib" "$(OUTDIR)\libpq.dll"
...@@ -72,13 +78,17 @@ CPP_PROJ=/nologo /MD /W3 /GX $(OPT) /I "..\..\include" /D "FRONTEND" $(DEBUGDEF) ...@@ -72,13 +78,17 @@ CPP_PROJ=/nologo /MD /W3 /GX $(OPT) /I "..\..\include" /D "FRONTEND" $(DEBUGDEF)
"WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\ "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
/Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c /D "HAVE_VSNPRINTF" /D "HAVE_STRDUP"
CPP_OBJS=.\Release/ !IFDEF USE_SSL
CPP_PROJ=$(CPP_PROJ) /D USE_SSL
SSL_LIBS=ssleay32.lib libeay32.lib gdi32.lib
!ENDIF
CPP_SBRS=. CPP_SBRS=.
LIB32=link.exe -lib LIB32=link.exe -lib
LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib" LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib"
LIB32_OBJS= \ LIB32_OBJS= \
"$(OUTDIR)\win32.obj" \ "$(INTDIR)\win32.obj" \
"$(INTDIR)\getaddrinfo.obj" \ "$(INTDIR)\getaddrinfo.obj" \
"$(INTDIR)\inet_aton.obj" \ "$(INTDIR)\inet_aton.obj" \
"$(INTDIR)\crypt.obj" \ "$(INTDIR)\crypt.obj" \
...@@ -94,15 +104,17 @@ LIB32_OBJS= \ ...@@ -94,15 +104,17 @@ LIB32_OBJS= \
"$(INTDIR)\fe-lobj.obj" \ "$(INTDIR)\fe-lobj.obj" \
"$(INTDIR)\fe-misc.obj" \ "$(INTDIR)\fe-misc.obj" \
"$(INTDIR)\fe-print.obj" \ "$(INTDIR)\fe-print.obj" \
"$(INTDIR)\thread.obj" \
"$(INTDIR)\fe-secure.obj" \ "$(INTDIR)\fe-secure.obj" \
"$(INTDIR)\pqexpbuffer.obj" \ "$(INTDIR)\pqexpbuffer.obj" \
"$(INTDIR)\wchar.obj" \ "$(INTDIR)\wchar.obj" \
"$(INTDIR)\encnames.obj" "$(INTDIR)\encnames.obj"
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res" RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
LINK32=link.exe LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib\ LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib wsock32.lib $(SSL_LIBS) \
/nologo /subsystem:windows /dll $(LOPT) /incremental:no\ /nologo /subsystem:windows /dll $(LOPT) /incremental:no\
/pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\ /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\
/implib:"$(OUTDIR)\libpqdll.lib" /def:libpqdll.def /implib:"$(OUTDIR)\libpqdll.lib" /def:libpqdll.def
...@@ -126,38 +138,43 @@ LINK32_OBJS= \ ...@@ -126,38 +138,43 @@ LINK32_OBJS= \
$(LINK32_FLAGS) $(LINK32_OBJS) $(LINK32_FLAGS) $(LINK32_OBJS)
<< <<
"$(OUTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c "$(INTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\port\getaddrinfo.c $(CPP_PROJ) ..\..\port\getaddrinfo.c
<< <<
"$(OUTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c "$(INTDIR)\thread.obj" : ..\..\port\thread.c
$(CPP) @<<
$(CPP_PROJ) ..\..\port\thread.c
<<
"$(INTDIR)\inet_aton.obj" : ..\..\port\inet_aton.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\port\inet_aton.c $(CPP_PROJ) ..\..\port\inet_aton.c
<< <<
"$(OUTDIR)\crypt.obj" : ..\..\port\crypt.c "$(INTDIR)\crypt.obj" : ..\..\port\crypt.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\port\crypt.c $(CPP_PROJ) ..\..\port\crypt.c
<< <<
"$(OUTDIR)\path.obj" : ..\..\port\path.c "$(INTDIR)\path.obj" : ..\..\port\path.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\port\path.c $(CPP_PROJ) ..\..\port\path.c
<< <<
"$(OUTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c "$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\backend\lib\dllist.c $(CPP_PROJ) ..\..\backend\lib\dllist.c
<< <<
"$(OUTDIR)\md5.obj" : ..\..\backend\libpq\md5.c "$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\backend\libpq\md5.c $(CPP_PROJ) ..\..\backend\libpq\md5.c
<< <<
"$(OUTDIR)\ip.obj" : ..\..\backend\libpq\ip.c "$(INTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\backend\libpq\ip.c $(CPP_PROJ) ..\..\backend\libpq\ip.c
<< <<
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment