From 344af24c2f2771c70470a9bd26828670568f180b Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Fri, 5 Apr 2019 00:13:34 +0100 Subject: [PATCH] filter: add DROP and ABORT --- extensions/filter.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/extensions/filter.c b/extensions/filter.c index cf7907c2..40704554 100644 --- a/extensions/filter.c +++ b/extensions/filter.c @@ -126,7 +126,7 @@ moddeinit(void) mapi_clist_av1 filter_clist[] = { &setfilter_msgtab, NULL }; -DECLARE_MODULE_AV1(filter, modinit, moddeinit, filter_clist, NULL, filter_hfnlist, "0.3"); +DECLARE_MODULE_AV1(filter, modinit, moddeinit, filter_clist, NULL, filter_hfnlist, "0.4"); static int setfilter(const char *check, const char *data, const char **error) @@ -162,6 +162,28 @@ setfilter(const char *check, const char *data, const char **error) return 0; } + if (!strcasecmp(data, "drop")) { + if (!filter_db) { + if (error) *error = "no database to drop"; + return -1; + } + hs_free_database(filter_db); + filter_db = 0; + return 0; + } + + if (!strcasecmp(data, "abort")) { + if (state != FILTER_FILLING) { + if (error) *error = "not filling"; + return -1; + } + state = filter_db ? FILTER_LOADED : FILTER_EMPTY; + rb_free(filter_data); + filter_data = 0; + filter_data_len = 0; + return 0; + } + if (strcmp(check, check_str) != 0) { if (error) *error = "check strings don't match"; return -1;