* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wtcl.c,v $
+ * Revision 1.18 1997/01/24 13:13:13 adam
+ * Implemnted egw_source and added a "raw" option to the URL.
+ * Fixed a bug in the buffering system of wproto; the macro wo_putc could
+ * override memory if it was the first HTML generating function called.
+ *
* Revision 1.17 1996/05/31 08:02:56 adam
* Bug fix: egw_enc encoded '/' - it shouldn't.
*
WCLIENT wcl;
};
+static int exec_file (const char *fname, struct tcl_info *p);
+
Tcl_Interp *w_interp_tcl_get (W_Interp w_interp)
{
struct tcl_info *p;
return TCL_OK;
}
+static int proc_source (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ struct tcl_info *p = (struct tcl_info*) clientData;
+ int r;
+
+ if (argc != 2)
+ {
+ Tcl_AppendResult (p->interp,
+ "wrong # args: should be egw_source file", NULL);
+ return TCL_ERROR;
+ }
+ r = exec_file (argv[1], p);
+ if (r == -2)
+ {
+ Tcl_AppendResult (p->interp, "egw_source: couldn't source ",
+ argv[1], NULL);
+ return TCL_ERROR;
+ }
+ else if (r == -1)
+ {
+ Tcl_AppendResult (p->interp, "egw_source: Tcl error in script ",
+ argv[1], NULL);
+ return TCL_ERROR;
+ }
+ return TCL_OK;
+}
+
+
int Tcl_AppInit (Tcl_Interp *interp)
{
if (Tcl_Init (interp) == TCL_ERROR)
Tcl_CreateCommand (p->interp, "egw_enc", proc_enc, p, NULL);
Tcl_CreateCommand (p->interp, "egw_dec", proc_dec, p, NULL);
Tcl_CreateCommand (p->interp, "egw_prog", proc_prog, p, NULL);
+ Tcl_CreateCommand (p->interp, "egw_source", proc_source, p, NULL);
sprintf (tmp_str, "%d", wcl->id);
Tcl_SetVar (p->interp, "sessionId", tmp_str, TCL_GLOBAL_ONLY);
return p;
wo_printf (p->wcl, "<xmp>\n%s</xmp>\n<hr>\n", msg);
}
-static int tcl_exec (const char *fname, char *parms,
- struct tcl_info *p, FILE *inf, int *lineno)
+static int tcl_exec (const char *fname, struct tcl_info *p, FILE *inf,
+ int *lineno)
{
int c, escape = 0, level = 0;
int r, fbuf_ptr = 0;
return r;
}
-static int do_exec (const char *fname, char *parms, void *mydata)
+static int exec_file (const char *fname, struct tcl_info *p)
{
- struct tcl_info *p = mydata;
int c, escape = 0;
int lineno = 1;
FILE *inf = fopen (fname, "r");
gw_log (GW_LOG_WARN|GW_LOG_ERRNO, mod, "open %s", fname);
return -1;
}
- Tcl_SetVar (p->interp, "sessionParms", parms, TCL_GLOBAL_ONLY);
while ((c = getc(inf)) != EOF)
{
if (c == '\\')
wo_putc (p->wcl, c);
else
{
- int r = tcl_exec (fname, parms, p, inf, &lineno);
+ int r = tcl_exec (fname, p, inf, &lineno);
if (r == TCL_RETURN)
{
fclose (inf);
return 0;
}
+static int do_exec (const char *fname, char *parms, void *mydata)
+{
+ struct tcl_info *p = mydata;
+
+ Tcl_SetVar (p->interp, "sessionParms", parms, TCL_GLOBAL_ONLY);
+ return exec_file (fname, p);
+}
static int do_load (char *parms, void *mydata)
{