]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add function removing queries from event_filter
authorsergey.kitov <sergey.kitov@open-xchange.com>
Tue, 20 Apr 2021 14:06:26 +0000 (17:06 +0300)
committersergey.kitov <sergey.kitov@open-xchange.com>
Fri, 3 Sep 2021 12:44:32 +0000 (15:44 +0300)
src/lib/event-filter.c
src/lib/event-filter.h

index f720118dad7c856d492c427b2a0d7686f9d9d49f..88a998a6ee66897b17061f5baee7db0cf0b51ee0 100644 (file)
@@ -266,6 +266,22 @@ event_filter_merge_with_context_internal(struct event_filter *dest,
        } T_END;
 }
 
+bool event_filter_remove_queries_with_context(struct event_filter *filter,
+                                             void *context)
+{
+       const struct event_filter_query_internal *int_query;
+       unsigned int idx;
+
+       array_foreach(&filter->queries, int_query) {
+               if (int_query->context == context) {
+                       idx = array_foreach_idx(&filter->queries, int_query);
+                       array_delete(&filter->queries, idx, 1);
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
 void event_filter_merge(struct event_filter *dest,
                        const struct event_filter *src)
 {
index de2d7c78995abaf15c55f9bc274aefcb695e6d8e..0a55e05755d9d075db0637e707859fd3f44c8029 100644 (file)
@@ -22,6 +22,11 @@ void event_filter_merge_with_context(struct event_filter *dest,
                                     const struct event_filter *src,
                                     void *new_context);
 
+/* Remove query with given context from filter.
+   Returns TRUE if query was removed, otherwise FALSE. */
+bool event_filter_remove_queries_with_context(struct event_filter *filter,
+                                             void *context);
+
 /* Export the filter into a string.  The context pointers aren't exported. */
 void event_filter_export(struct event_filter *filter, string_t *dest);
 /* Add queries to the filter from the given string. The string is expected to