summaryrefslogtreecommitdiffstats
path: root/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2004-12-08 09:31:30 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2004-12-08 09:31:30 +0000
commitba69aa639557cc57c6a07324567644eef2559e3b (patch)
tree2d57a543064341feeb62a72240dd150bcc3d080f /syslogd.c
parentb963b1c275a53aa250c0362d015105ba953b3b87 (diff)
downloadrsyslog-ba69aa639557cc57c6a07324567644eef2559e3b.tar.gz
rsyslog-ba69aa639557cc57c6a07324567644eef2559e3b.tar.xz
rsyslog-ba69aa639557cc57c6a07324567644eef2559e3b.zip
property option drop-last-lf added; some doc in test.conf
Diffstat (limited to 'syslogd.c')
-rw-r--r--syslogd.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/syslogd.c b/syslogd.c
index 8d611aba..067351f6 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -959,7 +959,7 @@ int Initialized = 0; /* set when we have initialized ourselves
extern int errno;
/* hardcoded standard templates (used for defaults) */
-static char template_TraditionalFormat[] = "\"%timegenerated% %HOSTNAME% %syslogtag%%msg%\n\"";
+static char template_TraditionalFormat[] = "\"%timegenerated% %HOSTNAME% %syslogtag%%msg:::drop-last-lf%\n\"";
static char template_WallFmt[] = "\"\r\n\7Message from syslogd@%HOSTNAME% at %timegenerated% ...\r\n %syslogtag%%msg%\n\r\"";
static char template_StdFwdFmt[] = "\"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%\"";
static char template_StdUsrMsgFmt[] = "\" %syslogtag%%msg%\n\r\"";
@@ -1924,14 +1924,12 @@ char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe, unsigned short *p
*/
// ++iFrom; /* nbr of chars to skip! */
while(*pRes && iFrom) {
- printf("%c", *pRes);
--iFrom;
++pRes;
}
}
/* OK, we are at the begin - now let's copy... */
while(*pRes && iLen) {
- printf("%c", *pRes);
*pBuf++ = *pRes;
++pRes;
--iLen;
@@ -1943,8 +1941,8 @@ char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe, unsigned short *p
*pbMustBeFreed = 1;
}
- /* case conversations (should go last, because so we are able to
- * work on the smalles possible buffer).
+ /* case conversations (should go after substring, because so we are able to
+ * work on the smallest possible buffer).
*/
if(pTpe->data.field.eCaseConv != tplCaseConvNo) {
/* we need to obtain a private copy */
@@ -1971,6 +1969,32 @@ char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe, unsigned short *p
*pbMustBeFreed = 1;
}
+ /* Now drop last LF if present (pls note that this must not be done
+ * if bEscapeCC was set! - once that is implemented ;)).
+ */
+ if(pTpe->data.field.options.bDropLastLF) {
+ int iLen = strlen(pRes);
+ char *pBuf;
+ if(*(pRes + iLen - 1) == '\n') {
+ /* we have a LF! */
+ /* check if we need to obtain a private copy */
+ if(pbMustBeFreed == 0) {
+ /* ok, original copy, need a private one */
+ pBuf = malloc((iLen + 1) * sizeof(char));
+ if(pBuf == NULL) {
+ if(*pbMustBeFreed == 1)
+ free(pRes);
+ *pbMustBeFreed = 0;
+ return "**OUT OF MEMORY**";
+ }
+ memcpy(pBuf, pRes, iLen - 1);
+ pRes = pBuf;
+ *pbMustBeFreed = 1;
+ }
+ *(pRes + iLen - 1) = '\0'; /* drop LF ;) */
+ }
+ }
+
/*dprintf("MsgGetProp(\"%s\"): \"%s\"\n", pName, pRes); only for verbose debug logging */
return(pRes);
}
@@ -3654,7 +3678,7 @@ const char *cvthname(f)
}
hp = gethostbyaddr((char *) &f->sin_addr, sizeof(struct in_addr), \
f->sin_family);
- if (hp == 0) {
+ if (hp == NULL) {
dprintf("Host name for your address (%s) unknown.\n",
inet_ntoa(f->sin_addr));
return (inet_ntoa(f->sin_addr));