summaryrefslogtreecommitdiffstats
path: root/msg.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-03-25 09:23:31 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-03-25 09:23:31 +0000
commit752ec6ceddf2783de237bd3f1353c0926c90991b (patch)
treef435ca1b0ea8c0da7b398be5459138b9cda7b9a1 /msg.c
parentdb04482e56e4a815b8a36358aac6756595ed1a8e (diff)
downloadrsyslog-752ec6ceddf2783de237bd3f1353c0926c90991b.tar.gz
rsyslog-752ec6ceddf2783de237bd3f1353c0926c90991b.tar.xz
rsyslog-752ec6ceddf2783de237bd3f1353c0926c90991b.zip
added $HHOUR and $QHOUR system properties - can be used for half- and
quarter-hour logfile rotation
Diffstat (limited to 'msg.c')
-rw-r--r--msg.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/msg.c b/msg.c
index d4291a66..d2713871 100644
--- a/msg.c
+++ b/msg.c
@@ -1479,7 +1479,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)
{
@@ -1508,6 +1508,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;
@@ -1660,6 +1666,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***";