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