Changes in functions.c [9b70dd4:3f3ee61]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.