]> granicus.if.org Git - postgresql/commitdiff
Enable Win32 to compile libpq again, and enable SSL compiles on that
authorBruce Momjian <bruce@momjian.us>
Fri, 5 Sep 2003 02:08:36 +0000 (02:08 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 5 Sep 2003 02:08:36 +0000 (02:08 +0000)
platform.

Andreas Pflug

src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-secure.c
src/interfaces/libpq/libpq-int.h
src/interfaces/libpq/win32.c
src/interfaces/libpq/win32.mak

index ef72edb8c721713f9f3130fc077282f5ca551afd..9c2d7be4fa2df4f2ab83e8587c69afec6ffec39c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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 @@
 
 /* For FNCTL_NONBLOCK */
 #if defined(WIN32) || defined(__BEOS__)
-long           ioctlsocket_ret;
+long           ioctlsocket_ret=1;
 #endif
 
 #define PGPASSFILE ".pgpass"
index f9ce9564a7cdf0fc969014685710ea6425022ac0..af176d919d8014f0107e298188daaf7869f03c3c 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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)
        if (buffer == NULL)
                return NULL;
 
-       for (i = j = buflen = 0; i < strtextlen;)
+       for (i = j = buflen = 0; i < (int)strtextlen;)
        {
                switch (strtext[i])
                {
index b116c523b7febe7a4e2d45c8eb20374d39fcf416..9a2ac48698901ad5c38b193374545cc34b6ba56b 100644 (file)
@@ -11,7 +11,7 @@
  *
  *
  * 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
  *       The client *requires* a valid server certificate.  Since
@@ -312,7 +312,7 @@ rloop:
                                                printfPQExpBuffer(&conn->errorMessage,
                                                                                  libpq_gettext("SSL SYSCALL error: EOF detected\n"));
 
-                                               SOCK_ERRNO = ECONNRESET;
+                                               SOCK_ERRNO_SET(ECONNRESET);
                                                n = -1;
                                        }
                                        break;
@@ -322,7 +322,7 @@ rloop:
                                          libpq_gettext("SSL error: %s\n"), SSLerrmessage());
                                /* fall through */
                        case SSL_ERROR_ZERO_RETURN:
-                               SOCK_ERRNO = ECONNRESET;
+                               SOCK_ERRNO_SET(ECONNRESET);
                                n = -1;
                                break;
                        default:
@@ -383,7 +383,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
                                        {
                                                printfPQExpBuffer(&conn->errorMessage,
                                                                                  libpq_gettext("SSL SYSCALL error: EOF detected\n"));
-                                               SOCK_ERRNO = ECONNRESET;
+                                               SOCK_ERRNO_SET(ECONNRESET);
                                                n = -1;
                                        }
                                        break;
@@ -393,7 +393,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
                                          libpq_gettext("SSL error: %s\n"), SSLerrmessage());
                                /* fall through */
                        case SSL_ERROR_ZERO_RETURN:
-                               SOCK_ERRNO = ECONNRESET;
+                               SOCK_ERRNO_SET(ECONNRESET);
                                n = -1;
                                break;
                        default:
@@ -544,6 +544,9 @@ verify_peer(PGconn *conn)
 static DH  *
 load_dh_file(int keylength)
 {
+#ifdef WIN32
+    return NULL;
+#else
        char            pwdbuf[BUFSIZ];
        struct passwd pwdstr;
        struct passwd *pwd = NULL;
@@ -558,6 +561,7 @@ load_dh_file(int keylength)
        /* attempt to open file.  It's not an error if it doesn't exist. */
        snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/dh%d.pem",
                         pwd->pw_dir, keylength);
+
        if ((fp = fopen(fnbuf, "r")) == NULL)
                return NULL;
 
@@ -583,6 +587,7 @@ load_dh_file(int keylength)
        }
 
        return dh;
+#endif
 }
 
 /*
@@ -686,6 +691,9 @@ tmp_dh_cb(SSL *s, int is_export, int keylength)
 static int
 client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
 {
+#ifdef WIN32
+   return 0;
+#else
        char            pwdbuf[BUFSIZ];
        struct passwd pwdstr;
        struct passwd *pwd = NULL;
@@ -785,6 +793,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
        }
 
        return 1;
+#endif
 }
 
 /*
@@ -793,11 +802,13 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
 static int
 initialize_SSL(PGconn *conn)
 {
+#ifndef WIN32
        struct stat buf;
        char            pwdbuf[BUFSIZ];
        struct passwd pwdstr;
        struct passwd *pwd = NULL;
        char            fnbuf[2048];
+#endif
 
        if (!SSL_context)
        {
@@ -813,6 +824,7 @@ initialize_SSL(PGconn *conn)
                }
        }
 
+#ifndef WIN32
        if (pqGetpwuid(getuid(), &pwdstr, pwdbuf, sizeof(pwdbuf), &pwd) == 0)
        {
                snprintf(fnbuf, sizeof fnbuf, "%s/.postgresql/root.crt",
@@ -849,6 +861,7 @@ initialize_SSL(PGconn *conn)
 
        /* set up mechanism to provide client certificate, if available */
        SSL_CTX_set_client_cert_cb(SSL_context, client_cert_cb);
