diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-07 08:22:40 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-07 08:22:40 +0200 |
commit | 5710b413963d2fde9d062127ed72672b8a58a07e (patch) | |
tree | 35cd364e62273da3a239f1c72f1d50d4e69ce21b /runtime | |
parent | 30f2b5b094d282af6f601aa4e8fa88c1baf187f4 (diff) | |
download | rsyslog-5710b413963d2fde9d062127ed72672b8a58a07e.tar.gz rsyslog-5710b413963d2fde9d062127ed72672b8a58a07e.tar.bz2 rsyslog-5710b413963d2fde9d062127ed72672b8a58a07e.zip |
milestone/[PARTWORK]: integrted script filter, but var access is missing
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/conf.c | 10 | ||||
-rw-r--r-- | runtime/conf.h | 3 | ||||
-rw-r--r-- | runtime/rsconf.c | 20 | ||||
-rw-r--r-- | runtime/rule.c | 8 | ||||
-rw-r--r-- | runtime/rule.h | 6 |
5 files changed, 31 insertions, 16 deletions
diff --git a/runtime/conf.c b/runtime/conf.c index 5eb1aae2..51cf39e1 100644 --- a/runtime/conf.c +++ b/runtime/conf.c @@ -104,9 +104,9 @@ int bConfStrictScoping = 0; /* force strict scoping during config processing? */ * be run in a single thread anyways. So there can be no race conditions. * rgerhards 2005-10-18 */ -static EHostnameCmpMode eDfltHostnameCmpMode = HN_NO_COMP; -static cstr_t *pDfltHostnameCmp = NULL; -static cstr_t *pDfltProgNameCmp = NULL; +EHostnameCmpMode eDfltHostnameCmpMode = HN_NO_COMP; +cstr_t *pDfltHostnameCmp = NULL; +cstr_t *pDfltProgNameCmp = NULL; /* process a directory and include all of its files into @@ -763,6 +763,7 @@ rsRetVal cflineProcessTradPRIFilter(uchar **pline, register rule_t *pRule) } +#if 0 /* Helper to cfline(). This function processes an "if" type of filter, * what essentially means it parses an expression. As usual, * It processes the line up to the beginning of the action part. @@ -830,6 +831,7 @@ finalize_it: RETiRet; } +#endif /* Helper to cfline(). This function takes the filter part of a property @@ -1061,12 +1063,14 @@ static rsRetVal cflineDoFilter(uchar **pp, rule_t *f) case ':': CHKiRet(cflineProcessPropFilter(pp, f)); break; +#if 0 case 'i': /* "if" filter? */ if(*(*pp+1) && (*(*pp+1) == 'f') && isspace(*(*pp+2))) { CHKiRet(cflineProcessIfFilter(pp, f)); break; } /*FALLTHROUGH*/ +#endif default: CHKiRet(cflineProcessTradPRIFilter(pp, f)); break; diff --git a/runtime/conf.h b/runtime/conf.h index 28ccdde1..aa57c8fc 100644 --- a/runtime/conf.h +++ b/runtime/conf.h @@ -72,5 +72,8 @@ rsRetVal cflineProcessHostSelector(uchar **pline); rsRetVal cflineProcessTradPRIFilter(uchar **pline, rule_t *pRule); rsRetVal cflineProcessPropFilter(uchar **pline, rule_t *f); rsRetVal cflineDoAction(rsconf_t *conf, uchar **p, action_t **ppAction); +extern EHostnameCmpMode eDfltHostnameCmpMode; +extern cstr_t *pDfltHostnameCmp; +extern cstr_t *pDfltProgNameCmp; #endif /* #ifndef INCLUDED_CONF_H */ diff --git a/runtime/rsconf.c b/runtime/rsconf.c index 17332464..cb8eac50 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -255,7 +255,9 @@ parser_errmsg(char *fmt, ...) va_list ap; va_start(ap, fmt); // TODO: create useful code ;) 2011-07-06 - dbgprintf("error on or before line %d: ", yylineno); + errmsg.LogError(0, NO_ERRCODE, "error during parsing on or before line %d", + yylineno); +dbgprintf("error on or before line %d: ", yylineno); vprintf(fmt, ap); printf("\n"); va_end(ap); @@ -284,8 +286,8 @@ void cnfDoRule(struct cnfrule *cnfrule) cnfrulePrint(cnfrule); CHKiRet(rule.Construct(&pRule)); /* create "fresh" selector */ - CHKiRet(rule.SetAssRuleset(pRule, ruleset.GetCurrent(loadConf))); /* create "fresh" selector */ - CHKiRet(rule.ConstructFinalize(pRule)); /* create "fresh" selector */ + CHKiRet(rule.SetAssRuleset(pRule, ruleset.GetCurrent(loadConf))); + CHKiRet(rule.ConstructFinalize(pRule)); switch(cnfrule->filttype) { case CNFFILT_NONE: @@ -300,23 +302,21 @@ void cnfDoRule(struct cnfrule *cnfrule) iRet = cflineProcessPropFilter(&str, pRule); break; case CNFFILT_SCRIPT: - dbgprintf("TODO: script filter implementation missing\n"); - cnfexprPrint(cnfrule->filt.expr, 0); + pRule->f_filter_type = FILTER_EXPR; + pRule->f_filterData.f_expr = cnfrule->filt.expr; break; } /* we now check if there are some global (BSD-style) filter conditions * and, if so, we copy them over. rgerhards, 2005-10-18 */ -#if 0 // TODO: add LATER! if(pDfltProgNameCmp != NULL) { - CHKiRet(rsCStrConstructFromCStr(&(f->pCSProgNameComp), pDfltProgNameCmp)); + CHKiRet(rsCStrConstructFromCStr(&(pRule->pCSProgNameComp), pDfltProgNameCmp)); } if(eDfltHostnameCmpMode != HN_NO_COMP) { - f->eHostnameCmpMode = eDfltHostnameCmpMode; - CHKiRet(rsCStrConstructFromCStr(&(f->pCSHostnameComp), pDfltHostnameCmp)); + pRule->eHostnameCmpMode = eDfltHostnameCmpMode; + CHKiRet(rsCStrConstructFromCStr(&(pRule->pCSHostnameComp), pDfltHostnameCmp)); } -#endif cnfDoActlst(cnfrule->actlst, pRule); diff --git a/runtime/rule.c b/runtime/rule.c index 3dcee877..8976c898 100644 --- a/runtime/rule.c +++ b/runtime/rule.c @@ -40,6 +40,7 @@ #include "var.h" #include "srUtils.h" #include "batch.h" +#include "parserif.h" #include "unicode-helper.h" /* static data */ @@ -186,14 +187,17 @@ shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, sbool *bProcessMsg) else bRet = 1; } else if(pRule->f_filter_type == FILTER_EXPR) { +#if 0 CHKiRet(vm.Construct(&pVM)); CHKiRet(vm.ConstructFinalize(pVM)); CHKiRet(vm.SetMsg(pVM, pMsg)); CHKiRet(vm.ExecProg(pVM, pRule->f_filterData.f_expr->pVmprg)); CHKiRet(vm.PopBoolFromStack(pVM, &pResult)); - dbgprintf("result of rainerscript filter evaluation: %lld\n", pResult->val.num); /* VM is destructed on function exit */ bRet = (pResult->val.num) ? 1 : 0; +#endif + bRet = cnfexprEvalBool(pRule->f_filterData.expr); + dbgprintf("result of rainerscript filter evaluation: %d\n", bRet); } else { assert(pRule->f_filter_type == FILTER_PROP); /* assert() just in case... */ pszPropVal = MsgGetProp(pMsg, NULL, pRule->f_filterData.prop.propID, @@ -356,9 +360,11 @@ CODESTARTobjDestruct(rule) rsCStrRegexDestruct(&pThis->f_filterData.prop.regex_cache); if(pThis->f_filterData.prop.propName != NULL) es_deleteStr(pThis->f_filterData.prop.propName); +#if 0 } else if(pThis->f_filter_type == FILTER_EXPR) { if(pThis->f_filterData.f_expr != NULL) expr.Destruct(&pThis->f_filterData.f_expr); +#endif } llDestroy(&pThis->llActList); diff --git a/runtime/rule.h b/runtime/rule.h index 3b34e11a..f346c764 100644 --- a/runtime/rule.h +++ b/runtime/rule.h @@ -2,7 +2,7 @@ * * This implements rules within rsyslog. * - * Copyright 2009 Rainer Gerhards and Adiscon GmbH. + * Copyright 2009-2011 Rainer Gerhards and Adiscon GmbH. * * This file is part of the rsyslog runtime library. * @@ -28,7 +28,8 @@ #include "libestr.h" #include "linkedlist.h" #include "regexp.h" -#include "expr.h" +#include "expr.h" // TODO: remove #if 0 +#include "rainerscript.h" /* the rule object */ struct rule_s { @@ -52,6 +53,7 @@ struct rule_s { propid_t propID; /* ID of the requested property */ es_str_t *propName; /* name of property for CEE-based filters */ } prop; + struct cnfexpr *expr; /* expression object */ expr_t *f_expr; /* expression object */ } f_filterData; |