source: zephyr.c @ 0cb6c26

debianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 0cb6c26 was 79d7d98, checked in by Alex Vandiver <alexmv@mit.edu>, 16 years ago
Make compiling without zephyr support work again, by moving an ifdef
  • Property mode set to 100644
File size: 30.5 KB
RevLine 
[7d4fbcd]1#include <stdlib.h>
2#include <unistd.h>
3#include <sys/types.h>
4#include <sys/wait.h>
[4357be8]5#include <sys/stat.h>
[7d4fbcd]6#include <string.h>
7#include "owl.h"
8
[1aee7d9]9static const char fileIdent[] = "$Id$";
10
[a5e7ed6]11static GList *deferred_subs = NULL;
[79d7d98]12
13#ifdef HAVE_LIBZEPHYR
[a5e7ed6]14typedef struct _owl_sub_list {                            /* noproto */
15  ZSubscription_t *subs;
16  int nsubs;
17} owl_sub_list;
18
[8262340]19Code_t ZResetAuthentication();
[09489b89]20#endif
[8262340]21
[02f55dc]22#define HM_SVC_FALLBACK         htons((unsigned short) 2104)
23
[52a0f14]24#ifdef HAVE_LIBZEPHYR
25void owl_zephyr_initialize()
26{
27  int ret;
[02f55dc]28  struct servent *sp;
29  struct sockaddr_in sin;
30  ZNotice_t req;
31  Code_t code;
[52a0f14]32  owl_dispatch *dispatch;
33
34  /*
35   * Code modified from libzephyr's ZhmStat.c
36   *
37   * Modified to add the fd to our select loop, rather than hanging
38   * until we get an ack.
39   */
40
41  if ((ret = ZOpenPort(NULL)) != ZERR_NONE) {
42    owl_function_error("Error opening Zephyr port: %s", error_message(ret));
43    return;
44  }
[02f55dc]45
46  (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in));
47
48  sp = getservbyname(HM_SVCNAME, "udp");
49
50  sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK;
51  sin.sin_family = AF_INET;
52
53  sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
54
55  (void) memset((char *)&req, 0, sizeof(req));
56  req.z_kind = STAT;
57  req.z_port = 0;
58  req.z_class = HM_STAT_CLASS;
59  req.z_class_inst = HM_STAT_CLIENT;
60  req.z_opcode = HM_GIMMESTATS;
61  req.z_sender = "";
62  req.z_recipient = "";
63  req.z_default_format = "";
64  req.z_message_len = 0;
[52a0f14]65
66  if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) {
67    owl_function_error("Initializing Zephyr: %s", error_message(code));
68    return;
69  }
70
71  if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) {
72    owl_function_error("Initializing Zephyr: %s", error_message(code));
73    return;
74  }
75
76  dispatch = owl_malloc(sizeof(*dispatch));
77  dispatch->fd = ZGetFD();
78  dispatch->cfunc = owl_zephyr_finish_initialization;
79  dispatch->destroy = (void(*)(owl_dispatch*))owl_free;
80
81  owl_select_add_dispatch(dispatch);
[02f55dc]82}
83
[52a0f14]84void owl_zephyr_finish_initialization(owl_dispatch *d) {
85  Code_t code;
86
87  owl_select_remove_dispatch(d->fd);
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  d = owl_malloc(sizeof(owl_dispatch));
102  d->fd = ZGetFD();
103  d->cfunc = &owl_zephyr_process_events;
104  d->destroy = NULL;
105  owl_select_add_dispatch(d);
106  owl_global_set_havezephyr(&g);
107
108  if(g.load_initial_subs) {
109    owl_zephyr_load_initial_subs();
110  }
[a5e7ed6]111  while(deferred_subs != NULL) {
112    owl_sub_list *subs = deferred_subs->data;
113    owl_function_debugmsg("Loading %d deferred subs.", subs->nsubs);
114    owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs);
115    deferred_subs = g_list_delete_link(deferred_subs, deferred_subs);
116    owl_free(subs);
117  }
[619d864]118
119  /* zlog in if we need to */
120  if (owl_global_is_startuplogin(&g)) {
121    owl_function_debugmsg("startup: doing zlog in");
122    owl_zephyr_zlog_in();
123  }
[52a0f14]124}
125
126void owl_zephyr_load_initial_subs() {
127  int ret, ret2;
128
129  owl_function_debugmsg("startup: loading initial zephyr subs");
130
131  /* load default subscriptions */
132  ret = owl_zephyr_loaddefaultsubs();
133
134  /* load subscriptions from subs file */
135  ret2 = owl_zephyr_loadsubs(NULL, 0);
136
137  if (ret || ret2) {
138    owl_function_error("Error loading zephyr subscriptions");
139  } else if (ret2!=-1) {
140    owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES);
141  }
142
143  /* load login subscriptions */
144  if (owl_global_is_loginsubs(&g)) {
145    owl_function_debugmsg("startup: loading login subs");
146    owl_function_loadloginsubs(NULL);
147  }
148}
149#else
150void owl_zephyr_initialize()
151{
152}
[02f55dc]153#endif
154
[52a0f14]155
[09489b89]156int owl_zephyr_shutdown()
157{
158#ifdef HAVE_LIBZEPHYR
[bfbf590]159  if(owl_global_is_havezephyr(&g)) {
160    unsuball();
161    ZClosePort();
162  }
[09489b89]163#endif
[be0a79f]164  return(0);
165}
166
167int owl_zephyr_zpending()
168{
169#ifdef HAVE_LIBZEPHYR
[bfbf590]170  if(owl_global_is_havezephyr(&g))
171    return(ZPending());
172  else
173    return 0;
[be0a79f]174#else
175  return(0);
176#endif
177}
178
[09489b89]179char *owl_zephyr_get_realm()
180{
181#ifdef HAVE_LIBZEPHYR
182  return(ZGetRealm());
183#else
184  return("");
185#endif
186}
187
188char *owl_zephyr_get_sender()
189{
190#ifdef HAVE_LIBZEPHYR
191  return(ZGetSender());
192#else
193  return("");
194#endif
195}
196
[f6050ee]197#ifdef HAVE_LIBZEPHYR
[93e883d]198int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count)
199{
[18105584]200  int ret = 0;
[a5e7ed6]201  if (owl_global_is_havezephyr(&g)) {
202    int i;
203    /* sub without defaults */
204    if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
205      owl_function_error("Error subscribing to zephyr notifications.");
206      ret=-2;
207    }
[93e883d]208
[a5e7ed6]209    /* free stuff */
210    for (i=0; i<count; i++) {
211      owl_free(subs[i].zsub_class);
212      owl_free(subs[i].zsub_classinst);
213      owl_free(subs[i].zsub_recipient);
214    }
[bb2c60d]215
[a5e7ed6]216    owl_free(subs);
217  } else {
218    owl_sub_list *s = owl_malloc(sizeof(owl_sub_list));
219    s->subs = subs;
220    s->nsubs = count;
221    deferred_subs = g_list_append(deferred_subs, s);
222  }
[d21efbc]223
[93e883d]224  return ret;
225}
[f6050ee]226#endif
[93e883d]227
[95474d7]228/* Load zephyr subscriptions form 'filename'.  If 'filename' is NULL,
229 * the default file $HOME/.zephyr.subs will be used.
230 *
231 * Returns 0 on success.  If the file does not exist, return -1 if
232 * 'error_on_nofile' is 1, otherwise return 0.  Return -1 if the file
233 * exists but can not be read.  Return -2 if there is a failure from
234 * zephyr to load the subscriptions.
[2de4f20]235 */
[95474d7]236int owl_zephyr_loadsubs(char *filename, int error_on_nofile)
[31e48a3]237{
[be0a79f]238#ifdef HAVE_LIBZEPHYR
[7d4fbcd]239  FILE *file;
240  char *tmp, *start;
241  char buffer[1024], subsfile[1024];
[bb2c60d]242  ZSubscription_t *subs;
243  int subSize = 1024;
[93e883d]244  int count, ret;
[4357be8]245  struct stat statbuff;
[7d4fbcd]246
[bb2c60d]247  subs = owl_malloc(sizeof(ZSubscription_t) * subSize);
[7d4fbcd]248  if (filename==NULL) {
249    sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".zephyr.subs");
250  } else {
251    strcpy(subsfile, filename);
252  }
[8262340]253
[4357be8]254  ret=stat(subsfile, &statbuff);
[95474d7]255  if (ret) {
256    if (error_on_nofile==1) return(-1);
257    return(0);
258  }
[4357be8]259
[8262340]260  ZResetAuthentication();
[7d4fbcd]261  count=0;
262  file=fopen(subsfile, "r");
[95474d7]263  if (!file) return(-1);
264  while ( fgets(buffer, 1024, file)!=NULL ) {
265    if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue;
266   
267    if (buffer[0]=='-') {
268      start=buffer+1;
269    } else {
270      start=buffer;
[7d4fbcd]271    }
[95474d7]272   
[bb2c60d]273    if (count >= subSize) {
[d21efbc]274      subSize *= 2;
275      subs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize);
[93e883d]276    }
[95474d7]277   
278    /* add it to the list of subs */
279    if ((tmp=(char *) strtok(start, ",\n\r"))==NULL) continue;
280    subs[count].zsub_class=owl_strdup(tmp);
281    if ((tmp=(char *) strtok(NULL, ",\n\r"))==NULL) continue;
282    subs[count].zsub_classinst=owl_strdup(tmp);
283    if ((tmp=(char *) strtok(NULL, " \t\n\r"))==NULL) continue;
284    subs[count].zsub_recipient=owl_strdup(tmp);
285   
[bb2c60d]286    /* if it started with '-' then add it to the global punt list, and
287     * remove it from the list of subs. */
[95474d7]288    if (buffer[0]=='-') {
289      owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0);
[bb2c60d]290      owl_free(subs[count].zsub_class);
291      owl_free(subs[count].zsub_classinst);
292      owl_free(subs[count].zsub_recipient);
293    }
294    else {
295      count++;
[95474d7]296    }
[7d4fbcd]297  }
[95474d7]298  fclose(file);
[7d4fbcd]299
[0cff2b4]300  owl_zephyr_loadsubs_helper(subs, count);
[7d4fbcd]301  return(ret);
[be0a79f]302#else
303  return(0);
304#endif
[7d4fbcd]305}
306
[4357be8]307int owl_zephyr_loaddefaultsubs()
308{
[40d834a]309#ifdef HAVE_LIBZEPHYR
[4357be8]310  ZSubscription_t subs[10];
311   
312  if (ZSubscribeTo(subs,0,0) != ZERR_NONE) {
313    owl_function_error("Error subscribing to default zephyr notifications.");
314    return(-1);
315  }
316  return(0);
[40d834a]317#else
318  return(0);
319#endif
[4357be8]320}
321
[31e48a3]322int owl_zephyr_loadloginsubs(char *filename)
323{
[be0a79f]324#ifdef HAVE_LIBZEPHYR
[7d4fbcd]325  FILE *file;
[d21efbc]326  ZSubscription_t *subs;
327  int numSubs = 100;
[7d4fbcd]328  char subsfile[1024], buffer[1024];
[d21efbc]329  int count, ret;
[4357be8]330  struct stat statbuff;
[7d4fbcd]331
[d21efbc]332  subs = owl_malloc(numSubs * sizeof(ZSubscription_t));
333
[7d4fbcd]334  if (filename==NULL) {
335    sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".anyone");
336  } else {
337    strcpy(subsfile, filename);
338  }
[4357be8]339 
340  ret=stat(subsfile, &statbuff);
341  if (ret) return(0);
342
343  ret=0;
[7d4fbcd]344
[8262340]345  ZResetAuthentication();
[7d4fbcd]346  count=0;
347  file=fopen(subsfile, "r");
348  if (file) {
349    while ( fgets(buffer, 1024, file)!=NULL ) {
350      if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue;
351     
[d21efbc]352      if (count == numSubs) {
353        numSubs *= 2;
354        subs = owl_realloc(subs, numSubs * sizeof(ZSubscription_t));
355      }
[7d4fbcd]356
357      buffer[strlen(buffer)-1]='\0';
[d21efbc]358      subs[count].zsub_class=owl_strdup("login");
359      subs[count].zsub_recipient=owl_strdup("*");
[7d4fbcd]360      if (strchr(buffer, '@')) {
[d21efbc]361        subs[count].zsub_classinst=owl_strdup(buffer);
[7d4fbcd]362      } else {
[d21efbc]363        subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm());
[7d4fbcd]364      }
365
366      count++;
367    }
368    fclose(file);
369  } else {
370    count=0;
371    ret=-1;
372  }
373
[d21efbc]374  ret = owl_zephyr_loadsubs_helper(subs, count);
[7d4fbcd]375  return(ret);
[be0a79f]376#else
377  return(0);
378#endif
[7d4fbcd]379}
380
[31e48a3]381void unsuball()
382{
[be0a79f]383#if HAVE_LIBZEPHYR
[7d4fbcd]384  int ret;
[8262340]385
386  ZResetAuthentication();
[7d4fbcd]387  ret=ZCancelSubscriptions(0);
388  if (ret != ZERR_NONE) {
389    com_err("owl",ret,"while unsubscribing");
390  }
[be0a79f]391#endif
[7d4fbcd]392}
393
[31e48a3]394int owl_zephyr_sub(char *class, char *inst, char *recip)
395{
[be0a79f]396#ifdef HAVE_LIBZEPHYR
[7d4fbcd]397  ZSubscription_t subs[5];
398
399  subs[0].zsub_class=class;
400  subs[0].zsub_classinst=inst;
401  subs[0].zsub_recipient=recip;
402
[8262340]403  ZResetAuthentication();
[7d4fbcd]404  if (ZSubscribeTo(subs,1,0) != ZERR_NONE) {
[97cd00be]405    owl_function_error("Error subbing to <%s,%s,%s>", class, inst, recip);
406    return(-2);
[7d4fbcd]407  }
408  return(0);
[be0a79f]409#else
410  return(0);
411#endif
[7d4fbcd]412}
413
414
[31e48a3]415int owl_zephyr_unsub(char *class, char *inst, char *recip)
416{
[be0a79f]417#ifdef HAVE_LIBZEPHYR
[7d4fbcd]418  ZSubscription_t subs[5];
419
420  subs[0].zsub_class=class;
421  subs[0].zsub_classinst=inst;
422  subs[0].zsub_recipient=recip;
423
[8262340]424  ZResetAuthentication();
[7d4fbcd]425  if (ZUnsubscribeTo(subs,1,0) != ZERR_NONE) {
[97cd00be]426    owl_function_error("Error unsubbing from <%s,%s,%s>", class, inst, recip);
427    return(-2);
[7d4fbcd]428  }
429  return(0);
[be0a79f]430#else
431  return(0);
432#endif
[7d4fbcd]433}
434
[b0430a6]435/* return a pointer to the data in the Jth field, (NULL terminated by
436 * definition).  Caller must free the return.
437 */
[be0a79f]438#ifdef HAVE_LIBZEPHYR
[b0430a6]439char *owl_zephyr_get_field(ZNotice_t *n, int j)
[31e48a3]440{
[7d4fbcd]441  int i, count, save;
[b0430a6]442  char *out;
[7d4fbcd]443
[128171a]444  /* If there's no message here, just run along now */
445  if (n->z_message_len == 0)
446    return(owl_strdup(""));
447
[7d4fbcd]448  count=save=0;
449  for (i=0; i<n->z_message_len; i++) {
450    if (n->z_message[i]=='\0') {
451      count++;
452      if (count==j) {
453        /* just found the end of the field we're looking for */
[b0430a6]454        return(owl_strdup(n->z_message+save));
[7d4fbcd]455      } else {
456        save=i+1;
457      }
458    }
459  }
[b0430a6]460  /* catch the last field, which might not be null terminated */
[7d4fbcd]461  if (count==j-1) {
[b0430a6]462    out=owl_malloc(n->z_message_len-save+5);
463    memcpy(out, n->z_message+save, n->z_message_len-save);
464    out[n->z_message_len-save]='\0';
465    return(out);
[7d4fbcd]466  }
[b0430a6]467
468  return(owl_strdup(""));
[7d4fbcd]469}
[5376a95]470
471char *owl_zephyr_get_field_as_utf8(ZNotice_t *n, int j)
472{
473  int i, count, save;
474
475  /* If there's no message here, just run along now */
476  if (n->z_message_len == 0)
477    return(owl_strdup(""));
478
479  count=save=0;
480  for (i = 0; i < n->z_message_len; i++) {
481    if (n->z_message[i]=='\0') {
482      count++;
483      if (count == j) {
484        /* just found the end of the field we're looking for */
[6201646]485        return(owl_validate_or_convert(n->z_message + save));
[5376a95]486      } else {
487        save = i + 1;
488      }
489    }
490  }
491  /* catch the last field, which might not be null terminated */
492  if (count == j - 1) {
[6201646]493    char *tmp, *out;
494    tmp = owl_malloc(n->z_message_len-save+5);
495    memcpy(tmp, n->z_message+save, n->z_message_len-save);
496    tmp[n->z_message_len-save]='\0';
497    out = owl_validate_or_convert(tmp);
498    owl_free(tmp);
499    return out;
[5376a95]500  }
501
502  return(owl_strdup(""));
503}
[09489b89]504#else
[701a184]505char *owl_zephyr_get_field(void *n, int j)
[09489b89]506{
[b0430a6]507  return(owl_strdup(""));
[09489b89]508}
[5577606]509char *owl_zephyr_get_field_as_utf8(void *n, int j)
[5376a95]510{
511  return owl_zephyr_get_field(n, j);
512}
[be0a79f]513#endif
[7d4fbcd]514
[b0430a6]515
[be0a79f]516#ifdef HAVE_LIBZEPHYR
[31e48a3]517int owl_zephyr_get_num_fields(ZNotice_t *n)
518{
[7d4fbcd]519  int i, fields;
520
[50e29e3]521  if(n->z_message_len == 0)
522    return 0;
523
[7d4fbcd]524  fields=1;
525  for (i=0; i<n->z_message_len; i++) {
526    if (n->z_message[i]=='\0') fields++;
527  }
528 
529  return(fields);
530}
[09489b89]531#else
532int owl_zephyr_get_num_fields(void *n)
533{
534  return(0);
535}
[be0a79f]536#endif
[7d4fbcd]537
[be0a79f]538#ifdef HAVE_LIBZEPHYR
[bf73bdd]539/* return a pointer to the message, place the message length in k
540 * caller must free the return
541 */
[85d1795]542char *owl_zephyr_get_message(ZNotice_t *n, owl_message *m)
[31e48a3]543{
[405d5e6]544  /* don't let ping messages have a body */
[7d4fbcd]545  if (!strcasecmp(n->z_opcode, "ping")) {
[bf73bdd]546    return(owl_strdup(""));
[7d4fbcd]547  }
548
[a1bb198]549  /* deal with MIT NOC messages */
[85d1795]550  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")) {
551    char *msg, *field3, *field4;
[a1bb198]552
553    field3 = owl_zephyr_get_field(n, 3);
554    field4 = owl_zephyr_get_field(n, 4);
555
[85d1795]556    msg = owl_sprintf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, field3, field4);
[272a4a0]557    owl_free(field3);
558    owl_free(field4);
[a1bb198]559    if (msg) {
560      return msg;
561    }
562  }
[fba0f96]563  /* deal with MIT Discuss messages */
[e2a620b]564  else if (!strcasecmp(n->z_default_format, "New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4") ||
565           !strcasecmp(n->z_default_format, "New transaction [$1] entered in $2\nFrom: $3\nSubject: $4")) {
[fba0f96]566    char *msg, *field1, *field2, *field3, *field4, *field5;
567   
568    field1 = owl_zephyr_get_field(n, 1);
569    field2 = owl_zephyr_get_field(n, 2);
570    field3 = owl_zephyr_get_field(n, 3);
571    field4 = owl_zephyr_get_field(n, 4);
572    field5 = owl_zephyr_get_field(n, 5);
573   
574    msg = owl_sprintf("New transaction [%s] entered in %s\nFrom: %s (%s)\nSubject: %s", field1, field2, field3, field5, field4);
575    owl_free(field1);
576    owl_free(field2);
577    owl_free(field3);
578    owl_free(field4);
579    owl_free(field5);
580    if (msg) {
581      return msg;
582    }
583  }
[85d1795]584  /* deal with MIT Moira messages */
585  else if (!strcasecmp(n->z_default_format, "MOIRA $instance on $fromhost:\n $message\n")) {
586    char *msg, *field1;
587   
588    field1 = owl_zephyr_get_field(n, 1);
589   
590    msg = owl_sprintf("MOIRA %s on %s: %s", n->z_class_inst, owl_message_get_hostname(m), field1);
591    owl_free(field1);
592    if (msg) {
593      return msg;
594    }
595  }
[405d5e6]596
[85d1795]597  if (owl_zephyr_get_num_fields(n) == 1) {
598    return(owl_zephyr_get_field(n, 1));
599  }
600  else {
601    return(owl_zephyr_get_field(n, 2));
602  }
[7d4fbcd]603}
[be0a79f]604#endif
[7d4fbcd]605
[be0a79f]606#ifdef HAVE_LIBZEPHYR
[31e48a3]607char *owl_zephyr_get_zsig(ZNotice_t *n, int *k)
608{
[7d4fbcd]609  /* return a pointer to the zsig if there is one */
610
[405d5e6]611  /* message length 0? No zsig */
[7d4fbcd]612  if (n->z_message_len==0) {
613    *k=0;
614    return("");
615  }
[405d5e6]616
[85d1795]617  /* If there's only one field, no zsig */
618  if (owl_zephyr_get_num_fields(n) == 1) {
619    *k=0;
[405d5e6]620    return("");
621  }
622
623  /* Everything else is field 1 */
[7d4fbcd]624  *k=strlen(n->z_message);
625  return(n->z_message);
626}
[09489b89]627#else
628char *owl_zephyr_get_zsig(void *n, int *k)
629{
630  return("");
631}
[be0a79f]632#endif
[7d4fbcd]633
[31e48a3]634int send_zephyr(char *opcode, char *zsig, char *class, char *instance, char *recipient, char *message)
635{
[be0a79f]636#ifdef HAVE_LIBZEPHYR
[7d4fbcd]637  int ret;
638  ZNotice_t notice;
639   
640  memset(&notice, 0, sizeof(notice));
641
[8262340]642  ZResetAuthentication();
[8ba37ec]643
644  if (!zsig) zsig="";
[8262340]645 
[7d4fbcd]646  notice.z_kind=ACKED;
647  notice.z_port=0;
648  notice.z_class=class;
649  notice.z_class_inst=instance;
[21882032]650  notice.z_sender=NULL;
[7d4fbcd]651  if (!strcmp(recipient, "*") || !strcmp(recipient, "@")) {
652    notice.z_recipient="";
[21882032]653    if (*owl_global_get_zsender(&g))
654        notice.z_sender=owl_global_get_zsender(&g);
[7d4fbcd]655  } else {
656    notice.z_recipient=recipient;
657  }
658  notice.z_default_format="Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold{$1 <$sender>}\n\n$2";
659  if (opcode) notice.z_opcode=opcode;
660
[56330ff]661  notice.z_message_len=strlen(zsig)+1+strlen(message);
[7d4fbcd]662  notice.z_message=owl_malloc(notice.z_message_len+10);
[56330ff]663  strcpy(notice.z_message, zsig);
664  memcpy(notice.z_message+strlen(zsig)+1, message, strlen(message));
[7d4fbcd]665
666  /* ret=ZSendNotice(&notice, ZAUTH); */
667  ret=ZSrvSendNotice(&notice, ZAUTH, send_zephyr_helper);
668 
669  /* free then check the return */
670  owl_free(notice.z_message);
671  ZFreeNotice(&notice);
672  if (ret!=ZERR_NONE) {
[ec6ff52]673    owl_function_error("Error sending zephyr");
[7d4fbcd]674    return(ret);
675  }
676  return(0);
[be0a79f]677#else
678  return(0);
679#endif
[7d4fbcd]680}
681
[be0a79f]682#ifdef HAVE_LIBZEPHYR
[31e48a3]683Code_t send_zephyr_helper(ZNotice_t *notice, char *buf, int len, int wait)
684{
[7d4fbcd]685  return(ZSendPacket(buf, len, 0));
686}
[be0a79f]687#endif
[7d4fbcd]688
[31e48a3]689void send_ping(char *to)
690{
[be0a79f]691#ifdef HAVE_LIBZEPHYR
[7d4fbcd]692  send_zephyr("PING", "", "MESSAGE", "PERSONAL", to, "");
[be0a79f]693#endif
[7d4fbcd]694}
695
[be0a79f]696#ifdef HAVE_LIBZEPHYR
[31e48a3]697void owl_zephyr_handle_ack(ZNotice_t *retnotice)
698{
[7d4fbcd]699  char *tmp;
700 
701  /* if it's an HMACK ignore it */
702  if (retnotice->z_kind == HMACK) return;
[aecf3e6]703
[7d4fbcd]704  if (retnotice->z_kind == SERVNAK) {
[ec6ff52]705    owl_function_error("Authorization failure sending zephyr");
[7d4fbcd]706  } else if ((retnotice->z_kind != SERVACK) || !retnotice->z_message_len) {
[ec6ff52]707    owl_function_error("Detected server failure while receiving acknowledgement");
[7d4fbcd]708  } else if (!strcmp(retnotice->z_message, ZSRVACK_SENT)) {
709    if (!strcasecmp(retnotice->z_opcode, "ping")) {
710      return;
711    } else if (!strcasecmp(retnotice->z_class, "message") &&
712               !strcasecmp(retnotice->z_class_inst, "personal")) {
[4b464a4]713      tmp=short_zuser(retnotice->z_recipient);
[b4db911]714      owl_function_makemsg("Message sent to %s.", tmp);
[7d4fbcd]715      free(tmp);
716    } else {
[b4db911]717      owl_function_makemsg("Message sent to -c %s -i %s\n", retnotice->z_class, retnotice->z_class_inst);
[7d4fbcd]718    }
719  } else if (!strcmp(retnotice->z_message, ZSRVACK_NOTSENT)) {
[1151f0b]720    #define BUFFLEN 1024
[44f32fb]721    if (retnotice->z_recipient == NULL
[60c2e1e]722        || *retnotice->z_recipient == 0
[44f32fb]723        || *retnotice->z_recipient == '@') {
[1151f0b]724      char buff[BUFFLEN];
[44f32fb]725      owl_function_error("No one subscribed to class %s", retnotice->z_class);
[1151f0b]726      snprintf(buff, BUFFLEN, "Could not send message to class %s: no one subscribed.\n", retnotice->z_class);
[9119a47]727      owl_function_adminmsg("", buff);
[7d4fbcd]728    } else {
[1151f0b]729      char buff[BUFFLEN];
[4b464a4]730      tmp = short_zuser(retnotice->z_recipient);
[44f32fb]731      owl_function_error("%s: Not logged in or subscribing.", tmp);
732      if(strcmp(retnotice->z_class, "message")) {
[1151f0b]733        snprintf(buff, BUFFLEN,
[10e3963]734                 "Could not send message to %s: "
735                 "not logged in or subscribing to class %s, instance %s.\n", 
736                 tmp,
[1151f0b]737                 retnotice->z_class,
738                 retnotice->z_class_inst);
[44f32fb]739      } else {
[1151f0b]740        snprintf(buff, BUFFLEN,
[10e3963]741                 "Could not send message to %s: "
742                 "not logged in or subscribing to messages.\n",
743                 tmp);
[44f32fb]744      }
[9119a47]745      owl_function_adminmsg("", buff);
[180cd15]746      owl_log_outgoing_zephyr_error(tmp, buff);
[1c6c4d3]747      owl_free(tmp);
[7d4fbcd]748    }
749  } else {
[ec6ff52]750    owl_function_error("Internal error on ack (%s)", retnotice->z_message);
[7d4fbcd]751  }
752}
[09489b89]753#else
754void owl_zephyr_handle_ack(void *retnotice)
755{
756}
[be0a79f]757#endif
[7d4fbcd]758
[be0a79f]759#ifdef HAVE_LIBZEPHYR
[31e48a3]760int owl_zephyr_notice_is_ack(ZNotice_t *n)
761{
[7d4fbcd]762  if (n->z_kind == SERVNAK || n->z_kind == SERVACK || n->z_kind == HMACK) {
763    if (!strcasecmp(n->z_class, LOGIN_CLASS)) return(0);
764    return(1);
765  }
766  return(0);
767}
[09489b89]768#else
769int owl_zephyr_notice_is_ack(void *n)
770{
771  return(0);
772}
[be0a79f]773#endif
[7d4fbcd]774 
[31e48a3]775void owl_zephyr_zaway(owl_message *m)
776{
[be0a79f]777#ifdef HAVE_LIBZEPHYR
[7c8060d0]778  char *tmpbuff, *myuser, *to;
[15b34fd]779  owl_message *mout;
[7d4fbcd]780 
[aa2f6364]781  /* bail if it doesn't look like a message we should reply to.  Some
[2de4f20]782   * of this defined by the way zaway(1) works
783   */
[7d4fbcd]784  if (strcasecmp(owl_message_get_class(m), "message")) return;
785  if (strcasecmp(owl_message_get_recipient(m), ZGetSender())) return;
786  if (!strcasecmp(owl_message_get_sender(m), "")) return;
787  if (!strcasecmp(owl_message_get_opcode(m), "ping")) return;
788  if (!strcasecmp(owl_message_get_opcode(m), "auto")) return;
[d023c25]789  if (!strcasecmp(owl_message_get_zsig(m), "Automated reply:")) return;
[7d4fbcd]790  if (!strcasecmp(owl_message_get_sender(m), ZGetSender())) return;
[9854278]791  if (owl_message_get_attribute_value(m, "isauto")) return;
[7d4fbcd]792
[7c8060d0]793  if (owl_global_is_smartstrip(&g)) {
[e3d9c77]794    to=owl_zephyr_smartstripped_user(owl_message_get_sender(m));
[7c8060d0]795  } else {
796    to=owl_strdup(owl_message_get_sender(m));
797  }
798
[7d4fbcd]799  send_zephyr("",
800              "Automated reply:",
801              owl_message_get_class(m),
802              owl_message_get_instance(m),
[7c8060d0]803              to,
[7d4fbcd]804              owl_global_get_zaway_msg(&g));
805
[7c8060d0]806  myuser=short_zuser(to);
[aa2f6364]807  if (!strcasecmp(owl_message_get_instance(m), "personal")) {
808    tmpbuff = owl_sprintf("zwrite %s", myuser);
809  } else {
810    tmpbuff = owl_sprintf("zwrite -i %s %s", owl_message_get_instance(m), myuser);
811  }
812  owl_free(myuser);
[7c8060d0]813  owl_free(to);
[aa2f6364]814
[7d4fbcd]815  /* display the message as an admin message in the receive window */
[15b34fd]816  mout=owl_function_make_outgoing_zephyr(owl_global_get_zaway_msg(&g), tmpbuff, "Automated reply:");
[13a3c1db]817  owl_global_messagequeue_addmsg(&g, mout);
[7d4fbcd]818  owl_free(tmpbuff);
[be0a79f]819#endif
[7d4fbcd]820}
821
[be0a79f]822#ifdef HAVE_LIBZEPHYR
[31e48a3]823void owl_zephyr_hackaway_cr(ZNotice_t *n)
824{
[7d4fbcd]825  /* replace \r's with ' '.  Gross-ish */
826  int i;
827
828  for (i=0; i<n->z_message_len; i++) {
829    if (n->z_message[i]=='\r') {
830      n->z_message[i]=' ';
831    }
832  }
833}
[be0a79f]834#endif
[7d4fbcd]835
[31e48a3]836void owl_zephyr_zlocate(char *user, char *out, int auth)
837{
[be0a79f]838#ifdef HAVE_LIBZEPHYR
[7d4fbcd]839  int ret, numlocs;
840  int one = 1;
841  ZLocations_t locations;
842  char *myuser;
843 
844  strcpy(out, "");
[8262340]845  ZResetAuthentication();
[7d4fbcd]846  ret=ZLocateUser(user,&numlocs,auth?ZAUTH:ZNOAUTH);
847  if (ret != ZERR_NONE) {
[667a1b6]848    sprintf(out, "Error locating user %s\n", user);
849    return;
[7d4fbcd]850  }
851
852  if (numlocs==0) {
[2527615]853    myuser=short_zuser(user);
[451db9e]854    sprintf(out, "%s: Hidden or not logged in\n", myuser);
[2527615]855    owl_free(myuser);
[7d4fbcd]856    return;
857  }
858   
859  for (;numlocs;numlocs--) {
860    ZGetLocations(&locations,&one);
[4b464a4]861    myuser=short_zuser(user);
[b9cb41b]862    sprintf(out + strlen(out), "%s: %s\t%s\t%s\n", myuser,
[667a1b6]863            locations.host ? locations.host : "?",
864            locations.tty ? locations.tty : "?",
865            locations.time ? locations.time : "?");
[7d4fbcd]866    owl_free(myuser);
867  }
[be0a79f]868#endif
[7d4fbcd]869}
[bde7714]870
[31e48a3]871void owl_zephyr_addsub(char *filename, char *class, char *inst, char *recip)
872{
[be0a79f]873#ifdef HAVE_LIBZEPHYR
[bde7714]874  char *line, subsfile[LINE], buff[LINE];
875  FILE *file;
876
877  line=owl_zephyr_makesubline(class, inst, recip);
878
879  if (filename==NULL) {
880    sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".zephyr.subs");
881  } else {
882    strcpy(subsfile, filename);
883  }
884
[74037d9]885  /* if the file already exists, check to see if the sub is already there */
[bde7714]886  file=fopen(subsfile, "r");
[74037d9]887  if (file) {
888    while (fgets(buff, LINE, file)!=NULL) {
889      if (!strcasecmp(buff, line)) {
890        owl_function_error("Subscription already present in %s", subsfile);
891        owl_free(line);
[e78397d]892        fclose(file);
[74037d9]893        return;
894      }
[bde7714]895    }
[99dabee]896    fclose(file);
[bde7714]897  }
898
899  /* if we get here then we didn't find it */
900  file=fopen(subsfile, "a");
901  if (!file) {
[ec6ff52]902    owl_function_error("Error opening file %s for writing", subsfile);
[bde7714]903    owl_free(line);
904    return;
905  }
906  fputs(line, file);
907  fclose(file);
908  owl_function_makemsg("Subscription added");
909 
910  owl_free(line);
[be0a79f]911#endif
[bde7714]912}
913
[31e48a3]914void owl_zephyr_delsub(char *filename, char *class, char *inst, char *recip)
915{
[be0a79f]916#ifdef HAVE_LIBZEPHYR
[b2a91b6]917  char *line, *subsfile;
[bde7714]918 
919  line=owl_zephyr_makesubline(class, inst, recip);
[b2a91b6]920  line[strlen(line)-1]='\0';
[bde7714]921
[b2a91b6]922  if (!filename) {
923    subsfile=owl_sprintf("%s/.zephyr.subs", owl_global_get_homedir(&g));
[bde7714]924  } else {
[b2a91b6]925    subsfile=owl_strdup(filename);
[bde7714]926  }
[b2a91b6]927 
928  owl_util_file_deleteline(subsfile, line, 1);
929  owl_free(subsfile);
[bde7714]930  owl_free(line);
931  owl_function_makemsg("Subscription removed");
[be0a79f]932#endif
[bde7714]933}
934
[b2a91b6]935/* caller must free the return */
[31e48a3]936char *owl_zephyr_makesubline(char *class, char *inst, char *recip)
937{
[bde7714]938  char *out;
939
940  out=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+30);
941  sprintf(out, "%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
942  return(out);
943}
[31e48a3]944
945
946void owl_zephyr_zlog_in(void)
947{
[be0a79f]948#ifdef HAVE_LIBZEPHYR
[31e48a3]949  char *exposure, *eset;
950  int ret;
951
952  ZResetAuthentication();
953   
954  eset=EXPOSE_REALMVIS;
955  exposure=ZGetVariable("exposure");
956  if (exposure==NULL) {
957    eset=EXPOSE_REALMVIS;
958  } else if (!strcasecmp(exposure,EXPOSE_NONE)) {
959    eset = EXPOSE_NONE;
960  } else if (!strcasecmp(exposure,EXPOSE_OPSTAFF)) {
961    eset = EXPOSE_OPSTAFF;
962  } else if (!strcasecmp(exposure,EXPOSE_REALMVIS)) {
963    eset = EXPOSE_REALMVIS;
964  } else if (!strcasecmp(exposure,EXPOSE_REALMANN)) {
965    eset = EXPOSE_REALMANN;
966  } else if (!strcasecmp(exposure,EXPOSE_NETVIS)) {
967    eset = EXPOSE_NETVIS;
968  } else if (!strcasecmp(exposure,EXPOSE_NETANN)) {
969    eset = EXPOSE_NETANN;
970  }
971   
972  ret=ZSetLocation(eset);
973  if (ret != ZERR_NONE) {
974    /*
975      char buff[LINE];
976      sprintf(buff, "Error setting location: %s", error_message(ret));
977      owl_function_makemsg(buff);
978    */
979  }
[be0a79f]980#endif
[31e48a3]981}
982
983void owl_zephyr_zlog_out(void)
984{
[be0a79f]985#ifdef HAVE_LIBZEPHYR
[31e48a3]986  int ret;
987
988  ZResetAuthentication();
989  ret=ZUnsetLocation();
990  if (ret != ZERR_NONE) {
991    /*
992      char buff[LINE];
993      sprintf(buff, "Error unsetting location: %s", error_message(ret));
994      owl_function_makemsg(buff);
995    */
996  }
[be0a79f]997#endif
[31e48a3]998}
999
[65ad073]1000void owl_zephyr_addbuddy(char *name)
1001{
1002  char *filename;
1003  FILE *file;
1004 
1005  filename=owl_sprintf("%s/.anyone", owl_global_get_homedir(&g));
1006  file=fopen(filename, "a");
1007  owl_free(filename);
1008  if (!file) {
[ec6ff52]1009    owl_function_error("Error opening zephyr buddy file for append");
[65ad073]1010    return;
1011  }
1012  fprintf(file, "%s\n", name);
1013  fclose(file);
1014}
1015
1016void owl_zephyr_delbuddy(char *name)
1017{
1018  char *filename;
1019
1020  filename=owl_sprintf("%s/.anyone", owl_global_get_homedir(&g));
1021  owl_util_file_deleteline(filename, name, 0);
1022  owl_free(filename);
1023}
[9381782]1024
1025/* return auth string */
[09489b89]1026#ifdef HAVE_LIBZEPHYR
[9381782]1027char *owl_zephyr_get_authstr(ZNotice_t *n)
1028{
1029
1030  if (!n) return("UNKNOWN");
1031
1032  if (n->z_auth == ZAUTH_FAILED) {
1033    return ("FAILED");
1034  } else if (n->z_auth == ZAUTH_NO) {
1035    return ("NO");
1036  } else if (n->z_auth == ZAUTH_YES) {
1037    return ("YES");
1038  } else {
1039    return ("UNKNOWN");
1040  }           
1041}
[09489b89]1042#else
1043char *owl_zephyr_get_authstr(void *n)
1044{
1045  return("");
1046}
1047#endif
[9381782]1048
[2de4f20]1049/* Returns a buffer of subscriptions or an error message.  Caller must
1050 * free the return.
[09489b89]1051 */
1052char *owl_zephyr_getsubs()
1053{
1054#ifdef HAVE_LIBZEPHYR
1055  int ret, num, i, one;
[ddacb9c]1056  int buffsize;
[09489b89]1057  ZSubscription_t sub;
[ddacb9c]1058  char *out;
[09489b89]1059  one=1;
1060
1061  ret=ZRetrieveSubscriptions(0, &num);
1062  if (ret==ZERR_TOOMANYSUBS) {
[c8735aa]1063    return(owl_strdup("Zephyr: too many subscriptions\n"));
[ddacb9c]1064  } else if (ret || (num <= 0)) {
[c8735aa]1065    return(owl_strdup("Zephyr: error retriving subscriptions\n"));
[09489b89]1066  }
1067
[ddacb9c]1068  buffsize = (num + 1) * 50;
1069  out=owl_malloc(buffsize);
[09489b89]1070  strcpy(out, "");
1071  for (i=0; i<num; i++) {
1072    if ((ret = ZGetSubscriptions(&sub, &one)) != ZERR_NONE) {
1073      owl_free(out);
1074      ZFlushSubscriptions();
1075      out=owl_strdup("Error while getting subscriptions\n");
1076      return(out);
1077    } else {
[ddacb9c]1078      int tmpbufflen;
1079      char *tmpbuff;
1080      tmpbuff = owl_sprintf("<%s,%s,%s>\n%s", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient, out);
1081      tmpbufflen = strlen(tmpbuff) + 1;
1082      if (tmpbufflen > buffsize) {
1083        char *out2;
1084        buffsize = tmpbufflen * 2;
1085        out2 = owl_realloc(out, buffsize);
1086        if (out2 == NULL) {
1087          owl_free(out);
1088          owl_free(tmpbuff);
1089          ZFlushSubscriptions();
1090          out=owl_strdup("Realloc error while getting subscriptions\n");
1091          return(out);   
1092        }
1093        out = out2;
1094      }
[09489b89]1095      strcpy(out, tmpbuff);
[ddacb9c]1096      owl_free(tmpbuff);
[09489b89]1097    }
1098  }
1099
1100  ZFlushSubscriptions();
1101  return(out);
1102#else
[12c35df]1103  return(owl_strdup("Zephyr not available"));
[09489b89]1104#endif
1105}
1106
1107char *owl_zephyr_get_variable(char *var)
1108{
1109#ifdef HAVE_LIBZEPHYR
1110  return(ZGetVariable(var));
1111#else
1112  return("");
1113#endif
1114}
1115
1116void owl_zephyr_set_locationinfo(char *host, char *val)
1117{
1118#ifdef HAVE_LIBZEPHYR
1119  ZInitLocationInfo(host, val);
1120#endif
1121}
1122 
[e3d9c77]1123/* Strip a local realm fron the zephyr user name.
1124 * The caller must free the return
1125 */
1126char *short_zuser(char *in)
1127{
1128  char *out, *ptr;
1129
1130  out=owl_strdup(in);
1131  ptr=strchr(out, '@');
1132  if (ptr) {
1133    if (!strcasecmp(ptr+1, owl_zephyr_get_realm())) {
1134      *ptr='\0';
1135    }
1136  }
1137  return(out);
1138}
1139
1140/* Append a local realm to the zephyr user name if necessary.
1141 * The caller must free the return.
1142 */
1143char *long_zuser(char *in)
1144{
[1971b59]1145  if (strchr(in, '@')) {
1146    return(owl_strdup(in));
[e3d9c77]1147  }
[1971b59]1148  return(owl_sprintf("%s@%s", in, owl_zephyr_get_realm()));
[e3d9c77]1149}
1150
1151/* strip out the instance from a zsender's principal.  Preserves the
1152 * realm if present.  daemon.webzephyr is a special case.  The
1153 * caller must free the return
1154 */
1155char *owl_zephyr_smartstripped_user(char *in)
1156{
1157  char *ptr, *realm, *out;
1158
1159  out=owl_strdup(in);
1160
1161  /* bail immeaditly if we don't have to do any work */
1162  ptr=strchr(in, '.');
1163  if (!strchr(in, '/') && !ptr) {
1164    /* no '/' and no '.' */
1165    return(out);
1166  }
1167  if (ptr && strchr(in, '@') && (ptr > strchr(in, '@'))) {
1168    /* There's a '.' but it's in the realm */
1169    return(out);
1170  }
1171  if (!strncasecmp(in, OWL_WEBZEPHYR_PRINCIPAL, strlen(OWL_WEBZEPHYR_PRINCIPAL))) {
1172    return(out);
1173  }
1174
1175  /* remove the realm from ptr, but hold on to it */
1176  realm=strchr(out, '@');
1177  if (realm) realm[0]='\0';
1178
1179  /* strip */
1180  ptr=strchr(out, '.');
1181  if (!ptr) ptr=strchr(out, '/');
1182  ptr[0]='\0';
1183
1184  /* reattach the realm if we had one */
1185  if (realm) {
1186    strcat(out, "@");
1187    strcat(out, realm+1);
1188  }
1189
1190  return(out);
1191}
[5a95b69]1192
1193/* read the list of users in 'filename' as a .anyone file, and put the
1194 * names of the zephyr users in the list 'in'.  If 'filename' is NULL,
1195 * use the default .anyone file in the users home directory.  Returns
1196 * -1 on failure, 0 on success.
1197 */
1198int owl_zephyr_get_anyone_list(owl_list *in, char *filename)
1199{
1200#ifdef HAVE_LIBZEPHYR
1201  char *ourfile, *tmp, buff[LINE];
1202  FILE *f;
1203
1204  if (filename==NULL) {
1205    tmp=owl_global_get_homedir(&g);
1206    ourfile=owl_sprintf("%s/.anyone", owl_global_get_homedir(&g));
1207  } else {
1208    ourfile=owl_strdup(filename);
1209  }
1210 
1211  f=fopen(ourfile, "r");
1212  if (!f) {
1213    owl_function_error("Error opening file %s: %s", ourfile, strerror(errno) ? strerror(errno) : "");
1214    owl_free(ourfile);
1215    return(-1);
1216  }
1217
1218  while (fgets(buff, LINE, f)!=NULL) {
1219    /* ignore comments, blank lines etc. */
1220    if (buff[0]=='#') continue;
1221    if (buff[0]=='\n') continue;
1222    if (buff[0]=='\0') continue;
1223   
1224    /* strip the \n */
1225    buff[strlen(buff)-1]='\0';
1226   
1227    /* ingore from # on */
1228    tmp=strchr(buff, '#');
1229    if (tmp) tmp[0]='\0';
1230   
1231    /* ingore from SPC */
1232    tmp=strchr(buff, ' ');
1233    if (tmp) tmp[0]='\0';
1234   
1235    /* stick on the local realm. */
1236    if (!strchr(buff, '@')) {
1237      strcat(buff, "@");
1238      strcat(buff, ZGetRealm());
1239    }
1240    owl_list_append_element(in, owl_strdup(buff));
1241  }
1242  fclose(f);
1243  owl_free(ourfile);
1244  return(0);
1245#else
1246  return(-1);
1247#endif
1248}
[13a3c1db]1249
1250#ifdef HAVE_LIBZEPHYR
[f36cd97]1251void owl_zephyr_process_events(owl_dispatch *d) {
[13a3c1db]1252  int zpendcount=0;
1253  ZNotice_t notice;
1254  struct sockaddr_in from;
1255  owl_message *m=NULL;
1256
1257  while(owl_zephyr_zpending() && zpendcount < 20) {
1258    if (owl_zephyr_zpending()) {
1259      ZReceiveNotice(&notice, &from);
1260      zpendcount++;
1261
1262      /* is this an ack from a zephyr we sent? */
1263      if (owl_zephyr_notice_is_ack(&notice)) {
1264        owl_zephyr_handle_ack(&notice);
1265        continue;
1266      }
1267
1268      /* if it's a ping and we're not viewing pings then skip it */
1269      if (!owl_global_is_rxping(&g) && !strcasecmp(notice.z_opcode, "ping")) {
1270        continue;
1271      }
1272
1273      /* create the new message */
1274      m=owl_malloc(sizeof(owl_message));
1275      owl_message_create_from_znotice(m, &notice);
1276
1277      owl_global_messagequeue_addmsg(&g, m);
1278    }
1279  }
1280}
1281
1282#else
[f36cd97]1283void owl_zephyr_process_events(owl_dispatch *d) {
[13a3c1db]1284 
1285}
1286#endif
Note: See TracBrowser for help on using the repository browser.