From 39148b1b6dc6c7a10f7e713ece084b6d5cf27537 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 16 Feb 2025 20:03:40 +0100 Subject: Initial --- filter.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 filter.h (limited to 'filter.h') diff --git a/filter.h b/filter.h new file mode 100644 index 0000000..2bc41e1 --- /dev/null +++ b/filter.h @@ -0,0 +1,29 @@ +#pragma once + + +enum filter_type { + // FILTER_INCLUDE, // unsupported for now + FILTER_EXCLUDE, +}; + +// A subset of borg patterns +enum pattern_type { + PATTERN_EQUAL, // /str + PATTERN_PREFIX, // /str/** + PATTERN_SUFFIX, // **/str + PATTERN_INFIX, // **/str/** +}; + +struct filter_rule { + enum filter_type ftype; + enum pattern_type ptype; + char *str; + size_t len; // length of str (strlen, but cached) +}; + +struct filter_rule parse_exclude_rule(const char *rule); + +// The path must be relative to the tree root (and thus not start with a '/'). +bool filter_rule_allows(const struct filter_rule rule, const char *path); + +void filter_rule_debugdump(FILE *stream, const struct filter_rule rule); -- cgit v1.2.3-70-g09d2