You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by mx...@apache.org on 2011/03/24 23:17:12 UTC
svn commit: r1085163 - in /tcl/rivet/branches/rivet-namespace:
doc/xml/packages.xml rivet/rivet-tcl/parray.tcl src/Makefile.am
src/apache-2/mod_rivet.c src/apache-2/rivetCore.c src/parserPkgInit.c
src/rivet.h src/rivetList.c src/rivetPkgInit.c
Author: mxmanghi
Date: Thu Mar 24 22:17:11 2011
New Revision: 1085163
URL: http://svn.apache.org/viewvc?rev=1085163&view=rev
Log:
added support for stubs in rivetlib rivetparser libraries
Modified:
tcl/rivet/branches/rivet-namespace/doc/xml/packages.xml
tcl/rivet/branches/rivet-namespace/rivet/rivet-tcl/parray.tcl
tcl/rivet/branches/rivet-namespace/src/Makefile.am
tcl/rivet/branches/rivet-namespace/src/apache-2/mod_rivet.c (contents, props changed)
tcl/rivet/branches/rivet-namespace/src/apache-2/rivetCore.c
tcl/rivet/branches/rivet-namespace/src/parserPkgInit.c
tcl/rivet/branches/rivet-namespace/src/rivet.h
tcl/rivet/branches/rivet-namespace/src/rivetList.c
tcl/rivet/branches/rivet-namespace/src/rivetPkgInit.c
Modified: tcl/rivet/branches/rivet-namespace/doc/xml/packages.xml
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/doc/xml/packages.xml?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/doc/xml/packages.xml (original)
+++ tcl/rivet/branches/rivet-namespace/doc/xml/packages.xml Thu Mar 24 22:17:11 2011
@@ -36,5 +36,10 @@
<listitem>
<para>tclrivet</para>
</listitem>
+
+ <listitem>
+ <para>calendar - a package providing a simple configurable calendar generator</para>
+ </listitem>
+
</itemizedlist>
</section>
Modified: tcl/rivet/branches/rivet-namespace/rivet/rivet-tcl/parray.tcl
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/rivet/rivet-tcl/parray.tcl?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/rivet/rivet-tcl/parray.tcl (original)
+++ tcl/rivet/branches/rivet-namespace/rivet/rivet-tcl/parray.tcl Thu Mar 24 22:17:11 2011
@@ -33,4 +33,5 @@ namespace eval ::rivet {
puts stdout "</PRE>"
}
+ namespace export parray
}
Modified: tcl/rivet/branches/rivet-namespace/src/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/src/Makefile.am?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/src/Makefile.am (original)
+++ tcl/rivet/branches/rivet-namespace/src/Makefile.am Thu Mar 24 22:17:11 2011
@@ -51,16 +51,17 @@ lib_libexec_LTLIBRARIES = librivetlib.la
# Rivet Library
#
librivetlib_la_SOURCES = rivetList.c rivetCrypt.c rivetWWW.c rivetPkgInit.c
-librivetlib_la_LDFLAGS = @TCL_LIB_SPEC@ @APXS_LDFLAGS@ @APR_LDFLAGS@ -module -avoid-version
-librivetlib_la_LIBADD = @TCL_LIBS@ @APXS_LIBS@
-librivetlib_la_CPPFLAGS = @MOD_RIVET_INCLUDES@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_INCLUDES@ @APR_CPPFLAGS@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
+librivetlib_la_LDFLAGS = @TCL_STUB_LIB_SPEC@ @APXS_LDFLAGS@ @APR_LDFLAGS@ -module -avoid-version
+librivetlib_la_LIBADD = @APXS_LIBS@
+librivetlib_la_CPPFLAGS = @MOD_RIVET_INCLUDES@ @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_INCLUDES@ @APR_CPPFLAGS@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"' -DUSE_TCL_STUBS=1
#
# Rivet Parser Library
#
librivetparser_la_SOURCES = rivetParser.c parserPkgInit.c
-librivetparser_la_LDFLAGS = @TCL_LIB_SPEC@ @APXS_LDFLAGS@ -module -avoid-version
-librivetparser_la_LIBADD = @TCL_LIBS@ @APXS_LIBS@
-librivetparser_la_CPPFLAGS = @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
-
+librivetparser_la_LDFLAGS = @TCL_STUB_LIB_SPEC@ @APXS_LDFLAGS@ -module -avoid-version
+librivetparser_la_LIBADD = @APXS_LIBS@
+librivetparser_la_CPPFLAGS = @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"' -DUSE_TCL_STUBS=1
+
SUBDIRS = @apache_version_dir@
+
Modified: tcl/rivet/branches/rivet-namespace/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/src/apache-2/mod_rivet.c?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/branches/rivet-namespace/src/apache-2/mod_rivet.c Thu Mar 24 22:17:11 2011
@@ -15,7 +15,7 @@
limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
/* Rivet config */
#ifdef HAVE_CONFIG_H
@@ -28,6 +28,8 @@
/* as long as we need to emulate ap_chdir_file we need to include unistd.h */
#include <unistd.h>
+#include <dlfcn.h>
+
/* Apache includes */
#include <httpd.h>
#include <http_config.h>
@@ -946,29 +948,30 @@ Rivet_PerInterpInit(server_rec *s, rivet
exit(1);
}
- /* Loading into the module commands provided by librivet.so */
+ /* Loading into the interpreter the commands provided by librivet.so */
+
+ /* It would be nice to have to whole set of Rivet commands
+ * loaded into the interpreter at this stage. Unfortunately
+ * a problem with the dynamic loader of some OS prevents us
+ * from callingTcl_PkgRequire for 'rivetlib' because Apache segfaults
+ * shortly after the extension library is loaded.
+ * The problem was investigated on Linux and it became clear
+ * that it's linked to the way Tcl calls dlopen (Bug #3216070)
+ * The problem could be solved in Tcl8.6
+ */
-/*
- * It's been so far impossible to understand why the following call to Tcl_PkgRequire
- * causes a segfault later on in Rivet_ServerConf when Apache reconstructs the
- * configuration record (weird behavior of the framework, still it was confirmed by
- * the people at Apache).
- */
- /*
if (Tcl_PkgRequire(interp, RIVETLIB_TCL_PACKAGE, "1.2", 1) == NULL)
{
ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
"Error loading rivetlib package: %s", Tcl_GetStringResult(interp) );
exit(1);
}
- */
/* Set the output buffer size to the largest allowed value, so that we
* won't send any result packets to the browser unless the Rivet
* programmer does a "flush stdout" or the page is completed.
*/
-// Tcl_SetChannelOption(interp, *(rsc->outchannel), "-buffersize", "1000000");
Tcl_SetChannelBufferSize (*(rsc->outchannel), 1000000);
Tcl_RegisterChannel(interp, *(rsc->outchannel));
Tcl_Release(interp);
Propchange: tcl/rivet/branches/rivet-namespace/src/apache-2/mod_rivet.c
------------------------------------------------------------------------------
svn:keywords = Id
Modified: tcl/rivet/branches/rivet-namespace/src/apache-2/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/src/apache-2/rivetCore.c?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/src/apache-2/rivetCore.c (original)
+++ tcl/rivet/branches/rivet-namespace/src/apache-2/rivetCore.c Thu Mar 24 22:17:11 2011
@@ -1362,8 +1362,9 @@ Rivet_InitCore( Tcl_Interp *interp )
RIVET_OBJ_CMD ("load_env",Rivet_LoadEnv,rivet_ns);
RIVET_OBJ_CMD ("load_headers",Rivet_LoadHeaders,rivet_ns);
RIVET_OBJ_CMD ("var",Rivet_Var,rivet_ns);
- RIVET_OBJ_CMD ("abort_page",Rivet_AbortPageCmd ,rivet_ns);
- RIVET_OBJ_CMD ("virtual_filename",Rivet_VirtualFilenameCmd ,rivet_ns);
+ RIVET_OBJ_CMD ("abort_page",Rivet_AbortPageCmd,rivet_ns);
+ RIVET_OBJ_CMD ("abort_code", Rivet_AbortCodeCmd,rivet_ns);
+ RIVET_OBJ_CMD ("virtual_filename",Rivet_VirtualFilenameCmd,rivet_ns);
RIVET_OBJ_CMD ("apache_table",Rivet_ApacheTable,rivet_ns);
RIVET_OBJ_CMD ("var_qs",Rivet_Var,rivet_ns);
RIVET_OBJ_CMD ("var_post",Rivet_Var,rivet_ns);
@@ -1379,9 +1380,5 @@ Rivet_InitCore( Tcl_Interp *interp )
RIVET_OBJ_CMD ("testpanic",TestpanicCmd,rivet_ns);
#endif
- TCL_OBJ_CMD( "abort_page", Rivet_AbortPageCmd );
- TCL_OBJ_CMD( "abort_code", Rivet_AbortCodeCmd );
- TCL_OBJ_CMD( "virtual_filename", Rivet_VirtualFilenameCmd );
-
- return Tcl_PkgProvide( interp, RIVET_TCL_PACKAGE, "1.2" );
+ return Tcl_PkgProvide( interp,RIVET_TCL_PACKAGE,"1.2");
}
Modified: tcl/rivet/branches/rivet-namespace/src/parserPkgInit.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/src/parserPkgInit.c?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/src/parserPkgInit.c (original)
+++ tcl/rivet/branches/rivet-namespace/src/parserPkgInit.c Thu Mar 24 22:17:11 2011
@@ -116,6 +116,14 @@ Parse_RivetData(ClientData clientData, T
EXTERN int
Rivetparser_Init( Tcl_Interp *interp )
{
+#ifdef USE_TCL_STUBS
+ if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
+#else
+ if (Tcl_PkgRequire(interp, "Tcl", "8.5", 0) == NULL) {
+#endif
+ return TCL_ERROR;
+ }
+
Tcl_CreateObjCommand(interp,
"rivet::parserivet",
Parse_Rivet,
@@ -144,6 +152,15 @@ Rivetparser_SafeInit( Tcl_Interp *interp
* target string, which should by design prevent buffer overflow
* attacks, etc.
*/
+
+#ifdef USE_TCL_STUBS
+ if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
+#else
+ if (Tcl_PkgRequire(interp, "Tcl", "8.5", 0) == NULL) {
+#endif
+ return TCL_ERROR;
+ }
+
Tcl_CreateObjCommand(interp,
"rivet::parserivetdata",
Parse_RivetData,
Modified: tcl/rivet/branches/rivet-namespace/src/rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/src/rivet.h?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/src/rivet.h (original)
+++ tcl/rivet/branches/rivet-namespace/src/rivet.h Thu Mar 24 22:17:11 2011
@@ -23,9 +23,9 @@
#define STREQU(s1, s2) (s1[0] == s2[0] && strcmp(s1, s2) == 0)
#define STRNEQU(s1, s2) (s1[0] == s2[0] && strncmp(s1, s2, strlen(s2)) == 0)
-#define RIVET_NS "::rivet"
-#define RIVET_TCL_PACKAGE "rivet"
-#define RIVETLIB_TCL_PACKAGE "rivetlib"
+#define RIVET_NS "::rivet"
+#define RIVET_TCL_PACKAGE "rivet"
+#define RIVETLIB_TCL_PACKAGE "rivetlib"
#define TCL_CMD_HEADER(cmd) \
static int cmd(\
@@ -41,6 +41,12 @@ Tcl_CreateObjCommand( interp, /* Tcl int
NULL, /* Client Data */\
(Tcl_CmdDeleteProc *)NULL /* Tcl Delete Prov */)
+/* RIVET_OBJ_CMD creates a command in the RIVET_NS namespace and
+ * it also exports the command using the Tcl_Export function. This
+ * is suboptimal, rivet_ns must point to a Tcl_Namespace structure
+ * created somewhere before the macro is called.
+ */
+
#define RIVET_OBJ_CMD(name,func,ns) \
Tcl_CreateObjCommand( interp, /* Tcl interpreter */\
RIVET_NS "::" name, /* Function name in Tcl */\
Modified: tcl/rivet/branches/rivet-namespace/src/rivetList.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/src/rivetList.c?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/src/rivetList.c (original)
+++ tcl/rivet/branches/rivet-namespace/src/rivetList.c Thu Mar 24 22:17:11 2011
@@ -530,6 +530,8 @@ TCL_CMD_HEADER( Rivet_LassignArrayObjCmd
*
* Parameters:
* o interp - Interpreter to add commands to.
+ * o rivet_ns - Tcl_Namespace pointer to the RIVET_NS namespace.
+ *
*-----------------------------------------------------------------------------
*/
@@ -540,5 +542,6 @@ Rivet_InitList( Tcl_Interp *interp, Tcl_
RIVET_OBJ_CMD( "comma_split", Rivet_CommaSplitObjCmd ,rivet_ns);
RIVET_OBJ_CMD( "comma_join", Rivet_CommaJoinObjCmd ,rivet_ns);
RIVET_OBJ_CMD( "lassign_array", Rivet_LassignArrayObjCmd ,rivet_ns);
+
return TCL_OK;
}
Modified: tcl/rivet/branches/rivet-namespace/src/rivetPkgInit.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/rivet-namespace/src/rivetPkgInit.c?rev=1085163&r1=1085162&r2=1085163&view=diff
==============================================================================
--- tcl/rivet/branches/rivet-namespace/src/rivetPkgInit.c (original)
+++ tcl/rivet/branches/rivet-namespace/src/rivetPkgInit.c Thu Mar 24 22:17:11 2011
@@ -26,6 +26,28 @@
#include "rivet.h"
#include "mod_rivet.h"
+
+/*-----------------------------------------------------------------------------
+ * Rivet_GetNamespace --
+ *
+ * Get the rivet namespace pointer. The procedure attempts to retrieve a
+ * pointer to the Tcl_Namespace structure for the ::rivet namespace. This
+ * pointer is stored in the interpreter's associated data (pointing to a
+ * rivet_interp_globals structure) if the interpreter is passed by mod_rivet.
+ * Otherwise a new ::rivet namespace is created and its Tcl_Namespace
+ * pointer is returned
+ *
+ * Parameters:
+ *
+ * o interp - Interpreter to add commands to.
+ *
+ * Returned value:
+ *
+ * o rivet_ns - Tcl_Namespace* pointer to the RIVET_NS (::rivet) namespace
+ *
+ *-----------------------------------------------------------------------------
+ */
+
static Tcl_Namespace*
Rivet_GetNamespace( Tcl_Interp* interp)
{
@@ -35,7 +57,6 @@ Rivet_GetNamespace( Tcl_Interp* interp)
globals = Tcl_GetAssocData(interp, "rivet", NULL);
if (globals != NULL)
{
-// fprintf(stderr,"Associated data found, getting Rivet ns from mod_rivet\n");
rivet_ns = globals->rivet_ns;
}
else
@@ -62,7 +83,17 @@ Rivet_GetNamespace( Tcl_Interp* interp)
int
Rivetlib_Init( Tcl_Interp *interp )
{
- Tcl_Namespace *rivet_ns = Rivet_GetNamespace(interp);
+ Tcl_Namespace *rivet_ns = NULL;
+
+#ifdef USE_TCL_STUBS
+ if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
+#else
+ if (Tcl_PkgRequire(interp, "Tcl", "8.5", 0) == NULL) {
+#endif
+ return TCL_ERROR;
+ }
+
+ rivet_ns = Rivet_GetNamespace(interp);
Rivet_InitList ( interp, rivet_ns );
Rivet_InitCrypt( interp, rivet_ns );
@@ -86,7 +117,17 @@ Rivetlib_Init( Tcl_Interp *interp )
int
Rivetlib_SafeInit( Tcl_Interp *interp )
{
- Tcl_Namespace *rivet_ns = Rivet_GetNamespace(interp);
+ Tcl_Namespace *rivet_ns = NULL;
+
+#ifdef USE_TCL_STUBS
+ if (Tcl_InitStubs(interp, "8.5", 0) == NULL) {
+#else
+ if (Tcl_PkgRequire(interp, "Tcl", "8.5", 0) == NULL) {
+#endif
+ return TCL_ERROR;
+ }
+
+ rivet_ns = Rivet_GetNamespace(interp);
Rivet_InitList( interp, rivet_ns );
Rivet_InitCrypt( interp, rivet_ns );
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org