+#endif
 
        return 0;
 }
index 49cd29cb6c83eed400304d3f3c85a40003965520..40b161f78d3b8350d371e20d4981cd4a1c40a9af 100644 (file)
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * 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)));
 #ifdef WIN32
 #define SOCK_ERRNO (WSAGetLastError())
 #define SOCK_STRERROR winsock_strerror
+#define SOCK_ERRNO_SET(e) WSASetLastError(e)
 #else
 #define SOCK_ERRNO errno
 #define SOCK_STRERROR pqStrerror
+#define SOCK_ERRNO_SET(e) errno=e
 #endif
 
 #endif   /* LIBPQ_INT_H */
index a458361ced19bc29eead3d15cb351427233ff961..de83c38e8589ce8290eda4535f0192394edf8969 100644 (file)
@@ -312,7 +312,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen)
        {
                strerrbuf[buflen - 1] = '\0';
                offs = strlen(strerrbuf);
-               if (offs > buflen - 64)
+               if (offs > (int)buflen - 64)
                        offs = buflen - 64;
                sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err);
        }
index 11450a55858f7b31724fb0c172b2d88b1c673429..a910303c0faf9c0aaaae2f119c986f3fbab372dd 100644 (file)
@@ -1,14 +1,16 @@
 # Makefile for Microsoft Visual C++ 5.0 (or compat)
 
-# Will build a Win32 static library (non-debug) libpq.lib
-#        and a Win32 dynamic library (non-debug) libpq.dll with import library libpqdll.lib
+# Will build a Win32 static library libpq.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
 
 !IFDEF DEBUG
-OPT=/Od
+OPT=/Od /Zi
 LOPT=/debug
 DEBUGDEF=/D _DEBUG
 !ELSE
@@ -26,12 +28,16 @@ NULL=nul
 CPP=cl.exe
 RSC=rc.exe
 
+!IFDEF DEBUG
+OUTDIR=.\Debug
+INTDIR=.\Debug
+CPP_OBJS=.\Debug/
+!ELSE
 OUTDIR=.\Release
 INTDIR=.\Release
+CPP_OBJS=.\Release/
+!ENDIF
 
-# Begin Custom Macros
-OutDir=.\Release
-# End Custom Macros
 
 ALL : "$(OUTDIR)\libpq.lib" "$(OUTDIR)\libpq.dll" 
 
@@ -72,16 +78,20 @@ CPP_PROJ=/nologo /MD /W3 /GX $(OPT) /I "..\..\include" /D "FRONTEND" $(DEBUGDEF)
  "WIN32" /D "_WINDOWS" /Fp"$(INTDIR)\libpq.pch" /YX\
  /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=.
 
 LIB32=link.exe -lib
 LIB32_FLAGS=$(LOPT) /nologo /out:"$(OUTDIR)\libpq.lib" 
 LIB32_OBJS= \
-       "$(OUTDIR)\win32.obj" \
+       "$(INTDIR)\win32.obj" \
        "$(INTDIR)\getaddrinfo.obj" \
        "$(INTDIR)\inet_aton.obj" \
-      "$(INTDIR)\crypt.obj" \
+        "$(INTDIR)\crypt.obj" \
        "$(INTDIR)\path.obj" \
        "$(INTDIR)\dllist.obj" \
        "$(INTDIR)\md5.obj" \
@@ -94,15 +104,17 @@ LIB32_OBJS= \
        "$(INTDIR)\fe-lobj.obj" \
        "$(INTDIR)\fe-misc.obj" \
        "$(INTDIR)\fe-print.obj" \
+       "$(INTDIR)\thread.obj" \
        "$(INTDIR)\fe-secure.obj" \
        "$(INTDIR)\pqexpbuffer.obj" \
        "$(INTDIR)\wchar.obj" \
        "$(INTDIR)\encnames.obj"
 
+
 RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
 
 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\
  /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\libpq.dll"\
  /implib:"$(OUTDIR)\libpqdll.lib"  /def:libpqdll.def
@@ -126,38 +138,43 @@ LINK32_OBJS= \
   $(LINK32_FLAGS) $(LINK32_OBJS)
 <<
 
-"$(OUTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
+"$(INTDIR)\getaddrinfo.obj" : ..\..\port\getaddrinfo.c
     $(CPP) @<<
     $(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_PROJ) ..\..\port\inet_aton.c
 <<
 
-"$(OUTDIR)\crypt.obj" : ..\..\port\crypt.c
+"$(INTDIR)\crypt.obj" : ..\..\port\crypt.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\port\crypt.c
 <<
 
-"$(OUTDIR)\path.obj" : ..\..\port\path.c
+"$(INTDIR)\path.obj" : ..\..\port\path.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\port\path.c
 <<
 
-"$(OUTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
+"$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\backend\lib\dllist.c
 <<
 
 
-"$(OUTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
+"$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\backend\libpq\md5.c
 <<
 
-"$(OUTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
+"$(INTDIR)\ip.obj" : ..\..\backend\libpq\ip.c
     $(CPP) @<<
     $(CPP_PROJ) ..\..\backend\libpq\ip.c
 <<