--- 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;
}
|