diff options
author | Marc Horowitz <marc@mit.edu> | 1989-11-01 20:02:01 +0000 |
---|---|---|
committer | Marc Horowitz <marc@mit.edu> | 1989-11-01 20:02:01 +0000 |
commit | d13d8a046838ce3d0e2643bb5b49f2ff77d679ca (patch) | |
tree | 05737bc11e3461836ce817939b9129ed58545ac7 /zwgc/mux.h | |
parent | fd994e4099ad66fb3bf26cd636ca5d5cae72da68 (diff) |
Initial revision
Diffstat (limited to 'zwgc/mux.h')
-rw-r--r-- | zwgc/mux.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/zwgc/mux.h b/zwgc/mux.h new file mode 100644 index 0000000..a0741c9 --- /dev/null +++ b/zwgc/mux.h @@ -0,0 +1,56 @@ +#ifndef mux_MODULE +#define mux_MODULE + +/* + * MAX_SOURCES - the greatest file descriptor # that can be waited on minus one + * This can not exceed FD_SETSIZE from <sys/types.h>. + */ + +#define MAX_SOURCES 32 + +/* + * mux_end_loop_p - Setting this to true during a mux_loop causes the mux_loop + * to be exited. + */ + +extern int mux_end_loop_p; + +/* + * void mux_init() + * Requires: mux_init has never been called before + * Effects: Initializes the mux module. Must be called before + * any other mux call. + */ + +extern void mux_init(); + +/* + * void mux_add_input_source(int descriptior; void (*handler)(); void *arg) + * Requires: 0<=descriptor<MAX_SOURCES, mux_init has been called + * Modifies: Removes the previous input handler if any for descriptor + * Effects: Registers handler as the input handler for file descriptor + * descriptor. When mux_loop() is running and input is + * available on descriptor, handler will be called with + * argument arg. + */ + +extern void mux_add_input_source(); + +/* + * void mux_loop() + * Requires: mux_init has been called. + * Effects: Loops until mux_end_loop_p becomes true. (Sets + * mux_end_loop_p false to start). Whenever input is + * available on an input source which has a registered + * handler (see mux_add_input_source), that handler is + * called with its argument. It is guarenteed that if + * input is available on a source, its respective input + * handler, if any, will eventually be called. No other + * ordering guarentees are made. When some signal handler + * or input handler eventually sets mux_end_loop_p to + * true, we return. + */ + +extern void mux_loop(); + +#endif |