Changes in / [b848e30:f1c845b]
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
r3b8a563 r697221f 281 281 OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY, 282 282 "suppress an arbitrary filter", 283 "punt <filter- text>",284 "punt <filter-text (multiple words)> \n"283 "punt <filter-name>\n" 284 "punt <filter-text (multiple words)>", 285 285 "The punt command will suppress messages to the specified\n" 286 286 "filter\n\n" … … 289 289 OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY, 290 290 "remove an entry from the punt list", 291 "unpunt < filter-text>\n"292 "unpunt <filter- text>\n"293 "unpunt < number>\n",291 "unpunt <number>\n" 292 "unpunt <filter-name>\n" 293 "unpunt <filter-text (multiple words)>", 294 294 "The unpunt command will remove an entry from the puntlist.\n" 295 "The first two forms correspond to the firsttwo forms of the :punt\n"296 "command. The latter allows you to remove a specific entry from the\n"295 "The last two forms correspond to the two forms of the :punt\n" 296 "command. The first allows you to remove a specific entry from\n" 297 297 "the list (see :show zpunts)\n\n" 298 298 "SEE ALSO: punt, zpunt, zunpunt, show zpunts\n"), … … 2464 2464 owl_list * fl; 2465 2465 owl_filter * f; 2466 char * text;2467 2466 int i; 2468 2467 … … 2480 2479 return; 2481 2480 } else { 2482 owl_function_ error("No such filter number: %d", i+1);2481 owl_function_makemsg("No such filter number: %d.", i+1); 2483 2482 } 2484 2483 } 2485 text = owl_string_build_quoted("filter %q", argv[1]); 2486 owl_function_punt(text, unpunt); 2487 g_free(text); 2484 const char *filter[] = {"filter", argv[1]}; 2485 owl_function_punt(2, filter, unpunt); 2488 2486 } else { 2489 owl_function_punt(skiptokens(buff, 1), unpunt); 2487 /* Pass in argv[1]..argv[argc-1]. */ 2488 owl_function_punt(argc - 1, argv + 1, unpunt); 2490 2489 } 2491 2490 } -
functions.c
r47128d9 r697221f 2781 2781 void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction) 2782 2782 { 2783 G String *buf;2783 GPtrArray *argv; 2784 2784 char *quoted; 2785 2785 2786 buf = g_string_new("");2786 argv = g_ptr_array_new(); 2787 2787 if (!strcmp(class, "*")) { 2788 g_string_append(buf, "class .*"); 2788 g_ptr_array_add(argv, g_strdup("class")); 2789 g_ptr_array_add(argv, g_strdup(".*")); 2789 2790 } else { 2790 2791 quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2791 owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted); 2792 g_ptr_array_add(argv, g_strdup("class")); 2793 g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted)); 2792 2794 g_free(quoted); 2793 2795 } 2794 2796 if (!strcmp(inst, "*")) { 2795 g_string_append(buf, " and instance .*"); 2797 g_ptr_array_add(argv, g_strdup("and")); 2798 g_ptr_array_add(argv, g_strdup("instance")); 2799 g_ptr_array_add(argv, g_strdup(".*")); 2796 2800 } else { 2797 2801 quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2798 owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted); 2802 g_ptr_array_add(argv, g_strdup("and")); 2803 g_ptr_array_add(argv, g_strdup("instance")); 2804 g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted)); 2799 2805 g_free(quoted); 2800 2806 } 2801 2807 if (!strcmp(recip, "*")) { 2802 /* g_string_append(buf, "");*/2808 /* nothing */ 2803 2809 } else { 2804 2810 if(!strcmp(recip, "%me%")) { … … 2806 2812 } 2807 2813 quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); 2808 owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted); 2814 g_ptr_array_add(argv, g_strdup("and")); 2815 g_ptr_array_add(argv, g_strdup("recipient")); 2816 g_ptr_array_add(argv, g_strdup_printf("^%s$", quoted)); 2809 2817 g_free(quoted); 2810 2818 } 2811 2819 2812 owl_function_punt(buf->str, direction); 2813 g_string_free(buf, true); 2814 } 2815 2816 void owl_function_punt(const char *filter, int direction) 2820 owl_function_punt(argv->len, (const char *const*) argv->pdata, direction); 2821 g_ptr_array_foreach(argv, (GFunc)g_free, NULL); 2822 g_ptr_array_free(argv, true); 2823 } 2824 2825 void owl_function_punt(int argc, const char *const *argv, int direction) 2817 2826 { 2818 2827 owl_filter *f; … … 2822 2831 2823 2832 /* first, create the filter */ 2824 owl_function_debugmsg("About to filter %s", filter); 2825 f = owl_filter_new_fromstring("punt-filter", filter); 2833 f = owl_filter_new("punt-filter", argc, argv); 2826 2834 if (f == NULL) { 2827 2835 owl_function_error("Error creating filter for zpunt"); … … 2850 2858 } 2851 2859 2852 owl_function_debugmsg("punting");2853 /* If we're punting, add the filter to the global punt list */2854 if (direction==0) {2860 if (direction == 0) { 2861 owl_function_debugmsg("punting"); 2862 /* If we're punting, add the filter to the global punt list */ 2855 2863 owl_list_append_element(fl, f); 2856 } 2864 } else if (direction == 1) { 2865 owl_function_makemsg("No matching punt filter"); 2866 } 2857 2867 } 2858 2868
Note: See TracChangeset
for help on using the changeset viewer.