1 | #include "owl.h" |
---|
2 | #include <stdio.h> |
---|
3 | #include <sys/stat.h> |
---|
4 | |
---|
5 | #ifdef HAVE_LIBZEPHYR |
---|
6 | static GSource *owl_zephyr_event_source_new(int fd); |
---|
7 | |
---|
8 | static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout); |
---|
9 | static gboolean owl_zephyr_event_check(GSource *source); |
---|
10 | static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data); |
---|
11 | |
---|
12 | static GList *deferred_subs = NULL; |
---|
13 | |
---|
14 | typedef struct _owl_sub_list { /* noproto */ |
---|
15 | ZSubscription_t *subs; |
---|
16 | int nsubs; |
---|
17 | } owl_sub_list; |
---|
18 | |
---|
19 | Code_t ZResetAuthentication(void); |
---|
20 | |
---|
21 | static GSourceFuncs zephyr_event_funcs = { |
---|
22 | owl_zephyr_event_prepare, |
---|
23 | owl_zephyr_event_check, |
---|
24 | owl_zephyr_event_dispatch, |
---|
25 | NULL |
---|
26 | }; |
---|
27 | #endif |
---|
28 | |
---|
29 | #define HM_SVC_FALLBACK htons((unsigned short) 2104) |
---|
30 | |
---|
31 | static CALLER_OWN char *owl_zephyr_dotfile(const char *name, const char *input) |
---|
32 | { |
---|
33 | if (input != NULL) |
---|
34 | return g_strdup(input); |
---|
35 | else |
---|
36 | return g_build_filename(owl_global_get_homedir(&g), name, NULL); |
---|
37 | } |
---|
38 | |
---|
39 | #ifdef HAVE_LIBZEPHYR |
---|
40 | void owl_zephyr_initialize(void) |
---|
41 | { |
---|
42 | Code_t ret; |
---|
43 | struct servent *sp; |
---|
44 | struct sockaddr_in sin; |
---|
45 | ZNotice_t req; |
---|
46 | GIOChannel *channel; |
---|
47 | |
---|
48 | /* |
---|
49 | * Code modified from libzephyr's ZhmStat.c |
---|
50 | * |
---|
51 | * Modified to add the fd to our select loop, rather than hanging |
---|
52 | * until we get an ack. |
---|
53 | */ |
---|
54 | |
---|
55 | if ((ret = ZOpenPort(NULL)) != ZERR_NONE) { |
---|
56 | owl_function_error("Error opening Zephyr port: %s", error_message(ret)); |
---|
57 | return; |
---|
58 | } |
---|
59 | |
---|
60 | (void) memset(&sin, 0, sizeof(struct sockaddr_in)); |
---|
61 | |
---|
62 | sp = getservbyname(HM_SVCNAME, "udp"); |
---|
63 | |
---|
64 | sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK; |
---|
65 | sin.sin_family = AF_INET; |
---|
66 | |
---|
67 | sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
---|
68 | |
---|
69 | (void) memset(&req, 0, sizeof(req)); |
---|
70 | req.z_kind = STAT; |
---|
71 | req.z_port = 0; |
---|
72 | req.z_class = zstr(HM_STAT_CLASS); |
---|
73 | req.z_class_inst = zstr(HM_STAT_CLIENT); |
---|
74 | req.z_opcode = zstr(HM_GIMMESTATS); |
---|
75 | req.z_sender = zstr(""); |
---|
76 | req.z_recipient = zstr(""); |
---|
77 | req.z_default_format = zstr(""); |
---|
78 | req.z_message_len = 0; |
---|
79 | |
---|
80 | if ((ret = ZSetDestAddr(&sin)) != ZERR_NONE) { |
---|
81 | owl_function_error("Initializing Zephyr: %s", error_message(ret)); |
---|
82 | return; |
---|
83 | } |
---|
84 | |
---|
85 | if ((ret = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) { |
---|
86 | owl_function_error("Initializing Zephyr: %s", error_message(ret)); |
---|
87 | return; |
---|
88 | } |
---|
89 | |
---|
90 | channel = g_io_channel_unix_new(ZGetFD()); |
---|
91 | g_io_add_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP, |
---|
92 | &owl_zephyr_finish_initialization, NULL); |
---|
93 | g_io_channel_unref(channel); |
---|
94 | } |
---|
95 | |
---|
96 | gboolean owl_zephyr_finish_initialization(GIOChannel *source, GIOCondition condition, void *data) { |
---|
97 | Code_t code; |
---|
98 | char *perl; |
---|
99 | GSource *event_source; |
---|
100 | |
---|
101 | ZClosePort(); |
---|
102 | |
---|
103 | if ((code = ZInitialize()) != ZERR_NONE) { |
---|
104 | owl_function_error("Initializing Zephyr: %s", error_message(code)); |
---|
105 | return FALSE; |
---|
106 | } |
---|
107 | |
---|
108 | if ((code = ZOpenPort(NULL)) != ZERR_NONE) { |
---|
109 | owl_function_error("Initializing Zephyr: %s", error_message(code)); |
---|
110 | return FALSE; |
---|
111 | } |
---|
112 | |
---|
113 | event_source = owl_zephyr_event_source_new(ZGetFD()); |
---|
114 | g_source_attach(event_source, NULL); |
---|
115 | g_source_unref(event_source); |
---|
116 | |
---|
117 | owl_global_set_havezephyr(&g); |
---|
118 | |
---|
119 | if(g.load_initial_subs) { |
---|
120 | owl_zephyr_load_initial_subs(); |
---|
121 | } |
---|
122 | while(deferred_subs != NULL) { |
---|
123 | owl_sub_list *subs = deferred_subs->data; |
---|
124 | owl_function_debugmsg("Loading %d deferred subs.", subs->nsubs); |
---|
125 | owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs); |
---|
126 | deferred_subs = g_list_delete_link(deferred_subs, deferred_subs); |
---|
127 | g_free(subs); |
---|
128 | } |
---|
129 | |
---|
130 | /* zlog in if we need to */ |
---|
131 | if (owl_global_is_startuplogin(&g)) { |
---|
132 | owl_function_debugmsg("startup: doing zlog in"); |
---|
133 | owl_zephyr_zlog_in(); |
---|
134 | } |
---|
135 | /* check pseudo-logins if we need to */ |
---|
136 | if (owl_global_is_pseudologins(&g)) { |
---|
137 | owl_function_debugmsg("startup: checking pseudo-logins"); |
---|
138 | owl_function_zephyr_buddy_check(0); |
---|
139 | } |
---|
140 | |
---|
141 | perl = owl_perlconfig_execute("BarnOwl::Zephyr::_zephyr_startup()"); |
---|
142 | g_free(perl); |
---|
143 | return FALSE; |
---|
144 | } |
---|
145 | |
---|
146 | void owl_zephyr_load_initial_subs(void) { |
---|
147 | int ret_sd, ret_bd, ret_u; |
---|
148 | |
---|
149 | owl_function_debugmsg("startup: loading initial zephyr subs"); |
---|
150 | |
---|
151 | /* load default subscriptions */ |
---|
152 | ret_sd = owl_zephyr_loaddefaultsubs(); |
---|
153 | |
---|
154 | /* load Barnowl default subscriptions */ |
---|
155 | ret_bd = owl_zephyr_loadbarnowldefaultsubs(); |
---|
156 | |
---|
157 | /* load subscriptions from subs file */ |
---|
158 | ret_u = owl_zephyr_loadsubs(NULL, 0); |
---|
159 | |
---|
160 | if (ret_sd || ret_bd || ret_u) { |
---|
161 | owl_function_error("Error loading zephyr subscriptions"); |
---|
162 | } |
---|
163 | |
---|
164 | /* load login subscriptions */ |
---|
165 | if (owl_global_is_loginsubs(&g)) { |
---|
166 | owl_function_debugmsg("startup: loading login subs"); |
---|
167 | owl_function_loadloginsubs(NULL); |
---|
168 | } |
---|
169 | } |
---|
170 | #else |
---|
171 | void owl_zephyr_initialize(void) |
---|
172 | { |
---|
173 | } |
---|
174 | #endif |
---|
175 | |
---|
176 | |
---|
177 | int owl_zephyr_shutdown(void) |
---|
178 | { |
---|
179 | #ifdef HAVE_LIBZEPHYR |
---|
180 | if(owl_global_is_havezephyr(&g)) { |
---|
181 | unsuball(); |
---|
182 | ZClosePort(); |
---|
183 | } |
---|
184 | #endif |
---|
185 | return 0; |
---|
186 | } |
---|
187 | |
---|
188 | int owl_zephyr_zpending(void) |
---|
189 | { |
---|
190 | #ifdef HAVE_LIBZEPHYR |
---|
191 | Code_t code; |
---|
192 | if(owl_global_is_havezephyr(&g)) { |
---|
193 | if((code = ZPending()) < 0) { |
---|
194 | owl_function_debugmsg("Error (%s) in ZPending()\n", |
---|
195 | error_message(code)); |
---|
196 | return 0; |
---|
197 | } |
---|
198 | return code; |
---|
199 | } |
---|
200 | #endif |
---|
201 | return 0; |
---|
202 | } |
---|
203 | |
---|
204 | int owl_zephyr_zqlength(void) |
---|
205 | { |
---|
206 | #ifdef HAVE_LIBZEPHYR |
---|
207 | Code_t code; |
---|
208 | if(owl_global_is_havezephyr(&g)) { |
---|
209 | if((code = ZQLength()) < 0) { |
---|
210 | owl_function_debugmsg("Error (%s) in ZQLength()\n", |
---|
211 | error_message(code)); |
---|
212 | return 0; |
---|
213 | } |
---|
214 | return code; |
---|
215 | } |
---|
216 | #endif |
---|
217 | return 0; |
---|
218 | } |
---|
219 | |
---|
220 | const char *owl_zephyr_get_realm(void) |
---|
221 | { |
---|
222 | #ifdef HAVE_LIBZEPHYR |
---|
223 | if (owl_global_is_havezephyr(&g)) |
---|
224 | return(ZGetRealm()); |
---|
225 | #endif |
---|
226 | return ""; |
---|
227 | } |
---|
228 | |
---|
229 | const char *owl_zephyr_get_sender(void) |
---|
230 | { |
---|
231 | #ifdef HAVE_LIBZEPHYR |
---|
232 | if (owl_global_is_havezephyr(&g)) |
---|
233 | return(ZGetSender()); |
---|
234 | #endif |
---|
235 | return ""; |
---|
236 | } |
---|
237 | |
---|
238 | #ifdef HAVE_LIBZEPHYR |
---|
239 | int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count) |
---|
240 | { |
---|
241 | int ret = 0; |
---|
242 | Code_t code; |
---|
243 | |
---|
244 | if (owl_global_is_havezephyr(&g)) { |
---|
245 | int i; |
---|
246 | /* sub without defaults */ |
---|
247 | code = ZSubscribeToSansDefaults(subs, count, 0); |
---|
248 | if (code != ZERR_NONE) { |
---|
249 | owl_function_error("Error subscribing to zephyr notifications: %s", |
---|
250 | error_message(code)); |
---|
251 | ret=-2; |
---|
252 | } |
---|
253 | |
---|
254 | /* free stuff */ |
---|
255 | for (i=0; i<count; i++) { |
---|
256 | g_free(subs[i].zsub_class); |
---|
257 | g_free(subs[i].zsub_classinst); |
---|
258 | g_free(subs[i].zsub_recipient); |
---|
259 | } |
---|
260 | |
---|
261 | g_free(subs); |
---|
262 | } else { |
---|
263 | owl_sub_list *s = g_new(owl_sub_list, 1); |
---|
264 | s->subs = subs; |
---|
265 | s->nsubs = count; |
---|
266 | deferred_subs = g_list_append(deferred_subs, s); |
---|
267 | } |
---|
268 | |
---|
269 | return ret; |
---|
270 | } |
---|
271 | #endif |
---|
272 | |
---|
273 | /* Load zephyr subscriptions from 'filename'. If 'filename' is NULL, |
---|
274 | * the default file $HOME/.zephyr.subs will be used. |
---|
275 | * |
---|
276 | * Returns 0 on success. If the file does not exist, return -1 if |
---|
277 | * 'error_on_nofile' is 1, otherwise return 0. Return -1 if the file |
---|
278 | * exists but can not be read. Return -2 if there is a failure from |
---|
279 | * zephyr to load the subscriptions. |
---|
280 | */ |
---|
281 | int owl_zephyr_loadsubs(const char *filename, int error_on_nofile) |
---|
282 | { |
---|
283 | #ifdef HAVE_LIBZEPHYR |
---|
284 | FILE *file; |
---|
285 | char *tmp, *start; |
---|
286 | char *buffer = NULL; |
---|
287 | char *subsfile; |
---|
288 | ZSubscription_t *subs; |
---|
289 | int subSize = 1024; |
---|
290 | int count; |
---|
291 | struct stat statbuff; |
---|
292 | |
---|
293 | subsfile = owl_zephyr_dotfile(".zephyr.subs", filename); |
---|
294 | |
---|
295 | if (stat(subsfile, &statbuff) != 0) { |
---|
296 | g_free(subsfile); |
---|
297 | if (error_on_nofile == 1) |
---|
298 | return -1; |
---|
299 | return 0; |
---|
300 | } |
---|
301 | |
---|
302 | ZResetAuthentication(); |
---|
303 | count = 0; |
---|
304 | file = fopen(subsfile, "r"); |
---|
305 | g_free(subsfile); |
---|
306 | if (!file) |
---|
307 | return -1; |
---|
308 | |
---|
309 | subs = g_new(ZSubscription_t, subSize); |
---|
310 | while (owl_getline(&buffer, file)) { |
---|
311 | if (buffer[0] == '#' || buffer[0] == '\n') |
---|
312 | continue; |
---|
313 | |
---|
314 | if (buffer[0] == '-') |
---|
315 | start = buffer + 1; |
---|
316 | else |
---|
317 | start = buffer; |
---|
318 | |
---|
319 | if (count >= subSize) { |
---|
320 | subSize *= 2; |
---|
321 | subs = g_renew(ZSubscription_t, subs, subSize); |
---|
322 | } |
---|
323 | |
---|
324 | /* add it to the list of subs */ |
---|
325 | if ((tmp = strtok(start, ",\n\r")) == NULL) |
---|
326 | continue; |
---|
327 | subs[count].zsub_class = g_strdup(tmp); |
---|
328 | if ((tmp=strtok(NULL, ",\n\r")) == NULL) |
---|
329 | continue; |
---|
330 | subs[count].zsub_classinst = g_strdup(tmp); |
---|
331 | if ((tmp = strtok(NULL, " \t\n\r")) == NULL) |
---|
332 | continue; |
---|
333 | subs[count].zsub_recipient = g_strdup(tmp); |
---|
334 | |
---|
335 | /* if it started with '-' then add it to the global punt list, and |
---|
336 | * remove it from the list of subs. */ |
---|
337 | if (buffer[0] == '-') { |
---|
338 | owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0); |
---|
339 | g_free(subs[count].zsub_class); |
---|
340 | g_free(subs[count].zsub_classinst); |
---|
341 | g_free(subs[count].zsub_recipient); |
---|
342 | } else { |
---|
343 | count++; |
---|
344 | } |
---|
345 | } |
---|
346 | fclose(file); |
---|
347 | if (buffer) |
---|
348 | g_free(buffer); |
---|
349 | |
---|
350 | return owl_zephyr_loadsubs_helper(subs, count); |
---|
351 | #else |
---|
352 | return 0; |
---|
353 | #endif |
---|
354 | } |
---|
355 | |
---|
356 | /* Load default Barnowl subscriptions |
---|
357 | * |
---|
358 | * Returns 0 on success. |
---|
359 | * Return -2 if there is a failure from zephyr to load the subscriptions. |
---|
360 | */ |
---|
361 | int owl_zephyr_loadbarnowldefaultsubs(void) |
---|
362 | { |
---|
363 | #ifdef HAVE_LIBZEPHYR |
---|
364 | ZSubscription_t *subs; |
---|
365 | int subSize = 10; /* Max Barnowl default subs we allow */ |
---|
366 | int count, ret; |
---|
367 | |
---|
368 | subs = g_new(ZSubscription_t, subSize); |
---|
369 | ZResetAuthentication(); |
---|
370 | count=0; |
---|
371 | |
---|
372 | subs[count].zsub_class=g_strdup("message"); |
---|
373 | subs[count].zsub_classinst=g_strdup("*"); |
---|
374 | subs[count].zsub_recipient=g_strdup("%me%"); |
---|
375 | count++; |
---|
376 | |
---|
377 | ret = owl_zephyr_loadsubs_helper(subs, count); |
---|
378 | return(ret); |
---|
379 | #else |
---|
380 | return(0); |
---|
381 | #endif |
---|
382 | } |
---|
383 | |
---|
384 | int owl_zephyr_loaddefaultsubs(void) |
---|
385 | { |
---|
386 | #ifdef HAVE_LIBZEPHYR |
---|
387 | Code_t ret; |
---|
388 | |
---|
389 | if (owl_global_is_havezephyr(&g)) { |
---|
390 | ZSubscription_t subs[10]; |
---|
391 | |
---|
392 | ret = ZSubscribeTo(subs, 0, 0); |
---|
393 | if (ret != ZERR_NONE) { |
---|
394 | owl_function_error("Error subscribing to default zephyr notifications: %s.", |
---|
395 | error_message(ret)); |
---|
396 | return(-1); |
---|
397 | } |
---|
398 | } |
---|
399 | return(0); |
---|
400 | #else |
---|
401 | return(0); |
---|
402 | #endif |
---|
403 | } |
---|
404 | |
---|
405 | int owl_zephyr_loadloginsubs(const char *filename) |
---|
406 | { |
---|
407 | #ifdef HAVE_LIBZEPHYR |
---|
408 | FILE *file; |
---|
409 | ZSubscription_t *subs; |
---|
410 | int numSubs = 100; |
---|
411 | char *subsfile; |
---|
412 | char *buffer = NULL; |
---|
413 | int count; |
---|
414 | struct stat statbuff; |
---|
415 | |
---|
416 | subs = g_new(ZSubscription_t, numSubs); |
---|
417 | subsfile = owl_zephyr_dotfile(".anyone", filename); |
---|
418 | |
---|
419 | if (stat(subsfile, &statbuff) == -1) { |
---|
420 | g_free(subs); |
---|
421 | g_free(subsfile); |
---|
422 | return 0; |
---|
423 | } |
---|
424 | |
---|
425 | ZResetAuthentication(); |
---|
426 | count = 0; |
---|
427 | file = fopen(subsfile, "r"); |
---|
428 | g_free(subsfile); |
---|
429 | if (file) { |
---|
430 | while (owl_getline_chomp(&buffer, file)) { |
---|
431 | if (buffer[0] == '\0' || buffer[0] == '#') |
---|
432 | continue; |
---|
433 | |
---|
434 | if (count == numSubs) { |
---|
435 | numSubs *= 2; |
---|
436 | subs = g_renew(ZSubscription_t, subs, numSubs); |
---|
437 | } |
---|
438 | |
---|
439 | subs[count].zsub_class = g_strdup("login"); |
---|
440 | subs[count].zsub_recipient = g_strdup("*"); |
---|
441 | subs[count].zsub_classinst = long_zuser(buffer); |
---|
442 | |
---|
443 | count++; |
---|
444 | } |
---|
445 | fclose(file); |
---|
446 | } else { |
---|
447 | return 0; |
---|
448 | } |
---|
449 | g_free(buffer); |
---|
450 | |
---|
451 | return owl_zephyr_loadsubs_helper(subs, count); |
---|
452 | #else |
---|
453 | return 0; |
---|
454 | #endif |
---|
455 | } |
---|
456 | |
---|
457 | bool unsuball(void) |
---|
458 | { |
---|
459 | #if HAVE_LIBZEPHYR |
---|
460 | Code_t ret; |
---|
461 | |
---|
462 | ZResetAuthentication(); |
---|
463 | ret = ZCancelSubscriptions(0); |
---|
464 | if (ret != ZERR_NONE) |
---|
465 | owl_function_error("Zephyr: Cancelling subscriptions: %s", |
---|
466 | error_message(ret)); |
---|
467 | return (ret == ZERR_NONE); |
---|
468 | #endif |
---|
469 | return true; |
---|
470 | } |
---|
471 | |
---|
472 | int owl_zephyr_sub(const char *class, const char *inst, const char *recip) |
---|
473 | { |
---|
474 | #ifdef HAVE_LIBZEPHYR |
---|
475 | ZSubscription_t subs[5]; |
---|
476 | Code_t ret; |
---|
477 | |
---|
478 | subs[0].zsub_class=zstr(class); |
---|
479 | subs[0].zsub_classinst=zstr(inst); |
---|
480 | subs[0].zsub_recipient=zstr(recip); |
---|
481 | |
---|
482 | ZResetAuthentication(); |
---|
483 | ret = ZSubscribeTo(subs, 1, 0); |
---|
484 | if (ret != ZERR_NONE) { |
---|
485 | owl_function_error("Error subbing to <%s,%s,%s>: %s", |
---|
486 | class, inst, recip, |
---|
487 | error_message(ret)); |
---|
488 | return(-2); |
---|
489 | } |
---|
490 | return(0); |
---|
491 | #else |
---|
492 | return(0); |
---|
493 | #endif |
---|
494 | } |
---|
495 | |
---|
496 | |
---|
497 | int owl_zephyr_unsub(const char *class, const char *inst, const char *recip) |
---|
498 | { |
---|
499 | #ifdef HAVE_LIBZEPHYR |
---|
500 | ZSubscription_t subs[5]; |
---|
501 | Code_t ret; |
---|
502 | |
---|
503 | subs[0].zsub_class=zstr(class); |
---|
504 | subs[0].zsub_classinst=zstr(inst); |
---|
505 | subs[0].zsub_recipient=zstr(recip); |
---|
506 | |
---|
507 | ZResetAuthentication(); |
---|
508 | ret = ZUnsubscribeTo(subs, 1, 0); |
---|
509 | if (ret != ZERR_NONE) { |
---|
510 | owl_function_error("Error unsubbing from <%s,%s,%s>: %s", |
---|
511 | class, inst, recip, |
---|
512 | error_message(ret)); |
---|
513 | return(-2); |
---|
514 | } |
---|
515 | return(0); |
---|
516 | #else |
---|
517 | return(0); |
---|
518 | #endif |
---|
519 | } |
---|
520 | |
---|
521 | #ifdef HAVE_LIBZEPHYR |
---|
522 | const char *owl_zephyr_first_raw_field(const ZNotice_t *n) |
---|
523 | { |
---|
524 | if (n->z_message_len == 0) |
---|
525 | return NULL; |
---|
526 | return n->z_message; |
---|
527 | } |
---|
528 | |
---|
529 | const char *owl_zephyr_next_raw_field(const ZNotice_t *n, const char *f) |
---|
530 | { |
---|
531 | const char *end = n->z_message + n->z_message_len; |
---|
532 | f = memchr(f, '\0', end - f); |
---|
533 | if (f == NULL) |
---|
534 | return NULL; |
---|
535 | return f + 1; |
---|
536 | } |
---|
537 | |
---|
538 | const char *owl_zephyr_get_raw_field(const ZNotice_t *n, int j) |
---|
539 | { |
---|
540 | int i; |
---|
541 | const char *f; |
---|
542 | for (i = 1, f = owl_zephyr_first_raw_field(n); i < j && f != NULL; |
---|
543 | i++, f = owl_zephyr_next_raw_field(n, f)) |
---|
544 | ; |
---|
545 | return f; |
---|
546 | } |
---|
547 | |
---|
548 | CALLER_OWN char *owl_zephyr_field(const ZNotice_t *n, const char *f) |
---|
549 | { |
---|
550 | if (f == NULL) |
---|
551 | return g_strdup(""); |
---|
552 | return g_strndup(f, n->z_message + n->z_message_len - f); |
---|
553 | } |
---|
554 | |
---|
555 | CALLER_OWN char *owl_zephyr_field_as_utf8(const ZNotice_t *n, const char *f) |
---|
556 | { |
---|
557 | char *tmp = owl_zephyr_field(n, f); |
---|
558 | char *out = owl_validate_or_convert(tmp); |
---|
559 | g_free(tmp); |
---|
560 | return out; |
---|
561 | } |
---|
562 | |
---|
563 | CALLER_OWN char *owl_zephyr_get_field(const ZNotice_t *n, int j) |
---|
564 | { |
---|
565 | return owl_zephyr_field(n, owl_zephyr_get_raw_field(n, j)); |
---|
566 | } |
---|
567 | |
---|
568 | CALLER_OWN char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j) |
---|
569 | { |
---|
570 | return owl_zephyr_field_as_utf8(n, owl_zephyr_get_raw_field(n, j)); |
---|
571 | } |
---|
572 | #else |
---|
573 | const char *owl_zephyr_first_raw_field(const void *n) |
---|
574 | { |
---|
575 | return NULL; |
---|
576 | } |
---|
577 | |
---|
578 | const char *owl_zephyr_next_raw_field(const void *n, const char *f) |
---|
579 | { |
---|
580 | return NULL; |
---|
581 | } |
---|
582 | |
---|
583 | const char *owl_zephyr_get_raw_field(const void *n, int j) |
---|
584 | { |
---|
585 | return NULL; |
---|
586 | } |
---|
587 | |
---|
588 | CALLER_OWN char *owl_zephyr_field(const void *n, const char *f) |
---|
589 | { |
---|
590 | return g_strdup(""); |
---|
591 | } |
---|
592 | |
---|
593 | CALLER_OWN char *owl_zephyr_field_as_utf8(const void *n, const char *f) |
---|
594 | { |
---|
595 | return g_strdup(""); |
---|
596 | } |
---|
597 | |
---|
598 | CALLER_OWN char *owl_zephyr_get_field(const void *n, int j) |
---|
599 | { |
---|
600 | return g_strdup(""); |
---|
601 | } |
---|
602 | |
---|
603 | CALLER_OWN char *owl_zephyr_get_field_as_utf8(const void *n, int j) |
---|
604 | { |
---|
605 | return owl_zephyr_field(n, owl_zephyr_get_raw_field(n, j)); |
---|
606 | } |
---|
607 | #endif |
---|
608 | |
---|
609 | |
---|
610 | #ifdef HAVE_LIBZEPHYR |
---|
611 | int owl_zephyr_get_num_fields(const ZNotice_t *n) |
---|
612 | { |
---|
613 | int i; |
---|
614 | const char *f; |
---|
615 | for (i = 0, f = owl_zephyr_first_raw_field(n); f != NULL; |
---|
616 | i++, f = owl_zephyr_next_raw_field(n, f)) |
---|
617 | ; |
---|
618 | return i; |
---|
619 | } |
---|
620 | #else |
---|
621 | int owl_zephyr_get_num_fields(const void *n) |
---|
622 | { |
---|
623 | return(0); |
---|
624 | } |
---|
625 | #endif |
---|
626 | |
---|
627 | #ifdef HAVE_LIBZEPHYR |
---|
628 | /* return a pointer to the message, place the message length in k |
---|
629 | * caller must free the return |
---|
630 | */ |
---|
631 | CALLER_OWN char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m) |
---|
632 | { |
---|
633 | #define OWL_NFIELDS 5 |
---|
634 | int i; |
---|
635 | char *fields[OWL_NFIELDS + 1]; |
---|
636 | char *msg = NULL; |
---|
637 | |
---|
638 | /* don't let ping messages have a body */ |
---|
639 | if (!strcasecmp(n->z_opcode, "ping")) { |
---|
640 | return(g_strdup("")); |
---|
641 | } |
---|
642 | |
---|
643 | for(i = 0; i < OWL_NFIELDS; i++) |
---|
644 | fields[i + 1] = owl_zephyr_get_field(n, i + 1); |
---|
645 | |
---|
646 | /* deal with MIT NOC messages */ |
---|
647 | if (!strcasecmp(n->z_default_format, "@center(@bold(NOC Message))\n\n@bold(Sender:) $1 <$sender>\n@bold(Time: ) $time\n\n@italic($opcode service on $instance $3.) $4\n")) { |
---|
648 | |
---|
649 | msg = g_strdup_printf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, fields[3], fields[4]); |
---|
650 | } |
---|
651 | /* deal with MIT Discuss messages */ |
---|
652 | else if (!strcasecmp(n->z_default_format, "New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4") || |
---|
653 | !strcasecmp(n->z_default_format, "New transaction [$1] entered in $2\nFrom: $3\nSubject: $4")) { |
---|
654 | |
---|
655 | msg = g_strdup_printf("New transaction [%s] entered in %s\nFrom: %s (%s)\nSubject: %s", |
---|
656 | fields[1], fields[2], fields[3], fields[5], fields[4]); |
---|
657 | } |
---|
658 | /* deal with MIT Moira messages */ |
---|
659 | else if (!strcasecmp(n->z_default_format, "MOIRA $instance on $fromhost:\n $message\n")) { |
---|
660 | msg = g_strdup_printf("MOIRA %s on %s: %s", |
---|
661 | n->z_class_inst, |
---|
662 | owl_message_get_hostname(m), |
---|
663 | fields[1]); |
---|
664 | } else { |
---|
665 | if (owl_zephyr_get_num_fields(n) == 1) |
---|
666 | msg = g_strdup(fields[1]); |
---|
667 | else |
---|
668 | msg = g_strdup(fields[2]); |
---|
669 | } |
---|
670 | |
---|
671 | for (i = 0; i < OWL_NFIELDS; i++) |
---|
672 | g_free(fields[i + 1]); |
---|
673 | |
---|
674 | return msg; |
---|
675 | } |
---|
676 | #endif |
---|
677 | |
---|
678 | #ifdef HAVE_LIBZEPHYR |
---|
679 | const char *owl_zephyr_get_zsig(const ZNotice_t *n, int *k) |
---|
680 | { |
---|
681 | /* return a pointer to the zsig if there is one */ |
---|
682 | |
---|
683 | /* message length 0? No zsig */ |
---|
684 | if (n->z_message_len==0) { |
---|
685 | *k=0; |
---|
686 | return(""); |
---|
687 | } |
---|
688 | |
---|
689 | /* If there's only one field, no zsig */ |
---|
690 | if (owl_zephyr_get_num_fields(n) == 1) { |
---|
691 | *k=0; |
---|
692 | return(""); |
---|
693 | } |
---|
694 | |
---|
695 | /* Everything else is field 1 */ |
---|
696 | *k=strlen(n->z_message); |
---|
697 | return(n->z_message); |
---|
698 | } |
---|
699 | #else |
---|
700 | const char *owl_zephyr_get_zsig(const void *n, int *k) |
---|
701 | { |
---|
702 | return(""); |
---|
703 | } |
---|
704 | #endif |
---|
705 | |
---|
706 | int send_zephyr(const char *opcode, const char *zsig, const char *class, const char *instance, const char *recipient, const char *message) |
---|
707 | { |
---|
708 | #ifdef HAVE_LIBZEPHYR |
---|
709 | Code_t ret; |
---|
710 | ZNotice_t notice; |
---|
711 | char *zsender = NULL; |
---|
712 | |
---|
713 | memset(¬ice, 0, sizeof(notice)); |
---|
714 | |
---|
715 | ZResetAuthentication(); |
---|
716 | |
---|
717 | if (!zsig) zsig=""; |
---|
718 | |
---|
719 | notice.z_kind=ACKED; |
---|
720 | notice.z_port=0; |
---|
721 | #ifdef ZCHARSET_UTF_8 |
---|
722 | notice.z_charset = ZCHARSET_UTF_8; |
---|
723 | #endif |
---|
724 | notice.z_class=zstr(class); |
---|
725 | notice.z_class_inst=zstr(instance); |
---|
726 | if (!strcmp(recipient, "@")) { |
---|
727 | notice.z_recipient=zstr(""); |
---|
728 | } else { |
---|
729 | notice.z_recipient=zstr(recipient); |
---|
730 | } |
---|
731 | if (!owl_zwrite_recip_is_personal(recipient) && *owl_global_get_zsender(&g)) |
---|
732 | notice.z_sender = zsender = long_zuser(owl_global_get_zsender(&g)); |
---|
733 | notice.z_default_format=zstr(ZEPHYR_DEFAULT_FORMAT); |
---|
734 | if (opcode) notice.z_opcode=zstr(opcode); |
---|
735 | |
---|
736 | notice.z_message_len=strlen(zsig)+1+strlen(message); |
---|
737 | notice.z_message=g_new(char, notice.z_message_len+10); |
---|
738 | strcpy(notice.z_message, zsig); |
---|
739 | memcpy(notice.z_message+strlen(zsig)+1, message, strlen(message)); |
---|
740 | |
---|
741 | /* ret=ZSendNotice(¬ice, ZAUTH); */ |
---|
742 | ret=ZSrvSendNotice(¬ice, ZAUTH, send_zephyr_helper); |
---|
743 | |
---|
744 | /* free then check the return */ |
---|
745 | g_free(notice.z_message); |
---|
746 | g_free(zsender); |
---|
747 | if (ret != ZERR_NONE) { |
---|
748 | owl_function_error("Error sending zephyr: %s", error_message(ret)); |
---|
749 | return(ret); |
---|
750 | } |
---|
751 | return(0); |
---|
752 | #else |
---|
753 | return(0); |
---|
754 | #endif |
---|
755 | } |
---|
756 | |
---|
757 | #ifdef HAVE_LIBZEPHYR |
---|
758 | Code_t send_zephyr_helper(ZNotice_t *notice, char *buf, int len, int wait) |
---|
759 | { |
---|
760 | return(ZSendPacket(buf, len, 0)); |
---|
761 | } |
---|
762 | #endif |
---|
763 | |
---|
764 | void send_ping(const char *to, const char *zclass, const char *zinstance) |
---|
765 | { |
---|
766 | #ifdef HAVE_LIBZEPHYR |
---|
767 | send_zephyr("PING", "", zclass, zinstance, to, ""); |
---|
768 | #endif |
---|
769 | } |
---|
770 | |
---|
771 | #ifdef HAVE_LIBZEPHYR |
---|
772 | void owl_zephyr_handle_ack(const ZNotice_t *retnotice) |
---|
773 | { |
---|
774 | char *tmp; |
---|
775 | |
---|
776 | /* if it's an HMACK ignore it */ |
---|
777 | if (retnotice->z_kind == HMACK) return; |
---|
778 | |
---|
779 | if (retnotice->z_kind == SERVNAK) { |
---|
780 | owl_function_error("Authorization failure sending zephyr"); |
---|
781 | } else if ((retnotice->z_kind != SERVACK) || !retnotice->z_message_len) { |
---|
782 | owl_function_error("Detected server failure while receiving acknowledgement"); |
---|
783 | } else if (!strcmp(retnotice->z_message, ZSRVACK_SENT)) { |
---|
784 | if (!strcasecmp(retnotice->z_opcode, "ping")) { |
---|
785 | return; |
---|
786 | } else { |
---|
787 | if (strcasecmp(retnotice->z_recipient, "")) |
---|
788 | { /* personal */ |
---|
789 | tmp=short_zuser(retnotice->z_recipient); |
---|
790 | if(!strcasecmp(retnotice->z_class, "message") && |
---|
791 | !strcasecmp(retnotice->z_class_inst, "personal")) { |
---|
792 | owl_function_makemsg("Message sent to %s.", tmp); |
---|
793 | } else if(!strcasecmp(retnotice->z_class, "message")) { /* instanced, but not classed, personal */ |
---|
794 | owl_function_makemsg("Message sent to %s on -i %s\n", tmp, retnotice->z_class_inst); |
---|
795 | } else { /* classed personal */ |
---|
796 | owl_function_makemsg("Message sent to %s on -c %s -i %s\n", tmp, retnotice->z_class, retnotice->z_class_inst); |
---|
797 | } |
---|
798 | g_free(tmp); |
---|
799 | } else { |
---|
800 | /* class / instance message */ |
---|
801 | owl_function_makemsg("Message sent to -c %s -i %s\n", retnotice->z_class, retnotice->z_class_inst); |
---|
802 | } |
---|
803 | } |
---|
804 | } else if (!strcmp(retnotice->z_message, ZSRVACK_NOTSENT)) { |
---|
805 | if (retnotice->z_recipient == NULL |
---|
806 | || !owl_zwrite_recip_is_personal(retnotice->z_recipient)) { |
---|
807 | char *buff; |
---|
808 | owl_function_error("No one subscribed to class %s", retnotice->z_class); |
---|
809 | buff = g_strdup_printf("Could not send message to class %s: no one subscribed.\n", retnotice->z_class); |
---|
810 | owl_function_adminmsg("", buff); |
---|
811 | g_free(buff); |
---|
812 | } else { |
---|
813 | char *buff; |
---|
814 | owl_zwrite zw; |
---|
815 | |
---|
816 | tmp = short_zuser(retnotice->z_recipient); |
---|
817 | owl_function_error("%s: Not logged in or subscribing.", tmp); |
---|
818 | /* |
---|
819 | * These error messages are often over 80 chars, but users who want to |
---|
820 | * see the whole thing can scroll to the side, and for those with wide |
---|
821 | * terminals or who don't care, not splitting saves a line in the UI |
---|
822 | */ |
---|
823 | if(strcasecmp(retnotice->z_class, "message")) { |
---|
824 | buff = g_strdup_printf( |
---|
825 | "Could not send message to %s: " |
---|
826 | "not logged in or subscribing to class %s, instance %s.\n", |
---|
827 | tmp, |
---|
828 | retnotice->z_class, |
---|
829 | retnotice->z_class_inst); |
---|
830 | } else if(strcasecmp(retnotice->z_class_inst, "personal")) { |
---|
831 | buff = g_strdup_printf( |
---|
832 | "Could not send message to %s: " |
---|
833 | "not logged in or subscribing to instance %s.\n", |
---|
834 | tmp, |
---|
835 | retnotice->z_class_inst); |
---|
836 | } else { |
---|
837 | buff = g_strdup_printf( |
---|
838 | "Could not send message to %s: " |
---|
839 | "not logged in or subscribing to messages.\n", |
---|
840 | tmp); |
---|
841 | } |
---|
842 | owl_function_adminmsg("", buff); |
---|
843 | |
---|
844 | memset(&zw, 0, sizeof(zw)); |
---|
845 | zw.class = g_strdup(retnotice->z_class); |
---|
846 | zw.inst = g_strdup(retnotice->z_class_inst); |
---|
847 | zw.realm = g_strdup(""); |
---|
848 | zw.opcode = g_strdup(retnotice->z_opcode); |
---|
849 | zw.zsig = g_strdup(""); |
---|
850 | zw.recips = g_ptr_array_new(); |
---|
851 | g_ptr_array_add(zw.recips, g_strdup(retnotice->z_recipient)); |
---|
852 | |
---|
853 | owl_log_outgoing_zephyr_error(&zw, buff); |
---|
854 | |
---|
855 | owl_zwrite_cleanup(&zw); |
---|
856 | g_free(buff); |
---|
857 | g_free(tmp); |
---|
858 | } |
---|
859 | } else { |
---|
860 | owl_function_error("Internal error on ack (%s)", retnotice->z_message); |
---|
861 | } |
---|
862 | } |
---|
863 | #else |
---|
864 | void owl_zephyr_handle_ack(const void *retnotice) |
---|
865 | { |
---|
866 | } |
---|
867 | #endif |
---|
868 | |
---|
869 | #ifdef HAVE_LIBZEPHYR |
---|
870 | int owl_zephyr_notice_is_ack(const ZNotice_t *n) |
---|
871 | { |
---|
872 | if (n->z_kind == SERVNAK || n->z_kind == SERVACK || n->z_kind == HMACK) { |
---|
873 | if (!strcasecmp(n->z_class, LOGIN_CLASS)) return(0); |
---|
874 | return(1); |
---|
875 | } |
---|
876 | return(0); |
---|
877 | } |
---|
878 | #else |
---|
879 | int owl_zephyr_notice_is_ack(const void *n) |
---|
880 | { |
---|
881 | return(0); |
---|
882 | } |
---|
883 | #endif |
---|
884 | |
---|
885 | void owl_zephyr_zaway(const owl_message *m) |
---|
886 | { |
---|
887 | #ifdef HAVE_LIBZEPHYR |
---|
888 | char *tmpbuff, *myuser, *to; |
---|
889 | owl_zwrite *z; |
---|
890 | |
---|
891 | /* bail if it doesn't look like a message we should reply to. Some |
---|
892 | * of this defined by the way zaway(1) works |
---|
893 | */ |
---|
894 | if (strcasecmp(owl_message_get_class(m), "message")) return; |
---|
895 | if (strcasecmp(owl_message_get_recipient(m), ZGetSender())) return; |
---|
896 | if (!strcasecmp(owl_message_get_sender(m), "")) return; |
---|
897 | if (!strcasecmp(owl_message_get_opcode(m), "ping")) return; |
---|
898 | if (!strcasecmp(owl_message_get_opcode(m), "auto")) return; |
---|
899 | if (!strcasecmp(owl_message_get_zsig(m), "Automated reply:")) return; |
---|
900 | if (!strcasecmp(owl_message_get_sender(m), ZGetSender())) return; |
---|
901 | if (owl_message_get_attribute_value(m, "isauto")) return; |
---|
902 | |
---|
903 | if (owl_global_is_smartstrip(&g)) { |
---|
904 | to=owl_zephyr_smartstripped_user(owl_message_get_sender(m)); |
---|
905 | } else { |
---|
906 | to=g_strdup(owl_message_get_sender(m)); |
---|
907 | } |
---|
908 | |
---|
909 | send_zephyr("", |
---|
910 | "Automated reply:", |
---|
911 | owl_message_get_class(m), |
---|
912 | owl_message_get_instance(m), |
---|
913 | to, |
---|
914 | owl_global_get_zaway_msg(&g)); |
---|
915 | |
---|
916 | myuser=short_zuser(to); |
---|
917 | if (!strcasecmp(owl_message_get_instance(m), "personal")) { |
---|
918 | tmpbuff = owl_string_build_quoted("zwrite %q", myuser); |
---|
919 | } else { |
---|
920 | tmpbuff = owl_string_build_quoted("zwrite -i %q %q", owl_message_get_instance(m), myuser); |
---|
921 | } |
---|
922 | g_free(myuser); |
---|
923 | g_free(to); |
---|
924 | |
---|
925 | z = owl_zwrite_new_from_line(tmpbuff); |
---|
926 | g_free(tmpbuff); |
---|
927 | if (z == NULL) { |
---|
928 | owl_function_error("Error creating outgoing zephyr."); |
---|
929 | return; |
---|
930 | } |
---|
931 | owl_zwrite_set_message(z, owl_global_get_zaway_msg(&g)); |
---|
932 | owl_zwrite_set_zsig(z, "Automated reply:"); |
---|
933 | |
---|
934 | /* display the message as an admin message in the receive window */ |
---|
935 | owl_function_add_outgoing_zephyrs(z); |
---|
936 | owl_zwrite_delete(z); |
---|
937 | #endif |
---|
938 | } |
---|
939 | |
---|
940 | #ifdef HAVE_LIBZEPHYR |
---|
941 | void owl_zephyr_hackaway_cr(ZNotice_t *n) |
---|
942 | { |
---|
943 | /* replace \r's with ' '. Gross-ish */ |
---|
944 | int i; |
---|
945 | |
---|
946 | for (i=0; i<n->z_message_len; i++) { |
---|
947 | if (n->z_message[i]=='\r') { |
---|
948 | n->z_message[i]=' '; |
---|
949 | } |
---|
950 | } |
---|
951 | } |
---|
952 | #endif |
---|
953 | |
---|
954 | CALLER_OWN char *owl_zephyr_zlocate(const char *user, int auth) |
---|
955 | { |
---|
956 | #ifdef HAVE_LIBZEPHYR |
---|
957 | int ret, numlocs; |
---|
958 | int one = 1; |
---|
959 | ZLocations_t locations; |
---|
960 | char *myuser; |
---|
961 | char *p, *result; |
---|
962 | |
---|
963 | ZResetAuthentication(); |
---|
964 | ret = ZLocateUser(zstr(user), &numlocs, auth ? ZAUTH : ZNOAUTH); |
---|
965 | if (ret != ZERR_NONE) |
---|
966 | return g_strdup_printf("Error locating user %s: %s\n", |
---|
967 | user, error_message(ret)); |
---|
968 | |
---|
969 | myuser = short_zuser(user); |
---|
970 | if (numlocs == 0) { |
---|
971 | result = g_strdup_printf("%s: Hidden or not logged in\n", myuser); |
---|
972 | } else { |
---|
973 | result = g_strdup(""); |
---|
974 | for (; numlocs; numlocs--) { |
---|
975 | ZGetLocations(&locations, &one); |
---|
976 | p = g_strdup_printf("%s%s: %s\t%s\t%s\n", |
---|
977 | result, myuser, |
---|
978 | locations.host ? locations.host : "?", |
---|
979 | locations.tty ? locations.tty : "?", |
---|
980 | locations.time ? locations.time : "?"); |
---|
981 | g_free(result); |
---|
982 | result = p; |
---|
983 | } |
---|
984 | } |
---|
985 | g_free(myuser); |
---|
986 | |
---|
987 | return result; |
---|
988 | #else |
---|
989 | return g_strdup(""); |
---|
990 | #endif |
---|
991 | } |
---|
992 | |
---|
993 | void owl_zephyr_addsub(const char *filename, const char *class, const char *inst, const char *recip) |
---|
994 | { |
---|
995 | #ifdef HAVE_LIBZEPHYR |
---|
996 | char *line, *subsfile, *s = NULL; |
---|
997 | FILE *file; |
---|
998 | int duplicate = 0; |
---|
999 | |
---|
1000 | line = owl_zephyr_makesubline(class, inst, recip); |
---|
1001 | subsfile = owl_zephyr_dotfile(".zephyr.subs", filename); |
---|
1002 | |
---|
1003 | /* if the file already exists, check to see if the sub is already there */ |
---|
1004 | file = fopen(subsfile, "r"); |
---|
1005 | if (file) { |
---|
1006 | while (owl_getline(&s, file)) { |
---|
1007 | if (strcasecmp(s, line) == 0) { |
---|
1008 | owl_function_error("Subscription already present in %s", subsfile); |
---|
1009 | duplicate++; |
---|
1010 | } |
---|
1011 | } |
---|
1012 | fclose(file); |
---|
1013 | g_free(s); |
---|
1014 | } |
---|
1015 | |
---|
1016 | if (!duplicate) { |
---|
1017 | file = fopen(subsfile, "a"); |
---|
1018 | if (file) { |
---|
1019 | fputs(line, file); |
---|
1020 | fclose(file); |
---|
1021 | owl_function_makemsg("Subscription added"); |
---|
1022 | } else { |
---|
1023 | owl_function_error("Error opening file %s for writing", subsfile); |
---|
1024 | } |
---|
1025 | } |
---|
1026 | |
---|
1027 | g_free(subsfile); |
---|
1028 | g_free(line); |
---|
1029 | #endif |
---|
1030 | } |
---|
1031 | |
---|
1032 | void owl_zephyr_delsub(const char *filename, const char *class, const char *inst, const char *recip) |
---|
1033 | { |
---|
1034 | #ifdef HAVE_LIBZEPHYR |
---|
1035 | char *line, *subsfile; |
---|
1036 | int linesdeleted; |
---|
1037 | |
---|
1038 | line=owl_zephyr_makesubline(class, inst, recip); |
---|
1039 | line[strlen(line)-1]='\0'; |
---|
1040 | |
---|
1041 | subsfile = owl_zephyr_dotfile(".zephyr.subs", filename); |
---|
1042 | |
---|
1043 | linesdeleted = owl_util_file_deleteline(subsfile, line, 1); |
---|
1044 | if (linesdeleted > 0) { |
---|
1045 | owl_function_makemsg("Subscription removed"); |
---|
1046 | } else if (linesdeleted == 0) { |
---|
1047 | owl_function_error("No subscription present in %s", subsfile); |
---|
1048 | } |
---|
1049 | g_free(subsfile); |
---|
1050 | g_free(line); |
---|
1051 | #endif |
---|
1052 | } |
---|
1053 | |
---|
1054 | /* caller must free the return */ |
---|
1055 | CALLER_OWN char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip) |
---|
1056 | { |
---|
1057 | return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip); |
---|
1058 | } |
---|
1059 | |
---|
1060 | |
---|
1061 | void owl_zephyr_zlog_in(void) |
---|
1062 | { |
---|
1063 | #ifdef HAVE_LIBZEPHYR |
---|
1064 | ZResetAuthentication(); |
---|
1065 | |
---|
1066 | /* ZSetLocation, and store the default value as the current value */ |
---|
1067 | owl_global_set_exposure(&g, owl_global_get_default_exposure(&g)); |
---|
1068 | #endif |
---|
1069 | } |
---|
1070 | |
---|
1071 | void owl_zephyr_zlog_out(void) |
---|
1072 | { |
---|
1073 | #ifdef HAVE_LIBZEPHYR |
---|
1074 | Code_t ret; |
---|
1075 | |
---|
1076 | ZResetAuthentication(); |
---|
1077 | ret = ZUnsetLocation(); |
---|
1078 | if (ret != ZERR_NONE) |
---|
1079 | owl_function_error("Error unsetting location: %s", error_message(ret)); |
---|
1080 | #endif |
---|
1081 | } |
---|
1082 | |
---|
1083 | void owl_zephyr_addbuddy(const char *name) |
---|
1084 | { |
---|
1085 | char *filename; |
---|
1086 | FILE *file; |
---|
1087 | |
---|
1088 | filename = owl_zephyr_dotfile(".anyone", NULL); |
---|
1089 | file = fopen(filename, "a"); |
---|
1090 | g_free(filename); |
---|
1091 | if (!file) { |
---|
1092 | owl_function_error("Error opening zephyr buddy file for append"); |
---|
1093 | return; |
---|
1094 | } |
---|
1095 | fprintf(file, "%s\n", name); |
---|
1096 | fclose(file); |
---|
1097 | } |
---|
1098 | |
---|
1099 | void owl_zephyr_delbuddy(const char *name) |
---|
1100 | { |
---|
1101 | char *filename; |
---|
1102 | |
---|
1103 | filename = owl_zephyr_dotfile(".anyone", NULL); |
---|
1104 | owl_util_file_deleteline(filename, name, 0); |
---|
1105 | g_free(filename); |
---|
1106 | } |
---|
1107 | |
---|
1108 | /* return auth string */ |
---|
1109 | #ifdef HAVE_LIBZEPHYR |
---|
1110 | const char *owl_zephyr_get_authstr(const ZNotice_t *n) |
---|
1111 | { |
---|
1112 | |
---|
1113 | if (!n) return("UNKNOWN"); |
---|
1114 | |
---|
1115 | if (n->z_auth == ZAUTH_FAILED) { |
---|
1116 | return ("FAILED"); |
---|
1117 | } else if (n->z_auth == ZAUTH_NO) { |
---|
1118 | return ("NO"); |
---|
1119 | } else if (n->z_auth == ZAUTH_YES) { |
---|
1120 | return ("YES"); |
---|
1121 | } else { |
---|
1122 | return ("UNKNOWN"); |
---|
1123 | } |
---|
1124 | } |
---|
1125 | #else |
---|
1126 | const char *owl_zephyr_get_authstr(const void *n) |
---|
1127 | { |
---|
1128 | return(""); |
---|
1129 | } |
---|
1130 | #endif |
---|
1131 | |
---|
1132 | /* Returns a buffer of subscriptions or an error message. Caller must |
---|
1133 | * free the return. |
---|
1134 | */ |
---|
1135 | CALLER_OWN char *owl_zephyr_getsubs(void) |
---|
1136 | { |
---|
1137 | #ifdef HAVE_LIBZEPHYR |
---|
1138 | Code_t ret; |
---|
1139 | int num, i, one; |
---|
1140 | ZSubscription_t sub; |
---|
1141 | GString *buf; |
---|
1142 | |
---|
1143 | ret = ZRetrieveSubscriptions(0, &num); |
---|
1144 | if (ret != ZERR_NONE) |
---|
1145 | return g_strdup_printf("Zephyr: Requesting subscriptions: %s\n", error_message(ret)); |
---|
1146 | if (num == 0) |
---|
1147 | return g_strdup("Zephyr: No subscriptions retrieved\n"); |
---|
1148 | |
---|
1149 | buf = g_string_new(""); |
---|
1150 | for (i=0; i<num; i++) { |
---|
1151 | one = 1; |
---|
1152 | if ((ret = ZGetSubscriptions(&sub, &one)) != ZERR_NONE) { |
---|
1153 | ZFlushSubscriptions(); |
---|
1154 | g_string_free(buf, true); |
---|
1155 | return g_strdup_printf("Zephyr: Getting subscriptions: %s\n", error_message(ret)); |
---|
1156 | } else { |
---|
1157 | /* g_string_append_printf would be backwards. */ |
---|
1158 | char *tmp = g_strdup_printf("<%s,%s,%s>\n", |
---|
1159 | sub.zsub_class, |
---|
1160 | sub.zsub_classinst, |
---|
1161 | sub.zsub_recipient); |
---|
1162 | g_string_prepend(buf, tmp); |
---|
1163 | g_free(tmp); |
---|
1164 | } |
---|
1165 | } |
---|
1166 | |
---|
1167 | ZFlushSubscriptions(); |
---|
1168 | return g_string_free(buf, false); |
---|
1169 | #else |
---|
1170 | return(g_strdup("Zephyr not available")); |
---|
1171 | #endif |
---|
1172 | } |
---|
1173 | |
---|
1174 | const char *owl_zephyr_get_variable(const char *var) |
---|
1175 | { |
---|
1176 | #ifdef HAVE_LIBZEPHYR |
---|
1177 | return(ZGetVariable(zstr(var))); |
---|
1178 | #else |
---|
1179 | return(""); |
---|
1180 | #endif |
---|
1181 | } |
---|
1182 | |
---|
1183 | void owl_zephyr_set_locationinfo(const char *host, const char *val) |
---|
1184 | { |
---|
1185 | #ifdef HAVE_LIBZEPHYR |
---|
1186 | ZInitLocationInfo(zstr(host), zstr(val)); |
---|
1187 | #endif |
---|
1188 | } |
---|
1189 | |
---|
1190 | const char *owl_zephyr_normalize_exposure(const char *exposure) |
---|
1191 | { |
---|
1192 | if (exposure == NULL) |
---|
1193 | return NULL; |
---|
1194 | #ifdef HAVE_LIBZEPHYR |
---|
1195 | return ZParseExposureLevel(zstr(exposure)); |
---|
1196 | #else |
---|
1197 | return exposure; |
---|
1198 | #endif |
---|
1199 | } |
---|
1200 | |
---|
1201 | int owl_zephyr_set_default_exposure(const char *exposure) |
---|
1202 | { |
---|
1203 | #ifdef HAVE_LIBZEPHYR |
---|
1204 | Code_t ret; |
---|
1205 | if (exposure == NULL) |
---|
1206 | return -1; |
---|
1207 | exposure = ZParseExposureLevel(zstr(exposure)); |
---|
1208 | if (exposure == NULL) |
---|
1209 | return -1; |
---|
1210 | ret = ZSetVariable(zstr("exposure"), zstr(exposure)); /* ZSetVariable does file I/O */ |
---|
1211 | if (ret != ZERR_NONE) { |
---|
1212 | owl_function_error("Unable to set default exposure location: %s", error_message(ret)); |
---|
1213 | return -1; |
---|
1214 | } |
---|
1215 | #endif |
---|
1216 | return 0; |
---|
1217 | } |
---|
1218 | |
---|
1219 | const char *owl_zephyr_get_default_exposure(void) |
---|
1220 | { |
---|
1221 | #ifdef HAVE_LIBZEPHYR |
---|
1222 | const char *exposure = ZGetVariable(zstr("exposure")); /* ZGetVariable does file I/O */ |
---|
1223 | if (exposure == NULL) |
---|
1224 | return EXPOSE_REALMVIS; |
---|
1225 | exposure = ZParseExposureLevel(zstr(exposure)); |
---|
1226 | if (exposure == NULL) /* The user manually entered an invalid value in ~/.zephyr.vars, or something weird happened. */ |
---|
1227 | return EXPOSE_REALMVIS; |
---|
1228 | return exposure; |
---|
1229 | #else |
---|
1230 | return ""; |
---|
1231 | #endif |
---|
1232 | } |
---|
1233 | |
---|
1234 | int owl_zephyr_set_exposure(const char *exposure) |
---|
1235 | { |
---|
1236 | #ifdef HAVE_LIBZEPHYR |
---|
1237 | Code_t ret; |
---|
1238 | if (exposure == NULL) |
---|
1239 | return -1; |
---|
1240 | exposure = ZParseExposureLevel(zstr(exposure)); |
---|
1241 | if (exposure == NULL) |
---|
1242 | return -1; |
---|
1243 | ret = ZSetLocation(zstr(exposure)); |
---|
1244 | if (ret != ZERR_NONE |
---|
1245 | #ifdef ZCONST |
---|
1246 | /* Before zephyr 3.0, ZSetLocation had a bug where, if you were subscribed |
---|
1247 | * to your own logins, it could wait for the wrong notice and return |
---|
1248 | * ZERR_INTERNAL when found neither SERVACK nor SERVNAK. Suppress it when |
---|
1249 | * building against the old ABI. */ |
---|
1250 | && ret != ZERR_INTERNAL |
---|
1251 | #endif |
---|
1252 | ) { |
---|
1253 | owl_function_error("Unable to set exposure level: %s.", error_message(ret)); |
---|
1254 | return -1; |
---|
1255 | } |
---|
1256 | #endif |
---|
1257 | return 0; |
---|
1258 | } |
---|
1259 | |
---|
1260 | /* Strip a local realm fron the zephyr user name. |
---|
1261 | * The caller must free the return |
---|
1262 | */ |
---|
1263 | CALLER_OWN char *short_zuser(const char *in) |
---|
1264 | { |
---|
1265 | char *ptr = strrchr(in, '@'); |
---|
1266 | if (ptr && (ptr[1] == '\0' || !strcasecmp(ptr+1, owl_zephyr_get_realm()))) { |
---|
1267 | return g_strndup(in, ptr - in); |
---|
1268 | } |
---|
1269 | return g_strdup(in); |
---|
1270 | } |
---|
1271 | |
---|
1272 | /* Append a local realm to the zephyr user name if necessary. |
---|
1273 | * The caller must free the return. |
---|
1274 | */ |
---|
1275 | CALLER_OWN char *long_zuser(const char *in) |
---|
1276 | { |
---|
1277 | char *ptr = strrchr(in, '@'); |
---|
1278 | if (ptr) { |
---|
1279 | if (ptr[1]) |
---|
1280 | return g_strdup(in); |
---|
1281 | /* Ends in @, so assume default realm. */ |
---|
1282 | return g_strdup_printf("%s%s", in, owl_zephyr_get_realm()); |
---|
1283 | } |
---|
1284 | return g_strdup_printf("%s@%s", in, owl_zephyr_get_realm()); |
---|
1285 | } |
---|
1286 | |
---|
1287 | /* Return the realm of the zephyr user name. Caller does /not/ free the return. |
---|
1288 | * The string is valid at least as long as the input is. |
---|
1289 | */ |
---|
1290 | const char *zuser_realm(const char *in) |
---|
1291 | { |
---|
1292 | char *ptr = strrchr(in, '@'); |
---|
1293 | /* If the name has an @ and does not end with @, use that. Otherwise, take |
---|
1294 | * the default realm. */ |
---|
1295 | return (ptr && ptr[1]) ? (ptr+1) : owl_zephyr_get_realm(); |
---|
1296 | } |
---|
1297 | |
---|
1298 | /* strip out the instance from a zsender's principal. Preserves the |
---|
1299 | * realm if present. Leave host/ and daemon/ krb5 principals |
---|
1300 | * alone. Also leave rcmd. and daemon. krb4 principals alone. The |
---|
1301 | * caller must free the return. |
---|
1302 | */ |
---|
1303 | CALLER_OWN char *owl_zephyr_smartstripped_user(const char *in) |
---|
1304 | { |
---|
1305 | char *slash, *dot, *realm, *out; |
---|
1306 | |
---|
1307 | out = g_strdup(in); |
---|
1308 | |
---|
1309 | /* bail immeaditly if we don't have to do any work */ |
---|
1310 | slash = strchr(out, '/'); |
---|
1311 | dot = strchr(out, '.'); |
---|
1312 | if (!slash && !dot) { |
---|
1313 | return(out); |
---|
1314 | } |
---|
1315 | |
---|
1316 | if (!strncasecmp(out, OWL_ZEPHYR_NOSTRIP_HOST, strlen(OWL_ZEPHYR_NOSTRIP_HOST)) || |
---|
1317 | !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_RCMD, strlen(OWL_ZEPHYR_NOSTRIP_RCMD)) || |
---|
1318 | !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_DAEMON5, strlen(OWL_ZEPHYR_NOSTRIP_DAEMON5)) || |
---|
1319 | !strncasecmp(out, OWL_ZEPHYR_NOSTRIP_DAEMON4, strlen(OWL_ZEPHYR_NOSTRIP_DAEMON4))) { |
---|
1320 | return(out); |
---|
1321 | } |
---|
1322 | |
---|
1323 | realm = strchr(out, '@'); |
---|
1324 | if (!slash && dot && realm && (dot > realm)) { |
---|
1325 | /* There's no '/', and the first '.' is in the realm */ |
---|
1326 | return(out); |
---|
1327 | } |
---|
1328 | |
---|
1329 | /* remove the realm from out, but hold on to it */ |
---|
1330 | if (realm) realm[0]='\0'; |
---|
1331 | |
---|
1332 | /* strip */ |
---|
1333 | if (slash) slash[0] = '\0'; /* krb5 style user/instance */ |
---|
1334 | else if (dot) dot[0] = '\0'; /* krb4 style user.instance */ |
---|
1335 | |
---|
1336 | /* reattach the realm if we had one */ |
---|
1337 | if (realm) { |
---|
1338 | strcat(out, "@"); |
---|
1339 | strcat(out, realm+1); |
---|
1340 | } |
---|
1341 | |
---|
1342 | return(out); |
---|
1343 | } |
---|
1344 | |
---|
1345 | /* Read the list of users in 'filename' as a .anyone file, and return as a |
---|
1346 | * GPtrArray of strings. If 'filename' is NULL, use the default .anyone file |
---|
1347 | * in the users home directory. Returns NULL on failure. |
---|
1348 | */ |
---|
1349 | GPtrArray *owl_zephyr_get_anyone_list(const char *filename) |
---|
1350 | { |
---|
1351 | #ifdef HAVE_LIBZEPHYR |
---|
1352 | char *ourfile, *tmp, *s = NULL; |
---|
1353 | FILE *f; |
---|
1354 | GPtrArray *list; |
---|
1355 | |
---|
1356 | ourfile = owl_zephyr_dotfile(".anyone", filename); |
---|
1357 | |
---|
1358 | f = fopen(ourfile, "r"); |
---|
1359 | if (!f) { |
---|
1360 | owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : ""); |
---|
1361 | g_free(ourfile); |
---|
1362 | return NULL; |
---|
1363 | } |
---|
1364 | g_free(ourfile); |
---|
1365 | |
---|
1366 | list = g_ptr_array_new(); |
---|
1367 | while (owl_getline_chomp(&s, f)) { |
---|
1368 | /* ignore comments, blank lines etc. */ |
---|
1369 | if (s[0] == '#' || s[0] == '\0') |
---|
1370 | continue; |
---|
1371 | |
---|
1372 | /* ignore from # on */ |
---|
1373 | tmp = strchr(s, '#'); |
---|
1374 | if (tmp) |
---|
1375 | tmp[0] = '\0'; |
---|
1376 | |
---|
1377 | /* ignore from SPC */ |
---|
1378 | tmp = strchr(s, ' '); |
---|
1379 | if (tmp) |
---|
1380 | tmp[0] = '\0'; |
---|
1381 | |
---|
1382 | g_ptr_array_add(list, long_zuser(s)); |
---|
1383 | } |
---|
1384 | g_free(s); |
---|
1385 | fclose(f); |
---|
1386 | return list; |
---|
1387 | #else |
---|
1388 | return NULL; |
---|
1389 | #endif |
---|
1390 | } |
---|
1391 | |
---|
1392 | #ifdef HAVE_LIBZEPHYR |
---|
1393 | void owl_zephyr_process_pseudologin(ZNotice_t *n) |
---|
1394 | { |
---|
1395 | owl_message *m; |
---|
1396 | owl_zbuddylist *zbl; |
---|
1397 | GList **zaldlist; |
---|
1398 | GList *zaldptr; |
---|
1399 | ZAsyncLocateData_t *zald = NULL; |
---|
1400 | ZLocations_t location; |
---|
1401 | int numlocs, ret, notify; |
---|
1402 | |
---|
1403 | /* Find a ZALD to match this notice. */ |
---|
1404 | zaldlist = owl_global_get_zaldlist(&g); |
---|
1405 | zaldptr = g_list_first(*zaldlist); |
---|
1406 | while (zaldptr) { |
---|
1407 | if (ZCompareALDPred(n, zaldptr->data)) { |
---|
1408 | zald = zaldptr->data; |
---|
1409 | *zaldlist = g_list_remove(*zaldlist, zaldptr->data); |
---|
1410 | break; |
---|
1411 | } |
---|
1412 | zaldptr = g_list_next(zaldptr); |
---|
1413 | } |
---|
1414 | if (zald) { |
---|
1415 | /* Deal with notice. */ |
---|
1416 | notify = owl_global_get_pseudologin_notify(&g); |
---|
1417 | zbl = owl_global_get_zephyr_buddylist(&g); |
---|
1418 | ret = ZParseLocations(n, zald, &numlocs, NULL); |
---|
1419 | if (ret == ZERR_NONE) { |
---|
1420 | if (numlocs > 0 && !owl_zbuddylist_contains_user(zbl, zald->user)) { |
---|
1421 | if (notify) { |
---|
1422 | numlocs = 1; |
---|
1423 | ret = ZGetLocations(&location, &numlocs); |
---|
1424 | if (ret == ZERR_NONE) { |
---|
1425 | /* Send a PSEUDO LOGIN! */ |
---|
1426 | m = g_new(owl_message, 1); |
---|
1427 | owl_message_create_pseudo_zlogin(m, 0, zald->user, |
---|
1428 | location.host, |
---|
1429 | location.time, |
---|
1430 | location.tty); |
---|
1431 | owl_global_messagequeue_addmsg(&g, m); |
---|
1432 | } |
---|
1433 | owl_zbuddylist_adduser(zbl, zald->user); |
---|
1434 | owl_function_debugmsg("owl_function_zephyr_buddy_check: login for %s ", zald->user); |
---|
1435 | } |
---|
1436 | } else if (numlocs == 0 && owl_zbuddylist_contains_user(zbl, zald->user)) { |
---|
1437 | /* Send a PSEUDO LOGOUT! */ |
---|
1438 | if (notify) { |
---|
1439 | m = g_new(owl_message, 1); |
---|
1440 | owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", ""); |
---|
1441 | owl_global_messagequeue_addmsg(&g, m); |
---|
1442 | } |
---|
1443 | owl_zbuddylist_deluser(zbl, zald->user); |
---|
1444 | owl_function_debugmsg("owl_function_zephyr_buddy_check: logout for %s ", zald->user); |
---|
1445 | } |
---|
1446 | } |
---|
1447 | ZFreeALD(zald); |
---|
1448 | g_free(zald); |
---|
1449 | } |
---|
1450 | } |
---|
1451 | #else |
---|
1452 | void owl_zephyr_process_pseudologin(void *n) |
---|
1453 | { |
---|
1454 | } |
---|
1455 | #endif |
---|
1456 | |
---|
1457 | gboolean owl_zephyr_buddycheck_timer(void *data) |
---|
1458 | { |
---|
1459 | if (owl_global_is_pseudologins(&g)) { |
---|
1460 | owl_function_debugmsg("Doing zephyr buddy check"); |
---|
1461 | owl_function_zephyr_buddy_check(1); |
---|
1462 | } else { |
---|
1463 | owl_function_debugmsg("Warning: owl_zephyr_buddycheck_timer call pointless; timer should have been disabled"); |
---|
1464 | } |
---|
1465 | return TRUE; |
---|
1466 | } |
---|
1467 | |
---|
1468 | /* |
---|
1469 | * Process zephyrgrams from libzephyr's queue. To prevent starvation, |
---|
1470 | * process a maximum of OWL_MAX_ZEPHYRGRAMS_TO_PROCESS. |
---|
1471 | * |
---|
1472 | * Returns the number of zephyrgrams processed. |
---|
1473 | */ |
---|
1474 | |
---|
1475 | #define OWL_MAX_ZEPHYRGRAMS_TO_PROCESS 20 |
---|
1476 | |
---|
1477 | #ifdef HAVE_LIBZEPHYR |
---|
1478 | static int _owl_zephyr_process_events(void) |
---|
1479 | { |
---|
1480 | int zpendcount=0; |
---|
1481 | ZNotice_t notice; |
---|
1482 | Code_t code; |
---|
1483 | owl_message *m=NULL; |
---|
1484 | |
---|
1485 | while(owl_zephyr_zpending() && zpendcount < OWL_MAX_ZEPHYRGRAMS_TO_PROCESS) { |
---|
1486 | if (owl_zephyr_zpending()) { |
---|
1487 | if ((code = ZReceiveNotice(¬ice, NULL)) != ZERR_NONE) { |
---|
1488 | owl_function_debugmsg("Error: %s while calling ZReceiveNotice\n", |
---|
1489 | error_message(code)); |
---|
1490 | continue; |
---|
1491 | } |
---|
1492 | zpendcount++; |
---|
1493 | |
---|
1494 | /* is this an ack from a zephyr we sent? */ |
---|
1495 | if (owl_zephyr_notice_is_ack(¬ice)) { |
---|
1496 | owl_zephyr_handle_ack(¬ice); |
---|
1497 | ZFreeNotice(¬ice); |
---|
1498 | continue; |
---|
1499 | } |
---|
1500 | |
---|
1501 | /* if it's a ping and we're not viewing pings then skip it */ |
---|
1502 | if (!owl_global_is_rxping(&g) && !strcasecmp(notice.z_opcode, "ping")) { |
---|
1503 | ZFreeNotice(¬ice); |
---|
1504 | continue; |
---|
1505 | } |
---|
1506 | |
---|
1507 | /* if it is a LOCATE message, it's for pseudologins. */ |
---|
1508 | if (strcmp(notice.z_opcode, LOCATE_LOCATE) == 0) { |
---|
1509 | owl_zephyr_process_pseudologin(¬ice); |
---|
1510 | ZFreeNotice(¬ice); |
---|
1511 | continue; |
---|
1512 | } |
---|
1513 | |
---|
1514 | /* create the new message */ |
---|
1515 | m=g_new(owl_message, 1); |
---|
1516 | owl_message_create_from_znotice(m, ¬ice); |
---|
1517 | |
---|
1518 | owl_global_messagequeue_addmsg(&g, m); |
---|
1519 | } |
---|
1520 | } |
---|
1521 | return zpendcount; |
---|
1522 | } |
---|
1523 | |
---|
1524 | typedef struct { /*noproto*/ |
---|
1525 | GSource source; |
---|
1526 | GPollFD poll_fd; |
---|
1527 | } owl_zephyr_event_source; |
---|
1528 | |
---|
1529 | static GSource *owl_zephyr_event_source_new(int fd) { |
---|
1530 | GSource *source; |
---|
1531 | owl_zephyr_event_source *event_source; |
---|
1532 | |
---|
1533 | source = g_source_new(&zephyr_event_funcs, sizeof(owl_zephyr_event_source)); |
---|
1534 | event_source = (owl_zephyr_event_source*) source; |
---|
1535 | event_source->poll_fd.fd = fd; |
---|
1536 | event_source->poll_fd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; |
---|
1537 | g_source_add_poll(source, &event_source->poll_fd); |
---|
1538 | |
---|
1539 | return source; |
---|
1540 | } |
---|
1541 | |
---|
1542 | static gboolean owl_zephyr_event_prepare(GSource *source, int *timeout) { |
---|
1543 | *timeout = -1; |
---|
1544 | return owl_zephyr_zqlength() > 0; |
---|
1545 | } |
---|
1546 | |
---|
1547 | static gboolean owl_zephyr_event_check(GSource *source) { |
---|
1548 | owl_zephyr_event_source *event_source = (owl_zephyr_event_source*)source; |
---|
1549 | if (event_source->poll_fd.revents & event_source->poll_fd.events) |
---|
1550 | return owl_zephyr_zpending() > 0; |
---|
1551 | return FALSE; |
---|
1552 | } |
---|
1553 | |
---|
1554 | static gboolean owl_zephyr_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { |
---|
1555 | _owl_zephyr_process_events(); |
---|
1556 | return TRUE; |
---|
1557 | } |
---|
1558 | #endif |
---|