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

Commit0cb6bc7

Browse files
committed
Hi!
Here is a patch to bring both libpq and psql to a state where it compiles onwin32 (native) again. A lot of things have changed, and I have not been ableto 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 theserver, but I have not yet tested all things. Sending queries, and usinge.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 missedsomething. Except for one or maybe two places where I have moved a #includethat should not be used on win32 from the "global area" into a "#ifndefWIN32 area".//Magnus
1 parent2eebcdd commit0cb6bc7

File tree

14 files changed

+121
-17
lines changed

14 files changed

+121
-17
lines changed

‎src/bin/psql/command.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include"variables.h"
2929

3030
#ifdefWIN32
31+
#include"../../interfaces/libpq/win32.h"
3132
#definepopen(x,y) _popen(x,y)
3233
#definepclose(x) _pclose(x)
3334
#endif
@@ -849,7 +850,11 @@ unescape(const char *source, int encoding)
849850
unsignedintlen;
850851
char*copy;
851852
constchar*value;
853+
#ifndefWIN32
852854
void*new;
855+
#else
856+
char*new;
857+
#endif
853858

854859
len=strcspn(p+2,"}");
855860
copy=xstrdup(p+2);

‎src/bin/psql/common.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ setQFout(const char *fname)
111111
}
112112

113113
/* Direct signals */
114+
#ifndefWIN32
114115
if (pset.queryFoutPipe)
115116
pqsignal(SIGPIPE,SIG_IGN);
116117
else
117118
pqsignal(SIGPIPE,SIG_DFL);
119+
#endif
118120

119121
returnstatus;
120122
}
@@ -252,11 +254,15 @@ PSQLexec(const char *query)
252254
returnNULL;
253255

254256
cancelConn=pset.db;
257+
#ifndefWIN32
255258
pqsignal(SIGINT,handle_sigint);/* control-C => cancel */
259+
#endif
256260

257261
res=PQexec(pset.db,query);
258262

263+
#ifndefWIN32
259264
pqsignal(SIGINT,SIG_DFL);/* now control-C is back to normal */
265+
#endif
260266

261267
if (PQstatus(pset.db)==CONNECTION_BAD)
262268
{
@@ -345,11 +351,15 @@ SendQuery(const char *query)
345351
}
346352

347353
cancelConn=pset.db;
354+
#ifndefWIN32
348355
pqsignal(SIGINT,handle_sigint);
356+
#endif
349357

350358
results=PQexec(pset.db,query);
351359

360+
#ifndefWIN32
352361
pqsignal(SIGINT,SIG_DFL);
362+
#endif
353363

354364
if (results==NULL)
355365
{

‎src/bin/psql/help.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ slashUsage(void)
176176
(fout=popen(pagerenv,"w")))
177177
{
178178
usePipe= true;
179+
#ifndefWIN32
179180
pqsignal(SIGPIPE,SIG_IGN);
181+
#endif
180182
}
181183
else
182184
fout=stdout;
@@ -220,7 +222,9 @@ slashUsage(void)
220222
if (usePipe)
221223
{
222224
pclose(fout);
225+
#ifndefWIN32
223226
pqsignal(SIGPIPE,SIG_DFL);
227+
#endif
224228
}
225229
}
226230

