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 2012/05/04 10:23:08 UTC
svn commit: r1333806 [4/7] - in /tcl/rivet/branches/apreq-multipart: ./ doc/
doc/examples-sgml/ doc/examples/ doc/xml/ m4/ rivet/
rivet/packages/entities/ rivet/packages/form/ rivet/packages/simpledb/
rivet/packages/tclrivet/ rivet/rivet-tcl/ src/ src/...
Modified: tcl/rivet/branches/apreq-multipart/src/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/Makefile.am?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/Makefile.am (original)
+++ tcl/rivet/branches/apreq-multipart/src/Makefile.am Fri May 4 08:23:05 2012
@@ -26,7 +26,7 @@ INCLUDES = -I@apache_include@
# ... and these two. We want to put the libs in the package path,
# rather than the standard library location for the system.
lib_libexecdir = @RIVET_TCL_TARGET@
-lib_libexec_LTLIBRARIES = librivet.la librivetparser.la
+lib_libexec_LTLIBRARIES = librivetlib.la librivetparser.la
#
# Apache Rivet Module, mod_rivet.so / mod_rivet.dll
@@ -50,19 +50,19 @@ lib_libexec_LTLIBRARIES = librivet.la li
#
# Rivet Library
#
-librivet_la_SOURCES = rivetList.c rivetCrypt.c rivetWWW.c rivetPkgInit.c
-librivet_la_LDFLAGS = @TCL_LIB_SPEC@ @APXS_LDFLAGS@ @APR_LDFLAGS@ -module -avoid-version
-librivet_la_LIBADD = @TCL_LIBS@ @APXS_LIBS@
-librivet_la_CPPFLAGS = @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_INCLUDES@ @APR_CPPFLAGS@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
+librivetlib_la_SOURCES = rivetList.c rivetCrypt.c rivetWWW.c rivetPkgInit.c
+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
#
# 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
+
SUBDIRS = @apache_version_dir@
# Removing libtool .la files from installation
Modified: tcl/rivet/branches/apreq-multipart/src/apache-2/Makefile.am
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/apache-2/Makefile.am?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/apache-2/Makefile.am (original)
+++ tcl/rivet/branches/apreq-multipart/src/apache-2/Makefile.am Fri May 4 08:23:05 2012
@@ -31,20 +31,20 @@ INCLUDES = -I@apache_include@ -I@RIVET_B
#
# Apache Rivet Module, mod_rivet.so / mod_rivet.dll
#
-mod_rivet_la_SOURCES = \
- apache_multipart_buffer.c \
- apache_request.c \
- mod_rivet.c \
- TclWebapache.c \
- rivetCore.c \
- ../rivetChannel.c \
- ../rivetParser.c
+mod_rivet_la_SOURCES = \
+ apache_multipart_buffer.c \
+ apache_request.c \
+ mod_rivet.c \
+ TclWebapache.c \
+ rivetCore.c \
+ ../rivetChannel.c \
+ ../rivetParser.c
##mod_rivet_la_SOURCES = mod_rivet.c mod_rivet.h
mod_rivet_la_LDFLAGS = @TCL_LIB_SPEC@ @APXS_LDFLAGS@ @APR_LDFLAGS@ -module -avoid-version
mod_rivet_la_LIBADD = @TCL_LIBS@ @APXS_LIBS@
-mod_rivet_la_CPPFLAGS = @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_CPPFLAGS@ @APR_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
+mod_rivet_la_CPPFLAGS = @TCL_INCLUDES@ @APXS_CPPFLAGS@ @APXS_INCLUDES@ @APR_CPPFLAGS@ @APR_INCLUDES@ -DSTART_TAG='"<?"' -DEND_TAG='"?>"'
# APXS_CPPFLAGS_SHLIB
Modified: tcl/rivet/branches/apreq-multipart/src/apache-2/apache_request.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/apache-2/apache_request.c?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/apache-2/apache_request.c (original)
+++ tcl/rivet/branches/apreq-multipart/src/apache-2/apache_request.c Fri May 4 08:23:05 2012
@@ -46,11 +46,8 @@ util_read(ApacheRequest *req, const char
long length = r->remaining;
if (length > req->post_max && req->post_max > 0) {
- //TODO: fix logging apr_log_rerror
- //ap_log_error(REQ_ERROR, "[libapreq] entity too large (%d, max=%d)",
- // (int)length, req->post_max);
- //apr_log_rerror(REQ_ERROR, "[libapreq] entity too large (%d, max=%d)",
- // (int)length, req->post_max);
+ ap_log_rerror(REQ_ERROR,"entity too large (%d, max=%d)",
+ (int)length, req->post_max);
return HTTP_REQUEST_ENTITY_TOO_LARGE;
}
@@ -391,7 +388,6 @@ int ApacheRequest___parse(ApacheRequest
} else if (ct && strncaseEQ(ct, MULTIPART_ENCTYPE, MULTIPART_ENCTYPE_LENGTH)) {
result = ApacheRequest_parse_multipart(req,ct);
} else {
- //TODO: fix logging apr_log_rerror
ap_log_rerror(REQ_ERROR, "unknown content-type: `%s'", ct);
result = HTTP_INTERNAL_SERVER_ERROR;
}
@@ -493,14 +489,14 @@ apr_file_t *ApacheRequest_tmpfile(Apache
int
ApacheRequest_parse_multipart(ApacheRequest *req,const char* ct)
{
- request_rec *r = req->r;
- int rc = OK;
- long length;
- char *boundary;
- multipart_buffer *mbuff;
- ApacheUpload *upload = NULL;
- apr_status_t status;
- char error[1024];
+ request_rec *r = req->r;
+ int rc = OK;
+ long length;
+ char *boundary;
+ multipart_buffer *mbuff;
+ ApacheUpload *upload = NULL;
+ apr_status_t status;
+ char error[1024];
if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
return rc;
@@ -511,9 +507,8 @@ ApacheRequest_parse_multipart(ApacheRequ
}
if ((length = r->remaining) > req->post_max && req->post_max > 0) {
- //TODO: fix logging apr_log_rerror
- //apr_log_rerror(REQ_ERROR, "entity too large (%d, max=%d)",
- // (int)length, req->post_max);
+ ap_log_rerror(REQ_ERROR,"entity too large (%d, max=%d)",
+ (int)length,req->post_max);
return HTTP_REQUEST_ENTITY_TOO_LARGE;
}
@@ -542,7 +537,7 @@ ApacheRequest_parse_multipart(ApacheRequ
if (!header) {
#ifdef DEBUG
- apr_log_rerror(REQ_ERROR,"Silently dropping remaining '%ld' bytes", r->remaining);
+ ap_log_rerror(REQ_ERROR,"Silently dropping remaining '%ld' bytes", r->remaining);
#endif
do { } while ( ap_get_client_block(r, buff, sizeof(buff)) > 0 );
@@ -576,8 +571,9 @@ ApacheRequest_parse_multipart(ApacheRequ
if (!param) continue; /* shouldn't happen, but just in case. */
if (req->disable_uploads) {
- //TODO: fix logging apr_log_rerror
- //apr_log_rerror(REQ_ERROR, "[libapreq] file upload forbidden");
+#if DEBUG
+ ap_log_rerror(REQ_ERROR, "[libapreq] file upload forbidden");
+#endif
return HTTP_FORBIDDEN;
}
Modified: tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.c?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.c (original)
+++ tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.c Fri May 4 08:23:05 2012
@@ -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>
@@ -56,6 +58,8 @@
#include "rivetParser.h"
#include "rivetChannel.h"
+#define MODNAME "mod_rivet"
+
//module AP_MODULE_DECLARE_DATA rivet_module;
/* This is used *only* in the PanicProc. Otherwise, don't touch it! */
@@ -89,9 +93,9 @@ static void Rivet_CreateCache (server_re
static int Rivet_chdir_file (const char *file)
{
- const char *x;
- int chdir_retval = 0;
- char chdir_buf[HUGE_STRING_LEN];
+ const char *x;
+ int chdir_retval = 0;
+ char chdir_buf[HUGE_STRING_LEN];
x = strrchr(file, '/');
if (x == NULL) {
@@ -268,6 +272,17 @@ Rivet_InitServerVariables( Tcl_Interp *i
obj,
TCL_GLOBAL_ONLY);
Tcl_DecrRefCount(obj);
+
+#if RIVET_DISPLAY_VERSION
+ obj = Tcl_NewStringObj(RIVET_PACKAGE_VERSION, -1);
+ Tcl_IncrRefCount(obj);
+ Tcl_SetVar2Ex(interp,
+ "server",
+ "RIVET_PACKAGE_VERSION",
+ obj,
+ TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(obj);
+#endif
}
static void
@@ -368,9 +383,7 @@ Rivet_ExecuteAndCheck(Tcl_Interp *interp
}
}
- Tcl_SetVar( interp, "errorOutbuf",
- Tcl_GetStringFromObj( outbuf, NULL ),
- TCL_GLOBAL_ONLY );
+ Tcl_SetVar( interp, "errorOutbuf",Tcl_GetStringFromObj( outbuf, NULL ),TCL_GLOBAL_ONLY );
/* If we don't have an error script, use the default error handler. */
if (conf->rivet_error_script ) {
@@ -502,7 +515,6 @@ Rivet_ParseExecFile(TclWebRequest *req,
if (toplevel) {
if (rsc->rivet_before_script) {
Tcl_AppendObjToObj(outbuf,rsc->rivet_before_script);
-// Tcl_NewStringObj(rsc->rivet_before_script, -1));
}
}
@@ -529,7 +541,6 @@ Rivet_ParseExecFile(TclWebRequest *req,
}
if (toplevel) {
if (rsc->rivet_after_script) {
-// Tcl_AppendObjToObj(outbuf,Tcl_NewStringObj(rsc->rivet_after_script, -1));
Tcl_AppendObjToObj(outbuf,rsc->rivet_after_script);
}
}
@@ -586,8 +597,6 @@ Rivet_ParseExecFile(TclWebRequest *req,
static void
Rivet_CleanupRequest( request_rec *r )
{
-
-
#if 0
apr_table_t *t;
apr_array_header_t *arr;
@@ -886,16 +895,10 @@ Rivet_PerInterpInit(server_rec *s, rivet
Tcl_SetStdChannel(*(rsc->outchannel), TCL_STDOUT);
- /* Initialize the interpreter with Rivet's Tcl commands. */
- Rivet_InitCore( interp );
-
- /* Create a global array with information about the server. */
- Rivet_InitServerVariables( interp, p );
- Rivet_PropagateServerConfArray( interp, rsc );
-
/* Set up interpreter associated data */
+
globals = apr_pcalloc(p, sizeof(rivet_interp_globals));
- Tcl_SetAssocData(interp, "rivet", NULL, globals);
+ Tcl_SetAssocData(interp,"rivet",NULL,globals);
/*
* abort_page status variables in globals are set here and then
@@ -903,6 +906,9 @@ Rivet_PerInterpInit(server_rec *s, rivet
* completed
*/
+ /* Rivet commands namespace is created */
+ globals->rivet_ns = Tcl_CreateNamespace (interp,RIVET_NS,NULL,
+ (Tcl_NamespaceDeleteProc *)NULL);
globals->page_aborting = 0;
globals->abort_code = NULL;
@@ -916,26 +922,70 @@ Rivet_PerInterpInit(server_rec *s, rivet
rivet_tcl = Tcl_NewStringObj(RIVET_DIR,-1);
Tcl_IncrRefCount(rivet_tcl);
+
if (Tcl_ListObjReplace(interp,auto_path,0,0,1,&rivet_tcl) == TCL_ERROR)
{
- ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- "error setting auto_path: %s",Tcl_GetStringFromObj(auto_path,NULL));
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ MODNAME ": error setting auto_path: %s",
+ Tcl_GetStringFromObj(auto_path,NULL));
}
Tcl_DecrRefCount(rivet_tcl);
-
- if (Tcl_PkgRequire(interp, "RivetTcl", "1.1", 1) == NULL)
+
+ /* Initialize the interpreter with Rivet's Tcl commands. */
+ Rivet_InitCore(interp);
+
+ /* Create a global array with information about the server. */
+ Rivet_InitServerVariables(interp, p );
+ Rivet_PropagateServerConfArray( interp, rsc );
+
+ /* Eval Rivet's init.tcl file to load in the Tcl-level commands. */
+
+ /* Watch out! Calling Tcl_PkgRequire with a version number binds this module to
+ * the 'package provide' statement in rivet/init.tcl
+ */
+
+ /* If rivet was configured to export the ::rivet namespace commands we have to
+ * set the array variable ::rivet::module_conf(export_namespace_commands) before calling init.tcl
+ * This array will be unset after commands are exported.
+ */
+
+ Tcl_SetVar2Ex(interp,"module_conf","export_namespace_commands",Tcl_NewIntObj(RIVET_NAMESPACE_EXPORT),0);
+ Tcl_SetVar2Ex(interp,"module_conf","import_rivet_commands",Tcl_NewIntObj(RIVET_NAMESPACE_IMPORT),0);
+
+ if (Tcl_PkgRequire(interp, "RivetTcl", "2.1", 1) == NULL)
{
- ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- "init.tcl must be installed correctly for Apache Rivet to function: %s",
- Tcl_GetStringResult(interp) );
+ ap_log_error (APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ MODNAME ": init.tcl must be installed correctly for Apache Rivet to function: %s (%s)",
+ Tcl_GetStringResult(interp), RIVET_DIR );
+ exit(1);
+ }
+
+ /* 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
+ */
+
+ if (Tcl_PkgRequire(interp, RIVETLIB_TCL_PACKAGE, "1.2", 1) == NULL)
+ {
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ MODNAME ": 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);
@@ -1001,8 +1051,7 @@ Rivet_AssignStringToConf (Tcl_Obj** objP
static const char *
-Rivet_SetScript (apr_pool_t *pool, rivet_server_conf *rsc,
- const char *script, const char *string)
+Rivet_SetScript (apr_pool_t *pool, rivet_server_conf *rsc, const char *script, const char *string)
{
Tcl_Obj *objarg = NULL;
@@ -1035,6 +1084,7 @@ Rivet_SetScript (apr_pool_t *pool, rivet
* Implements the RivetServerConf Apache Directive
*
* Command Arguments:
+ *
* RivetServerConf GlobalInitScript <script>
* RivetServerConf ChildInitScript <script>
* RivetServerConf ChildExitScript <script>
@@ -1180,13 +1230,15 @@ Rivet_InitHandler(apr_pool_t *pPool, apr
if (Tcl_EvalObjEx(interp, rsc->rivet_server_init_script, 0) != TCL_OK)
{
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, "%s",
- Tcl_GetVar(interp, "errorInfo", 0));
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ MODNAME ": Error running ServerInitScript '%s': %s",
+ Tcl_GetString(rsc->rivet_server_init_script),
+ Tcl_GetVar(interp, "errorInfo", 0));
} else {
- ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_EGENERAL, s,
- "RivetServerInit has run");
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+ MODNAME ": ServerInitScript '%s' successful",
+ Tcl_GetString(rsc->rivet_server_init_script));
}
-
}
return OK;
@@ -1338,14 +1390,14 @@ Rivet_Panic TCL_VARARGS_DEF(CONST char *
buf = (char *) apr_pvsprintf(rivet_panic_pool, format, argList);
if (rivet_panic_request_rec != NULL) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL,
- rivet_panic_server_rec,
- "Critical error in request: %s",
- rivet_panic_request_rec->unparsed_uri);
+ ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL,
+ rivet_panic_server_rec,
+ MODNAME ": Critical error in request: %s",
+ rivet_panic_request_rec->unparsed_uri);
}
ap_log_error(APLOG_MARK, APLOG_CRIT, APR_EGENERAL,
- rivet_panic_server_rec, buf);
+ rivet_panic_server_rec, "%s", buf);
abort();
}
@@ -1380,11 +1432,11 @@ Rivet_ChildHandlers(server_rec *s, int i
top = RIVET_SERVER_CONF(s->module_config);
if (init == 1) {
parentfunction = top->rivet_child_init_script;
- errmsg = "Error in Child init script: %s";
+ errmsg = MODNAME ": Error in Child init script: %s";
//errmsg = (char *) apr_pstrdup(p, "Error in child init script: %s");
} else {
parentfunction = top->rivet_child_exit_script;
- errmsg = "Error in Child exit script: %s";
+ errmsg = MODNAME ": Error in Child exit script: %s";
//errmsg = (char *) apr_pstrdup(p, "Error in child exit script: %s");
}
@@ -1408,12 +1460,13 @@ Rivet_ChildHandlers(server_rec *s, int i
Tcl_Preserve (rsc->server_interp);
if (Tcl_EvalObjEx(rsc->server_interp,function, 0) != TCL_OK) {
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- errmsg, Tcl_GetString(function));
+ errmsg,
+ Tcl_GetString(function));
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- "errorCode: %s",
+ "errorCode: %s",
Tcl_GetVar(rsc->server_interp, "errorCode", 0));
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- "errorInfo: %s",
+ "errorInfo: %s",
Tcl_GetVar(rsc->server_interp, "errorInfo", 0));
}
Tcl_Release (rsc->server_interp);
@@ -1485,14 +1538,15 @@ Rivet_CreateTclInterp (server_rec* s)
if (interp == NULL)
{
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- "Error in Tcl_CreateInterp, aborting\n");
+ MODNAME ": Error in Tcl_CreateInterp, aborting\n");
exit(1);
}
if (Tcl_Init(interp) == TCL_ERROR)
{
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- Tcl_GetStringResult(interp));
+ MODNAME ": Error in Tcl_Init: %s, aborting\n",
+ Tcl_GetStringResult(interp));
exit(1);
}
Tcl_SetPanicProc(Rivet_Panic);
@@ -1550,7 +1604,6 @@ Rivet_CreateCache (server_rec *s, apr_po
}
}
-
/*
*-----------------------------------------------------------------------------
*
@@ -1581,8 +1634,14 @@ Rivet_InitTclStuff(server_rec *s, apr_po
if (rsc->rivet_global_init_script != NULL) {
if (Tcl_EvalObjEx(interp, rsc->rivet_global_init_script, 0) != TCL_OK)
{
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s, "%s",
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ MODNAME ": Error running GlobalInitScript '%s': %s",
+ Tcl_GetString(rsc->rivet_global_init_script),
Tcl_GetVar(interp, "errorInfo", 0));
+ } else {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+ MODNAME ": GlobalInitScript '%s' successful",
+ Tcl_GetString(rsc->rivet_global_init_script));
}
}
@@ -1610,12 +1669,17 @@ Rivet_InitTclStuff(server_rec *s, apr_po
sr->port,
interpCount++);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
+ MODNAME ": Rivet_InitTclStuff: creating slave interpreter '%s', hostname '%s', port '%d', separate interpreters %d",
+ slavename, sr->server_hostname, sr->port,
+ rsc->separate_virtual_interps);
+
/* Separate virtual interps. */
myrsc->server_interp = Tcl_CreateSlave(interp, slavename, 0);
if (myrsc->server_interp == NULL) {
- ap_log_error( APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
- "slave interp create failed: %s",
- Tcl_GetStringResult(interp) );
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, s,
+ MODNAME ": slave interp create failed: %s",
+ Tcl_GetStringResult(interp) );
exit(1);
}
Rivet_PerInterpInit(s, myrsc, p);
@@ -1651,6 +1715,7 @@ Rivet_InitTclStuff(server_rec *s, apr_po
*-----------------------------------------------------------------------------
*/
+
static void
Rivet_ChildInit(apr_pool_t *pChild, server_rec *s)
{
@@ -1663,6 +1728,11 @@ Rivet_ChildInit(apr_pool_t *pChild, serv
apr_pool_cleanup_register (pChild, s, Rivet_ChildExit, Rivet_ChildExit);
}
+
+//TODO: clarify whether rsc or rdc
+
+#define USE_APACHE_RSC
+
/* Set things up to execute a file, then execute */
static int
Rivet_SendContent(request_rec *r)
@@ -1676,8 +1746,11 @@ Rivet_SendContent(request_rec *r)
static Tcl_Obj *request_cleanup = NULL;
rivet_interp_globals *globals = NULL;
+#ifdef USE_APACHE_RSC
rivet_server_conf *rsc = NULL;
+#else
rivet_server_conf *rdc;
+#endif
ctype = Rivet_CheckType(r);
if (ctype == CTYPE_NOT_HANDLED) {
@@ -1700,10 +1773,12 @@ Rivet_SendContent(request_rec *r)
globals->req->charset = NULL;
+#ifndef USE_APACHE_RSC
if (r->per_dir_config != NULL)
rdc = RIVET_SERVER_CONF( r->per_dir_config );
else
rdc = rsc;
+#endif
r->allowed |= (1 << M_GET);
r->allowed |= (1 << M_POST);
@@ -1714,9 +1789,10 @@ Rivet_SendContent(request_rec *r)
if (r->finfo.filetype == 0)
{
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, r->server,
- "File does not exist: %s",
- (r->path_info ? (char*)apr_pstrcat(r->pool, r->filename, r->path_info, NULL) : r->filename));
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL,
+ r->server,
+ MODNAME ": File does not exist: %s",
+ (r->path_info ? (char*)apr_pstrcat(r->pool, r->filename, r->path_info, NULL) : r->filename));
retval = HTTP_NOT_FOUND;
goto sendcleanup;
}
@@ -1740,15 +1816,18 @@ Rivet_SendContent(request_rec *r)
* at this. We simply emit an internal server error and print a log message
*/
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_EGENERAL, r->server,
- "Error accessing %s, could not chdir into directory", r->filename);
+ MODNAME ": Error accessing %s, could not chdir into directory",
+ r->filename);
retval = HTTP_INTERNAL_SERVER_ERROR;
goto sendcleanup;
}
- //TODO: clarify whether rsc or rdc
- //Rivet_PropagatePerDirConfArrays( interp, rdc );
+#ifdef USE_APACHE_RSC
Rivet_PropagatePerDirConfArrays( interp, rsc );
+#else
+ Rivet_PropagatePerDirConfArrays( interp, rdc );
+#endif
/* Initialize this the first time through and keep it around. */
if (request_init == NULL) {
@@ -1759,7 +1838,7 @@ Rivet_SendContent(request_rec *r)
if (Tcl_EvalObjEx(interp, request_init, 0) == TCL_ERROR)
{
ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server,
- "Could not create request namespace\n");
+ MODNAME ": Could not create request namespace\n");
retval = HTTP_BAD_REQUEST;
goto sendcleanup;
}
@@ -1849,8 +1928,10 @@ Rivet_SendContent(request_rec *r)
if (Rivet_ParseExecFile(globals->req, r->filename, 1) != TCL_OK)
{
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, "%s",
- Tcl_GetVar(interp, "errorInfo", 0));
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server,
+ MODNAME ": Error parsing exec file '%s': %s",
+ r->filename,
+ Tcl_GetVar(interp, "errorInfo", 0));
}
if (request_cleanup == NULL) {
@@ -1859,8 +1940,9 @@ Rivet_SendContent(request_rec *r)
}
if (Tcl_EvalObjEx(interp, request_cleanup, 0) == TCL_ERROR) {
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server, "%s",
- Tcl_GetVar(interp, "errorInfo", 0));
+ ap_log_error(APLOG_MARK, APLOG_ERR, APR_EGENERAL, r->server,
+ MODNAME ": Error evaluating cleanup request: %s",
+ Tcl_GetVar(interp, "errorInfo", 0));
}
/* Reset globals */
Modified: tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.h?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.h (original)
+++ tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.h Fri May 4 08:23:05 2012
@@ -1,3 +1,21 @@
+/* mod_rivet.h -- The apache module itself, for Apache 2.x. */
+
+/* Copyright 2000-2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/* $Id$ */
#ifndef MOD_RIVET_H
#define MOD_RIVET_H 1
@@ -56,11 +74,11 @@ typedef struct _rivet_server_conf {
Tcl_Obj *rivet_global_init_script; /* run once when apache is started */
Tcl_Obj *rivet_child_init_script;
Tcl_Obj *rivet_child_exit_script;
- Tcl_Obj *rivet_before_script; /* script run before each page */
- Tcl_Obj *rivet_after_script; /* after */
- Tcl_Obj *rivet_error_script; /* for errors */
- Tcl_Obj *rivet_abort_script; /* script run upon abort_page call */
- Tcl_Obj *after_every_script; /* script to be run always */
+ Tcl_Obj *rivet_before_script; /* script run before each page */
+ Tcl_Obj *rivet_after_script; /* after */
+ Tcl_Obj *rivet_error_script; /* for errors */
+ Tcl_Obj *rivet_abort_script; /* script run upon abort_page call */
+ Tcl_Obj *after_every_script; /* script to be run always */
/* This flag is used with the above directives.
If any of them have changed, it gets set. */
@@ -73,26 +91,26 @@ typedef struct _rivet_server_conf {
int upload_max;
int upload_files_to_var;
int separate_virtual_interps;
- int honor_header_only_reqs; /* default: 0 */
+ int honor_header_only_reqs;
char *server_name;
const char *upload_dir;
apr_table_t *rivet_server_vars;
apr_table_t *rivet_dir_vars;
apr_table_t *rivet_user_vars;
- char **objCacheList; /* Array of cached objects (for priority handling) */
- Tcl_HashTable *objCache; /* Objects cache - the key is the script name */
+ char **objCacheList; /* Array of cached objects (for priority handling) */
+ Tcl_HashTable *objCache; /* Objects cache - the key is the script name */
- Tcl_Channel *outchannel; /* stuff for buffering output */
+ Tcl_Channel *outchannel; /* stuff for buffering output */
} rivet_server_conf;
-/* eventually we will transfer 'global' variables in here and
- 'de-globalize' them */
+/* eventually we will transfer 'global' variables in here and 'de-globalize' them */
typedef struct _rivet_interp_globals {
- request_rec* r; /* request rec */
- TclWebRequest* req; /* TclWeb API request */
+ request_rec *r; /* request rec */
+ TclWebRequest *req; /* TclWeb API request */
+ Tcl_Namespace *rivet_ns; /* Rivet commands namespace */
int page_aborting; /* set by abort_page. */
- /* to be reset by Rivet_SendContent */
+ /* to be reset by Rivet_SendContent */
Tcl_Obj* abort_code;
} rivet_interp_globals;
@@ -113,6 +131,5 @@ rivet_server_conf *Rivet_GetConf(request
#define RIVET_NEW_CONF(p) \
(rivet_server_conf *)apr_pcalloc(p, sizeof(rivet_server_conf))
-
#endif /* MOD_RIVET_H */
Propchange: tcl/rivet/branches/apreq-multipart/src/apache-2/mod_rivet.h
------------------------------------------------------------------------------
svn:keywords = Id
Modified: tcl/rivet/branches/apreq-multipart/src/apache-2/rivetCore.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/apache-2/rivetCore.c?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/apache-2/rivetCore.c (original)
+++ tcl/rivet/branches/apreq-multipart/src/apache-2/rivetCore.c Fri May 4 08:23:05 2012
@@ -8,7 +8,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -34,10 +34,8 @@
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
-//#include "http_conf_globals.h"
#include "http_config.h"
-
#include <tcl.h>
#include <string.h>
#include <stdio.h>
@@ -63,13 +61,13 @@ extern char* TclWeb_GetRawPost (TclWebRe
*
* Rivet_MakeURL --
*
- * Make a self-referencing URL.
+ * Make a self-referencing URL.
*
* Results:
- * Standard Tcl result.
+ * Standard Tcl result.
*
* Side Effects:
- * None.
+ * None.
*
*-----------------------------------------------------------------------------
*/
@@ -105,13 +103,13 @@ TCL_CMD_HEADER( Rivet_MakeURL )
char* script_name = TclWeb_GetEnvVar (globals->req,"SCRIPT_NAME");
int script_name_l = strlen(script_name);
- // regardless the reason for SCRIPT_NAME being undefined we
+ // regardless the reason for a SCRIPT_NAME being undefined we
// prevent a segfault and we revert the behavior of makeurl
// to the case of an absolute path
if (script_name_l > 0)
{
- // script name may have the form of a directory path (and mod_rewrite
+ // script name may have the form a directory path (and mod_rewrite
// could have mapped it to a .tcl or .rvt script)
if (script_name[script_name_l-1] == '/')
@@ -142,20 +140,20 @@ TCL_CMD_HEADER( Rivet_MakeURL )
*
* Rivet_Parse --
*
- * Include and parse a Rivet file.
+ * Include and parse a Rivet file.
*
* Results:
- * Standard Tcl result.
+ * Standard Tcl result.
*
* Side Effects:
- * Whatever occurs in the Rivet page parsed.
+ * Whatever occurs in the Rivet page parsed.
*
*-----------------------------------------------------------------------------
*/
TCL_CMD_HEADER( Rivet_Parse )
{
- char *filename;
+ char *filename;
apr_status_t stat_s;
apr_finfo_t finfo_b;
@@ -186,7 +184,7 @@ TCL_CMD_HEADER( Rivet_Parse )
stat_s = apr_stat(&finfo_b,filename,APR_FINFO_NORM,globals->r->pool);
if (stat_s != APR_SUCCESS)
{
- char apr_error_message[256];
+ char apr_error_message[256];
Tcl_AddErrorInfo(interp,apr_strerror(stat_s,apr_error_message,256));
return TCL_ERROR;
@@ -204,14 +202,14 @@ TCL_CMD_HEADER( Rivet_Parse )
*
* Rivet_Include --
*
- * Includes a file literally in the output stream. Useful for
- * images, plain HTML and the like.
+ * Includes a file literally in the output stream. Useful for
+ * images, plain HTML and the like.
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * Adds to the output stream.
+ * Adds to the output stream.
*
*-----------------------------------------------------------------------------
*/
@@ -230,19 +228,19 @@ TCL_CMD_HEADER( Rivet_Include )
if( objc < 2 || objc > 3 )
{
- Tcl_WrongNumArgs(interp, 1, objv, "?-virtual? filename");
- return TCL_ERROR;
+ Tcl_WrongNumArgs(interp, 1, objv, "?-virtual? filename");
+ return TCL_ERROR;
}
if( objc == 2 ) {
- filename = Tcl_GetStringFromObj( objv[1], (int *)NULL );
+ filename = Tcl_GetStringFromObj( objv[1], (int *)NULL );
} else {
- if( !STREQU( Tcl_GetStringFromObj(objv[1], (int *)NULL), "-virtual") ) {
- Tcl_WrongNumArgs( interp, 1, objv, "?-virtual? filename" );
- return TCL_ERROR;
- }
- filename = TclWeb_GetVirtualFile( globals->req,
- Tcl_GetStringFromObj(objv[2], (int *)NULL) );
+ if( !STREQU( Tcl_GetStringFromObj(objv[1], (int *)NULL), "-virtual") ) {
+ Tcl_WrongNumArgs( interp, 1, objv, "?-virtual? filename" );
+ return TCL_ERROR;
+ }
+ filename = TclWeb_GetVirtualFile( globals->req,
+ Tcl_GetStringFromObj(objv[2], (int *)NULL) );
}
fd = Tcl_OpenFileChannel(interp, filename, "r", 0664);
@@ -258,9 +256,9 @@ TCL_CMD_HEADER( Rivet_Include )
sz = Tcl_ReadChars(fd, outobj, -1, 0);
if (sz == -1)
{
- Tcl_AddErrorInfo(interp, Tcl_PosixError(interp));
- Tcl_DecrRefCount(outobj);
- return TCL_ERROR;
+ Tcl_AddErrorInfo(interp, Tcl_PosixError(interp));
+ Tcl_DecrRefCount(outobj);
+ return TCL_ERROR;
}
/* What we are doing is saving the translation and encoding
@@ -286,13 +284,13 @@ TCL_CMD_HEADER( Rivet_Include )
*
* Rivet_Headers --
*
- * Command to manipulate HTTP headers from Tcl.
+ * Command to manipulate HTTP headers from Tcl.
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * None.
+ * None.
*
*-----------------------------------------------------------------------------
*/
@@ -304,72 +302,72 @@ TCL_CMD_HEADER( Rivet_Headers )
if (objc < 2)
{
- Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
- return TCL_ERROR;
+ Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?");
+ return TCL_ERROR;
}
if (globals->req->headers_printed != 0)
{
- Tcl_AddObjErrorInfo(interp,
- "Cannot manipulate headers - already sent", -1);
- return TCL_ERROR;
+ Tcl_AddObjErrorInfo(interp,
+ "Cannot manipulate headers - already sent", -1);
+ return TCL_ERROR;
}
opt = Tcl_GetStringFromObj(objv[1], NULL);
if (!strcmp("redirect", opt)) /* ### redirect ### */
{
- if (objc != 3)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "new-url");
- return TCL_ERROR;
- }
- apr_table_set(globals->r->headers_out, "Location",
- Tcl_GetStringFromObj (objv[2], (int *)NULL));
- TclWeb_SetStatus(301, globals->req);
- return TCL_RETURN;
+ if (objc != 3)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "new-url");
+ return TCL_ERROR;
+ }
+ apr_table_set(globals->r->headers_out, "Location",
+ Tcl_GetStringFromObj (objv[2], (int *)NULL));
+ TclWeb_SetStatus(301, globals->req);
+ return TCL_RETURN;
}
else if (!strcmp("set", opt)) /* ### set ### */
{
- if (objc != 4)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "headername value");
- return TCL_ERROR;
- }
- TclWeb_HeaderSet(Tcl_GetString(objv[2]), Tcl_GetString(objv[3]), globals->req);
+ if (objc != 4)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "headername value");
+ return TCL_ERROR;
+ }
+ TclWeb_HeaderSet(Tcl_GetString(objv[2]), Tcl_GetString(objv[3]), globals->req);
}
else if (!strcmp("add", opt)) /* ### set ### */
{
- if (objc != 4)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "headername value");
- return TCL_ERROR;
- }
- TclWeb_HeaderAdd(Tcl_GetString(objv[2]), Tcl_GetString(objv[3]), globals->req);
+ if (objc != 4)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "headername value");
+ return TCL_ERROR;
+ }
+ TclWeb_HeaderAdd(Tcl_GetString(objv[2]), Tcl_GetString(objv[3]), globals->req);
}
else if (!strcmp("type", opt)) /* ### set ### */
{
- if (objc != 3)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "mime/type");
- return TCL_ERROR;
- }
- TclWeb_SetHeaderType(Tcl_GetString(objv[2]), globals->req);
+ if (objc != 3)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "mime/type");
+ return TCL_ERROR;
+ }
+ TclWeb_SetHeaderType(Tcl_GetString(objv[2]), globals->req);
} else if (!strcmp("numeric", opt)) /* ### numeric ### */
{
- int st = 200;
+ int st = 200;
- if (objc != 3)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "response_code_number");
- return TCL_ERROR;
- }
- if (Tcl_GetIntFromObj(interp, objv[2], &st) != TCL_ERROR) {
- TclWeb_SetStatus(st, globals->req);
+ if (objc != 3)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "response_code_number");
+ return TCL_ERROR;
+ }
+ if (Tcl_GetIntFromObj(interp, objv[2], &st) != TCL_ERROR) {
+ TclWeb_SetStatus(st, globals->req);
+ } else {
+ return TCL_ERROR;
+ }
} else {
return TCL_ERROR;
}
- } else {
- return TCL_ERROR;
- }
return TCL_OK;
}
@@ -378,16 +376,16 @@ TCL_CMD_HEADER( Rivet_Headers )
*
* Rivet_LoadEnv --
*
- * Load the "environmental variables" - those variables that are
- * set in the environment in a standard CGI program. If no array
- * name is supplied, they are loaded into an array whose name is
- * the value of the ENV_ARRAY_NAME #define.
+ * Load the "environmental variables" - those variables that are
+ * set in the environment in a standard CGI program. If no array
+ * name is supplied, they are loaded into an array whose name is
+ * the value of the ENV_ARRAY_NAME #define.
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * None.
+ * None.
*
*-----------------------------------------------------------------------------
*/
@@ -398,14 +396,14 @@ TCL_CMD_HEADER( Rivet_LoadEnv )
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
if( objc > 2 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "?arrayName?" );
- return TCL_ERROR;
+ Tcl_WrongNumArgs( interp, 1, objv, "?arrayName?" );
+ return TCL_ERROR;
}
if( objc == 2 ) {
- ArrayObj = objv[1];
+ ArrayObj = objv[1];
} else {
- ArrayObj = Tcl_NewStringObj( ENV_ARRAY_NAME, -1 );
+ ArrayObj = Tcl_NewStringObj( ENV_ARRAY_NAME, -1 );
}
return TclWeb_GetEnvVars(ArrayObj, globals->req);
@@ -416,15 +414,15 @@ TCL_CMD_HEADER( Rivet_LoadEnv )
*
* Rivet_LoadHeaders --
*
- * Load the HTTP headers supplied by the client into a Tcl array,
- * whose name defaults to the value of the HEADERS_ARRAY_NAME
- * #define.
+ * Load the HTTP headers supplied by the client into a Tcl array,
+ * whose name defaults to the value of the HEADERS_ARRAY_NAME
+ * #define.
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * Creates an array variable if none exists.
+ * Creates an array variable if none exists.
*
*-----------------------------------------------------------------------------
*/
@@ -435,14 +433,14 @@ TCL_CMD_HEADER ( Rivet_LoadHeaders )
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
if( objc > 2 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "?arrayName?" );
- return TCL_ERROR;
+ Tcl_WrongNumArgs( interp, 1, objv, "?arrayName?" );
+ return TCL_ERROR;
}
if( objc == 2 ) {
- ArrayObj = objv[1];
+ ArrayObj = objv[1];
} else {
- ArrayObj = Tcl_NewStringObj( HEADERS_ARRAY_NAME, -1 );
+ ArrayObj = Tcl_NewStringObj( HEADERS_ARRAY_NAME, -1 );
}
return TclWeb_GetHeaderVars(ArrayObj, globals->req);
@@ -458,19 +456,19 @@ TCL_CMD_HEADER ( Rivet_LoadHeaders )
*
* Rivet_Var --
*
- * Returns information about GET or POST variables:
+ * Returns information about GET or POST variables:
*
- * var get foo ?default?
- * var list foo
- * var names
- * var number
- * var all
+ * var get foo ?default?
+ * var list foo
+ * var names
+ * var number
+ * var all
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * None.
+ * None.
*
*-----------------------------------------------------------------------------
*/
@@ -485,10 +483,10 @@ TCL_CMD_HEADER ( Rivet_Var )
if (objc < 2 || objc > 4)
{
- Tcl_WrongNumArgs(interp, 1, objv,
- "(get varname ?default?|list varname|exists varname|names"
- "|number|all)");
- return TCL_ERROR;
+ Tcl_WrongNumArgs(interp, 1, objv,
+ "(get varname ?default?|list varname|exists varname|names"
+ "|number|all)");
+ return TCL_ERROR;
}
cmd = Tcl_GetString(objv[0]);
command = Tcl_GetString(objv[1]);
@@ -501,84 +499,84 @@ TCL_CMD_HEADER ( Rivet_Var )
if (!strcmp(command, "get"))
{
- char *key = NULL;
- char *deflt = NULL;
- if (objc != 3 && objc != 4)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "variablename ?defaultval?");
- return TCL_ERROR;
- }
- key = Tcl_GetStringFromObj(objv[2], NULL);
- if (objc == 4)
- {
- deflt = Tcl_GetString(objv[3]);
- }
+ char *key = NULL;
+ char *deflt = NULL;
+ if (objc != 3 && objc != 4)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "variablename ?defaultval?");
+ return TCL_ERROR;
+ }
+ key = Tcl_GetStringFromObj(objv[2], NULL);
+ if (objc == 4)
+ {
+ deflt = Tcl_GetString(objv[3]);
+ }
- if (TclWeb_GetVar(result, key, source, globals->req) != TCL_OK)
- {
- if (deflt == NULL) {
- Tcl_SetStringObj(result, "", -1);
- } else {
- Tcl_SetStringObj(result, deflt, -1);
+ if (TclWeb_GetVar(result, key, source, globals->req) != TCL_OK)
+ {
+ if (deflt == NULL) {
+ Tcl_SetStringObj(result, "", -1);
+ } else {
+ Tcl_SetStringObj(result, deflt, -1);
+ }
}
- }
} else if(!strcmp(command, "exists")) {
- char *key;
- if (objc != 3)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "variablename");
- return TCL_ERROR;
- }
- key = Tcl_GetString(objv[2]);
+ char *key;
+ if (objc != 3)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "variablename");
+ return TCL_ERROR;
+ }
+ key = Tcl_GetString(objv[2]);
- TclWeb_VarExists(result, key, source, globals->req);
+ TclWeb_VarExists(result, key, source, globals->req);
} else if(!strcmp(command, "list")) {
- char *key;
- if (objc != 3)
- {
- Tcl_WrongNumArgs(interp, 2, objv, "variablename");
- return TCL_ERROR;
- }
- key = Tcl_GetStringFromObj(objv[2], NULL);
+ char *key;
+ if (objc != 3)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, "variablename");
+ return TCL_ERROR;
+ }
+ key = Tcl_GetStringFromObj(objv[2], NULL);
- if (TclWeb_GetVarAsList(result, key, source, globals->req) != TCL_OK)
- {
- result = Tcl_NewStringObj("", -1);
- }
+ if (TclWeb_GetVarAsList(result, key, source, globals->req) != TCL_OK)
+ {
+ result = Tcl_NewStringObj("", -1);
+ }
} else if(!strcmp(command, "names")) {
- if (objc != 2)
- {
- Tcl_WrongNumArgs(interp, 2, objv, NULL);
- return TCL_ERROR;
- }
+ if (objc != 2)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, NULL);
+ return TCL_ERROR;
+ }
- if (TclWeb_GetVarNames(result, source, globals->req) != TCL_OK)
- {
- result = Tcl_NewStringObj("", -1);
- }
+ if (TclWeb_GetVarNames(result, source, globals->req) != TCL_OK)
+ {
+ result = Tcl_NewStringObj("", -1);
+ }
} else if(!strcmp(command, "number")) {
- if (objc != 2)
- {
- Tcl_WrongNumArgs(interp, 2, objv, NULL);
- return TCL_ERROR;
- }
+ if (objc != 2)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, NULL);
+ return TCL_ERROR;
+ }
- TclWeb_VarNumber(result, source, globals->req);
+ TclWeb_VarNumber(result, source, globals->req);
} else if(!strcmp(command, "all")) {
- if (objc != 2)
- {
- Tcl_WrongNumArgs(interp, 2, objv, NULL);
- return TCL_ERROR;
- }
- if (TclWeb_GetAllVars(result, source, globals->req) != TCL_OK)
- {
- result = Tcl_NewStringObj("", -1);
- }
+ if (objc != 2)
+ {
+ Tcl_WrongNumArgs(interp, 2, objv, NULL);
+ return TCL_ERROR;
+ }
+ if (TclWeb_GetAllVars(result, source, globals->req) != TCL_OK)
+ {
+ result = Tcl_NewStringObj("", -1);
+ }
} else {
- /* bad command */
- Tcl_AppendResult(interp, "bad option: must be one of ",
- "'get, list, names, number, all'", NULL);
- return TCL_ERROR;
+ /* bad command */
+ Tcl_AppendResult(interp, "bad option: must be one of ",
+ "'get, list, names, number, all'", NULL);
+ return TCL_ERROR;
}
Tcl_SetObjResult(interp, result);
@@ -611,9 +609,9 @@ append_key_value_callback (void *data, c
*
* Rivet_ApacheTable --
*
- * Deals with Rivet key-value tables in the request structure
+ * Deals with Rivet key-value tables in the request structure
*
- * apache_table get tablename key
+ * apache_table get tablename key
* apache_table set tablename key value
* apache_table set tablename list
* apache_table exists tablename key
@@ -626,7 +624,7 @@ append_key_value_callback (void *data, c
* "err_headers_out", and "subprocess_env".
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
*
@@ -685,7 +683,7 @@ TCL_CMD_HEADER( Rivet_ApacheTable )
return TCL_ERROR;
}
- if (Tcl_GetIndexFromObj(interp, objv[1],SubCommand,
+ if (Tcl_GetIndexFromObj(interp, objv[1], SubCommand,
"get|set|unset|list",
0, &subcommandindex) == TCL_ERROR) {
return TCL_ERROR;
@@ -694,7 +692,7 @@ TCL_CMD_HEADER( Rivet_ApacheTable )
if (Tcl_GetIndexFromObj (interp, objv[2], tableNames,
"notes|headers_in|headers_out|err_header_out|subprocess_env",
0, &tableindex) == TCL_ERROR) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
switch ((enum tablename)tableindex)
@@ -732,26 +730,24 @@ TCL_CMD_HEADER( Rivet_ApacheTable )
const char *value;
if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "tablename key");
- return TCL_ERROR;
+ Tcl_WrongNumArgs(interp, 2, objv, "tablename key");
+ return TCL_ERROR;
}
-
key = Tcl_GetString (objv[3]);
value = apr_table_get (table, key);
if (value != NULL) {
- Tcl_SetObjResult (interp, Tcl_NewStringObj (value, -1));
+ Tcl_SetObjResult (interp, Tcl_NewStringObj (value, -1));
}
break;
}
-
case SUB_EXISTS: {
const char *key;
const char *value;
if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "tablename key");
- return TCL_ERROR;
+ Tcl_WrongNumArgs(interp, 2, objv, "tablename key");
+ return TCL_ERROR;
}
key = Tcl_GetString (objv[3]);
@@ -760,8 +756,6 @@ TCL_CMD_HEADER( Rivet_ApacheTable )
Tcl_SetObjResult (interp, Tcl_NewBooleanObj (value != NULL));
break;
}
-
-
case SUB_SET: {
int i;
char *key;
@@ -844,23 +838,23 @@ TCL_CMD_HEADER( Rivet_ApacheTable )
*
* Rivet_Upload --
*
- * Deals with file uploads (multipart/form-data) like so:
+ * Deals with file uploads (multipart/form-data) like so:
*
- * upload channel uploadname
- * upload save name uploadname
- * upload data uploadname
- * upload exists uploadname
- * upload size uploadname
- * upload type uploadname
- * upload filename uploadname
- * upload names
+ * upload channel uploadname
+ * upload save name uploadname
+ * upload data uploadname
+ * upload exists uploadname
+ * upload size uploadname
+ * upload type uploadname
+ * upload filename uploadname
+ * upload names
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * Has the potential to create files on the file system, or work
- * with large amounts of data.
+ * Has the potential to create files on the file system, or work
+ * with large amounts of data.
*
*-----------------------------------------------------------------------------
*/
@@ -900,10 +894,10 @@ TCL_CMD_HEADER( Rivet_Upload )
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
if (Tcl_GetIndexFromObj(interp, objv[1], SubCommand,
- "channel|save|data|exists|size|type|filename|names|tempname"
- "|tempname|names",
- 0, &subcommandindex) == TCL_ERROR) {
- return TCL_ERROR;
+ "channel|save|data|exists|size|type|filename|names|tempname"
+ "|tempname|names",
+ 0, &subcommandindex) == TCL_ERROR) {
+ return TCL_ERROR;
}
/* If it's any of these, we need to find a specific name. */
@@ -924,8 +918,8 @@ TCL_CMD_HEADER( Rivet_Upload )
{
if (TclWeb_PrepareUpload(varname, globals->req) != TCL_OK)
{
- Tcl_AddErrorInfo(interp, "Unable to find variable");
- return TCL_ERROR;
+ Tcl_AddErrorInfo(interp, "Unable to find variable");
+ return TCL_ERROR;
}
}
@@ -942,84 +936,65 @@ TCL_CMD_HEADER( Rivet_Upload )
switch ((enum subcommand)subcommandindex)
{
- case CHANNEL:
- {
- Tcl_Channel chan;
- char *channelname = NULL;
+ case CHANNEL: {
+ Tcl_Channel chan;
+ char *channelname = NULL;
- if (TclWeb_UploadChannel(varname, &chan, globals->req) != TCL_OK) {
- return TCL_ERROR;
- }
- channelname = (char *)Tcl_GetChannelName(chan);
- Tcl_SetStringObj(result, channelname, -1);
- break;
- }
- case SAVE:
- {
- /* save data to a specified filename */
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "uploadname filename");
- return TCL_ERROR;
- }
-
- if (TclWeb_UploadSave(varname, objv[3], globals->req) != TCL_OK)
- {
- return TCL_ERROR;
- }
- break;
- }
- case DATA:
- {
- if (TclWeb_UploadData(varname, result, globals->req) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- }
- case EXISTS:
- {
- if (TclWeb_PrepareUpload(varname, globals->req) != TCL_OK)
- {
- Tcl_SetIntObj(result, 0);
- } else {
- Tcl_SetIntObj(result, 1);
- }
- break;
- }
- case SIZE:
- {
- TclWeb_UploadSize(result, globals->req);
- break;
+ if (TclWeb_UploadChannel(varname, &chan, globals->req) != TCL_OK) {
+ return TCL_ERROR;
}
- case TYPE:
- {
- TclWeb_UploadType(result, globals->req);
- break;
+ channelname = (char *)Tcl_GetChannelName(chan);
+ Tcl_SetStringObj(result, channelname, -1);
+ break;
+ }
+ case SAVE:
+ /* save data to a specified filename */
+ if (objc != 4) {
+ Tcl_WrongNumArgs(interp, 2, objv, "uploadname filename");
+ return TCL_ERROR;
}
- case FILENAME:
+
+ if (TclWeb_UploadSave(varname, objv[3], globals->req) != TCL_OK)
{
- TclWeb_UploadFilename(result, globals->req);
- break;
+ return TCL_ERROR;
}
- case TEMPNAME:
- {
- TclWeb_UploadTempname(result,globals->req);
- break;
+ break;
+ case DATA:
+ if (TclWeb_UploadData(varname, result, globals->req) != TCL_OK) {
+ return TCL_ERROR;
}
- case NAMES:
+ break;
+ case EXISTS:
+ if (TclWeb_PrepareUpload(varname, globals->req) != TCL_OK)
{
- if (objc != 2)
- {
- Tcl_WrongNumArgs(interp, 1, objv, "names");
- return TCL_ERROR;
- }
- TclWeb_UploadNames(result, globals->req);
- break;
+ Tcl_SetIntObj(result, 0);
+ } else {
+ Tcl_SetIntObj(result, 1);
}
- default:
+ break;
+ case SIZE:
+ TclWeb_UploadSize(result, globals->req);
+ break;
+ case TYPE:
+ TclWeb_UploadType(result, globals->req);
+ break;
+ case FILENAME:
+ TclWeb_UploadFilename(result, globals->req);
+ break;
+ case TEMPNAME:
+ TclWeb_UploadTempname(result,globals->req);
+ break;
+ case NAMES:
+ if (objc != 2)
{
- Tcl_WrongNumArgs(interp, 1, objv,
- "channel|save ?name?|data|exists|size|type|filename|names|tempname");
+ Tcl_WrongNumArgs(interp, 1, objv, "names");
+ return TCL_ERROR;
}
+ TclWeb_UploadNames(result, globals->req);
+ break;
+ default:
+ Tcl_WrongNumArgs(interp, 1, objv,
+ "channel|save ?name?|data|exists|size|type|filename|names|tempname");
}
Tcl_SetObjResult(interp, result);
return TCL_OK;
@@ -1030,13 +1005,13 @@ TCL_CMD_HEADER( Rivet_Upload )
*
* Rivet_RawPost --
*
- * Returns the raw POST data.
+ * Returns the raw POST data.
*
* Results:
- * The raw post data, or an empty string if there is none.
+ * The raw post data, or an empty string if there is none.
*
* Side Effects:
- * None.
+ * None.
*
*-----------------------------------------------------------------------------
*/
@@ -1062,14 +1037,14 @@ TCL_CMD_HEADER ( Rivet_RawPost )
*
* Rivet_NoBody --
*
- * Tcl command to erase body, so that only header is returned.
- * Necessary for 304 responses.
+ * Tcl command to erase body, so that only header is returned.
+ * Necessary for 304 responses.
*
* Results:
- * A standard Tcl return value.
+ * A standard Tcl return value.
*
* Side Effects:
- * Eliminates any body returned in the HTTP response.
+ * Eliminates any body returned in the HTTP response.
*
*-----------------------------------------------------------------------------
*/
@@ -1092,16 +1067,16 @@ TCL_CMD_HEADER( Rivet_NoBody )
*
* Rivet_AbortPageCmd --
*
- * Similar in purpose to PHP's "die" command, which halts all
- * further output to the user. Like an "exit" for web pages, but
- * without actually exiting the apache child.
+ * Similar in purpose to PHP's "die" command, which halts all
+ * further output to the user. Like an "exit" for web pages, but
+ * without actually exiting the apache child.
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * Flushes the standard (apache) output channel, and tells apache
- * to stop sending data.
+ * Flushes the standard (apache) output channel, and tells apache
+ * to stop sending data.
*
*-----------------------------------------------------------------------------
*/
@@ -1186,14 +1161,14 @@ TCL_CMD_HEADER( Rivet_AbortCodeCmd )
*
* Rivet_EnvCmd --
*
- * Loads a single environmental variable, to avoid the overhead
- * of storing all of them when only one is needed.
+ * Loads a single environmental variable, to avoid the overhead
+ * of storing all of them when only one is needed.
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * None.
+ * None.
*
*-----------------------------------------------------------------------------
*/
@@ -1222,14 +1197,14 @@ TCL_CMD_HEADER( Rivet_EnvCmd )
*
* Rivet_VirtualFilenameCmd --
*
- * Gets file according to its relationship with the request's
- * root. (FIXME - check this).
+ * Gets file according to its relationship with the request's
+ * root. (FIXME - check this).
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * None.
+ * None.
*
*-----------------------------------------------------------------------------
*/
@@ -1257,9 +1232,9 @@ TCL_CMD_HEADER( Rivet_VirtualFilenameCmd
*
* Rivet_LogError --
*
- * Log an error from Rivet
+ * Log an error from Rivet
*
- * log_error priority message
+ * log_error priority message
*
* priority can be one of "emerg", "alert", "crit", "err",
* "warning", "notice", "info", "debug"
@@ -1280,40 +1255,40 @@ TCL_CMD_HEADER( Rivet_LogErrorCmd )
int apLogLevel = 0;
static CONST84 char *logLevel[] = {
- "emerg",
- "alert",
- "crit",
- "err",
- "warning",
- "notice",
- "info",
- "debug",
- NULL
+ "emerg",
+ "alert",
+ "crit",
+ "err",
+ "warning",
+ "notice",
+ "info",
+ "debug",
+ NULL
};
enum loglevel {
- EMERG,
- ALERT,
- CRIT,
- ERR,
- WARNING,
- NOTICE,
- INFO,
- DEBUG
+ EMERG,
+ ALERT,
+ CRIT,
+ ERR,
+ WARNING,
+ NOTICE,
+ INFO,
+ DEBUG
};
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
if( objc != 3 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "loglevel message" );
- return TCL_ERROR;
+ Tcl_WrongNumArgs( interp, 1, objv, "loglevel message" );
+ return TCL_ERROR;
}
message = Tcl_GetString (objv[2]);
if (Tcl_GetIndexFromObj(interp, objv[1], logLevel,
- "emerg|alert|crit|err|warning|notice|info|debug",
- 0, &loglevelindex) == TCL_ERROR) {
- return TCL_ERROR;
+ "emerg|alert|crit|err|warning|notice|info|debug",
+ 0, &loglevelindex) == TCL_ERROR) {
+ return TCL_ERROR;
}
switch ((enum loglevel)loglevelindex)
@@ -1368,23 +1343,23 @@ TCL_CMD_HEADER( Rivet_LogErrorCmd )
*
* TestpanicCmd --
*
- * Calls the panic routine.
+ * Calls the panic routine.
*
* Results:
* Always returns TCL_OK.
*
* Side effects:
- * May exit application.
+ * May exit application.
*
*----------------------------------------------------------------------
*/
static int
TestpanicCmd(dummy, interp, argc, argv)
- ClientData dummy; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+ ClientData dummy; /* Not used. */
+ Tcl_Interp *interp; /* Current interpreter. */
+ int argc; /* Number of arguments. */
+ CONST char **argv; /* Argument strings. */
{
CONST char *argString;
@@ -1406,13 +1381,13 @@ TestpanicCmd(dummy, interp, argc, argv)
*
* Rivet_InitCore --
*
- * Creates the core rivet commands.
+ * Creates the core rivet commands.
*
* Results:
- * A standard Tcl result.
+ * A standard Tcl result.
*
* Side Effects:
- * Creates new commands.
+ * Creates new commands.
*
*-----------------------------------------------------------------------------
*/
@@ -1420,104 +1395,41 @@ TestpanicCmd(dummy, interp, argc, argv)
int
Rivet_InitCore( Tcl_Interp *interp )
{
- Tcl_CreateObjCommand(interp,
- "makeurl",
- Rivet_MakeURL,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "headers",
- Rivet_Headers,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "load_env",
- Rivet_LoadEnv,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "load_headers",
- Rivet_LoadHeaders,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "var",
- Rivet_Var,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "apache_table",
- Rivet_ApacheTable,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "var_qs",
- Rivet_Var,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "var_post",
- Rivet_Var,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "raw_post",
- Rivet_RawPost,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "upload",
- Rivet_Upload,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "include",
- Rivet_Include,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "parse",
- Rivet_Parse,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "no_body",
- Rivet_NoBody,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "env",
- Rivet_EnvCmd,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
-
- Tcl_CreateObjCommand(interp,
- "apache_log_error",
- Rivet_LogErrorCmd,
- NULL,
- (Tcl_CmdDeleteProc *)NULL);
+#if RIVET_NAMESPACE_EXPORT == 1
+ rivet_interp_globals *globals = NULL;
+ Tcl_Namespace *rivet_ns;
+
+ globals = Tcl_GetAssocData(interp, "rivet", NULL);
+ rivet_ns = globals->rivet_ns;
+#endif
+
+ RIVET_OBJ_CMD ("makeurl",Rivet_MakeURL);
+ RIVET_OBJ_CMD ("headers",Rivet_Headers);
+ RIVET_OBJ_CMD ("load_env",Rivet_LoadEnv);
+ RIVET_OBJ_CMD ("load_headers",Rivet_LoadHeaders);
+ RIVET_OBJ_CMD ("var",Rivet_Var);
+ RIVET_OBJ_CMD ("abort_page",Rivet_AbortPageCmd);
+ RIVET_OBJ_CMD ("abort_code", Rivet_AbortCodeCmd);
+ RIVET_OBJ_CMD ("virtual_filename",Rivet_VirtualFilenameCmd);
+ RIVET_OBJ_CMD ("apache_table",Rivet_ApacheTable);
+ RIVET_OBJ_CMD ("var_qs",Rivet_Var);
+ RIVET_OBJ_CMD ("var_post",Rivet_Var);
+ RIVET_OBJ_CMD ("raw_post",Rivet_RawPost);
+ RIVET_OBJ_CMD ("upload",Rivet_Upload);
+ RIVET_OBJ_CMD ("include",Rivet_Include);
+ RIVET_OBJ_CMD ("parse",Rivet_Parse);
+ RIVET_OBJ_CMD ("no_body",Rivet_NoBody);
+ RIVET_OBJ_CMD ("env",Rivet_EnvCmd);
+ RIVET_OBJ_CMD ("apache_log_error",Rivet_LogErrorCmd);
#ifdef TESTPANIC
- Tcl_CreateCommand(interp, "testpanic", TestpanicCmd, (ClientData) 0,
- (Tcl_CmdDeleteProc *) NULL);
+ RIVET_OBJ_CMD ("testpanic",TestpanicCmd);
#endif
- TCL_OBJ_CMD( "abort_page", Rivet_AbortPageCmd );
- TCL_OBJ_CMD( "abort_code", Rivet_AbortCodeCmd );
- TCL_OBJ_CMD( "virtual_filename", Rivet_VirtualFilenameCmd );
+#if RIVET_NAMESPACE_EXPORT == 1
+ Tcl_Export(interp,rivet_ns,"*",0);
+#endif
+// return Tcl_PkgProvide( interp,RIVET_TCL_PACKAGE,"1.2");
return TCL_OK;
}
Modified: tcl/rivet/branches/apreq-multipart/src/parserPkgInit.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/parserPkgInit.c?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/parserPkgInit.c (original)
+++ tcl/rivet/branches/apreq-multipart/src/parserPkgInit.c Fri May 4 08:23:05 2012
@@ -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, TCL_VERSION, 0) == NULL) {
+#else
+ if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) {
+#endif
+ return TCL_ERROR;
+ }
+
Tcl_CreateObjCommand(interp,
"rivet::parserivetdata",
Parse_RivetData,
Modified: tcl/rivet/branches/apreq-multipart/src/rivet.h
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/rivet.h?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/rivet.h (original)
+++ tcl/rivet/branches/apreq-multipart/src/rivet.h Fri May 4 08:23:05 2012
@@ -1,3 +1,19 @@
+/* Copyright 2002-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/* $Id$ */
/* This is for windows. */
#ifdef BUILD_rivet
@@ -7,6 +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 TCL_CMD_HEADER(cmd) \
static int cmd(\
@@ -22,8 +41,21 @@ Tcl_CreateObjCommand( interp, /* Tcl int
NULL, /* Client Data */\
(Tcl_CmdDeleteProc *)NULL /* Tcl Delete Prov */)
-EXTERN int Rivet_Init( Tcl_Interp *interp );
-EXTERN int Rivet_InitList( Tcl_Interp *interp );
-EXTERN int Rivet_InitCrypt( Tcl_Interp *interp );
-EXTERN int Rivet_InitWWW( Tcl_Interp *interp );
-EXTERN int Rivet_InitCore( Tcl_Interp *interp );
+/* RIVET_OBJ_CMD creates a command in the RIVET_NS namespace. Commands
+ * are exported from the RIVET_NS (::rivet) namespace in the init.tcl
+ * script accordingly to configuration switches passed to ./configure
+ * (see configure.ac)
+ */
+
+#define RIVET_OBJ_CMD(name,func) \
+Tcl_CreateObjCommand( interp, /* Tcl interpreter */\
+ RIVET_NS "::" name, /* Function name in Tcl */\
+ func, /* C function name */\
+ NULL, /* Client Data */\
+ (Tcl_CmdDeleteProc *)NULL /* Tcl Delete Prov */);
+
+EXTERN int Rivet_Init(Tcl_Interp *interp);
+EXTERN int Rivet_InitList(Tcl_Interp *interp);
+EXTERN int Rivet_InitCrypt(Tcl_Interp *interp);
+EXTERN int Rivet_InitWWW(Tcl_Interp *interp);
+EXTERN int Rivet_InitCore(Tcl_Interp *interp);
Propchange: tcl/rivet/branches/apreq-multipart/src/rivet.h
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Fri May 4 08:23:05 2012
@@ -1 +1 @@
-Author Date Id Revision
+Id
Modified: tcl/rivet/branches/apreq-multipart/src/rivetCrypt.c
URL: http://svn.apache.org/viewvc/tcl/rivet/branches/apreq-multipart/src/rivetCrypt.c?rev=1333806&r1=1333805&r2=1333806&view=diff
==============================================================================
--- tcl/rivet/branches/apreq-multipart/src/rivetCrypt.c (original)
+++ tcl/rivet/branches/apreq-multipart/src/rivetCrypt.c Fri May 4 08:23:05 2012
@@ -8,7 +8,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -45,19 +45,19 @@ Rivet_Crypt(char *string, const char *ke
while (*string != '\0')
{
- if (*string >= 32 && *string <= 126)
- {
- if (mode)
- *string = (((*string - 32) + (*kp - 32)) % 94) + 32;
- else
- *string = (((*string - 32) - (*kp - 32) + 94) % 94) + 32;
- }
-
- string++;
- kp++;
- if (*kp == '\0') {
- kp = key;
- }
+ if (*string >= 32 && *string <= 126)
+ {
+ if (mode)
+ *string = (((*string - 32) + (*kp - 32)) % 94) + 32;
+ else
+ *string = (((*string - 32) - (*kp - 32) + 94) % 94) + 32;
+ }
+
+ string++;
+ kp++;
+ if (*kp == '\0') {
+ kp = key;
+ }
}
}
@@ -69,7 +69,7 @@ TCL_CMD_HEADER( Rivet_EncryptCmd )
int keyIndex;
if( objc < 3 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "data key" );
+ Tcl_WrongNumArgs( interp, 1, objv, "data key" );
return TCL_ERROR;
}
@@ -80,7 +80,7 @@ TCL_CMD_HEADER( Rivet_EncryptCmd )
for( keyIndex = 2; keyIndex < objc; keyIndex++ )
{
- key = Tcl_GetStringFromObj( objv[keyIndex], NULL );
+ key = Tcl_GetStringFromObj( objv[keyIndex], NULL );
Rivet_Crypt( resultBuffer, key, 0L, MODE_ENCRYPT );
}
@@ -97,7 +97,7 @@ TCL_CMD_HEADER( Rivet_DecryptCmd )
int keyIndex;
if( objc < 3 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "data key" );
+ Tcl_WrongNumArgs( interp, 1, objv, "data key" );
return TCL_ERROR;
}
@@ -108,7 +108,7 @@ TCL_CMD_HEADER( Rivet_DecryptCmd )
for( keyIndex = 2; keyIndex < objc; keyIndex++ )
{
- key = Tcl_GetStringFromObj( objv[keyIndex], NULL );
+ key = Tcl_GetStringFromObj( objv[keyIndex], NULL );
Rivet_Crypt( resultBuffer, key, 0L, MODE_DECRYPT );
}
@@ -124,7 +124,7 @@ TCL_CMD_HEADER( Rivet_CryptCmd )
const char *resultBuffer;
if( objc != 3 ) {
- Tcl_WrongNumArgs( interp, 1, objv, "key salt" );
+ Tcl_WrongNumArgs( interp, 1, objv, "key salt" );
return TCL_ERROR;
}
@@ -134,17 +134,16 @@ TCL_CMD_HEADER( Rivet_CryptCmd )
resultBuffer = crypt((const char *)key, (const char *)salt);
if( resultBuffer == NULL ) {
- Tcl_AppendResult (interp,
- "crypt function failed: ",
- Tcl_GetStringFromObj(objv[1], NULL),
- (char *)NULL );
- return TCL_ERROR;
+ Tcl_AppendResult (interp,
+ "crypt function failed: ",
+ Tcl_GetStringFromObj(objv[1], NULL),
+ (char *)NULL );
+ return TCL_ERROR;
}
Tcl_SetObjResult( interp, Tcl_NewStringObj( resultBuffer, -1 ) );
return TCL_OK;
#else /* ! crypt */
- Tcl_SetObjResult(interp,
- Tcl_NewStringObj("error: command not available", -1));
+ Tcl_SetObjResult(interp,Tcl_NewStringObj("error: command not available", -1));
return TCL_ERROR;
#endif /* ! crypt */
}
@@ -162,11 +161,10 @@ TCL_CMD_HEADER( Rivet_CryptCmd )
*-----------------------------------------------------------------------------
*/
int
-Rivet_InitCrypt( Tcl_Interp *interp )
+Rivet_InitCrypt( Tcl_Interp *interp)
{
- TCL_OBJ_CMD( "encrypt", Rivet_EncryptCmd );
- TCL_OBJ_CMD( "decrypt", Rivet_DecryptCmd );
- TCL_OBJ_CMD( "crypt", Rivet_CryptCmd );
-
+ RIVET_OBJ_CMD("encrypt", Rivet_EncryptCmd);
+ RIVET_OBJ_CMD("decrypt", Rivet_DecryptCmd);
+ RIVET_OBJ_CMD("crypt", Rivet_CryptCmd);
return TCL_OK;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-cvs-help@tcl.apache.org