diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-02-16 20:03:40 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-02-16 20:03:40 +0100 |
commit | 39148b1b6dc6c7a10f7e713ece084b6d5cf27537 (patch) | |
tree | 619c9d951b1356bfc8dcaba45a66166972992170 /filter.h |
Initial
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); |