-const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.63 2011/09/04 11:37:05 fabiankeil Exp $";
+const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.71 2012/06/08 15:15:11 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $
* Purpose : Declares functions to match URLs against URL
* patterns.
*
- * Copyright : Written by and Copyright (C) 2001-2009
+ * Copyright : Written by and Copyright (C) 2001-2011
* the Privoxy team. http://www.privoxy.org/
*
* Based on the Internet Junkbuster originally written
/* map to lower case */
for (p = http->dbuffer; *p ; p++)
{
- *p = (char)tolower((int)(unsigned char)*p);
+ *p = (char)privoxy_tolower(*p);
}
/* split the domain name into components */
- http->dcount = ssplit(http->dbuffer, ".", vec, SZ(vec), 1, 1);
+ http->dcount = ssplit(http->dbuffer, ".", vec, SZ(vec));
if (http->dcount <= 0)
{
/* save a copy of the pointers in dvec */
size = (size_t)http->dcount * sizeof(*http->dvec);
- http->dvec = (char **)malloc(size);
- if (NULL == http->dvec)
- {
- return JB_ERR_MEMORY;
- }
+ http->dvec = malloc_or_die(size);
memcpy(http->dvec, vec, size);
*/
if (*http->url == '*')
{
- if ( NULL == (http->path = strdup("*"))
- || NULL == (http->hostport = strdup("")) )
+ if (NULL == (http->path = strdup("*"))
+ || NULL == (http->hostport = strdup("")))
{
return JB_ERR_MEMORY;
}
freez(buf);
- if ( (http->path == NULL)
- || (http->hostport == NULL))
+ if ((http->path == NULL)
+ || (http->hostport == NULL))
{
return JB_ERR_MEMORY;
}
return JB_ERR_MEMORY;
}
- n = ssplit(buf, " \r\n", v, SZ(v), 1, 1);
+ n = ssplit(buf, " \r\n", v, SZ(v));
if (n != 3)
{
freez(buf);
if ( (http->cmd == NULL)
|| (http->gpc == NULL)
- || (http->ver == NULL) )
+ || (http->ver == NULL))
{
return JB_ERR_MEMORY;
}
*
* Function : compile_host_pattern
*
- * Description : Parses and compiles a host pattern..
+ * Description : Parses and compiles a host pattern.
*
* Parameters :
* 1 : url = Target url_spec to be filled in.
*/
for (p = url->dbuffer; *p ; p++)
{
- *p = (char)tolower((int)(unsigned char)*p);
+ *p = (char)privoxy_tolower(*p);
}
/*
* Split the domain name into components
*/
- url->dcount = ssplit(url->dbuffer, ".", v, SZ(v), 1, 1);
+ url->dcount = ssplit(url->dbuffer, ".", v, SZ(v));
if (url->dcount < 0)
{
*/
size = (size_t)url->dcount * sizeof(*url->dvec);
- url->dvec = (char **)malloc(size);
- if (NULL == url->dvec)
- {
- free_url_spec(url);
- return JB_ERR_MEMORY;
- }
+ url->dvec = malloc_or_die(size);
memcpy(url->dvec, v, size);
}
/*
* Char match, or char range match?
*/
- if ( (*pat == *txt)
- || (*pat == '?')
- || ((*pat == ']') && (charmap[*txt / 8] & (1 << (*txt % 8)))) )
+ if ((*pat == *txt)
+ || (*pat == '?')
+ || ((*pat == ']') && (charmap[*txt / 8] & (1 << (*txt % 8)))))
{
/*
* Success: Go ahead
}
/* Cut off extra '*'s */
- if(*pat == '*') pat++;
+ if (*pat == '*') pat++;
/* If this is the pattern's end, fine! */
return(*pat);
* or, if max was omitted, between min and 65K
*/
*max++ = '\0';
- if(port >= atoi(min) && port <= (atoi(max) ? atoi(max) : 65535))
+ if (port >= atoi(min) && port <= (atoi(max) ? atoi(max) : 65535))
{
freez(portlist_copy);
return(1);