Changes in functions.c [259e60a8:1081d0f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r259e60a8 r1081d0f 32 32 char *rv; 33 33 rv=owl_function_command(cmdbuff); 34 g_free(rv);34 if (rv) g_free(rv); 35 35 } 36 36 … … 453 453 454 454 if (rv || status) { 455 g_free(cryptmsg);455 if(cryptmsg) 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 g_free(ret);993 if (ret) g_free(ret); 994 994 995 995 /* signal our child process, if any */ … … 2347 2347 done: 2348 2348 g_free(class); 2349 g_free(instance); 2349 if (instance) { 2350 g_free(instance); 2351 } 2350 2352 return(filtname); 2351 2353 } … … 2770 2772 void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction) 2771 2773 { 2772 G PtrArray *argv;2774 GString *buf; 2773 2775 char *quoted; 2774 2776 2775 argv = g_ptr_array_new();2777 buf = g_string_new(""); 2776 2778 if (!strcmp(class, "*")) { 2777 g_ptr_array_add(argv, g_strdup("class")); 2778 g_ptr_array_add(argv, g_strdup(".*")); 2779 g_string_append(buf, "class .*"); 2779 2780 } else { 2780 2781 quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2781 g_ptr_array_add(argv, g_strdup("class")); 2782 g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted)); 2782 owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted); 2783 2783 g_free(quoted); 2784 2784 } 2785 2785 if (!strcmp(inst, "*")) { 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(".*")); 2786 g_string_append(buf, " and instance .*"); 2789 2787 } else { 2790 2788 quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 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)); 2789 owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted); 2794 2790 g_free(quoted); 2795 2791 } 2796 2792 if (!strcmp(recip, "*")) { 2797 /* nothing*/2793 /* g_string_append(buf, ""); */ 2798 2794 } else { 2799 2795 if(!strcmp(recip, "%me%")) { … … 2801 2797 } 2802 2798 quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 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)); 2799 owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted); 2806 2800 g_free(quoted); 2807 2801 } 2808 2802 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) 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) 2815 2808 { 2816 2809 owl_filter *f; … … 2820 2813 2821 2814 /* first, create the filter */ 2822 f = owl_filter_new("punt-filter", argc, argv); 2815 owl_function_debugmsg("About to filter %s", filter); 2816 f = owl_filter_new_fromstring("punt-filter", filter); 2823 2817 if (f == NULL) { 2824 2818 owl_function_error("Error creating filter for zpunt"); … … 2847 2841 } 2848 2842 2849 if (direction == 0) {2850 owl_function_debugmsg("punting");2851 /* If we're punting, add the filter to the global punt list */2843 owl_function_debugmsg("punting"); 2844 /* If we're punting, add the filter to the global punt list */ 2845 if (direction==0) { 2852 2846 owl_list_append_element(fl, f); 2853 } else if (direction == 1) { 2854 owl_function_makemsg("No matching punt filter"); 2855 } 2847 } 2856 2848 } 2857 2849 … … 2990 2982 i--; 2991 2983 } 2992 if (owl_global_take_interrupt(&g)) { 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); 2993 2988 owl_function_makemsg("Search interrupted!"); 2994 2989 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2995 2990 return; 2996 2991 } 2992 owl_function_unmask_sigint(NULL); 2997 2993 } 2998 2994 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 3077 3073 ret=ZLocateUser(zstr(user), &numlocs, ZAUTH); 3078 3074 3079 if (owl_global_take_interrupt(&g)) { 3075 owl_function_mask_sigint(NULL); 3076 if(owl_global_is_interrupted(&g)) { 3080 3077 interrupted = 1; 3078 owl_global_unset_interrupted(&g); 3079 owl_function_unmask_sigint(NULL); 3081 3080 owl_function_makemsg("Interrupted!"); 3082 3081 break; 3083 3082 } 3083 3084 owl_function_unmask_sigint(NULL); 3084 3085 3085 3086 if (ret!=ZERR_NONE) { … … 3242 3243 filename=owl_global_get_startupfile(&g); 3243 3244 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); 3245 /* delete earlier copies */ 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 3489 3505 void _owl_function_mark_message(const owl_message *m) 3490 3506 {
Note: See TracChangeset
for help on using the changeset viewer.