diff options
-rw-r--r-- | action.c | 10 | ||||
-rw-r--r-- | datetime.c | 2 | ||||
-rw-r--r-- | plugins/imfile/imfile.c | 5 | ||||
-rw-r--r-- | syslogd.c | 6 | ||||
-rw-r--r-- | sysvar.c | 5 |
5 files changed, 19 insertions, 9 deletions
@@ -41,12 +41,15 @@ #include "cfsysline.h" #include "srUtils.h" #include "errmsg.h" +#include "datetime.h" /* forward definitions */ rsRetVal actionCallDoAction(action_t *pAction, msg_t *pMsg); /* object static data (once for all instances) */ -DEFobjStaticHelpers +/* TODO: make this an object! DEFobjStaticHelpers -- rgerhards, 2008-03-05 */ +DEFobjCurrIf(obj) +DEFobjCurrIf(datetime) DEFobjCurrIf(module) DEFobjCurrIf(errmsg) @@ -521,8 +524,8 @@ actionWriteToAction(action_t *pAction) * ... RAWMSG is a problem ... Please note that digital * signatures inside the message are also invalidated. */ - getCurrTime(&(pMsg->tRcvdAt)); - getCurrTime(&(pMsg->tTIMESTAMP)); + datetime.getCurrTime(&(pMsg->tRcvdAt)); + datetime.getCurrTime(&(pMsg->tTIMESTAMP)); MsgSetMSG(pMsg, (char*)szRepMsg); MsgSetRawMsg(pMsg, (char*)szRepMsg); @@ -689,6 +692,7 @@ rsRetVal actionClassInit(void) DEFiRet; /* request objects we use */ CHKiRet(objGetObjInterface(&obj)); /* this provides the root pointer for all other queries */ + CHKiRet(objUse(datetime, CORE_COMPONENT)); CHKiRet(objUse(module, CORE_COMPONENT)); CHKiRet(objUse(errmsg, CORE_COMPONENT)); @@ -62,7 +62,7 @@ DEFobjCurrIf(errmsg) * * Obviously, all caller-provided pointers must not be NULL... */ -void getCurrTime(struct syslogTime *t) +static void getCurrTime(struct syslogTime *t) { struct timeval tp; struct tm *tm; diff --git a/plugins/imfile/imfile.c b/plugins/imfile/imfile.c index aa866a6d..243004ab 100644 --- a/plugins/imfile/imfile.c +++ b/plugins/imfile/imfile.c @@ -40,6 +40,7 @@ #include "msg.h" #include "stream.h" #include "errmsg.h" +#include "datetime.h" MODULE_TYPE_INPUT /* must be present for input modules, do not remove */ @@ -48,6 +49,7 @@ MODULE_TYPE_INPUT /* must be present for input modules, do not remove */ /* Module static data */ DEF_IMOD_STATIC_DATA /* must be present, starts static data */ DEFobjCurrIf(errmsg) +DEFobjCurrIf(datetime) typedef struct fileInfo_s { uchar *pszFileName; @@ -88,7 +90,7 @@ static rsRetVal enqLine(fileInfo_t *pInfo, cstr_t *cstrLine) pMsg->iFacility = LOG_FAC(pInfo->iFacility); pMsg->iSeverity = LOG_PRI(pInfo->iSeverity); pMsg->bParseHOSTNAME = 0; - getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ + datetime.getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ CHKiRet(submitMsg(pMsg)); finalize_it: RETiRet; @@ -450,6 +452,7 @@ CODESTARTmodInit *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */ CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); + CHKiRet(objUse(datetime, CORE_COMPONENT)); CHKiRet(omsdRegCFSLineHdlr((uchar *)"inputfilename", 0, eCmdHdlrGetWord, NULL, &pszFileName, STD_LOADABLE_MODULE_ID)); @@ -913,7 +913,7 @@ logmsgInternal(int pri, char *msg, int flags) pMsg->iFacility = LOG_FAC(pri); pMsg->iSeverity = LOG_PRI(pri); pMsg->bParseHOSTNAME = 0; - getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ + datetime.getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ flags |= INTERNAL_MSG; if(bHaveMainQueue == 0) { /* not yet in queued mode */ @@ -1318,7 +1318,7 @@ static int parseRFCSyslogMsg(msg_t *pMsg, int flags) } if (flags & ADDDATE) { - getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ + datetime.getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ } /* HOSTNAME */ @@ -1402,7 +1402,7 @@ static int parseLegacySyslogMsg(msg_t *pMsg, int flags) * rgerhards 2004-12-03 */ if(flags & ADDDATE) { - getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ + datetime.getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */ } /* rgerhards, 2006-03-13: next, we parse the hostname and tag. But we @@ -34,10 +34,12 @@ #include "obj.h" #include "stringbuf.h" #include "sysvar.h" +#include "datetime.h" /* static data */ DEFobjStaticHelpers DEFobjCurrIf(var) +DEFobjCurrIf(datetime) /* Standard-Constructor @@ -81,7 +83,7 @@ getNOW(eNOWType eNow, cstr_t **ppStr) uchar szBuf[16]; struct syslogTime t; - getCurrTime(&t); + datetime.getCurrTime(&t); switch(eNow) { case NOW_NOW: snprintf((char*) szBuf, sizeof(szBuf)/sizeof(uchar), "%4.4d-%2.2d-%2.2d", t.year, t.month, t.day); @@ -189,6 +191,7 @@ ENDobjQueryInterface(sysvar) BEGINObjClassInit(sysvar, 1, OBJ_IS_CORE_MODULE) /* class, version */ /* request objects we use */ CHKiRet(objUse(var, CORE_COMPONENT)); + CHKiRet(objUse(datetime, CORE_COMPONENT)); /* set our own handlers */ OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, sysvarConstructFinalize); |