diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-09-07 08:56:43 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-09-07 08:56:43 +0000 |
commit | 5b9f98ee20a245cd5245717b168d7428c6bdad31 (patch) | |
tree | 88b90809b1f9dd3e5dc4ad4eae925e6eed8b1d03 /cfsysline.c | |
parent | 62db9e53bd64b3c4ebd381e0d30c84e891aa9e00 (diff) | |
download | rsyslog-5b9f98ee20a245cd5245717b168d7428c6bdad31.tar.gz rsyslog-5b9f98ee20a245cd5245717b168d7428c6bdad31.tar.bz2 rsyslog-5b9f98ee20a245cd5245717b168d7428c6bdad31.zip |
- added eCmdHdlrGetWord command handler
- added $ModDir config directive
Diffstat (limited to 'cfsysline.c')
-rw-r--r-- | cfsysline.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cfsysline.c b/cfsysline.c index b17683c6..24e652d7 100644 --- a/cfsysline.c +++ b/cfsysline.c @@ -348,6 +348,58 @@ finalize_it: } +/* Parse and a word config line option. A word is a consequitive + * sequence of non-whitespace characters. pVal must be + * a pointer to a string which is to receive the option + * value. The returned string must be freed by the caller. + * rgerhards, 2007-09-07 + */ +static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void *pVal) +{ + DEFiRet; + rsCStrObj *pStrB; + uchar *p; + uchar *pNewVal; + + assert(pp != NULL); + assert(*pp != NULL); + + if((pStrB = rsCStrConstruct()) == NULL) + return RS_RET_OUT_OF_MEMORY; + + /* parse out the word */ + p = *pp; + + while(*p && !isspace((int) *p)) { + CHKiRet(rsCStrAppendChar(pStrB, *p++)); + } + CHKiRet(rsCStrFinish(pStrB)); + + CHKiRet(rsCStrConvSzStrAndDestruct(pStrB, &pNewVal, 0)); +dbgprintf("pNewVal: %s\n", pNewVal); + + /* we got the word, now set it */ + if(pSetHdlr == NULL) { + /* we should set value directly to var */ + *((uchar**)pVal) = pNewVal; + } else { + /* we set value via a set function */ + CHKiRet(pSetHdlr(pVal, pNewVal)); + } + + *pp = p; + skipWhiteSpace(pp); /* skip over any whitespace */ + +finalize_it: + if(iRet != RS_RET_OK) { + if(pStrB != NULL) + rsCStrDestruct(pStrB); + } + + return iRet; +} + + /* --------------- END functions for handling canned syntaxes --------------- */ /* destructor for cslCmdHdlr @@ -426,6 +478,9 @@ static rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine) case eCmdHdlrGetChar: pHdlr = doGetChar; break; + case eCmdHdlrGetWord: + pHdlr = doGetWord; + break; default: iRet = RS_RET_NOT_IMPLEMENTED; goto finalize_it; |