Changes in functions.c [1081d0f:259e60a8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r1081d0f r259e60a8 32 32 char *rv; 33 33 rv=owl_function_command(cmdbuff); 34 if (rv)g_free(rv);34 g_free(rv); 35 35 } 36 36 … … 453 453 454 454 if (rv || status) { 455 if(cryptmsg)g_free(cryptmsg);455 g_free(cryptmsg); 456 456 g_free(old_msg); 457 457 owl_function_error("Error in zcrypt, possibly no key found. Message not sent."); … … 991 991 /* execute the commands in shutdown */ 992 992 ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();"); 993 if (ret)g_free(ret);993 g_free(ret); 994 994 995 995 /* signal our child process, if any */ … … 2347 2347 done: 2348 2348 g_free(class); 2349 if (instance) { 2350 g_free(instance); 2351 } 2349 g_free(instance); 2352 2350 return(filtname); 2353 2351 } … … 2772 2770 void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction) 2773 2771 { 2774 G String *buf;2772 GPtrArray *argv; 2775 2773 char *quoted; 2776 2774 2777 buf = g_string_new("");2775 argv = g_ptr_array_new(); 2778 2776 if (!strcmp(class, "*")) { 2779 g_string_append(buf, "class .*"); 2777 g_ptr_array_add(argv, g_strdup("class")); 2778 g_ptr_array_add(argv, g_strdup(".*")); 2780 2779 } else { 2781 2780 quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2782 owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted); 2781 g_ptr_array_add(argv, g_strdup("class")); 2782 g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted)); 2783 2783 g_free(quoted); 2784 2784 } 2785 2785 if (!strcmp(inst, "*")) { 2786 g_string_append(buf, " and instance .*"); 2786 g_ptr_array_add(argv, g_strdup("and")); 2787 g_ptr_array_add(argv, g_strdup("instance")); 2788 g_ptr_array_add(argv, g_strdup(".*")); 2787 2789 } else { 2788 2790 quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2789 owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted); 2791 g_ptr_array_add(argv, g_strdup("and")); 2792 g_ptr_array_add(argv, g_strdup("instance")); 2793 g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted)); 2790 2794 g_free(quoted); 2791 2795 } 2792 2796 if (!strcmp(recip, "*")) { 2793 /* g_string_append(buf, "");*/2797 /* nothing */ 2794 2798 } else { 2795 2799 if(!strcmp(recip, "%me%")) { … … 2797 2801 } 2798 2802 quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2799 owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted); 2803 g_ptr_array_add(argv, g_strdup("and")); 2804 g_ptr_array_add(argv, g_strdup("recipient")); 2805 g_ptr_array_add(argv, g_strdup_printf("^%s$", quoted)); 2800 2806 g_free(quoted); 2801 2807 } 2802 2808 2803 owl_function_punt(buf->str, direction); 2804 g_string_free(buf, true); 2805 } 2806 2807 void owl_function_punt(const char *filter, int direction) 2809 owl_function_punt(argv->len, (const char *const*) argv->pdata, direction); 2810 g_ptr_array_foreach(argv, (GFunc)g_free, NULL); 2811 g_ptr_array_free(argv, true); 2812 } 2813 2814 void owl_function_punt(int argc, const char *const *argv, int direction) 2808 2815 { 2809 2816 owl_filter *f; … … 2813 2820 2814 2821 /* first, create the filter */ 2815 owl_function_debugmsg("About to filter %s", filter); 2816 f = owl_filter_new_fromstring("punt-filter", filter); 2822 f = owl_filter_new("punt-filter", argc, argv); 2817 2823 if (f == NULL) { 2818 2824 owl_function_error("Error creating filter for zpunt"); … … 2841 2847 } 2842 2848 2843 owl_function_debugmsg("punting");2844 /* If we're punting, add the filter to the global punt list */2845 if (direction==0) {2849 if (direction == 0) { 2850 owl_function_debugmsg("punting"); 2851 /* If we're punting, add the filter to the global punt list */ 2846 2852 owl_list_append_element(fl, f); 2847 } 2853 } else if (direction == 1) { 2854 owl_function_makemsg("No matching punt filter"); 2855 } 2848 2856 } 2849 2857 … … 2982 2990 i--; 2983 2991 } 2984 owl_function_mask_sigint(NULL); 2985 if(owl_global_is_interrupted(&g)) { 2986 owl_global_unset_interrupted(&g); 2987 owl_function_unmask_sigint(NULL); 2992 if (owl_global_take_interrupt(&g)) { 2988 2993 owl_function_makemsg("Search interrupted!"); 2989 2994 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2990 2995 return; 2991 2996 } 2992 owl_function_unmask_sigint(NULL);2993 2997 } 2994 2998 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 3073 3077 ret=ZLocateUser(zstr(user), &numlocs, ZAUTH); 3074 3078 3075 owl_function_mask_sigint(NULL); 3076 if(owl_global_is_interrupted(&g)) { 3079 if (owl_global_take_interrupt(&g)) { 3077 3080 interrupted = 1; 3078 owl_global_unset_interrupted(&g);3079 owl_function_unmask_sigint(NULL);3080 3081 owl_function_makemsg("Interrupted!"); 3081 3082 break; 3082 3083 } 3083 3084 owl_function_unmask_sigint(NULL);3085 3084 3086 3085 if (ret!=ZERR_NONE) { … … 3243 3242 filename=owl_global_get_startupfile(&g); 3244 3243 3245 /* delete earlier copies */ 3246 owl_util_file_deleteline(filename, buff, 1); 3244 /* delete earlier copies, if the file exists */ 3245 if (g_file_test(filename, G_FILE_TEST_EXISTS)) 3246 owl_util_file_deleteline(filename, buff, 1); 3247 3247 3248 3248 file=fopen(filename, "a"); … … 3487 3487 } 3488 3488 3489 void owl_function_mask_sigint(sigset_t *oldmask) {3490 sigset_t intr;3491 3492 sigemptyset(&intr);3493 sigaddset(&intr, SIGINT);3494 sigprocmask(SIG_BLOCK, &intr, oldmask);3495 }3496 3497 void owl_function_unmask_sigint(sigset_t *oldmask) {3498 sigset_t intr;3499 3500 sigemptyset(&intr);3501 sigaddset(&intr, SIGINT);3502 sigprocmask(SIG_UNBLOCK, &intr, oldmask);3503 }3504 3505 3489 void _owl_function_mark_message(const owl_message *m) 3506 3490 {
Note: See TracChangeset
for help on using the changeset viewer.