Changes in / [f1c845b:b848e30]


Ignore:
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r697221f r3b8a563  
    281281  OWLCMD_ARGS("punt", owl_command_punt, OWL_CTX_ANY,
    282282              "suppress an arbitrary filter",
    283               "punt <filter-name>\n"
    284               "punt <filter-text (multiple words)>",
     283              "punt <filter-text>",
     284              "punt <filter-text (multiple words)>\n"
    285285              "The punt command will suppress messages to the specified\n"
    286286              "filter\n\n"
     
    289289  OWLCMD_ARGS("unpunt", owl_command_unpunt, OWL_CTX_ANY,
    290290              "remove an entry from the punt list",
    291               "unpunt <number>\n"
    292               "unpunt <filter-name>\n"
    293               "unpunt <filter-text (multiple words)>",
     291              "unpunt <filter-text>\n"
     292              "unpunt <filter-text>\n"
     293              "unpunt <number>\n",
    294294              "The unpunt command will remove an entry from the puntlist.\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"
     295              "The first two forms correspond to the first two forms of the :punt\n"
     296              "command. The latter allows you to remove a specific entry from the\n"
    297297              "the list (see :show zpunts)\n\n"
    298298              "SEE ALSO:  punt, zpunt, zunpunt, show zpunts\n"),
     
    24642464  owl_list * fl;
    24652465  owl_filter * f;
     2466  char * text;
    24662467  int i;
    24672468
     
    24792480        return;
    24802481      } else {
    2481         owl_function_makemsg("No such filter number: %d.", i+1);
     2482        owl_function_error("No such filter number: %d", i+1);
    24822483      }
    24832484    }
    2484     const char *filter[] = {"filter", argv[1]};
    2485     owl_function_punt(2, filter, unpunt);
     2485    text = owl_string_build_quoted("filter %q", argv[1]);
     2486    owl_function_punt(text, unpunt);
     2487    g_free(text);
    24862488  } else {
    2487     /* Pass in argv[1]..argv[argc-1]. */
    2488     owl_function_punt(argc - 1, argv + 1, unpunt);
     2489    owl_function_punt(skiptokens(buff, 1), unpunt);
    24892490  }
    24902491}
  • functions.c

    r697221f r47128d9  
    27812781void owl_function_zpunt(const char *class, const char *inst, const char *recip, int direction)
    27822782{
    2783   GPtrArray *argv;
     2783  GString *buf;
    27842784  char *quoted;
    27852785
    2786   argv = g_ptr_array_new();
     2786  buf = g_string_new("");
    27872787  if (!strcmp(class, "*")) {
    2788     g_ptr_array_add(argv, g_strdup("class"));
    2789     g_ptr_array_add(argv, g_strdup(".*"));
     2788    g_string_append(buf, "class .*");
    27902789  } else {
    27912790    quoted=owl_text_quote(class, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    2792     g_ptr_array_add(argv, g_strdup("class"));
    2793     g_ptr_array_add(argv, g_strdup_printf("^(un)*%s(\\.d)*$", quoted));
     2791    owl_string_appendf_quoted(buf, "class ^(un)*%q(\\.d)*$", quoted);
    27942792    g_free(quoted);
    27952793  }
    27962794  if (!strcmp(inst, "*")) {
    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(".*"));
     2795    g_string_append(buf, " and instance .*");
    28002796  } else {
    28012797    quoted=owl_text_quote(inst, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    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));
     2798    owl_string_appendf_quoted(buf, " and instance ^(un)*%q(\\.d)*$", quoted);
    28052799    g_free(quoted);
    28062800  }
    28072801  if (!strcmp(recip, "*")) {
    2808     /* nothing */
     2802    /* g_string_append(buf, ""); */
    28092803  } else {
    28102804    if(!strcmp(recip, "%me%")) {
     
    28122806    }
    28132807    quoted=owl_text_quote(recip, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    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));
     2808    owl_string_appendf_quoted(buf, " and recipient ^%q$", quoted);
    28172809    g_free(quoted);
    28182810  }
    28192811
    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)
     2812  owl_function_punt(buf->str, direction);
     2813  g_string_free(buf, true);
     2814}
     2815
     2816void owl_function_punt(const char *filter, int direction)
    28262817{
    28272818  owl_filter *f;
     
    28312822
    28322823  /* first, create the filter */
    2833   f = owl_filter_new("punt-filter", argc, argv);
     2824  owl_function_debugmsg("About to filter %s", filter);
     2825  f = owl_filter_new_fromstring("punt-filter", filter);
    28342826  if (f == NULL) {
    28352827    owl_function_error("Error creating filter for zpunt");
     
    28582850  }
    28592851
    2860   if (direction == 0) {
    2861     owl_function_debugmsg("punting");
    2862     /* If we're punting, add the filter to the global punt list */
     2852  owl_function_debugmsg("punting");
     2853  /* If we're punting, add the filter to the global punt list */
     2854  if (direction==0) {
    28632855    owl_list_append_element(fl, f);
    2864   } else if (direction == 1) {
    2865     owl_function_makemsg("No matching punt filter");
    2866  }
     2856  }
    28672857}
    28682858
Note: See TracChangeset for help on using the changeset viewer.