add 'excludes' to squirm

From: George Michaelson <ggm@dont-contact.us>
Date: Wed, 27 May 1998 11:53:52 +1000

Here is a lightweight diff to add 'exclude' patterns to squirm.

The pattern has to appear before the match which you otherwise expect to
re-write.

It seems to work ok after a trivial test.

This lets me run a www mirror, without modified cgi-bin and exclude the cgi's
from the local redirection.

The exclude pattern includes a replacement. I couldn't be bothered to rewrite
the parser to make it a 3 field match. It MUST have an accellerator as well.

Actually, if the regex() engine honours ! notation, this patch is redundant
since you can use the accellerator to select, and a !form with (arg) to reject
with parse. However, it proved hard to make that work so I decided to hack up
an explicit method.

cheers
        -George
--------------

*** config.c Tue Mar 10 21:21:54 1998
--- ../squirm-1.0betaB-mod/config.c Wed May 27 11:23:52 1998
***************
*** 171,176 ****
--- 171,181 ----
      abort_type = 1;
    }
    
+ if(strcmp(type, "exclude") == 0) {
+ rpattern.type = EXCLUDE;
+ abort_type = 1;
+ }
+
    if(strcmp(type, "regexi") == 0) {
      regex_flags |= REG_ICASE;
      rpattern.case_sensitive = 0;
*** lists.h Wed Mar 11 18:26:03 1998
--- ../squirm-1.0betaB-mod/lists.h Wed May 27 11:23:24 1998
***************
*** 37,42 ****
--- 37,43 ----
  #define NORMAL 1
  #define EXTENDED 2
  #define ABORT 3
+ #define EXCLUDE 4
  
  #define ACCEL_NORMAL 1
  #define ACCEL_START 2
*** squirm.c Fri Mar 13 18:55:12 1998
--- ../squirm-1.0betaB-mod/squirm.c Wed May 27 11:28:35 1998
***************
*** 173,178 ****
--- 173,195 ----
  #endif
          return NULL; /* URL matches abort file extension */
        }
+ } else if (curr->patterns.type == EXCLUDE) {
+ if(curr->patterns.has_accel) {
+ /* check to see if the accelerator string matches, then bother
+ doing a regexec() on it */
+ if(match_accel(url, curr->patterns.accel,
+ curr->patterns.accel_type,
+ curr->patterns.case_sensitive)) {
+
+ #ifdef DEBUG
+ log(LOG_DEBUG, "URL [%s] matches EXCLUDE accelerator [%s]\n",
+ url, curr->patterns.accel);
+ #endif
+ if(regexec(&curr->patterns.cpattern, url, 0, 0, 0) == 0) {
+ return NULL; /* URL matches exclude patternmatch */
+ }
+ }
+ }
      } else {
        
        /* check for accelerator string */

--
George Michaelson         |  DSTC Pty Ltd
Email: ggm@dstc.edu.au    |  University of Qld 4072
Phone: +61 7 3365 4310    |  Australia
  Fax: +61 7 3365 4311    |  http://www.dstc.edu.au
Received on Tue May 26 1998 - 18:56:28 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:40:20 MST