|
|
#include "mit-copyright.h"
#include "mux.h"
#include "error.h"
#include "main.h"
#include "pointer.h"
Go to the source code of this file.
Functions | |
void | mux_init () |
void | mux_add_input_source (int descriptor, void(*)() handler, pointer arg) |
void | mux_delete_input_source (int descriptor) |
void | mux_loop () |
Variables | |
int | mux_end_loop_p |
|
Definition at line 90 of file mux.c. References dPoll, and dprintf(). 00094 { 00095 dprintf(dPoll, "Adding handler on fd %d, will call %x(%x)\n", 00096 descriptor, handler, arg); 00097 input_handler[descriptor] = handler; 00098 input_handler_arg[descriptor] = arg; 00099 FD_SET(descriptor, &input_sources); 00100 if (descriptor > max_source) 00101 max_source = descriptor; 00102 }
|
|
Definition at line 105 of file mux.c. 00107 { 00108 input_handler[descriptor] = NULL; 00109 input_handler_arg[descriptor] = NULL; 00110 FD_CLR(descriptor, &input_sources); 00111 }
|
|
Definition at line 67 of file mux.c. Referenced by main(). 00068 { 00069 int i; 00070 00071 FD_ZERO(&input_sources); 00072 00073 for (i = 0; i < MAX_SOURCES; i++) 00074 input_handler[i] = NULL; 00075 00076 have_tty = check_tty(); 00077 }
|
|
Definition at line 129 of file mux.c. References dPoll, dprintf(), errno, mux_end_loop_p, and NULL. Referenced by main(). 00130 { 00131 int i; 00132 fd_set input_sources_copy; 00133 struct timeval tv; 00134 00135 mux_end_loop_p = 0; 00136 00137 for (;;) { 00138 /* 00139 * Exit if mux_end_loop_p has been set to true by a handler: 00140 */ 00141 if (mux_end_loop_p) 00142 break; 00143 00144 if (have_tty) { 00145 tv.tv_sec = 10; 00146 tv.tv_usec = 0; 00147 } 00148 else { 00149 tv.tv_sec = tv.tv_usec = 0; 00150 } 00151 00152 /* 00153 * Do a select on all the file descriptors we care about to 00154 * wait until at least one of them has input available: 00155 */ 00156 input_sources_copy = input_sources; 00157 00158 i = select(max_source + 1, &input_sources_copy, (fd_set *) 0, 00159 (fd_set *) NULL, have_tty ? &tv : (struct timeval *) 0); 00160 00161 if (i == -1) { 00162 if (errno == EINTR) 00163 continue; /* on a signal restart 00164 * checking mux_loop_end_p */ 00165 /* 00166 * else FATAL_TRAP( errno, "while selecting" ); 00167 */ 00168 } 00169 else if (i == 0) { 00170 if (have_tty && !check_tty()) { 00171 mux_end_loop_p = 1; 00172 continue; 00173 } 00174 } 00175 00176 /* 00177 * Call all input handlers whose corresponding file descriptors have 00178 * input: 00179 */ 00180 for (i = 0; i <= max_source; i++) 00181 if (FD_ISSET(i, &input_sources_copy) && input_handler[i]) { 00182 dprintf(dPoll, "mux_loop...activity on fd %d, calling %x(%x)\n", 00183 i, input_handler[i], input_handler_arg[i]); 00184 input_handler[i] (input_handler_arg[i]); 00185 } 00186 } 00187 }
|
|
Definition at line 31 of file mux.c. Referenced by jwg_on_event_handler(), and mux_loop(). |
Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |