Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.c @ 1426:a64778f5f26b
Implement FIFO named command pipe
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 18 Feb 2008 22:59:37 +0100 |
parents | fb438482b28e |
children | 9bf7f3ddff10 |
comparison
equal
deleted
inserted
replaced
1425:b0cfd9ab4b9f | 1426:a64778f5f26b |
---|---|
33 #include "histolog.h" | 33 #include "histolog.h" |
34 #include "commands.h" | 34 #include "commands.h" |
35 #include "pgp.h" | 35 #include "pgp.h" |
36 #include "otr.h" | 36 #include "otr.h" |
37 | 37 |
38 #ifdef ENABLE_FIFO | |
39 # include "fifo.h" | |
40 #endif | |
41 | |
38 #define JABBERPORT 5222 | 42 #define JABBERPORT 5222 |
39 #define JABBERSSLPORT 5223 | 43 #define JABBERSSLPORT 5223 |
40 | 44 |
41 #define RECONNECTION_TIMEOUT 60L | 45 #define RECONNECTION_TIMEOUT 60L |
42 | 46 |
229 time_t now; | 233 time_t now; |
230 fd_set fds; | 234 fd_set fds; |
231 long tmout; | 235 long tmout; |
232 struct timeval tv; | 236 struct timeval tv; |
233 static time_t last_eviqs_check = 0L; | 237 static time_t last_eviqs_check = 0L; |
238 int maxfd; | |
239 #ifdef ENABLE_FIFO | |
240 int fifofd; | |
241 #endif | |
234 | 242 |
235 if (!online) { | 243 if (!online) { |
236 safe_usleep(10000); | 244 safe_usleep(10000); |
237 check_connection(); | 245 check_connection(); |
238 return; | 246 return; |
245 } | 253 } |
246 | 254 |
247 FD_ZERO(&fds); | 255 FD_ZERO(&fds); |
248 FD_SET(0, &fds); | 256 FD_SET(0, &fds); |
249 FD_SET(jc->fd, &fds); | 257 FD_SET(jc->fd, &fds); |
258 maxfd = jc->fd; | |
259 | |
260 #ifdef ENABLE_FIFO | |
261 fifofd = fifo_get_fd(); | |
262 if (fifofd > 0) { | |
263 FD_SET(fifofd, &fds); | |
264 maxfd = MAX(maxfd, fifofd); | |
265 } | |
266 #endif | |
250 | 267 |
251 tv.tv_sec = 60; | 268 tv.tv_sec = 60; |
252 tv.tv_usec = 0; | 269 tv.tv_usec = 0; |
253 | 270 |
254 time(&now); | 271 time(&now); |
274 | 291 |
275 if (!tv.tv_sec) | 292 if (!tv.tv_sec) |
276 tv.tv_usec = 350000; | 293 tv.tv_usec = 350000; |
277 | 294 |
278 scr_DoUpdate(); | 295 scr_DoUpdate(); |
279 if (select(jc->fd + 1, &fds, NULL, NULL, &tv) > 0) { | 296 if (select(maxfd + 1, &fds, NULL, NULL, &tv) > 0) { |
280 if (FD_ISSET(jc->fd, &fds)) | 297 if (FD_ISSET(jc->fd, &fds)) |
281 jab_poll(jc, 0); | 298 jab_poll(jc, 0); |
282 } | 299 } |
283 | 300 |
284 if (jstate == STATE_CONNECTING) { | 301 if (jstate == STATE_CONNECTING) { |