X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=www%2Fwirtcl.c;h=c0ae80e53cd65936c81a5046906e385470943473;hb=d1fc0ff84894bba24f827a81597717e9f69b6c06;hp=e85af445eb6219482ee737deca71fbd0ca909fea;hpb=150d836eb46d0dde8fedeb77fc7fd4ef6eafba4f;p=egate.git diff --git a/www/wirtcl.c b/www/wirtcl.c index e85af44..c0ae80e 100644 --- a/www/wirtcl.c +++ b/www/wirtcl.c @@ -41,7 +41,30 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wirtcl.c,v $ - * Revision 1.7 1995/11/02 16:35:37 adam + * Revision 1.13 1996/01/24 08:26:54 adam + * All tcl commands prefixed with egw_ (except the html command). + * + * Revision 1.12 1996/01/12 10:05:18 adam + * If script name ends with ';' HTTP/GET/Expires will be defined. + * The cgi interface only reads final handshake if response from + * server (shell) was zero-terminated [If it isn't it probably died]. + * + * Revision 1.11 1996/01/09 16:16:49 adam + * Port to OSF/1. Gif references moved from /gif/ to /egwgif/. + * + * Revision 1.10 1996/01/09 10:46:50 adam + * New defines: LOGDIR/EGWDIR/CGIDIR set in Makefile. + * + * 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 +109,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 +132,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 +141,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); } @@ -154,9 +180,9 @@ static void *do_create (WCLIENT wcl, void *args) gw_log (GW_LOG_FATAL, mod, "Cannot make Irtcl_Interp"); exit (1); } - log_init(LOG_ALL, "irtcl", "/usr/local/etc/httpd/logs/irtcl_log"); + log_init(LOG_ALL, "irtcl", LOGDIR "/irtcl_log"); /* initialize irtcl */ - Tcl_CreateCommand (p->interp, "zwait", proc_zwait_invoke, p, NULL); + Tcl_CreateCommand (p->interp, "egw_wait", proc_zwait_invoke, p, NULL); for (i=0; i 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 +280,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,29 +288,31 @@ 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++) { if (FD_ISSET (i, &fdset_tcl_r)) { - assert (callback_table[i].r_handle); - (*callback_table[i].r_handle) (callback_table[i].obj); + if (callback_table[i].r_handle) + (*callback_table[i].r_handle) (callback_table[i].obj); } if (FD_ISSET (i, &fdset_tcl_w)) { - assert (callback_table[i].w_handle); - (*callback_table[i].w_handle) (callback_table[i].obj); + if (callback_table[i].w_handle) + (*callback_table[i].w_handle) (callback_table[i].obj); } if (FD_ISSET (i, &fdset_tcl_x)) { - assert (callback_table[i].x_handle); - (*callback_table[i].x_handle) (callback_table[i].obj); + if (callback_table[i].x_handle) + (*callback_table[i].x_handle) (callback_table[i].obj); } } } @@ -310,3 +348,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); +} +