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/04/20 01:03:44 UTC
cvs commit: tcl-rivet/src TclWeb.h TclWebapache.c rivetCore.c
damonc 02/04/19 16:03:44
Modified: . ChangeLog TODO
src TclWeb.h TclWebapache.c rivetCore.c
Log:
* src/TclWebapache.c
Added 'TclWeb_GetVirtualFile' command which returns the full
path to a virtual file.
* src/rivetCore.c
Added command 'virtual_filename' to return the full path to a
virtual file.
Added -virtual option to include and parse commands to enable
them to parse a virtual file which is relative to the webserver.
Revision Changes Path
1.54 +12 -0 tcl-rivet/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /home/cvs/tcl-rivet/ChangeLog,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- ChangeLog 26 Mar 2002 23:20:25 -0000 1.53
+++ ChangeLog 19 Apr 2002 23:03:43 -0000 1.54
@@ -1,3 +1,15 @@
+2002-04-19 Damon J. Courtney <da...@unreality.com>
+ * src/TclWebapache.c
+ Added 'TclWeb_GetVirtualFile' command which returns the full
+ path to a virtual file.
+
+ * src/rivetCore.c
+ Added command 'virtual_filename' to return the full path to a
+ virtual file.
+
+ Added -virtual option to include and parse commands to enable
+ them to parse a virtual file which is relative to the webserver.
+
2002-03-26 Damon J. Courtney <da...@unreality.com>
* rivet/packages/form
1.11 +0 -3 tcl-rivet/TODO
Index: TODO
===================================================================
RCS file: /home/cvs/tcl-rivet/TODO,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TODO 22 Mar 2002 01:11:37 -0000 1.10
+++ TODO 19 Apr 2002 23:03:43 -0000 1.11
@@ -15,9 +15,6 @@
* Swipe include_* from NWS and rework it like: include ?-virtual?
?-noparse? file
-* Add a '-virtual' option to include and parse. This will include or
- parse a file based on the server root.
-
* Re-write load_file. This basically loads an entire .tcl file into
the current document instead of sourcing it. This will allow us to
cache even pages which only source a huge .tcl file. load_virtual
1.14 +3 -1 tcl-rivet/src/TclWeb.h
Index: TclWeb.h
===================================================================
RCS file: /home/cvs/tcl-rivet/src/TclWeb.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TclWeb.h 22 Mar 2002 02:08:32 -0000 1.13
+++ TclWeb.h 19 Apr 2002 23:03:43 -0000 1.14
@@ -5,7 +5,7 @@
* Common API layer.
*/
-/* $Id: TclWeb.h,v 1.13 2002/03/22 02:08:32 damonc Exp $ */
+/* $Id: TclWeb.h,v 1.14 2002/04/19 23:03:43 damonc Exp $ */
/* Error wrappers */
#define ER1 "<hr><p><code><pre>\n"
@@ -237,6 +237,8 @@
Tcl_Obj * TclWeb_StringToUtfToObj(char *in, TclWebRequest *req);
char *TclWeb_GetEnvVar( TclWebRequest *req, char * );
+
+char *TclWeb_GetVirtualFile( TclWebRequest *req, char *virtualname );
/* output/write/flush? */
1.27 +18 -1 tcl-rivet/src/TclWebapache.c
Index: TclWebapache.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/TclWebapache.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- TclWebapache.c 26 Mar 2002 19:41:39 -0000 1.26
+++ TclWebapache.c 19 Apr 2002 23:03:43 -0000 1.27
@@ -7,10 +7,12 @@
* operations.
*/
-/* $Id: TclWebapache.c,v 1.26 2002/03/26 19:41:39 damonc Exp $ */
+/* $Id: TclWebapache.c,v 1.27 2002/04/19 23:03:43 damonc Exp $ */
#include <tcl.h>
+#include <httpd.h>
+#include <http_request.h>
#include "apache_request.h"
#include "mod_rivet.h"
#include "TclWeb.h"
@@ -574,4 +576,19 @@
}
return val;
+}
+
+char *
+TclWeb_GetVirtualFile( TclWebRequest *req, char *virtualname )
+{
+ request_rec *apreq;
+ char *filename = NULL;
+
+ apreq = ap_sub_req_lookup_uri( virtualname, req->req );
+
+ if( apreq->status == 200 && apreq->finfo.st_mode != 0 ) {
+ filename = apreq->filename;
+ }
+ if( apreq != NULL ) ap_destroy_sub_req( apreq );
+ return( filename );
}
1.23 +53 -11 tcl-rivet/src/rivetCore.c
Index: rivetCore.c
===================================================================
RCS file: /home/cvs/tcl-rivet/src/rivetCore.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- rivetCore.c 22 Mar 2002 02:08:32 -0000 1.22
+++ rivetCore.c 19 Apr 2002 23:03:44 -0000 1.23
@@ -2,7 +2,7 @@
* rivetCore.c - Core commands which are compiled into mod_rivet itself.
*/
-/* $Id: rivetCore.c,v 1.22 2002/03/22 02:08:32 damonc Exp $ */
+/* $Id: rivetCore.c,v 1.23 2002/04/19 23:03:44 damonc Exp $ */
#include "httpd.h"
#include "http_config.h"
@@ -64,13 +64,23 @@
struct stat finfo;
rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
- if (objc != 2)
+ if( objc < 2 || objc > 3 )
{
- Tcl_WrongNumArgs(interp, 1, objv, "filename");
+ Tcl_WrongNumArgs(interp, 1, objv, "?-virtual? filename");
return TCL_ERROR;
}
- filename = Tcl_GetStringFromObj (objv[1], (int *)NULL);
+ if( objc == 2 ) {
+ 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 (!strcmp(filename, globals->r->filename))
{
Tcl_AddErrorInfo(interp, "Cannot recursively call the same file!");
@@ -82,10 +92,11 @@
Tcl_AddErrorInfo(interp, Tcl_PosixError(interp));
return TCL_ERROR;
}
- if (Rivet_ParseExecFile(globals->req, filename, 0) == TCL_OK)
+ if (Rivet_ParseExecFile(globals->req, filename, 0) == TCL_OK) {
return TCL_OK;
- else
+ } else {
return TCL_ERROR;
+ }
}
/* Tcl command to include flat files */
@@ -100,16 +111,28 @@
int sz;
Tcl_Channel fd;
Tcl_Obj *outobj;
+ char *filename;
- if (objc != 2)
+ rivet_interp_globals *globals = Tcl_GetAssocData(interp, "rivet", NULL);
+
+ if( objc < 2 || objc > 3 )
{
- Tcl_WrongNumArgs(interp, 1, objv, "filename");
+ Tcl_WrongNumArgs(interp, 1, objv, "?-virtual? filename");
return TCL_ERROR;
}
- fd = Tcl_OpenFileChannel(interp,
- Tcl_GetStringFromObj(objv[1], (int *)NULL),
- "r", 0664);
+ if( objc == 2 ) {
+ 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) );
+ }
+
+ fd = Tcl_OpenFileChannel(interp, filename, "r", 0664);
if (fd == NULL)
{
@@ -534,6 +557,24 @@
return TCL_OK;
}
+TCL_CMD_HEADER( Rivet_VirtualFilenameCmd )
+{
+ rivet_interp_globals *globals = Tcl_GetAssocData( interp, "rivet", NULL );
+ char *filename;
+ char *virtual;
+
+ if( objc != 2 ) {
+ Tcl_WrongNumArgs( interp, 1, objv, "filename" );
+ return TCL_ERROR;
+ }
+
+ virtual = Tcl_GetStringFromObj( objv[1], NULL );
+ filename = TclWeb_GetVirtualFile( globals->req, virtual );
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj( filename, -1 ) );
+ return TCL_OK;
+}
+
int
Rivet_InitCore( Tcl_Interp *interp )
{
@@ -584,6 +625,7 @@
(Tcl_CmdDeleteProc *)NULL);
TCL_OBJ_CMD( "abort_page", Rivet_AbortPageCmd );
+ TCL_OBJ_CMD( "virtual_filename", Rivet_VirtualFilenameCmd );
return TCL_OK;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: rivet-dev-unsubscribe@tcl.apache.org
For additional commands, e-mail: rivet-dev-help@tcl.apache.org