Changeset d110d95
- Timestamp:
- Oct 7, 2017, 7:25:15 AM (9 years ago)
- Parents:
- 0c059f0 (diff), b36b9a6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Anders Kaseorg <andersk@mit.edu> (10/07/17 07:25:15)
- git-committer:
- GitHub <noreply@github.com> (10/07/17 07:25:15)
- Files:
-
- 7 added
- 1 deleted
- 36 edited
-
Makefile.am (modified) (1 diff)
-
aim.c (modified) (1 diff)
-
message.c (modified) (32 diffs)
-
owl.h (modified) (2 diffs)
-
pair.c (deleted)
-
perlconfig.c (modified) (6 diffs)
-
tester.c (modified) (1 diff)
-
util.c (modified) (1 diff)
-
.travis.yml (modified) (2 diffs)
-
ChangeLog (modified) (1 diff)
-
commands.c (modified) (9 diffs)
-
configure.ac (modified) (1 diff)
-
cpanfile (added)
-
filterproc.c (modified) (2 diffs)
-
functions.c (modified) (2 diffs)
-
keys.c (modified) (1 diff)
-
logging.c (modified) (3 diffs)
-
owl.c (modified) (1 diff)
-
perl/Makefile.am (modified) (1 diff)
-
perl/lib/BarnOwl.pm (modified) (4 diffs)
-
perl/lib/BarnOwl/Complete/Client.pm (modified) (1 diff)
-
perl/lib/BarnOwl/DeferredLogging.pm (added)
-
perl/lib/BarnOwl/Logging.pm (added)
-
perl/lib/BarnOwl/Message.pm (modified) (2 diffs)
-
perl/lib/BarnOwl/Message/AIM.pm (modified) (1 diff)
-
perl/lib/BarnOwl/Message/Loopback.pm (modified) (1 diff)
-
perl/lib/BarnOwl/Message/Zephyr.pm (modified) (3 diffs)
-
perl/modules/IRC/lib/BarnOwl/Message/IRC.pm (modified) (1 diff)
-
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm (modified) (1 diff)
-
perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm (modified) (2 diffs)
-
perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm (modified) (1 diff)
-
perl/modules/Kerberos/Makefile.PL (added)
-
perl/modules/Kerberos/lib/BarnOwl/Module/Kerberos.pm (added)
-
perl/modules/Makefile.am (modified) (1 diff)
-
perl/modules/Twitter/lib/BarnOwl/Module/Twitter.pm (modified) (3 diffs)
-
perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm (modified) (2 diffs)
-
perlglue.xs (modified) (3 diffs)
-
scripts/dist-ignore (added)
-
scripts/do-release (modified) (3 diffs)
-
t/BarnOwl_Message_Zephyr.t (added)
-
t/completion.t (modified) (1 diff)
-
variable.c (modified) (5 diffs)
-
zephyr.c (modified) (6 diffs)
-
zwrite.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r392b5cf rd110d95 63 63 util.c logging.c \ 64 64 perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \ 65 regex.c history.c view.c dict.c variable.c filterelement.c pair.c\65 regex.c history.c view.c dict.c variable.c filterelement.c \ 66 66 keypress.c keymap.c keybinding.c cmd.c context.c \ 67 67 aim.c buddy.c buddylist.c style.c errqueue.c \ -
aim.c
r7dcef03 r6a5f0c3 1056 1056 OWL_MESSAGE_DIRECTION_IN, 1057 1057 0); 1058 if (args->icbmflags & AIM_IMFLAGS_AWAY) owl_message_set_attribute(m, "isauto", "" );1058 if (args->icbmflags & AIM_IMFLAGS_AWAY) owl_message_set_attribute(m, "isauto", "", NULL); 1059 1059 owl_global_messagequeue_addmsg(&g, m); 1060 1060 g_free(stripmsg); -
message.c
rff528e6 rd110d95 39 39 40 40 owl_message_set_hostname(m, ""); 41 m->attributes = g_ptr_array_new();41 g_datalist_init(&m->attributes); 42 42 43 43 /* save the time */ … … 52 52 * name already exists, replace the old value with the new value 53 53 */ 54 void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue) 55 { 56 int i; 57 owl_pair *p = NULL, *pair = NULL; 58 59 attrname = g_intern_string(attrname); 60 61 /* look for an existing pair with this key, */ 62 for (i = 0; i < m->attributes->len; i++) { 63 p = m->attributes->pdata[i]; 64 if (owl_pair_get_key(p) == attrname) { 65 g_free(owl_pair_get_value(p)); 66 pair = p; 67 break; 68 } 69 } 70 71 if(pair == NULL) { 72 pair = g_slice_new(owl_pair); 73 owl_pair_create(pair, attrname, NULL); 74 g_ptr_array_add(m->attributes, pair); 75 } 76 owl_pair_set_value(pair, owl_validate_or_convert(attrvalue)); 54 void owl_message_set_attribute(owl_message *m, const char *attrname, const char *attrvalue, GDestroyNotify attrdestroy) 55 { 56 if (owl_needs_convert(attrvalue)) { 57 g_datalist_set_data_full(&m->attributes, attrname, 58 owl_validate_or_convert(attrvalue), g_free); 59 if (attrdestroy) 60 attrdestroy((gpointer)attrvalue); 61 } else { 62 g_datalist_set_data_full(&m->attributes, attrname, (gpointer)attrvalue, attrdestroy); 63 } 77 64 } 78 65 … … 82 69 const char *owl_message_get_attribute_value(const owl_message *m, const char *attrname) 83 70 { 84 int i; 85 owl_pair *p; 86 GQuark quark; 87 88 quark = g_quark_try_string(attrname); 89 if (quark == 0) 90 /* don't bother inserting into string table */ 91 return NULL; 92 attrname = g_quark_to_string(quark); 93 94 for (i = 0; i < m->attributes->len; i++) { 95 p = m->attributes->pdata[i]; 96 if (owl_pair_get_key(p) == attrname) { 97 return(owl_pair_get_value(p)); 98 } 99 } 100 101 /* 102 owl_function_debugmsg("No attribute %s found for message %i", 103 attrname, 104 owl_message_get_id(m)); 105 */ 106 return(NULL); 71 return g_datalist_get_data(&((owl_message *)m)->attributes, attrname); 107 72 } 108 73 … … 111 76 * function to indent fmtext. 112 77 */ 113 void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) { 114 int i; 115 owl_pair *p; 78 static void owl_message_attribute_tofmtext(GQuark key_id, gpointer data, gpointer fm) 79 { 116 80 char *buff, *tmpbuff; 117 81 82 tmpbuff = owl_text_indent(data, 19, false); 83 buff = g_strdup_printf(" %-15.15s: %s\n", g_quark_to_string(key_id), tmpbuff); 84 g_free(tmpbuff); 85 owl_fmtext_append_normal(fm, buff); 86 g_free(buff); 87 } 88 89 void owl_message_attributes_tofmtext(const owl_message *m, owl_fmtext *fm) 90 { 118 91 owl_fmtext_init_null(fm); 119 120 for (i = 0; i < m->attributes->len; i++) { 121 p = m->attributes->pdata[i]; 122 123 buff = g_strdup(owl_pair_get_value(p)); 124 if (buff) { 125 tmpbuff = owl_text_indent(buff, 19, false); 126 g_free(buff); 127 buff = g_strdup_printf(" %-15.15s: %s\n", owl_pair_get_key(p), tmpbuff); 128 g_free(tmpbuff); 129 } 130 131 if(buff == NULL) { 132 buff = g_strdup_printf(" %-15.15s: %s\n", owl_pair_get_key(p), "<error>"); 133 if(buff == NULL) 134 buff=g_strdup(" <error>\n"); 135 } 136 owl_fmtext_append_normal(fm, buff); 137 g_free(buff); 138 } 92 g_datalist_foreach(&((owl_message *)m)->attributes, owl_message_attribute_tofmtext, fm); 139 93 } 140 94 … … 170 124 } 171 125 172 void owl_message_set_class(owl_message *m, const char *class)173 {174 owl_message_set_attribute(m, "class", class);175 }176 177 126 const char *owl_message_get_class(const owl_message *m) 178 127 { … … 184 133 } 185 134 186 void owl_message_set_instance(owl_message *m, const char *inst)187 {188 owl_message_set_attribute(m, "instance", inst);189 }190 191 135 const char *owl_message_get_instance(const owl_message *m) 192 136 { … … 198 142 } 199 143 200 void owl_message_set_sender(owl_message *m, const char *sender)201 {202 owl_message_set_attribute(m, "sender", sender);203 }204 205 144 const char *owl_message_get_sender(const owl_message *m) 206 145 { … … 212 151 } 213 152 214 void owl_message_set_zsig(owl_message *m, const char *zsig)215 {216 owl_message_set_attribute(m, "zsig", zsig);217 }218 219 153 const char *owl_message_get_zsig(const owl_message *m) 220 154 { … … 226 160 } 227 161 228 void owl_message_set_recipient(owl_message *m, const char *recip)229 {230 owl_message_set_attribute(m, "recipient", recip);231 }232 233 162 const char *owl_message_get_recipient(const owl_message *m) 234 163 { … … 242 171 } 243 172 244 void owl_message_set_realm(owl_message *m, const char *realm)245 {246 owl_message_set_attribute(m, "realm", realm);247 }248 249 173 const char *owl_message_get_realm(const owl_message *m) 250 174 { … … 256 180 } 257 181 258 void owl_message_set_body(owl_message *m, const char *body)259 {260 owl_message_set_attribute(m, "body", body);261 }262 263 182 const char *owl_message_get_body(const owl_message *m) 264 183 { … … 271 190 272 191 273 void owl_message_set_opcode(owl_message *m, const char *opcode)274 {275 owl_message_set_attribute(m, "opcode", opcode);276 }277 278 192 const char *owl_message_get_opcode(const owl_message *m) 279 193 { … … 288 202 void owl_message_set_islogin(owl_message *m) 289 203 { 290 owl_message_set_attribute(m, "loginout", "login" );204 owl_message_set_attribute(m, "loginout", "login", NULL); 291 205 } 292 206 … … 294 208 void owl_message_set_islogout(owl_message *m) 295 209 { 296 owl_message_set_attribute(m, "loginout", "logout" );210 owl_message_set_attribute(m, "loginout", "logout", NULL); 297 211 } 298 212 … … 329 243 void owl_message_set_isprivate(owl_message *m) 330 244 { 331 owl_message_set_attribute(m, "isprivate", "true" );245 owl_message_set_attribute(m, "isprivate", "true", NULL); 332 246 } 333 247 … … 354 268 void owl_message_set_type_admin(owl_message *m) 355 269 { 356 owl_message_set_attribute(m, "type", "admin" );270 owl_message_set_attribute(m, "type", "admin", NULL); 357 271 } 358 272 359 273 void owl_message_set_type_loopback(owl_message *m) 360 274 { 361 owl_message_set_attribute(m, "type", "loopback" );275 owl_message_set_attribute(m, "type", "loopback", NULL); 362 276 } 363 277 364 278 void owl_message_set_type_zephyr(owl_message *m) 365 279 { 366 owl_message_set_attribute(m, "type", "zephyr" );280 owl_message_set_attribute(m, "type", "zephyr", NULL); 367 281 } 368 282 369 283 void owl_message_set_type_aim(owl_message *m) 370 284 { 371 owl_message_set_attribute(m, "type", "AIM"); 372 } 373 374 void owl_message_set_type(owl_message *m, const char* type) 375 { 376 owl_message_set_attribute(m, "type", type); 285 owl_message_set_attribute(m, "type", "AIM", NULL); 377 286 } 378 287 … … 477 386 if (!z) return ""; 478 387 return z; 479 }480 481 void owl_message_set_zwriteline(owl_message *m, const char *line)482 {483 owl_message_set_attribute(m, "zwriteline", line);484 388 } 485 389 … … 558 462 559 463 void owl_message_set_isanswered(owl_message *m) { 560 owl_message_set_attribute(m, "question", "answered" );464 owl_message_set_attribute(m, "question", "answered", NULL); 561 465 } 562 466 … … 690 594 { 691 595 owl_message_init(m); 692 owl_message_set_ body(m, text);693 owl_message_set_ sender(m, sender);694 owl_message_set_ recipient(m, recipient);596 owl_message_set_attribute(m, "body", g_strdup(text), g_free); 597 owl_message_set_attribute(m, "sender", g_strdup(sender), g_free); 598 owl_message_set_attribute(m, "recipient", g_strdup(recipient), g_free); 695 599 owl_message_set_type_aim(m); 696 600 … … 717 621 owl_message_init(m); 718 622 owl_message_set_type_admin(m); 719 owl_message_set_ body(m, text);720 owl_message_set_attribute(m, "adminheader", header); /* just a hack for now */623 owl_message_set_attribute(m, "body", g_strdup(text), g_free); 624 owl_message_set_attribute(m, "adminheader", g_strdup(header), g_free); /* just a hack for now */ 721 625 } 722 626 … … 726 630 owl_message_init(m); 727 631 owl_message_set_type_loopback(m); 728 owl_message_set_ body(m, text);729 owl_message_set_ sender(m, "loopsender");730 owl_message_set_ recipient(m, "looprecip");632 owl_message_set_attribute(m, "body", g_strdup(text), g_free); 633 owl_message_set_attribute(m, "sender", "loopsender", NULL); 634 owl_message_set_attribute(m, "recipient", "looprecip", NULL); 731 635 owl_message_set_isprivate(m); 732 636 } … … 762 666 } 763 667 764 owl_message_set_attribute(m, "zephyr_ccs", recips->str); 765 g_string_free(recips, true); 668 owl_message_set_attribute(m, "zephyr_ccs", g_string_free(recips, false), g_free); 766 669 } 767 670 } … … 775 678 struct hostent *hent; 776 679 #endif /* ZNOTICE_SOCKADDR */ 777 char *tmp , *tmp2;680 char *tmp; 778 681 int len; 779 682 … … 797 700 798 701 /* set other info */ 799 owl_message_set_ sender(m, n->z_sender);800 owl_message_set_ class(m, n->z_class);801 owl_message_set_ instance(m, n->z_class_inst);802 owl_message_set_ recipient(m, n->z_recipient);702 owl_message_set_attribute(m, "sender", n->z_sender, NULL); 703 owl_message_set_attribute(m, "class", n->z_class, NULL); 704 owl_message_set_attribute(m, "instance", n->z_class_inst, NULL); 705 owl_message_set_attribute(m, "recipient", n->z_recipient, NULL); 803 706 if (n->z_opcode) { 804 owl_message_set_ opcode(m, n->z_opcode);707 owl_message_set_attribute(m, "opcode", n->z_opcode, NULL); 805 708 } else { 806 owl_message_set_ opcode(m, "");807 } 808 owl_message_set_ zsig(m, owl_zephyr_get_zsig(n, &len));809 810 owl_message_set_ realm(m, zuser_realm(n->z_recipient));709 owl_message_set_attribute(m, "opcode", "", NULL); 710 } 711 owl_message_set_attribute(m, "zsig", owl_zephyr_get_zsig(n, &len), NULL); 712 713 owl_message_set_attribute(m, "realm", zuser_realm(n->z_recipient), NULL); 811 714 812 715 /* Set the "isloginout" attribute if it's a login message */ 813 716 if (!strcasecmp(n->z_class, "login") || !strcasecmp(n->z_class, OWL_WEBZEPHYR_CLASS)) { 814 717 if (!strcasecmp(n->z_opcode, "user_login") || !strcasecmp(n->z_opcode, "user_logout")) { 815 tmp=owl_zephyr_get_field(n, 1); 816 owl_message_set_attribute(m, "loginhost", tmp); 817 g_free(tmp); 818 819 tmp=owl_zephyr_get_field(n, 3); 820 owl_message_set_attribute(m, "logintty", tmp); 821 g_free(tmp); 718 owl_message_set_attribute(m, "loginhost", owl_zephyr_get_field(n, 1), g_free); 719 owl_message_set_attribute(m, "logintty", owl_zephyr_get_field(n, 3), g_free); 822 720 } 823 721 … … 838 736 if (!strcasecmp(n->z_message, "Automated reply:") || 839 737 !strcasecmp(n->z_opcode, "auto")) { 840 owl_message_set_attribute(m, "isauto", "" );738 owl_message_set_attribute(m, "isauto", "", NULL); 841 739 } 842 740 … … 858 756 tmp=owl_zephyr_get_message(n, m); 859 757 if (owl_global_is_newlinestrip(&g)) { 860 tmp2=owl_util_stripnewlines(tmp); 861 owl_message_set_body(m, tmp2); 862 g_free(tmp2); 758 owl_message_set_attribute(m, "body", owl_util_stripnewlines(tmp), g_free); 759 g_free(tmp); 863 760 } else { 864 owl_message_set_body(m, tmp); 865 } 866 g_free(tmp); 761 owl_message_set_attribute(m, "body", tmp, g_free); 762 } 867 763 868 764 /* if zcrypt is enabled try to decrypt the message */ … … 891 787 out[len - 8] = 0; 892 788 } 893 owl_message_set_ body(m, out);789 owl_message_set_attribute(m, "body", out, g_free); 894 790 } else { 895 791 /* Replace the opcode. Otherwise the UI and other bits of code think the 896 792 * message was encrypted. */ 897 owl_message_set_opcode(m, "failed-decrypt"); 793 owl_message_set_attribute(m, "opcode", "failed-decrypt", NULL); 794 g_free(out); 898 795 } 899 g_free(out);900 796 } 901 797 … … 924 820 owl_message_set_direction_in(m); 925 821 926 owl_message_set_attribute(m, "pseudo", "" );927 owl_message_set_attribute(m, "loginhost", host ? host : "");928 owl_message_set_attribute(m, "logintty", tty ? tty : "");929 930 owl_message_set_ sender(m, longuser);931 owl_message_set_ class(m, "LOGIN");932 owl_message_set_ instance(m, longuser);933 owl_message_set_ recipient(m, "");822 owl_message_set_attribute(m, "pseudo", "", NULL); 823 owl_message_set_attribute(m, "loginhost", g_strdup(host ? host : ""), g_free); 824 owl_message_set_attribute(m, "logintty", g_strdup(tty ? tty : ""), g_free); 825 826 owl_message_set_attribute(m, "sender", g_strdup(longuser), g_free); 827 owl_message_set_attribute(m, "class", "LOGIN", NULL); 828 owl_message_set_attribute(m, "instance", g_strdup(longuser), g_free); 829 owl_message_set_attribute(m, "recipient", "", NULL); 934 830 if (direction==0) { 935 owl_message_set_ opcode(m, "USER_LOGIN");831 owl_message_set_attribute(m, "opcode", "USER_LOGIN", NULL); 936 832 owl_message_set_islogin(m); 937 833 } else if (direction==1) { 938 owl_message_set_ opcode(m, "USER_LOGOUT");834 owl_message_set_attribute(m, "opcode", "USER_LOGOUT", NULL); 939 835 owl_message_set_islogout(m); 940 836 } 941 837 942 owl_message_set_ realm(m, zuser_realm(longuser));943 944 owl_message_set_ body(m, "<uninitialized>");838 owl_message_set_attribute(m, "realm", g_strdup(zuser_realm(longuser)), g_free); 839 840 owl_message_set_attribute(m, "body", "<uninitialized>", NULL); 945 841 946 842 /* save the hostname */ … … 959 855 owl_message_set_direction_out(m); 960 856 owl_message_set_type_zephyr(m); 961 owl_message_set_ sender(m, owl_zephyr_get_sender());962 owl_message_set_ class(m, owl_zwrite_get_class(z));963 owl_message_set_ instance(m, owl_zwrite_get_instance(z));857 owl_message_set_attribute(m, "sender", g_strdup(owl_zephyr_get_sender()), g_free); 858 owl_message_set_attribute(m, "class", g_strdup(owl_zwrite_get_class(z)), g_free); 859 owl_message_set_attribute(m, "instance", g_strdup(owl_zwrite_get_instance(z)), g_free); 964 860 if (recip_index < owl_zwrite_get_numrecips(z)) { 965 861 char *zuser = owl_zwrite_get_recip_n_with_realm(z, recip_index); 966 862 char *longzuser = long_zuser(zuser); 967 owl_message_set_recipient(m, longzuser); 968 owl_message_set_realm(m, zuser_realm(longzuser)); 969 g_free(longzuser); 863 owl_message_set_attribute(m, "realm", g_strdup(zuser_realm(longzuser)), g_free); 864 owl_message_set_attribute(m, "recipient", longzuser, g_free); 970 865 g_free(zuser); 971 866 } else { … … 974 869 * anyway. */ 975 870 const char *realm = owl_zwrite_get_realm(z); 976 owl_message_set_ realm(m, realm[0] ? realm : owl_zephyr_get_realm());977 } 978 owl_message_set_ opcode(m, owl_zwrite_get_opcode(z));871 owl_message_set_attribute(m, "realm", g_strdup(realm[0] ? realm : owl_zephyr_get_realm()), g_free); 872 } 873 owl_message_set_attribute(m, "opcode", g_strdup(owl_zwrite_get_opcode(z)), g_free); 979 874 980 875 /* Although not strictly the zwriteline, anyone using the unsantized version 981 876 * of it probably has a bug. */ 982 877 replyline = owl_zwrite_get_replyline(z, recip_index); 983 owl_message_set_ zwriteline(m, replyline);878 owl_message_set_attribute(m, "zwriteline", g_strdup(replyline), g_free); 984 879 g_free(replyline); 985 880 986 owl_message_set_ body(m, body);987 owl_message_set_ zsig(m, owl_zwrite_get_zsig(z));881 owl_message_set_attribute(m, "body", g_strdup(body), g_free); 882 owl_message_set_attribute(m, "zsig", g_strdup(owl_zwrite_get_zsig(z)), g_free); 988 883 989 884 /* save the hostname */ … … 1000 895 void owl_message_cleanup(owl_message *m) 1001 896 { 1002 int i;1003 owl_pair *p;1004 897 #ifdef HAVE_LIBZEPHYR 1005 898 if (m->has_notice) { … … 1010 903 1011 904 /* free all the attributes */ 1012 for (i = 0; i < m->attributes->len; i++) { 1013 p = m->attributes->pdata[i]; 1014 g_free(owl_pair_get_value(p)); 1015 g_slice_free(owl_pair, p); 1016 } 1017 1018 g_ptr_array_free(m->attributes, true); 905 g_datalist_clear(&m->attributes); 1019 906 1020 907 owl_message_invalidate_format(m); -
owl.h
rca1fb26a r58777e9 339 339 } owl_zwrite; 340 340 341 typedef struct _owl_pair {342 const char *key;343 char *value;344 } owl_pair;345 346 341 struct _owl_fmtext_cache; 347 342 … … 356 351 int delete; 357 352 const char *hostname; 358 G PtrArray *attributes; /* this is a list of pairs */353 GData *attributes; 359 354 char *timestr; 360 355 time_t time; -
perlconfig.c
r7dcef03 rb36b9a6 69 69 } 70 70 71 static void owl_perlconfig_store_attribute(GQuark key_id, gpointer data, gpointer h) 72 { 73 const char *key = g_quark_to_string(key_id); 74 (void)hv_store(h, key, strlen(key), owl_new_sv(data), 0); 75 } 76 71 77 CALLER_OWN SV *owl_perlconfig_message2hashref(const owl_message *m) 72 78 { … … 76 82 char *ptr, *utype, *blessas; 77 83 const char *f; 78 int i;79 const owl_pair *pair;80 84 const owl_filter *wrap; 81 85 … … 112 116 } 113 117 114 for (i = 0; i < m->attributes->len; i++) { 115 pair = m->attributes->pdata[i]; 116 (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)), 117 owl_new_sv(owl_pair_get_value(pair)),0); 118 } 118 g_datalist_foreach(&((owl_message *)m)->attributes, owl_perlconfig_store_attribute, h); 119 119 120 120 MSG2H(h, type); … … 195 195 key = hv_iterkey(ent, &len); 196 196 val = SvPV_nolen(hv_iterval(hash, ent)); 197 if(!strcmp(key, "type")) { 198 owl_message_set_type(m, val); 199 } else if(!strcmp(key, "direction")) { 197 if (!strcmp(key, "direction")) { 200 198 owl_message_set_direction(m, owl_message_parse_direction(val)); 201 199 } else if(!strcmp(key, "private")) { … … 206 204 } else if (!strcmp(key, "hostname")) { 207 205 owl_message_set_hostname(m, val); 208 } else if (!strcmp(key, "zwriteline")) {209 owl_message_set_zwriteline(m, val);210 206 } else if (!strcmp(key, "time")) { 211 207 g_free(m->timestr); … … 214 210 m->time = mktime(&tm); 215 211 } else { 216 owl_message_set_attribute(m, key, val);212 owl_message_set_attribute(m, key, g_strdup(val), g_free); 217 213 } 218 214 } 219 215 if(owl_message_is_type_admin(m)) { 220 216 if(!owl_message_get_attribute_value(m, "adminheader")) 221 owl_message_set_attribute(m, "adminheader", "" );217 owl_message_set_attribute(m, "adminheader", "", NULL); 222 218 } 223 219 return m; -
tester.c
ra7250ee rd110d95 464 464 owl_message_set_type_zephyr(&m); 465 465 owl_message_set_direction_in(&m); 466 owl_message_set_ class(&m, "owl");467 owl_message_set_ instance(&m, "tester");468 owl_message_set_ sender(&m, "owl-user");469 owl_message_set_ recipient(&m, "joe");470 owl_message_set_attribute(&m, "foo", "bar" );466 owl_message_set_attribute(&m, "class", "owl", NULL); 467 owl_message_set_attribute(&m, "instance", "tester", NULL); 468 owl_message_set_attribute(&m, "sender", "owl-user", NULL); 469 owl_message_set_attribute(&m, "recipient", "joe", NULL); 470 owl_message_set_attribute(&m, "foo", "bar", NULL); 471 471 472 472 #define TEST_FILTER(f, e) do { \ -
util.c
rd2ba33c rd110d95 608 608 } 609 609 return r; 610 } 611 612 /* Check whether in is not valid UTF-8 or has format characters. */ 613 bool owl_needs_convert(const char *in) 614 { 615 const char *p; 616 if (!g_utf8_validate(in, -1, NULL)) 617 return true; 618 for (p = strchr(in, OWL_FMTEXT_UC_STARTBYTE_UTF8); 619 p != NULL; 620 p = strchr(p + 1, OWL_FMTEXT_UC_STARTBYTE_UTF8)) { 621 if (owl_fmtext_is_format_char(g_utf8_get_char(p))) 622 return true; 623 } 624 return false; 610 625 } 611 626 -
.travis.yml
r48c09d4 rbecd617 1 1 language: perl 2 sudo: false 2 3 compiler: 3 4 - clang … … 9 10 - "5.16" 10 11 - "5.18" 11 - "5.19" 12 install: 13 - sudo apt-get update -q 14 # we actually want debhelper >= 7, libperl-dev >= 5.10.1-8, libzephyr-dev >= 3.0~beta 15 - sudo apt-get install -q autoconf autotools-dev debhelper dh-autoreconf libglib2.0-dev libkrb5-dev libncurses5-dev libncursesw5-dev libssl-dev libzephyr-dev pkg-config zip 12 - "5.20" 13 addons: 14 apt: 15 # we actually want debhelper >= 7, libperl-dev >= 5.10.1-8, libzephyr-dev >= 3.0~beta 16 packages: 17 - autoconf 18 - autotools-dev 19 - debhelper 20 - dh-autoreconf 21 - libglib2.0-dev 22 - libkrb5-dev 23 - libncurses5-dev 24 - libncursesw5-dev 25 - libssl-dev 26 - libzephyr-dev 27 - pkg-config 28 - zip 16 29 # perl things 17 30 # In lp:~barnowl/barnowl/packaging, we use apt-get. Here, we use cpanm. 18 31 # - sudo apt-get install libanyevent-perl libclass-accessor-perl libextutils-depends-perl libglib-perl libmodule-install-perl libnet-twitter-lite-perl libpar-perl libperl-dev 19 - cpanm AnyEvent Class::Accessor ExtUtils::Depends Glib Module::Install Net::Twitter::Lite PAR 20 script: "./autogen.sh && ./configure && make distcheck"32 # It's taken care of by the default install script 33 script: ./autogen.sh && ./configure && make distcheck -
ChangeLog
r6f87658 r678a7650 1 1.10 2 * No changes above what's already in 1.10rc1 3 4 1.10rc1 5 * Numerous autotools/build machinery fixes -andersk@mit.edu 6 * Numerous code correctness and simplification/cleanup fixes -andersk@mit.edu 7 * Add and use a cpanfile documenting perl module dependencies -jgross@mit.edu 8 * Add Travis configuration -jgross@mit.edu 9 * Avoid strchrnul -andersk@mit.edu 10 * Numerous IRC fixes -jgross@mit.edu 11 * Improve smartnarrow and smartfilter documentation -jgross@mit.edu 12 * filterproc: Rewrite using GIOChannel -andersk@mit.edu 13 * Implement :twitter-favorite -nelhage@nelhage.com 14 * Kill the client-side tweet length check. -nelhage@nelhage.com 15 * squelch the Twitter legacy_list_api warnings -nelhage@nelhage.com 16 * Use SSL for Twitter by default -adehnert@mit.edu 17 * Humanize zsigs -andersk@mit.edu 18 * Show Zephyr charset in info popup -andersk@mit.edu 19 * Fix Jabber SRV record support (at one point fixed connecting via jabber to google talk or facebook) -james2vegas@aim.com 20 * fix cmd_join in BarnOwl/Module/IRC.pm -james2vegas@aim.com 21 * Add a ~/.owl/ircchannels file, persist channels -jgross@mit.edu 22 * Added hooks for user going idle or active. -jgross@mit.edu 23 * Support channel-or-user IRC commands, and setup irc-msg to use it. -ezyang@mit.edu 24 * Refactor perl calls through a single method -jgross@mit.edu 25 * Really support building Perl modules from a separate builddir -andersk@mit.edu 26 * Get rid of all our embedded copies of Module::Install -andersk@mit.edu 27 * Don't let new_variable_* overriding previously set values -rnjacobs@mit.edu 28 * Messages sent to 'class messages' are not personal -jgross@mit.edu 29 * Expose message_matches_filter to perl -jgross@mit.edu 30 * Fail fast on -c filsrv, which most people won't have permission to send to -rnjacobs@mit.edu 31 * zcrypt: Use getopt_long for argument parsing -andersk@mit.edu 32 * zcrypt: Accept -help and --version -andersk@mit.edu 33 * barnowl --help: Write to stdout and exit successfully -andersk@mit.edu 34 * Don't swallow errors in :unsuball -davidben@mit.edu 35 * Allow testing in a separate build directory -andersk@mit.edu 36 * Add support for arbitrary Perl subs for getters and setters for barnowl variables -glasgall@mit.edu 37 * owl_zephyr_loadsubs: Don’t leak memory on error opening ~/.zephyr.subs -andersk@mit.edu 38 * Make :loadsubs reload instanced personals too -davidben@mit.edu 39 * Fix some undefined behavior in filter.c, caught by clang scan-build -jgross@mit.edu 40 * Die on a failed zephyr_zwrite; don't silently ignore it -jgross@mit.edu 41 * Fix a memory leak in zcrypt.c, caught by clang scan-build -jgross@mit.edu 42 * zcrypt: Make gpg stop messing around in ~/.gnupg -andersk@mit.edu 43 * Fix display of pseudologins -davidben@mit.edu 44 * Unbundle random Facebook module libraries -davidben@mit.edu 45 * Replace deprecated GLib < 2.31.0 APIs -andersk@mit.edu 46 * Abstract g->interrupt_lock -andersk@mit.edu 47 * zephyr: Replace outgoing default format with a small URL -geofft@mit.edu 48 1 49 1.9 2 50 * Update Jabber module for Net::DNS changes -james2vegas@aim.com -
commands.c
rca1fb26a r4511ac3 153 153 OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY, 154 154 "set a variable value", 155 "set [-q] [<variable>][<value>]\n"155 "set [-q] <variable> [<value>]\n" 156 156 "set", 157 157 "Set the named variable to the specified value. If no\n" … … 487 487 "\n" 488 488 "SEE ALSO: aaway, zaway"), 489 490 OWLCMD_ARGS("flush-logs", owl_command_flushlogs, OWL_CTX_ANY, 491 "flush the queue of messages waiting to be logged", 492 "flush-logs [-f | --force] [-q | --quiet]", 493 "If BarnOwl failed to log a file, this command tells\n" 494 "BarnOwl to try logging the messages that have since\n" 495 "come in, and to resume logging normally.\n" 496 "\n" 497 "Normally, if logging any of these messages fails,\n" 498 "that message is added to the queue of messages waiting\n" 499 "to be logged, and any new messages are deferred until\n" 500 "the next :flush-logs. If the --force flag is passed,\n" 501 "any messages on the queue which cannot successfully be\n" 502 "logged are dropped, and BarnOwl will resume logging\n" 503 "normally.\n" 504 "\n" 505 "Unless --quiet is passed, a message is printed about\n" 506 "how many logs there are to flush."), 489 507 490 508 OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY, … … 548 566 "optional color arguments are used they specifies the colors that\n" 549 567 "messages matching this filter should be displayed in.\n\n" 550 "SEE ALSO: view, viewclass, viewuser\n"),568 "SEE ALSO: smartfilter, smartnarrow, view, viewclass, viewuser\n"), 551 569 552 570 OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE, … … 585 603 "filter expression that will be dynamically created by BarnOwl and then\n" 586 604 "applied as the view's filter\n" 587 "SEE ALSO: filter, viewclass, viewuser\n"),605 "SEE ALSO: filter, smartfilter, smartnarrow, viewclass, viewuser\n"), 588 606 589 607 OWLCMD_ARGS("smartnarrow", owl_command_smartnarrow, OWL_CTX_INTERACTIVE, … … 599 617 " then narrow to the class and instance.\n" 600 618 "If '-r' or '--related' is specified, behave as though the\n" 601 " 'narrow-related' variable was inverted."), 619 " 'narrow-related' variable was inverted.\n\n" 620 "SEE ALSO: filter, smartfilter, view, viewclass, viewuser\n"), 602 621 603 622 OWLCMD_ARGS("smartfilter", owl_command_smartfilter, OWL_CTX_INTERACTIVE, … … 610 629 "If the curmsg is a class message, the filter is that class.\n" 611 630 "If the curmsg is a class message and '-i' is specified\n" 612 " the filter is to that class and instance.\n"), 631 " the filter is to that class and instance.\n\n" 632 "SEE ALSO: filter, smartnarrow, view, viewclass, viewuser\n"), 613 633 614 634 OWLCMD_ARGS("viewclass", owl_command_viewclass, OWL_CTX_INTERACTIVE, … … 618 638 "matching the specified class and switch the current view\n" 619 639 "to it.\n\n" 620 "SEE ALSO: filter, view, viewuser\n"),640 "SEE ALSO: filter, smartfilter, smartnarrow, view, viewuser\n"), 621 641 OWLCMD_ALIAS("vc", "viewclass"), 622 642 … … 627 647 "matching the specified user and switch the current\n" 628 648 "view to it.\n\n" 629 "SEE ALSO: filter, view, viewclass\n"),649 "SEE ALSO: filter, smartfilter, smartnarrow, view, viewclass\n"), 630 650 OWLCMD_ALIAS("vu", "viewuser"), 631 651 OWLCMD_ALIAS("viewperson", "viewuser"), … … 1433 1453 { 1434 1454 owl_function_unsuball(); 1455 } 1456 1457 char *owl_command_flushlogs(int argc, const char *const *argv, const char *buff) 1458 { 1459 bool force = false; 1460 bool quiet = false; 1461 int i; 1462 1463 for (i = 1; i < argc; i++) { 1464 if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--force")) { 1465 force = true; 1466 } else if (!strcmp(argv[i], "-q") || !strcmp(argv[i], "--quiet")) { 1467 quiet = true; 1468 } else { 1469 owl_function_makemsg("Invalid flag to flush-logs: %s", argv[i]); 1470 } 1471 } 1472 owl_log_flush_logs(force, quiet); 1473 return NULL; 1435 1474 } 1436 1475 -
configure.ac
r77dfeb1 r370d94d 1 1 dnl Process this file with autoconf to produce a configure script. 2 AC_INIT([BarnOwl],[1.1 0dev],[bug-barnowl@mit.edu])2 AC_INIT([BarnOwl],[1.11dev],[bug-barnowl@mit.edu]) 3 3 AM_INIT_AUTOMAKE([1.7.0 foreign std-options -Wall -Wno-portability]) 4 4 AM_MAINTAINER_MODE([enable]) -
filterproc.c
r7155955 re8db357 1 1 #include "filterproc.h" 2 2 #include <sys/wait.h> 3 #include < fcntl.h>3 #include <string.h> 4 4 #include <glib.h> 5 #include <poll.h>6 #include <string.h>7 #include <unistd.h>8 5 9 /* Even in case of error, send_receive is responsible for closing wfd 10 * (to EOF the child) and rfd (for consistency). */ 11 static int send_receive(int rfd, int wfd, const char *out, char **in) 6 struct filter_data { 7 const char **in; 8 const char *in_end; 9 GString *out_str; 10 GMainLoop *loop; 11 int err; 12 }; 13 14 static gboolean filter_stdin(GIOChannel *channel, GIOCondition condition, gpointer data_) 12 15 { 13 GString *str = g_string_new(""); 14 char buf[1024]; 15 nfds_t nfds; 16 int err = 0; 17 struct pollfd fds[2]; 16 struct filter_data *data = data_; 17 gboolean done = condition & (G_IO_ERR | G_IO_HUP); 18 18 19 fcntl(rfd, F_SETFL, O_NONBLOCK | fcntl(rfd, F_GETFL)); 20 fcntl(wfd, F_SETFL, O_NONBLOCK | fcntl(wfd, F_GETFL)); 21 22 fds[0].fd = rfd; 23 fds[0].events = POLLIN; 24 fds[1].fd = wfd; 25 fds[1].events = POLLOUT; 26 27 if(!out || !*out) { 28 /* Nothing to write. Close our end so the child doesn't hang waiting. */ 29 close(wfd); wfd = -1; 30 out = NULL; 19 if (condition & G_IO_OUT) { 20 gsize n; 21 GIOStatus ret = g_io_channel_write_chars(channel, *data->in, data->in_end - *data->in, &n, NULL); 22 *data->in += n; 23 if (ret == G_IO_STATUS_ERROR) 24 data->err = 1; 25 if (ret == G_IO_STATUS_ERROR || *data->in == data->in_end) 26 done = TRUE; 31 27 } 32 28 33 while(1) { 34 if(out && *out) { 35 nfds = 2; 36 } else { 37 nfds = 1; 38 } 39 err = poll(fds, nfds, -1); 40 if(err < 0) { 41 break; 42 } 43 if(out && *out) { 44 if(fds[1].revents & POLLOUT) { 45 err = write(wfd, out, strlen(out)); 46 if(err > 0) { 47 out += err; 48 } 49 if(err < 0) { 50 out = NULL; 51 } 52 } 53 if(!out || !*out || fds[1].revents & (POLLERR | POLLHUP)) { 54 close(wfd); wfd = -1; 55 out = NULL; 56 } 57 } 58 if(fds[0].revents & POLLIN) { 59 err = read(rfd, buf, sizeof(buf)); 60 if(err <= 0) { 61 break; 62 } 63 g_string_append_len(str, buf, err); 64 } else if(fds[0].revents & (POLLHUP | POLLERR)) { 65 err = 0; 66 break; 29 if (condition & G_IO_ERR) 30 data->err = 1; 31 32 if (done) 33 g_io_channel_shutdown(channel, TRUE, NULL); 34 return !done; 35 } 36 37 static gboolean filter_stdout(GIOChannel *channel, GIOCondition condition, gpointer data_) 38 { 39 struct filter_data *data = data_; 40 gboolean done = condition & (G_IO_ERR | G_IO_HUP); 41 42 if (condition & (G_IO_IN | G_IO_HUP)) { 43 gchar *buf; 44 gsize n; 45 GIOStatus ret = g_io_channel_read_to_end(channel, &buf, &n, NULL); 46 g_string_append_len(data->out_str, buf, n); 47 g_free(buf); 48 if (ret == G_IO_STATUS_ERROR) { 49 data->err = 1; 50 done = TRUE; 67 51 } 68 52 } 69 53 70 if (wfd >= 0) close(wfd); 71 close(rfd); 72 *in = g_string_free(str, err < 0); 73 return err; 54 if (condition & G_IO_ERR) 55 data->err = 1; 56 57 if (done) { 58 g_io_channel_shutdown(channel, TRUE, NULL); 59 g_main_loop_quit(data->loop); 60 } 61 return !done; 74 62 } 75 63 76 64 int call_filter(const char *const *argv, const char *in, char **out, int *status) 77 65 { 78 int err;79 66 GPid child_pid; 80 67 int child_stdin, child_stdout; … … 89 76 } 90 77 91 err = send_receive(child_stdout, child_stdin, in, out); 92 if (err == 0) { 93 waitpid(child_pid, status, 0); 94 } 95 return err; 78 if (in == NULL) in = ""; 79 GMainContext *context = g_main_context_new(); 80 struct filter_data data = {&in, in + strlen(in), g_string_new(""), g_main_loop_new(context, FALSE), 0}; 81 82 GIOChannel *channel = g_io_channel_unix_new(child_stdin); 83 g_io_channel_set_encoding(channel, NULL, NULL); 84 g_io_channel_set_flags(channel, g_io_channel_get_flags(channel) | G_IO_FLAG_NONBLOCK, NULL); 85 GSource *source = g_io_create_watch(channel, G_IO_OUT | G_IO_ERR | G_IO_HUP); 86 g_io_channel_unref(channel); 87 g_source_set_callback(source, (GSourceFunc)filter_stdin, &data, NULL); 88 g_source_attach(source, context); 89 g_source_unref(source); 90 91 channel = g_io_channel_unix_new(child_stdout); 92 g_io_channel_set_encoding(channel, NULL, NULL); 93 g_io_channel_set_flags(channel, g_io_channel_get_flags(channel) | G_IO_FLAG_NONBLOCK, NULL); 94 source = g_io_create_watch(channel, G_IO_IN | G_IO_ERR | G_IO_HUP); 95 g_io_channel_unref(channel); 96 g_source_set_callback(source, (GSourceFunc)filter_stdout, &data, NULL); 97 g_source_attach(source, context); 98 g_source_unref(source); 99 100 g_main_loop_run(data.loop); 101 102 g_main_loop_unref(data.loop); 103 g_main_context_unref(context); 104 105 waitpid(child_pid, status, 0); 106 g_spawn_close_pid(child_pid); 107 *out = g_string_free(data.out_str, data.err); 108 return data.err; 96 109 } -
functions.c
r7dcef03 rb61ad80 1227 1227 time_t now; 1228 1228 va_list ap; 1229 va_start(ap, fmt);1230 1229 1231 1230 if (!owl_global_is_debug_fast(&g)) … … 1242 1241 (int) getpid(), tmpbuff, now - owl_global_get_starttime(&g)); 1243 1242 g_free(tmpbuff); 1243 1244 va_start(ap, fmt); 1244 1245 vfprintf(file, fmt, ap); 1246 va_end(ap); 1247 1245 1248 putc('\n', file); 1246 1249 fflush(file); 1247 1248 va_end(ap);1249 1250 } 1250 1251 -
keys.c
rdcd48ad rd400776 44 44 BIND_CMD("M-RIGHT", "edit:move-next-word", ""); 45 45 BIND_CMD("M-[ 1 ; 3 D", "edit:move-next-word", ""); 46 BIND_CMD("M-[ 1 ; 5 D", "edit:move-next-word", ""); 46 47 BIND_CMD("M-b", "edit:move-prev-word", ""); 47 48 BIND_CMD("M-O 3 D", "edit:move-prev-word", ""); 48 49 BIND_CMD("M-LEFT", "edit:move-prev-word", ""); 49 BIND_CMD("M-[ 1 ; 3 C", "edit:move-next-word", ""); 50 BIND_CMD("M-[ 1 ; 3 C", "edit:move-prev-word", ""); 51 BIND_CMD("M-[ 1 ; 5 C", "edit:move-prev-word", ""); 50 52 51 53 BIND_CMD("LEFT", "edit:move-left", ""); -
logging.c
r7dcef03 r0c059f0 7 7 } owl_log_entry; 8 8 9 typedef struct _owl_log_options { /* noproto */ 10 bool drop_failed_logs; 11 bool display_initial_log_count; 12 } owl_log_options; 9 13 10 14 static GMainContext *log_context; 11 15 static GMainLoop *log_loop; 12 16 static GThread *logging_thread; 13 14 /* This is now the one function that should be called to log a 15 * message. It will do all the work necessary by calling the other 16 * functions in this file as necessary. 17 static bool defer_logs; /* to be accessed only on the disk-writing thread */ 18 static GQueue *deferred_entry_queue; 19 20 static void owl_log_error_main_thread(gpointer data) 21 { 22 owl_function_error("%s", (const char*)data); 23 } 24 25 static void owl_log_adminmsg_main_thread(gpointer data) 26 { 27 owl_function_adminmsg("Logging", (const char*)data); 28 } 29 30 static void owl_log_makemsg_main_thread(gpointer data) 31 { 32 owl_function_makemsg("%s", (const char*)data); 33 } 34 35 static void G_GNUC_PRINTF(1, 2) owl_log_error(const char *fmt, ...) 36 { 37 va_list ap; 38 char *data; 39 40 va_start(ap, fmt); 41 data = g_strdup_vprintf(fmt, ap); 42 va_end(ap); 43 44 owl_select_post_task(owl_log_error_main_thread, 45 data, g_free, g_main_context_default()); 46 } 47 48 static void G_GNUC_PRINTF(1, 2) owl_log_adminmsg(const char *fmt, ...) 49 { 50 va_list ap; 51 char *data; 52 53 va_start(ap, fmt); 54 data = g_strdup_vprintf(fmt, ap); 55 va_end(ap); 56 57 owl_select_post_task(owl_log_adminmsg_main_thread, 58 data, g_free, g_main_context_default()); 59 } 60 61 static void G_GNUC_PRINTF(1, 2) owl_log_makemsg(const char *fmt, ...) 62 { 63 va_list ap; 64 char *data; 65 66 va_start(ap, fmt); 67 data = g_strdup_vprintf(fmt, ap); 68 va_end(ap); 69 70 owl_select_post_task(owl_log_makemsg_main_thread, 71 data, g_free, g_main_context_default()); 72 } 73 74 static CALLER_OWN owl_log_entry *owl_log_new_entry(const char *buffer, const char *filename) 75 { 76 owl_log_entry *log_msg = g_slice_new(owl_log_entry); 77 log_msg->message = g_strdup(buffer); 78 log_msg->filename = g_strdup(filename); 79 return log_msg; 80 } 81 82 static void owl_log_deferred_enqueue_message(const char *buffer, const char *filename) 83 { 84 g_queue_push_tail(deferred_entry_queue, owl_log_new_entry(buffer, filename)); 85 } 86 87 static void owl_log_deferred_enqueue_first_message(const char *buffer, const char *filename) 88 { 89 g_queue_push_head(deferred_entry_queue, owl_log_new_entry(buffer, filename)); 90 } 91 92 /* write out the entry if possible 93 * return 0 on success, errno on failure to open 17 94 */ 18 void owl_log_message(const owl_message *m) { 19 owl_function_debugmsg("owl_log_message: entering"); 20 21 if (m == NULL) { 22 owl_function_debugmsg("owl_log_message: passed null message"); 23 return; 24 } 25 26 /* should we be logging this message? */ 27 if (!owl_log_shouldlog_message(m)) { 28 owl_function_debugmsg("owl_log_message: not logging message"); 29 return; 30 } 31 32 /* handle incmoing messages */ 33 if (owl_message_is_direction_in(m)) { 34 owl_log_incoming(m); 35 owl_function_debugmsg("owl_log_message: leaving"); 36 return; 37 } 38 39 /* handle outgoing messages */ 40 owl_log_outgoing(m); 41 42 owl_function_debugmsg("owl_log_message: leaving"); 43 } 44 45 /* Return 1 if we should log the given message, otherwise return 0 */ 46 int owl_log_shouldlog_message(const owl_message *m) { 47 const owl_filter *f; 48 49 /* If there's a logfilter and this message matches it, log */ 50 f=owl_global_get_filter(&g, owl_global_get_logfilter(&g)); 51 if (f && owl_filter_message_match(f, m)) return(1); 52 53 /* otherwise we do things based on the logging variables */ 54 55 /* skip login/logout messages if appropriate */ 56 if (!owl_global_is_loglogins(&g) && owl_message_is_loginout(m)) return(0); 57 58 /* check direction */ 59 if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_IN) && owl_message_is_direction_out(m)) { 60 return(0); 61 } 62 if ((owl_global_get_loggingdirection(&g)==OWL_LOGGING_DIRECTION_OUT) && owl_message_is_direction_in(m)) { 63 return(0); 64 } 65 66 if (owl_message_is_type_zephyr(m)) { 67 if (owl_message_is_personal(m) && !owl_global_is_logging(&g)) return(0); 68 if (!owl_message_is_personal(m) && !owl_global_is_classlogging(&g)) return(0); 69 } else { 70 if (owl_message_is_private(m) || owl_message_is_loginout(m)) { 71 if (!owl_global_is_logging(&g)) return(0); 72 } else { 73 if (!owl_global_is_classlogging(&g)) return(0); 74 } 75 } 76 return(1); 77 } 78 79 CALLER_OWN char *owl_log_zephyr(const owl_message *m) 80 { 81 char *tmp = NULL; 82 GString *buffer = NULL; 83 buffer = g_string_new(""); 84 tmp = short_zuser(owl_message_get_sender(m)); 85 g_string_append_printf(buffer, "Class: %s Instance: %s", 86 owl_message_get_class(m), 87 owl_message_get_instance(m)); 88 if (strcmp(owl_message_get_opcode(m), "")) { 89 g_string_append_printf(buffer, " Opcode: %s", 90 owl_message_get_opcode(m)); 91 } 92 g_string_append_printf(buffer, "\n"); 93 g_string_append_printf(buffer, "Time: %s Host: %s\n", 94 owl_message_get_timestr(m), 95 owl_message_get_hostname(m)); 96 g_string_append_printf(buffer, "From: %s <%s>\n\n", 97 owl_message_get_zsig(m), tmp); 98 g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m)); 99 g_free(tmp); 100 return g_string_free(buffer, FALSE); 101 } 102 103 CALLER_OWN char *owl_log_aim(const owl_message *m) 104 { 105 GString *buffer = NULL; 106 buffer = g_string_new(""); 107 g_string_append_printf(buffer, "From: <%s> To: <%s>\n", 108 owl_message_get_sender(m), owl_message_get_recipient(m)); 109 g_string_append_printf(buffer, "Time: %s\n\n", 110 owl_message_get_timestr(m)); 111 if (owl_message_is_login(m)) { 112 g_string_append_printf(buffer, "LOGIN\n\n"); 113 } else if (owl_message_is_logout(m)) { 114 g_string_append_printf(buffer, "LOGOUT\n\n"); 115 } else { 116 g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m)); 117 } 118 return g_string_free(buffer, FALSE); 119 } 120 121 CALLER_OWN char *owl_log_jabber(const owl_message *m) 122 { 123 GString *buffer = NULL; 124 buffer = g_string_new(""); 125 g_string_append_printf(buffer, "From: <%s> To: <%s>\n", 126 owl_message_get_sender(m), 127 owl_message_get_recipient(m)); 128 g_string_append_printf(buffer, "Time: %s\n\n", 129 owl_message_get_timestr(m)); 130 g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m)); 131 return g_string_free(buffer, FALSE); 132 } 133 134 CALLER_OWN char *owl_log_generic(const owl_message *m) 135 { 136 GString *buffer; 137 buffer = g_string_new(""); 138 g_string_append_printf(buffer, "From: <%s> To: <%s>\n", 139 owl_message_get_sender(m), 140 owl_message_get_recipient(m)); 141 g_string_append_printf(buffer, "Time: %s\n\n", 142 owl_message_get_timestr(m)); 143 g_string_append_printf(buffer, "%s\n\n", 144 owl_message_get_body(m)); 145 return g_string_free(buffer, FALSE); 146 } 147 148 static void owl_log_error_main_thread(gpointer data) 149 { 150 owl_function_error("%s", (const char*)data); 151 } 152 153 static void owl_log_error(const char *message) 154 { 155 char *data = g_strdup(message); 156 owl_select_post_task(owl_log_error_main_thread, 157 data, g_free, g_main_context_default()); 158 } 159 160 static void owl_log_write_entry(gpointer data) 161 { 162 owl_log_entry *msg = (owl_log_entry*)data; 95 static int owl_log_try_write_entry(owl_log_entry *msg) 96 { 163 97 FILE *file = NULL; 164 98 file = fopen(msg->filename, "a"); 165 99 if (!file) { 166 owl_log_error("Unable to open file for logging"); 167 return; 100 return errno; 168 101 } 169 102 fprintf(file, "%s", msg->message); 170 103 fclose(file); 171 } 172 173 static void owl_log_entry_free(void *data) 104 return 0; 105 } 106 107 static void owl_log_entry_delete(void *data) 174 108 { 175 109 owl_log_entry *msg = (owl_log_entry*)data; 176 if (msg) { 177 g_free(msg->message); 178 g_free(msg->filename); 179 g_slice_free(owl_log_entry, msg); 180 } 110 g_free(msg->message); 111 g_free(msg->filename); 112 g_slice_free(owl_log_entry, msg); 113 } 114 115 #if GLIB_CHECK_VERSION(2, 32, 0) 116 #else 117 static void owl_log_entry_delete_gfunc(gpointer data, gpointer user_data) 118 { 119 owl_log_entry_delete(data); 120 } 121 #endif 122 123 static void owl_log_file_error(owl_log_entry *msg, int errnum) 124 { 125 owl_log_error("Unable to open file for logging: %s (file %s)", 126 g_strerror(errnum), 127 msg->filename); 128 } 129 130 /* If we are deferring log messages, enqueue this entry for writing. 131 * Otherwise, try to write this log message, and, if it fails with 132 * EPERM, EACCES, or ETIMEDOUT, go into deferred logging mode and 133 * queue an admin message. If it fails with anything else, display an 134 * error message, drop the log message, and do not go into deferred 135 * logging mode. 136 * 137 * N.B. This function is called only on the disk-writing thread. */ 138 static void owl_log_eventually_write_entry(gpointer data) 139 { 140 int ret; 141 owl_log_entry *msg = (owl_log_entry*)data; 142 if (defer_logs) { 143 owl_log_deferred_enqueue_message(msg->message, msg->filename); 144 } else { 145 ret = owl_log_try_write_entry(msg); 146 if (ret == EPERM || ret == EACCES || ret == ETIMEDOUT) { 147 defer_logs = true; 148 owl_log_error("Unable to open file for logging (%s): \n" 149 "%s. \n" 150 "Consider renewing your tickets. Logging has been \n" 151 "suspended, and your messages will be saved. To \n" 152 "resume logging, use the command :flush-logs.\n\n", 153 msg->filename, 154 g_strerror(ret)); 155 /* If we were not in deferred logging mode, either the queue should be 156 * empty, or we are attempting to log a message that we just popped off 157 * the head of the queue. Either way, we should enqueue this message as 158 * the first message in the queue, rather than the last, so that we 159 * preserve message ordering. */ 160 owl_log_deferred_enqueue_first_message(msg->message, msg->filename); 161 } else if (ret != 0) { 162 owl_log_file_error(msg, ret); 163 } 164 } 165 } 166 167 /* tries to write the deferred log entries 168 * 169 * N.B. This function is called only on the disk-writing thread. */ 170 static void owl_log_write_deferred_entries(gpointer data) 171 { 172 owl_log_entry *entry; 173 owl_log_options *opts = (owl_log_options *)data; 174 int ret; 175 int logged_message_count = 0; 176 bool all_succeeded = true; 177 178 if (opts->display_initial_log_count) { 179 if (g_queue_is_empty(deferred_entry_queue)) { 180 owl_log_makemsg("There are no logs to flush."); 181 } else { 182 owl_log_makemsg("Attempting to flush %u logs...", 183 g_queue_get_length(deferred_entry_queue)); 184 } 185 } 186 187 defer_logs = false; 188 while (!g_queue_is_empty(deferred_entry_queue) && !defer_logs) { 189 logged_message_count++; 190 entry = (owl_log_entry*)g_queue_pop_head(deferred_entry_queue); 191 if (!opts->drop_failed_logs) { 192 /* Attempt to write the log entry. If it fails, re-queue the entry at 193 * the head of the queue. */ 194 owl_log_eventually_write_entry(entry); 195 } else { 196 /* Attempt to write the log entry. If it fails, print an error message, 197 * drop the log, and keep going through the queue. */ 198 ret = owl_log_try_write_entry(entry); 199 if (ret != 0) { 200 all_succeeded = false; 201 owl_log_file_error(entry, ret); 202 } 203 } 204 owl_log_entry_delete(entry); 205 } 206 if (logged_message_count > 0) { 207 if (opts->display_initial_log_count) { 208 /* first clear the "attempting to flush" message from the status bar */ 209 owl_log_makemsg(""); 210 } 211 if (!defer_logs) { 212 if (all_succeeded) { 213 owl_log_adminmsg("Flushed %d logs and resumed logging.", 214 logged_message_count); 215 } else { 216 owl_log_adminmsg("Flushed or dropped %d logs and resumed logging.", 217 logged_message_count); 218 } 219 } else { 220 owl_log_error("Attempted to flush %d logs; %u deferred logs remain.", 221 logged_message_count, g_queue_get_length(deferred_entry_queue)); 222 } 223 } 224 } 225 226 void owl_log_flush_logs(bool drop_failed_logs, bool quiet) 227 { 228 owl_log_options *data = g_new(owl_log_options, 1); 229 data->drop_failed_logs = drop_failed_logs; 230 data->display_initial_log_count = !quiet; 231 232 owl_select_post_task(owl_log_write_deferred_entries, 233 data, 234 g_free, 235 log_context); 181 236 } 182 237 183 238 void owl_log_enqueue_message(const char *buffer, const char *filename) 184 239 { 185 owl_log_entry *log_msg = NULL; 186 log_msg = g_slice_new(owl_log_entry); 187 log_msg->message = g_strdup(buffer); 188 log_msg->filename = g_strdup(filename); 189 owl_select_post_task(owl_log_write_entry, log_msg, 190 owl_log_entry_free, log_context); 191 } 192 193 void owl_log_append(const owl_message *m, const char *filename) { 194 char *buffer = NULL; 195 if (owl_message_is_type_zephyr(m)) { 196 buffer = owl_log_zephyr(m); 197 } else if (owl_message_is_type_jabber(m)) { 198 buffer = owl_log_jabber(m); 199 } else if (owl_message_is_type_aim(m)) { 200 buffer = owl_log_aim(m); 201 } else { 202 buffer = owl_log_generic(m); 203 } 204 owl_log_enqueue_message(buffer, filename); 205 g_free(buffer); 206 } 207 208 void owl_log_outgoing(const owl_message *m) 209 { 210 char *filename, *logpath; 211 char *to, *temp; 212 GList *cc; 213 214 /* expand ~ in path names */ 215 logpath = owl_util_makepath(owl_global_get_logpath(&g)); 216 217 /* Figure out what path to log to */ 218 if (owl_message_is_type_zephyr(m)) { 219 /* If this has CC's, do all but the "recipient" which we'll do below */ 220 cc = owl_message_get_cc_without_recipient(m); 221 while (cc != NULL) { 222 temp = short_zuser(cc->data); 223 filename = g_build_filename(logpath, temp, NULL); 224 owl_log_append(m, filename); 225 226 g_free(filename); 227 g_free(temp); 228 g_free(cc->data); 229 cc = g_list_delete_link(cc, cc); 230 } 231 232 to = short_zuser(owl_message_get_recipient(m)); 233 } else if (owl_message_is_type_jabber(m)) { 234 to = g_strdup_printf("jabber:%s", owl_message_get_recipient(m)); 235 g_strdelimit(to, "/", '_'); 236 } else if (owl_message_is_type_aim(m)) { 237 char *temp2; 238 temp = owl_aim_normalize_screenname(owl_message_get_recipient(m)); 239 temp2 = g_utf8_strdown(temp,-1); 240 to = g_strdup_printf("aim:%s", temp2); 241 g_free(temp2); 242 g_free(temp); 243 } else { 244 to = g_strdup("loopback"); 245 } 246 247 filename = g_build_filename(logpath, to, NULL); 248 owl_log_append(m, filename); 249 g_free(to); 250 g_free(filename); 251 252 filename = g_build_filename(logpath, "all", NULL); 253 owl_log_append(m, filename); 254 g_free(logpath); 255 g_free(filename); 256 } 257 240 owl_log_entry *log_msg = owl_log_new_entry(buffer, filename); 241 owl_select_post_task(owl_log_eventually_write_entry, log_msg, 242 owl_log_entry_delete, log_context); 243 } 258 244 259 245 void owl_log_outgoing_zephyr_error(const owl_zwrite *zw, const char *text) 260 246 { 261 char *filename, *logpath; 262 char *tobuff, *recip; 263 owl_message *m; 264 GString *msgbuf; 265 /* create a present message so we can pass it to 266 * owl_log_shouldlog_message(void) 267 */ 268 m = g_slice_new(owl_message); 247 owl_message *m = g_slice_new(owl_message); 269 248 /* recip_index = 0 because there can only be one recipient anyway */ 270 249 owl_message_create_from_zwrite(m, zw, text, 0); 271 if (!owl_log_shouldlog_message(m)) { 272 owl_message_delete(m); 273 return; 274 } 250 g_free(owl_perlconfig_call_with_message("BarnOwl::Logging::log_outgoing_error", m)); 275 251 owl_message_delete(m); 276 277 /* chop off a local realm */278 recip = owl_zwrite_get_recip_n_with_realm(zw, 0);279 tobuff = short_zuser(recip);280 g_free(recip);281 282 /* expand ~ in path names */283 logpath = owl_util_makepath(owl_global_get_logpath(&g));284 filename = g_build_filename(logpath, tobuff, NULL);285 msgbuf = g_string_new("");286 g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text);287 if (text[strlen(text)-1] != '\n') {288 g_string_append_printf(msgbuf, "\n");289 }290 owl_log_enqueue_message(msgbuf->str, filename);291 g_string_free(msgbuf, TRUE);292 293 filename = g_build_filename(logpath, "all", NULL);294 g_free(logpath);295 msgbuf = g_string_new("");296 g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text);297 if (text[strlen(text)-1] != '\n') {298 g_string_append_printf(msgbuf, "\n");299 }300 owl_log_enqueue_message(msgbuf->str, filename);301 g_string_free(msgbuf, TRUE);302 303 g_free(tobuff);304 }305 306 void owl_log_incoming(const owl_message *m)307 {308 char *filename, *allfilename, *logpath;309 const char *from=NULL;310 char *frombuff=NULL;311 int len, ch, i, personal;312 313 /* figure out if it's a "personal" message or not */314 if (owl_message_is_type_zephyr(m)) {315 if (owl_message_is_personal(m)) {316 personal = 1;317 } else {318 personal = 0;319 }320 } else if (owl_message_is_type_jabber(m)) {321 /* This needs to be fixed to handle groupchat */322 const char* msgtype = owl_message_get_attribute_value(m,"jtype");323 if (msgtype && !strcmp(msgtype,"groupchat")) {324 personal = 0;325 } else {326 personal = 1;327 }328 } else {329 if (owl_message_is_private(m) || owl_message_is_loginout(m)) {330 personal = 1;331 } else {332 personal = 0;333 }334 }335 336 337 if (owl_message_is_type_zephyr(m)) {338 if (personal) {339 from=frombuff=short_zuser(owl_message_get_sender(m));340 } else {341 from=frombuff=g_strdup(owl_message_get_class(m));342 }343 } else if (owl_message_is_type_aim(m)) {344 /* we do not yet handle chat rooms */345 char *normalto, *temp;346 temp = owl_aim_normalize_screenname(owl_message_get_sender(m));347 normalto = g_utf8_strdown(temp, -1);348 from=frombuff=g_strdup_printf("aim:%s", normalto);349 g_free(normalto);350 g_free(temp);351 } else if (owl_message_is_type_loopback(m)) {352 from=frombuff=g_strdup("loopback");353 } else if (owl_message_is_type_jabber(m)) {354 if (personal) {355 from=frombuff=g_strdup_printf("jabber:%s",356 owl_message_get_sender(m));357 } else {358 from=frombuff=g_strdup_printf("jabber:%s",359 owl_message_get_recipient(m));360 }361 } else {362 from=frombuff=g_strdup("unknown");363 }364 365 /* check for malicious sender formats */366 len=strlen(frombuff);367 if (len<1 || len>35) from="weird";368 if (strchr(frombuff, '/')) from="weird";369 370 ch=frombuff[0];371 if (!g_ascii_isalnum(ch)) from="weird";372 373 for (i=0; i<len; i++) {374 if (frombuff[i]<'!' || frombuff[i]>='~') from="weird";375 }376 377 if (!strcmp(frombuff, ".") || !strcasecmp(frombuff, "..")) from="weird";378 379 if (!personal) {380 if (strcmp(from, "weird")) {381 char* temp = g_utf8_strdown(frombuff, -1);382 if (temp) {383 g_free(frombuff);384 from = frombuff = temp;385 }386 }387 }388 389 /* create the filename (expanding ~ in path names) */390 if (personal) {391 logpath = owl_util_makepath(owl_global_get_logpath(&g));392 filename = g_build_filename(logpath, from, NULL);393 allfilename = g_build_filename(logpath, "all", NULL);394 owl_log_append(m, allfilename);395 g_free(allfilename);396 } else {397 logpath = owl_util_makepath(owl_global_get_classlogpath(&g));398 filename = g_build_filename(logpath, from, NULL);399 }400 401 owl_log_append(m, filename);402 g_free(filename);403 404 if (personal && owl_message_is_type_zephyr(m)) {405 /* We want to log to all of the CC'd people who were not us, or406 * the sender, as well.407 */408 char *temp;409 GList *cc;410 cc = owl_message_get_cc_without_recipient(m);411 while (cc != NULL) {412 temp = short_zuser(cc->data);413 if (strcasecmp(temp, frombuff) != 0) {414 filename = g_build_filename(logpath, temp, NULL);415 owl_log_append(m, filename);416 g_free(filename);417 }418 419 g_free(temp);420 g_free(cc->data);421 cc = g_list_delete_link(cc, cc);422 }423 }424 425 g_free(frombuff);426 g_free(logpath);427 252 } 428 253 429 254 static gpointer owl_log_thread_func(gpointer data) 430 255 { 256 log_context = g_main_context_new(); 431 257 log_loop = g_main_loop_new(log_context, FALSE); 432 258 g_main_loop_run(log_loop); … … 434 260 } 435 261 436 void owl_log_init(void) 262 void owl_log_init(void) 437 263 { 438 264 log_context = g_main_context_new(); … … 454 280 } 455 281 #endif 456 282 283 deferred_entry_queue = g_queue_new(); 457 284 } 458 285 459 286 static void owl_log_quit_func(gpointer data) 460 287 { 288 /* flush the deferred logs queue, trying to write the 289 * entries to the disk one last time. Drop any failed 290 * entries, and be quiet about it. */ 291 owl_log_options opts; 292 opts.drop_failed_logs = true; 293 opts.display_initial_log_count = false; 294 owl_log_write_deferred_entries(&opts); 295 #if GLIB_CHECK_VERSION(2, 32, 0) 296 g_queue_free_full(deferred_entry_queue, owl_log_entry_delete); 297 #else 298 g_queue_foreach(deferred_entry_queue, owl_log_entry_delete_gfunc, NULL); 299 g_queue_free(deferred_entry_queue); 300 #endif 301 461 302 g_main_loop_quit(log_loop); 462 303 } -
owl.c
r441fd42 r4ead7b3 230 230 /* let perl know about it */ 231 231 owl_perlconfig_newmsg(m, NULL); 232 /* log the message if we need to */233 owl_log_message(m);234 232 /* redraw the sepbar; TODO: don't violate layering */ 235 233 owl_global_sepbar_dirty(&g); -
perl/Makefile.am
ra870319 reea7bed4 9 9 lib/BarnOwl/Completion/Context.pm \ 10 10 lib/BarnOwl/Completion/Util.pm \ 11 lib/BarnOwl/DeferredLogging.pm \ 11 12 lib/BarnOwl/Editwin.pm \ 12 13 lib/BarnOwl/Help.pm \ 13 14 lib/BarnOwl/Hook.pm \ 14 15 lib/BarnOwl/Hooks.pm \ 16 lib/BarnOwl/Logging.pm \ 15 17 lib/BarnOwl/MainLoopCompatHook.pm \ 16 18 lib/BarnOwl/Message.pm \ -
perl/lib/BarnOwl.pm
recd4edf reea7bed4 16 16 create_style getnumcolors wordwrap 17 17 message_matches_filter 18 get_variable_info 18 19 add_dispatch remove_dispatch 19 20 add_io_dispatch remove_io_dispatch … … 38 39 use BarnOwl::Hook; 39 40 use BarnOwl::Hooks; 41 use BarnOwl::Logging; 40 42 use BarnOwl::Message; 41 43 use BarnOwl::Style; … … 45 47 use BarnOwl::Completion; 46 48 use BarnOwl::Help; 49 use BarnOwl::DeferredLogging; 47 50 48 51 use List::Util qw(max); … … 249 252 C<QUIET> is false, this method displays an error message if 250 253 if C<FILTER_NAME> does not name a valid filter. 254 255 =head2 get_variable_info VARIABLE_NAME 256 257 Returns a hash with the following keys, describing the variable named: 258 259 =over 260 261 =item name 262 263 =item description 264 265 =item summary 266 267 =item validsettings 268 269 =item takes_on_off 270 271 =back 272 273 Fails if C<VARIABLE_NAME> does not name a valid variable. 251 274 252 275 =head2 add_dispatch FD CALLBACK -
perl/lib/BarnOwl/Complete/Client.pm
r4626016 r1f92f39 146 146 sub complete_set { 147 147 my $ctx = shift; 148 return complete_flags($ctx, 149 [qw(-q)], 150 { 151 }, 152 \&complete_set_args 153 ); 154 } 155 sub complete_set_args { 156 my $ctx = shift; 157 my $arg = shift; 158 return if $arg; 159 return complete_variable(); 148 my $is_unset = ($ctx->words->[0] eq "unset"); 149 150 # Shift away the -q if seen. 151 my $seen_q = 0; 152 if ($ctx->word > 1 && $ctx->words->[1] eq "-q") { 153 $seen_q = 1; 154 $ctx = $ctx->shift_words(1); 155 } 156 157 # First argument is the variable. 158 if ($ctx->word == 1) { 159 my @vars = complete_variable(); 160 if ($is_unset) { 161 # Only complete the variables which are unsettable. 162 @vars = grep { BarnOwl::get_variable_info($_)->{takes_on_off} } @vars; 163 } 164 unshift(@vars, "-q") unless $seen_q; 165 return @vars; 166 } 167 # For set, second argument is the value. 168 if (!$is_unset && $ctx->word == 2) { 169 # Parse what we can out of validsettings. 170 my $info; 171 eval { $info = BarnOwl::get_variable_info($ctx->words->[1]) }; 172 return if $@; 173 if ($info->{validsettings} eq "<path>") { 174 return complete_file($ctx->words->[2]); 175 } elsif ($info->{validsettings} !~ /^<.*>$/) { 176 # Assume it's a comma-separated list of values; 177 return split(",", $info->{validsettings}); 178 } 179 } 180 return; 160 181 } 161 182 -
perl/lib/BarnOwl/Message.pm
r0adbce1 r5dee79a 3 3 4 4 package BarnOwl::Message; 5 6 use File::Spec; 5 7 6 8 use BarnOwl::Message::Admin; … … 115 117 } 116 118 return $s; 119 } 120 121 =head2 log MESSAGE 122 123 Returns the text that should be written to a file to log C<MESSAGE>. 124 125 =cut 126 127 sub log { 128 my ($m) = @_; 129 return $m->log_header . "\n\n" . $m->log_body . "\n\n"; 130 } 131 132 =head2 log_header MESSAGE 133 134 Returns the header of the message, for logging purposes. 135 If you override L<BarnOwl::Message::log>, this method is not called. 136 137 =cut 138 139 sub log_header { 140 my ($m) = @_; 141 my $sender = $m->sender; 142 my $recipient = $m->recipient; 143 my $timestr = $m->time; 144 return "From: <$sender> To: <$recipient>\n" 145 . "Time: $timestr"; 146 } 147 148 =head2 log_body MESSAGE 149 150 Returns the body of the message, for logging purposes. 151 If you override L<BarnOwl::Message::log>, this method is not called. 152 153 =cut 154 155 sub log_body { 156 my ($m) = @_; 157 if ($m->is_loginout) { 158 return uc($m->login) 159 . $m->login_type 160 . ($m->login_extra ? ' at ' . $m->login_extra : ''); 161 } else { 162 return $m->body; 163 } 164 } 165 166 =head2 log_filenames MESSAGE 167 168 Returns a list of filenames to which this message should be logged. 169 The filenames should be relative to the path returned by C<log_path>. 170 See L<BarnOwl::Logging::get_filenames> for the specification of valid 171 filenames, and for what happens if this method returns an invalid 172 filename. 173 174 =cut 175 176 sub log_filenames { 177 my ($m) = @_; 178 my $filename; 179 if ($m->is_incoming) { 180 $filename = $m->pretty_sender; 181 } elsif ($m->is_outgoing) { 182 $filename = $m->pretty_recipient; 183 } 184 $filename = "unknown" if !defined($filename) || $filename eq ''; 185 if (BarnOwl::getvar('log-to-subdirectories') eq 'on') { 186 return ($filename); 187 } else { 188 return ($m->log_subfolder . ':' . $filename); 189 } 190 } 191 192 =head2 log_to_all_file MESSAGE 193 194 There is an C<all> file. This method determines if C<MESSAGE> 195 should get logged to it, in addition to any files returned by 196 C<log_filenames>. 197 198 It defaults to returning true if and only if C<MESSAGE> is outgoing. 199 200 =cut 201 202 sub log_to_all_file { 203 my ($m) = @_; 204 return $m->is_outgoing; 205 } 206 207 =head2 log_path MESSAGE 208 209 Returns the folder in which all messages of this class get logged. 210 211 Defaults to C<log_base_path/log_subfolder> if C<log-to-subdirectories> 212 is enabled, or to the C<logpath> BarnOwl variable if it is not. 213 214 Most protocols should override C<log_subfolder> rather than 215 C<log_path>, in order to properly take into account the value of 216 C<log-to-subdirectories>. 217 218 =cut 219 220 sub log_path { 221 my ($m) = @_; 222 if (BarnOwl::getvar('log-to-subdirectories') eq 'on') { 223 return File::Spec->catfile($m->log_base_path, $m->log_subfolder); 224 } else { 225 return BarnOwl::getvar('logpath'); 226 } 227 } 228 229 =head2 log_base_path MESSAGE 230 231 Returns the base path for logging. See C<log_path> for more information. 232 233 Defaults to the BarnOwl variable C<logbasepath>. 234 235 =cut 236 237 sub log_base_path { 238 return BarnOwl::getvar('logbasepath'); 239 } 240 241 =head2 log_subfolder MESSAGE 242 243 Returns the subfolder of C<log_base_path> to log messages in. 244 245 Defaults to C<lc($m->type)>. 246 247 =cut 248 249 sub log_subfolder { 250 return lc(shift->type); 251 } 252 253 =head2 log_outgoing_error MESSAGE 254 255 Returns the string that should be logged if there is an error sending 256 an outgoing message. 257 258 =cut 259 260 sub log_outgoing_error { 261 my ($m) = @_; 262 my $recipient = $m->pretty_recipient; 263 my $body = $m->body; 264 chomp $body; 265 return "ERROR (BarnOwl): $recipient\n$body\n\n"; 266 } 267 268 =head2 should_log MESSAGE 269 270 Returns true if we should log C<MESSAGE>. This does not override 271 user settings; if the BarnOwl variable C<loggingdirection> is in, 272 and C<MESSAGE> is outgoing and does not match the C<logfilter>, it 273 will not get logged regardless of what this method returns. 274 275 Note that this method I<does> override the BarnOwl C<logging> 276 variable; if a derived class overrides this method and does not 277 provide an alternative BarnOwl variable (such as C<classlogging>), 278 the overriding method should check the BarnOwl C<logging> variable. 279 280 Defaults to returning the value of the BarnOwl variable C<logging>. 281 282 =cut 283 284 sub should_log { 285 return BarnOwl::getvar('logging') eq 'on'; 117 286 } 118 287 -
perl/lib/BarnOwl/Message/AIM.pm
r7011c3dc reea7bed4 24 24 } 25 25 26 sub normalize_screenname { 27 my ($screenname) = @_; 28 $screenname =~ s/\s+//g; 29 return lc($screenname); 30 } 31 32 sub log_filenames { 33 return map { normalize_screenname($_) } BarnOwl::Message::log_filenames(@_); 34 } 26 35 27 36 1; -
perl/lib/BarnOwl/Message/Loopback.pm
ree183be r8cec8f7 14 14 sub replysendercmd {return 'loopwrite';} 15 15 16 sub log_subfolder { return ''; } 17 sub log_filenames { return ('loopback'); } 16 18 17 19 1; -
perl/lib/BarnOwl/Message/Zephyr.pm
r0adbce1 r8f91a70 21 21 my ($user, $realm) = split(/@/,$principal); 22 22 return $realm; 23 } 24 25 sub casefold_principal { 26 my $principal = shift; 27 # split the principal right after the final @, without eating any 28 # characters; this way, we always get at least '@' in $user 29 my ($user, $realm) = split(/(?<=@)(?=[^@]+$)/, $principal); 30 $user = '' if !defined $user; 31 $user = lc($user); 32 $user = $user . uc($realm) if defined $realm; 33 return $user; 23 34 } 24 35 … … 132 143 return $1 if $self->body =~ /^\s*cc:\s+([^\n]+)/i; 133 144 return undef; 145 } 146 147 # Note: This is the cc-line without the recipient; it does not include 148 # the sender. 149 sub zephyr_cc_without_recipient { 150 my $self = shift; 151 my $recipient = lc(strip_realm($self->recipient)); 152 my $cc = $self->zephyr_cc; 153 return grep { lc(strip_realm($_)) ne $recipient } split(/\s+/, $cc) if defined $cc; 154 return (); 134 155 } 135 156 … … 223 244 } 224 245 246 # Logging 247 sub log_header { 248 my ($m) = @_; 249 my $class = $m->class; 250 my $instance = $m->instance; 251 my $opcode = $m->opcode; 252 my $timestr = $m->time; 253 my $host = $m->host; 254 my $sender = $m->pretty_sender; 255 my $zsig = $m->zsig; 256 my $rtn = "Class: $class Instance: $instance"; 257 $rtn .= " Opcode: $opcode" unless !defined $opcode || $opcode eq ''; 258 $rtn .= "\nTime: $timestr Host: $host" 259 . "\nFrom: $zsig <$sender>"; 260 return $rtn; 261 } 262 263 sub log_filenames { 264 my ($m) = @_; 265 my @filenames = (); 266 if ($m->is_personal) { 267 # If this has CC's, add all but the "recipient" which we'll add below 268 @filenames = $m->zephyr_cc_without_recipient; 269 } 270 if ($m->is_incoming) { 271 if ($m->is_personal) { 272 push @filenames, $m->sender; 273 } else { 274 my $realm = ''; 275 $realm .= '@' . $m->realm if $m->realm ne BarnOwl::zephyr_getrealm(); 276 return (BarnOwl::compat_casefold($m->class) . uc($realm)); 277 } 278 } else { 279 push @filenames, $m->recipient; 280 } 281 return map { casefold_principal(BarnOwl::zephyr_smartstrip_user(strip_realm($_))) } @filenames; 282 } 283 284 sub log_to_class_file { 285 my ($m) = @_; 286 return !$m->is_personal; 287 } 288 289 sub log_path { 290 my ($m) = @_; 291 if ($m->log_to_class_file) { 292 return BarnOwl::getvar('classlogpath'); 293 } else { 294 return BarnOwl::getvar('logpath'); 295 } 296 } 297 298 sub should_log { 299 my ($m) = @_; 300 if ($m->log_to_class_file) { 301 return BarnOwl::getvar('classlogging') eq 'on'; 302 } else { 303 return BarnOwl::getvar('logging') eq 'on'; 304 } 305 } 225 306 226 307 1; -
perl/modules/IRC/lib/BarnOwl/Message/IRC.pm
r60b49a7 r3f0c209 92 92 } 93 93 94 # logging 95 sub log_filenames { 96 my ($m) = @_; 97 die "IRC should not be handling non-IRC messages" if lc($m->type) ne "irc"; 98 BarnOwl::error("IRC message without a network") if !defined($m->network) || $m->network eq ''; 99 my $filename = lc($m->network); 100 # Note: Channel names generally start with '#', which 101 # disambiguates channels from individuals; for example, personals 102 # will look like, e.g., "~/zlog/irc/freenode:john-doe", whereas 103 # channels will look like, e.g., "~/zlog/irc/freenode:#barnowl" 104 if ($m->is_personal) { 105 if ($m->is_incoming) { 106 $filename .= ":" . $m->sender; 107 } elsif ($m->is_outgoing) { 108 $filename .= ":" . $m->recipient; 109 } 110 } else { 111 $filename .= ":" . $m->channel; 112 } 113 return ($filename); 114 } 115 116 sub log { 117 my ($m) = @_; 118 my $sender = $m->sender; 119 my $timestr = $m->time; 120 my $body = $m->body; 121 if ($m->is_loginout) { 122 return BarnOwl::Message::log($m); 123 } else { 124 return "[$timestr] <$sender> $body\n"; 125 } 126 } 127 94 128 1; -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
r926c721 rd4f33f1 562 562 "[" . $conn->alias . "] Reconnect cancelled"); 563 563 $conn->cancel_reconnect; 564 delete $ircnets{$conn->alias}; 565 } elsif (exists $ircnets{$conn->alias}) { # inconsistent state; no socket, but not yet deleted 566 BarnOwl::admin_message('IRC', 567 "[" . $conn->alias . "] Attempt to disconnect from a socketless connection; deleting it"); 564 568 delete $ircnets{$conn->alias}; 565 569 } -
perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
rbe43554 r4379288 437 437 } 438 438 439 sub rejoin_channels { 440 my $self = shift; 441 my @channels = @_; 442 # As reported in https://barnowl.mit.edu/ticket/274, if we reconnect to 443 # too many at once, the server rejects us. Empirically, this is about 444 # 20-26, so we set the cap at 15, then delay further joins for 5 seconds. 445 my $MAX_RECONNECT_CHANNELS = 15; 446 my $DELAY = 5; 447 foreach my $c (@channels[ 0 .. $MAX_RECONNECT_CHANNELS ]) { 448 $self->conn->send_msg(join => $c); 449 } 450 if ($MAX_RECONNECT_CHANNELS < $#channels) { 451 my $remaining = $#channels - $MAX_RECONNECT_CHANNELS; 452 my $cur_alias = $self->alias; 453 BarnOwl::admin_message('IRC', "[$cur_alias] Delaying $remaining autorejoins for $DELAY seconds"); 454 # if we don't assign the timer to anything, then it gets garbage 455 # collected, and never runs 456 $self->{autoconnect_channels_delay_timer} = BarnOwl::Timer->new({ 457 name => "IRC rejoin overflow timer ($remaining remaining)", 458 after => $DELAY, 459 cb => sub { 460 rejoin_channels($self, @channels[ $MAX_RECONNECT_CHANNELS .. $#channels ]); 461 } 462 }); 463 } 464 } 465 466 439 467 sub connected { 440 468 my $self = shift; … … 443 471 $self->cancel_reconnect; 444 472 if ($self->autoconnect_channels) { 445 for my $c (@{$self->autoconnect_channels}) { 446 $self->conn->send_msg(join => $c); 447 } 473 rejoin_channels($self, @{$self->autoconnect_channels}); 448 474 } 449 475 $self->conn->enable_ping(60, sub { -
perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
ra27acf7 rd2ba33c 172 172 } 173 173 174 sub log_filenames { 175 return map { BarnOwl::compat_casefold($_) } BarnOwl::Message::log_filenames(@_); 176 } 177 174 178 =head1 SEE ALSO 175 179 -
perl/modules/Makefile.am
re4b8f93 r268c7e8 1 MODULES = Jabber IRC WordWrap Twitter Facebook 1 MODULES = Jabber IRC WordWrap Twitter Facebook Kerberos 2 2 3 3 EXTRA_DIST = $(MODULES:=/Makefile.PL) $(MODULES:=/lib) -
perl/modules/Twitter/lib/BarnOwl/Module/Twitter.pm
rb8a3e00 r140429f 137 137 my $twitter_args = { username => $cfg->{user}, 138 138 password => $cfg->{password}, 139 source => 'barnowl', 139 source => 'barnowl', 140 ssl => 1, 141 legacy_lists_api => 0, 140 142 }; 141 143 if (defined $cfg->{service}) { … … 274 276 ); 275 277 278 BarnOwl::new_command( 'twitter-favorite' => sub { cmd_twitter_favorite(@_) }, 279 { 280 summary => 'Favorite the current Twitter message', 281 usage => 'twitter-favorite [ACCOUNT]', 282 description => <<END_DESCRIPTION 283 Favorite the current Twitter message using ACCOUNT (defaults to the 284 account that received the tweet). 285 END_DESCRIPTION 286 } 287 ); 288 276 289 BarnOwl::new_command( 'twitter-follow' => sub { cmd_twitter_follow(@_); }, 277 290 { … … 355 368 $account = $m->account unless defined($account); 356 369 find_account($account)->twitter_retweet($m); 370 return; 371 } 372 373 sub cmd_twitter_favorite { 374 my $cmd = shift; 375 my $account = shift; 376 my $m = BarnOwl::getcurmsg(); 377 if(!$m || $m->type ne 'Twitter') { 378 die("$cmd must be used with a Twitter message selected.\n"); 379 } 380 381 $account = $m->account unless defined($account); 382 find_account($account)->twitter_favorite($m); 357 383 return; 358 384 } -
perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm
r4ebbfbc r140429f 371 371 $self->twitter_direct($1, $2); 372 372 } elsif(defined $self->{twitter}) { 373 if(length($msg) > 140) {374 die("Twitter: Message over 140 characters long.\n");375 }376 373 $self->twitter_command('update', { 377 374 status => $msg, … … 432 429 } 433 430 431 sub twitter_favorite { 432 my $self = shift; 433 my $msg = shift; 434 435 if($msg->service ne $self->{cfg}->{service}) { 436 die("Cannot favorite a message from a different service.\n"); 437 } 438 $self->twitter_command(create_favorite => $msg->{status_id}); 439 } 440 441 434 442 sub twitter_follow { 435 443 my $self = shift; -
perlglue.xs
r7dcef03 rd2ba33c 385 385 RETVAL 386 386 387 SV * 388 get_variable_info(name) 389 const char *name; 390 PREINIT: 391 owl_variable *var; 392 HV *h; 393 CODE: 394 var = owl_variable_get_var(owl_global_get_vardict(&g), name); 395 if (var == NULL) { 396 croak("No such variable"); 397 } 398 h = newHV(); 399 (void)hv_store(h, "name", strlen("name"), 400 owl_new_sv(owl_variable_get_name(var)), 0); 401 (void)hv_store(h, "description", strlen("description"), 402 owl_new_sv(owl_variable_get_description(var)), 403 0); 404 (void)hv_store(h, "summary", strlen("summary"), 405 owl_new_sv(owl_variable_get_summary(var)), 0); 406 (void)hv_store(h, "validsettings", strlen("validsettings"), 407 owl_new_sv(owl_variable_get_validsettings(var)), 408 0); 409 (void)hv_store(h, "takes_on_off", strlen("takes_on_off"), 410 newSViv(owl_variable_takes_on_off(var)), 0); 411 RETVAL = newRV_noinc((SV*)h); 412 OUTPUT: 413 RETVAL 414 415 const utf8 * 416 compat_casefold(in) 417 const char * in 418 PREINIT: 419 char *rv; 420 CODE: 421 rv = owl_util_compat_casefold(in); 422 RETVAL = rv; 423 OUTPUT: 424 RETVAL 425 CLEANUP: 426 g_free(rv); 427 387 428 388 429 MODULE = BarnOwl PACKAGE = BarnOwl::Zephyr … … 407 448 OUTPUT: 408 449 RETVAL 450 451 const utf8 * 452 makepath(in) 453 const char * in 454 PREINIT: 455 char *rv; 456 CODE: 457 rv = owl_util_makepath(in); 458 RETVAL = rv; 459 OUTPUT: 460 RETVAL 461 CLEANUP: 462 g_free(rv); 409 463 410 464 void … … 642 696 OUTPUT: 643 697 RETVAL 698 699 MODULE = BarnOwl PACKAGE = BarnOwl::Logging 700 701 void 702 enqueue_text(log_text, filename) 703 const char * log_text 704 const char * filename 705 CODE: 706 owl_log_enqueue_message(log_text, filename); -
scripts/do-release
rb8a3e00 rbc308eb 1 #!/bin/sh -e 1 #!/bin/bash 2 set -eu 2 3 3 4 die() { … … 55 56 fi 56 57 58 [ -e Makefile.in ] || autoreconf -fvi 59 [ -e config.status ] || ./configure 60 make -j4 distcheck VERSION="$VERS" 61 62 echo 'Checking distributed files against Git:' 63 if comm -3 <(tar -tzf "$TAG.tar.gz" | grep -v '/$' | sed "s%^$TAG/%%" | sort) \ 64 <(git ls-files | sort) | grep -vxf scripts/dist-ignore; then 65 echo 66 echo 'Error: Please fix Makefile.am and/or scripts/dist-ignore.' 67 exit 1 68 fi 69 echo 'ok' 70 71 mv "$TAG.tar.gz" "$TGZ.tgz" 72 57 73 if ! [ "$no_tag" ]; then 58 74 if git cat-file -t "$TAG" > /dev/null 2>&1; then … … 65 81 fi 66 82 67 exittrap() { :; } 68 for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done 69 trap 'exittrap' EXIT 70 71 TMPDIR=$(mktemp -d /tmp/barnowl.XXXXXX) 72 73 exittrap() { rm -rf "$TMPDIR"; } 74 75 git archive --format=tar --prefix="$TGZ/" "$TAG" | tar -x -C "$TMPDIR" 76 77 CODIR=$(pwd) 78 cd "$TMPDIR/$TGZ" 79 [ "$git" ] && perl -i -pe 's{^(AC_INIT\(\[[^\]]+\],\s*)\[([^\]]+)\]}{${1}['$VERS']}' configure.ac 80 autoreconf -fvi 81 rm -r autom4te.cache/ 82 cd "$TMPDIR" 83 tar czvf "$TGZ.tgz" "$TGZ" 84 cd "$CODIR" 85 86 mv "$TMPDIR/$TGZ.tgz" . 87 rm -rf "$TMPDIR" 88 89 exittrap() { :; } 90 91 echo "Created release tarball for BarnOwl $VERS in $(pwd)" 83 echo "Created release tarball for BarnOwl $VERS at $(pwd)/$TGZ.tgz" 92 84 echo "Remember to bump OWL_VERSION_STRING for future development." 93 85 -
t/completion.t
re59d775 ra7250ee 6 6 7 7 use File::Basename; 8 BEGIN {require (dirname($0) . "/mock.pl");}; 8 use File::Spec; 9 BEGIN {require File::Spec->rel2abs("mock.pl", dirname($0));}; 9 10 10 11 use BarnOwl::Complete::Filter qw(complete_filter_expr); -
variable.c
r7dcef03 r03fbf66 136 136 "load logins from .anyone on startup", "" ); 137 137 138 OWLVAR_BOOL( "logging" /* %OwlVarStub */, 0,139 "turn personal logging on or off",140 "If this is set to on, personal messages are\n"141 "logged in the directory specified\n"142 "by the 'logpath' variable. The filename in that\n"143 "directory is derived from the sender of the message.\n" );144 145 OWLVAR_BOOL( "classlogging" /* %OwlVarStub */, 0,146 "turn class logging on or off",147 "If this is set to on, class messages are\n"148 "logged in the directory specified\n"149 "by the 'classlogpath' variable.\n"150 "The filename in that directory is derived from\n"151 "the name of the class to which the message was sent.\n" );152 153 OWLVAR_ENUM( "loggingdirection" /* %OwlVarStub */, OWL_LOGGING_DIRECTION_BOTH,154 "specifies which kind of messages should be logged",155 "Can be one of 'both', 'in', or 'out'. If 'in' is\n"156 "selected, only incoming messages are logged, if 'out'\n"157 "is selected only outgoing messages are logged. If 'both'\n"158 "is selected both incoming and outgoing messages are\n"159 "logged.",160 "both,in,out");161 162 138 OWLVAR_BOOL_FULL( "colorztext" /* %OwlVarStub */, 1, 163 139 "allow @color() in zephyrs to change color", 164 NULL, NULL, owl_variable_colorztext_set, NULL);140 "", NULL, owl_variable_colorztext_set, NULL); 165 141 166 142 OWLVAR_BOOL( "fancylines" /* %OwlVarStub */, 1, … … 185 161 "Enable printing of login notifications", 186 162 "When this is enabled, BarnOwl will print login and logout notifications\n" 187 "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n"188 "login or logout notifications.\n");189 190 OWLVAR_STRING( "logfilter" /* %OwlVarStub */, "",191 "name of a filter controlling which messages to log",192 193 "If non empty, any messages matching the given filter will be logged.\n"194 "This is a completely separate mechanism from the other logging\n"195 "variables like logging, classlogging, loglogins, loggingdirection,\n"196 "etc. If you want this variable to control all logging, make sure\n"197 "all other logging variables are in their default state.\n");198 199 OWLVAR_BOOL( "loglogins" /* %OwlVarStub */, 0,200 "Enable logging of login notifications",201 "When this is enabled, BarnOwl will log login and logout notifications\n"202 163 "for AIM, zephyr, or other protocols. If disabled BarnOwl will not print\n" 203 164 "login or logout notifications.\n"); … … 214 175 "off,middle,on", 215 176 NULL, owl_variable_disable_ctrl_d_set, NULL); 216 217 OWLVAR_PATH( "logpath" /* %OwlVarStub */, "~/zlog/people",218 "path for logging personal zephyrs",219 "Specifies a directory which must exist.\n"220 "Files will be created in the directory for each sender.\n");221 222 OWLVAR_PATH( "classlogpath" /* %OwlVarStub:classlogpath */, "~/zlog/class",223 "path for logging class zephyrs",224 "Specifies a directory which must exist.\n"225 "Files will be created in the directory for each class.\n");226 177 227 178 OWLVAR_PATH( "debug_file" /* %OwlVarStub */, OWL_DEBUG_FILE, … … 814 765 } 815 766 767 bool owl_variable_takes_on_off(const owl_variable *v) { 768 return v->takes_on_off; 769 } 770 816 771 int owl_variable_get_type(const owl_variable *v) 817 772 { … … 1038 993 CALLER_OWN char *owl_variable_bool_get_tostring_default(const owl_variable *v, void *dummy) 1039 994 { 1040 bool val = owl_variable_get_bool(v); 1041 if (val == 0) { 1042 return g_strdup("off"); 1043 } else if (val == 1) { 1044 return g_strdup("on"); 1045 } else { 1046 return g_strdup("<invalid>"); 1047 } 995 return g_strdup(owl_variable_get_bool(v) ? "on" : "off"); 1048 996 } 1049 997 -
zephyr.c
r7dcef03 rff58239 283 283 #ifdef HAVE_LIBZEPHYR 284 284 FILE *file; 285 int fopen_errno; 285 286 char *tmp, *start; 286 287 char *buffer = NULL; … … 289 290 int subSize = 1024; 290 291 int count; 291 struct stat statbuff;292 292 293 293 subsfile = owl_zephyr_dotfile(".zephyr.subs", filename); 294 294 295 if (stat(subsfile, &statbuff) != 0) { 296 g_free(subsfile); 297 if (error_on_nofile == 1) 295 count = 0; 296 file = fopen(subsfile, "r"); 297 fopen_errno = errno; 298 g_free(subsfile); 299 if (!file) { 300 if (error_on_nofile == 1 || fopen_errno != ENOENT) 298 301 return -1; 299 302 return 0; 300 303 } 301 302 ZResetAuthentication();303 count = 0;304 file = fopen(subsfile, "r");305 g_free(subsfile);306 if (!file)307 return -1;308 304 309 305 subs = g_new(ZSubscription_t, subSize); … … 348 344 g_free(buffer); 349 345 346 ZResetAuthentication(); 350 347 return owl_zephyr_loadsubs_helper(subs, count); 351 348 #else … … 412 409 char *buffer = NULL; 413 410 int count; 414 struct stat statbuff;415 411 416 412 subs = g_new(ZSubscription_t, numSubs); 417 413 subsfile = owl_zephyr_dotfile(".anyone", filename); 418 414 419 if (stat(subsfile, &statbuff) == -1) {420 g_free(subs);421 g_free(subsfile);422 return 0;423 }424 425 ZResetAuthentication();426 415 count = 0; 427 416 file = fopen(subsfile, "r"); … … 445 434 fclose(file); 446 435 } else { 436 g_free(subs); 447 437 return 0; 448 438 } 449 439 g_free(buffer); 450 440 441 ZResetAuthentication(); 451 442 return owl_zephyr_loadsubs_helper(subs, count); 452 443 #else … … 1320 1311 { 1321 1312 int n = strcspn(in, "./"); 1322 char *realm = strchrnul(in, '@'); 1313 const char *realm = strchr(in, '@'); 1314 if (realm == NULL) 1315 realm = in + strlen(in); 1323 1316 1324 1317 if (in + n >= realm || -
zwrite.c
r7dcef03 r1958790 270 270 rv = owl_zwrite_create_from_line(&z, cmd); 271 271 if (rv != 0) return rv; 272 if (!owl_zwrite_is_message_set(&z)) { 273 owl_zwrite_set_message(&z, msg); 274 } 275 owl_zwrite_populate_zsig(&z); 276 owl_zwrite_send_message(&z); 272 owl_function_zwrite(&z, msg); 277 273 owl_zwrite_cleanup(&z); 278 274 return(0);
Note: See TracChangeset
for help on using the changeset viewer.
