source: zephyr.c @ 7bfc613

release-1.7release-1.8release-1.9
Last change on this file since 7bfc613 was 987cf3f, checked in by Nelson Elhage <nelhage@mit.edu>, 11 years ago
Pass around owl_zwrite objects, instead of continually re-parsing them. In addition to be cleaner and shorter, this fixes a bug where ': zcrypt' ended in an unencrypted zwrite. Reported-by: Tony Valderrama <tvald@mit.edu>
  • Property mode set to 100644
File size: 36.2 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 owl_strdup(input);
26  else
27    return owl_sprintf("%s/%s", owl_global_get_homedir(&g), name);
28}
29
30#ifdef HAVE_LIBZEPHYR
31void owl_zephyr_initialize(void)
32{
33  int ret;
34  struct servent *sp;
35  struct sockaddr_in sin;
36  ZNotice_t req;
37  Code_t code;
38
39  /*
40   * Code modified from libzephyr's ZhmStat.c
41   *
42   * Modified to add the fd to our select loop, rather than hanging
43   * until we get an ack.
44   */
45
46  if ((ret = ZOpenPort(NULL)) != ZERR_NONE) {
47    owl_function_error("Error opening Zephyr port: %s", error_message(ret));
48    return;
49  }
50
51  (void) memset(&sin, 0, sizeof(struct sockaddr_in));
52
53  sp = getservbyname(HM_SVCNAME, "udp");
54
55  sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK;
56  sin.sin_family = AF_INET;
57
58  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
59
60  (void) memset(&req, 0, sizeof(req));
61  req.z_kind = STAT;
62  req.z_port = 0;
63  req.z_class = zstr(HM_STAT_CLASS);
64  req.z_class_inst = zstr(HM_STAT_CLIENT);
65  req.z_opcode = zstr(HM_GIMMESTATS);
66  req.z_sender = zstr("");
67  req.z_recipient = zstr("");
68  req.z_default_format = zstr("");
69  req.z_message_len = 0;
70
71  if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) {
72    owl_function_error("Initializing Zephyr: %s", error_message(code));
73    return;
74  }
75
76  if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) {
77    owl_function_error("Initializing Zephyr: %s", error_message(code));
78    return;
79  }
80
81  owl_select_add_io_dispatch(ZGetFD(), OWL_IO_READ|OWL_IO_EXCEPT, &owl_zephyr_finish_initialization, NULL, NULL);
82}
83
84void owl_zephyr_finish_initialization(const owl_io_dispatch *d, void *data) {
85  Code_t code;
86  char *perl;
87
88  owl_select_remove_io_dispatch(d);
89
90  ZClosePort();
91
92  if ((code = ZInitialize()) != ZERR_NONE) {
93    owl_function_error("Initializing Zephyr: %s", error_message(code));
94    return;
95  }
96
97  if ((code = ZOpenPort(NULL)) != ZERR_NONE) {
98    owl_function_error("Initializing Zephyr: %s", error_message(code));
99    return;
100  }
101
102  owl_select_add_io_dispatch(ZGetFD(), OWL_IO_READ|OWL_IO_EXCEPT, &owl_zephyr_process_events, NULL, NULL);
103
104  owl_global_set_havezephyr(&g);
105
106  if(g.load_initial_subs) {
107    owl_zephyr_load_initial_subs();
108  }
109  while(deferred_subs != NULL) {
110    owl_sub_list *subs = deferred_subs->data;
111    owl_function_debugmsg("Loading %d deferred subs.", subs->nsubs);
112    owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs);
113    deferred_subs = g_list_delete_link(deferred_subs, deferred_subs);
114    owl_free(subs);
115  }
116
117  /* zlog in if we need to */
118  if (owl_global_is_startuplogin(&g)) {
119    owl_function_debugmsg("startup: doing zlog in");
120    owl_zephyr_zlog_in();
121  }
122  /* check pseudo-logins if we need to */
123  if (owl_global_is_pseudologins(&g)) {
124    owl_function_debugmsg("startup: checking pseudo-logins");
125    owl_function_zephyr_buddy_check(0);
126  }
127
128  perl = owl_perlconfig_execute("BarnOwl::Zephyr::_zephyr_startup()");
129  owl_free(perl);
130
131  owl_select_add_pre_select_action(owl_zephyr_pre_select_action, NULL, NULL);
132}
133
134void owl_zephyr_load_initial_subs(void) {
135  int ret_sd, ret_bd, ret_u;
136
137  owl_function_debugmsg("startup: loading initial zephyr subs");
138
139  /* load default subscriptions */
140  ret_sd = owl_zephyr_loaddefaultsubs();
141
142  /* load Barnowl default subscriptions */
143  ret_bd = owl_zephyr_loadbarnowldefaultsubs();
144
145  /* load subscriptions from subs file */
146  ret_u = owl_zephyr_loadsubs(NULL, 0);
147
148  if (ret_sd || ret_bd || ret_u) {
149    owl_function_error("Error loading zephyr subscriptions");
150  } else if (ret_u!=-1) {
151    owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES);
152  }
153
154  /* load login subscriptions */
155  if (owl_global_is_loginsubs(&g)) {
156    owl_function_debugmsg("startup: loading login subs");
157    owl_function_loadloginsubs(NULL);
158  }
159}
160#else
161void owl_zephyr_initialize(void)
162{
163}
164#endif
165
166
167int owl_zephyr_shutdown(void)
168{
169#ifdef HAVE_LIBZEPHYR
170  if(owl_global_is_havezephyr(&g)) {
171    unsuball();
172    ZClosePort();
173  }
174#endif
175  return 0;
176}
177
178int owl_zephyr_zpending(void)
179{
180#ifdef HAVE_LIBZEPHYR
181  if(owl_global_is_havezephyr(&g))
182    return(ZPending());
183#endif
184  return 0;
185}
186
187const char *owl_zephyr_get_realm(void)
188{
189#ifdef HAVE_LIBZEPHYR
190  if (owl_global_is_havezephyr(&g))
191    return(ZGetRealm());
192#endif
193  return "";
194}
195
196const char *owl_zephyr_get_sender(void)
197{
198#ifdef HAVE_LIBZEPHYR
199  if (owl_global_is_havezephyr(&g))
200    return(ZGetSender());
201#endif
202  return "";
203}
204
205#ifdef HAVE_LIBZEPHYR
206int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count)
207{
208  int ret = 0;
209  if (owl_global_is_havezephyr(&g)) {
210    int i;
211    /* sub without defaults */
212    if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
213      owl_function_error("Error subscribing to zephyr notifications.");
214      ret=-2;
215    }
216
217    /* free stuff */
218    for (i=0; i<count; i++) {
219      owl_free(subs[i].zsub_class);
220      owl_free(subs[i].zsub_classinst);
221      owl_free(subs[i].zsub_recipient);
222    }
223
224    owl_free(subs);
225  } else {
226    owl_sub_list *s = owl_malloc(sizeof(owl_sub_list));
227    s->subs = subs;
228    s->nsubs = count;
229    deferred_subs = g_list_append(deferred_subs, s);
230  }
231
232  return ret;
233}
234#endif
235
236/* Load zephyr subscriptions from 'filename'.  If 'filename' is NULL,
237 * the default file $HOME/.zephyr.subs will be used.
238 *
239 * Returns 0 on success.  If the file does not exist, return -1 if
240 * 'error_on_nofile' is 1, otherwise return 0.  Return -1 if the file
241 * exists but can not be read.  Return -2 if there is a failure from
242 * zephyr to load the subscriptions.
243 */
244int owl_zephyr_loadsubs(const char *filename, int error_on_nofile)
245{
246#ifdef HAVE_LIBZEPHYR
247  FILE *file;
248  char *tmp, *start;
249  char *buffer = NULL;
250  char *subsfile;
251  ZSubscription_t *subs;
252  int subSize = 1024;
253  int count;
254  struct stat statbuff;
255
256  subs = owl_malloc(sizeof(ZSubscription_t) * subSize);
257  subsfile = owl_zephyr_dotfile(".zephyr.subs", filename);
258
259  if (stat(subsfile, &statbuff) != 0) {
260    owl_free(subsfile);
261    if (error_on_nofile == 1)
262      return -1;
263    return 0;
264  }
265
266  ZResetAuthentication();
267  count = 0;
268  file = fopen(subsfile, "r");
269  owl_free(subsfile);
270  if (!file)
271    return -1;
272  while (owl_getline(&buffer, file)) {
273    if (buffer[0] == '#' || buffer[0] == '\n')
274        continue;
275
276    if (buffer[0] == '-')
277      start = buffer + 1;
278    else
279      start = buffer;
280
281    if (count >= subSize) {
282      subSize *= 2;
283      subs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize);
284    }
285   
286    /* add it to the list of subs */
287    if ((tmp = strtok(start, ",\n\r")) == NULL)
288      continue;
289    subs[count].zsub_class = owl_strdup(tmp);
290    if ((tmp=strtok(NULL, ",\n\r")) == NULL)
291      continue;
292    subs[count].zsub_classinst = owl_strdup(tmp);
293    if ((tmp = strtok(NULL, " \t\n\r")) == NULL)
294      continue;
295    subs[count].zsub_recipient = owl_strdup(tmp);
296
297    /* if it started with '-' then add it to the global punt list, and
298     * remove it from the list of subs. */
299    if (buffer[0] == '-') {
300      owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0);
301      owl_free(subs[count].zsub_class);
302      owl_free(subs[count].zsub_classinst);
303      owl_free(subs[count].zsub_recipient);
304    } else {
305      count++;
306    }
307  }
308  fclose(file);
309  if (buffer)
310    owl_free(buffer);
311
312  return owl_zephyr_loadsubs_helper(subs, count);
313#else
314  return 0;
315#endif
316}
317
318/* Load default Barnowl subscriptions
319 *
320 * Returns 0 on success.
321 * Return -2 if there is a failure from zephyr to load the subscriptions.
322 */
323int owl_zephyr_loadbarnowldefaultsubs(void)
324{
325#ifdef HAVE_LIBZEPHYR
326  ZSubscription_t *subs;
327  int subSize = 10; /* Max Barnowl default subs we allow */
328  int count, ret;
329
330  subs = owl_malloc(sizeof(ZSubscription_t) * subSize);
331  ret = 0;
332  ZResetAuthentication();
333  count=0;
334
335  subs[count].zsub_class=owl_strdup("message");
336  subs[count].zsub_classinst=owl_strdup("*");
337  subs[count].zsub_recipient=owl_strdup("%me%");
338  count++;
339
340  ret = owl_zephyr_loadsubs_helper(subs, count);
341  return(ret);
342#else
343  return(0);
344#endif
345}
346
347int owl_zephyr_loaddefaultsubs(void)
348{
349#ifdef HAVE_LIBZEPHYR
350  ZSubscription_t subs[10];
351   
352  if (ZSubscribeTo(subs,0,0) != ZERR_NONE) {
353    owl_function_error("Error subscribing to default zephyr notifications.");
354    return(-1);
355  }
356  return(0);
357#else
358  return(0);
359#endif
360}
361
362int owl_zephyr_loadloginsubs(const char *filename)
363{
364#ifdef HAVE_LIBZEPHYR
365  FILE *file;
366  ZSubscription_t *subs;
367  int numSubs = 100;
368  char *subsfile;
369  char *buffer = NULL;
370  int count;
371  struct stat statbuff;
372
373  subs = owl_malloc(numSubs * sizeof(ZSubscription_t));
374  subsfile = owl_zephyr_dotfile(".anyone", filename);
375
376  if (stat(subsfile, &statbuff) == -1) {
377    owl_free(subsfile);
378    return 0;
379  }
380
381  ZResetAuthentication();
382  count = 0;
383  file = fopen(subsfile, "r");
384  owl_free(subsfile);
385  if (file) {
386    while (owl_getline_chomp(&buffer, file)) {
387      if (buffer[0] == '\0' || buffer[0] == '#')
388        continue;
389
390      if (count == numSubs) {
391        numSubs *= 2;
392        subs = owl_realloc(subs, numSubs * sizeof(ZSubscription_t));
393      }
394
395      subs[count].zsub_class = owl_strdup("login");
396      subs[count].zsub_recipient = owl_strdup("*");
397      subs[count].zsub_classinst = long_zuser(buffer);
398
399      count++;
400    }
401    fclose(file);
402  } else {
403    return 0;
404  }
405  if (buffer)
406    owl_free(buffer);
407
408  return owl_zephyr_loadsubs_helper(subs, count);
409#else
410  return 0;
411#endif
412}
413
414void unsuball(void)
415{
416#if HAVE_LIBZEPHYR
417  int ret;
418
419  ZResetAuthentication();
420  ret=ZCancelSubscriptions(0);
421  if (ret != ZERR_NONE) {
422    com_err("owl",ret,"while unsubscribing");
423  }
424#endif
425}
426
427int owl_zephyr_sub(const char *class, const char *inst, const char *recip)
428{
429#ifdef HAVE_LIBZEPHYR
430  ZSubscription_t subs[5];
431
432  subs[0].zsub_class=zstr(class);
433  subs[0].zsub_classinst=zstr(inst);
434  subs[0].zsub_recipient=zstr(recip);
435
436  ZResetAuthentication();
437  if (ZSubscribeTo(subs,1,0) != ZERR_NONE) {
438    owl_function_error("Error subbing to <%s,%s,%s>", class, inst, recip);
439    return(-2);
440  }
441  return(0);
442#else
443  return(0);
444#endif
445}
446
447
448int owl_zephyr_unsub(const char *class, const char *inst, const char *recip)
449{
450#ifdef HAVE_LIBZEPHYR
451  ZSubscription_t subs[5];
452
453  subs[0].zsub_class=zstr(class);
454  subs[0].zsub_classinst=zstr(inst);
455  subs[0].zsub_recipient=zstr(recip);
456
457  ZResetAuthentication();
458  if (ZUnsubscribeTo(subs,1,0) != ZERR_NONE) {
459    owl_function_error("Error unsubbing from <%s,%s,%s>", class, inst, recip);
460    return(-2);
461  }
462  return(0);
463#else
464  return(0);
465#endif
466}
467
468/* return a pointer to the data in the Jth field, (NULL terminated by
469 * definition).  Caller must free the return.
470 */
471#ifdef HAVE_LIBZEPHYR
472char *owl_zephyr_get_field(const ZNotice_t *n, int j)
473{
474  int i, count, save;
475  char *out;
476
477  /* If there's no message here, just run along now */
478  if (n->z_message_len == 0)
479    return(owl_strdup(""));
480
481  count=save=0;
482  for (i=0; i<n->z_message_len; i++) {
483    if (n->z_message[i]=='\0') {
484      count++;
485      if (count==j) {
486        /* just found the end of the field we're looking for */
487        return(owl_strdup(n->z_message+save));
488      } else {
489        save=i+1;
490      }
491    }
492  }
493  /* catch the last field, which might not be null terminated */
494  if (count==j-1) {
495    out=owl_malloc(n->z_message_len-save+5);
496    memcpy(out, n->z_message+save, n->z_message_len-save);
497    out[n->z_message_len-save]='\0';
498    return(out);
499  }
500
501  return(owl_strdup(""));
502}
503
504char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
505{
506  int i, count, save;
507
508  /* If there's no message here, just run along now */
509  if (n->z_message_len == 0)
510    return(owl_strdup(""));
511
512  count=save=0;
513  for (i = 0; i < n->z_message_len; i++) {
514    if (n->z_message[i]=='\0') {
515      count++;
516      if (count == j) {
517        /* just found the end of the field we're looking for */
518        return(owl_validate_or_convert(n->z_message + save));
519      } else {
520        save = i + 1;
521      }
522    }
523  }
524  /* catch the last field, which might not be null terminated */
525  if (count == j - 1) {
526    char *tmp, *out;
527    tmp = owl_malloc(n->z_message_len-save+5);
528    memcpy(tmp, n->z_message+save, n->z_message_len-save);
529    tmp[n->z_message_len-save]='\0';
530    out = owl_validate_or_convert(tmp);
531    owl_free(tmp);
532    return out;
533  }
534
535  return(owl_strdup(""));
536}
537#else
538char *owl_zephyr_get_field(void *n, int j)
539{
540  return(owl_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(owl_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 = owl_sprintf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, field3, field4);
590    owl_free(field3);
591    owl_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 = owl_sprintf("New transaction [%s] entered in %s\nFrom: %s (%s)\nSubject: %s", field1, field2, field3, field5, field4);
608    owl_free(field1);
609    owl_free(field2);
610    owl_free(field3);
611    owl_free(field4);
612    owl_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 = owl_sprintf("MOIRA %s on %s: %s", n->z_class_inst, owl_message_get_hostname(m), field1);
624    owl_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=owl_malloc(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  owl_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        owl_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    #define BUFFLEN 1024
764    if (retnotice->z_recipient == NULL
765        || *retnotice->z_recipient == 0
766        || *retnotice->z_recipient == '@') {
767      char buff[BUFFLEN];
768      owl_function_error("No one subscribed to class %s", retnotice->z_class);
769      snprintf(buff, BUFFLEN, "Could not send message to class %s: no one subscribed.\n", retnotice->z_class);
770      owl_function_adminmsg("", buff);
771    } else {
772      char buff[BUFFLEN];
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        snprintf(buff, BUFFLEN,
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        snprintf(buff, BUFFLEN,
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        snprintf(buff, BUFFLEN,
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 = owl_strdup(retnotice->z_class);
806      zw.inst  = owl_strdup(retnotice->z_class_inst);
807      realm = strchr(retnotice->z_recipient, '@');
808      if(realm) {
809        zw.realm = owl_strdup(realm + 1);
810      } else {
811        zw.realm = owl_strdup(owl_zephyr_get_realm());
812      }
813      zw.opcode = owl_strdup(retnotice->z_opcode);
814      zw.zsig   = owl_strdup("");
815      owl_list_create(&(zw.recips));
816      owl_list_append_element(&(zw.recips), owl_strdup(tmp));
817
818      owl_log_outgoing_zephyr_error(&zw, buff);
819
820      owl_zwrite_cleanup(&zw);
821      owl_free(tmp);
822    }
823  } else {
824    owl_function_error("Internal error on ack (%s)", retnotice->z_message);
825  }
826}
827#else
828void owl_zephyr_handle_ack(const void *retnotice)
829{
830}
831#endif
832
833#ifdef HAVE_LIBZEPHYR
834int owl_zephyr_notice_is_ack(const ZNotice_t *n)
835{
836  if (n->z_kind == SERVNAK || n->z_kind == SERVACK || n->z_kind == HMACK) {
837    if (!strcasecmp(n->z_class, LOGIN_CLASS)) return(0);
838    return(1);
839  }
840  return(0);
841}
842#else
843int owl_zephyr_notice_is_ack(const void *n)
844{
845  return(0);
846}
847#endif
848 
849void owl_zephyr_zaway(const owl_message *m)
850{
851#ifdef HAVE_LIBZEPHYR
852  char *tmpbuff, *myuser, *to;
853  owl_message *mout;
854  owl_zwrite *z;
855 
856  /* bail if it doesn't look like a message we should reply to.  Some
857   * of this defined by the way zaway(1) works
858   */
859  if (strcasecmp(owl_message_get_class(m), "message")) return;
860  if (strcasecmp(owl_message_get_recipient(m), ZGetSender())) return;
861  if (!strcasecmp(owl_message_get_sender(m), "")) return;
862  if (!strcasecmp(owl_message_get_opcode(m), "ping")) return;
863  if (!strcasecmp(owl_message_get_opcode(m), "auto")) return;
864  if (!strcasecmp(owl_message_get_zsig(m), "Automated reply:")) return;
865  if (!strcasecmp(owl_message_get_sender(m), ZGetSender())) return;
866  if (owl_message_get_attribute_value(m, "isauto")) return;
867
868  if (owl_global_is_smartstrip(&g)) {
869    to=owl_zephyr_smartstripped_user(owl_message_get_sender(m));
870  } else {
871    to=owl_strdup(owl_message_get_sender(m));
872  }
873
874  send_zephyr("",
875              "Automated reply:",
876              owl_message_get_class(m),
877              owl_message_get_instance(m),
878              to,
879              owl_global_get_zaway_msg(&g));
880
881  myuser=short_zuser(to);
882  if (!strcasecmp(owl_message_get_instance(m), "personal")) {
883    tmpbuff = owl_sprintf("zwrite %s", myuser);
884  } else {
885    tmpbuff = owl_sprintf("zwrite -i %s %s", owl_message_get_instance(m), myuser);
886  }
887  owl_free(myuser);
888  owl_free(to);
889
890  z = owl_zwrite_new(tmpbuff);
891  owl_zwrite_set_message(z, owl_global_get_zaway_msg(&g));
892  owl_zwrite_set_zsig(z, "Automated reply:");
893
894  /* display the message as an admin message in the receive window */
895  mout=owl_function_make_outgoing_zephyr(z);
896  owl_global_messagequeue_addmsg(&g, mout);
897  owl_free(tmpbuff);
898  owl_zwrite_delete(z);
899#endif
900}
901
902#ifdef HAVE_LIBZEPHYR
903void owl_zephyr_hackaway_cr(ZNotice_t *n)
904{
905  /* replace \r's with ' '.  Gross-ish */
906  int i;
907
908  for (i=0; i<n->z_message_len; i++) {
909    if (n->z_message[i]=='\r') {
910      n->z_message[i]=' ';
911    }
912  }
913}
914#endif
915
916char *owl_zephyr_zlocate(const char *user, int auth)
917{
918#ifdef HAVE_LIBZEPHYR
919  int ret, numlocs;
920  int one = 1;
921  ZLocations_t locations;
922  char *myuser;
923  char *p, *result;
924
925  ZResetAuthentication();
926  ret = ZLocateUser(zstr(user), &numlocs, auth ? ZAUTH : ZNOAUTH);
927  if (ret != ZERR_NONE)
928    return owl_sprintf("Error locating user %s: %s\n",
929                       user, error_message(ret));
930
931  myuser = short_zuser(user);
932  if (numlocs == 0) {
933    result = owl_sprintf("%s: Hidden or not logged in\n", myuser);
934  } else {
935    result = owl_strdup("");
936    for (; numlocs; numlocs--) {
937      ZGetLocations(&locations, &one);
938      p = owl_sprintf("%s%s: %s\t%s\t%s\n",
939                          result, myuser,
940                          locations.host ? locations.host : "?",
941                          locations.tty ? locations.tty : "?",
942                          locations.time ? locations.time : "?");
943      owl_free(result);
944      result = p;
945    }
946  }
947
948  return result;
949#else
950  return owl_strdup("");
951#endif
952}
953
954void owl_zephyr_addsub(const char *filename, const char *class, const char *inst, const char *recip)
955{
956#ifdef HAVE_LIBZEPHYR
957  char *line, *subsfile, *s = NULL;
958  FILE *file;
959  int duplicate = 0;
960
961  line = owl_zephyr_makesubline(class, inst, recip);
962  subsfile = owl_zephyr_dotfile(".zephyr.subs", filename);
963
964  /* if the file already exists, check to see if the sub is already there */
965  file = fopen(subsfile, "r");
966  if (file) {
967    while (owl_getline(&s, file)) {
968      if (strcasecmp(s, line) == 0) {
969        owl_function_error("Subscription already present in %s", subsfile);
970        duplicate++;
971      }
972    }
973    fclose(file);
974    owl_free(s);
975  }
976
977  if (!duplicate) {
978    file = fopen(subsfile, "a");
979    if (file) {
980      fputs(line, file);
981      fclose(file);
982      owl_function_makemsg("Subscription added");
983    } else {
984      owl_function_error("Error opening file %s for writing", subsfile);
985    }
986  }
987
988  owl_free(line);
989#endif
990}
991
992void owl_zephyr_delsub(const char *filename, const char *class, const char *inst, const char *recip)
993{
994#ifdef HAVE_LIBZEPHYR
995  char *line, *subsfile;
996  int linesdeleted;
997 
998  line=owl_zephyr_makesubline(class, inst, recip);
999  line[strlen(line)-1]='\0';
1000
1001  subsfile = owl_zephyr_dotfile(".zephyr.subs", filename);
1002 
1003  linesdeleted = owl_util_file_deleteline(subsfile, line, 1);
1004  if (linesdeleted > 0) {
1005    owl_function_makemsg("Subscription removed");
1006  } else {
1007    owl_function_error("No subscription present in %s", subsfile);
1008  }
1009  owl_free(subsfile);
1010  owl_free(line);
1011#endif
1012}
1013
1014/* caller must free the return */
1015char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
1016{
1017  return owl_sprintf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
1018}
1019
1020
1021void owl_zephyr_zlog_in(void)
1022{
1023#ifdef HAVE_LIBZEPHYR
1024  const char *exposure, *eset;
1025  int ret;
1026
1027  ZResetAuthentication();
1028   
1029  eset=EXPOSE_REALMVIS;
1030  exposure=ZGetVariable(zstr("exposure"));
1031  if (exposure==NULL) {
1032    eset=EXPOSE_REALMVIS;
1033  } else if (!strcasecmp(exposure,EXPOSE_NONE)) {
1034    eset = EXPOSE_NONE;
1035  } else if (!strcasecmp(exposure,EXPOSE_OPSTAFF)) {
1036    eset = EXPOSE_OPSTAFF;
1037  } else if (!strcasecmp(exposure,EXPOSE_REALMVIS)) {
1038    eset = EXPOSE_REALMVIS;
1039  } else if (!strcasecmp(exposure,EXPOSE_REALMANN)) {
1040    eset = EXPOSE_REALMANN;
1041  } else if (!strcasecmp(exposure,EXPOSE_NETVIS)) {
1042    eset = EXPOSE_NETVIS;
1043  } else if (!strcasecmp(exposure,EXPOSE_NETANN)) {
1044    eset = EXPOSE_NETANN;
1045  }
1046   
1047  ret=ZSetLocation(zstr(eset));
1048  if (ret != ZERR_NONE) {
1049    /*
1050      owl_function_makemsg("Error setting location: %s", error_message(ret));
1051    */
1052  }
1053#endif
1054}
1055
1056void owl_zephyr_zlog_out(void)
1057{
1058#ifdef HAVE_LIBZEPHYR
1059  int ret;
1060
1061  ZResetAuthentication();
1062  ret=ZUnsetLocation();
1063  if (ret != ZERR_NONE) {
1064    /*
1065      owl_function_makemsg("Error unsetting location: %s", error_message(ret));
1066    */
1067  }
1068#endif
1069}
1070
1071void owl_zephyr_addbuddy(const char *name)
1072{
1073  char *filename;
1074  FILE *file;
1075 
1076  filename = owl_zephyr_dotfile(".anyone", NULL);
1077  file = fopen(filename, "a");
1078  owl_free(filename);
1079  if (!file) {
1080    owl_function_error("Error opening zephyr buddy file for append");
1081    return;
1082  }
1083  fprintf(file, "%s\n", name);
1084  fclose(file);
1085}
1086
1087void owl_zephyr_delbuddy(const char *name)
1088{
1089  char *filename;
1090
1091  filename = owl_zephyr_dotfile(".anyone", NULL);
1092  owl_util_file_deleteline(filename, name, 0);
1093  owl_free(filename);
1094}
1095
1096/* return auth string */
1097#ifdef HAVE_LIBZEPHYR
1098const char *owl_zephyr_get_authstr(const ZNotice_t *n)
1099{
1100
1101  if (!n) return("UNKNOWN");
1102
1103  if (n->z_auth == ZAUTH_FAILED) {
1104    return ("FAILED");
1105  } else if (n->z_auth == ZAUTH_NO) {
1106    return ("NO");
1107  } else if (n->z_auth == ZAUTH_YES) {
1108    return ("YES");
1109  } else {
1110    return ("UNKNOWN");
1111  }           
1112}
1113#else
1114const char *owl_zephyr_get_authstr(const void *n)
1115{
1116  return("");
1117}
1118#endif
1119
1120/* Returns a buffer of subscriptions or an error message.  Caller must
1121 * free the return.
1122 */
1123char *owl_zephyr_getsubs(void)
1124{
1125#ifdef HAVE_LIBZEPHYR
1126  int ret, num, i, one;
1127  int buffsize;
1128  ZSubscription_t sub;
1129  char *out;
1130  one=1;
1131
1132  ret=ZRetrieveSubscriptions(0, &num);
1133  if (ret==ZERR_TOOMANYSUBS) {
1134    return(owl_strdup("Zephyr: too many subscriptions\n"));
1135  } else if (ret || (num <= 0)) {
1136    return(owl_strdup("Zephyr: error retriving subscriptions\n"));
1137  }
1138
1139  buffsize = (num + 1) * 50;
1140  out=owl_malloc(buffsize);
1141  strcpy(out, "");
1142  for (i=0; i<num; i++) {
1143    if ((ret = ZGetSubscriptions(&sub, &one)) != ZERR_NONE) {
1144      owl_free(out);
1145      ZFlushSubscriptions();
1146      out=owl_strdup("Error while getting subscriptions\n");
1147      return(out);
1148    } else {
1149      int tmpbufflen;
1150      char *tmpbuff;
1151      tmpbuff = owl_sprintf("<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out);
1152      tmpbufflen = strlen(tmpbuff) + 1;
1153      if (tmpbufflen > buffsize) {
1154        char *out2;
1155        buffsize = tmpbufflen * 2;
1156        out2 = owl_realloc(out, buffsize);
1157        if (out2 == NULL) {
1158          owl_free(out);
1159          owl_free(tmpbuff);
1160          ZFlushSubscriptions();
1161          out=owl_strdup("Realloc error while getting subscriptions\n");
1162          return(out);   
1163        }
1164        out = out2;
1165      }
1166      strcpy(out, tmpbuff);
1167      owl_free(tmpbuff);
1168    }
1169  }
1170
1171  ZFlushSubscriptions();
1172  return(out);
1173#else
1174  return(owl_strdup("Zephyr not available"));
1175#endif
1176}
1177
1178const char *owl_zephyr_get_variable(const char *var)
1179{
1180#ifdef HAVE_LIBZEPHYR
1181  return(ZGetVariable(zstr(var)));
1182#else
1183  return("");
1184#endif
1185}
1186
1187void owl_zephyr_set_locationinfo(const char *host, const char *val)
1188{
1189#ifdef HAVE_LIBZEPHYR
1190  ZInitLocationInfo(zstr(host), zstr(val));
1191#endif
1192}
1193 
1194/* Strip a local realm fron the zephyr user name.
1195 * The caller must free the return
1196 */
1197char *short_zuser(const char *in)
1198{
1199  char *out, *ptr;
1200
1201  out=owl_strdup(in);
1202  ptr=strchr(out, '@');
1203  if (ptr) {
1204    if (!strcasecmp(ptr+1, owl_zephyr_get_realm())) {
1205      *ptr='\0';
1206    }
1207  }
1208  return(out);
1209}
1210
1211/* Append a local realm to the zephyr user name if necessary.
1212 * The caller must free the return.
1213 */
1214char *long_zuser(const char *in)
1215{
1216  if (strchr(in, '@')) {
1217    return(owl_strdup(in));
1218  }
1219  return(owl_sprintf("%s@%s", in, owl_zephyr_get_realm()));
1220}
1221
1222/* strip out the instance from a zsender's principal.  Preserves the
1223 * realm if present.  daemon.webzephyr is a special case.  The
1224 * caller must free the return
1225 */
1226char *owl_zephyr_smartstripped_user(const char *in)
1227{
1228  char *ptr, *realm, *out;
1229
1230  out=owl_strdup(in);
1231
1232  /* bail immeaditly if we don't have to do any work */
1233  ptr=strchr(out, '.');
1234  if (!strchr(out, '/') && !ptr) {
1235    /* no '/' and no '.' */
1236    return(out);
1237  }
1238  if (ptr && strchr(out, '@') && (ptr > strchr(out, '@'))) {
1239    /* There's a '.' but it's in the realm */
1240    return(out);
1241  }
1242  if (!strncasecmp(out, OWL_WEBZEPHYR_PRINCIPAL, strlen(OWL_WEBZEPHYR_PRINCIPAL))) {
1243    return(out);
1244  }
1245
1246  /* remove the realm from out, but hold on to it */
1247  realm=strchr(out, '@');
1248  if (realm) realm[0]='\0';
1249
1250  /* strip */
1251  ptr=strchr(out, '.');
1252  if (!ptr) ptr=strchr(out, '/');
1253  ptr[0]='\0';
1254
1255  /* reattach the realm if we had one */
1256  if (realm) {
1257    strcat(out, "@");
1258    strcat(out, realm+1);
1259  }
1260
1261  return(out);
1262}
1263
1264/* read the list of users in 'filename' as a .anyone file, and put the
1265 * names of the zephyr users in the list 'in'.  If 'filename' is NULL,
1266 * use the default .anyone file in the users home directory.  Returns
1267 * -1 on failure, 0 on success.
1268 */
1269int owl_zephyr_get_anyone_list(owl_list *in, const char *filename)
1270{
1271#ifdef HAVE_LIBZEPHYR
1272  char *ourfile, *tmp, *s = NULL;
1273  FILE *f;
1274
1275  ourfile = owl_zephyr_dotfile(".anyone", filename);
1276
1277  f = fopen(ourfile, "r");
1278  if (!f) {
1279    owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : "");
1280    owl_free(ourfile);
1281    return -1;
1282  }
1283  owl_free(ourfile);
1284
1285  while (owl_getline_chomp(&s, f)) {
1286    /* ignore comments, blank lines etc. */
1287    if (s[0] == '#' || s[0] == '\0')
1288      continue;
1289
1290    /* ignore from # on */
1291    tmp = strchr(s, '#');
1292    if (tmp)
1293      tmp[0] = '\0';
1294
1295    /* ignore from SPC */
1296    tmp = strchr(s, ' ');
1297    if (tmp)
1298      tmp[0] = '\0';
1299
1300    owl_list_append_element(in, long_zuser(s));
1301  }
1302  owl_free(s);
1303  fclose(f);
1304  return 0;
1305#else
1306  return -1;
1307#endif
1308}
1309
1310#ifdef HAVE_LIBZEPHYR
1311void owl_zephyr_process_pseudologin(ZNotice_t *n)
1312{
1313  owl_message *m;
1314  owl_zbuddylist *zbl;
1315  GList **zaldlist;
1316  GList *zaldptr;
1317  ZAsyncLocateData_t *zald = NULL;
1318  ZLocations_t location;
1319  int numlocs, ret, notify;
1320
1321  /* Find a ZALD to match this notice. */
1322  zaldlist = owl_global_get_zaldlist(&g);
1323  zaldptr = g_list_first(*zaldlist);
1324  while (zaldptr) {
1325    if (ZCompareALDPred(n, zaldptr->data)) {
1326      zald = zaldptr->data;
1327      *zaldlist = g_list_remove(*zaldlist, zaldptr->data);
1328      break;
1329    }
1330    zaldptr = g_list_next(zaldptr);
1331  }
1332  if (zald) {
1333    /* Deal with notice. */
1334    notify = owl_global_get_pseudologin_notify(&g);
1335    zbl = owl_global_get_zephyr_buddylist(&g);
1336    ret = ZParseLocations(n, zald, &numlocs, NULL);
1337    if (ret == ZERR_NONE) {
1338      if (numlocs > 0 && !owl_zbuddylist_contains_user(zbl, zald->user)) {
1339        if (notify) {
1340          numlocs = 1;
1341          ret = ZGetLocations(&location, &numlocs);
1342          if (ret == ZERR_NONE) {
1343            /* Send a PSEUDO LOGIN! */
1344            m = owl_malloc(sizeof(owl_message));
1345            owl_message_create_pseudo_zlogin(m, 0, zald->user,
1346                                             location.host,
1347                                             location.time,
1348                                             location.tty);
1349            owl_global_messagequeue_addmsg(&g, m);
1350          }
1351          owl_zbuddylist_adduser(zbl, zald->user);
1352          owl_function_debugmsg("owl_function_zephyr_buddy_check: login for %s ", zald->user);
1353        }
1354      } else if (numlocs == 0 && owl_zbuddylist_contains_user(zbl, zald->user)) {
1355        /* Send a PSEUDO LOGOUT! */
1356        if (notify) {
1357          m = owl_malloc(sizeof(owl_message));
1358          owl_message_create_pseudo_zlogin(m, 1, zald->user, "", "", "");
1359          owl_global_messagequeue_addmsg(&g, m);
1360        }
1361        owl_zbuddylist_deluser(zbl, zald->user);
1362        owl_function_debugmsg("owl_function_zephyr_buddy_check: logout for %s ", zald->user);
1363      }
1364    }
1365    ZFreeALD(zald);
1366    owl_free(zald);
1367  }
1368}
1369#else
1370void owl_zephyr_process_pseudologin(void *n)
1371{
1372}
1373#endif
1374
1375void owl_zephyr_buddycheck_timer(owl_timer *t, void *data)
1376{
1377  if (owl_global_is_pseudologins(&g)) {
1378    owl_function_debugmsg("Doing zephyr buddy check");
1379    owl_function_zephyr_buddy_check(1);
1380  } else {
1381    owl_function_debugmsg("Warning: owl_zephyr_buddycheck_timer call pointless; timer should have been disabled");
1382  }
1383}
1384
1385/*
1386 * Process zephyrgrams from libzephyr's queue. To prevent starvation,
1387 * process a maximum of OWL_MAX_ZEPHYRGRAMS_TO_PROCESS.
1388 *
1389 * Returns the number of zephyrgrams processed.
1390 */
1391
1392#define OWL_MAX_ZEPHYRGRAMS_TO_PROCESS 20
1393
1394static int _owl_zephyr_process_events(void)
1395{
1396  int zpendcount=0;
1397#ifdef HAVE_LIBZEPHYR
1398  ZNotice_t notice;
1399  owl_message *m=NULL;
1400
1401  while(owl_zephyr_zpending() && zpendcount < OWL_MAX_ZEPHYRGRAMS_TO_PROCESS) {
1402    if (owl_zephyr_zpending()) {
1403      ZReceiveNotice(&notice, NULL);
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=owl_malloc(sizeof(owl_message));
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.