Changes in functions.c [3f3ee61:9b70dd4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r3f3ee61 r9b70dd4 99 99 } 100 100 101 char *owl_function_style_describe( void*name) {101 char *owl_function_style_describe(char *name) { 102 102 char *desc, *s; 103 103 owl_style *style; … … 114 114 } 115 115 116 char *owl_function_cmd_describe( void*name)116 char *owl_function_cmd_describe(char *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_LIBZEPHYR 180 "@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 #endif 185 "@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 174 204 /* Create an admin message, append it to the global list of messages 175 205 * and redisplay if necessary. … … 602 632 603 633 if (!found) { 604 owl_function_makemsg("already at last%s message%s%s ",634 owl_function_makemsg("already at last%s message%s%s%s", 605 635 skip_deleted?" non-deleted":"", 606 filter?" in ":"", filter?filter:""); 636 filter?" in ":"", filter?filter:"", 637 owl_mainwin_is_curmsg_truncated(owl_global_get_mainwin(&g)) ? 638 ", press Enter to scroll" : ""); 607 639 /* if (!skip_deleted) owl_function_beep(); */ 608 640 } … … 1019 1051 owl_function_debugmsg("Quitting Owl"); 1020 1052 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 }1119 1053 } 1120 1054 … … 1610 1544 /* fix this */ 1611 1545 sprintf(buff, " Checkd Ath: %i\n", n->z_checked_auth); 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);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); 1615 1549 owl_fmtext_append_normal(&fm, buff); 1616 1550 … … 1922 1856 void owl_function_status() 1923 1857 { 1924 char buff[ 5000];1858 char buff[MAXPATHLEN+1]; 1925 1859 time_t start; 1926 1860 int up, days, hours, minutes; … … 1942 1876 1943 1877 owl_fmtext_append_normal(&fm, " Current Directory: "); 1944 (void) getcwd(buff, MAXPATHLEN); 1945 owl_fmtext_append_normal(&fm, buff); 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 } 1946 1883 owl_fmtext_append_normal(&fm, "\n"); 1947 1884 … … 2052 1989 return; 2053 1990 } 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; 2054 1997 } 2055 1998 … … 2548 2491 sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass); 2549 2492 if (tmpinstance) { 2550 sprintf(argbuff , "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance);2493 sprintf(argbuff + strlen(argbuff), " and ( instance ^(un)*%s(\\.d)*$ )", tmpinstance); 2551 2494 } 2552 2495 owl_free(tmpclass); … … 2577 2520 { 2578 2521 owl_filter *f; 2579 char *argbuff, *longuser, * shortuser, *filtname;2522 char *argbuff, *longuser, *esclonguser, *shortuser, *filtname; 2580 2523 2581 2524 /* stick the local realm on if it's not there */ … … 2584 2527 2585 2528 /* name for the filter */ 2586 filtname=owl_malloc(strlen(shortuser)+20); 2587 sprintf(filtname, "user-%s", shortuser); 2529 filtname=owl_sprintf("user-%s", shortuser); 2588 2530 2589 2531 /* if it already exists then go with it. This lets users override */ … … 2595 2537 f=owl_malloc(sizeof(owl_filter)); 2596 2538 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); 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); 2601 2545 2602 2546 owl_filter_init_fromstring(f, filtname, argbuff); … … 2608 2552 owl_free(argbuff); 2609 2553 owl_free(longuser); 2554 owl_free(esclonguser); 2610 2555 owl_free(shortuser); 2611 2556 … … 2626 2571 2627 2572 /* name for the filter */ 2628 filtname=owl_malloc(strlen(user)+40); 2629 sprintf(filtname, "aimuser-%s", user); 2573 filtname=owl_sprintf("aimuser-%s", user); 2630 2574 2631 2575 /* if it already exists then go with it. This lets users override */ … … 2639 2583 escuser = owl_text_quote(user, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2640 2584 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); 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)); 2646 2589 2647 2590 owl_filter_init_fromstring(f, filtname, argbuff); … … 2660 2603 { 2661 2604 owl_filter *f; 2662 char *argbuff, *filtname ;2605 char *argbuff, *filtname, *esctype; 2663 2606 2664 2607 /* name for the filter */ … … 2673 2616 f=owl_malloc(sizeof(owl_filter)); 2674 2617 2675 argbuff = owl_sprintf("type ^%s$", type); 2618 esctype = owl_text_quote(type, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2619 2620 argbuff = owl_sprintf("type ^%s$", esctype); 2676 2621 2677 2622 owl_filter_init_fromstring(f, filtname, argbuff); … … 2682 2627 /* free stuff */ 2683 2628 owl_free(argbuff); 2629 owl_free(esctype); 2684 2630 2685 2631 return filtname; … … 2955 2901 owl_text_tr(quoted, '\'', '.'); 2956 2902 owl_text_tr(quoted, '"', '.'); 2957 sprintf(buff , "%s ^(un)*%s(\\.d)*$", buff, quoted);2903 sprintf(buff + strlen(buff), " ^(un)*%s(\\.d)*$", quoted); 2958 2904 owl_free(quoted); 2959 2905 } … … 2965 2911 owl_text_tr(quoted, '\'', '.'); 2966 2912 owl_text_tr(quoted, '"', '.'); 2967 sprintf(buff , "%s and instance ^(un)*%s(\\.d)*$", buff, quoted);2913 sprintf(buff + strlen(buff), " and instance ^(un)*%s(\\.d)*$", quoted); 2968 2914 owl_free(quoted); 2969 2915 } … … 2973 2919 owl_text_tr(quoted, '\'', '.'); 2974 2920 owl_text_tr(quoted, '"', '.'); 2975 sprintf(buff , "%s and recipient ^%s$", buff, quoted);2921 sprintf(buff + strlen(buff), " and recipient ^%s$", quoted); 2976 2922 owl_free(quoted); 2977 2923 } … … 3065 3011 } 3066 3012 3067 char *owl_function_keymap_summary( void*name)3013 char *owl_function_keymap_summary(char *name) 3068 3014 { 3069 3015 owl_keymap *km
Note: See TracChangeset
for help on using the changeset viewer.