summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2006-11-17 13:44:50 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2006-11-17 13:44:50 +0000
commitb3497a08c81a02e82685160b329761266b3b692c (patch)
tree3aad883298762d6370ed5423332173f521402271
parent42c47e4678f9cd49f0f095bb4a41f4c5e6bf57a2 (diff)
downloadrsyslog-b3497a08c81a02e82685160b329761266b3b692c.tar.gz
rsyslog-b3497a08c81a02e82685160b329761266b3b692c.tar.xz
rsyslog-b3497a08c81a02e82685160b329761266b3b692c.zip
property replacer options space-cc and drop-cc added
-rw-r--r--NEWS1
-rw-r--r--syslogd.c24
-rw-r--r--template.c10
-rw-r--r--template.h2
4 files changed, 35 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 575208f3..90af4abe 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@
Version 1.12.4 (RGer), 2006-??-??
- added '$' as ToPos proptery replacer specifier - means "up to the
end of the string
+- property replacer option "escape-cc", "drop-cc" and "space-cc" added
---------------------------------------------------------------------------
Version 1.12.3 (RGer), 2006-10-04
- implemented some changes to support Solaris (but support is not
diff --git a/syslogd.c b/syslogd.c
index a2b78a54..d52edcaf 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -3318,9 +3318,29 @@ static char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe,
}
/* now do control character dropping/escaping/replacement
+ * Only one of these can be used. If multiple options are given, the
+ * result is random (though currently there obviously is an order of
+ * preferrence, see code below. But this is NOT guaranteed.
* RGerhards, 2006-11-17
*/
- if(pTpe->data.field.options.bEscapeCC) {
+ if(pTpe->data.field.options.bDropCC) {
+ char *pSrc = pRes;
+ char *pDst = pRes;
+
+ while(*pSrc) {
+ if(!iscntrl(*pSrc))
+ *pDst++ = *pSrc;
+ ++pSrc;
+ }
+ *pDst = '\0';
+ } else if(pTpe->data.field.options.bSpaceCC) {
+ char *pBuf = pRes;
+ while(*pBuf) {
+ if(iscntrl(*pBuf))
+ *pBuf = ' ';
+ ++pBuf;
+ }
+ } else if(pTpe->data.field.options.bEscapeCC) {
/* we must first count how many control charactes are
* present, because we need this to compute the new string
* buffer length. While doing so, we also compute the string
@@ -3369,7 +3389,7 @@ static char *MsgGetProp(struct msg *pMsg, struct templateEntry *pTpe,
}
/* Now drop last LF if present (pls note that this must not be done
- * if bEscapeCC was set! - once that is implemented ;)).
+ * if bEscapeCC was set!
*/
if(pTpe->data.field.options.bDropLastLF && !pTpe->data.field.options.bEscapeCC) {
int iLen = strlen(pRes);
diff --git a/template.c b/template.c
index 2cb6b8cc..b749a6bd 100644
--- a/template.c
+++ b/template.c
@@ -212,6 +212,10 @@ static void doOptions(char **pp, struct templateEntry *pTpe)
pTpe->data.field.eCaseConv = tplCaseConvUpper;
} else if(!strcmp(Buf, "escape-cc")) {
pTpe->data.field.options.bEscapeCC = 1;
+ } else if(!strcmp(Buf, "drop-cc")) {
+ pTpe->data.field.options.bDropCC = 1;
+ } else if(!strcmp(Buf, "space-cc")) {
+ pTpe->data.field.options.bSpaceCC = 1;
} else if(!strcmp(Buf, "drop-last-lf")) {
pTpe->data.field.options.bDropLastLF = 1;
} else {
@@ -676,6 +680,12 @@ void tplPrintList(void)
if(pTpe->data.field.options.bEscapeCC) {
dprintf("[escape control-characters] ");
}
+ if(pTpe->data.field.options.bDropCC) {
+ dprintf("[drop control-characters] ");
+ }
+ if(pTpe->data.field.options.bSpaceCC) {
+ dprintf("[replace control-characters with space] ");
+ }
if(pTpe->data.field.options.bDropLastLF) {
dprintf("[drop last LF in msg] ");
}
diff --git a/template.h b/template.h
index 591a8c98..80770895 100644
--- a/template.h
+++ b/template.h
@@ -53,6 +53,8 @@ struct templateEntry {
enum tplFormatTypes eDateFormat;
enum tplFormatCaseConvTypes eCaseConv;
struct { /* bit fields! */
+ unsigned bDropCC: 1; /* drop control characters? */
+ unsigned bSpaceCC: 1; /* change control characters to spaceescape? */
unsigned bEscapeCC: 1; /* escape control characters? */
unsigned bDropLastLF: 1; /* drop last LF char in msg (PIX!) */
} options; /* options as bit fields */