You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_dtcl-cvs@tcl.apache.org by da...@apache.org on 2001/06/06 18:12:23 UTC
cvs commit: tcl-moddtcl mod_dtcl.c mod_dtcl.h
davidw 01/06/06 09:12:22
Modified: . mod_dtcl.c mod_dtcl.h
Log:
Added Valerio's patch enabling error message checking/printing for .tcl files
Submitted by: Valerio Gionco <va...@most.it>
Revision Changes Path
1.30 +39 -29 tcl-moddtcl/mod_dtcl.c
Index: mod_dtcl.c
===================================================================
RCS file: /home/cvs/tcl-moddtcl/mod_dtcl.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- mod_dtcl.c 2001/05/21 19:49:19 1.29
+++ mod_dtcl.c 2001/06/06 16:12:15 1.30
@@ -58,7 +58,7 @@
* University of Illinois, Urbana-Champaign.
*/
-/* $Id: mod_dtcl.c,v 1.29 2001/05/21 19:49:19 davidw Exp $ */
+/* $Id: mod_dtcl.c,v 1.30 2001/06/06 16:12:15 davidw Exp $ */
/* mod_dtcl.c by David Welton <da...@apache.org> - originally mod_include. */
/* See http://tcl.apache.org/mod_dtcl/credits.ttml for additional credits. */
@@ -328,7 +328,8 @@
}
/* Function to be used should we desire to upload files to a variable */
-int dtcl_upload_hook(void *ptr, char *buf, int len, const ApacheUpload *upload)
+
+int dtcl_upload_hook(void *ptr, char *buf, int len, ApacheUpload *upload)
{
Tcl_Interp *interp = ptr;
static void *oldptr;
@@ -365,7 +366,7 @@
char *hashKey;
Tcl_HashEntry *entry;
- Tcl_Obj *cmdObjPtr;
+ Tcl_Obj *cmdObjPtr = NULL;
Tcl_Interp *interp = GETREQINTERP(r);
@@ -425,24 +426,19 @@
return TCL_ERROR;
end:
- Tcl_EvalObj(interp, (cmdObjPtr));
+ return execute_and_check(interp, (cmdObjPtr), r);
} else {
- Tcl_EvalObj(interp, (Tcl_Obj *)Tcl_GetHashValue(entry));
+ return execute_and_check(interp, (Tcl_Obj *)Tcl_GetHashValue(entry), r);
}
#else
Tcl_EvalFile(interp, r->filename);
#endif /* 1 */
- print_headers(global_rr);
- flush_output_buffer(global_rr);
-
- return OK;
}
/* Parse and execute a ttml file */
int send_parsed_file(request_rec *r, char *filename, struct stat *finfo, int toplevel)
{
- char *errorinfo;
char *hashKey;
int isNew;
@@ -639,30 +635,44 @@
return OK;
#endif
+ return(execute_and_check(interp, outbuf, r));
+}
+
+/* Calls Tcl_EvalObj() and checks for errors; prints the error buffer if any. */
+
+int execute_and_check(Tcl_Interp *interp, Tcl_Obj *outbuf, request_rec *r)
+{
+ char *errorinfo;
+ dtcl_server_conf *dsc = NULL;
+
+ dsc = (dtcl_server_conf *) ap_get_module_config(r->server->module_config, &dtcl_module);
+
if (Tcl_EvalObj(interp, outbuf) == TCL_ERROR)
- {
- print_headers(global_rr);
- flush_output_buffer(global_rr);
- if (dsc->dtcl_error_script)
- {
- if (Tcl_EvalObj(interp, dsc->dtcl_error_script) == TCL_ERROR)
- print_error(r, 1, "<b>Tcl_ErrorScript failed!</b>");
- } else {
- /* default action */
- errorinfo = Tcl_GetVar(interp, "errorInfo", 0);
- print_error(r, 0, errorinfo);
- print_error(r, 1, "<p><b>OUTPUT BUFFER:</b></p>");
- print_error(r, 0, Tcl_GetStringFromObj(outbuf, (int *)NULL));
- }
-/* "</pre><b>OUTPUT BUFFER</b><pre>\n",
- Tcl_GetStringFromObj(outbuf, (int *)NULL)); */
+ {
+ print_headers(global_rr);
+ flush_output_buffer(global_rr);
+ if (dsc->dtcl_error_script)
+ {
+ if (Tcl_EvalObj(interp, dsc->dtcl_error_script) == TCL_ERROR)
+ print_error(r, 1, "<b>Tcl_ErrorScript failed!</b>");
+ } else {
+ /* default action */
+ errorinfo = Tcl_GetVar(interp, "errorInfo", 0);
+ print_error(r, 0, errorinfo);
+ print_error(r, 1, "<p><b>OUTPUT BUFFER:</b></p>");
+ print_error(r, 0, Tcl_GetStringFromObj(outbuf, (int *)NULL));
+ }
+/* "</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 */
- print_headers(global_rr);
- flush_output_buffer(global_rr);
+ /* We make sure to flush the output if buffer_add was the only output */
+ print_headers(global_rr);
+ flush_output_buffer(global_rr);
}
return OK;
}
+
+
/* Set things up to execute a file, then execute */
1.4 +1 -1 tcl-moddtcl/mod_dtcl.h
Index: mod_dtcl.h
===================================================================
RCS file: /home/cvs/tcl-moddtcl/mod_dtcl.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- mod_dtcl.h 2001/05/21 19:49:20 1.3
+++ mod_dtcl.h 2001/06/06 16:12:18 1.4
@@ -57,13 +57,13 @@
int memwrite(obuff *, char *, int);
int send_content(request_rec *);
int send_parsed_file(request_rec *, char *, struct stat*, int);
+int execute_and_check(Tcl_Interp *interp, Tcl_Obj *outbuf, request_rec *r);
int send_tcl_file(request_rec *, char *, struct stat*);
int set_header_type(request_rec *, char *);
int print_headers(request_rec *);
int print_error(request_rec *, int, char *);
int flush_output_buffer(request_rec *);
void tcl_init_stuff(server_rec *s, pool *p);
-
char *StringToUtf(char *input);
/* Macro to Tcl Objectify StringToUtf stuff */