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

« back to all changes in this revision

Viewing changes to template.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2009-06-23 12:12:43 UTC
  • mfrom: (1.1.11 upstream) (3.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20090623121243-d2fejarzidywnn17
Tags: 4.2.0-1
* New upstream release of the now stable v4 branch.
  - Fix warnings when /etc/rsyslog.d/ is empty. Closes: #530228
* debian/patches/imudp_multiple_udp_sockets.patch
  - Removed, merged upstream.
* debian/rsyslog.default
  - Set default compat mode to '4'.
* debian/rsyslog.logcheck.ignore.server
  - Update logcheck rules files to also ignore rsyslogd and imklog stop
    messages.
* debian/control
  - Bump Standards-Version to 3.8.2. No further changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
static struct template *tplLast = NULL; /* points to the last element of the template list */
48
48
static struct template *tplLastStatic = NULL; /* last static element of the template list */
49
49
 
 
50
 
 
51
 
50
52
/* This functions converts a template into a string. It should
51
53
 * actually be in template.c, but this requires larger re-structuring
52
54
 * of the code (because all the property-access functions are static
140
142
        RETiRet;
141
143
}
142
144
 
 
145
 
 
146
/* This functions converts a template into an array of strings.
 
147
 * For further general details, see the very similar funtion
 
148
 * tpltoString().
 
149
 * Instead of a string, an array of string pointers is returned by
 
150
 * thus function. The caller is repsonsible for destroying that array as
 
151
 * well as all of its elements. The array is of fixed size. It's end
 
152
 * is indicated by a NULL pointer.
 
153
 * rgerhards, 2009-04-03
 
154
 */
 
155
rsRetVal tplToArray(struct template *pTpl, msg_t *pMsg, uchar*** ppArr)
 
156
{
 
157
        DEFiRet;
 
158
        struct templateEntry *pTpe;
 
159
        uchar **pArr;
 
160
        int iArr;
 
161
        unsigned short bMustBeFreed;
 
162
        uchar *pVal;
 
163
 
 
164
        assert(pTpl != NULL);
 
165
        assert(pMsg != NULL);
 
166
        assert(ppArr != NULL);
 
167
 
 
168
        /* loop through the template. We obtain one value, create a
 
169
         * private copy (if necessary), add it to the string array
 
170
         * and then on to the next until we have processed everything.
 
171
         */
 
172
 
 
173
        CHKmalloc(pArr = calloc(pTpl->tpenElements + 1, sizeof(uchar*)));
 
174
        iArr = 0;
 
175
 
 
176
        pTpe = pTpl->pEntryRoot;
 
177
        while(pTpe != NULL) {
 
178
                if(pTpe->eEntryType == CONSTANT) {
 
179
                        CHKmalloc(pArr[iArr] = (uchar*)strdup((char*) pTpe->data.constant.pConstant));
 
180
                } else  if(pTpe->eEntryType == FIELD) {
 
181
                        pVal = (uchar*) MsgGetProp(pMsg, pTpe, NULL, &bMustBeFreed);
 
182
                        if(bMustBeFreed) { /* if it must be freed, it is our own private copy... */
 
183
                                pArr[iArr] = pVal; /* ... so we can use it! */
 
184
                        } else {
 
185
                                CHKmalloc(pArr[iArr] = (uchar*)strdup((char*) pVal));
 
186
                        }
 
187
                }
 
188
                iArr++;
 
189
                pTpe = pTpe->pNext;
 
190
        }
 
191
 
 
192
finalize_it:
 
193
        *ppArr = (iRet == RS_RET_OK) ? pArr : NULL;
 
194
 
 
195
        RETiRet;
 
196
}
 
197
 
 
198
 
143
199
/* Helper to doSQLEscape. This is called if doSQLEscape
144
200
 * runs out of memory allocating the escaped string.
145
201
 * Then we are in trouble. We can
460
516
                        pTpe->data.field.options.bSecPathDrop = 1;
461
517
                 } else if(!strcmp((char*)Buf, "secpath-replace")) {
462
518
                        pTpe->data.field.options.bSecPathReplace = 1;
 
519
                 } else if(!strcmp((char*)Buf, "csv")) {
 
520
                        pTpe->data.field.options.bCSV = 1;
463
521
                 } else {
464
522
                        dbgprintf("Invalid field option '%s' specified - ignored.\n", Buf);
465
523
                 }
1105
1163
                                if(pTpe->data.field.options.bSPIffNo1stSP) {
1106
1164
                                        dbgprintf("[SP iff no first SP] ");
1107
1165
                                }
 
1166
                                if(pTpe->data.field.options.bCSV) {
 
1167
                                        dbgprintf("[format as CSV (RFC4180)]");
 
1168
                                }
1108
1169
                                if(pTpe->data.field.options.bDropLastLF) {
1109
1170
                                        dbgprintf("[drop last LF in msg] ");
1110
1171
                                }