Changes in functions.c [4fd211f:259e60a8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
functions.c
r4fd211f 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 */ … … 1408 1408 #ifdef HAVE_LIBZEPHYR 1409 1409 if (owl_message_is_direction_in(m)) { 1410 char * ptr, tmpbuff[1024];1411 int i, j, fields, len;1410 char *tmpbuff; 1411 int i, fields; 1412 1412 1413 1413 n=owl_message_get_notice(m); … … 1453 1453 owl_fmtext_appendf_normal(&fm, " Fields : %i\n", fields); 1454 1454 1455 for (i=0; i<fields; i++) { 1456 ptr=owl_zephyr_get_field_as_utf8(n, i+1); 1457 len=strlen(ptr); 1458 if (len<30) { 1459 strncpy(tmpbuff, ptr, len); 1460 tmpbuff[len]='\0'; 1461 } else { 1462 strncpy(tmpbuff, ptr, 30); 1463 tmpbuff[30]='\0'; 1464 strcat(tmpbuff, "..."); 1465 } 1466 g_free(ptr); 1467 1468 for (j=0; j<strlen(tmpbuff); j++) { 1469 if (tmpbuff[j]=='\n') tmpbuff[j]='~'; 1470 if (tmpbuff[j]=='\r') tmpbuff[j]='!'; 1471 } 1472 1473 owl_fmtext_appendf_normal(&fm, " Field %i : %s\n", i+1, tmpbuff); 1455 for (i = 0; i < fields; i++) { 1456 tmpbuff = owl_zephyr_get_field_as_utf8(n, i + 1); 1457 1458 g_strdelimit(tmpbuff, "\n", '~'); 1459 g_strdelimit(tmpbuff, "\r", '!'); 1460 1461 owl_fmtext_appendf_normal(&fm, " Field %i : %s\n", i + 1, tmpbuff); 1462 g_free(tmpbuff); 1474 1463 } 1475 1464 owl_fmtext_appendf_normal(&fm, " Default Fm: %s\n", n->z_default_format); … … 1817 1806 owl_global_get_cols(&g)); 1818 1807 1819 if ( owl_global_get_hascolors(&g)) {1808 if (has_colors()) { 1820 1809 owl_fmtext_append_normal(&fm, "Color: Yes\n"); 1821 owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_ global_get_colorpairs(&g));1810 owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_util_get_colorpairs()); 1822 1811 owl_fmtext_appendf_normal(&fm, "Can change colors: %s\n", can_change_color() ? "yes" : "no"); 1823 1812 } else { … … 2226 2215 f = fl->data; 2227 2216 owl_fmtext_append_normal(&fm, " "); 2228 if (owl_global_get_hascolors(&g)) { 2229 owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_fgcolor(f), owl_filter_get_bgcolor(f)); 2230 } else { 2231 owl_fmtext_append_normal(&fm, owl_filter_get_name(f)); 2232 } 2217 owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), 2218 owl_filter_get_fgcolor(f), 2219 owl_filter_get_bgcolor(f)); 2233 2220 owl_fmtext_append_normal(&fm, "\n"); 2234 2221 } … … 2360 2347 done: 2361 2348 g_free(class); 2362 if (instance) { 2363 g_free(instance); 2364 } 2349 g_free(instance); 2365 2350 return(filtname); 2366 2351 } … … 2523 2508 2524 2509 filtname = g_strdup_printf("conversation-%s", ccs); 2525 owl_text_tr(filtname, ' ', '-');2510 g_strdelimit(filtname, " ", '-'); 2526 2511 2527 2512 if (owl_global_get_filter(&g, filtname)) { … … 2785 2770 void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction) 2786 2771 { 2787 G String *buf;2772 GPtrArray *argv; 2788 2773 char *quoted; 2789 2774 2790 buf = g_string_new("");2775 argv = g_ptr_array_new(); 2791 2776 if (!strcmp(class, "*")) { 2792 g_string_append(buf, "class .*"); 2777 g_ptr_array_add(argv, g_strdup("class")); 2778 g_ptr_array_add(argv, g_strdup(".*")); 2793 2779 } else { 2794 2780 quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2795 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)); 2796 2783 g_free(quoted); 2797 2784 } 2798 2785 if (!strcmp(inst, "*")) { 2799 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(".*")); 2800 2789 } else { 2801 2790 quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2802 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)); 2803 2794 g_free(quoted); 2804 2795 } 2805 2796 if (!strcmp(recip, "*")) { 2806 /* g_string_append(buf, "");*/2797 /* nothing */ 2807 2798 } else { 2808 2799 if(!strcmp(recip, "%me%")) { … … 2810 2801 } 2811 2802 quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2812 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)); 2813 2806 g_free(quoted); 2814 2807 } 2815 2808 2816 owl_function_punt(buf->str, direction); 2817 g_string_free(buf, true); 2818 } 2819 2820 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) 2821 2815 { 2822 2816 owl_filter *f; … … 2826 2820 2827 2821 /* first, create the filter */ 2828 owl_function_debugmsg("About to filter %s", filter); 2829 f = owl_filter_new_fromstring("punt-filter", filter); 2822 f = owl_filter_new("punt-filter", argc, argv); 2830 2823 if (f == NULL) { 2831 2824 owl_function_error("Error creating filter for zpunt"); … … 2854 2847 } 2855 2848 2856 owl_function_debugmsg("punting");2857 /* If we're punting, add the filter to the global punt list */2858 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 */ 2859 2852 owl_list_append_element(fl, f); 2860 } 2853 } else if (direction == 1) { 2854 owl_function_makemsg("No matching punt filter"); 2855 } 2861 2856 } 2862 2857 … … 2995 2990 i--; 2996 2991 } 2997 owl_function_mask_sigint(NULL); 2998 if(owl_global_is_interrupted(&g)) { 2999 owl_global_unset_interrupted(&g); 3000 owl_function_unmask_sigint(NULL); 2992 if (owl_global_take_interrupt(&g)) { 3001 2993 owl_function_makemsg("Search interrupted!"); 3002 2994 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 3003 2995 return; 3004 2996 } 3005 owl_function_unmask_sigint(NULL);3006 2997 } 3007 2998 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 3086 3077 ret=ZLocateUser(zstr(user), &numlocs, ZAUTH); 3087 3078 3088 owl_function_mask_sigint(NULL); 3089 if(owl_global_is_interrupted(&g)) { 3079 if (owl_global_take_interrupt(&g)) { 3090 3080 interrupted = 1; 3091 owl_global_unset_interrupted(&g);3092 owl_function_unmask_sigint(NULL);3093 3081 owl_function_makemsg("Interrupted!"); 3094 3082 break; 3095 3083 } 3096 3097 owl_function_unmask_sigint(NULL);3098 3084 3099 3085 if (ret!=ZERR_NONE) { … … 3256 3242 filename=owl_global_get_startupfile(&g); 3257 3243 3258 /* delete earlier copies */ 3259 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); 3260 3247 3261 3248 file=fopen(filename, "a"); … … 3500 3487 } 3501 3488 3502 void owl_function_mask_sigint(sigset_t *oldmask) {3503 sigset_t intr;3504 3505 sigemptyset(&intr);3506 sigaddset(&intr, SIGINT);3507 sigprocmask(SIG_BLOCK, &intr, oldmask);3508 }3509 3510 void owl_function_unmask_sigint(sigset_t *oldmask) {3511 sigset_t intr;3512 3513 sigemptyset(&intr);3514 sigaddset(&intr, SIGINT);3515 sigprocmask(SIG_UNBLOCK, &intr, oldmask);3516 }3517 3518 3489 void _owl_function_mark_message(const owl_message *m) 3519 3490 {
Note: See TracChangeset
for help on using the changeset viewer.