‎src/bin/psql/print.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,9 @@ printTable(const char *title,
922922
if (pager)
923923
{
924924
output=pager;
925+
#ifndefWIN32
925926
pqsignal(SIGPIPE,SIG_IGN);
927+
#endif
926928
}
927929
else
928930
output=fout;
@@ -963,7 +965,10 @@ printTable(const char *title,
963965
if (pager)
964966
{
965967
pclose(pager);
968+
#ifndefWIN32
966969
pqsignal(SIGPIPE,SIG_DFL);
970+
#endif
971+
967972
}
968973
}
969974

‎src/bin/psql/startup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#ifdefWIN32
1212
#include<io.h>
13-
#include<window.h>
13+
#include<windows.h>
1414
#else
1515
#include<unistd.h>
1616
#endif
@@ -223,7 +223,8 @@ main(int argc, char **argv)
223223
#ifdefWIN32
224224
/* getopt is not in the standard includes on Win32 */
225225
intgetopt(int,char*const[],constchar*);
226-
226+
/* And it requires progname to be set */
227+
char*__progname="psql";
227228
#endif
228229

229230
staticvoid

‎src/bin/psql/win32.mak

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@ OutDir=.\Release
1717
ALL : "$(OUTDIR)\psql.exe"
1818

1919
CLEAN :
20-
-@erase"$(INTDIR)\psql.obj"
20+
-@erase"$(INTDIR)\command.obj"
21+
-@erase"$(INTDIR)\common.obj"
22+
-@erase"$(INTDIR)\help.obj"
23+
-@erase"$(INTDIR)\input.obj"
2124
-@erase"$(INTDIR)\stringutils.obj"
25+
-@erase"$(INTDIR)\mainloop.obj"
26+
-@erase"$(INTDIR)\copy.obj"
27+
-@erase"$(INTDIR)\startup.obj"
28+
-@erase"$(INTDIR)\prompt.obj"
29+
-@erase"$(INTDIR)\variables.obj"
30+
-@erase"$(INTDIR)\large_obj.obj"
31+
-@erase"$(INTDIR)\print.obj"
32+
-@erase"$(INTDIR)\describe.obj"
33+
-@erase"$(INTDIR)\tab-complete.obj"
2234
-@erase"$(INTDIR)\getopt.obj"
2335
-@erase"$(INTDIR)\vc50.idb"
2436
-@erase"$(OUTDIR)\psql.exe"
@@ -46,8 +58,20 @@ LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
4658
odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:no\
4759
/pdb:"$(OUTDIR)\psql.pdb" /machine:I386 /out:"$(OUTDIR)\psql.exe"
4860
LINK32_OBJS=\
49-
"$(INTDIR)\psql.obj"\
61+
"$(INTDIR)\command.obj"\
62+
"$(INTDIR)\common.obj"\
63+
"$(INTDIR)\help.obj"\
64+
"$(INTDIR)\input.obj"\
5065
"$(INTDIR)\stringutils.obj"\
66+
"$(INTDIR)\mainloop.obj"\
67+
"$(INTDIR)\copy.obj"\
68+
"$(INTDIR)\startup.obj"\
69+
"$(INTDIR)\prompt.obj"\
70+
"$(INTDIR)\variables.obj"\
71+
"$(INTDIR)\large_obj.obj"\
72+
"$(INTDIR)\print.obj"\
73+
"$(INTDIR)\describe.obj"\
74+
"$(INTDIR)\tab-complete.obj"\
5175
"$(INTDIR)\getopt.obj"\
5276
"..\..\interfaces\libpq\Release\libpqdll.lib"
5377

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.34 1999/10/25 03:08:00 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.35 2000/01/18 19:05:31 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -27,7 +27,9 @@
2727
*
2828
*/
2929

30+
#ifndefWIN32
3031
#include"postgres.h"
32+
#endif
3133
#include"libpq-fe.h"
3234
#include"libpq-int.h"
3335
#include"fe-auth.h"

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.112 2000/01/1806:09:24 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.113 2000/01/1819:05:31 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#include<sys/types.h>
16-
#include<sys/socket.h>
1716
#include<fcntl.h>
1817
#include<errno.h>
1918
#include<ctype.h>
@@ -26,6 +25,7 @@
2625
#ifdefWIN32
2726
#include"win32.h"
2827
#else
28+
#include<sys/socket.h>
2929
#include<unistd.h>
3030
#include<netdb.h>
3131
#include<netinet/tcp.h>
@@ -43,6 +43,16 @@
4343
#include"mb/pg_wchar.h"
4444
#endif
4545

46+
#ifdefWIN32
47+
staticintinet_aton(constchar*cp,structin_addr*inp) {
48+
unsigned longa=inet_addr(cp);
49+
if (a==-1)
50+
return0;
51+
inp->s_addr=a;
52+
return1;
53+
}
54+
#endif
55+
4656
/* ----------
4757
* pg_setenv_state
4858
* A struct used when polling a setenv request. This is referred to externally
@@ -842,7 +852,11 @@ connectDBStart(PGconn *conn)
842852
*/
843853
if (connect(conn->sock,&conn->raddr.sa,conn->raddr_len)<0)
844854
{
855+
#ifndefWIN32
845856
if (errno==EINPROGRESS)
857+
#else
858+
if (WSAGetLastError()==WSAEINPROGRESS)
859+
#endif
846860
{
847861
/* This is fine - we're in non-blocking mode, and the
848862
* connection is in progress. */
@@ -1036,8 +1050,12 @@ PQconnectPoll(PGconn *conn)
10361050
caseCONNECTION_STARTED:
10371051
{
10381052
SOCKET_SIZE_TYPEladdrlen;
1053+
#ifndefWIN32
10391054
intoptval;
1040-
intoptlen=sizeof(int);
1055+
#else
1056+
charoptval;
1057+
#endif
1058+
intoptlen=sizeof(optval);
10411059

10421060
/* Write ready, since we've made it here, so the connection
10431061
* has been made. */

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
*
2525
*
2626
* IDENTIFICATION
27-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.34 2000/01/1806:09:24 momjian Exp $
27+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.35 2000/01/1819:05:31 momjian Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
3131

32-
#include<sys/time.h>
3332
#include<errno.h>
3433
#include<signal.h>
3534
#include<time.h>
@@ -43,6 +42,7 @@
4342
#include"win32.h"
4443
#else
4544
#include<unistd.h>
45+
#include<sys/time.h>
4646
#endif
4747

4848
#ifdefHAVE_SYS_SELECT_H

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* didn't really belong there.
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.29 2000/01/1505:37:21 ishii Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.30 2000/01/18 19:05:31 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -30,8 +30,10 @@
3030
#ifdefHAVE_TERMIOS_H
3131
#include<termios.h>
3232
#else
33+
#ifndefWIN32
3334
#include<sys/termios.h>
3435
#endif
36+
#endif
3537

3638
#ifdefMULTIBYTE
3739
#include"mb/pg_wchar.h"

‎src/interfaces/libpq/libpq.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <winver.h>
22

33
VS_VERSION_INFO VERSIONINFO
4-
FILEVERSION6,6,0,0
5-
PRODUCTVERSION6,6,0,0
4+
FILEVERSION7,0,0,0
5+
PRODUCTVERSION7,0,0,0
66
FILEFLAGSMASK 0x3fL
77
FILEFLAGS 0
88
FILEOS VOS__WINDOWS32
@@ -15,13 +15,13 @@ BEGIN
1515
BEGIN
1616
VALUE "CompanyName", "\0"
1717
VALUE "FileDescription", "PostgreSQL Access Library\0"
18-
VALUE "FileVersion", "6, 6, 0, 0\0"
18+
VALUE "FileVersion", "7, 0, 0, 0\0"
1919
VALUE "InternalName", "libpq\0"
20-
VALUE "LegalCopyright", "Copyright (C)1999\0"
20+
VALUE "LegalCopyright", "Copyright (C)2000\0"
2121
VALUE "LegalTrademarks", "\0"
2222
VALUE "OriginalFilename", "libpq.dll\0"
2323
VALUE "ProductName", "PostgreSQL\0"
24-
VALUE "ProductVersion", "6, 6, 0, 0\0"
24+
VALUE "ProductVersion", "7, 0, 0, 0\0"
2525
END
2626
END
2727
BLOCK "VarFileInfo"

‎src/interfaces/libpq/libpqdll.def

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,14 @@ EXPORTS
6767
PQmblen@ 64
6868
PQresultErrorMessage@ 65
6969
PQresStatus@ 66
70+
termPQExpBuffer@ 67
71+
appendPQExpBufferChar@ 68
72+
initPQExpBuffer@ 69
73+
resetPQExpBuffer@ 70
74+
PQoidValue@ 71
75+
PQclientencoding@ 72
76+
PQenv2encoding@ 73
77+
appendBinaryPQExpBuffer@ 74
78+
appendPQExpBufferStr@ 75
79+
destroyPQExpBuffer@ 76
80+
createPQExpBuffer@ 77

‎src/interfaces/libpq/pqexpbuffer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@
1616
*
1717
* Copyright (c) 1994, Regents of the University of California
1818
*
19-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.2 2000/01/17 02:59:46 tgl Exp $
19+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.3 2000/01/18 19:05:31 momjian Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
2323

2424
#include"postgres.h"
2525
#include"pqexpbuffer.h"
2626

27+
#ifdefWIN32
28+
#include<stdarg.h>
29+
#include<stdio.h>
30+
#include"win32.h"
31+
#endif
32+
2733
/*
2834
* createPQExpBuffer
2935
*

‎src/win32.mak

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,25 @@ MAKEMACRO = "MULTIBYTE=$(MULTIBYTE)"
1515
!ENDIF
1616

1717
ALL:
18+
cd include
19+
if not exist config.h copy config.h.win32 config.h
20+
cd ..
1821
cd interfaces\libpq
1922
nmake /f win32.mak $(MAKEMACRO)
2023
cd ..\..\bin\psql
2124
nmake /f win32.mak $(MAKEMACRO)
2225
cd ..\..
2326
echo All Win32 parts have been built!
27+
28+
CLEAN:
29+
cd interfaces\libpq
30+
nmake /f win32.mak CLEAN
31+
cd ..\..\bin\psql
32+
nmake /f win32.mak CLEAN
33+
cd ..\..
34+
echo All Win32 parts have been cleaned!
35+
36+
DISTCLEAN: CLEAN
37+
cd include
38+
del config.h
39+
cd ..

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp