Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 37c0b64

Browse files
committed
Below is the patch against current cvs for libpgtcl and
two additional files win32.mak and libpgtcl.def. This patch allows to compile libpgtcl.dll on Windows with tcl > 8.0. I've tested it on WinNT (VC6.0), SUSE Linux (7.0) and Solaris 2.6 with tcl 8.3.3. Mikhail Terekhov
1 parent ee0ef05 commit 37c0b64

File tree

8 files changed

+255
-14
lines changed

8 files changed

+255
-14
lines changed

src/interfaces/libpgtcl.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
;libpgtcl.def
2+
; The LIBRARY entry must be same as the name of your DLL, the name of
3+
; our DLL is libpgtcl.dll
4+
LIBRARY libpgtcl
5+
EXPORTS
6+
7+
Pgtcl_Init
8+
Pgtcl_SafeInit

src/interfaces/libpgtcl/pgtclCmds.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.56 2001/08/10 22:50:10 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.57 2001/09/06 02:54:56 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -403,6 +403,8 @@ Pg_connect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
403403
int
404404
Pg_disconnect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
405405
{
406+
Pg_ConnectionId *connid;
407+
PGconn *conn;
406408
Tcl_Channel conn_chan;
407409

408410
if (argc != 2)
@@ -419,6 +421,12 @@ Pg_disconnect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
419421
return TCL_ERROR;
420422
}
421423

424+
#if TCL_MAJOR_VERSION >= 8
425+
conn = PgGetConnectionId(interp, argv[1], &connid);
426+
if (connid->notifier_channel != NULL)
427+
Tcl_UnregisterChannel(interp, connid->notifier_channel);
428+
#endif
429+
422430
return Tcl_UnregisterChannel(interp, conn_chan);
423431
}
424432

src/interfaces/libpgtcl/pgtclCmds.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pgtclCmds.h,v 1.21 2001/03/22 04:01:24 momjian Exp $
9+
* $Id: pgtclCmds.h,v 1.22 2001/09/06 02:54:56 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -64,7 +64,11 @@ typedef struct Pg_ConnectionId_s
6464

6565
Pg_TclNotifies *notify_list;/* head of list of notify info */
6666
int notifier_running; /* notify event source is live */
67+
#if TCL_MAJOR_VERSION >= 8
68+
Tcl_Channel notifier_channel;/* Tcl_Channel on which notifier is listening */
69+
#else
6770
int notifier_socket;/* PQsocket on which notifier is listening */
71+
#endif
6872
} Pg_ConnectionId;
6973

7074
/* Values of res_copyStatus */

src/interfaces/libpgtcl/pgtclId.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.25 2001/02/10 02:31:29 tgl Exp $
16+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.26 2001/09/06 02:54:56 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -174,10 +174,16 @@ PgSetConnectionId(Tcl_Interp *interp, PGconn *conn)
174174
connid->results[i] = NULL;
175175
connid->notify_list = NULL;
176176
connid->notifier_running = 0;
177-
connid->notifier_socket = -1;
178177

179178
sprintf(connid->id, "pgsql%d", PQsocket(conn));
180179

180+
#if TCL_MAJOR_VERSION >= 8
181+
connid->notifier_channel = Tcl_MakeTcpClientChannel((ClientData) PQsocket(conn));
182+
Tcl_RegisterChannel(interp, connid->notifier_channel);
183+
#else
184+
connid->notifier_socket = -1;
185+
#endif
186+
181187
#if TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION == 5
182188
/* Original signature (only seen in Tcl 7.5) */
183189
conn_chan = Tcl_CreateChannel(&Pg_ConnType, connid->id, NULL, NULL, (ClientData) connid);
@@ -581,7 +587,7 @@ PgNotifyTransferEvents(Pg_ConnectionId * connid)
581587
event->info = *notify;
582588
event->connid = connid;
583589
Tcl_QueueEvent((Tcl_Event *) event, TCL_QUEUE_TAIL);
584-
free(notify);
590+
PQfreeNotify(notify);
585591
}
586592

