diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-04-02 12:48:46 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-04-02 12:48:46 +0200 |
commit | 5f397495524ffe460fe93d2f1069f3077f48b7b0 (patch) | |
tree | 57169cd55d4b0c8e2c9a5bcf9f4945d1a8ba157f /runtime | |
parent | e92a0db46dfd2661a92e41a678d982ce6d3eedde (diff) | |
parent | 3954f2e166c3cbd78c71819c8d6c25120042dbcf (diff) | |
download | rsyslog-5f397495524ffe460fe93d2f1069f3077f48b7b0.tar.gz rsyslog-5f397495524ffe460fe93d2f1069f3077f48b7b0.tar.xz rsyslog-5f397495524ffe460fe93d2f1069f3077f48b7b0.zip |
Merge branch 'master' into oracle
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/msg.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index 9aa2ce84..5d1f21fd 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -2405,6 +2405,40 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, } } + /* finally, we need to check if the property should be formatted in CSV + * format (we use RFC 4180, and always use double quotes). As of this writing, + * this should be the last action carried out on the property, but in the + * future there may be reasons to change that. -- rgerhards, 2009-04-02 + */ + if(pTpe->data.field.options.bCSV) { + /* we need to obtain a private copy, as we need to at least add the double quotes */ + int iBufLen = strlen(pRes); + char *pBStart; + char *pDst; + char *pSrc; + /* the malloc may be optimized, we currently use the worst case... */ + pBStart = pDst = malloc((2 * iBufLen + 3) * sizeof(char)); + if(pDst == NULL) { + if(*pbMustBeFreed == 1) + free(pRes); + *pbMustBeFreed = 0; + return "**OUT OF MEMORY**"; + } + pSrc = pRes; + *pDst++ = '"'; /* starting quote */ + while(*pSrc) { + if(*pSrc == '"') + *pDst++ = '"'; /* need to add double double quote (see RFC4180) */ + *pDst++ = *pSrc++; + } + *pDst++ = '"'; /* ending quote */ + *pDst = '\0'; + if(*pbMustBeFreed == 1) + free(pRes); + pRes = pBStart; + *pbMustBeFreed = 1; + } + /*dbgprintf("MsgGetProp(\"%s\"): \"%s\"\n", pName, pRes); only for verbose debug logging */ return(pRes); } |