Changes in functions.c [3939268:34509d5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r3939268 r34509d5 580 580 581 581 if (i>owl_view_get_size(v)-1) i=owl_view_get_size(v)-1; 582 if (i<0) i=0;583 582 584 583 if (!found) { … … 849 848 { 850 849 int ret, ret2; 851 char *foo , *path;850 char *foo; 852 851 853 852 if (file==NULL) { 854 853 ret=owl_zephyr_loadsubs(NULL, 0); 855 854 } else { 856 path = owl_util_makepath(file); 857 ret=owl_zephyr_loadsubs(path, 1); 858 free(path); 855 ret=owl_zephyr_loadsubs(file, 1); 859 856 } 860 857 … … 2060 2057 /* if it's a zephyr we sent, send it out the same way again */ 2061 2058 if (owl_message_is_direction_out(m)) { 2062 buff = owl_strdup(owl_message_get_zwriteline(m)); 2059 owl_function_zwrite_setup(owl_message_get_zwriteline(m)); 2060 owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m)); 2061 return; 2062 } 2063 2064 /* Special case a personal reply to a webzephyr user on a class */ 2065 if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) { 2066 class=OWL_WEBZEPHYR_CLASS; 2067 inst=owl_message_get_sender(m); 2068 to=OWL_WEBZEPHYR_PRINCIPAL; 2069 } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) { 2070 /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */ 2071 class=OWL_WEBZEPHYR_CLASS; 2072 inst=owl_message_get_instance(m); 2073 to=OWL_WEBZEPHYR_PRINCIPAL; 2074 } else if (owl_message_is_loginout(m)) { 2075 /* Normal LOGIN/LOGOUT messages */ 2076 class="MESSAGE"; 2077 inst="PERSONAL"; 2078 to=owl_message_get_sender(m); 2079 } else if (type==1) { 2080 /* Personal reply */ 2081 class="MESSAGE"; 2082 inst="PERSONAL"; 2083 to=owl_message_get_sender(m); 2063 2084 } else { 2064 2065 /* Special case a personal reply to a webzephyr user on a class */ 2066 if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) { 2067 class=OWL_WEBZEPHYR_CLASS; 2068 inst=owl_message_get_sender(m); 2069 to=OWL_WEBZEPHYR_PRINCIPAL; 2070 } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) { 2071 /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */ 2072 class=OWL_WEBZEPHYR_CLASS; 2073 inst=owl_message_get_instance(m); 2074 to=OWL_WEBZEPHYR_PRINCIPAL; 2075 } else if (owl_message_is_loginout(m)) { 2076 /* Normal LOGIN/LOGOUT messages */ 2077 class="MESSAGE"; 2078 inst="PERSONAL"; 2079 to=owl_message_get_sender(m); 2080 } else if (type==1) { 2081 /* Personal reply */ 2082 class="MESSAGE"; 2083 inst="PERSONAL"; 2084 to=owl_message_get_sender(m); 2085 } else { 2086 /* General reply */ 2087 class=owl_message_get_class(m); 2088 inst=owl_message_get_instance(m); 2089 to=owl_message_get_recipient(m); 2090 cc=owl_message_get_cc_without_recipient(m); 2091 if (!strcmp(to, "") || !strcmp(to, "*")) { 2092 to=""; 2093 } else if (to[0]=='@') { 2094 /* leave it, to get the realm */ 2095 } else { 2096 to=owl_message_get_sender(m); 2097 } 2098 } 2099 2100 /* create the command line */ 2101 if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) { 2102 buff=owl_strdup("zcrypt"); 2103 } else { 2104 buff = owl_strdup("zwrite"); 2105 } 2106 if (strcasecmp(class, "message")) { 2107 buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class)); 2108 owl_free(oldbuff); 2109 } 2110 if (strcasecmp(inst, "personal")) { 2111 buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst)); 2112 owl_free(oldbuff); 2113 } 2114 if (*to != '\0') { 2115 char *tmp, *oldtmp, *tmp2; 2116 tmp=short_zuser(to); 2117 if (cc) { 2118 tmp = owl_util_uniq(oldtmp=tmp, cc, "-"); 2119 owl_free(oldtmp); 2120 buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp); 2121 owl_free(oldbuff); 2122 } else { 2123 if (owl_global_is_smartstrip(&g)) { 2124 tmp2=tmp; 2125 tmp=owl_zephyr_smartstripped_user(tmp2); 2126 owl_free(tmp2); 2127 } 2128 buff = owl_sprintf("%s %s", oldbuff=buff, tmp); 2129 owl_free(oldbuff); 2130 } 2131 owl_free(tmp); 2132 } 2133 if (cc) owl_free(cc); 2085 /* General reply */ 2086 class=owl_message_get_class(m); 2087 inst=owl_message_get_instance(m); 2088 to=owl_message_get_recipient(m); 2089 cc=owl_message_get_cc_without_recipient(m); 2090 if (!strcmp(to, "") || !strcmp(to, "*")) { 2091 to=""; 2092 } else if (to[0]=='@') { 2093 /* leave it, to get the realm */ 2094 } else { 2095 to=owl_message_get_sender(m); 2096 } 2134 2097 } 2098 2099 /* create the command line */ 2100 if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) { 2101 buff=owl_strdup("zcrypt"); 2102 } else { 2103 buff = owl_strdup("zwrite"); 2104 } 2105 if (strcasecmp(class, "message")) { 2106 buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class)); 2107 owl_free(oldbuff); 2108 } 2109 if (strcasecmp(inst, "personal")) { 2110 buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst)); 2111 owl_free(oldbuff); 2112 } 2113 if (*to != '\0') { 2114 char *tmp, *oldtmp, *tmp2; 2115 tmp=short_zuser(to); 2116 if (cc) { 2117 tmp = owl_util_uniq(oldtmp=tmp, cc, "-"); 2118 owl_free(oldtmp); 2119 buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp); 2120 owl_free(oldbuff); 2121 } else { 2122 if (owl_global_is_smartstrip(&g)) { 2123 tmp2=tmp; 2124 tmp=owl_zephyr_smartstripped_user(tmp2); 2125 owl_free(tmp2); 2126 } 2127 buff = owl_sprintf("%s %s", oldbuff=buff, tmp); 2128 owl_free(oldbuff); 2129 } 2130 owl_free(tmp); 2131 } 2132 if (cc) owl_free(cc); 2135 2133 } else if (owl_message_is_type_aim(m)) { 2136 2134 /* aim */ … … 2559 2557 for (i=0; i<j; i++) { 2560 2558 f=owl_list_get_element(fl, i); 2561 snprintf(buff, sizeof(buff), "[% 2d] ", i+1);2562 owl_fmtext_append_normal(&fm, buff);2563 2559 owl_filter_print(f, buff); 2564 2560 owl_fmtext_append_normal(&fm, buff); … … 2626 2622 sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass); 2627 2623 if (tmpinstance) { 2628 sprintf(argbuff, "%s and ( instance ^ (un)*%s(\\.d)*$ )", argbuff, tmpinstance);2624 sprintf(argbuff, "%s and ( instance ^%s(\\.d)*$ )", argbuff, tmpinstance); 2629 2625 } 2630 2626 owl_free(tmpclass); … … 2674 2670 2675 2671 argbuff=owl_malloc(strlen(longuser)+1000); 2676 sprintf(argbuff, "( type ^zephyr$ and filter personaland ");2672 sprintf(argbuff, "( type ^zephyr$ and ( class ^message$ and instance ^personal$ and "); 2677 2673 sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser); 2678 sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) ) ", argbuff, longuser);2674 sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) ) )", argbuff, longuser); 2679 2675 2680 2676 owl_filter_init_fromstring(f, filtname, argbuff); … … 2804 2800 owl_message *m; 2805 2801 char *zperson, *filtname=NULL; 2806 char *argv[1];2807 2802 2808 2803 v=owl_global_get_current_view(&g); … … 2836 2831 /* narrow personal and login messages to the sender or recip as appropriate */ 2837 2832 if (owl_message_is_type_zephyr(m)) { 2838 if (owl_message_is_p ersonal(m) || owl_message_is_loginout(m)) {2833 if (owl_message_is_private(m) || owl_message_is_loginout(m)) { 2839 2834 if (owl_message_is_direction_in(m)) { 2840 2835 zperson=short_zuser(owl_message_get_sender(m)); … … 2863 2858 2864 2859 /* pass it off to perl */ 2860 char *argv[1]; 2865 2861 if(type) { 2866 2862 argv[0] = "-i"; … … 3020 3016 void owl_function_zpunt(char *class, char *inst, char *recip, int direction) 3021 3017 { 3018 owl_filter *f; 3019 owl_list *fl; 3022 3020 char *buff; 3023 3021 char *quoted; 3024 3025 buff=malloc(strlen(class)+strlen(inst)+strlen(recip)+100); 3022 int ret, i, j; 3023 3024 fl=owl_global_get_puntlist(&g); 3025 3026 /* first, create the filter */ 3027 f=owl_malloc(sizeof(owl_filter)); 3028 buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100); 3026 3029 strcpy(buff, "class"); 3027 3030 if (!strcmp(class, "*")) { … … 3053 3056 owl_free(quoted); 3054 3057 } 3055 3056 owl_function_punt(buff, direction); 3058 3059 owl_function_debugmsg("About to filter %s", buff); 3060 ret=owl_filter_init_fromstring(f, "punt-filter", buff); 3057 3061 owl_free(buff); 3058 }3059 3060 void owl_function_punt(char *filter, int direction)3061 {3062 owl_filter *f;3063 owl_list *fl;3064 int ret, i, j;3065 fl=owl_global_get_puntlist(&g);3066 3067 /* first, create the filter */3068 f=malloc(sizeof(owl_filter));3069 3070 owl_function_debugmsg("About to filter %s", filter);3071 ret=owl_filter_init_fromstring(f, "punt-filter", filter);3072 3062 if (ret) { 3073 3063 owl_function_error("Error creating filter for zpunt"); … … 3080 3070 for (i=0; i<j; i++) { 3081 3071 if (owl_filter_equiv(f, owl_list_get_element(fl, i))) { 3082 owl_function_debugmsg("found an equivalent punt filter");3083 3072 /* if we're punting, then just silently bow out on this duplicate */ 3084 3073 if (direction==0) { … … 3091 3080 owl_filter_free(owl_list_get_element(fl, i)); 3092 3081 owl_list_remove_element(fl, i); 3093 owl_filter_free(f);3094 3082 return; 3095 3083 } … … 3097 3085 } 3098 3086 3099 owl_function_debugmsg("punting");3100 3087 /* If we're punting, add the filter to the global punt list */ 3101 3088 if (direction==0) { … … 3327 3314 if (ret==0) { 3328 3315 for (x=0; x<numlocs; x++) { 3329 line= malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100);3316 line=owl_malloc(strlen(location[x].host)+strlen(location[x].time)+strlen(location[x].tty)+100); 3330 3317 tmp=short_zuser(user); 3331 3318 sprintf(line, " %-10.10s %-24.24s %-12.12s %20.20s\n", … … 3433 3420 _exit(127); 3434 3421 } 3435 parsed= realloc(parsed, sizeof(*parsed) * (myargc+1));3422 parsed=owl_realloc(parsed, sizeof(*parsed) * (myargc+1)); 3436 3423 parsed[myargc] = NULL; 3437 3424 … … 3474 3461 char *filename; 3475 3462 3476 filename=owl_ global_get_startupfile(&g);3463 filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE); 3477 3464 file=fopen(filename, "a"); 3478 3465 if (!file) { 3479 3466 owl_function_error("Error opening startupfile for new command"); 3467 owl_free(filename); 3480 3468 return; 3481 3469 } … … 3483 3471 /* delete earlier copies */ 3484 3472 owl_util_file_deleteline(filename, buff, 1); 3473 owl_free(filename); 3485 3474 3486 3475 /* add this line */ … … 3494 3483 { 3495 3484 char *filename; 3496 filename=owl_ global_get_startupfile(&g);3485 filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE); 3497 3486 owl_util_file_deleteline(filename, buff, 1); 3487 owl_free(filename); 3498 3488 } 3499 3489 … … 3507 3497 3508 3498 if (!filename) { 3509 filename=owl_ global_get_startupfile(&g);3499 filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE); 3510 3500 file=fopen(filename, "r"); 3501 owl_free(filename); 3511 3502 } else { 3512 3503 file=fopen(filename, "r");
Note: See TracChangeset
for help on using the changeset viewer.