From cc768428f3226e3bc331c203cc4b0ab2441e4f09 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 31 Jul 2007 10:07:03 +0000 Subject: - added doCustomHdlr() to cfsysline.c - this completes implementing functions for canned handlers. --- syslogd.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'syslogd.c') diff --git a/syslogd.c b/syslogd.c index 87437e52..e4121327 100644 --- a/syslogd.c +++ b/syslogd.c @@ -3467,8 +3467,9 @@ static rsRetVal setDynaFileCacheSize(void __attribute__((unused)) *pVal, int iNe * loader for plug-ins. * rgerhards, 2007-07-21 */ -static void doModLoad(uchar **pp) +static rsRetVal doModLoad(uchar **pp, __attribute__((unused)) void* pVal) { + DEFiRet; uchar szName[512]; assert(pp != NULL); @@ -3476,7 +3477,7 @@ static void doModLoad(uchar **pp) if(getSubString(pp, (char*) szName, sizeof(szName) / sizeof(uchar), ' ') != 0) { logerror("could not extract group name"); - return; + ABORT_FINALIZE(RS_RET_NOT_FOUND); } dprintf("Requested to load module '%s'\n", szName); @@ -3489,6 +3490,9 @@ static void doModLoad(uchar **pp) } skipWhiteSpace(pp); /* skip over any whitespace */ + +finalize_it: + return iRet; } /* parse and interpret a $-config line that starts with @@ -3499,16 +3503,19 @@ static void doModLoad(uchar **pp) * rgerhards 2005-06-21: previously only for templates, now * generalized. */ -static rsRetVal doNameLine(uchar **pp, enum eDirective eDir) +static rsRetVal doNameLine(uchar **pp, void* pVal) { DEFiRet; uchar *p; + enum eDirective eDir; char szName[128]; assert(pp != NULL); p = *pp; assert(p != NULL); + eDir = (enum eDirective) pVal; /* this time, it actually is NOT a pointer! */ + if(getSubString(&p, szName, sizeof(szName) / sizeof(char), ',') != 0) { char errMsg[128]; snprintf(errMsg, sizeof(errMsg)/sizeof(char), @@ -3585,11 +3592,11 @@ rsRetVal cfsysline(uchar *p) /* check the command and carry out processing */ if(!strcasecmp((char*) szCmd, "template")) { - doNameLine(&p, DIR_TEMPLATE); + CHKiRet(doCustomHdlr(&p, doNameLine, (void*) DIR_TEMPLATE)); } else if(!strcasecmp((char*) szCmd, "outchannel")) { - doNameLine(&p, DIR_OUTCHANNEL); + CHKiRet(doCustomHdlr(&p, doNameLine, (void*) DIR_OUTCHANNEL)); } else if(!strcasecmp((char*) szCmd, "allowedsender")) { - doNameLine(&p, DIR_ALLOWEDSENDER); + CHKiRet(doCustomHdlr(&p, doNameLine, (void*) DIR_ALLOWEDSENDER)); } else if(!strcasecmp((char*) szCmd, "dircreatemode")) { CHKiRet(doFileCreateMode(&p, NULL, &fDirCreateMode)); } else if(!strcasecmp((char*) szCmd, "filecreatemode")) { @@ -3623,9 +3630,14 @@ rsRetVal cfsysline(uchar *p) } else if(!strcasecmp((char*) szCmd, "droptrailinglfonreception")) { CHKiRet(doBinaryOptionLine(&p, NULL, &bDropTrailingLF)); } else if(!strcasecmp((char*) szCmd, "resetconfigvariables")) { - resetConfigVariables(); + /* TODO: the compiler warning for the line below is OK for the time being. In the + * longer term, we should create a special parsing function which + * will also check if there are any spurios characters. + * rgerhards, 2007-07-31 + */ + CHKiRet(doCustomHdlr(&p , resetConfigVariables, NULL)); } else if(!strcasecmp((char*) szCmd, "modload")) { - doModLoad(&p); + CHKiRet(doCustomHdlr(&p, doModLoad, NULL)); } else { /* invalid command! */ char err[100]; snprintf(err, sizeof(err)/sizeof(char), @@ -4088,7 +4100,6 @@ rsRetVal cflineParseTemplateName(uchar** pp, omodStringRequest_t *pOMSR, int iEn assert(pp != NULL); assert(*pp != NULL); assert(pOMSR != NULL); -dprintf("cflineParsetTemplateName opts: %d\n", iTplOpts); p =*pp; /* a template must follow - search it and complain, if not found -- cgit v1.2.3