diff options
Diffstat (limited to 'filter.h')
-rw-r--r-- | filter.h | 29 |
1 files changed, 29 insertions, 0 deletions
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); |