~ubuntu-branches/ubuntu/lucid/rsyslog/lucid

« back to all changes in this revision

Viewing changes to template.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2007-10-19 17:21:49 UTC
  • Revision ID: james.westby@ubuntu.com-20071019172149-ie6ej2xve33mxiu7
Tags: upstream-1.19.10
ImportĀ upstreamĀ versionĀ 1.19.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
 */
 
6
 
 
7
#ifndef TEMPLATE_H_INCLUDED
 
8
#define TEMPLATE_H_INCLUDED 1
 
9
 
 
10
 
 
11
#include "stringbuf.h"
 
12
 
 
13
#ifdef FEATURE_REGEXP
 
14
/* Include regular expressions */
 
15
#include <regex.h>
 
16
#endif
 
17
 
 
18
struct template {
 
19
        struct template *pNext;
 
20
        char *pszName;
 
21
        int iLenName;
 
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" 
 
28
                                 */
 
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
 
31
         * than short...
 
32
         */
 
33
};
 
34
 
 
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 };
 
39
 
 
40
#include "msg.h"
 
41
 
 
42
/* a specific parse entry */
 
43
struct templateEntry {
 
44
        struct templateEntry *pNext;
 
45
        enum EntryTypes eEntryType;
 
46
        union {
 
47
                struct {
 
48
                        uchar *pConstant;       /* pointer to constant value */
 
49
                        int iLenConstant;       /* its length */
 
50
                } constant;
 
51
                struct {
 
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... */
 
55
#ifdef FEATURE_REGEXP
 
56
                        regex_t re;     /* APR: this is the regular expression */
 
57
                        unsigned has_regex;
 
58
#endif
 
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 */
 
71
                } field;
 
72
        } data;
 
73
};
 
74
 
 
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
 
87
 */
 
88
rsRetVal tplToString(struct template *pTpl, msg_t *pMsg, uchar** ppSz);
 
89
void doSQLEscape(uchar **pp, size_t *pLen, unsigned short *pbMustBeFreed, int escapeMode);
 
90
 
 
91
#endif /* #ifndef TEMPLATE_H_INCLUDED */
 
92
/*
 
93
 * vi:set ai:
 
94
 */