918384d458981e7db4aadc283212eb19912d5709Timo Sirainen /* NULL-terminated list of categories */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen /* key=NULL-terminated list of key=value fields */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen /* event name */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen /* source filename:line */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen /* context associated with this query. This is returned when iterating
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen through matched queries. If NULL, the iteration won't return this
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenstruct event_filter *event_filter_create(void);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenvoid event_filter_ref(struct event_filter *filter);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenvoid event_filter_unref(struct event_filter **filter);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Add a new query to the filter. All of the categories and fields in the query
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen need to match, so they're ANDed together. Separate queries are ORed
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenvoid event_filter_add(struct event_filter *filter,
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Add queries from source filter to destination filter. */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenvoid event_filter_merge(struct event_filter *dest,
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Export the filter into a tabescaped string, so its fields are separated
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen with TABs and there are no NUL, CR or LF characters. The context pointers
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen aren't exported. */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenvoid event_filter_export(struct event_filter *filter, string_t *dest);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Add queries to the filter from the given string. The string is expected to
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen be generated by event_filter_export(). Returns TRUE on success, FALSE on
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen invalid string. */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenbool event_filter_import(struct event_filter *filter, const char *str,
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen const char **error_r);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Same as event_filter_import(), but string is already split into an array
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen of strings via *_strsplit_tabescaped(). */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenbool event_filter_import_unescaped(struct event_filter *filter,
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen const char *const *args,
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen const char **error_r);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Returns TRUE if the event matches the event filter. */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenbool event_filter_match(struct event_filter *filter, struct event *event);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Same as event_filter_match(), but use the given source filename:linenum
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen instead of taking it from the event. */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenbool event_filter_match_source(struct event_filter *filter, struct event *event,
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Iterate through all queries that match the event. */
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenevent_filter_match_iter_init(struct event_filter *filter, struct event *event);
918384d458981e7db4aadc283212eb19912d5709Timo Sirainen/* Return context for the query that matched, or NULL when there are no more
918384d458981e7db4aadc283212eb19912d5709Timo Sirainenvoid *event_filter_match_iter_next(struct event_filter_match_iter *iter);