blob: 37ee5da85e2dd3f0ba3ee12d0c515fa6def2a043 [file] [log] [blame]
Kyle J. McKay3402a8d2013-07-31 13:52:00 -07001#ifndef URL_MATCH_H
2#include "string-list.h"
3
4struct url_info {
5 /* normalized url on success, must be freed, otherwise NULL */
6 char *url;
7 /* if !url, a brief reason for the failure, otherwise NULL */
8 const char *err;
9
10 /* the rest of the fields are only set if url != NULL */
11
12 size_t url_len; /* total length of url (which is now normalized) */
13 size_t scheme_len; /* length of scheme name (excluding final :) */
14 size_t user_off; /* offset into url to start of user name (0 => none) */
15 size_t user_len; /* length of user name; if user_off != 0 but
16 user_len == 0, an empty user name was given */
17 size_t passwd_off; /* offset into url to start of passwd (0 => none) */
18 size_t passwd_len; /* length of passwd; if passwd_off != 0 but
19 passwd_len == 0, an empty passwd was given */
20 size_t host_off; /* offset into url to start of host name (0 => none) */
Patrick Steinhardt3ec6e6e2017-01-31 10:01:45 +010021 size_t host_len; /* length of host name;
Kyle J. McKay3402a8d2013-07-31 13:52:00 -070022 * file urls may have host_len == 0 */
Patrick Steinhardt3ec6e6e2017-01-31 10:01:45 +010023 size_t port_off; /* offset into url to start of port number (0 => none) */
24 size_t port_len; /* if a portnum is present (port_off != 0), it has
25 * this length (excluding the leading ':') starting
26 * from port_off (always 0 for file urls) */
Kyle J. McKay3402a8d2013-07-31 13:52:00 -070027 size_t path_off; /* offset into url to the start of the url path;
28 * this will always point to a '/' character
29 * after the url has been normalized */
30 size_t path_len; /* length of path portion excluding any trailing
31 * '?...' and '#...' portion; will always be >= 1 */
32};
33
34extern char *url_normalize(const char *, struct url_info *);
Kyle J. McKay3402a8d2013-07-31 13:52:00 -070035
Junio C Hamano836b6fb2013-07-31 10:42:01 -070036struct urlmatch_item {
Patrick Steinhardtaf990492017-01-31 10:01:46 +010037 size_t hostmatch_len;
38 size_t pathmatch_len;
Junio C Hamano836b6fb2013-07-31 10:42:01 -070039 char user_matched;
40};
41
42struct urlmatch_config {
43 struct string_list vars;
44 struct url_info url;
45 const char *section;
46 const char *key;
47
48 void *cb;
49 int (*collect_fn)(const char *var, const char *value, void *cb);
50 int (*cascade_fn)(const char *var, const char *value, void *cb);
51};
52
53extern int urlmatch_config_entry(const char *var, const char *value, void *cb);
54
Kyle J. McKay3402a8d2013-07-31 13:52:00 -070055#endif /* URL_MATCH_H */