summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-05 16:37:16 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-05 16:37:16 +0000
commit1560e84ff87dafd0d8b4fef3294a7a412e95b1c3 (patch)
treebf5c11bc46e720b0270889375522dbb19dbef336
parent23910636176e49b47cb7c110c09dbbe0c7bdc9ca (diff)
downloadrsyslog-1560e84ff87dafd0d8b4fef3294a7a412e95b1c3.tar.gz
rsyslog-1560e84ff87dafd0d8b4fef3294a7a412e95b1c3.tar.xz
rsyslog-1560e84ff87dafd0d8b4fef3294a7a412e95b1c3.zip
moved date/time handling functions to their own object (2nd pass)
-rw-r--r--action.c10
-rw-r--r--datetime.c2
-rw-r--r--plugins/imfile/imfile.c5
-rw-r--r--syslogd.c6
-rw-r--r--sysvar.c5
5 files changed, 19 insertions, 9 deletions
diff --git a/action.c b/action.c
index 5095993a..0fee9b23 100644
--- a/action.c
+++ b/action.c
@@ -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));
diff --git a/datetime.c b/datetime.c
index 9ecd32b3..1c3b1603 100644
--- a/datetime.c
+++ b/datetime.c
@@ -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));
diff --git a/syslogd.c b/syslogd.c
index e4685715..edbeddfe 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -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
diff --git a/sysvar.c b/sysvar.c
index 6fb2aab3..1b770ff2 100644
--- a/sysvar.c
+++ b/sysvar.c
@@ -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);