]> granicus.if.org Git - postgresql/commitdiff
Hi!
authorBruce Momjian <bruce@momjian.us>
Tue, 18 Jan 2000 19:05:31 +0000 (19:05 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 18 Jan 2000 19:05:31 +0000 (19:05 +0000)
Here is a patch to bring both libpq and psql to a state where it compiles on
win32 (native) again. A lot of things have changed, and I have not been able
to keep up with them all, so it has been broken for quite a while.
After this patch, at least it compiles. It also talks "basic talk" to the
server, but I have not yet tested all things. Sending queries, and using
e.g. \d or \dt works fine. The rest will have to be tested further.
It also bumps the version on libpq.dll to 7.0.

Everything should be enclosed in #ifdef WIN32, unless I have missed
something. Except for one or maybe two places where I have moved a #include
that should not be used on win32 from the "global area" into a "#ifndef
WIN32 area".

//Magnus

14 files changed:
src/bin/psql/command.c
src/bin/psql/common.c
src/bin/psql/help.c
src/bin/psql/print.c
src/bin/psql/startup.c
src/bin/psql/win32.mak
src/interfaces/libpq/fe-auth.c
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-print.c
src/interfaces/libpq/libpq.rc
src/interfaces/libpq/libpqdll.def
src/interfaces/libpq/pqexpbuffer.c
src/win32.mak

index 6f1bc1b66d881660a3b806109660f0a29cf317d4..4ed0280c895c08ccf0707e4564040ec6168ebe63 100644 (file)
@@ -28,6 +28,7 @@
 #include "variables.h"
 
 #ifdef WIN32
+#include "../../interfaces/libpq/win32.h"
 #define popen(x,y) _popen(x,y)
 #define pclose(x) _pclose(x)
 #endif
@@ -849,7 +850,11 @@ unescape(const char *source, int encoding)
                                unsigned int len;
                                char       *copy;
                                const char *value;
+#ifndef WIN32
                                void       *new;
+#else
+                               char *new;
+#endif
 
                                len = strcspn(p + 2, "}");
                                copy = xstrdup(p + 2);
index 8133faa467aab1128369affd18d4a8051f18b56d..b1241bd53d83867b4140b248afb38464468de6c1 100644 (file)
@@ -111,10 +111,12 @@ setQFout(const char *fname)
        }
 
        /* Direct signals */
+#ifndef WIN32
        if (pset.queryFoutPipe)
                pqsignal(SIGPIPE, SIG_IGN);
        else
                pqsignal(SIGPIPE, SIG_DFL);
+#endif
 
        return status;
 }
@@ -252,11 +254,15 @@ PSQLexec(const char *query)
                return NULL;
 
        cancelConn = pset.db;
+#ifndef WIN32
        pqsignal(SIGINT, handle_sigint);        /* control-C => cancel */
+#endif
 
        res = PQexec(pset.db, query);
 
+#ifndef WIN32
        pqsignal(SIGINT, SIG_DFL);      /* now control-C is back to normal */
+#endif
 
        if (PQstatus(pset.db) == CONNECTION_BAD)
        {
@@ -345,11 +351,15 @@ SendQuery(const char *query)
     }
 
        cancelConn = pset.db;
+#ifndef WIN32
        pqsignal(SIGINT, handle_sigint);
+#endif
 
        results = PQexec(pset.db, query);
 
+#ifndef WIN32
        pqsignal(SIGINT, SIG_DFL);
+#endif
 
        if (results == NULL)
        {
index 47fc0d8fc51da596f7f12f7843f6b3923628853c..18f41e84fc56057b9de4fc8e64739b0a5b347518 100644 (file)
@@ -176,7 +176,9 @@ slashUsage(void)
                (fout = popen(pagerenv, "w")))
        {
                usePipe = true;
+#ifndef WIN32
                pqsignal(SIGPIPE, SIG_IGN);
+#endif
        }
        else
                fout = stdout;
@@ -220,7 +222,9 @@ slashUsage(void)
        if (usePipe)
        {
                pclose(fout);
+#ifndef WIN32
                pqsignal(SIGPIPE, SIG_DFL);
+#endif
        }
 }
 
