Index: ossp-pkg/l2/l2_ch_filter.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_ch_filter.c,v rcsdiff -q -kk '-r1.9' '-r1.10' -u '/v/ossp/cvs/ossp-pkg/l2/l2_ch_filter.c,v' 2>/dev/null --- l2_ch_filter.c 2001/09/25 09:35:17 1.9 +++ l2_ch_filter.c 2001/09/28 14:28:41 1.10 @@ -83,7 +83,8 @@ return L2_ERR_ARG; } /* study FSM for more performance */ - if ((cfg->pcreExtra = pcre_study(cfg->pcreRegex, 0, &szError)) == NULL) { + cfg->pcreExtra = pcre_study(cfg->pcreRegex, 0, &szError); + if (szError != NULL) { free(cfg->pcreRegex); cfg->pcreRegex = NULL; l2_channel_errorinfo(ch, L2_ERR_ARG, "%s", szError); @@ -101,13 +102,14 @@ l2_ch_filter_t *cfg = (l2_ch_filter_t *)ctx->vp; l2_channel_t *downstream = l2_channel_downstream(ch); l2_result_t rv; - int bPass; + int bPass, iCheck; bPass = TRUE; /* apply filter */ - if (cfg->pcreRegex != NULL && cfg->pcreExtra != NULL) { - if (pcre_exec(cfg->pcreRegex, cfg->pcreExtra, buf, buf_size, 0, 0, NULL, 0) > 0) + if (cfg->pcreRegex != NULL) { + iCheck = pcre_exec(cfg->pcreRegex, cfg->pcreExtra, buf, buf_size, 0, 0, NULL, 0); + if (iCheck >= 0) bPass = TRUE; else bPass = FALSE; Index: ossp-pkg/l2/l2_test.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_test.c,v rcsdiff -q -kk '-r1.27' '-r1.28' -u '/v/ossp/cvs/ossp-pkg/l2/l2_test.c,v' 2>/dev/null --- l2_test.c 2001/09/21 17:30:26 1.27 +++ l2_test.c 2001/09/28 14:28:41 1.28 @@ -63,6 +63,7 @@ int main(int argc, char *argv[]) { + l2_channel_t *chFilt; l2_channel_t *chPrefix; l2_channel_t *chBuf; l2_channel_t *chFile; @@ -92,6 +93,12 @@ if (l2_channel_configure(chPrefix, "prefix,timezone", "[%d-%m-%Y/%H:%M:%S] %L test[%P]: ", "local") != L2_OK) die("failed to configure prefix channel"); + if ((chFilt = l2_channel_create(&l2_handler_filter)) == NULL) /* Filter */ + die("failed to create filter channel"); + + if (l2_channel_configure(chFilt, "regex,negate", "hecking", 0) != L2_OK) + die("failed to configure filter channel"); + if ((chBuf = l2_channel_create(&l2_handler_buffer)) == NULL) /* Buffer */ die("failed to create buffer channel"); @@ -110,10 +117,13 @@ if (l2_channel_stack(chBuf, chPrefix) != L2_OK) die("failed to stack prefix channel on top of buffer channel"); - if (l2_channel_open(chPrefix) != L2_OK) + if (l2_channel_stack(chPrefix, chFilt) != L2_OK) + die("failed to stack filter channel on top of prefix channel"); + + if (l2_channel_open(chFilt) != L2_OK) die("failed to open channel stack"); - if (l2_stream_channel(st, chPrefix, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK) + if (l2_stream_channel(st, chFilt, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK) die("failed to attach channel stack into stream"); #ifdef WITH_SYSLOG