#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);