summaryrefslogtreecommitdiffstats
path: root/expr.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-19 14:07:10 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-19 14:07:10 +0000
commit47aab374d40c05cbb7a4ceb2a4236cb65a399c3a (patch)
treeccd3d7cff29b9033c274fcf72771aa50cf3aec74 /expr.c
parent296a9b0f0d1a1f6fb45d9741c5bcd32941250b3c (diff)
downloadrsyslog-47aab374d40c05cbb7a4ceb2a4236cb65a399c3a.tar.gz
rsyslog-47aab374d40c05cbb7a4ceb2a4236cb65a399c3a.tar.xz
rsyslog-47aab374d40c05cbb7a4ceb2a4236cb65a399c3a.zip
- added ctok class (the config tokenizer)
- done stage work to begin implement tokenizer
Diffstat (limited to 'expr.c')
-rw-r--r--expr.c54
1 files changed, 10 insertions, 44 deletions
diff --git a/expr.c b/expr.c
index dfdf5fc7..88098325 100644
--- a/expr.c
+++ b/expr.c
@@ -38,6 +38,8 @@
DEFobjStaticHelpers
+/* ------------------------------ actual expr object functions ------------------------------ */
+
/* Standard-Constructor
*/
BEGINobjConstruct(expr) /* be sure to specify the object type also in END macro! */
@@ -68,7 +70,7 @@ ENDobjDestruct(expr)
/* evaluate an expression and store the result. pMsg is optional, but if
* it is not given, no message-based variables can be accessed. The expression
* must previously have been created.
- * rgerhards, 2008-02-09
+ * rgerhards, 2008-02-09 (a rainy tenerife return flight day ;))
*/
rsRetVal
exprEval(expr_t *pThis, msg_t *pMsg)
@@ -89,7 +91,7 @@ exprEval(expr_t *pThis, msg_t *pMsg)
* Also, it is assumed that most callers will hold their private expression. If it
* is not shared, the caller can count on the string to remain stable as long as it
* does not reevaluate the expression (via exprEval or other means) or destruct it.
- * rgerhards, 2008-02-09
+ * rgerhards, 2008-02-09 (a rainy tenerife return flight day ;))
*/
rsRetVal
exprGetStr(expr_t *pThis, rsCStrObj **ppStr)
@@ -103,54 +105,18 @@ exprGetStr(expr_t *pThis, rsCStrObj **ppStr)
}
-/* parse an expression from a string. The string MUST include the full expression. The
- * expression object is only created if there is no error during parsing.
- * The string is a standard C string. It must NOT contain anything else but the
- * expression. Most importantly, it must not contain any comments after the
- * expression.
- * rgerhards, 2008-02-09 (a rainy tenerife return flight day ;))
+/* parse an expression object based on a given tokenizer
+ * rgerhards, 2008-02-19
*/
rsRetVal
-exprParseStr(expr_t **ppThis, uchar *p)
+exprParse(expr_t *pThis, ctok_t *ctok)
{
DEFiRet;
- expr_t *pThis = NULL;
-
- ASSERT(ppThis != NULL);
- ASSERT(p != NULL);
-
- CHKiRet(exprConstruct(&pThis));
-
- CHKiRet(rsCStrConstruct(&pThis->cstrConst));
- /* so far, we are a dummy - we just pull the first string and
- * ignore the rest...
- */
- while(*p && *p != '"')
- ++p; /* find begin of string */
- if(*p == '"')
- ++p; /* eat it */
-
- /* we got it, now copy over everything up until the end of the string */
- while(*p && *p != '"') {
- CHKiRet(rsCStrAppendChar(pThis->cstrConst, *p));
- ++p;
- }
-
- /* we are done with it... */
- CHKiRet(rsCStrFinish(pThis->cstrConst));
-
- CHKiRet(exprConstructFinalize(&pThis));
-
- /* we are successfully done, so store the result */
- *ppThis = pThis;
-
-finalize_it:
- if(iRet != RS_RET_OK) {
- if(pThis != NULL)
- exprDestruct(pThis);
- }
+ ISOBJ_TYPE_assert(pThis, expr);
+ ISOBJ_TYPE_assert(ctok, ctok);
+RUNLOG_STR("expr parser being called");
RETiRet;
}