X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=tclmain.c;h=92f240dec385a37dbe2d95e9d2881c34f3d4001d;hb=694f7bbadeaa3580f00275fb98becfe9e580f3b2;hp=6c085daaeec12f677ed5e76dc3102d33e181346b;hpb=81c7aeedca99611b86c068f0663b322be3800248;p=ir-tcl-moved-to-github.git diff --git a/tclmain.c b/tclmain.c index 6c085da..92f240d 100644 --- a/tclmain.c +++ b/tclmain.c @@ -1,14 +1,33 @@ /* * IR toolkit for tcl/tk * (c) Index Data 1995 + * See the file LICENSE for details. + * Sebastian Hammer, Adam Dickmeiss + * + * $Log: tclmain.c,v $ + * Revision 1.7 1995-06-21 11:04:54 adam + * Uses GNU autoconf 2.3. + * Install procedure implemented. + * boook bitmaps moved to sub directory bitmaps. + * + * Revision 1.6 1995/05/29 08:44:28 adam + * Work on delete of objects. + * + * Revision 1.5 1995/03/20 08:53:30 adam + * Event loop in tclmain.c rewritten. New method searchStatus. + * + * Revision 1.4 1995/03/17 07:50:31 adam + * Headers have changed a little. * - * $Id: tclmain.c,v 1.3 1995-03-09 08:35:58 adam Exp $ */ +#include #include #include +#if HAVE_SYS_SELECT_H +#include +#endif #include -#include #include @@ -16,9 +35,19 @@ static char *fileName = NULL; -static fd_set fdset_tcl; +/* select(2) callbacks */ +struct callback { + void (*r_handle)(void *p); + void (*w_handle)(void *p); + void (*x_handle)(void *p); + void *obj; +}; +#define MAX_CALLBACK 200 -void tcl_mainloop (Tcl_Interp *interp); +static struct callback callback_table[MAX_CALLBACK]; +static int max_fd = 3; /* don't worry: it will grow... */ + +void tcl_mainloop (Tcl_Interp *interp, int interactive); int Tcl_AppInit (Tcl_Interp *interp) { @@ -33,6 +62,7 @@ int main (int argc, char **argv) { Tcl_Interp *interp; int code; + int i; interp = Tcl_CreateInterp(); Tcl_SetVar (interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); @@ -42,6 +72,12 @@ int main (int argc, char **argv) if (Tcl_AppInit(interp) != TCL_OK) { fprintf(stderr, "Tcl_AppInit failed: %s\n", interp->result); } + for (i=0; iresult); if (code != TCL_OK) exit (1); + tcl_mainloop (interp, 0); + } + else + { + Tcl_SetVar (interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); + tcl_mainloop (interp, 1); } - Tcl_SetVar (interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); - tcl_mainloop (interp); exit (0); } -struct callback { - void (*handle)(void *p); - void *obj; -}; - -#define MAX_CALLBACK 20 - -struct callback callback_table[MAX_CALLBACK]; - -void tcl_mainloop (Tcl_Interp *interp) +void tcl_mainloop (Tcl_Interp *interp, int interactive) { int i; int res; - int count; - char input_buf[256]; Tcl_DString command; + static fd_set fdset_tcl_r; + static fd_set fdset_tcl_w; + static fd_set fdset_tcl_x; + int min_fd; - for (i=0; i max_fd) + max_fd = fd; +} + +void ir_select_add_write (int fd, void *obj) +{ + callback_table[fd].w_handle = ir_select_write; + if (fd > max_fd) + max_fd = fd; +} + +void ir_select_remove_write (int fd, void *obj) +{ + callback_table[fd].w_handle = NULL; } void ir_select_remove (int fd, void *obj) { - callback_table[fd].handle = NULL; + callback_table[fd].r_handle = NULL; + callback_table[fd].w_handle = NULL; + callback_table[fd].x_handle = NULL; }