summaryrefslogtreecommitdiffstats
path: root/template.h
diff options
context:
space:
mode:
authorNathan Scott <nathans@aconex.com>2011-08-15 22:22:05 +1000
committerRainer Gerhards <rgerhards@adiscon.com>2012-01-17 10:29:02 +0100
commit052b1c75945106c6336fd0c172fbaa129248334c (patch)
treee737f950dc50321f6272af2f4bb913ef1e0c88b0 /template.h
parent92f7e549df5a1333f037cf3b290e3087fd9ad5da (diff)
downloadrsyslog-052b1c75945106c6336fd0c172fbaa129248334c.tar.gz
rsyslog-052b1c75945106c6336fd0c172fbaa129248334c.tar.xz
rsyslog-052b1c75945106c6336fd0c172fbaa129248334c.zip
add JSON escaping option
Following the path taken by the two SQL formatting options, which escape single quotes with double quotes (amongst other things), this patch adds a JSON quoting option. JSON is the opposite to the SQL options, requiring double quotes to be quoted within a string. This patch provides a formatting option implementing this requirement, while piggy-backing on the existing code as much as possible. Signed-off-by: Nathan Scott <nathans@aconex.com>
Diffstat (limited to 'template.h')
-rw-r--r--template.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/template.h b/template.h
index f7ac2e08..b5598b6d 100644
--- a/template.h
+++ b/template.h
@@ -36,9 +36,10 @@ struct template {
int tpenElements; /* number of elements in templateEntry list */
struct templateEntry *pEntryRoot;
struct templateEntry *pEntryLast;
- char optFormatForSQL; /* in text fields, 0 - do not escape,
- * 1 - escape quotes by double quotes,
- * 2 - escape "the MySQL way"
+ char optFormatEscape; /* in text fields, 0 - do not escape,
+ * 1 - escape "the MySQL way"
+ * 2 - escape quotes by double quotes,
+ * 3 - escape double quotes for JSON.
*/
/* following are options. All are 0/1 defined (either on or off).
* we use chars because they are faster than bit fields and smaller
@@ -130,7 +131,7 @@ rsRetVal ExtendBuf(uchar **pBuf, size_t *pLenBuf, size_t iMinSize);
*/
rsRetVal tplToArray(struct template *pTpl, msg_t *pMsg, uchar*** ppArr);
rsRetVal tplToString(struct template *pTpl, msg_t *pMsg, uchar** ppSz, size_t *);
-rsRetVal doSQLEscape(uchar **pp, size_t *pLen, unsigned short *pbMustBeFreed, int escapeMode);
+rsRetVal doEscape(uchar **pp, size_t *pLen, unsigned short *pbMustBeFreed, int escapeMode);
rsRetVal templateInit();