diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-12-03 17:11:03 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-12-03 17:11:03 +0100 |
commit | 4618773be685488e081bebb397db32851dc16782 (patch) | |
tree | 744a80610a877eaa0f8ff5f552e17a5cbf0563a3 /runtime/stringbuf.c | |
parent | f871bd135a33c88a013f49402d0af87fb1f1de5d (diff) | |
download | rsyslog-4618773be685488e081bebb397db32851dc16782.tar.gz rsyslog-4618773be685488e081bebb397db32851dc16782.tar.bz2 rsyslog-4618773be685488e081bebb397db32851dc16782.zip |
milestone: added support for CEE-variables to RainerScript
Diffstat (limited to 'runtime/stringbuf.c')
-rw-r--r-- | runtime/stringbuf.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/runtime/stringbuf.c b/runtime/stringbuf.c index ccf115c1..f4a9caae 100644 --- a/runtime/stringbuf.c +++ b/runtime/stringbuf.c @@ -35,6 +35,7 @@ #include <string.h> #include <ctype.h> #include <sys/types.h> +#include <libestr.h> #include "rsyslog.h" #include "stringbuf.h" #include "srUtils.h" @@ -104,6 +105,34 @@ finalize_it: RETiRet; } + +/* construct from es_str_t string + * rgerhards 2010-12-03 + */ +rsRetVal cstrConstructFromESStr(cstr_t **ppThis, es_str_t *str) +{ + DEFiRet; + cstr_t *pThis; + + assert(ppThis != NULL); + + CHKiRet(rsCStrConstruct(&pThis)); + + pThis->iBufSize = pThis->iStrLen = es_strlen(str); + if((pThis->pBuf = (uchar*) MALLOC(sizeof(uchar) * pThis->iStrLen)) == NULL) { + RSFREEOBJ(pThis); + ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); + } + + /* we do NOT need to copy the \0! */ + memcpy(pThis->pBuf, es_getBufAddr(str), pThis->iStrLen); + + *ppThis = pThis; + +finalize_it: + RETiRet; +} + /* construct from CStr object. only the counted string is * copied, not the szString. * rgerhards 2005-10-18 |