diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2006-11-17 13:44:50 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2006-11-17 13:44:50 +0000 |
commit | b3497a08c81a02e82685160b329761266b3b692c (patch) | |
tree | 3aad883298762d6370ed5423332173f521402271 | |
parent | 42c47e4678f9cd49f0f095bb4a41f4c5e6bf57a2 (diff) | |
download | rsyslog-b3497a08c81a02e82685160b329761266b3b692c.tar.gz rsyslog-b3497a08c81a02e82685160b329761266b3b692c.tar.bz2 rsyslog-b3497a08c81a02e82685160b329761266b3b692c.zip |
property replacer options space-cc and drop-cc added
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | syslogd.c | 24 | ||||
-rw-r--r-- | template.c | 10 | ||||
-rw-r--r-- | template.h | 2 |
4 files changed, 35 insertions, 2 deletions
@@ -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 @@ -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); @@ -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] "); } @@ -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 */ |