1
/* This is the header for template processing code of rsyslog.
2
* Please see syslogd.c for license information.
3
* This code is placed under the GPL.
4
* begun 2004-11-17 rgerhards
7
#ifndef TEMPLATE_H_INCLUDED
8
#define TEMPLATE_H_INCLUDED 1
11
#include "stringbuf.h"
14
/* Include regular expressions */
19
struct template *pNext;
22
int tpenElements; /* number of elements in templateEntry list */
23
struct templateEntry *pEntryRoot;
24
struct templateEntry *pEntryLast;
25
char optFormatForSQL; /* in text fields, 0 - do not escape,
26
* 1 - escape quotes by double quotes,
27
* 2 - escape "the MySQL way"
29
/* following are options. All are 0/1 defined (either on or off).
30
* we use chars because they are faster than bit fields and smaller
35
enum EntryTypes { UNDEFINED = 0, CONSTANT = 1, FIELD = 2 };
36
enum tplFormatTypes { tplFmtDefault = 0, tplFmtMySQLDate = 1,
37
tplFmtRFC3164Date = 2, tplFmtRFC3339Date = 3 };
38
enum tplFormatCaseConvTypes { tplCaseConvNo = 0, tplCaseConvUpper = 1, tplCaseConvLower = 2 };
42
/* a specific parse entry */
43
struct templateEntry {
44
struct templateEntry *pNext;
45
enum EntryTypes eEntryType;
48
uchar *pConstant; /* pointer to constant value */
49
int iLenConstant; /* its length */
52
uchar *pPropRepl; /* pointer to property replacer string */
53
unsigned iFromPos; /* for partial strings only chars from this position ... */
54
unsigned iToPos; /* up to that one... */
56
regex_t re; /* APR: this is the regular expression */
59
unsigned has_fields; /* support for field-counting: field to extract */
60
unsigned char field_delim; /* support for field-counting: field delemiter char */
61
enum tplFormatTypes eDateFormat;
62
enum tplFormatCaseConvTypes eCaseConv;
63
struct { /* bit fields! */
64
unsigned bDropCC: 1; /* drop control characters? */
65
unsigned bSpaceCC: 1; /* change control characters to spaceescape? */
66
unsigned bEscapeCC: 1; /* escape control characters? */
67
unsigned bDropLastLF: 1; /* drop last LF char in msg (PIX!) */
68
unsigned bSecPathDrop: 1; /* drop slashes, replace dots, empty string */
69
unsigned bSecPathReplace: 1; /* replace slashes, replace dots, empty string */
70
} options; /* options as bit fields */
75
struct template* tplConstruct(void);
76
struct template *tplAddLine(char* pName, unsigned char** pRestOfConfLine);
77
struct template *tplFind(char *pName, int iLenName);
78
int tplGetEntryCount(struct template *pTpl);
79
void tplDeleteAll(void);
80
void tplDeleteNew(void);
81
void tplPrintList(void);
82
void tplLastStaticInit(struct template *tpl);
83
/* note: if a compiler warning for undefined type tells you to look at this
84
* code line below, the actual cause is that you currently MUST include template.h
85
* BEFORE msg.h, even if your code file does not actually need it.
86
* rgerhards, 2007-08-06
88
rsRetVal tplToString(struct template *pTpl, msg_t *pMsg, uchar** ppSz);
89
void doSQLEscape(uchar **pp, size_t *pLen, unsigned short *pbMustBeFreed, int escapeMode);
91
#endif /* #ifndef TEMPLATE_H_INCLUDED */