X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=www%2Fwtcl.c;fp=www%2Fwtcl.c;h=8053f24b92cde92b6519dc262dc9052a2408941e;hb=1140389ab96fc8ca7bc9c8dc642adbcec625f4a6;hp=a3fa1f6dae502606c8526823e98e0dfa6f79afd3;hpb=5a0f09e655bd92bcc19d417b8fffc0df1aaef61e;p=egate.git diff --git a/www/wtcl.c b/www/wtcl.c index a3fa1f6..8053f24 100644 --- a/www/wtcl.c +++ b/www/wtcl.c @@ -41,6 +41,10 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wtcl.c,v $ + * Revision 1.19 1997/01/27 11:27:17 adam + * Implemented a new command, egw_clear, to clear http output cache. + * Changed prototype for function wo_clear. + * * 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 @@ -404,6 +408,14 @@ static int proc_source (ClientData clientData, Tcl_Interp *interp, return TCL_OK; } +static int proc_clear (ClientData clientData, Tcl_Interp *interp, + int argc, char **argv) +{ + struct tcl_info *p = (struct tcl_info*) clientData; + + wo_clear (p->wcl); + return TCL_OK; +} int Tcl_AppInit (Tcl_Interp *interp) { @@ -445,6 +457,7 @@ static void *do_create (WCLIENT wcl, void *args) 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); + Tcl_CreateCommand (p->interp, "egw_clear", proc_clear, p, NULL); sprintf (tmp_str, "%d", wcl->id); Tcl_SetVar (p->interp, "sessionId", tmp_str, TCL_GLOBAL_ONLY); return p; @@ -524,6 +537,45 @@ static int tcl_exec (const char *fname, struct tcl_info *p, FILE *inf, return r; } +static int var_ref (struct tcl_info *p, FILE *inf) +{ + int c, i = 0; + char name[32], *vp; + + c = getc (inf); + if (c == '{') + { + while ((c = getc(inf)) != EOF) + { + if (c == '\n') + break; + if (c == '}') + { + c = getc (inf); + break; + } + if (i < 31) + name[i++] = c; + } + } + else + { + while (c != EOF) + { + if (c != '(' && c != ')' && c != '-' && c != '_' && !isalnum(c)) + break; + if (i < 31) + name[i++] = c; + c = getc (inf); + } + } + name[i] = '\0'; + vp = Tcl_GetVar (p->interp, name, 0); + if (vp) + wo_puts (p->wcl, vp); + return c; +} + static int exec_file (const char *fname, struct tcl_info *p) { int c, escape = 0; @@ -536,12 +588,25 @@ static int exec_file (const char *fname, struct tcl_info *p) gw_log (GW_LOG_WARN|GW_LOG_ERRNO, mod, "open %s", fname); return -1; } - while ((c = getc(inf)) != EOF) + c = getc (inf); + while (c != EOF) { - if (c == '\\') - escape = 1; - else if (c == '{') + switch (c) { + case '\\': + escape = 1; + c = getc (inf); + break; + case '$': + if (escape) + { + c = getc (inf); + wo_putc (p->wcl, c); + } + else + c = var_ref (p, inf); + break; + case '{': if (escape) wo_putc (p->wcl, c); else @@ -559,13 +624,14 @@ static int exec_file (const char *fname, struct tcl_info *p) } } escape = 0; - } - else - { + c = getc (inf); + break; + default: if (c == '\n') lineno++; escape = 0; wo_putc (p->wcl, c); + c = getc (inf); } } fclose (inf);