OSSP CVS Repository

ossp - Check-in [1452]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1452
Date: 2001-Dec-22 23:24:40 (local)
2001-Dec-22 22:24:40 (UTC)
User:rse
Branch:
Comment: add no case support
Tickets:
Inspections:
Files:
ossp-pkg/l2/TODO      1.49 -> 1.50     0 inserted, 2 deleted
ossp-pkg/l2/l2_ch_filter.c      1.14 -> 1.15     11 inserted, 4 deleted

ossp-pkg/l2/TODO 1.49 -> 1.50

--- TODO 2001/12/22 22:23:43     1.49
+++ TODO 2001/12/22 22:24:40     1.50
@@ -39,8 +39,6 @@
 - l2_ch_socket bind and udp parameters need work. (RSE: why and what?)
 - l2_ch_socket consider taking a fd at configuration.
 
-- l2_ch_filter should have a PCRE_CASELESS option.
-
 - l2_ch_pcre is too large and might benefit from a
     smaller set of pattern matching logic.
 


ossp-pkg/l2/l2_ch_filter.c 1.14 -> 1.15

--- l2_ch_filter.c       2001/11/07 13:05:20     1.14
+++ l2_ch_filter.c       2001/12/22 22:24:40     1.15
@@ -34,6 +34,7 @@
 typedef struct {
     char *szRegex;
     int   bNegate;
+    int   bNoCase;
     pcre *pcreRegex;
     pcre_extra *pcreExtra;
 } l2_ch_filter_t;
@@ -49,7 +50,8 @@
 
     /* initialize configuration with reasonable defaults */
     cfg->szRegex   = NULL;
-    cfg->bNegate   = 0;
+    cfg->bNegate   = FALSE;
+    cfg->bNoCase   = FALSE;
     cfg->pcreRegex = NULL;
     cfg->pcreExtra = NULL;
 
@@ -64,15 +66,17 @@
 {
     l2_ch_filter_t *cfg = (l2_ch_filter_t *)ctx->vp;
     l2_env_t *env;
-    l2_param_t pa[3]; 
+    l2_param_t pa[4]; 
     l2_result_t rv;
     const char *szError;
     int nErrorOffset;
+    int opt;
 
     /* feed and call generic parameter parsing engine */
     L2_PARAM_SET(pa[0], regex,  STR, &cfg->szRegex);
     L2_PARAM_SET(pa[1], negate, INT, &cfg->bNegate);
-    L2_PARAM_END(pa[2]);
+    L2_PARAM_SET(pa[2], nocase, INT, &cfg->bNoCase);
+    L2_PARAM_END(pa[3]);
     l2_channel_env(ch, &env);
     if ((rv = l2_util_setparams(env, pa, fmt, ap)) != L2_OK)
         return rv;
@@ -80,7 +84,10 @@
     /* translate regular expression into finite state machine */ 
     if (cfg->szRegex != NULL) {
         /* compile regular expression into FSM */
-        if ((cfg->pcreRegex = pcre_compile(cfg->szRegex, 0, &szError, &nErrorOffset, NULL)) == NULL) {
+        opt = 0;
+        if (cfg->bNoCase)
+            opt |= PCRE_CASELESS;
+        if ((cfg->pcreRegex = pcre_compile(cfg->szRegex, opt, &szError, &nErrorOffset, NULL)) == NULL) {
             l2_env_errorinfo(env, L2_ERR_ARG, "%s ('%c')", szError, cfg->szRegex[nErrorOffset]);
             return L2_ERR_ARG;
         }

CVSTrac 2.0.1