Changes in / [098376e:209ea94]
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rb940b91 r43a306c 1 1.0.42 * Added a ':show quickstart' command. -geofft3 * Allow filters that reference a sub filter more than once non-cyclically. -nelhage4 * Make 'version' return 'BarnOwl' not 'Owl'5 * Escape interpolated regexes in filters. -andersk6 * Various code cleanups. -andersk7 * Fix format string injection bugs. -andersk8 * Clean up various code warnings. -nelhage9 * Replace questionable sprintf(buf, "%s...", buf, ...) pattern. -andersk10 * Show IRC /me messages with the conventional * instead of bold. -andersk11 * Rip out the openurl function and webbrowser variable. -andersk12 13 1 1.0.3 14 2 * Moved BarnOwl source control to git on github. -
Makefile.in
rd4b6b23 r7e78e49 5 5 prefix = @prefix@ 6 6 exec_prefix = @exec_prefix@ 7 datarootdir = @datarootdir@8 7 datadir = @datadir@/barnowl 9 8 bindir = @bindir@ … … 54 53 $(ATHSTATIC) $(CC) -o $(EXE) owl.o $(OBJS) $(LDFLAGS) $(LIBS) 55 54 56 tester: $(AUTOGEN) $(OBJS) tester.o libfaim55 tester: $(AUTOGEN) $(OBJS) tester.o 57 56 $(ATHSTATIC) $(CC) -o tester tester.o $(OBJS) $(LDFLAGS) $(LIBS) 58 57 -
aim.c
r554a2b8 re3e6cff 239 239 { 240 240 if (message) { 241 owl_function_error( "%s",message);241 owl_function_error(message); 242 242 } else { 243 243 owl_function_error("Authentication error on login"); … … 252 252 int ret; 253 253 254 ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, 0, msg);254 ret=aim_im_sendch1(owl_global_get_aimsess(&g), to, NULL, msg); 255 255 256 256 /* I don't know how to check for an error yet */ … … 1698 1698 1699 1699 /* printf("snac threw error (reason 0x%04x: %s)\n", reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ 1700 if (reason<msgerrreasonslen) owl_function_error( "%s",msgerrreasons[reason]);1700 if (reason<msgerrreasonslen) owl_function_error(msgerrreasons[reason]); 1701 1701 1702 1702 return 1; … … 1715 1715 1716 1716 /* printf("message to %s bounced (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ 1717 if (reason<msgerrreasonslen) owl_function_error( "%s",msgerrreasons[reason]);1717 if (reason<msgerrreasonslen) owl_function_error(msgerrreasons[reason]); 1718 1718 1719 1719 if (reason==4) { … … 1736 1736 1737 1737 /* printf("user information for %s unavailable (reason 0x%04x: %s)\n", destsn, reason, (reason<msgerrreasonslen)?msgerrreasons[reason]:"unknown"); */ 1738 if (reason<msgerrreasonslen) owl_function_error( "%s",msgerrreasons[reason]);1738 if (reason<msgerrreasonslen) owl_function_error(msgerrreasons[reason]); 1739 1739 1740 1740 return 1; … … 2309 2309 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); 2310 2310 return; 2311 }2312 2313 void owl_process_aim()2314 {2315 if (owl_global_is_doaimevents(&g)) {2316 owl_aim_process_events();2317 2318 if (owl_global_is_aimloggedin(&g)) {2319 if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) {2320 /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */2321 owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g));2322 }2323 }2324 }2325 2311 } 2326 2312 -
commands.c
r9b70dd4 r451db9e 453 453 OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN, 454 454 "pops up a message in a window", "", ""), 455 456 OWLCMD_VOID("openurl", owl_command_openurl, OWL_CTX_INTERACTIVE, 457 "opens up a URL from the current message", 458 "", 459 "Uses the 'webbrowser' variable to determine\n" 460 "which browser to use. Currently, 'netscape'\n" 461 "and 'galeon' are supported.\n"), 455 462 456 463 OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE, … … 634 641 "show keymap <keymap>\n" 635 642 "show license\n" 636 "show quickstart\n"637 643 "show startup\n" 638 644 "show status\n" … … 1040 1046 void owl_command_version() 1041 1047 { 1042 owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING); 1048 char buff[1024]; 1049 1050 sprintf(buff, "Owl version %s", OWL_VERSION_STRING); 1051 owl_function_makemsg(buff); 1043 1052 } 1044 1053 … … 1452 1461 owl_function_aaway_on(); 1453 1462 owl_function_zaway_on(); 1454 owl_function_makemsg("Away messages set." );1463 owl_function_makemsg("Away messages set.", owl_global_get_aaway_msg_default(&g)); 1455 1464 return NULL; 1456 1465 } … … 1682 1691 } 1683 1692 1684 owl_function_debugmsg( "%s",argv[1]);1693 owl_function_debugmsg(argv[1]); 1685 1694 return(NULL); 1686 1695 } … … 2198 2207 } else if (!strcmp(argv[1], "license")) { 2199 2208 owl_function_show_license(); 2200 } else if (!strcmp(argv[1], "quickstart")) {2201 owl_function_show_quickstart();2202 2209 } else if (!strcmp(argv[1], "startup")) { 2203 2210 char *filename; … … 2244 2251 { 2245 2252 owl_function_curmsg_to_popwin(); 2253 } 2254 2255 void owl_command_openurl(void) 2256 { 2257 owl_function_openurl(); 2246 2258 } 2247 2259 … … 2568 2580 { 2569 2581 buff = skiptokens(buff, 1); 2570 owl_function_error( "%s",buff);2582 owl_function_error(buff); 2571 2583 return NULL; 2572 2584 } … … 2575 2587 { 2576 2588 buff = skiptokens(buff, 1); 2577 owl_function_makemsg( "%s",buff);2589 owl_function_makemsg(buff); 2578 2590 return NULL; 2579 2591 } -
examples/owlconf.erik
r160d3f4 r5d9c664 147 147 owl::command("set -q rxping on"); 148 148 owl::command("set -q typewinsize 5"); 149 if ($ENV{"DISPLAY"} eq ":0.0") { 150 owl::command("set -q webbrowser galeon"); 151 } 149 152 owl::command("filter me recipient %me% or ( sender %me% and class message and instance personal ) or class mail or type aim"); 150 153 owl::command("filter owl instance ^owl.*"); -
examples/owlconf.simple
r160d3f4 r2b14303 93 93 # owl::command('set -q view_home all'); 94 94 95 96 ## Which webbrowser to use to launch URLs with the 'w' key. 97 # owl::command('set -q webbrowser netscape'); 98 # owl::command('set -q webbrowser galeon'); 99 # owl::command('set -q webbrowser none'); 95 100 96 101 ## Default message to send when zaway is on (toggle with 'A') -
filter.c
r9711a6e rcdc6ff1 3 3 4 4 static const char fileIdent[] = "$Id$"; 5 6 #define OWL_FILTER_MAXRECURSE 20 5 7 6 8 int owl_filter_init_fromstring(owl_filter *f, char *name, char *string) … … 48 50 /* Now check for recursion. */ 49 51 if (owl_filter_is_toodeep(f)) { 50 owl_function_error("Filter loop !");52 owl_function_error("Filter loop or exceeds recursion depth"); 51 53 owl_filter_free(f); 52 54 return(-1); … … 311 313 int numfailed=0; 312 314 owl_message m; 313 owl_filter f1, f2, f3, f4 , f5;315 owl_filter f1, f2, f3, f4; 314 316 315 317 owl_list_create(&(g.filterlist)); … … 363 365 FAIL_UNLESS("mutual recursion", owl_filter_init_fromstring(&f4, "f4", "filter f3")); 364 366 365 /* support referencing a filter several times */366 FAIL_UNLESS("DAG", !owl_filter_init_fromstring(&f5, "dag", "filter f1 or filter f1"));367 368 367 return 0; 369 368 } -
filterelement.c
rf446454 r0504f63 279 279 } 280 280 281 static int fe_visiting = 0;282 static int fe_visited = 1;283 284 281 int owl_filterelement_is_toodeep(owl_filter *f, owl_filterelement *fe) 285 282 { 286 int rv; 283 int one = 1; 284 owl_list nodes; 287 285 owl_dict filters; 286 owl_list_create(&nodes); 288 287 owl_dict_create(&filters); 289 290 owl_dict_insert_element(&filters, f->name, &fe_visiting, owl_dict_noop_free); 291 292 rv = _owl_filterelement_is_toodeep(fe, &filters); 293 288 289 owl_list_append_element(&nodes, fe); 290 owl_dict_insert_element(&filters, f->name, &one, NULL); 291 while(owl_list_get_size(&nodes)) { 292 fe = owl_list_get_element(&nodes, 0); 293 owl_list_remove_element(&nodes, 0); 294 if(fe->left) owl_list_append_element(&nodes, fe->left); 295 if(fe->right) owl_list_append_element(&nodes, fe->right); 296 if(fe->match_message == owl_filterelement_match_filter) { 297 if(owl_dict_find_element(&filters, fe->field)) return 1; 298 owl_dict_insert_element(&filters, fe->field, &one, NULL); 299 f = owl_global_get_filter(&g, fe->field); 300 if(f) owl_list_append_element(&nodes, f->root); 301 } 302 } 303 304 owl_list_free_simple(&nodes); 294 305 owl_dict_free_simple(&filters); 295 return rv; 296 } 297 298 int _owl_filterelement_is_toodeep(owl_filterelement *fe, owl_dict *seen) 299 { 300 int rv = 0; 301 owl_filter *f; 302 303 if(fe->match_message == owl_filterelement_match_filter) { 304 int *nval = owl_dict_find_element(seen, fe->field); 305 if(nval == &fe_visiting) { 306 return 1; 307 } else if (nval == NULL) { 308 f = owl_global_get_filter(&g, fe->field); 309 owl_dict_insert_element(seen, fe->field, &fe_visiting, owl_dict_noop_free); 310 if(f) rv = _owl_filterelement_is_toodeep(f->root, seen); 311 owl_dict_insert_element(seen, fe->field, &fe_visited, owl_dict_noop_free); 312 } 313 } else { 314 if(fe->left) 315 rv = rv || _owl_filterelement_is_toodeep(fe->left, seen); 316 if(fe->right) 317 rv = rv || _owl_filterelement_is_toodeep(fe->right, seen); 318 } 319 return rv; 306 return 0; 320 307 } 321 308 -
fmtext.c
r2aaca94 r6f6330b 763 763 * If format_fn is specified, passes it the list element value 764 764 * and it will return a string which this needs to free. */ 765 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)( char*))765 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*)) 766 766 { 767 767 int i, size; 768 char*elem;768 void *elem; 769 769 char *text; 770 770 -
functions.c
r9b70dd4 r3f3ee61 99 99 } 100 100 101 char *owl_function_style_describe( char*name) {101 char *owl_function_style_describe(void *name) { 102 102 char *desc, *s; 103 103 owl_style *style; … … 114 114 } 115 115 116 char *owl_function_cmd_describe( char*name)116 char *owl_function_cmd_describe(void *name) 117 117 { 118 118 owl_cmd *cmd = owl_cmddict_find(owl_global_get_cmddict(&g), name); … … 172 172 } 173 173 174 void owl_function_show_quickstart()175 {176 char *message =177 "Move between messages with the arrow keys, and press 'r' to reply.\n"178 "For more info, press 'h' or visit http://barnowl.mit.edu/\n\n"179 #ifdef HAVE_LIBZEPHYR180 "@b(Zephyr:)\n"181 "To send a message to a user, type ':zwrite @b(username)'. You can also\n"182 "press 'z' and then type the username. To subscribe to a class, type\n"183 "':sub @b(class)', and then type ':zwrite -c @b(class)' to send.\n\n"184 #endif185 "@b(AIM:)\n"186 "Log in to AIM with ':aimlogin @b(screenname)'. Use ':aimwrite @b(screenname)',\n"187 "or 'a' and then the screen name, to send someone a message.\n\n"188 ;189 190 if (owl_perlconfig_is_function("BarnOwl::Hooks::_get_quickstart")) {191 char *perlquickstart = owl_perlconfig_execute("BarnOwl::Hooks::_get_quickstart()");192 if (perlquickstart) {193 char *result = owl_sprintf("%s%s", message, perlquickstart);194 owl_function_adminmsg("BarnOwl Quickstart", result);195 owl_free(result);196 owl_free(perlquickstart);197 return;198 }199 }200 owl_function_adminmsg("BarnOwl Quickstart", message);201 }202 203 204 174 /* Create an admin message, append it to the global list of messages 205 175 * and redisplay if necessary. … … 632 602 633 603 if (!found) { 634 owl_function_makemsg("already at last%s message%s%s %s",604 owl_function_makemsg("already at last%s message%s%s", 635 605 skip_deleted?" non-deleted":"", 636 filter?" in ":"", filter?filter:"", 637 owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g)) ? 638 ", press Enter to scroll" : ""); 606 filter?" in ":"", filter?filter:""); 639 607 /* if (!skip_deleted) owl_function_beep(); */ 640 608 } … … 1051 1019 owl_function_debugmsg("Quitting Owl"); 1052 1020 exit(0); 1021 } 1022 1023 void owl_function_openurl() 1024 { 1025 /* visit the first url in the current message */ 1026 owl_message *m; 1027 owl_view *v; 1028 char *ptr1, *ptr2, *text, url[LINE], tmpbuff[LINE]; 1029 int webbrowser; 1030 1031 webbrowser = owl_global_get_webbrowser(&g); 1032 1033 if (webbrowser < 0 || webbrowser == OWL_WEBBROWSER_NONE) { 1034 owl_function_error("No browser selected"); 1035 return; 1036 } 1037 1038 v=owl_global_get_current_view(&g); 1039 1040 m=owl_view_get_element(v, owl_global_get_curmsg(&g)); 1041 1042 if (!m || owl_view_get_size(v)==0) { 1043 owl_function_error("No current message selected"); 1044 return; 1045 } 1046 1047 text=owl_message_get_text(m); 1048 1049 /* First look for a good URL */ 1050 if ((ptr1=strstr(text, "http://"))!=NULL) { 1051 ptr2=strpbrk(ptr1, " \n\t"); 1052 if (ptr2) { 1053 strncpy(url, ptr1, ptr2-ptr1+1); 1054 url[ptr2-ptr1+1]='\0'; 1055 } else { 1056 strcpy(url, ptr1); 1057 } 1058 1059 /* if we had <http strip a trailing > */ 1060 if (ptr1>text && ptr1[-1]=='<') { 1061 if (url[strlen(url)-1]=='>') { 1062 url[strlen(url)-1]='\0'; 1063 } 1064 } 1065 } else if ((ptr1=strstr(text, "https://"))!=NULL) { 1066 /* Look for an https URL */ 1067 ptr2=strpbrk(ptr1, " \n\t"); 1068 if (ptr2) { 1069 strncpy(url, ptr1, ptr2-ptr1+1); 1070 url[ptr2-ptr1+1]='\0'; 1071 } else { 1072 strcpy(url, ptr1); 1073 } 1074 1075 /* if we had <http strip a trailing > */ 1076 if (ptr1>text && ptr1[-1]=='<') { 1077 if (url[strlen(url)-1]=='>') { 1078 url[strlen(url)-1]='\0'; 1079 } 1080 } 1081 } else if ((ptr1=strstr(text, "www."))!=NULL) { 1082 /* if we can't find a real url look for www.something */ 1083 ptr2=strpbrk(ptr1, " \n\t"); 1084 if (ptr2) { 1085 strncpy(url, ptr1, ptr2-ptr1+1); 1086 url[ptr2-ptr1+1]='\0'; 1087 } else { 1088 strcpy(url, ptr1); 1089 } 1090 } else { 1091 owl_function_beep(); 1092 owl_function_error("Could not find URL to open."); 1093 return; 1094 } 1095 1096 /* Make sure there aren't any quotes or \'s in the url */ 1097 for (ptr1 = url; *ptr1; ptr1++) { 1098 if (*ptr1 == '"' || *ptr1 == '\\') { 1099 owl_function_beep(); 1100 owl_function_error("URL contains invalid characters."); 1101 return; 1102 } 1103 } 1104 1105 /* NOTE: There are potentially serious security issues here... */ 1106 1107 /* open the page */ 1108 owl_function_makemsg("Opening %s", url); 1109 if (webbrowser == OWL_WEBBROWSER_NETSCAPE) { 1110 snprintf(tmpbuff, LINE, "netscape -remote \"openURL(%s)\" > /dev/null 2> /dev/null", url); 1111 system(tmpbuff); 1112 } else if (webbrowser == OWL_WEBBROWSER_GALEON) { 1113 snprintf(tmpbuff, LINE, "galeon \"%s\" > /dev/null 2> /dev/null &", url); 1114 system(tmpbuff); 1115 } else if (webbrowser == OWL_WEBBROWSER_OPERA) { 1116 snprintf(tmpbuff, LINE, "opera \"%s\" > /dev/null 2> /dev/null &", url); 1117 system(tmpbuff); 1118 } 1053 1119 } 1054 1120 … … 1544 1610 /* fix this */ 1545 1611 sprintf(buff, " Checkd Ath: %i\n", n->z_checked_auth); 1546 sprintf(buff + strlen(buff), " Multi notc: %s\n", n->z_multinotice);1547 sprintf(buff + strlen(buff), " Num other : %i\n", n->z_num_other_fields);1548 sprintf(buff + strlen(buff), " Msg Len : %i\n", n->z_message_len);1612 sprintf(buff, "%s Multi notc: %s\n", buff, n->z_multinotice); 1613 sprintf(buff, "%s Num other : %i\n", buff, n->z_num_other_fields); 1614 sprintf(buff, "%s Msg Len : %i\n", buff, n->z_message_len); 1549 1615 owl_fmtext_append_normal(&fm, buff); 1550 1616 … … 1856 1922 void owl_function_status() 1857 1923 { 1858 char buff[ MAXPATHLEN+1];1924 char buff[5000]; 1859 1925 time_t start; 1860 1926 int up, days, hours, minutes; … … 1876 1942 1877 1943 owl_fmtext_append_normal(&fm, " Current Directory: "); 1878 if(getcwd(buff, MAXPATHLEN) == NULL) { 1879 owl_fmtext_append_normal(&fm, "<Error in getcwd>"); 1880 } else { 1881 owl_fmtext_append_normal(&fm, buff); 1882 } 1944 (void) getcwd(buff, MAXPATHLEN); 1945 owl_fmtext_append_normal(&fm, buff); 1883 1946 owl_fmtext_append_normal(&fm, "\n"); 1884 1947 … … 1989 2052 return; 1990 2053 } 1991 }1992 1993 /* then check if it's a question and just bring up the command prompt */1994 if (owl_message_is_question(m)) {1995 owl_function_start_command("");1996 return;1997 2054 } 1998 2055 … … 2491 2548 sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass); 2492 2549 if (tmpinstance) { 2493 sprintf(argbuff + strlen(argbuff), " and ( instance ^(un)*%s(\\.d)*$ )", tmpinstance);2550 sprintf(argbuff, "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance); 2494 2551 } 2495 2552 owl_free(tmpclass); … … 2520 2577 { 2521 2578 owl_filter *f; 2522 char *argbuff, *longuser, * esclonguser, *shortuser, *filtname;2579 char *argbuff, *longuser, *shortuser, *filtname; 2523 2580 2524 2581 /* stick the local realm on if it's not there */ … … 2527 2584 2528 2585 /* name for the filter */ 2529 filtname=owl_sprintf("user-%s", shortuser); 2586 filtname=owl_malloc(strlen(shortuser)+20); 2587 sprintf(filtname, "user-%s", shortuser); 2530 2588 2531 2589 /* if it already exists then go with it. This lets users override */ … … 2537 2595 f=owl_malloc(sizeof(owl_filter)); 2538 2596 2539 esclonguser = owl_text_quote(longuser, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2540 2541 argbuff=owl_sprintf("( type ^zephyr$ and filter personal and " 2542 "( ( direction ^in$ and sender ^%1$s$ ) or ( direction ^out$ and " 2543 "recipient ^%1$s$ ) ) ) or ( ( class ^login$ ) and ( sender ^%1$s$ ) )", 2544 esclonguser); 2597 argbuff=owl_malloc(strlen(longuser)+1000); 2598 sprintf(argbuff, "( type ^zephyr$ and filter personal and "); 2599 sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser); 2600 sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) )", argbuff, longuser); 2545 2601 2546 2602 owl_filter_init_fromstring(f, filtname, argbuff); … … 2552 2608 owl_free(argbuff); 2553 2609 owl_free(longuser); 2554 owl_free(esclonguser);2555 2610 owl_free(shortuser); 2556 2611 … … 2571 2626 2572 2627 /* name for the filter */ 2573 filtname=owl_sprintf("aimuser-%s", user); 2628 filtname=owl_malloc(strlen(user)+40); 2629 sprintf(filtname, "aimuser-%s", user); 2574 2630 2575 2631 /* if it already exists then go with it. This lets users override */ … … 2583 2639 escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2584 2640 2585 argbuff = owl_sprintf( 2586 "( type ^aim$ and ( ( sender ^%1$s$ and recipient ^%2$s$ ) or " 2587 "( sender ^%2$s$ and recipient ^%1$s$ ) ) )", 2588 escuser, owl_global_get_aim_screenname_for_filters(&g)); 2641 argbuff=owl_malloc(1000); 2642 sprintf(argbuff, 2643 "( type ^aim$ and ( ( sender ^%s$ and recipient ^%s$ ) or ( sender ^%s$ and recipient ^%s$ ) ) )", 2644 escuser, owl_global_get_aim_screenname_for_filters(&g), 2645 owl_global_get_aim_screenname_for_filters(&g), escuser); 2589 2646 2590 2647 owl_filter_init_fromstring(f, filtname, argbuff); … … 2603 2660 { 2604 2661 owl_filter *f; 2605 char *argbuff, *filtname , *esctype;2662 char *argbuff, *filtname; 2606 2663 2607 2664 /* name for the filter */ … … 2616 2673 f=owl_malloc(sizeof(owl_filter)); 2617 2674 2618 esctype = owl_text_quote(type, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2619 2620 argbuff = owl_sprintf("type ^%s$", esctype); 2675 argbuff = owl_sprintf("type ^%s$", type); 2621 2676 2622 2677 owl_filter_init_fromstring(f, filtname, argbuff); … … 2627 2682 /* free stuff */ 2628 2683 owl_free(argbuff); 2629 owl_free(esctype);2630 2684 2631 2685 return filtname; … … 2901 2955 owl_text_tr(quoted, '\'', '.'); 2902 2956 owl_text_tr(quoted, '"', '.'); 2903 sprintf(buff + strlen(buff), " ^(un)*%s(\\.d)*$", quoted);2957 sprintf(buff, "%s ^(un)*%s(\\.d)*$", buff, quoted); 2904 2958 owl_free(quoted); 2905 2959 } … … 2911 2965 owl_text_tr(quoted, '\'', '.'); 2912 2966 owl_text_tr(quoted, '"', '.'); 2913 sprintf(buff + strlen(buff), " and instance ^(un)*%s(\\.d)*$", quoted);2967 sprintf(buff, "%s and instance ^(un)*%s(\\.d)*$", buff, quoted); 2914 2968 owl_free(quoted); 2915 2969 } … … 2919 2973 owl_text_tr(quoted, '\'', '.'); 2920 2974 owl_text_tr(quoted, '"', '.'); 2921 sprintf(buff + strlen(buff), " and recipient ^%s$", quoted);2975 sprintf(buff, "%s and recipient ^%s$", buff, quoted); 2922 2976 owl_free(quoted); 2923 2977 } … … 3011 3065 } 3012 3066 3013 char *owl_function_keymap_summary( char*name)3067 char *owl_function_keymap_summary(void *name) 3014 3068 { 3015 3069 owl_keymap *km -
global.c
r5547211b rda466e0 139 139 g->recwin=newwin(g->recwinlines, cols, 0, 0); 140 140 if (g->recwin==NULL) { 141 owl_function_debugmsg("_owl_global_setup_windows: newwin returned NULL\n" );141 owl_function_debugmsg("_owl_global_setup_windows: newwin returned NULL\n", g->recwinlines, cols); 142 142 endwin(); 143 143 exit(50); … … 570 570 strcpy(g->startupargs, ""); 571 571 for (i=0; i<argc; i++) { 572 sprintf(g->startupargs + strlen(g->startupargs), "%s ", argv[i]);572 sprintf(g->startupargs, "%s%s ", g->startupargs, argv[i]); 573 573 } 574 574 g->startupargs[strlen(g->startupargs)-1]='\0'; -
help.c
r799b60e r0398d55 18 18 owl_fmtext_append_normal 19 19 (&fm, 20 " If you're new to BarnOwl, the first thing you should type is\n\n"21 " :show quickstart\n\n"22 20 " For help on a specific command use 'help <command>'\n" 23 21 " For information on advanced keys, use 'show keymaps'.\n" -
keys.c
r9b70dd4 r3004c9f 282 282 BIND_CMD("M-r", "reply -e", "reply to the current message, but allow editing of recipient"); 283 283 BIND_CMD("M-R", "reply -e sender", "reply to sender of the current message, but allow editing of recipient"); 284 285 BIND_CMD("w", "openurl", "open a URL using a webbrowser"); 284 286 285 287 BIND_CMD("W", "start-command webzephyr ", "start a webzephyr command"); -
owl.c
r5b37c063 r5b37c063 323 323 sprintf(buff, "Welcome to barnowl version %s. Press 'h' for on-line help. \n", OWL_VERSION_STRING); 324 324 strcat(startupmsg, buff); 325 strcat(startupmsg, "To see a quick introduction, type ':show quickstart'. \n");326 325 strcat(startupmsg, " \n"); 327 326 strcat(startupmsg, "BarnOwl is free software. Type ':show license' for more \n"); 328 strcat(startupmsg, "information. ^ ^ \n"); 327 strcat(startupmsg, "information. \n"); 328 strcat(startupmsg, " ^ ^ \n"); 329 329 strcat(startupmsg, " OvO \n"); 330 330 strcat(startupmsg, "Please report any bugs or suggestions to bug-barnowl@mit.edu ( ) \n"); … … 511 511 int signum; 512 512 if ((signum = owl_global_get_errsignal_and_clear(&g, &si)) > 0) { 513 owl_function_error("Got unexpected signal: %d %s (code: %d band: % ld errno: %d)",513 owl_function_error("Got unexpected signal: %d %s (code: %d band: %d errno: %d)", 514 514 signum, signum==SIGPIPE?"SIGPIPE":"SIG????", 515 515 si.si_code, si.si_band, si.si_errno); … … 612 612 613 613 return 1; 614 } 615 616 void owl_process_aim() 617 { 618 if (owl_global_is_doaimevents(&g)) { 619 owl_aim_process_events(); 620 621 if (owl_global_is_aimloggedin(&g)) { 622 if (owl_timer_is_expired(owl_global_get_aim_buddyinfo_timer(&g))) { 623 /* owl_buddylist_request_idletimes(owl_global_get_buddylist(&g)); */ 624 owl_timer_reset(owl_global_get_aim_buddyinfo_timer(&g)); 625 } 626 } 627 } 614 628 } 615 629 -
owl.h
rb940b91 r43a306c 52 52 53 53 #ifndef OWL_VERSION_STRING 54 #define OWL_VERSION_STRING "1.0. 4.1"54 #define OWL_VERSION_STRING "1.0.3" 55 55 #endif 56 56 … … 320 320 321 321 typedef struct _owl_pair { 322 char*key;323 char*value;322 void *key; 323 void *value; 324 324 } owl_pair; 325 325 -
pair.c
rde1c8a5 r160ea47 1 1 #include "owl.h" 2 2 3 void owl_pair_create(owl_pair *p, char *key, char*value) {3 void owl_pair_create(owl_pair *p, void *key, void *value) { 4 4 p->key=key; 5 5 p->value=value; 6 6 } 7 7 8 void owl_pair_set_key(owl_pair *p, char*key) {8 void owl_pair_set_key(owl_pair *p, void *key) { 9 9 p->key=key; 10 10 } 11 11 12 void owl_pair_set_value(owl_pair *p, char*value) {12 void owl_pair_set_value(owl_pair *p, void *value) { 13 13 p->value=value; 14 14 } 15 15 16 char*owl_pair_get_key(owl_pair *p) {16 void *owl_pair_get_key(owl_pair *p) { 17 17 return(p->key); 18 18 } 19 19 20 char*owl_pair_get_value(owl_pair *p) {20 void *owl_pair_get_value(owl_pair *p) { 21 21 return(p->value); 22 22 } -
perl/modules/IRC/lib/BarnOwl/Message/IRC.pm
rf79d6a2 r38a7f22 33 33 @filter = 34 34 (qw{( type ^irc$ and filter personal and }, 35 qw{( ( direction ^in$ and sender}, "^ \Q$who\E\$",36 qw{ ) or ( direction ^out$ and recipient}, "^ \Q$who\E\$",35 qw{( ( direction ^in$ and sender}, "^$who\$", 36 qw{ ) or ( direction ^out$ and recipient}, "^$who\$", 37 37 qw{) ) ) }); 38 38 BarnOwl::command("filter", "$filter", @filter); … … 47 47 $filter = "irc-$network-channel-$channel-$sender-$1"; 48 48 @filter = 49 (qw{type ^irc$ and network}, "^ \Q$network\E\$",50 qw{and channel}, "^ \Q$channel\E\$",51 qw{and ( sender}, "^ \Q$sender\E\$",52 qw{or sender}, "^ \Q$1\E\$",qq{)});49 (qw{type ^irc$ and network}, "^$network\$", 50 qw{and channel}, "^$channel\$", 51 qw{and ( sender}, "^$sender\$", 52 qw{or sender}, "^$1\$",qq{)}); 53 53 } else { 54 54 $filter = "irc-$network-channel-$channel"; 55 @filter = (qw{type ^irc$ and network}, "^ \Q$network\E\$",56 qw{and channel}, "^ \Q$channel\E\$");55 @filter = (qw{type ^irc$ and network}, "^$network\$", 56 qw{and channel}, "^$channel\$"); 57 57 } 58 58 BarnOwl::command("filter", "$filter", @filter); -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
r1c014eec r167044b 214 214 if ($body =~ /^\/me (.*)/) { 215 215 $conn->conn->me($to, $1); 216 $body = '* '.$conn->nick.' '.$1;216 $body = BarnOwl::Style::boldify($conn->nick.' '.$1); 217 217 } else { 218 218 $conn->conn->privmsg($to, $body); -
perl/modules/Jabber/lib/BarnOwl/Message/Jabber.pm
r9375f8c r96134cb 70 70 $filter = "jabber-room-$room"; 71 71 BarnOwl::command(qw[filter], $filter, 72 qw[type ^jabber$ and room], "^ \Q$room\E\$");72 qw[type ^jabber$ and room], "^$room\$"); 73 73 return $filter; 74 74 } elsif ($self->login ne 'none') { … … 84 84 my $filter = "jabber-user-$user"; 85 85 BarnOwl::command(qw[filter], $filter, qw[type ^jabber$], 86 qw[and ( ( direction ^in$ and from], "^ \Q$user\E(/.*)?\$",87 qw[) or ( direction ^out$ and to ], "^ \Q$user\E(/.*)?\$",86 qw[and ( ( direction ^in$ and from], "^$user", 87 qw[) or ( direction ^out$ and to ], "^$user", 88 88 qw[ ) ) ]); 89 89 return $filter; -
perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm
r799b60e re979da9 70 70 $BarnOwl::Hooks::mainLoop->add("BarnOwl::Module::Jabber::onMainLoop"); 71 71 $BarnOwl::Hooks::getBuddyList->add("BarnOwl::Module::Jabber::onGetBuddyList"); 72 $BarnOwl::Hooks::getQuickstart->add("BarnOwl::Module::Jabber::onGetQuickstart");73 72 $vars{show} = ''; 74 73 BarnOwl::new_variable_bool("jabber:show_offline_buddies", … … 223 222 } 224 223 225 sub onGetQuickstart {226 return <<'EOF'227 @b(Jabber:)228 Type ':jabberlogin @b(username@mit.edu)' to log in to Jabber. The command229 ':jroster sub @b(somebody@gmail.com)' will request that they let you message230 them. Once you get a message saying you are subscribed, you can message231 them by typing ':jwrite @b(somebody@gmail.com)' or just 'j @b(somebody)'.232 EOF233 }234 235 224 ################################################################################ 236 225 ### Owl Commands -
perlconfig.c
r5b37c063 r5b37c063 44 44 h = newHV(); 45 45 46 #define MSG2H(h,field) (void)hv_store(h, #field, strlen(#field),\47 46 #define MSG2H(h,field) hv_store(h, #field, strlen(#field), \ 47 newSVpv(owl_message_get_##field(m),0), 0) 48 48 49 49 if (owl_message_is_type_zephyr(m) … … 59 59 owl_free(ptr); 60 60 } 61 (void)hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0);62 63 (void)hv_store(h, "auth", strlen("auth"),64 61 hv_store(h, "fields", strlen("fields"), newRV_noinc((SV*)av_zfields), 0); 62 63 hv_store(h, "auth", strlen("auth"), 64 newSVpv(owl_zephyr_get_authstr(owl_message_get_notice(m)),0),0); 65 65 } 66 66 … … 68 68 for(i=0; i<j; i++) { 69 69 pair=owl_list_get_element(&(m->attributes), i); 70 (void)hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)),71 70 hv_store(h, owl_pair_get_key(pair), strlen(owl_pair_get_key(pair)), 71 newSVpv(owl_pair_get_value(pair),0),0); 72 72 } 73 73 … … 88 88 MSG2H(h, header); 89 89 } 90 (void)hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0);91 (void)hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0);92 (void)hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0);93 (void)hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0);94 (void)hv_store(h, "should_wordwrap",95 96 90 hv_store(h, "time", strlen("time"), newSVpv(owl_message_get_timestr(m),0),0); 91 hv_store(h, "id", strlen("id"), newSViv(owl_message_get_id(m)),0); 92 hv_store(h, "deleted", strlen("deleted"), newSViv(owl_message_is_delete(m)),0); 93 hv_store(h, "private", strlen("private"), newSViv(owl_message_is_private(m)),0); 94 hv_store(h, "should_wordwrap", 95 strlen("should_wordwrap"), newSViv( 96 owl_filter_message_match(wrap, m)),0); 97 97 98 98 type = owl_message_get_type(m); … … 102 102 blessas = owl_sprintf("BarnOwl::Message::%s", type); 103 103 104 hr = newRV_noinc((SV*)h);104 hr = sv_2mortal(newRV_noinc((SV*)h)); 105 105 stash = gv_stashpv(blessas,0); 106 106 if(!stash) { … … 182 182 dSP ; 183 183 int count; 184 unsigned int len; 184 185 SV *msgref, *srv; 185 char *out ;186 char *out, *preout; 186 187 187 188 ENTER ; … … 190 191 PUSHMARK(SP) ; 191 192 msgref = owl_perlconfig_message2hashref(m); 192 XPUSHs( sv_2mortal(msgref));193 XPUSHs(msgref); 193 194 PUTBACK ; 194 195 … … 198 199 199 200 if (SvTRUE(ERRSV)) { 200 owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV)); 201 STRLEN n_a; 202 owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a)); 201 203 /* and clear the error */ 202 204 sv_setsv (ERRSV, &PL_sv_undef); … … 211 213 212 214 if (srv) { 213 out = owl_strdup(SvPV_nolen(srv)); 215 preout=SvPV(srv, len); 216 out = owl_malloc(strlen(preout)+1); 217 strncpy(out, preout, len); 218 out[len] = '\0'; 214 219 } else { 215 220 out = NULL; … … 230 235 { 231 236 dSP; 232 unsigned int count, i;237 unsigned int count, len, i; 233 238 SV *msgref, *srv; 234 char *out ;239 char *out, *preout; 235 240 236 241 msgref = owl_perlconfig_message2hashref(m); … … 240 245 241 246 PUSHMARK(SP); 242 XPUSHs( sv_2mortal(msgref));247 XPUSHs(msgref); 243 248 for(i=0;i<argc;i++) { 244 249 XPUSHs(sv_2mortal(newSVpv(argv[i], 0))); … … 256 261 257 262 if (SvTRUE(ERRSV)) { 258 owl_function_error("Error: '%s'", SvPV_nolen(ERRSV)); 263 STRLEN n_a; 264 owl_function_error("Error: '%s'", SvPV(ERRSV, n_a)); 259 265 /* and clear the error */ 260 266 sv_setsv (ERRSV, &PL_sv_undef); … … 264 270 265 271 if (srv) { 266 out = owl_strdup(SvPV_nolen(srv)); 272 preout=SvPV(srv, len); 273 out = owl_malloc(strlen(preout)+1); 274 strncpy(out, preout, len); 275 out[len] = '\0'; 267 276 } else { 268 277 out = NULL; … … 295 304 ret=perl_parse(p, owl_perl_xs_init, 2, args, NULL); 296 305 if (ret || SvTRUE(ERRSV)) { 297 err=owl_strdup(SvPV_nolen(ERRSV)); 306 STRLEN n_a; 307 err=owl_strdup(SvPV(ERRSV, n_a)); 298 308 sv_setsv(ERRSV, &PL_sv_undef); /* and clear the error */ 299 309 return(err); … … 302 312 ret=perl_run(p); 303 313 if (ret || SvTRUE(ERRSV)) { 304 err=owl_strdup(SvPV_nolen(ERRSV)); 314 STRLEN n_a; 315 err=owl_strdup(SvPV(ERRSV, n_a)); 305 316 sv_setsv(ERRSV, &PL_sv_undef); /* and clear the error */ 306 317 return(err); … … 331 342 332 343 if (SvTRUE(ERRSV)) { 333 err=owl_strdup(SvPV_nolen(ERRSV)); 344 STRLEN n_a; 345 err=owl_strdup(SvPV(ERRSV, n_a)); 334 346 sv_setsv (ERRSV, &PL_sv_undef); /* and clear the error */ 335 347 return(err); … … 384 396 385 397 if (SvTRUE(ERRSV)) { 386 owl_function_error("Perl Error: '%s'", SvPV_nolen(ERRSV)); 398 STRLEN n_a; 399 owl_function_error("Perl Error: '%s'", SvPV(ERRSV, n_a)); 387 400 sv_setsv (ERRSV, &PL_sv_undef); /* and clear the error */ 388 401 } 389 402 390 403 preout=SvPV(response, len); 391 if (len == 0 || preout[len - 1] != '\n') 392 out = owl_sprintf("%s\n", preout); 393 else 394 out = owl_strdup(preout); 404 /* leave enough space in case we have to add a newline */ 405 out = owl_malloc(strlen(preout)+2); 406 strncpy(out, preout, len); 407 out[len] = '\0'; 408 if (!strlen(out) || out[strlen(out)-1]!='\n') { 409 strcat(out, "\n"); 410 } 395 411 396 412 return(out); … … 423 439 char * ret = NULL; 424 440 SV *rv; 441 STRLEN n_a; 425 442 dSP; 426 443 … … 441 458 442 459 if(SvTRUE(ERRSV)) { 443 owl_function_error("%s", SvPV _nolen(ERRSV));460 owl_function_error("%s", SvPV(ERRSV, n_a)); 444 461 (void)POPs; 445 462 } else { … … 448 465 rv = POPs; 449 466 if(SvTRUE(rv)) { 450 ret = owl_strdup(SvPV _nolen(rv));467 ret = owl_strdup(SvPV(rv, n_a)); 451 468 } 452 469 } … … 472 489 SV *cb = (SV*)(e->cbdata); 473 490 SV *text; 491 unsigned int n_a; 474 492 dSP; 475 493 … … 490 508 491 509 if(SvTRUE(ERRSV)) { 492 owl_function_error("%s", SvPV _nolen(ERRSV));510 owl_function_error("%s", SvPV(ERRSV, n_a)); 493 511 } 494 512 … … 508 526 call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL); 509 527 if(SvTRUE(ERRSV)) { 510 owl_function_error("%s", SvPV_nolen(ERRSV)); 528 STRLEN n_a; 529 owl_function_error("%s", SvPV(ERRSV, n_a)); 511 530 } 512 531 return; … … 516 535 { 517 536 SV *cb = d->pfunc; 537 unsigned int n_a; 518 538 dSP; 519 539 if(cb == NULL) { … … 530 550 531 551 if(SvTRUE(ERRSV)) { 532 owl_function_error("%s", SvPV _nolen(ERRSV));552 owl_function_error("%s", SvPV(ERRSV, n_a)); 533 553 } 534 554 -
perlglue.xs
r5d2248c r740d5f7 24 24 * complex argument processing or something, we define a 25 25 * simple version here that takes arguments in as flat a 26 * manner as possible, to simplify the XS code, put it in27 * BarnOwl::Intenal::, and write a perl wrapper in perlwrap.pm28 * that munges the arguments as appropriate and calls the29 * internal version.26 * manner as possible, to simplify the XS code, with a name 27 * with a trailing `_internal', and write a perl wrapper in 28 * perlwrap.pm that munges the arguments as appropriate and 29 * calls the internal version. 30 30 */ 31 31 … … 62 62 getcurmsg() 63 63 CODE: 64 RETVAL = owl_perlconfig_curmessage2hashref(); 65 OUTPUT: 66 RETVAL 64 ST(0) = owl_perlconfig_curmessage2hashref(); 67 65 68 66 int … … 143 141 if (rv) owl_free(rv); 144 142 145 void queue_message(msg) 146 SV *msg 147 PREINIT: 148 owl_message *m; 149 CODE: 150 { 151 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { 152 croak("Usage: BarnOwl::queue_message($message)"); 153 } 154 155 m = owl_perlconfig_hashref2message(msg); 156 157 owl_global_messagequeue_addmsg(&g, m); 158 } 159 160 void admin_message(header, body) 161 char *header 162 char *body 163 CODE: 164 { 165 owl_function_adminmsg(header, body); 166 } 167 168 void start_question(line, callback) 169 char *line 170 SV *callback 171 PREINIT: 172 CODE: 173 { 174 if(!SV_IS_CODEREF(callback)) 175 croak("Callback must be a subref"); 176 177 owl_function_start_question(line); 178 179 SvREFCNT_inc(callback); 180 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); 181 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 182 } 183 184 void start_password(line, callback) 185 char *line 186 SV *callback 187 PREINIT: 188 CODE: 189 { 190 if(!SV_IS_CODEREF(callback)) 191 croak("Callback must be a subref"); 192 193 owl_function_start_password(line); 194 195 SvREFCNT_inc(callback); 196 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); 197 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 198 } 199 200 void start_edit_win(line, callback) 201 char *line 202 SV *callback 203 PREINIT: 204 owl_editwin * e; 205 char buff[1024]; 206 CODE: 207 { 208 if(!SV_IS_CODEREF(callback)) 209 croak("Callback must be a subref"); 210 211 e = owl_global_get_typwin(&g); 212 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, 213 owl_global_get_msg_history(&g)); 214 owl_editwin_clear(e); 215 owl_editwin_set_dotsend(e); 216 snprintf(buff, 1023, "----> %s\n", line); 217 owl_editwin_set_locktext(e, buff); 218 219 owl_global_set_typwin_active(&g); 220 221 SvREFCNT_inc(callback); 222 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); 223 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 224 } 225 226 227 char * 228 get_data_dir () 229 CODE: 230 RETVAL = (char *) owl_get_datadir(); 231 OUTPUT: 232 RETVAL 233 234 char * 235 get_config_dir () 236 CODE: 237 RETVAL = (char *) owl_global_get_confdir(&g); 238 OUTPUT: 239 RETVAL 240 241 void 242 popless_text(text) 243 char *text 244 CODE: 245 { 246 owl_function_popless_text(text); 247 } 248 249 void 250 popless_ztext(text) 251 char *text 252 CODE: 253 { 254 owl_fmtext fm; 255 owl_fmtext_init_null(&fm); 256 owl_fmtext_append_ztext(&fm, text); 257 owl_function_popless_fmtext(&fm); 258 owl_fmtext_free(&fm); 259 } 260 261 void 262 error(text) 263 char *text 264 CODE: 265 { 266 owl_function_error("%s", text); 267 } 268 269 void 270 create_style(name, object) 271 char *name 272 SV *object 273 PREINIT: 274 owl_style *s; 275 CODE: 276 { 277 s = owl_malloc(sizeof(owl_style)); 278 owl_style_create_perl(s, name, object); 279 owl_global_add_style(&g, s); 280 } 281 282 int 283 getnumcolors() 284 CODE: 285 RETVAL = owl_function_get_color_count(); 286 OUTPUT: 287 RETVAL 288 289 void 290 _remove_filter(filterName) 291 char *filterName 292 CODE: 293 { 294 /* Don't delete the current view, or the 'all' filter */ 295 if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) 296 && strcmp(filterName, "all")) { 297 owl_global_remove_filter(&g,filterName); 298 } 299 } 300 301 char * 302 wordwrap(in, cols) 303 char *in 304 int cols 305 PREINIT: 306 char *rv = NULL; 307 CODE: 308 rv = owl_text_wordwrap(in, cols); 309 RETVAL = rv; 310 OUTPUT: 311 RETVAL 312 CLEANUP: 313 if (rv) owl_free(rv); 314 315 void 316 add_dispatch(fd, cb) 317 int fd 318 SV * cb 319 CODE: 320 SvREFCNT_inc(cb); 321 owl_select_add_perl_dispatch(fd, cb); 322 323 void 324 remove_dispatch(fd) 325 int fd 326 CODE: 327 owl_select_remove_perl_dispatch(fd); 328 329 MODULE = BarnOwl PACKAGE = BarnOwl::Internal 330 331 332 void 333 new_command(name, func, summary, usage, description) 143 void 144 new_command_internal(name, func, summary, usage, description) 334 145 char *name 335 146 SV *func … … 361 172 } 362 173 363 void 364 new_variable_string(name, ival, summ, desc) 174 void queue_message(msg) 175 SV *msg 176 PREINIT: 177 owl_message *m; 178 CODE: 179 { 180 if(!SvROK(msg) || SvTYPE(SvRV(msg)) != SVt_PVHV) { 181 croak("Usage: BarnOwl::queue_message($message)"); 182 } 183 184 m = owl_perlconfig_hashref2message(msg); 185 186 owl_global_messagequeue_addmsg(&g, m); 187 } 188 189 void admin_message(header, body) 190 char *header 191 char *body 192 CODE: 193 { 194 owl_function_adminmsg(header, body); 195 } 196 197 void start_question(line, callback) 198 char *line 199 SV *callback 200 PREINIT: 201 CODE: 202 { 203 if(!SV_IS_CODEREF(callback)) 204 croak("Callback must be a subref"); 205 206 owl_function_start_question(line); 207 208 SvREFCNT_inc(callback); 209 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); 210 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 211 } 212 213 void start_password(line, callback) 214 char *line 215 SV *callback 216 PREINIT: 217 CODE: 218 { 219 if(!SV_IS_CODEREF(callback)) 220 croak("Callback must be a subref"); 221 222 owl_function_start_password(line); 223 224 SvREFCNT_inc(callback); 225 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); 226 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 227 } 228 229 void start_edit_win(line, callback) 230 char *line 231 SV *callback 232 PREINIT: 233 owl_editwin * e; 234 char buff[1024]; 235 CODE: 236 { 237 if(!SV_IS_CODEREF(callback)) 238 croak("Callback must be a subref"); 239 240 e = owl_global_get_typwin(&g); 241 owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, 242 owl_global_get_msg_history(&g)); 243 owl_editwin_clear(e); 244 owl_editwin_set_dotsend(e); 245 snprintf(buff, 1023, "----> %s\n", line); 246 owl_editwin_set_locktext(e, buff); 247 248 owl_global_set_typwin_active(&g); 249 250 SvREFCNT_inc(callback); 251 owl_editwin_set_cbdata(owl_global_get_typwin(&g), callback); 252 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 253 } 254 255 256 char * 257 get_data_dir () 258 CODE: 259 RETVAL = (char *) owl_get_datadir(); 260 OUTPUT: 261 RETVAL 262 263 char * 264 get_config_dir () 265 CODE: 266 RETVAL = (char *) owl_global_get_confdir(&g); 267 OUTPUT: 268 RETVAL 269 270 void 271 popless_text(text) 272 char *text 273 CODE: 274 { 275 owl_function_popless_text(text); 276 } 277 278 void 279 popless_ztext(text) 280 char *text 281 CODE: 282 { 283 owl_fmtext fm; 284 owl_fmtext_init_null(&fm); 285 owl_fmtext_append_ztext(&fm, text); 286 owl_function_popless_fmtext(&fm); 287 owl_fmtext_free(&fm); 288 } 289 290 void 291 error(text) 292 char *text 293 CODE: 294 { 295 owl_function_error("%s", text); 296 } 297 298 void 299 create_style(name, object) 300 char *name 301 SV *object 302 PREINIT: 303 owl_style *s; 304 CODE: 305 { 306 s = owl_malloc(sizeof(owl_style)); 307 owl_style_create_perl(s, name, object); 308 owl_global_add_style(&g, s); 309 } 310 311 int 312 getnumcolors() 313 CODE: 314 RETVAL = owl_function_get_color_count(); 315 OUTPUT: 316 RETVAL 317 318 void 319 _remove_filter(filterName) 320 char *filterName 321 CODE: 322 { 323 /* Don't delete the current view, or the 'all' filter */ 324 if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) 325 && strcmp(filterName, "all")) { 326 owl_global_remove_filter(&g,filterName); 327 } 328 } 329 330 char * 331 wordwrap(in, cols) 332 char *in 333 int cols 334 PREINIT: 335 char *rv = NULL; 336 CODE: 337 rv = owl_text_wordwrap(in, cols); 338 RETVAL = rv; 339 OUTPUT: 340 RETVAL 341 CLEANUP: 342 if (rv) owl_free(rv); 343 344 void 345 new_variable_string_internal(name, ival, summ, desc) 365 346 char * name 366 347 char * ival … … 375 356 376 357 void 377 new_variable_int (name, ival, summ, desc)358 new_variable_int_internal(name, ival, summ, desc) 378 359 char * name 379 360 int ival … … 388 369 389 370 void 390 new_variable_bool (name, ival, summ, desc)371 new_variable_bool_internal(name, ival, summ, desc) 391 372 char * name 392 373 int ival … … 399 380 desc, 400 381 ival); 382 383 void 384 add_dispatch(fd, cb) 385 int fd 386 SV * cb 387 CODE: 388 SvREFCNT_inc(cb); 389 owl_select_add_perl_dispatch(fd, cb); 390 391 void 392 remove_dispatch(fd) 393 int fd 394 CODE: 395 owl_select_remove_perl_dispatch(fd); -
perlwrap.pm
r5d2248c r740d5f7 242 242 ); 243 243 244 BarnOwl:: Internal::new_command($name, $func, $args{summary}, $args{usage}, $args{description});244 BarnOwl::new_command_internal($name, $func, $args{summary}, $args{usage}, $args{description}); 245 245 } 246 246 … … 275 275 276 276 sub new_variable_int { 277 unshift @_, \&BarnOwl:: Internal::new_variable_int, 0;277 unshift @_, \&BarnOwl::new_variable_int_internal, 0; 278 278 goto \&_new_variable; 279 279 } 280 280 281 281 sub new_variable_bool { 282 unshift @_, \&BarnOwl:: Internal::new_variable_bool, 0;282 unshift @_, \&BarnOwl::new_variable_bool_internal, 0; 283 283 goto \&_new_variable; 284 284 } 285 285 286 286 sub new_variable_string { 287 unshift @_, \&BarnOwl:: Internal::new_variable_string, "";287 unshift @_, \&BarnOwl::new_variable_string_internal, ""; 288 288 goto \&_new_variable; 289 289 } … … 810 810 displayed in a popup window, with zephyr formatting parsed. 811 811 812 =item $getQuickstart813 814 Called by :show quickstart to display 2-5 lines of help on how to815 start using the protocol. The result from every function registered816 with this hook will be appended and displayed in an admin message,817 with zephyr formatting parsed. The format should be818 "@b(Protocol:)\nSome text.\nMore text.\n"819 820 812 =back 821 813 … … 826 818 our @EXPORT_OK = qw($startup $shutdown 827 819 $receiveMessage $newMessage 828 $mainLoop $getBuddyList 829 $getQuickstart); 820 $mainLoop $getBuddyList); 830 821 831 822 our %EXPORT_TAGS = (all => [@EXPORT_OK]); … … 837 828 our $mainLoop = BarnOwl::Hook->new; 838 829 our $getBuddyList = BarnOwl::Hook->new; 839 our $getQuickstart = BarnOwl::Hook->new;840 830 841 831 # Internal startup/shutdown routines called by the C code … … 931 921 } 932 922 933 sub _get_quickstart {934 return join("\n", $getQuickstart->run);935 }936 937 923 ################################################################################ 938 924 # Built-in perl styles -
popexec.c
r44fc93b r1971b59 73 73 dup2(child_write_fd, 2 /*stderr*/); 74 74 close(child_write_fd); 75 76 while(0) { 77 write(child_write_fd, "meep\n", 5); 78 sleep(1); 79 } 75 80 76 81 argv[0] = "sh"; -
regex.c
r554a2b8 r8b7466b 13 13 { 14 14 int ret; 15 char buff1[LINE] ;15 char buff1[LINE], buff2[LINE]; 16 16 char *ptr; 17 17 … … 29 29 if (ret) { 30 30 regerror(ret, NULL, buff1, LINE); 31 owl_function_makemsg("Error in regular expression: %s", buff1); 31 sprintf(buff2, "Error in regular expression: %s", buff1); 32 owl_function_makemsg(buff2); 32 33 owl_free(re->string); 33 34 re->string=NULL; -
tester.c
r3381399 r1cf3f8d3 6 6 7 7 owl_global g; 8 9 void screeninit() 10 { 11 char buff[1024]; 12 13 sprintf(buff, "TERMINFO=%s", TERMINFO); 14 putenv(buff); 15 16 initscr(); 17 start_color(); 18 /* cbreak(); */ 19 raw(); 20 noecho(); 21 intrflush(stdscr,FALSE); 22 keypad(stdscr,TRUE); 23 nodelay(stdscr,1); 24 clear(); 25 refresh(); 26 meta(stdscr, TRUE); 27 } 28 29 void test1() 30 { 31 int j; 32 owl_editwin e; 33 34 screeninit(); 35 36 owl_editwin_init(&e, stdscr, LINES, COLS, OWL_EDITWIN_STYLE_MULTILINE, NULL); 37 /* owl_editwin_set_locktext(&e, "Here is some locktext:\n");*/ 38 doupdate(); 39 while (1) { 40 usleep(50); 41 42 j=getch(); 43 44 if (j==ERR) continue; 45 46 if (j==3) break; 47 48 if (j==27) { 49 j=getch(); 50 if (j==ERR) continue; 51 owl_editwin_process_char(&e, j); 52 doupdate(); 53 } else { 54 owl_editwin_process_char(&e, j); 55 doupdate(); 56 } 57 } 58 endwin(); 59 printf("Had:\n%s", owl_editwin_get_text(&e)); 60 } 61 62 void test2(char *in) 63 { 64 owl_fmtext t; 65 66 screeninit(); 67 68 owl_fmtext_init_null(&t); 69 owl_fmtext_append_ztext(&t, in); 70 owl_fmtext_curs_waddstr(&t, stdscr); 71 wrefresh(stdscr); 72 sleep(5000); 73 endwin(); 74 } 75 76 void test3() 77 { 78 ZNotice_t *n; 79 80 printf("%i\n", sizeof(n->z_uid.zuid_addr)); 81 /* gethostbyaddr((char *) &(n->z_uid.zuid_addr), sizeof(n->z_uid.zuid_addr), AF_INET); */ 82 } 83 84 void colorinfo() 85 { 86 char buff[1024]; 87 88 screeninit(); 89 sprintf(buff, "Have %i COLOR_PAIRS\n", COLOR_PAIRS); 90 addstr(buff); 91 refresh(); 92 sleep(10); 93 endwin(); 94 } 95 96 void test4() 97 { 98 int j; 99 char buff[1024]; 100 101 screeninit(); 102 103 while (1) { 104 usleep(100); 105 106 j=getch(); 107 108 if (j==ERR) continue; 109 110 if (j==3) break; 111 sprintf(buff, "%o\n", j); 112 addstr(buff); 113 } 114 endwin(); 115 } 116 117 void test_keypress() 118 { 119 int j, rev; 120 char buff[1024], buff2[64]; 121 122 screeninit(); 123 124 while (1) { 125 usleep(100); 126 127 j=wgetch(stdscr); 128 129 if (j==ERR) continue; 130 131 if (j==3) break; 132 if (0 == owl_keypress_tostring(j, 0, buff2, 1000)) { 133 rev = owl_keypress_fromstring(buff2); 134 sprintf(buff, "%s : 0x%x 0%o %d %d %s\n", buff2, j, j, j, rev, 135 (j==rev?"matches":"*** WARNING: Does Not Reverse")); 136 } else { 137 sprintf(buff, "UNKNOWN : 0x%x 0%o %d\n", j, j, j); 138 } 139 addstr(buff); 140 } 141 endwin(); 142 } 143 8 144 9 145 #define OWL_DICT_NTESTS 20 … … 19 155 20 156 int numfailures=0; 21 printf("1..%d\n", OWL_UTIL_NTESTS+OWL_DICT_NTESTS+OWL_VARIABLE_NTESTS 22 +OWL_FILTER_NTESTS+OWL_OBARRAY_NTESTS); 23 numfailures += owl_util_regtest(); 24 numfailures += owl_dict_regtest(); 25 numfailures += owl_variable_regtest(); 26 numfailures += owl_filter_regtest(); 27 numfailures += owl_obarray_regtest(); 28 if (numfailures) { 157 if (argc==1 || (argc==2 && 0==strcmp(argv[1],"reg"))) { 158 printf("1..%d\n", OWL_UTIL_NTESTS+OWL_DICT_NTESTS+OWL_VARIABLE_NTESTS 159 +OWL_FILTER_NTESTS+OWL_OBARRAY_NTESTS); 160 numfailures += owl_util_regtest(); 161 numfailures += owl_dict_regtest(); 162 numfailures += owl_variable_regtest(); 163 numfailures += owl_filter_regtest(); 164 numfailures += owl_obarray_regtest(); 165 if (numfailures) { 29 166 fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures); 167 } 168 return(numfailures); 169 } else if (argc==2 && 0==strcmp(argv[1],"test1")) { 170 test1(); 171 } else if (argc==2 && 0==strcmp(argv[1],"colorinfo")) { 172 colorinfo(); 173 } else if (argc==2 && 0==strcmp(argv[1],"test4")) { 174 test4(); 175 } else if (argc==2 && 0==strcmp(argv[1],"keypress")) { 176 test_keypress(); 177 } else { 178 fprintf(stderr, "No test specified. Current options are: reg test1\n"); 30 179 } 31 return( numfailures);180 return(0); 32 181 } -
util.c
r6eaf35b r601733d 373 373 374 374 if (days>0) { 375 out=owl_sprintf("%i d %2.2i:%2.2 li", days, hours, run);375 out=owl_sprintf("%i d %2.2i:%2.2i", days, hours, run); 376 376 } else { 377 out=owl_sprintf(" %2.2i:%2.2 li", hours, run);377 out=owl_sprintf(" %2.2i:%2.2i", hours, run); 378 378 } 379 379 return(out); -
variable.c
r160d3f4 r451db9e 351 351 " the cursor will be near the center.\n", 352 352 "normal,top,neartop,center,paged,pagedcenter" ), 353 354 OWLVAR_ENUM( "webbrowser" /* %OwlVarStub */, OWL_WEBBROWSER_NETSCAPE, 355 "web browser to use to launch URLs", 356 "When the 'w' key is pressed, this browser is used\n" 357 "to display the requested URL.\n", 358 "none,netscape,galeon,opera" ), 353 359 354 360 … … 1050 1056 FAIL_UNLESS("get int 7", 9==owl_variable_get_int(&vd,"typewinsize")); 1051 1057 1058 FAIL_UNLESS("get enum", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser")); 1059 FAIL_UNLESS("get enum as string 1", 0==owl_variable_get_tostring(&vd,"webbrowser", buf, 1024)); 1060 FAIL_UNLESS("get enum as string 2", 0==strcmp(buf,"netscape")); 1061 FAIL_UNLESS("set enum 1", 0==owl_variable_set_int(&vd,"webbrowser",OWL_WEBBROWSER_GALEON)); 1062 FAIL_UNLESS("get enum 2", OWL_WEBBROWSER_GALEON==owl_variable_get_int(&vd,"webbrowser")); 1063 FAIL_UNLESS("set enum 1b", -1==owl_variable_set_int(&vd,"webbrowser",-3)); 1064 FAIL_UNLESS("set enum 1b", -1==owl_variable_set_int(&vd,"webbrowser",209)); 1065 FAIL_UNLESS("get enum 2b", OWL_WEBBROWSER_GALEON==owl_variable_get_int(&vd,"webbrowser")); 1066 FAIL_UNLESS("set enum 3", 0==owl_variable_set_fromstring(&vd,"webbrowser","none",0,0)); 1067 FAIL_UNLESS("get enum 4", OWL_WEBBROWSER_NONE==owl_variable_get_int(&vd,"webbrowser")); 1068 FAIL_UNLESS("set enum 5", 0==owl_variable_set_fromstring(&vd,"webbrowser","netscape",0,0)); 1069 FAIL_UNLESS("get enum 6", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser")); 1070 FAIL_UNLESS("set enum 7", -1==owl_variable_set_fromstring(&vd,"webbrowser","xxx",0,0)); 1071 FAIL_UNLESS("set enum 8", -1==owl_variable_set_fromstring(&vd,"webbrowser","",0,0)); 1072 FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0,0)); 1073 FAIL_UNLESS("get enum 10", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser")); 1074 1052 1075 owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval"); 1053 1076 FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar", OWL_VARIABLE_STRING))); -
wcwidth.c
r44fc93b r47519e1b 62 62 #include <wchar.h> 63 63 64 st ruct interval { /* noproto */64 static struct interval { 65 65 int first; 66 66 int last; -
zcrypt.c
r5547211b r34509d5 375 375 376 376 for (i = 0; i < 8; i++) { 377 sprintf(out + strlen(out), "%c", ((output[i] & 0xf0) >> 4) + BASE_CODE);378 sprintf(out + strlen(out), "%c", (output[i] & 0x0f) + BASE_CODE);377 sprintf(out, "%s%c", out, ((output[i] & 0xf0) >> 4) + BASE_CODE); 378 sprintf(out, "%s%c", out, (output[i] & 0x0f) + BASE_CODE); 379 379 } 380 380 -
zephyr.c
r5547211b r451db9e 814 814 ZGetLocations(&locations,&one); 815 815 myuser=short_zuser(user); 816 sprintf(out + strlen(out), "%s: %s\t%s\t%s\n", myuser,816 sprintf(out, "%s%s: %s\t%s\t%s\n", out, myuser, 817 817 locations.host ? locations.host : "?", 818 818 locations.tty ? locations.tty : "?", -
zwrite.c
r5547211b r3f3ee61 231 231 for (i=0; i<j; i++) { 232 232 if (strcmp(z->realm, "")) { 233 sprintf(toline + strlen(toline), "%s@%s ", (char *) owl_list_get_element(&(z->recips), i), z->realm);233 sprintf(toline, "%s%s@%s ", toline, (char *) owl_list_get_element(&(z->recips), i), z->realm); 234 234 } else { 235 sprintf(toline + strlen(toline), "%s ", (char *) owl_list_get_element(&(z->recips), i));235 sprintf(toline, "%s%s ", toline, (char *) owl_list_get_element(&(z->recips), i)); 236 236 } 237 237 }
Note: See TracChangeset
for help on using the changeset viewer.