587593
/*
@@ -688,18 +694,17 @@ PgStartNotifyEventSource(Pg_ConnectionId * connid)
688694
if (pqsock >= 0)
689695
{
690696
#if TCL_MAJOR_VERSION >= 8
691-
/* In Tcl 8, Tcl_CreateFileHandler takes a socket directly. */
692-
Tcl_CreateFileHandler(pqsock, TCL_READABLE,
693-
Pg_Notify_FileHandler, (ClientData) connid);
697+
Tcl_CreateChannelHandler(connid->notifier_channel, TCL_READABLE,
698+
Pg_Notify_FileHandler, (ClientData) connid);
694699
#else
695700
/* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */
696701
Tcl_File tclfile = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD);
697702

698703
Tcl_CreateFileHandler(tclfile, TCL_READABLE,
699704
Pg_Notify_FileHandler, (ClientData) connid);
705+
connid->notifier_socket = pqsock;
700706
#endif
701707
connid->notifier_running = 1;
702-
connid->notifier_socket = pqsock;
703708
}
704709
}
705710
}
@@ -711,8 +716,8 @@ PgStopNotifyEventSource(Pg_ConnectionId * connid)
711716
if (connid->notifier_running)
712717
{
713718
#if TCL_MAJOR_VERSION >= 8
714-
/* In Tcl 8, Tcl_DeleteFileHandler takes a socket directly. */
715-
Tcl_DeleteFileHandler(connid->notifier_socket);
719+
Tcl_DeleteChannelHandler(connid->notifier_channel,
720+
Pg_Notify_FileHandler, (ClientData) connid);
716721
#else
717722
/* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */
718723
Tcl_File tclfile = Tcl_GetFile((ClientData) connid->notifier_socket,

src/interfaces/libpq/fe-exec.c

Lines changed: 15 additions & 1 deletion
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.108 2001/08/21 20:39:53 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.109 2001/09/06 02:54:56 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1345,6 +1345,20 @@ PQnotifies(PGconn *conn)
13451345
return event;
13461346
}
13471347

1348+
/*
1349+
* PQfreeNotify - free's the memory associated with a PGnotify
1350+
*
1351+
* This function is needed on Windows when using libpq.dll and
1352+
* for example libpgtcl.dll: All memory allocated inside a dll
1353+
* should be freed in the context of the same dll.
1354+
*
1355+
*/
1356+
void
1357+
PQfreeNotify(PGnotify *notify)
1358+
{
1359+
free(notify);
1360+
}
1361+
13481362
/*
13491363
* PQgetline - gets a newline-terminated string from the backend.
13501364
*

src/interfaces/libpq/libpq-fe.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: libpq-fe.h,v 1.72 2001/08/21 20:39:54 momjian Exp $
10+
* $Id: libpq-fe.h,v 1.73 2001/09/06 02:54:56 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -254,6 +254,7 @@ extern "C"
254254
/* Simple synchronous query */
255255
extern PGresult *PQexec(PGconn *conn, const char *query);
256256
extern PGnotify *PQnotifies(PGconn *conn);
257+
extern void PQfreeNotify(PGnotify *notify);
257258

258259
/* Interface for multiple-result or asynchronous queries */
259260
extern int PQsendQuery(PGconn *conn, const char *query);

src/interfaces/libpq/libpqdll.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ EXPORTS
8787
PQresetStart @ 84
8888
PQsetClientEncoding @ 85
8989
PQsetnonblocking @ 86
90-
90+
PQfreeNotify @ 87

src/interfaces/win32.mak

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
# Microsoft Developer Studio Generated NMAKE File, Based on libpgtcl_REL7_1_STABLE.dsp
2+
!IF "$(CFG)" == ""
3+
CFG=libpgtcl - Win32 Release
4+
!MESSAGE No configuration specified. Defaulting to libpgtcl - Win32 Release.
5+
!ENDIF
6+
7+
!IF "$(CFG)" != "libpgtcl - Win32 Release" && "$(CFG)" != "libpgtcl - Win32 Debug"
8+
!MESSAGE Invalid configuration "$(CFG)" specified.
9+
!MESSAGE You can specify a configuration when running NMAKE
10+
!MESSAGE by defining the macro CFG on the command line. For example:
11+
!MESSAGE
12+
!MESSAGE NMAKE /f "libpgtcl.mak" CFG="libpgtcl - Win32 Debug"
13+
!MESSAGE
14+
!MESSAGE Possible choices for configuration are:
15+
!MESSAGE
16+
!MESSAGE "libpgtcl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
17+
!MESSAGE "libpgtcl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
18+
!MESSAGE
19+
!ERROR An invalid configuration is specified.
20+
!ENDIF
21+
22+
!IF "$(OS)" == "Windows_NT"
23+
NULL=
24+
!ELSE
25+
NULL=nul
26+
!ENDIF
27+
28+
CPP=cl.exe
29+
MTL=midl.exe
30+
RSC=rc.exe
31+
32+
TCLBASE=\usr\local\tcltk833
33+
PGINCLUDE=/I ..\..\include /I ..\libpq /I $(TCLBASE)\include
34+
35+
!IF "$(CFG)" == "libpgtcl - Win32 Release"
36+
37+
OUTDIR=.\Release
38+
INTDIR=.\Release
39+
# Begin Custom Macros
40+
OutDir=.\Release
41+
# End Custom Macros
42+
43+
ALL : "$(OUTDIR)\libpgtcl.dll" "$(OUTDIR)\libpgtcl.bsc"
44+
45+
46+
CLEAN :
47+
-@erase "$(INTDIR)\pgtcl.obj"
48+
-@erase "$(INTDIR)\pgtcl.sbr"
49+
-@erase "$(INTDIR)\pgtclCmds.obj"
50+
-@erase "$(INTDIR)\pgtclCmds.sbr"
51+
-@erase "$(INTDIR)\pgtclId.obj"
52+
-@erase "$(INTDIR)\pgtclId.sbr"
53+
-@erase "$(INTDIR)\vc60.idb"
54+
-@erase "$(OUTDIR)\libpgtcl.dll"
55+
-@erase "$(OUTDIR)\libpgtcl.exp"
56+
-@erase "$(OUTDIR)\libpgtcl.lib"
57+
-@erase "$(OUTDIR)\libpgtcl.bsc"
58+
59+
"$(OUTDIR)" :
60+
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
61+
62+
CPP_PROJ=/nologo /MT /W3 /GX /O2 $(PGINCLUDE) /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\libpgtcl.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
63+
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
64+
BSC32=bscmake.exe
65+
BSC32_FLAGS=/nologo /o"$(OUTDIR)\libpgtcl.bsc"
66+
BSC32_SBRS= \
67+
"$(INTDIR)\pgtcl.sbr" \
68+
"$(INTDIR)\pgtclCmds.sbr" \
69+
"$(INTDIR)\pgtclId.sbr"
70+
71+
"$(OUTDIR)\libpgtcl.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
72+
$(BSC32) @<<
73+
$(BSC32_FLAGS) $(BSC32_SBRS)
74+
<<
75+
76+
LINK32=link.exe
77+
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tcl83.lib libpq.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\libpgtcl.pdb" /machine:I386 /def:".\libpgtcl.def" /out:"$(OUTDIR)\libpgtcl.dll" /implib:"$(OUTDIR)\libpgtcl.lib" /libpath:"$(TCLBASE)\lib" /libpath:"..\libpq\Release"
78+
DEF_FILE= \
79+
".\libpgtcl.def"
80+
LINK32_OBJS= \
81+
"$(INTDIR)\pgtcl.obj" \
82+
"$(INTDIR)\pgtclCmds.obj" \
83+
"$(INTDIR)\pgtclId.obj"
84+
85+
"$(OUTDIR)\libpgtcl.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
86+
$(LINK32) @<<
87+
$(LINK32_FLAGS) $(LINK32_OBJS)
88+
<<
89+
90+
!ELSEIF "$(CFG)" == "libpgtcl - Win32 Debug"
91+
92+
OUTDIR=.\Debug
93+
INTDIR=.\Debug
94+
# Begin Custom Macros
95+
OutDir=.\Debug
96+
# End Custom Macros
97+
98+
ALL : "$(OUTDIR)\libpgtcl.dll" "$(OUTDIR)\libpgtcl.bsc"
99+
100+
101+
CLEAN :
102+
-@erase "$(INTDIR)\pgtcl.obj"
103+
-@erase "$(INTDIR)\pgtcl.sbr"
104+
-@erase "$(INTDIR)\pgtclCmds.obj"
105+
-@erase "$(INTDIR)\pgtclCmds.sbr"
106+
-@erase "$(INTDIR)\pgtclId.obj"
107+
-@erase "$(INTDIR)\pgtclId.sbr"
108+
-@erase "$(INTDIR)\vc60.idb"
109+
-@erase "$(INTDIR)\vc60.pdb"
110+
-@erase "$(OUTDIR)\libpgtcl.dll"
111+
-@erase "$(OUTDIR)\libpgtcl.exp"
112+
-@erase "$(OUTDIR)\libpgtcl.ilk"
113+
-@erase "$(OUTDIR)\libpgtcl.lib"
114+
-@erase "$(OUTDIR)\libpgtcl.pdb"
115+
-@erase "$(OUTDIR)\libpgtcl.bsc"
116+
117+
"$(OUTDIR)" :
118+
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
119+
120+
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od $(PGINCLUDE) /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\libpgtcl.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
121+
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
122+
BSC32=bscmake.exe
123+
BSC32_FLAGS=/nologo /o"$(OUTDIR)\libpgtcl.bsc"
124+
BSC32_SBRS= \
125+
"$(INTDIR)\pgtcl.sbr" \
126+
"$(INTDIR)\pgtclCmds.sbr" \
127+
"$(INTDIR)\pgtclId.sbr"
128+
129+
"$(OUTDIR)\libpgtcl.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
130+
$(BSC32) @<<
131+
$(BSC32_FLAGS) $(BSC32_SBRS)
132+
<<
133+
134+
LINK32=link.exe
135+
LINK32_FLAGS=tcl83.lib libpq.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\libpgtcl.pdb" /debug /machine:I386 /def:".\libpgtcl.def" /out:"$(OUTDIR)\libpgtcl.dll" /implib:"$(OUTDIR)\libpgtcl.lib" /pdbtype:sept /libpath:"$(TCLBASE)\lib" /libpath:"..\libpq\Debug"
136+
DEF_FILE= \
137+
".\libpgtcl.def"
138+
LINK32_OBJS= \
139+
"$(INTDIR)\pgtcl.obj" \
140+
"$(INTDIR)\pgtclCmds.obj" \
141+
"$(INTDIR)\pgtclId.obj"
142+
143+
"$(OUTDIR)\libpgtcl.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
144+
$(LINK32) @<<
145+
$(LINK32_FLAGS) $(LINK32_OBJS)
146+
<<
147+
148+
!ENDIF
149+
150+
.c{$(INTDIR)}.obj::
151+
$(CPP) @<<
152+
$(CPP_PROJ) $<
153+
<<
154+
155+
.cpp{$(INTDIR)}.obj::
156+
$(CPP) @<<
157+
$(CPP_PROJ) $<
158+
<<
159+
160+
.cxx{$(INTDIR)}.obj::
161+
$(CPP) @<<
162+
$(CPP_PROJ) $<
163+
<<
164+
165+
.c{$(INTDIR)}.sbr::
166+
$(CPP) @<<
167+
$(CPP_PROJ) $<
168+
<<
169+
170+
.cpp{$(INTDIR)}.sbr::
171+
$(CPP) @<<
172+
$(CPP_PROJ) $<
173+
<<
174+
175+
.cxx{$(INTDIR)}.sbr::
176+
$(CPP) @<<
177+
$(CPP_PROJ) $<
178+
<<
179+
180+
!IF "$(CFG)" == "libpgtcl - Win32 Release" || "$(CFG)" == "libpgtcl - Win32 Debug"
181+
SOURCE=pgtcl.c
182+
183+
"$(INTDIR)\pgtcl.obj" "$(INTDIR)\pgtcl.sbr" : $(SOURCE) "$(INTDIR)"
184+
$(CPP) $(CPP_PROJ) $(SOURCE)
185+
186+
187+
SOURCE=pgtclCmds.c
188+
189+
"$(INTDIR)\pgtclCmds.obj" "$(INTDIR)\pgtclCmds.sbr" : $(SOURCE) "$(INTDIR)"
190+
$(CPP) $(CPP_PROJ) $(SOURCE)
191+
192+
193+
SOURCE=pgtclId.c
194+
195+
"$(INTDIR)\pgtclId.obj" "$(INTDIR)\pgtclId.sbr" : $(SOURCE) "$(INTDIR)"
196+
$(CPP) $(CPP_PROJ) $(SOURCE)
197+
198+
199+
200+
!ENDIF
201+

0 commit comments

Comments
 (0)