Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

urlmatch.c File Reference

Declares functions to match URLs against URL patterns. More...


Functions

void free_http_request (struct http_request *http)
jb_err parse_http_url (const char *url, struct http_request *http, struct client_state *csp)
jb_err parse_http_request (const char *req, struct http_request *http, struct client_state *csp)
int simple_domaincmp (char **pv, char **fv, int len)
int domain_match (const struct url_spec *pattern, const struct http_request *fqdn)
jb_err create_url_spec (struct url_spec *url, const char *buf)
void free_url_spec (struct url_spec *url)
int url_match (const struct url_spec *pattern, const struct http_request *url)

Variables

const char urlmatch_rcs [] = "$Id: urlmatch.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"
const char urlmatch_h_rcs [] = URLMATCH_H_VERSION


Detailed Description

Declares functions to match URLs against URL patterns.

Log:
urlmatch.c,v
Revision 2.0 2002/06/04 14:34:21 jongfoster Moving source files to src/

Revision 1.10 2002/05/12 21:40:37 jongfoster

Revision 1.9 2002/04/04 00:36:36 gliptak always use pcre for matching

Revision 1.8 2002/04/03 23:32:47 jongfoster Fixing memory leak on error

Revision 1.7 2002/03/26 22:29:55 swa we have a new homepage!

Revision 1.6 2002/03/24 13:25:43 swa name change related issues

Revision 1.5 2002/03/13 00:27:05 jongfoster Killing warnings

Revision 1.4 2002/03/07 03:46:17 oes Fixed compiler warnings

Revision 1.3 2002/03/03 14:51:11 oes Fixed CLF logging: Added ocmd member for client's request to struct http_request

Revision 1.2 2002/01/21 00:14:09 jongfoster Correcting comment style Fixing an uninitialized memory bug in create_url_spec()

Revision 1.1 2002/01/17 20:53:46 jongfoster Moving all our URL and URL pattern parsing code to the same file - it was scattered around in filters.c, loaders.c and parsers.c.

Providing a single, simple url_match(pattern,url) function - rather than the 3-line match routine which was repeated all over the place.

Renaming free_url to free_url_spec, since it frees a struct url_spec.

Providing parse_http_url() so that URLs can be parsed without faking a HTTP request line for parse_http_request() or repeating the parsing code (both of which were techniques that were actually in use).

Standardizing that struct http_request is used to represent a URL, and struct url_spec is used to represent a URL pattern. (Before, URLs were represented as seperate variables and a partially-filled-in url_spec).


Function Documentation

jb_err create_url_spec struct url_spec   url,
const char *    buf
 

Creates a "url_spec" structure from a string.

When finished, free with unload_url().

Parameters:
url  Target url_spec to be filled in. Will be zeroed before use.
buf  Source pattern, null terminated. NOTE: The contents of this buffer are destroyed by this function. If this function succeeds, the buffer is copied to url->spec. If this function fails, the contents of the buffer are lost forever.
Returns:
JB_ERR_OK - Success JB_ERR_MEMORY - Out of memory JB_ERR_PARSE - Cannot parse regex (Detailed message written to system log)

int domain_match const struct url_spec   pattern,
const struct http_request   fqdn
[static]
 

Domain-wise Compare fqdn's.

Governed by the bimap in pattern->unachored, the comparison is un-, left-, right-anchored, or both. The individual domain names are compared with simplematch().

Parameters:
pattern  a domain that may contain a '*' as a wildcard.
fqdn  domain name against which the patterns are compared.
Returns:
0 => domains are equivalent, else no match.

void free_http_request struct http_request   http
 

Freez a http_request structure.

Parameters:
http  points to a http_request structure to free
Returns:
N/A

void free_url_spec struct url_spec   url
 

Called from the "unloaders".

Freez the url structure elements.

Parameters:
url  pointer to a url_spec structure.
Returns:
N/A

jb_err parse_http_request const char *    req,
struct http_request   http,
struct client_state   csp
 

Parse out the host and port from the URL.

Find the hostname & path, port (if ':'), and/or password (if '@')

Parameters:
req  HTTP request line to break down
http  pointer to the http structure to hold elements
csp  Current client state (buffers, headers, etc...)
Returns:
JB_ERR_OK on success JB_ERR_MEMORY on out of memory JB_ERR_CGI_PARAMS on malformed command/URL or >100 domains deep.

jb_err parse_http_url const char *    url,
struct http_request   http,
struct client_state   csp
 

Parse out the host and port from the URL.

Find the hostname & path, port (if ':'), and/or password (if '@')

Parameters:
url  URL (or is it URI?) to break down
http  pointer to the http structure to hold elements. Will be zeroed before use. Note that this function sets the http->gpc and http->ver members to NULL.
csp  Current client state (buffers, headers, etc...)
Returns:
JB_ERR_OK on success JB_ERR_MEMORY on out of memory JB_ERR_CGI_PARAMS on malformed command/URL or >100 domains deep.

int simple_domaincmp char **    pv,
char **    fv,
int    len
[static]
 

Domain-wise Compare fqdn's.

The comparison is both left- and right-anchored. The individual domain names are compared with simplematch(). This is only used by domain_match.

Parameters:
pv  array of patterns to compare
fv  array of domain components to compare
len  length of the arrays (both arrays are the same length - if they weren't, it couldn't possibly be a match).
Returns:
0 => domains are equivalent, else no match.

int url_match const struct url_spec   pattern,
const struct http_request   url
 

Compare a URL against a URL pattern.

Parameters:
pattern  a URL pattern
url  URL to match
Returns:
0 iff the URL matches the pattern, else nonzero.


Variable Documentation

const char urlmatch_h_rcs[] = URLMATCH_H_VERSION
 

Version information about urlmatch.h.

const char urlmatch_rcs[] = "$Id: urlmatch.c,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"
 

Version information about urlmatch.c.


Generated on Tue Jun 4 18:54:49 2002 for Privoxy 3.1.1 by doxygen1.2.15