-const char filters_rcs[] = "$Id: filters.c,v 1.34 2001/09/20 15:49:36 steudten Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.35 2001/10/07 15:41:23 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.35 2001/10/07 15:41:23 oes
+ * Replaced 6 boolean members of csp with one bitmap (csp->flags)
+ *
+ * New function remove_chunked_transfer_coding that strips chunked
+ * transfer coding to plain and is called by pcrs_filter_response
+ * and gif_deanimate_response if neccessary
+ *
+ * Improved handling of zero-change re_filter runs
+ *
+ * pcrs_filter_response and gif_deanimate_response now remove
+ * chunked transfer codeing before processing the body.
+ *
* Revision 1.34 2001/09/20 15:49:36 steudten
*
* Fix BUG: Change int size to size_t size in pcrs_filter_response().
#endif /* def FEATURE_ACL */
+/*********************************************************************
+ *
+ * Function : match_portlist
+ *
+ * Description : Check if a given number is covered by a comma
+ * separated list of numbers and ranges (a,b-c,d,..)
+ *
+ * Parameters :
+ * 1 : portlist = String with list
+ * 2 : port = port to check
+ *
+ * Returns : 0 => no match
+ * 1 => match
+ *
+ *********************************************************************/
+int match_portlist(const char *portlist, int port)
+{
+ char *min, *max, *next, *portlist_copy;
+
+ min = next = portlist_copy = strdup(portlist);
+
+ /*
+ * Zero-terminate first item and remember offset for next
+ */
+ if (NULL != (next = strchr(portlist_copy, (int) ',')))
+ {
+ *next++ = '\0';
+ }
+
+ /*
+ * Loop through all items, checking for match
+ */
+ while(min)
+ {
+ if (NULL == (max = strchr(min, (int) '-')))
+ {
+ /*
+ * No dash, check for equality
+ */
+ if (port == atoi(min))
+ {
+ free(portlist_copy);
+ return(1);
+ }
+ }
+ else
+ {
+ /*
+ * This is a range, so check if between min and max,
+ * or, if max was omitted, between min and 65K
+ */
+ *max++ = '\0';
+ if(port >= atoi(min) && port <= (atoi(max) ? atoi(max) : 65535))
+ {
+ free(portlist_copy);
+ return(1);
+ }
+
+ }
+
+ /*
+ * Jump to next item
+ */
+ min = next;
+
+ /*
+ * Zero-terminate next item and remember offset for n+1
+ */
+ if ((NULL != next) && (NULL != (next = strchr(next, (int) ','))))
+ {
+ *next++ = '\0';
+ }
+ }
+
+ free(portlist_copy);
+ return 0;
+
+}
+
+
/*********************************************************************
*
* Function : block_url
#ifndef FILTERS_H_INCLUDED
#define FILTERS_H_INCLUDED
-#define FILTERS_H_VERSION "$Id: filters.h,v 1.13 2001/07/30 22:08:36 jongfoster Exp $"
+#define FILTERS_H_VERSION "$Id: filters.h,v 1.14 2001/10/07 15:41:40 oes Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.h,v $
*
* Revisions :
* $Log: filters.h,v $
+ * Revision 1.14 2001/10/07 15:41:40 oes
+ * Added prototype for remove_chunked_transfer_coding
+ *
* Revision 1.13 2001/07/30 22:08:36 jongfoster
* Tidying up #defines:
* - All feature #defines are now of the form FEATURE_xxx
extern int block_acl(struct access_control_addr *dst, struct client_state *csp);
extern int acl_addr(char *aspec, struct access_control_addr *aca);
#endif /* def FEATURE_ACL */
+extern int match_portlist(const char *portlist, int port);
/*
* Interceptors