Make it harder to mistake url_match()'s
authorFabian Keil <fk@fabiankeil.de>
Tue, 8 Apr 2008 16:07:39 +0000 (16:07 +0000)
committerFabian Keil <fk@fabiankeil.de>
Tue, 8 Apr 2008 16:07:39 +0000 (16:07 +0000)
second parameter for an url_spec.

urlmatch.c
urlmatch.h

index 3745492..1c4963a 100644 (file)
@@ -1,4 +1,4 @@
-const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.26 2008/04/07 16:57:18 fabiankeil Exp $";
+const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.27 2008/04/08 15:44:33 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/urlmatch.c,v $
@@ -33,6 +33,10 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.26 2008/04/07 16:57:18 fabianke
  *
  * Revisions   :
  *    $Log: urlmatch.c,v $
+ *    Revision 1.27  2008/04/08 15:44:33  fabiankeil
+ *    Save a bit of memory (and a few cpu cycles) by not bothering to
+ *    compile slash-only path regexes that don't affect the result.
+ *
  *    Revision 1.26  2008/04/07 16:57:18  fabiankeil
  *    - Use free_url_spec() more consistently.
  *    - Let it reset url->dcount just in case.
@@ -1122,16 +1126,16 @@ void free_url_spec(struct url_spec *url)
  *
  *********************************************************************/
 int url_match(const struct url_spec *pattern,
-              const struct http_request *url)
+              const struct http_request *http)
 {
    /* XXX: these should probably be functions. */
-#define PORT_MATCHES ((NULL == pattern->port_list) || match_portlist(pattern->port_list, url->port))
+#define PORT_MATCHES ((NULL == pattern->port_list) || match_portlist(pattern->port_list, http->port))
 #ifdef FEATURE_EXTENDED_HOST_PATTERNS
-#define DOMAIN_MATCHES ((NULL == pattern->host_regex) || (0 == regexec(pattern->host_regex, url->host, 0, NULL, 0)))
+#define DOMAIN_MATCHES ((NULL == pattern->host_regex) || (0 == regexec(pattern->host_regex, http->host, 0, NULL, 0)))
 #else
-#define DOMAIN_MATCHES ((NULL == pattern->dbuffer) || (0 == domain_match(pattern, url)))
+#define DOMAIN_MATCHES ((NULL == pattern->dbuffer) || (0 == domain_match(pattern, http)))
 #endif
-#define PATH_MATCHES ((NULL == pattern->path) || (0 == regexec(pattern->preg, url->path, 0, NULL, 0)))
+#define PATH_MATCHES ((NULL == pattern->path) || (0 == regexec(pattern->preg, http->path, 0, NULL, 0)))
 
    if (pattern->tag_regex != NULL)
    {
index 71e2633..8f55e6d 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef URLMATCH_H_INCLUDED
 #define URLMATCH_H_INCLUDED
-#define URLMATCH_H_VERSION "$Id: urlmatch.h,v 1.7 2007/01/06 14:24:38 fabiankeil Exp $"
+#define URLMATCH_H_VERSION "$Id: urlmatch.h,v 1.8 2007/09/02 15:31:20 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/urlmatch.h,v $
  *
  * Revisions   :
  *    $Log: urlmatch.h,v $
+ *    Revision 1.8  2007/09/02 15:31:20  fabiankeil
+ *    Move match_portlist() from filter.c to urlmatch.c.
+ *    It's used for url matching, not for filtering.
+ *
  *    Revision 1.7  2007/01/06 14:24:38  fabiankeil
  *    Mark *csp as immutable for parse_http_url()
  *    and url_match().
@@ -89,7 +93,7 @@ extern jb_err parse_http_url(const char * url,
                              const struct client_state *csp);
 
 extern int url_match(const struct url_spec *pattern,
-                     const struct http_request *url);
+                     const struct http_request *http);
 
 extern jb_err create_url_spec(struct url_spec * url, const char * buf);
 extern void free_url_spec(struct url_spec *url);