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 */
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
146
/* This functions converts a template into an array of strings.
147
* For further general details, see the very similar funtion
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
155
rsRetVal tplToArray(struct template *pTpl, msg_t *pMsg, uchar*** ppArr)
158
struct templateEntry *pTpe;
161
unsigned short bMustBeFreed;
164
assert(pTpl != NULL);
165
assert(pMsg != NULL);
166
assert(ppArr != NULL);
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.
173
CHKmalloc(pArr = calloc(pTpl->tpenElements + 1, sizeof(uchar*)));
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! */
185
CHKmalloc(pArr[iArr] = (uchar*)strdup((char*) pVal));
193
*ppArr = (iRet == RS_RET_OK) ? pArr : NULL;
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;
464
522
dbgprintf("Invalid field option '%s' specified - ignored.\n", Buf);
1105
1163
if(pTpe->data.field.options.bSPIffNo1stSP) {
1106
1164
dbgprintf("[SP iff no first SP] ");
1166
if(pTpe->data.field.options.bCSV) {
1167
dbgprintf("[format as CSV (RFC4180)]");
1108
1169
if(pTpe->data.field.options.bDropLastLF) {
1109
1170
dbgprintf("[drop last LF in msg] ");