X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=www%2Fwirtcl.c;h=9939df8b53d3808407d7b773d1f57c4158406e3e;hb=e1652b5355c529be09d2c847ca0354bfb8db8067;hp=e85af445eb6219482ee737deca71fbd0ca909fea;hpb=150d836eb46d0dde8fedeb77fc7fd4ef6eafba4f;p=egate.git diff --git a/www/wirtcl.c b/www/wirtcl.c index e85af44..9939df8 100644 --- a/www/wirtcl.c +++ b/www/wirtcl.c @@ -41,7 +41,16 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wirtcl.c,v $ - * Revision 1.7 1995/11/02 16:35:37 adam + * Revision 1.9 1995/11/07 14:56:59 adam + * Work on search in multiple targets. + * New wtcl command: wlog. + * Optional timeout parameter to zwait. + * + * Revision 1.8 1995/11/06 17:44:22 adam + * State reestablised when shell restarts. History of previous + * result sets. + * + * Revision 1.7 1995/11/02 16:35:37 adam * Bug fixes and select on FIFOs in wcgi - doesn't really work! * * Revision 1.6 1995/11/01 16:15:47 adam @@ -86,11 +95,15 @@ static void *do_create (WCLIENT wcl, void *args); static int do_exec (const char *fname, char *parms, void *mydata); +static int do_load (char *parms, void *mydata); +static int do_save (char *parms, void *mydata); static struct w_interp_type w_interp_t = { "irtcl", do_create, - do_exec + do_exec, + do_load, + do_save }; W_Interp_Type w_interp_irtcl = &w_interp_t; @@ -105,7 +118,7 @@ struct tcl_info { }; -static int events (struct tcl_info *p, char *waitVar); +static int events (struct tcl_info *p, char *waitVar, int tout); static int proc_zwait_invoke (ClientData clientData, Tcl_Interp *interp, int argc, char **argv) @@ -114,8 +127,7 @@ static int proc_zwait_invoke (ClientData clientData, Tcl_Interp *interp, if (argc < 2) return TCL_OK; - events (p, argv[1]); - return TCL_OK; + return events (p, argv[1], (argc == 3) ? atoi(argv[2]) : 0); } @@ -177,7 +189,7 @@ static int do_exec (const char *fname, char *parms, void *mydata) } -static int events (struct tcl_info *p, char *waitVar) +static int events (struct tcl_info *p, char *waitVar, int tout) { int r, i; char *cp; @@ -207,6 +219,16 @@ static int events (struct tcl_info *p, char *waitVar) gw_log (GW_LOG_DEBUG, mod, "Waiting %s=%s", waitVar, waitVarVal); while (1) { + struct timeval to, *top; + if (tout > 0) + { + to.tv_usec = 0; + to.tv_sec = tout; + top = &to; + } + else + top = 0; + if (!(cp = Tcl_GetVar (p->interp, waitVar, 0)) || strcmp (cp, waitVarVal)) { @@ -244,7 +266,7 @@ static int events (struct tcl_info *p, char *waitVar) FD_SET (fifo_in, &fdset_tcl_r); #endif if ((r = select(max_fd+1, &fdset_tcl_r, &fdset_tcl_w, - &fdset_tcl_x, NULL)) < 0) + &fdset_tcl_x, top)) < 0) { gw_log (GW_LOG_ERRNO|GW_LOG_FATAL, mod, "select"); exit(1); @@ -252,12 +274,14 @@ static int events (struct tcl_info *p, char *waitVar) if (!r) { gw_log (GW_LOG_DEBUG, mod, "timeout"); - break; + free (waitVarVal); + return TCL_ERROR; } if (FD_ISSET (fifo_in, &fdset_tcl_r)) { gw_log (GW_LOG_DEBUG, mod, "FIFO closed"); - break; + free (waitVarVal); + return TCL_ERROR; } for (i=0; i<=max_fd; i++) { @@ -310,3 +334,18 @@ void ir_select_remove (int fd, void *obj) callback_table[fd].w_handle = NULL; callback_table[fd].x_handle = NULL; } + +static int do_load (char *parms, void *mydata) +{ + struct tcl_info *p = mydata; + + return w_interp_load_state (p->w_interp, parms); +} + +static int do_save (char *parms, void *mydata) +{ + struct tcl_info *p = mydata; + + return w_interp_save_state (p->w_interp, parms); +} +