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 2001/11/20 22:38:37 UTC
cvs commit: tcl-rivet/src apache_request.c mod_rivet.c mod_rivet.h tcl_commands.c
damonc 01/11/20 13:38:37
Modified: . ChangeLog TODO
src apache_request.c mod_rivet.c mod_rivet.h
tcl_commands.c
Log:
* src/tcl_commands.c
Cleaned up some more code. Just textual changes.
* src/mod_rivet.c
Cleaned up some run-over lines and code.
* src/mod_rivet.c
Changed module signature from "mod_rivet" to "Rivet"
* src/tcl_commands.c
Changed hgetvars command to load_env command.
* src/tcl_command.c
Moved loading of cookies to load_cookies command.
* src/tcl_command.c
Renamed default load_env array from ENVS array to env.
* src/tcl_command.c
Renamed default load_cookies array from COOKIES to cookies.
Revision Changes Path
1.4 +17 -1 tcl-rivet/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /home/cvs/tcl-rivet/ChangeLog,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ChangeLog 2001/11/08 10:20:23 1.3
+++ ChangeLog 2001/11/20 21:38:37 1.4
@@ -1,3 +1,20 @@
+2001-11-20 Damon J. Courtney <da...@unreality.com>
+
+ * src/tcl_commands.c
+ Cleaned up some more code. Just textual changes.
+ * src/mod_rivet.c
+ Cleaned up some run-over lines and code.
+ * src/mod_rivet.c
+ Changed module signature from "mod_rivet" to "Rivet"
+ * src/tcl_commands.c
+ Changed hgetvars command to load_env command.
+ * src/tcl_command.c
+ Moved loading of cookies to load_cookies command.
+ * src/tcl_command.c
+ Renamed default load_env array from ENVS array to env.
+ * src/tcl_command.c
+ Renamed default load_cookies array from COOKIES to cookies.
+
2001-11-08 David N. Welton <da...@dedasys.com>
* src/mod_rivet.c (rivet_child_init): Fix loop, pass correct
@@ -15,4 +32,3 @@
2001-09-23 David N. Welton <da...@dedasys.com>
* Initial commit and cleanup of old mod_dtcl code.
-
1.2 +4 -1 tcl-rivet/TODO
Index: TODO
===================================================================
RCS file: /home/cvs/tcl-rivet/TODO,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TODO 2001/09/19 13:12:58 1.1
+++ TODO 2001/11/20 21:38:37 1.2
@@ -1 +1,4 @@
-* Kill 'old style vars and use only command'.
\ No newline at end of file
+* Kill 'old style vars and use only command'.
+
+Add a '-virtual' option to include and parse. This will include or parse
+a file based on the server root.
1.2 +1 -1 tcl-rivet/src/apache_request.c
Index: apache_request.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/apache_request.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- apache_request.c 2001/09/19 13:12:58 1.1
+++ apache_request.c 2001/11/20 21:38:37 1.2
@@ -469,7 +469,7 @@
if (req->upload_hook != NULL) {
wlen = req->upload_hook(req->hook_data, buff, blen, upload);
} else {
- wlen = fwrite(buff, 1, blen, upload->fp);
+ wlen = fwrite(buff, 1, (unsigned)blen, upload->fp);
}
if (wlen != blen) {
return HTTP_INTERNAL_SERVER_ERROR;
1.9 +64 -50 tcl-rivet/src/mod_rivet.c
Index: mod_rivet.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/mod_rivet.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- mod_rivet.c 2001/11/16 10:41:44 1.8
+++ mod_rivet.c 2001/11/20 21:38:37 1.9
@@ -57,9 +57,13 @@
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign. */
-/* $Id: mod_rivet.c,v 1.8 2001/11/16 10:41:44 davidw Exp $ */
+/* $Id: mod_rivet.c,v 1.9 2001/11/20 21:38:37 damonc Exp $ */
-/* mod_rivet.c by David Welton <da...@apache.org> - originally mod_include. */
+/* mod_rivet.c by David Welton <da...@apache.org>
+ * and Damon Courtney <da...@unreality.com>
+ * - originally mod_include.
+ */
+
/* See http://tcl.apache.org/mod_rivet/credits.ttml for additional credits. */
#include "httpd.h"
@@ -84,31 +88,30 @@
module MODULE_VAR_EXPORT rivet_module;
static void tcl_init_stuff(server_rec *s, pool *p);
-static void copy_rivet_config( rivet_server_conf *oldrsc, rivet_server_conf *newrsc);
+static void copy_rivet_config( rivet_server_conf *oldrsc,
+ rivet_server_conf *newrsc);
static int get_ttml_file(request_rec *r, rivet_server_conf *rsc,
- Tcl_Interp *interp, char *filename, int toplevel, Tcl_Obj *outbuf);
+ Tcl_Interp *interp, char *filename, int toplevel,
+ Tcl_Obj *outbuf);
static int send_content(request_rec *);
-static int execute_and_check(Tcl_Interp *interp, Tcl_Obj *outbuf, request_rec *r);
+static int execute_and_check(Tcl_Interp *interp, Tcl_Obj *outbuf,
+ request_rec *r);
-/* just need some arbitrary non-NULL pointer which can't also be a request_rec */
+/* Need some arbitrary non-NULL pointer which can't also be a request_rec */
#define NESTED_INCLUDE_MAGIC (&rivet_module)
-#define RIVET_SERVER_CONF(module) (rivet_server_conf *)ap_get_module_config(module, &rivet_module)
-
/* Set up the content type header */
int
set_header_type(request_rec *r, char *header)
{
rivet_server_conf *rsc = rivet_get_conf(r);
- if (*(rsc->headers_set) == 0)
- {
- r->content_type = header;
- *(rsc->headers_set) = 1;
- return 1;
- } else {
- return 0;
- }
+
+ if( *(rsc->headers_set) ) return 0;
+
+ r->content_type = header;
+ *(rsc->headers_set) = 1;
+ return 1;
}
/* Printer headers if they haven't been printed yet */
@@ -116,17 +119,15 @@
print_headers(request_rec *r)
{
rivet_server_conf *rsc = rivet_get_conf(r);
- if (*(rsc->headers_printed) == 0)
- {
- if (*(rsc->headers_set) == 0)
- set_header_type(r, DEFAULT_HEADER_TYPE);
- ap_send_http_header(r);
- *(rsc->headers_printed) = 1;
- return 1;
- } else {
- return 0;
- }
+ if( *(rsc->headers_printed) ) return 0;
+
+ if (*(rsc->headers_set) == 0)
+ set_header_type(r, DEFAULT_HEADER_TYPE);
+
+ ap_send_http_header(r);
+ *(rsc->headers_printed) = 1;
+ return 1;
}
/* Print nice HTML formatted errors */
@@ -161,7 +162,8 @@
rivet_server_conf *rsc = rivet_get_conf(r);
if (Tcl_DStringLength(rsc->buffer) != 0)
{
- ap_rwrite(Tcl_DStringValue(rsc->buffer), Tcl_DStringLength(rsc->buffer), r);
+ ap_rwrite(Tcl_DStringValue(rsc->buffer),
+ Tcl_DStringLength(rsc->buffer), r);
Tcl_DStringInit(rsc->buffer);
}
*(rsc->content_sent) = 1;
@@ -287,7 +289,8 @@
if (ferror(f))
{
ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
- "Encountered error in mod_rivet getchar routine while reading %s",
+ "Encountered error in mod_rivet getchar routine "
+ "while reading %s",
r->uri);
ap_pfclose( r->pool, f);
}
@@ -305,7 +308,9 @@
if (rsc->rivet_after_script)
Tcl_AppendObjToObj(outbuf, rsc->rivet_after_script);
-/* Tcl_AppendToObj(outbuf, "\n}\nnamespace delete request\n", -1); seems redundant */
+/* Seems redundant
+ Tcl_AppendToObj(outbuf, "\n}\nnamespace delete request\n", -1);
+ */
Tcl_AppendToObj(outbuf, "\n}\n", -1);
}
else
@@ -328,7 +333,7 @@
conf = rivet_get_conf(r);
if (Tcl_EvalObj(interp, outbuf) == TCL_ERROR)
{
- Tcl_Obj *errscript = conf->rivet_error_script ? conf->rivet_error_script :
+ Tcl_Obj *errscript =
conf->rivet_error_script ? conf->rivet_error_script : NULL;
print_headers(r);
@@ -347,7 +352,7 @@
/* "</pre><b>OUTPUT BUFFER</b><pre>\n",
Tcl_GetStringFromObj(outbuf, (int *)NULL)); */
} else {
- /* We make sure to flush the output if buffer_add was the only output */
+ /* Make sure to flush the output if buffer_add was the only output */
print_headers(r);
flush_output_buffer(r);
}
@@ -399,7 +404,7 @@
outbuf = Tcl_NewObj();
Tcl_IncrRefCount(outbuf);
- if(!strcmp(r->content_type, "application/x-httpd-tcl") || toplevel == 0)
+ if( STREQU( r->content_type, "application/x-httpd-tcl") || !toplevel )
{
/* It's a TTML file - which we always are if toplevel is
0, meaning we are in the Parse command */
@@ -416,10 +421,10 @@
if (*(rsc->cache_free)) {
rsc->objCacheList[-- *(rsc->cache_free) ] = strdup(hashKey);
- } else if (*(rsc->cache_size)) { /* if it's zero, we just skip this... */
+ } else if (*(rsc->cache_size)) { /* If it's zero, we just skip this. */
Tcl_HashEntry *delEntry;
delEntry = Tcl_FindHashEntry(rsc->objCache,
- rsc->objCacheList[*(rsc->cache_size) - 1]);
+ rsc->objCacheList[*(rsc->cache_size)-1]);
Tcl_DecrRefCount((Tcl_Obj *)Tcl_GetHashValue(delEntry));
Tcl_DeleteHashEntry(delEntry);
free(rsc->objCacheList[*(rsc->cache_size) - 1]);
@@ -488,7 +493,8 @@
if (Tcl_EvalObj(interp, rsc->namespacePrologue) == TCL_ERROR)
{
- ap_log_error(APLOG_MARK, APLOG_ERR, r->server, "Could not create request namespace\n");
+ ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
+ "Could not create request namespace\n");
return HTTP_BAD_REQUEST;
}
@@ -536,7 +542,8 @@
Tcl_Obj *concat[2];
concat[0] = oldval;
concat[1] = newval;
- Tcl_ObjSetVar2(interp, varsobj, newkey, Tcl_ConcatObj(2, concat), 0);
+ Tcl_ObjSetVar2(interp, varsobj, newkey,
+ Tcl_ConcatObj(2, concat), 0);
}
}
}
@@ -613,9 +620,9 @@
{
int rslt;
Tcl_Interp *interp;
- rivet_server_conf *rsc = (rivet_server_conf *)
- ap_get_module_config(s->module_config, &rivet_module);
+ rivet_server_conf *rsc = RIVET_SERVER_CONF( s->module_config );
server_rec *sr;
+
/* Initialize TCL stuff */
Tcl_FindExecutable(NULL);
@@ -623,7 +630,8 @@
rsc->server_interp = interp; /* root interpreter */
/* Create TCL commands to deal with Apache's BUFFs. */
- *(rsc->outchannel) = Tcl_CreateChannel(&ApacheChan, "apacheout", rsc, TCL_WRITABLE);
+ *(rsc->outchannel) = Tcl_CreateChannel(&ApacheChan, "apacheout", rsc,
+ TCL_WRITABLE);
Tcl_SetStdChannel(*(rsc->outchannel), TCL_STDOUT);
Tcl_SetChannelOption(interp, *(rsc->outchannel), "-buffering", "none");
@@ -631,7 +639,8 @@
Tcl_RegisterChannel(interp, *(rsc->outchannel));
if (interp == NULL)
{
- ap_log_error(APLOG_MARK, APLOG_ERR, s, "Error in Tcl_CreateInterp, aborting\n");
+ ap_log_error(APLOG_MARK, APLOG_ERR, s,
+ "Error in Tcl_CreateInterp, aborting\n");
exit(1);
}
if (Tcl_Init(interp) == TCL_ERROR)
@@ -639,17 +648,21 @@
ap_log_error(APLOG_MARK, APLOG_ERR, s, Tcl_GetStringResult(interp));
exit(1);
}
+
Rivet_init( interp );
+
rsc->namespacePrologue = Tcl_NewStringObj(
"catch { namespace delete request }\n"
"namespace eval request { }\n"
- "proc ::request::global { args } { foreach arg $args { uplevel \"::global ::request::$arg\" } }\n", -1);
+ "proc ::request::global { args } { "
+ "foreach arg $args { uplevel \"::global ::request::$arg\" } }\n", -1);
Tcl_IncrRefCount(rsc->namespacePrologue);
#if DBG
ap_log_error(APLOG_MARK, APLOG_ERR, s, "Config string = \"%s\"",
- Tcl_GetStringFromObj(rsc->rivet_global_init_script, NULL)); /* XXX */
- ap_log_error(APLOG_MARK, APLOG_ERR, s, "Cache size = \"%d\"", *(rsc->cache_size)); /* XXX */
+ Tcl_GetStringFromObj(rsc->rivet_global_init_script, NULL));
+ ap_log_error(APLOG_MARK, APLOG_ERR, s, "Cache size = \"%d\"",
+ *(rsc->cache_size));
#endif
if (rsc->rivet_global_init_script != NULL)
@@ -692,13 +705,15 @@
if (rsc->seperate_virtual_interps != 0)
myrsc->server_interp = NULL;
} else {
- myrsc = (rivet_server_conf *) ap_get_module_config(sr->module_config, &rivet_module);
+ myrsc = RIVET_SERVER_CONF( sr->module_config );
}
if (!myrsc->server_interp)
{
- myrsc->server_interp = Tcl_CreateSlave(interp, sr->server_hostname, 0);
+ myrsc->server_interp = Tcl_CreateSlave(interp,
+ sr->server_hostname, 0);
Rivet_init( myrsc->server_interp );
- Tcl_SetChannelOption(myrsc->server_interp, *(rsc->outchannel), "-buffering", "none");
+ Tcl_SetChannelOption(myrsc->server_interp, *(rsc->outchannel),
+ "-buffering", "none");
Tcl_RegisterChannel(myrsc->server_interp, *(rsc->outchannel));
}
@@ -714,9 +729,9 @@
tcl_init_stuff(s, p);
#endif
#ifndef HIDE_RIVET_VERSION
- ap_add_version_component("mod_rivet/"RIVET_VERSION);
+ ap_add_version_component("Rivet / "RIVET_VERSION);
#else
- ap_add_version_component("mod_rivet");
+ ap_add_version_component("Rivet");
#endif /* !HIDE_RIVET_VERSION */
}
@@ -1023,8 +1038,7 @@
void
rivet_child_exit(server_rec *s, pool *p)
{
- rivet_server_conf *rsc = (rivet_server_conf *)
- ap_get_module_config(s->module_config, &rivet_module);
+ rivet_server_conf *rsc = RIVET_SERVER_CONF( s->module_config );
if( rsc->rivet_child_exit_script == NULL ) return;
1.4 +2 -0 tcl-rivet/src/mod_rivet.h
Index: mod_rivet.h
===================================================================
RCS file: /home/cvs/tcl-rivet/src/mod_rivet.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- mod_rivet.h 2001/11/08 01:37:11 1.3
+++ mod_rivet.h 2001/11/20 21:38:37 1.4
@@ -93,6 +93,8 @@
/* Macro to Tcl Objectify StringToUtf stuff */
#define STRING_TO_UTF_TO_OBJ(string, pool) Tcl_NewStringObj(StringToUtf(string, pool), -1)
+#define RIVET_SERVER_CONF(module) (rivet_server_conf *)ap_get_module_config(module, &rivet_module)
+
#define STREQU(s1, s2) (s1[0] == s2[0] && strcmp(s1, s2) == 0)
#endif
1.8 +90 -52 tcl-rivet/src/tcl_commands.c
Index: tcl_commands.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/tcl_commands.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- tcl_commands.c 2001/11/16 10:41:44 1.7
+++ tcl_commands.c 2001/11/20 21:38:37 1.8
@@ -56,8 +56,8 @@
char *filename;
struct stat finfo;
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
- rivet_server_conf *rsc = (rivet_server_conf *)
- ap_get_module_config(globals->r->server->module_config, &rivet_module);
+ rivet_server_conf *rsc =
+ RIVET_SERVER_CONF( globals->r->server->module_config );
if (objc != 2)
{
@@ -97,9 +97,7 @@
char buf[BUFSZ];
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
rivet_server_conf *rsc =
- (rivet_server_conf *)ap_get_module_config(
- globals->r->server->module_config,
- &rivet_module);
+ RIVET_SERVER_CONF( globals->r->server->module_config );
Tcl_Obj *outobj;
if (objc != 2)
@@ -118,8 +116,6 @@
} else {
Tcl_SetChannelOption(interp, fd, "-translation", "lf");
}
-/* print_headers(globals->r);
- flush_output_buffer(globals->r); */
outobj = Tcl_NewObj();
Tcl_IncrRefCount(outobj);
@@ -157,7 +153,7 @@
char *opt;
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
rivet_server_conf *rsc = (rivet_server_conf *)
- ap_get_module_config(globals->r->server->module_config, &rivet_module);
+ RIVET_SERVER_CONF( globals->r->server->module_config );
if (objc < 2)
{
@@ -166,7 +162,8 @@
}
if (*(rsc->headers_printed) != 0)
{
- Tcl_AddObjErrorInfo(interp, "Cannot manipulate headers - already sent", -1);
+ Tcl_AddObjErrorInfo(interp,
+ "Cannot manipulate headers - already sent", -1);
return TCL_ERROR;
}
opt = Tcl_GetStringFromObj(objv[1], NULL);
@@ -181,11 +178,15 @@
if (objc < 4 || objc > 14)
{
Tcl_WrongNumArgs(interp, 2, objv,
- "-name cookie-name -value cookie-value ?-expires expires? ?-domain domain? ?-path path? ?-secure on/off?");
+ "-name cookie-name -value cookie-value "
+ "?-expires expires? ?-domain domain? "
+ "?-path path? ?-secure on/off?");
return TCL_ERROR;
}
- /* SetCookie: foo=bar; EXPIRES=DD-Mon-YY HH:MM:SS; DOMAIN=domain; PATH=path; SECURE */
+ /* SetCookie: foo=bar; EXPIRES=DD-Mon-YY HH:MM:SS;
+ * DOMAIN=domain; PATH=path; SECURE
+ */
for (i = 0; i < objc - 2; i++)
{
@@ -231,7 +232,7 @@
Tcl_WrongNumArgs(interp, 2, objv, "mime/type");
return TCL_ERROR;
}
- set_header_type(globals->r, Tcl_GetStringFromObj(objv[2], (int *)NULL));
+ set_header_type(globals->r, Tcl_GetStringFromObj(objv[2],(int *)NULL));
} else if (!strcmp("numeric", opt)) /* ### numeric ### */
{
int st = 200;
@@ -246,7 +247,6 @@
else
return TCL_ERROR;
} else {
- /* XXX Tcl_WrongNumArgs(interp, 1, objv, "headers option arg ?arg ...?"); */
return TCL_ERROR;
}
return TCL_OK;
@@ -258,7 +258,7 @@
we can decide whether we wish to or not */
int
-Rivet_HGetVars(
+Rivet_LoadEnv(
ClientData clientData,
Tcl_Interp *interp,
int objc,
@@ -283,7 +283,7 @@
table_entry *env;
Tcl_Obj *EnvsObj = NULL;
- EnvsObj = Tcl_NewStringObj("::request::ENVS", -1);
+ EnvsObj = Tcl_NewStringObj("::request::env", -1);
Tcl_IncrRefCount(EnvsObj);
date = globals->r->request_time;
/* ensure that the system area which holds the cgi variables is empty */
@@ -300,8 +300,10 @@
env = (table_entry *) env_arr->elts;
/* Get the user/pass info for Basic authentication */
- (const char*)authorization = ap_table_get(globals->r->headers_in, "Authorization");
- if (authorization && !strcasecmp(ap_getword_nc(POOL, &authorization, ' '), "Basic"))
+ (const char*)authorization =
+ ap_table_get(globals->r->headers_in, "Authorization");
+ if (authorization
+ && !strcasecmp(ap_getword_nc(POOL, &authorization, ' '), "Basic"))
{
char *tmp;
char *user;
@@ -322,11 +324,15 @@
/* These were the "include vars" */
Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("DATE_LOCAL", -1),
- STRING_TO_UTF_TO_OBJ(ap_ht_time(POOL, date, timefmt, 0), POOL), 0);
+ STRING_TO_UTF_TO_OBJ(ap_ht_time(POOL,
+ date, timefmt, 0), POOL), 0);
Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("DATE_GMT", -1),
- STRING_TO_UTF_TO_OBJ(ap_ht_time(POOL, date, timefmt, 1), POOL), 0);
+ STRING_TO_UTF_TO_OBJ(ap_ht_time(POOL,
+ date, timefmt, 1), POOL), 0);
Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("LAST_MODIFIED", -1),
- STRING_TO_UTF_TO_OBJ(ap_ht_time(POOL, globals->r->finfo.st_mtime, timefmt, 0), POOL), 0);
+ STRING_TO_UTF_TO_OBJ(ap_ht_time(POOL,
+ globals->r->finfo.st_mtime,
+ timefmt, 0), POOL), 0);
Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("DOCUMENT_URI", -1),
STRING_TO_UTF_TO_OBJ(globals->r->uri, POOL), 0);
Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("DOCUMENT_PATH_INFO", -1),
@@ -336,12 +342,12 @@
pw = getpwuid(globals->r->finfo.st_uid);
if (pw)
Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("USER_NAME", -1),
- STRING_TO_UTF_TO_OBJ(ap_pstrdup(POOL, pw->pw_name), POOL), 0);
+ STRING_TO_UTF_TO_OBJ(ap_pstrdup(POOL, pw->pw_name), POOL), 0);
else
Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("USER_NAME", -1),
STRING_TO_UTF_TO_OBJ(
ap_psprintf(POOL, "user#%lu",
- (unsigned long) globals->r->finfo.st_uid), POOL), 0);
+ (unsigned long)globals->r->finfo.st_uid), POOL), 0);
#endif
if ((t = strrchr(globals->r->filename, '/')))
@@ -355,8 +361,9 @@
{
char *arg_copy = ap_pstrdup(POOL, globals->r->args);
ap_unescape_url(arg_copy);
- Tcl_ObjSetVar2(interp, EnvsObj, Tcl_NewStringObj("QUERY_STRING_UNESCAPED", -1),
- STRING_TO_UTF_TO_OBJ(ap_escape_shell_cmd(POOL, arg_copy), POOL), 0);
+ Tcl_ObjSetVar2(interp, EnvsObj,
+ Tcl_NewStringObj("QUERY_STRING_UNESCAPED", -1),
+ STRING_TO_UTF_TO_OBJ(ap_escape_shell_cmd(POOL, arg_copy), POOL), 0);
}
/* ---------------------------- */
@@ -367,7 +374,8 @@
if (!hdrs[i].key)
continue;
else {
- Tcl_ObjSetVar2(interp, EnvsObj, STRING_TO_UTF_TO_OBJ(hdrs[i].key, POOL),
+ Tcl_ObjSetVar2(interp, EnvsObj,
+ STRING_TO_UTF_TO_OBJ(hdrs[i].key, POOL),
STRING_TO_UTF_TO_OBJ(hdrs[i].val, POOL), 0);
}
}
@@ -381,9 +389,25 @@
STRING_TO_UTF_TO_OBJ(env[i].val, POOL), 0);
}
+ /* cleanup system cgi variables */
+ ap_clear_table(globals->r->subprocess_env);
+
+ return TCL_OK;
+}
+
+int
+Rivet_LoadCookies(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[])
+{
+ rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
+ int i;
+
do { /* I do this because I want some 'local' variables */
ApacheCookieJar *cookies = ApacheCookie_parse(globals->r, NULL);
- Tcl_Obj *cookieobj = Tcl_NewStringObj("::request::COOKIES", -1);
+ Tcl_Obj *cookieobj = Tcl_NewStringObj("::request::cookies", -1);
for (i = 0; i < ApacheCookieJarItems(cookies); i++) {
ApacheCookie *c = ApacheCookieJarFetch(cookies, i);
@@ -394,16 +418,11 @@
Tcl_ObjSetVar2(interp, cookieobj,
Tcl_NewStringObj(name, -1),
Tcl_NewStringObj(value, -1), 0);
-/* STRING_TO_UTF_TO_OBJ(name, POOL),
- STRING_TO_UTF_TO_OBJ(value, POOL), 0); */
}
}
} while (0);
- /* cleanup system cgi variables */
- ap_clear_table(globals->r->subprocess_env);
-
return TCL_OK;
}
@@ -434,7 +453,8 @@
if (objc < 2 || objc > 3)
{
Tcl_WrongNumArgs(interp, 1, objv,
- "(get varname|list varname|exists varname|names|number|all)");
+ "(get varname|list varname|exists varname|names"
+ "|number|all)");
return TCL_ERROR;
}
command = Tcl_GetString(objv[1]);
@@ -518,7 +538,7 @@
Tcl_IncrRefCount(result);
}
Tcl_ListObjAppendElement(interp, result,
- STRING_TO_UTF_TO_OBJ(parms[i].val, POOL));
+ STRING_TO_UTF_TO_OBJ(parms[i].val, POOL));
}
}
@@ -579,7 +599,8 @@
} else {
/* bad command */
- Tcl_AddErrorInfo(interp, "bad option: must be one of 'get, list, names, number, all'");
+ Tcl_AddErrorInfo(interp, "bad option: must be one of "
+ "'get, list, names, number, all'");
return TCL_ERROR;
}
@@ -619,7 +640,7 @@
ApacheUpload *upload;
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
rivet_server_conf *rsc = (rivet_server_conf *)
- ap_get_module_config(globals->r->server->module_config, &rivet_module);
+ RIVET_SERVER_CONF( globals->r->server->module_config );
if (objc < 2 || objc > 5)
{
@@ -634,7 +655,8 @@
char *varname = NULL;
if (objc < 4)
{
- Tcl_WrongNumArgs(interp, 2, objv, "varname channel|save filename|var varname");
+ Tcl_WrongNumArgs(interp, 2, objv,
+ "varname channel|save filename|var varname");
return TCL_ERROR;
}
varname = Tcl_GetString(objv[2]);
@@ -668,11 +690,13 @@
return TCL_ERROR;
}
- savechan = Tcl_OpenFileChannel(interp, Tcl_GetString(objv[4]), "w", 0600);
+ savechan = Tcl_OpenFileChannel(interp, Tcl_GetString(objv[4]),
+ "w", 0600);
if (savechan == NULL)
return TCL_ERROR;
else
- Tcl_SetChannelOption(interp, savechan, "-translation", "binary");
+ Tcl_SetChannelOption(interp, savechan,
+ "-translation", "binary");
chan = Tcl_MakeFileChannel((ClientData)fileno(
ApacheUpload_FILE(upload)), TCL_READABLE);
@@ -703,12 +727,14 @@
bytes = Tcl_Alloc((unsigned)ApacheUpload_size(upload));
chan = Tcl_MakeFileChannel((ClientData)fileno(
ApacheUpload_FILE(upload)), TCL_READABLE);
- Tcl_SetChannelOption(interp, chan, "-translation", "binary");
+ Tcl_SetChannelOption(interp, chan,
+ "-translation", "binary");
Tcl_SetChannelOption(interp, chan, "-encoding", "binary");
- /* put data in a variable */
+ /* Put data in a variable */
Tcl_ReadChars(chan, result, ApacheUpload_size(upload), 0);
} else {
- Tcl_AppendResult(interp, "Rivet_UploadFilesToVar is not set", NULL);
+ Tcl_AppendResult(interp,
+ "Rivet_UploadFilesToVar is not set", NULL);
return TCL_ERROR;
}
}
@@ -721,7 +747,8 @@
char *infotype = NULL;
if (objc != 4)
{
- Tcl_WrongNumArgs(interp, 2, objv, "varname exists|size|type|filename");
+ Tcl_WrongNumArgs(interp, 2, objv,
+ "varname exists|size|type|filename");
return TCL_ERROR;
}
varname = Tcl_GetString(objv[2]);
@@ -743,9 +770,11 @@
else
Tcl_SetStringObj(result, "", -1);
} else if (!strcmp(infotype, "filename")) {
- Tcl_SetStringObj(result, StringToUtf(upload->filename, POOL), -1);
+ Tcl_SetStringObj(result,
+ StringToUtf(upload->filename, POOL), -1);
} else {
- Tcl_AddErrorInfo(interp, "unknown upload info command, should be exists|size|type|filename");
+ Tcl_AddErrorInfo(interp,"unknown upload info command, should "
+ "be exists|size|type|filename");
return TCL_ERROR;
}
} else {
@@ -785,7 +814,8 @@
{
char *tble;
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
- rivet_server_conf *rsc = (rivet_server_conf *)ap_get_module_config(globals->r->server->module_config, &rivet_module);
+ rivet_server_conf *rsc =
+ RIVET_SERVER_CONF( globals->r->server->module_config );
tble = ap_psprintf(POOL,
"<table border=0 bgcolor=green><tr><td>\n"
@@ -795,8 +825,6 @@
"<tr><td><font color=\"#ffffff\">PID: %d</font><br></td></tr>\n"
"</table>\n"
"</td></tr></table>\n", *(rsc->cache_free), getpid());
-/* print_headers(globals->r);
- flush_output_buffer(globals->r); */
Tcl_WriteObj(*(rsc->outchannel), Tcl_NewStringObj(tble, -1));
return TCL_OK;
}
@@ -804,12 +832,17 @@
/* Tcl command to erase body, so that only header is returned.
Necessary for 304 responses */
-int Rivet_NoBody(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+int
+Rivet_NoBody(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[])
{
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
- rivet_server_conf *rsc = (rivet_server_conf *)
- ap_get_module_config(globals->r->server->module_config, &rivet_module);
+ rivet_server_conf *rsc =
+ RIVET_SERVER_CONF( globals->r->server->module_config );
if (*(rsc->content_sent) == 1)
return TCL_ERROR;
@@ -832,9 +865,14 @@
Rivet_Headers,
NULL,
(Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(interp,
+ "load_env",
+ Rivet_LoadEnv,
+ NULL,
+ (Tcl_CmdDeleteProc *)NULL);
Tcl_CreateObjCommand(interp,
- "hgetvars",
- Rivet_HGetVars,
+ "load_cookies",
+ Rivet_LoadCookies,
NULL,
(Tcl_CmdDeleteProc *)NULL);
Tcl_CreateObjCommand(interp,