- Timestamp:
- Mar 28, 2009, 5:00:34 PM (15 years ago)
- Branches:
- owl
- Children:
- 4de643d
- Parents:
- 5189631
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zephyr.c
r180cd15 rdab82f29 66 66 #endif 67 67 } 68 69 #ifdef HAVE_LIBZEPHYR 70 int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count) 71 { 72 int i, ret = 0; 73 /* sub without defaults */ 74 if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) { 75 owl_function_error("Error subscribing to zephyr notifications."); 76 ret=-2; 77 } 78 79 /* free stuff */ 80 for (i=0; i<count; i++) { 81 owl_free(subs[i].zsub_class); 82 owl_free(subs[i].zsub_classinst); 83 owl_free(subs[i].zsub_recipient); 84 } 85 return ret; 86 } 87 #endif 68 88 69 89 /* Load zephyr subscriptions form 'filename'. If 'filename' is NULL, … … 82 102 char buffer[1024], subsfile[1024]; 83 103 ZSubscription_t subs[3001]; 84 int count, ret , i;104 int count, ret; 85 105 struct stat statbuff; 86 106 … … 98 118 99 119 ZResetAuthentication(); 100 /* need to redo this to do chunks, not just bail after 3000 */101 120 count=0; 102 121 file=fopen(subsfile, "r"); … … 111 130 } 112 131 113 if (count >= 3000) break; /* also tell the user */ 132 if (count >= 3000) { 133 ret = owl_zephyr_loadsubs_helper(subs, count); 134 if (ret != 0) { 135 fclose(file); 136 return(ret); 137 } 138 count=0; 139 } 114 140 115 141 /* add it to the list of subs */ … … 130 156 fclose(file); 131 157 132 /* sub without defaults */ 133 ret=0; 134 if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) { 135 owl_function_error("Error subscribing to zephyr notifications."); 136 ret=-2; 137 } 138 139 /* free stuff */ 140 for (i=0; i<count; i++) { 141 owl_free(subs[i].zsub_class); 142 owl_free(subs[i].zsub_classinst); 143 owl_free(subs[i].zsub_recipient); 144 } 158 ret=owl_zephyr_loadsubs_helper(subs, count); 145 159 146 160 return(ret); … … 291 305 int i, count, save; 292 306 char *out; 307 308 /* If there's no message here, just run along now */ 309 if (n->z_message_len == 0) 310 return(owl_strdup("")); 293 311 294 312 count=save=0; … … 327 345 int i, fields; 328 346 347 if(n->z_message_len == 0) 348 return 0; 349 329 350 fields=1; 330 351 for (i=0; i<n->z_message_len; i++) { … … 355 376 if (!strcasecmp(n->z_sender, "olc.matisse@ATHENA.MIT.EDU")) { 356 377 return(owl_zephyr_get_field(n, 1)); 378 } 379 /* deal with MIT NOC messages */ 380 else if (!strcasecmp(n->z_sender, "rcmd.achilles@ATHENA.MIT.EDU")) { 381 /* $opcode service on $instance $3.\n$4 */ 382 char *msg, *opcode, *instance, *field3, *field4; 383 384 opcode = n->z_opcode; 385 instance = n->z_class_inst; 386 field3 = owl_zephyr_get_field(n, 3); 387 field4 = owl_zephyr_get_field(n, 4); 388 389 msg = owl_sprintf("%s service on %s %s\n%s", opcode, instance, field3, field4); 390 if (msg) { 391 return msg; 392 } 357 393 } 358 394 … … 629 665 owl_function_error("Subscription already present in %s", subsfile); 630 666 owl_free(line); 667 fclose(file); 631 668 return; 632 669 } 633 670 } 671 fclose(file); 634 672 } 635 673 636 674 /* if we get here then we didn't find it */ 637 fclose(file);638 675 file=fopen(subsfile, "a"); 639 676 if (!file) { … … 969 1006 #endif 970 1007 } 1008 1009 1010 #ifdef HAVE_LIBZEPHYR 1011 void owl_zephyr_process_events(owl_dispatch *d) { 1012 int zpendcount=0; 1013 ZNotice_t notice; 1014 struct sockaddr_in from; 1015 owl_message *m=NULL; 1016 1017 while(owl_zephyr_zpending() && zpendcount < 20) { 1018 if (owl_zephyr_zpending()) { 1019 ZReceiveNotice(¬ice, &from); 1020 zpendcount++; 1021 1022 /* is this an ack from a zephyr we sent? */ 1023 if (owl_zephyr_notice_is_ack(¬ice)) { 1024 owl_zephyr_handle_ack(¬ice); 1025 continue; 1026 } 1027 1028 /* if it's a ping and we're not viewing pings then skip it */ 1029 if (!owl_global_is_rxping(&g) && !strcasecmp(notice.z_opcode, "ping")) { 1030 continue; 1031 } 1032 1033 /* create the new message */ 1034 m=owl_malloc(sizeof(owl_message)); 1035 owl_message_create_from_znotice(m, ¬ice); 1036 1037 owl_global_messagequeue_addmsg(&g, m); 1038 } 1039 } 1040 } 1041 1042 #else 1043 void owl_zephyr_process_events(owl_dispatch *d) { 1044 1045 } 1046 #endif
Note: See TracChangeset
for help on using the changeset viewer.