]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/zwgc/mux.h
r4264@bucket (orig r254): kcr | 2008-01-20 22:11:44 -0500
[1ts-debian.git] / zephyr / zwgc / mux.h
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It is one of the source files comprising zwgc, the Zephyr WindowGram
3  * client.
4  *
5  *      Created by:     Marc Horowitz <marc@athena.mit.edu>
6  *
7  *      $Id$
8  *
9  *      Copyright (c) 1989 by the Massachusetts Institute of Technology.
10  *      For copying and distribution information, see the file
11  *      "mit-copyright.h".
12  */
13
14
15 #include <zephyr/mit-copyright.h>
16
17 #ifndef mux_MODULE
18 #define mux_MODULE
19
20 /*
21  * MAX_SOURCES - the greatest file descriptor # that can be waited on minus one
22  *               This can not exceed FD_SETSIZE from <sys/types.h>.
23  */
24
25 #define  MAX_SOURCES  32
26
27 /*
28  * mux_end_loop_p - Setting this to true during a mux_loop causes the mux_loop
29  *                  to be exited.
30  */
31
32 extern int mux_end_loop_p;
33
34 /*
35  *    void mux_init()
36  *        Requires: mux_init has never been called before
37  *        Effects: Initializes the mux module.  Must be called before
38  *                 any other mux call.
39  */
40
41 extern void mux_init(void);
42
43 /*
44  *    void mux_add_input_source(int descriptior; void (*handler)(); void *arg)
45  *        Requires: 0<=descriptor<MAX_SOURCES, mux_init has been called
46  *        Modifies: Removes the previous input handler if any for descriptor
47  *        Effects: Registers handler as the input handler for file descriptor
48  *                 descriptor.  When mux_loop() is running and input is
49  *                 available on descriptor, handler will be called with
50  *                 argument arg.
51  */
52
53 extern void mux_add_input_source(int, void (*)(void *), void *);
54
55 /*
56  *    void mux_loop()
57  *        Requires: mux_init has been called.
58  *        Effects: Loops until mux_end_loop_p becomes true.  (Sets
59  *                 mux_end_loop_p false to start).  Whenever input is
60  *                 available on an input source which has a registered
61  *                 handler (see mux_add_input_source), that handler is
62  *                 called with its argument.  It is guarenteed that if
63  *                 input is available on a source, its respective input
64  *                 handler, if any, will eventually be called.  No other
65  *                 ordering guarentees are made.  When some signal handler
66  *                 or input handler eventually sets mux_end_loop_p to
67  *                 true, we return.
68  */
69
70 extern void mux_loop(void);
71
72 #endif