diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-26 12:25:10 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-09-26 12:25:10 +0200 |
commit | 7c2183ee323dc062b0dde6bac4cd9c5afa4ab369 (patch) | |
tree | 5ff20593e1526ee27859d7aa3ac1e95e4eca4652 /runtime/rsconf.c | |
parent | b715e86769b9b6d77e9c57e4d0cc70725962cf1f (diff) | |
download | rsyslog-7c2183ee323dc062b0dde6bac4cd9c5afa4ab369.tar.gz rsyslog-7c2183ee323dc062b0dde6bac4cd9c5afa4ab369.tar.xz rsyslog-7c2183ee323dc062b0dde6bac4cd9c5afa4ab369.zip |
input stmt: add core engine plumbing
Diffstat (limited to 'runtime/rsconf.c')
-rw-r--r-- | runtime/rsconf.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/runtime/rsconf.c b/runtime/rsconf.c index 67a13893..170e0bb1 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -99,6 +99,18 @@ static uchar template_SysklogdFileFormat[] = "\"%TIMESTAMP% %HOSTNAME% %syslogta static uchar template_StdJSONFmt[] = "\"{\\\"message\\\":\\\"%msg:::json%\\\",\\\"fromhost\\\":\\\"%HOSTNAME:::json%\\\",\\\"facility\\\":\\\"%syslogfacility-text%\\\",\\\"priority\\\":\\\"%syslogpriority-text%\\\",\\\"timereported\\\":\\\"%timereported:::date-rfc3339%\\\",\\\"timegenerated\\\":\\\"%timegenerated:::date-rfc3339%\\\"}\""; /* end templates */ +/* tables for interfacing with the v6 config system (as far as we need to) */ +static struct cnfparamdescr inppdescr[] = { + { "name", eCmdHdlrGetWord, 0 }, + { "type", eCmdHdlrString, CNFPARAM_REQUIRED } +}; +static struct cnfparamblk inppblk = + { CNFPARAMBLK_VERSION, + sizeof(inppdescr)/sizeof(struct cnfparamdescr), + inppdescr + }; + +/* forward-definitions */ void cnfDoCfsysline(char *ln); /* Standard-Constructor @@ -373,6 +385,49 @@ finalize_it: return estr; } + +/* Process input() objects */ +rsRetVal +inputProcessCnf(struct cnfobj *o) +{ + struct cnfparamvals *pvals; + modInfo_t *pMod; + uchar *cnfModName = NULL; + void *pModData; + action_t *pAction; + int typeIdx; + DEFiRet; + + pvals = nvlstGetParams(o->nvlst, &inppblk, NULL); + if(pvals == NULL) { + ABORT_FINALIZE(RS_RET_ERR); + } + DBGPRINTF("input param blk after inputProcessCnf:\n"); + cnfparamsPrint(&inppblk, pvals); + typeIdx = cnfparamGetIdx(&inppblk, "type"); + if(pvals[typeIdx].bUsed == 0) { + errmsg.LogError(0, RS_RET_CONF_RQRD_PARAM_MISSING, "input type missing"); + ABORT_FINALIZE(RS_RET_CONF_RQRD_PARAM_MISSING); // TODO: move this into rainerscript handlers + } + cnfModName = (uchar*)es_str2cstr(pvals[typeIdx].val.d.estr, NULL); + if((pMod = module.FindWithCnfName(loadConf, cnfModName, eMOD_IN)) == NULL) { + errmsg.LogError(0, RS_RET_MOD_UNKNOWN, "input module name '%s' is unknown", cnfModName); + ABORT_FINALIZE(RS_RET_MOD_UNKNOWN); + } + if(pMod->mod.im.newInpInst == NULL) { + errmsg.LogError(0, RS_RET_MOD_NO_INPUT_STMT, + "input module '%s' does not support input() statement", cnfModName); + ABORT_FINALIZE(RS_RET_MOD_NO_INPUT_STMT); + } +dbgprintf("DDDD: ready to roll...\n"); + CHKiRet(pMod->mod.im.newInpInst(o->nvlst)); +dbgprintf("DDDD: done calling module entry point\n"); +finalize_it: + free(cnfModName); + cnfparamvalsDestruct(pvals, &inppblk); + RETiRet; +} + /*------------------------------ interface to flex/bison parser ------------------------------*/ extern int yylineno; @@ -416,6 +471,9 @@ void cnfDoObj(struct cnfobj *o) case CNFOBJ_ACTION: actionProcessCnf(o); break; + case CNFOBJ_INPUT: + inputProcessCnf(o); + break; case CNFOBJ_TPL: tplProcessCnf(o); break; |