Module: sip-router
Branch: andrei/switch
Commit: 2d6686519542ee12bedbe085500ed3cd6f87f280
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2d66865…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Feb 4 19:20:53 2009 +0100
expr engine: minor additions
- added rve_has_side_effects(), preliminary version
(for now is equivalent with !rve_is_constant())
- exported rve_destroy()
---
rvalue.c | 11 +++++++++++
rvalue.h | 4 ++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/rvalue.c b/rvalue.c
index 9e020ef..4c7472d 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -452,6 +452,17 @@ int rve_is_constant(struct rval_expr* rve)
+/** returns true if the expression has side-effects.
+ * @return 1 for possible side-effects, 0 for no side-effects
+ * TODO: add better checks
+ */
+int rve_has_side_effects(struct rval_expr* rve)
+{
+ return !rve_is_constant(rve);
+}
+
+
+
/** returns true if operator is unary (takes only 1 arg).
* @return 0 or 1 on
*/
diff --git a/rvalue.h b/rvalue.h
index a694c0d..88fd6f2 100644
--- a/rvalue.h
+++ b/rvalue.h
@@ -188,6 +188,8 @@ int rval_expr_eval_rvint( struct run_act_ctx* h, struct sip_msg* msg,
enum rval_type rve_guess_type(struct rval_expr* rve);
/** returns true if expression is constant. */
int rve_is_constant(struct rval_expr* rve);
+/** returns true if the expression can have side-effect */
+int rve_has_side_effects(struct rval_expr* rve);
/** returns 1 if expression is valid (type-wise).*/
int rve_check_type(enum rval_type* type, struct rval_expr* rve,
struct rval_expr** bad_rve, enum rval_type* bad_type,
@@ -206,6 +208,8 @@ struct rval_expr* mk_rval_expr1(enum rval_expr_op op, struct
rval_expr* rve1,
struct rval_expr* mk_rval_expr2(enum rval_expr_op op, struct rval_expr* rve1,
struct rval_expr* rve2,
struct cfg_pos* pos);
+/** destroys a pkg_malloc'ed rve. */
+void rve_destroy(struct rval_expr* rve);
/** fix a rval_expr. */
int fix_rval_expr(void** p);