From 2962bfb7abb25bfeb8d0f818826992ab7c5ac62f Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 25 Mar 2008 09:16:41 +0000 Subject: added $HHOUR and $QHOUR system properties - can be used for half- and quarter-hour logfile rotation --- ChangeLog | 2 ++ doc/property_replacer.html | 12 ++++++++++++ msg.c | 18 +++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d9931505..84021a62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ Version 2.0.4 STABLE (rgerhards), 2008-03-?? - bugfix: internally generated messages had "FROMHOST" property not set - bugfix: continue parsing if tag is oversize (discard oversize part) - thanks to mclaughlin77@gmail.com for the patch +- added $HHOUR and $QHOUR system properties - can be used for half- and + quarter-hour logfile rotation --------------------------------------------------------------------------- Version 2.0.3 STABLE (rgerhards), 2008-03-12 - bugfix: setting for $EscapeCopntrolCharactersOnReceive was not diff --git a/doc/property_replacer.html b/doc/property_replacer.html index 4b98774b..8b777a73 100644 --- a/doc/property_replacer.html +++ b/doc/property_replacer.html @@ -71,6 +71,18 @@ only seconds) $DAYThe current day of the month (2-digit) $HOURThe current hour in military (24 hour) time (2-digit) + +$HHOUR +The current half hour we are in. From minute 0 to 29, +this is always 0 while +from 30 to 59 it is always 1. + + +$QHOUR +The current quarter hour we are in. Much like $HHOUR, but values +range from 0 to 3 (for the four quater hours that are in each hour) + + $MINUTEThe current minute (2-digit)

Properties starting with a $-sign are so-called system properties. These do diff --git a/msg.c b/msg.c index 5b211b8a..16180e56 100644 --- a/msg.c +++ b/msg.c @@ -1243,7 +1243,7 @@ char *textpri(char *pRes, size_t pResLen, int pri) * can not allocate memory, it returns a NULL pointer. * Added 2007-07-10 rgerhards */ -typedef enum ENOWType { NOW_NOW, NOW_YEAR, NOW_MONTH, NOW_DAY, NOW_HOUR, NOW_MINUTE } eNOWType; +typedef enum ENOWType { NOW_NOW, NOW_YEAR, NOW_MONTH, NOW_DAY, NOW_HOUR, NOW_HHOUR, NOW_QHOUR, NOW_MINUTE } eNOWType; #define tmpBUFSIZE 16 /* size of formatting buffer */ static uchar *getNOW(eNOWType eNow) { @@ -1272,6 +1272,12 @@ static uchar *getNOW(eNOWType eNow) case NOW_HOUR: snprintf((char*) pBuf, tmpBUFSIZE, "%2.2d", t.hour); break; + case NOW_HHOUR: + snprintf((char*) pBuf, tmpBUFSIZE, "%2.2d", t.hour / 30); + break; + case NOW_QHOUR: + snprintf((char*) pBuf, tmpBUFSIZE, "%2.2d", t.hour / 15); + break; case NOW_MINUTE: snprintf((char*) pBuf, tmpBUFSIZE, "%2.2d", t.minute); break; @@ -1424,6 +1430,16 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, return "***OUT OF MEMORY***"; } else *pbMustBeFreed = 1; /* all of these functions allocate dyn. memory */ + } else if(!strcmp((char*) pName, "$HHOUR")) { + if((pRes = (char*) getNOW(NOW_HHOUR)) == NULL) { + return "***OUT OF MEMORY***"; + } else + *pbMustBeFreed = 1; /* all of these functions allocate dyn. memory */ + } else if(!strcmp((char*) pName, "$QHOUR")) { + if((pRes = (char*) getNOW(NOW_QHOUR)) == NULL) { + return "***OUT OF MEMORY***"; + } else + *pbMustBeFreed = 1; /* all of these functions allocate dyn. memory */ } else if(!strcmp((char*) pName, "$MINUTE")) { if((pRes = (char*) getNOW(NOW_MINUTE)) == NULL) { return "***OUT OF MEMORY***"; -- cgit