diff options
Diffstat (limited to 'urlmatch.h')
-rw-r--r-- | urlmatch.h | 27 |
1 files changed, 24 insertions, 3 deletions
@@ -2,6 +2,7 @@ #define URL_MATCH_H #include "string-list.h" +#include "config.h" struct url_info { /* normalized url on success, must be freed, otherwise NULL */ @@ -48,10 +49,30 @@ struct urlmatch_config { const char *key; void *cb; - int (*collect_fn)(const char *var, const char *value, void *cb); - int (*cascade_fn)(const char *var, const char *value, void *cb); + config_fn_t collect_fn; + config_fn_t cascade_fn; + /* + * Compare the two matches, the one just discovered and the existing + * best match and return a negative value if the found item is to be + * rejected or a non-negative value if it is to be accepted. If this + * field is set to NULL, use the default comparison technique, which + * checks to ses if found is better (according to the urlmatch + * specificity rules) than existing. + */ + int (*select_fn)(const struct urlmatch_item *found, const struct urlmatch_item *existing); + /* + * An optional callback to allow e.g. for partial URLs; it shall + * return 1 or 0 depending whether `url` matches or not. + */ + int (*fallback_match_fn)(const char *url, void *cb); }; -int urlmatch_config_entry(const char *var, const char *value, void *cb); +#define URLMATCH_CONFIG_INIT { \ + .vars = STRING_LIST_INIT_DUP, \ +} + +int urlmatch_config_entry(const char *var, const char *value, + const struct config_context *ctx, void *cb); +void urlmatch_config_release(struct urlmatch_config *config); #endif /* URL_MATCH_H */ |