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 da...@apache.org on 2002/03/11 01:31:10 UTC
cvs commit: tcl-rivet/src mod_rivet.c rivetCrypt.c rivetParser.c
damonc 02/03/10 16:31:10
Modified: . ChangeLog TODO
rivet/packages/dtcl dtcl.tcl
rivet/rivet-tcl tclIndex
src mod_rivet.c rivetCrypt.c rivetParser.c
Added: rivet/rivet-tcl load_cookies.tcl make_cookie.tcl
Log:
* src/mod_rivet.c
The Scripts output to the UserConf arrays now properly display
the scripts in their entirety.
Cleaned up the handling of directory configuration merging.
Fixed a bug where Rivet_GetRivetFile was stomping the BeforeScript.
Revision Changes Path
1.36 +10 -0 tcl-rivet/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /home/cvs/tcl-rivet/ChangeLog,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ChangeLog 23 Feb 2002 10:55:56 -0000 1.35
+++ ChangeLog 11 Mar 2002 00:31:10 -0000 1.36
@@ -1,3 +1,13 @@
+2002-03-10 Damon J. Courtney <da...@unreality.com>
+
+ * src/mod_rivet.c
+ The Scripts output to the UserConf arrays now properly display
+ the scripts in their entirety.
+
+ Cleaned up the handling of directory configuration merging.
+
+ Fixed a bug where Rivet_GetRivetFile was stomping the BeforeScript.
+
2002-02-23 David N. Welton <da...@dedasys.com>
* src/TclWebapache.c: Added functions: TclWeb_PrepareUpload,
1.7 +3 -6 tcl-rivet/TODO
Index: TODO
===================================================================
RCS file: /home/cvs/tcl-rivet/TODO,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TODO 17 Feb 2002 19:40:13 -0000 1.6
+++ TODO 11 Mar 2002 00:31:10 -0000 1.7
@@ -1,3 +1,6 @@
+BUGS
+====
+
TODO
====
@@ -21,9 +24,6 @@
* Create escape_string and unescape_string using Apache conventions.
-* Add a PackageRequire Server directive that will load packages on
- start-up.
-
* Free all Rivet commands of apache dependencies, which are moved into
the TclWebapache.c file. Compatible file, for CGI only operating,
TclWebcgi.c needs to be created.
@@ -34,9 +34,6 @@
* Maybe write load_cookies in Tcl and try to get rid of the
apache_cookie.* stuff.
-
-* Maybe write the header command in Tcl.
- - basic API is in C... difficult to do.
* Maybe move ::request commands into a file called request.tcl.
1.2 +1 -3 tcl-rivet/rivet/packages/dtcl/dtcl.tcl
Index: dtcl.tcl
===================================================================
RCS file: /home/cvs/tcl-rivet/rivet/packages/dtcl/dtcl.tcl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dtcl.tcl 12 Jan 2002 01:35:19 -0000 1.1
+++ dtcl.tcl 11 Mar 2002 00:31:10 -0000 1.2
@@ -33,6 +33,4 @@
flush stdout
}
-proc dtcl_info {} {
- rivet_info
-}
+proc dtcl_info {} { }
1.5 +4 -1 tcl-rivet/rivet/rivet-tcl/tclIndex
Index: tclIndex
===================================================================
RCS file: /home/cvs/tcl-rivet/rivet/rivet-tcl/tclIndex,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- tclIndex 10 Mar 2002 10:30:22 -0000 1.4
+++ tclIndex 11 Mar 2002 00:31:10 -0000 1.5
@@ -11,8 +11,11 @@
set auto_index(html) [list source [file join $dir html.tcl]]
set auto_index(incr0) [list source [file join $dir incr0.tcl]]
set auto_index(read_file) [list source [file join $dir read_file.tcl]]
-set auto_index(include0) [list source [file join $dir include0.tcl]]
set auto_index(wrap) [list source [file join $dir wrap.tcl]]
set auto_index(wrapline) [list source [file join $dir wrap.tcl]]
set auto_index(debug) [list source [file join $dir debug.tcl]]
set auto_index(lempty) [list source [file join $dir lempty.tcl]]
+set auto_index(load_cookies) [list source [file join $dir load_cookies.tcl]]
+set auto_index(clock_to_rfc850_gmt) [list source [file join $dir make_cookie.tcl]]
+set auto_index(make_cookie_attributes) [list source [file join $dir make_cookie.tcl]]
+set auto_index(make_cookie) [list source [file join $dir make_cookie.tcl]]
1.1 tcl-rivet/rivet/rivet-tcl/load_cookies.tcl
Index: load_cookies.tcl
===================================================================
proc load_cookies {{arrayName cookies}} {
upvar 1 $arrayName cookies
load_env
if {![info exists env(HTTP_COOKIE)]} { return }
foreach pair [split $env(HTTP_COOKIE) ";"] {
set pair [split [string trim $pair] "="]
set key [lindex $pair 0]
set value [lindex $pair 1]
set cookies($key) [list $value]
}
}
1.1 tcl-rivet/rivet/rivet-tcl/make_cookie.tcl
Index: make_cookie.tcl
===================================================================
##
## Convert an integer-seconds-since-1970 click value to RFC850 format,
## with the additional requirement that it be GMT only.
##
proc clock_to_rfc850_gmt {seconds} {
return [clock format $seconds -format "%a, %d-%b-%y %T GMT" -gmt 1]
}
proc make_cookie_attributes {paramsArray} {
upvar $paramsArray params
set cookieParams ""
set expiresIn 0
foreach {time num} [list days 86400 hours 3600 minutes 60] {
if [info exists params($time)] {
incr expiresIn [expr $params($time) * $num]
}
}
if {$expiresIn != 0} {
set secs [expr [clock seconds] + $expiresIn]
append cookieParams "; expires=[clock_to_rfc850_gmt $secs]"
}
if [info exists params(path)] {
append cookieParams "; path=$params(path)"
}
if [info exists params(domain)] {
append cookieParams "; domain=$params(domain)"
}
if {[info exists params(secure)] && $params(secure) == 1} {
append cookieParams "; secure"
}
return $cookieParams
}
# make_cookie cookieName cookieValue [-days expireInDays]
# [-hours expireInHours] [-minutes expireInMinutes]
# [-path uriPathCookieAppliesTo]
# [-secure 1|0]
#
proc make_cookie {name value args} {
import_keyvalue_pairs params $args
set badchars "\[ \t;\]"
if {[regexp $badchars $name]} {
return -code error "name may not contain semicolons, spaces, or tabs"
}
if {[regexp $badchars $value]} {
return -code error "value may not contain semicolons, spaces, or tabs"
}
set cookieKey "Set-cookie"
set cookieValue "$name=$value"
append cookieValue [make_cookie_attributes params]
set_header $cookieKey $cookieValue
}
1.33 +57 -61 tcl-rivet/src/mod_rivet.c
Index: mod_rivet.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/mod_rivet.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- mod_rivet.c 23 Feb 2002 10:55:56 -0000 1.32
+++ mod_rivet.c 11 Mar 2002 00:31:10 -0000 1.33
@@ -55,7 +55,7 @@
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign. */
-/* $Id: mod_rivet.c,v 1.32 2002/02/23 10:55:56 davidw Exp $ */
+/* $Id: mod_rivet.c,v 1.33 2002/03/11 00:31:10 damonc Exp $ */
/* mod_rivet.c by David Welton <da...@apache.org>
* and Damon Courtney <da...@unreality.com>
@@ -140,14 +140,17 @@
Tcl_Flush(*(conf->outchannel));
if (errscript)
{
- if (Tcl_EvalObj(interp, errscript) == TCL_ERROR)
- TclWeb_PrintError("<b>Tcl_ErrorScript failed!</b>", 1, globals->req);
+ if (Tcl_EvalObj(interp, errscript) == TCL_ERROR) {
+ TclWeb_PrintError("<b>Tcl_ErrorScript failed!</b>", 1,
+ globals->req);
+ }
} else {
/* default action */
errorinfo = Tcl_GetVar(interp, "errorInfo", 0);
TclWeb_PrintError(errorinfo, 0, globals->req);
TclWeb_PrintError("<p><b>OUTPUT BUFFER:</b></p>", 1, globals->req);
- TclWeb_PrintError(Tcl_GetStringFromObj(outbuf, (int *)NULL), 1, globals->req);
+ TclWeb_PrintError(Tcl_GetStringFromObj(outbuf, (int *)NULL), 1,
+ globals->req);
}
} else {
/* Make sure to flush the output if buffer_add was the only output */
@@ -174,7 +177,8 @@
rivet_server_conf *rsc = NULL;
Tcl_Interp *interp = req->interp;
- rsc = RIVET_SERVER_CONF( req->req->server->module_config );
+ /* rsc = RIVET_SERVER_CONF( req->req->server->module_config ); */
+ rsc = Rivet_GetConf( req->req );
/* If toplevel is 0, we are being called from Parse, which means
we need to get the information about the file ourselves. */
@@ -205,6 +209,7 @@
/* We don't have a compiled version. Let's create one */
if (isNew || *(rsc->cache_size) == 0)
{
+
outbuf = Tcl_NewObj();
Tcl_IncrRefCount(outbuf);
if (toplevel && rsc->rivet_before_script) {
@@ -575,10 +580,10 @@
}
}
-static void
+static char *
Rivet_AppendToScript( rivet_server_conf *rsc, char *script, char *string )
{
- Tcl_Obj *objarg;
+ Tcl_Obj *objarg = NULL;
if( STREQU( script, "GlobalInitScript" ) ) {
if( rsc->rivet_global_init_script == NULL ) {
@@ -647,6 +652,10 @@
Tcl_AppendToObj( objarg, "\n", 1 );
}
}
+
+ if( !objarg ) return string;
+
+ return Tcl_GetStringFromObj( objarg, NULL );
}
/*
@@ -671,24 +680,13 @@
{
server_rec *s = cmd->server;
rivet_server_conf *rsc = RIVET_SERVER_CONF(s->module_config);
+ char *string = val;
if ( var == NULL || val == NULL ) {
return "Rivet Error: RivetServerConf requires two arguments";
}
- if( STREQU( var, "GlobalInitScript" ) ) {
- Rivet_AppendToScript( rsc, var, val );
- } else if( STREQU( var, "ChildInitScript" ) ) {
- Rivet_AppendToScript( rsc, var, val );
- } else if( STREQU( var, "ChildExitScript" ) ) {
- Rivet_AppendToScript( rsc, var, val );
- } else if( STREQU( var, "BeforeScript" ) ) {
- Rivet_AppendToScript( rsc, var, val );
- } else if( STREQU( var, "AfterScript" ) ) {
- Rivet_AppendToScript( rsc, var, val );
- } else if( STREQU( var, "ErrorScript" ) ) {
- Rivet_AppendToScript( rsc, var, val );
- } else if( STREQU( var, "CacheSize" ) ) {
+ if( STREQU( var, "CacheSize" ) ) {
*(rsc->cache_size) = strtol( val, NULL, 10 );
} else if( STREQU( var, "UploadDirectory" ) ) {
rsc->upload_dir = val;
@@ -706,9 +704,11 @@
} else {
rsc->seperate_virtual_interps = 0;
}
+ } else {
+ string = Rivet_AppendToScript( rsc, var, val );
}
- ap_table_set( rsc->rivet_server_vars, var, val );
+ ap_table_set( rsc->rivet_server_vars, var, string );
return( NULL );
}
@@ -724,20 +724,19 @@
static const char *
Rivet_DirConf( cmd_parms *cmd, rivet_server_conf *rdc, char *var, char *val )
{
+ char *string = val;
+
if ( var == NULL || val == NULL ) {
return "Rivet Error: RivetDirConf requires two arguments";
}
- if( STREQU( var, "BeforeScript" ) ) {
- Rivet_AppendToScript( rdc, var, val );
- } else if( STREQU( var, "AfterScript" ) ) {
- Rivet_AppendToScript( rdc, var, val );
- } else if( STREQU( var, "ErrorScript" ) ) {
- Rivet_AppendToScript( rdc, var, val );
- } else if( STREQU( var, "UploadDirectory" ) ) {
+ if( STREQU( var, "UploadDirectory" ) ) {
rdc->upload_dir = val;
+ } else {
+ string = Rivet_AppendToScript( rdc, var, val );
}
- ap_table_set( rdc->rivet_dir_vars, var, val );
+
+ ap_table_set( rdc->rivet_dir_vars, var, string );
return( NULL );
}
@@ -752,22 +751,41 @@
static const char *
Rivet_UserConf( cmd_parms *cmd, rivet_server_conf *rdc, char *var, char *val )
{
+ char *string = val;
+
if ( var == NULL || val == NULL ) {
return "Rivet Error: RivetUserConf requires two arguments";
}
- if( STREQU( var, "BeforeScript" ) ) {
- Rivet_AppendToScript( rdc, var, val );
- } else if( STREQU( var, "AfterScript" ) ) {
- Rivet_AppendToScript( rdc, var, val );
- } else if( STREQU( var, "ErrorScript" ) ) {
- Rivet_AppendToScript( rdc, var, val );
- }
+ string = Rivet_AppendToScript( rdc, var, val );
- ap_table_set( rdc->rivet_user_vars, var, val );
+ ap_table_set( rdc->rivet_user_vars, var, string );
return( NULL );
}
+/*
+ * Merge the per-directory configuration options into a new configuration.
+ */
+static void *
+Rivet_MergeDirConfigVars( pool *p, rivet_server_conf *new,
+ rivet_server_conf *base, rivet_server_conf *add )
+{
+ new->rivet_before_script = add->rivet_before_script ?
+ add->rivet_before_script : base->rivet_before_script;
+ new->rivet_after_script = add->rivet_after_script ?
+ add->rivet_after_script : base->rivet_after_script;
+ new->rivet_error_script = add->rivet_error_script ?
+ add->rivet_error_script : base->rivet_error_script;
+ new->upload_dir = add->upload_dir ?
+ add->upload_dir : base->upload_dir;
+
+ /* Merge the tables of dir and user variables. */
+ new->rivet_dir_vars =
+ ap_overlay_tables( p, base->rivet_dir_vars, add->rivet_dir_vars );
+ new->rivet_user_vars =
+ ap_overlay_tables( p, base->rivet_user_vars, add->rivet_user_vars );
+}
+
/* Function to get a config and merge the directory/server options */
rivet_server_conf *
Rivet_GetConf( request_rec *r )
@@ -784,20 +802,10 @@
rdc = RIVET_SERVER_CONF( dconf );
newconfig = RIVET_NEW_CONF( r->pool );
- newconfig->server_interp = rsc->server_interp;
Rivet_CopyConfig( rsc, newconfig );
- /* List here things that can be per-directory. */
-
- newconfig->rivet_before_script = rdc->rivet_before_script ?
- rdc->rivet_before_script : rsc->rivet_before_script;
-
- newconfig->rivet_after_script = rdc->rivet_after_script ?
- rdc->rivet_after_script : rsc->rivet_after_script;
-
- newconfig->rivet_error_script = rdc->rivet_error_script ?
- rdc->rivet_error_script : rsc->rivet_error_script;
+ Rivet_MergeDirConfigVars( r->pool, newconfig, rsc, rdc );
return newconfig;
}
@@ -887,19 +895,7 @@
rivet_server_conf *add = (rivet_server_conf *)addv;
rivet_server_conf *new = RIVET_NEW_CONF(p);
- /* Merge the allowed directory options. */
- new->rivet_before_script = add->rivet_before_script ?
- add->rivet_before_script : base->rivet_before_script;
- new->rivet_after_script = add->rivet_after_script ?
- add->rivet_after_script : base->rivet_after_script;
- new->rivet_error_script = add->rivet_error_script ?
- add->rivet_error_script : base->rivet_error_script;
-
- /* Merge the tables of dir and user variables. */
- new->rivet_dir_vars =
- ap_overlay_tables( p, base->rivet_dir_vars, add->rivet_dir_vars );
- new->rivet_user_vars =
- ap_overlay_tables( p, base->rivet_user_vars, add->rivet_user_vars );
+ Rivet_MergeDirConfigVars( p, new, base, add );
return new;
}
1.3 +0 -1 tcl-rivet/src/rivetCrypt.c
Index: rivetCrypt.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/rivetCrypt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- rivetCrypt.c 22 Jan 2002 01:27:56 -0000 1.2
+++ rivetCrypt.c 11 Mar 2002 00:31:10 -0000 1.3
@@ -5,7 +5,6 @@
#include <tcl.h>
#include "rivet.h"
#include <unistd.h>
-#include <crypt.h>
#define MODE_DECRYPT 0
#define MODE_ENCRYPT 1
1.3 +2 -2 tcl-rivet/src/rivetParser.c
Index: rivetParser.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/rivetParser.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- rivetParser.c 27 Jan 2002 16:10:22 -0000 1.2
+++ rivetParser.c 11 Mar 2002 00:31:10 -0000 1.3
@@ -6,7 +6,7 @@
*
*/
-/* $Id: rivetParser.c,v 1.2 2002/01/27 16:10:22 davidw Exp $ */
+/* $Id: rivetParser.c,v 1.3 2002/03/11 00:31:10 damonc Exp $ */
#include <tcl.h>
#include "mod_rivet.h"
@@ -87,7 +87,7 @@
}
if (toplevel) {
- Tcl_SetStringObj(outbuf, "namespace eval request {\n", -1);
+ Tcl_AppendToObj(outbuf, "namespace eval request {\n", -1);
} else {
Tcl_SetStringObj(outbuf, "", -1);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org