From 5820c5f3e8dc69bdee969d6487d084e884595069 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 20 Jul 2011 17:37:44 +0200 Subject: milestone: done plumbing to call plugin create action instance entry point --- runtime/conf.c | 40 ---------------------------------------- runtime/modules.c | 22 +++++++++++++++++++++- runtime/modules.h | 3 ++- runtime/rsconf.c | 6 +++++- runtime/rsyslog.h | 2 ++ 5 files changed, 30 insertions(+), 43 deletions(-) (limited to 'runtime') diff --git a/runtime/conf.c b/runtime/conf.c index 1757c944..6136262e 100644 --- a/runtime/conf.c +++ b/runtime/conf.c @@ -708,46 +708,6 @@ finalize_it: } -#if 0 -/* read the filter part of a configuration line and store the filter - * in the supplied rule_t - * rgerhards, 2007-08-01 - */ -static rsRetVal cflineDoFilter(uchar **pp, rule_t *f) -{ - DEFiRet; - - ASSERT(pp != NULL); - ISOBJ_TYPE_assert(f, rule); - - /* check which filter we need to pull... */ - switch(**pp) { - case ':': - CHKiRet(cflineProcessPropFilter(pp, f)); - break; - default: - CHKiRet(cflineProcessTradPRIFilter(pp, f)); - 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(pDfltProgNameCmp != NULL) { - CHKiRet(rsCStrConstructFromCStr(&(f->pCSProgNameComp), pDfltProgNameCmp)); - } - - if(eDfltHostnameCmpMode != HN_NO_COMP) { - f->eHostnameCmpMode = eDfltHostnameCmpMode; - CHKiRet(rsCStrConstructFromCStr(&(f->pCSHostnameComp), pDfltHostnameCmp)); - } - -finalize_it: - RETiRet; -} -#endif - - /* process the action part of a selector line * rgerhards, 2007-08-01 */ diff --git a/runtime/modules.c b/runtime/modules.c index d09ba770..59eaec34 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -427,7 +427,7 @@ static cfgmodules_etry_t if(rqtdType != eMOD_ANY) { /* if any, we already have the right one! */ while(node != NULL && node->pMod->eType != rqtdType) { - node = node->next; /* warning: do ... while() */ + node = node->next; } } @@ -435,6 +435,25 @@ static cfgmodules_etry_t } +/* Find a module with the given conf name and type. Returns NULL if none + * can be found, otherwise module found. + */ +static modInfo_t * +FindWithCnfName(rsconf_t *cnf, uchar *name, eModType_t rqtdType) +{ + cfgmodules_etry_t *node; + + node = cnf->modules.root; + while(node != NULL && node->pMod->eType != rqtdType) { + if(!strcasecmp((char*)node->pMod->cnfName, (char*)name)) + break; + node = node->next; + } + + return node == NULL ? NULL : node->pMod; +} + + /* Prepare a module for unloading. * This is currently a dummy, to be filled when we have a plug-in * interface - rgerhards, 2007-08-09 @@ -1179,6 +1198,7 @@ CODESTARTobjQueryInterface(module) pIf->GetName = modGetName; pIf->GetStateName = modGetStateName; pIf->PrintList = modPrintList; + pIf->FindWithCnfName = FindWithCnfName; pIf->UnloadAndDestructAll = modUnloadAndDestructAll; pIf->doModInit = doModInit; pIf->SetModDir = SetModDir; diff --git a/runtime/modules.h b/runtime/modules.h index 1579fb86..ebde1219 100644 --- a/runtime/modules.h +++ b/runtime/modules.h @@ -174,8 +174,9 @@ BEGINinterface(module) /* name must also be changed in ENDinterface macro! */ rsRetVal (*doModInit)(rsRetVal (*modInit)(), uchar *name, void *pModHdlr, modInfo_t **pNew); rsRetVal (*Load)(uchar *name, sbool bConfLoad); rsRetVal (*SetModDir)(uchar *name); + modInfo_t *(*FindWithCnfName)(rsconf_t *cnf, uchar *name, eModType_t rqtdType); /* added v3, 2011-07-19 */ ENDinterface(module) -#define moduleCURR_IF_VERSION 2 /* increment whenever you change the interface structure! */ +#define moduleCURR_IF_VERSION 3 /* increment whenever you change the interface structure! */ /* Changes: * v2 * - added param bCondLoad to Load call - 2011-04-27 diff --git a/runtime/rsconf.c b/runtime/rsconf.c index 26105e88..4fe17534 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -230,7 +230,8 @@ cnfDoActlst(struct cnfactlst *actlst, rule_t *pRule) while(actlst != NULL) { dbgprintf("aclst %p: ", actlst); if(actlst->actType == CNFACT_V2) { - dbgprintf("V2 action type not yet handled\n"); + dbgprintf("v6+ action object\n"); + actionNewInst(actlst->data.lst, &pAction); } else { dbgprintf("legacy action line:%s\n", actlst->data.legActLine); str = (uchar*) actlst->data.legActLine; @@ -360,6 +361,9 @@ void cnfDoObj(struct cnfobj *o) case CNFOBJ_GLOBAL: glblProcessCnf(o); break; + case CNFOBJ_ACTION: + actionProcessCnf(o); + break; } nvlstChkUnused(o->nvlst); cnfobjDestruct(o); diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index 39f00ebc..dc2f15be 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -361,6 +361,8 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth RS_RET_ERR_SCHED_PARAMS = -2205,/**< there is a problem with configured thread scheduling params */ RS_RET_SOCKNAME_MISSING = -2206,/**< no socket name configured where one is required */ RS_RET_CONF_PARSE_ERROR = -2207,/**< (fatal) error parsing config file */ + RS_RET_CONF_RQRD_PARAM_MISSING = -2208,/**< required parameter in config object is missing */ + RS_RET_MOD_UNKNOWN = -2209,/**< module (config name) is unknown */ /* RainerScript error messages (range 1000.. 1999) */ RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */ -- cgit