* USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $Log: wirtcl.c,v $
- * Revision 1.8 1995/11/06 17:44:22 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.
*
};
-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)
if (argc < 2)
return TCL_OK;
- events (p, argv[1]);
- return TCL_OK;
+ return events (p, argv[1], (argc == 3) ? atoi(argv[2]) : 0);
}
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<MAX_CALLBACK; i++)
{
callback_table[i].r_handle = NULL;
}
-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;
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))
{
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);
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);
}
}
}