25 |
|
|
26 |
struct input_system { |
struct input_system { |
27 |
LIST *methods; /* List of METHOD structures */ |
LIST *methods; /* List of METHOD structures */ |
28 |
|
ITERATOR *mitr; |
29 |
LIST *channels; /* List of CHANNEL structures */ |
LIST *channels; /* List of CHANNEL structures */ |
30 |
|
ITERATOR *citr; |
31 |
}; |
}; |
32 |
|
|
33 |
typedef struct input_method METHOD; |
typedef struct input_method METHOD; |
150 |
{ |
{ |
151 |
CHANNEL *p; |
CHANNEL *p; |
152 |
|
|
153 |
for (p = list_first(input->channels); p; |
if (!input->citr) |
154 |
p = list_next(input->channels)) { |
input->citr = iterator_create(input->channels); |
155 |
|
|
156 |
|
for (p = iterator_first(input->citr); p; |
157 |
|
p = iterator_next(input->citr)) { |
158 |
|
list_remove(input->channels, p, NULL); |
159 |
channel_close(p); |
channel_close(p); |
160 |
efree(p); |
efree(p); |
|
list_remove_current(input->channels); |
|
161 |
} |
} |
162 |
|
iterator_destroy(&input->citr); |
163 |
} |
} |
164 |
|
|
165 |
void |
void |
168 |
CHANNEL *p = list_locate(input->channels, &fd, _channel_cmp_fd); |
CHANNEL *p = list_locate(input->channels, &fd, _channel_cmp_fd); |
169 |
|
|
170 |
if (p) { |
if (p) { |
171 |
|
list_remove(input->channels, p, NULL); |
172 |
channel_close(p); |
channel_close(p); |
|
list_remove_current(input->channels); |
|
173 |
} |
} |
174 |
} |
} |
175 |
|
|
195 |
clos.data = data; |
clos.data = data; |
196 |
p = list_locate(input->channels, &clos, _channel_cmp); |
p = list_locate(input->channels, &clos, _channel_cmp); |
197 |
if (p) { |
if (p) { |
198 |
|
list_remove(input->channels, p, NULL); |
199 |
channel_close(p); |
channel_close(p); |
200 |
efree(p); |
efree(p); |
|
list_remove_current(input->channels); |
|
201 |
} |
} |
202 |
} |
} |
203 |
|
|
207 |
METHOD *m; |
METHOD *m; |
208 |
int status; |
int status; |
209 |
|
|
210 |
for (m = list_first(input->methods); m; |
if (!input->citr) |
211 |
m = list_next(input->methods)) { |
input->citr = iterator_create(input->channels); |
212 |
|
if (!input->mitr) |
213 |
|
input->mitr = iterator_create(input->methods); |
214 |
|
|
215 |
|
for (m = iterator_first(input->mitr); m; |
216 |
|
m = iterator_next(input->mitr)) { |
217 |
CHANNEL *p; |
CHANNEL *p; |
218 |
fd_set readfds; |
fd_set readfds; |
219 |
|
|
220 |
if (m->fd_max == -2) { |
if (m->fd_max == -2) { |
221 |
for (p = list_first(input->channels); p; |
for (p = iterator_first(input->citr); p; |
222 |
p = list_next(input->channels)) { |
p = iterator_next(input->citr)) { |
223 |
if (p->method == m && p->fd > m->fd_max) |
if (p->method == m && p->fd > m->fd_max) |
224 |
m->fd_max = p->fd; |
m->fd_max = p->fd; |
225 |
} |
} |
238 |
if (errno == EINTR) |
if (errno == EINTR) |
239 |
return 0; |
return 0; |
240 |
} else if (status > 0) { |
} else if (status > 0) { |
241 |
for (p = list_first(input->channels); p; |
for (p = iterator_first(input->citr); p; |
242 |
p = list_next(input->channels)) { |
p = iterator_next(input->citr)) { |
243 |
if (FD_ISSET(p->fd, &readfds)) |
if (FD_ISSET(p->fd, &readfds)) |
244 |
channel_handle(p); |
channel_handle(p); |
245 |
} |
} |