source: zephyr.c @ 488913a

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