Merge pull request #3063 from rgerhards/cleanup-tpl

cleanup: remove no longer needed code
This commit is contained in:
Rainer Gerhards 2018-09-26 23:04:38 +02:00 committed by GitHub
commit 3e481fda07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 76 deletions

View File

@ -268,81 +268,6 @@ finalize_it:
}
/* This functions converts a template into an array of strings.
* For further general details, see the very similar funtion
* tpltoString().
* Instead of a string, an array of string pointers is returned by
* thus function. The caller is repsonsible for destroying that array as
* well as all of its elements. The array is of fixed size. It's end
* is indicated by a NULL pointer.
* rgerhards, 2009-04-03
*/
rsRetVal
tplToArray(struct template *pTpl, smsg_t *pMsg, uchar*** ppArr, struct syslogTime *ttNow)
{
DEFiRet;
struct templateEntry *pTpe;
uchar **pArr;
int iArr;
rs_size_t propLen;
unsigned short bMustBeFreed;
uchar *pVal;
assert(pTpl != NULL);
assert(pMsg != NULL);
assert(ppArr != NULL);
if(pTpl->bHaveSubtree) {
/* Note: this mode is untested, as there is no official plugin
* using array passing, so I simply could not test it.
*/
CHKmalloc(pArr = calloc(2, sizeof(uchar*)));
getJSONPropVal(pMsg, &pTpl->subtree, &pVal, &propLen, &bMustBeFreed);
if(bMustBeFreed) { /* if it must be freed, it is our own private copy... */
pArr[0] = pVal; /* ... so we can use it! */
} else {
CHKmalloc(pArr[0] = (uchar*)strdup((char*) pVal));
}
FINALIZE;
}
/* loop through the template. We obtain one value, create a
* private copy (if necessary), add it to the string array
* and then on to the next until we have processed everything.
*/
CHKmalloc(pArr = calloc(pTpl->tpenElements + 1, sizeof(uchar*)));
iArr = 0;
pTpe = pTpl->pEntryRoot;
while(pTpe != NULL) {
if(pTpe->eEntryType == CONSTANT) {
CHKmalloc(pArr[iArr] = (uchar*)strdup((char*) pTpe->data.constant.pConstant));
} else if(pTpe->eEntryType == FIELD) {
pVal = (uchar*) MsgGetProp(pMsg, pTpe, &pTpe->data.field.msgProp,
&propLen, &bMustBeFreed, ttNow);
if(bMustBeFreed) { /* if it must be freed, it is our own private copy... */
pArr[iArr] = pVal; /* ... so we can use it! */
} else {
CHKmalloc(pArr[iArr] = (uchar*)strdup((char*) pVal));
}
}
iArr++;
pTpe = pTpe->pNext;
}
finalize_it:
*ppArr = (iRet == RS_RET_OK) ? pArr : NULL;
if(iRet == RS_RET_OK) {
*ppArr = pArr;
} else {
*ppArr = NULL;
free(pArr);
}
RETiRet;
}
/* This functions converts a template into a json object.
* For further general details, see the very similar funtion
* tpltoString().

View File

@ -163,7 +163,6 @@ int tplRequiresDateCall(struct template *pTpl);
* BEFORE msg.h, even if your code file does not actually need it.
* rgerhards, 2007-08-06
*/
rsRetVal tplToArray(struct template *pTpl, smsg_t *pMsg, uchar*** ppArr, struct syslogTime *ttNow);
rsRetVal tplToJSON(struct template *pTpl, smsg_t *pMsg, struct json_object **, struct syslogTime *ttNow);
rsRetVal doEscape(uchar **pp, rs_size_t *pLen, unsigned short *pbMustBeFreed, int escapeMode);
rsRetVal