index 156cdf6c653520ad480f4749d2de09a21840aaf2..4676d4b506e1b5d60990685ea8053440ac317118 100644 (file)
@@ -922,7 +922,9 @@ printTable(const char *title,
        if (pager)
        {
                output = pager;
+#ifndef WIN32
                pqsignal(SIGPIPE, SIG_IGN);
+#endif
        }
        else
                output = fout;
@@ -963,7 +965,10 @@ printTable(const char *title,
        if (pager)
        {
                pclose(pager);
+#ifndef WIN32
                pqsignal(SIGPIPE, SIG_DFL);
+#endif
+
        }
 }
 
index 2b2a1db3d4b412a6498fad2aecf2d877d2d2d819..c1e9fa021900dba068ab018b5360ba206e2ce934 100644 (file)
@@ -10,7 +10,7 @@
 
 #ifdef WIN32
 #include <io.h>
-#include <window.h>
+#include <windows.h>
 #else
 #include <unistd.h>
 #endif
@@ -223,7 +223,8 @@ main(int argc, char **argv)
 #ifdef WIN32
 /* getopt is not in the standard includes on Win32 */
 int                    getopt(int, char *const[], const char *);
-
+/* And it requires progname to be set */
+char        *__progname = "psql";
 #endif
 
 static void
index 0b0228f3f62b8e9c1273d07b21ea8dc892b0cfe6..0365a0031161e10db5379de41ec3be9738cbf6ab 100644 (file)
@@ -17,8 +17,20 @@ OutDir=.\Release
 ALL : "$(OUTDIR)\psql.exe"
 
 CLEAN :
-       -@erase "$(INTDIR)\psql.obj"
+       -@erase "$(INTDIR)\command.obj"
+       -@erase "$(INTDIR)\common.obj"
+       -@erase "$(INTDIR)\help.obj"
+       -@erase "$(INTDIR)\input.obj"
        -@erase "$(INTDIR)\stringutils.obj"
+       -@erase "$(INTDIR)\mainloop.obj"
+       -@erase "$(INTDIR)\copy.obj"
+       -@erase "$(INTDIR)\startup.obj"
+       -@erase "$(INTDIR)\prompt.obj"
+       -@erase "$(INTDIR)\variables.obj"
+       -@erase "$(INTDIR)\large_obj.obj"
+       -@erase "$(INTDIR)\print.obj"
+       -@erase "$(INTDIR)\describe.obj"
+       -@erase "$(INTDIR)\tab-complete.obj"
        -@erase "$(INTDIR)\getopt.obj"
        -@erase "$(INTDIR)\vc50.idb"
        -@erase "$(OUTDIR)\psql.exe"
@@ -46,8 +58,20 @@ LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
  odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:no\
  /pdb:"$(OUTDIR)\psql.pdb" /machine:I386 /out:"$(OUTDIR)\psql.exe" 
 LINK32_OBJS= \
-       "$(INTDIR)\psql.obj" \
+       "$(INTDIR)\command.obj" \
+       "$(INTDIR)\common.obj" \
+       "$(INTDIR)\help.obj" \
+       "$(INTDIR)\input.obj" \
        "$(INTDIR)\stringutils.obj" \
+       "$(INTDIR)\mainloop.obj" \
+       "$(INTDIR)\copy.obj" \
+       "$(INTDIR)\startup.obj" \
+       "$(INTDIR)\prompt.obj" \
+       "$(INTDIR)\variables.obj" \
+       "$(INTDIR)\large_obj.obj" \
+       "$(INTDIR)\print.obj" \
+       "$(INTDIR)\describe.obj" \
+       "$(INTDIR)\tab-complete.obj" \
        "$(INTDIR)\getopt.obj" \
        "..\..\interfaces\libpq\Release\libpqdll.lib"
 
index fe92bd6964a15010bd324ae60312da003d4acb39..53d29a59d313772e279b9fd7bd170248361cdb88 100644 (file)
@@ -9,7 +9,7 @@
  * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.34 1999/10/25 03:08:00 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.35 2000/01/18 19:05:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,7 +27,9 @@
  *
  */
 
+#ifndef WIN32
 #include "postgres.h"
+#endif
 #include "libpq-fe.h"
 #include "libpq-int.h"
 #include "fe-auth.h"
index 818b85f0eaea85e3f85d33dbbf89d8fb57feef92..a444e5bd7a8f8dbfe7e6bc0ef9cd199e930aba3f 100644 (file)
@@ -7,13 +7,12 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.112 2000/01/18 06:09:24 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.113 2000/01/18 19:05:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <ctype.h>
@@ -26,6 +25,7 @@
 #ifdef WIN32
 #include "win32.h"
 #else
+#include <sys/socket.h>
 #include <unistd.h>
 #include <netdb.h>
 #include <netinet/tcp.h>
 #include "mb/pg_wchar.h"
 #endif
 
+#ifdef WIN32
+static int inet_aton(const char *cp, struct in_addr *inp) {
+       unsigned long a = inet_addr(cp);
+       if (a == -1)
+               return 0;
+       inp->s_addr = a;        
+       return 1;
+}
+#endif
+
 /* ----------
  *     pg_setenv_state
  * A struct used when polling a setenv request. This is referred to externally
@@ -842,7 +852,11 @@ connectDBStart(PGconn *conn)
         */
        if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0)
        {
+#ifndef WIN32
                if (errno == EINPROGRESS)
+#else
+               if (WSAGetLastError() == WSAEINPROGRESS)
+#endif
                {
                        /* This is fine - we're in non-blocking mode, and the
                         * connection is in progress. */
@@ -1036,8 +1050,12 @@ PQconnectPoll(PGconn *conn)
                case CONNECTION_STARTED:
                {
                        SOCKET_SIZE_TYPE laddrlen;
+#ifndef WIN32
                        int optval;
-                       int optlen = sizeof(int);
+#else
+                       char optval;
+#endif
+                       int optlen = sizeof(optval);
 
                        /* Write ready, since we've made it here, so the connection
                         * has been made. */
index a936e9374271431fdc1406d801c322dcdc08d6d3..b87ab4df98ba7ff837fbfa83ce00e2fe391e1c77 100644 (file)
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.34 2000/01/18 06:09:24 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.35 2000/01/18 19:05:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
-#include <sys/time.h>
 #include <errno.h>
 #include <signal.h>
 #include <time.h>
@@ -43,6 +42,7 @@
 #include "win32.h"
 #else
 #include <unistd.h>
+#include <sys/time.h>
 #endif
 
 #ifdef HAVE_SYS_SELECT_H
index d6f952d32bd2616ee44279443f34c7e52f50047f..7a73a8669b8a21f903e8d1aad0e75dd4f1ad06cc 100644 (file)
@@ -9,7 +9,7 @@
  * didn't really belong there.
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.29 2000/01/15 05:37:21 ishii Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.30 2000/01/18 19:05:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifdef HAVE_TERMIOS_H
 #include <termios.h>
 #else
+#ifndef WIN32
 #include <sys/termios.h>
 #endif
+#endif
 
 #ifdef MULTIBYTE
 #include "mb/pg_wchar.h"
index 9bf68cb19a92cd1b06c056282b24e583f8315a35..5a6ada372ad68e8875e22cb9fa840a24be70dcfe 100644 (file)
@@ -1,8 +1,8 @@
 #include <winver.h>
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 6,6,0,0
- PRODUCTVERSION 6,6,0,0
+ FILEVERSION 7,0,0,0
+ PRODUCTVERSION 7,0,0,0
  FILEFLAGSMASK 0x3fL
  FILEFLAGS 0
  FILEOS VOS__WINDOWS32
@@ -15,13 +15,13 @@ BEGIN
         BEGIN
             VALUE "CompanyName", "\0"
             VALUE "FileDescription", "PostgreSQL Access Library\0"
-            VALUE "FileVersion", "6, 6, 0, 0\0"
+            VALUE "FileVersion", "7, 0, 0, 0\0"
             VALUE "InternalName", "libpq\0"
-            VALUE "LegalCopyright", "Copyright (C) 1999\0"
+            VALUE "LegalCopyright", "Copyright (C) 2000\0"
             VALUE "LegalTrademarks", "\0"
             VALUE "OriginalFilename", "libpq.dll\0"
             VALUE "ProductName", "PostgreSQL\0"
-            VALUE "ProductVersion", "6, 6, 0, 0\0"
+            VALUE "ProductVersion", "7, 0, 0, 0\0"
         END
     END
     BLOCK "VarFileInfo"
index d83bdfafd4809b42bf179fa875092f6b48db710e..dc33dc0ee90732982ac0ab3b672aa3406e417314 100644 (file)
@@ -67,3 +67,14 @@ EXPORTS
        PQmblen                 @ 64
        PQresultErrorMessage    @ 65
        PQresStatus             @ 66
+       termPQExpBuffer         @ 67
+       appendPQExpBufferChar   @ 68
+       initPQExpBuffer         @ 69
+       resetPQExpBuffer        @ 70
+       PQoidValue              @ 71
+       PQclientencoding        @ 72
+       PQenv2encoding          @ 73
+       appendBinaryPQExpBuffer @ 74
+       appendPQExpBufferStr    @ 75
+       destroyPQExpBuffer      @ 76
+       createPQExpBuffer       @ 77
index bedf456b3ceb67ed333f7ed476292485b7043eb9..6850a80c5b7f6fdd8e47c790b3b8958c1b23e803 100644 (file)
@@ -16,7 +16,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.2 2000/01/17 02:59:46 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.3 2000/01/18 19:05:31 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
 #include "pqexpbuffer.h"
 
+#ifdef WIN32
+#include <stdarg.h>
+#include <stdio.h>
+#include "win32.h"
+#endif
+
 /*
  * createPQExpBuffer
  *
index a7264acf543ad3b9133db7d6008bd866c7f0dabe..86d9ee8216e1e3db39852bbf953c78ec0d0f3405 100644 (file)
@@ -15,9 +15,25 @@ MAKEMACRO = "MULTIBYTE=$(MULTIBYTE)"
 !ENDIF
 
 ALL: 
+   cd include
+   if not exist config.h copy config.h.win32 config.h
+   cd ..
    cd interfaces\libpq
    nmake /f win32.mak $(MAKEMACRO)
    cd ..\..\bin\psql
    nmake /f win32.mak $(MAKEMACRO)
    cd ..\..
    echo All Win32 parts have been built!
+
+CLEAN:
+   cd interfaces\libpq
+   nmake /f win32.mak CLEAN
+   cd ..\..\bin\psql
+   nmake /f win32.mak CLEAN
+   cd ..\..
+   echo All Win32 parts have been cleaned!
+
+DISTCLEAN: CLEAN
+   cd include
+   del config.h
+   cd ..
\ No newline at end of file