From b8d74973cffc504a76c543f65940a4810633efe5 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Wed, 16 Nov 2022 14:20:38 +0100 Subject: [PATCH] core: rename RV_INT to RV_LONG and RVE_INT_OP to RVE_LONG_OP --- src/core/cfg.y | 12 +-- src/core/lvalue.c | 4 +- src/core/route.c | 10 +-- src/core/rvalue.c | 186 +++++++++++++++++++++++----------------------- src/core/rvalue.h | 8 +- 5 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/core/cfg.y b/src/core/cfg.y index 02cb7bd90c1..89eb5c210f6 100644 --- a/src/core/cfg.y +++ b/src/core/cfg.y @@ -2438,7 +2438,7 @@ preprocess_stm: }else if (!rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){ yyerror("invalid expression"); $$=0; - }else if (i_tmp!=RV_INT && i_tmp!=RV_NONE){ + }else if (i_tmp!=RV_LONG && i_tmp!=RV_NONE){ yyerror("invalid expression type, int expected\n"); $$=0; }else @@ -2562,7 +2562,7 @@ exp_elem: $$=0; if (rve_is_constant($3)){ i_tmp=rve_guess_type($3); - if (i_tmp==RV_INT) + if (i_tmp==RV_LONG) yyerror("string expected"); else if (i_tmp==RV_STR){ if (((rval_tmp=rval_expr_eval(0, 0, $3))==0) || @@ -2806,7 +2806,7 @@ ct_rval: rval_expr { } else if ($1 && !rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){ yyerror("invalid expression (bad type)"); - }else if ($1 && i_tmp!=RV_INT){ + }else if ($1 && i_tmp!=RV_LONG){ yyerror("invalid expression type, int expected\n"); */ }else @@ -3166,7 +3166,7 @@ lval: attr_id_ass { } ; -rval: intno {$$=mk_rve_rval(RV_INT, (void*)$1); } +rval: intno {$$=mk_rve_rval(RV_LONG, (void*)$1); } | STRING { s_tmp.s=$1; s_tmp.len=strlen($1); $$=mk_rve_rval(RV_STR, &s_tmp); } | attr_id_any {$$=mk_rve_rval(RV_AVP, $1); pkg_free($1); } @@ -3217,7 +3217,7 @@ rval_expr: rval { $$=$1; } } | rve_un_op rval_expr %prec UNARY {$$=mk_rve1($1, $2); } - | INTCAST rval_expr {$$=mk_rve1(RVE_INT_OP, $2); } + | INTCAST rval_expr {$$=mk_rve1(RVE_LONG_OP, $2); } | STRCAST rval_expr {$$=mk_rve1(RVE_STR_OP, $2); } | rval_expr PLUS rval_expr {$$=mk_rve2(RVE_PLUS_OP, $1, $3); } | rval_expr MINUS rval_expr {$$=mk_rve2(RVE_MINUS_OP, $1, $3); } @@ -4033,7 +4033,7 @@ static int rval_expr_int_check(struct rval_expr *rve) else yyerror("BUG: unexpected null \"bad\" expression\n"); return -1; - }else if (type!=RV_INT && type!=RV_NONE){ + }else if (type!=RV_LONG && type!=RV_NONE){ warn_at(&rve->fpos, "non-int expression (you might want to use" " casts)\n"); return 1; diff --git a/src/core/lvalue.c b/src/core/lvalue.c index 5d779cfbcef..72adaad6c76 100644 --- a/src/core/lvalue.c +++ b/src/core/lvalue.c @@ -92,7 +92,7 @@ inline static int lval_avp_assign(struct run_act_ctx* h, struct sip_msg* msg, AVP_ASSIGN_NOVAL(); ret=-1; break; - case RV_INT: + case RV_LONG: value.n=rv->v.l; flags=avp->type & ~AVP_VAL_STR; ret=!(!value.n); @@ -268,7 +268,7 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg, PVAR_ASSIGN_NOVAL(); ret=-1; break; - case RV_INT: + case RV_LONG: pval.flags=PV_TYPE_INT|PV_VAL_INT; pval.ri=rv->v.l; ret=!(!pval.ri); diff --git a/src/core/route.c b/src/core/route.c index f520804312b..796fe0feb5c 100644 --- a/src/core/route.c +++ b/src/core/route.c @@ -298,7 +298,7 @@ static int exp_optimize_left(struct expr* exp) if (rve->op==RVE_RVAL_OP){ rval=&rve->left.rval; switch(rval->type){ - case RV_INT: + case RV_LONG: if (exp->op==NO_OP){ exp->l_type=NUMBER_O; exp->l.param=0; @@ -408,7 +408,7 @@ static int exp_optimize_right(struct expr* exp) if (rve->op==RVE_RVAL_OP){ rval=&rve->left.rval; switch(rval->type){ - case RV_INT: + case RV_LONG: exp->r_type=NUMBER_ST; exp->r.numval=rval->v.l; rval_destroy(rval); @@ -712,7 +712,7 @@ int fix_actions(struct action* a) /* it's not an error anymore to have non-int in an if, only a script warning (to allow backward compat. stuff like if (@ruri) - if (rve_type!=RV_INT && rve_type!=RV_NONE){ + if (rve_type!=RV_LONG && rve_type!=RV_NONE){ LM_ERR("fix_actions: invalid expression (%d,%d):" " bad type, integer expected\n", rve->fpos.s_line, rve->fpos.s_col); @@ -786,7 +786,7 @@ int fix_actions(struct action* a) ret = E_SCRIPT; goto error; } - if (rve_type!=RV_INT && rve_type!=RV_NONE){ + if (rve_type!=RV_LONG && rve_type!=RV_NONE){ LM_ERR("invalid expression (%d,%d): bad type, integer expected\n", rve->fpos.s_line, rve->fpos.s_col); ret = E_SCRIPT; @@ -827,7 +827,7 @@ int fix_actions(struct action* a) ret = E_SCRIPT; goto error; } - if (rve_type!=RV_INT && rve_type!=RV_NONE){ + if (rve_type!=RV_LONG && rve_type!=RV_NONE){ LM_ERR("invalid expression (%d,%d): bad type, integer expected\n", rve->fpos.s_line, rve->fpos.s_col); ret = E_SCRIPT; diff --git a/src/core/rvalue.c b/src/core/rvalue.c index 902f3c2c66b..9e5268c888d 100644 --- a/src/core/rvalue.c +++ b/src/core/rvalue.c @@ -332,7 +332,7 @@ char* rval_type_name(enum rval_type type) switch(type){ case RV_NONE: return "none"; - case RV_INT: + case RV_LONG: return "int"; case RV_STR: return "str"; @@ -385,7 +385,7 @@ struct rvalue* rval_new(enum rval_type t, union rval_val* v, int extra_size) /** - * @brief get rvalue basic type (RV_INT or RV_STR) + * @brief get rvalue basic type (RV_LONG or RV_STR) * * Given a rvalue it tries to determinte its basic type. * Fills val_cache if non-null and empty (can be used in other rval* @@ -413,12 +413,12 @@ inline static enum rval_type rval_get_btype(struct run_act_ctx* h, enum rval_type* ptype; switch(rv->type){ - case RV_INT: + case RV_LONG: case RV_STR: return rv->type; case RV_BEXPR: case RV_ACTION_ST: - return RV_INT; + return RV_LONG; case RV_PVAR: if (likely(val_cache && val_cache->cache_type==RV_CACHE_EMPTY)){ pv=&val_cache->c.pval; @@ -431,10 +431,10 @@ inline static enum rval_type rval_get_btype(struct run_act_ctx* h, if (likely(pv_get_spec_value(msg, &rv->v.pvs, pv)==0)){ if (pv->flags & PV_TYPE_INT){ if (likely(val_cache!=0)) - val_cache->val_type=RV_INT; + val_cache->val_type=RV_LONG; else pv_value_destroy(pv); - return RV_INT; + return RV_LONG; }else if (pv->flags & PV_VAL_STR){ if (likely(val_cache!=0)) val_cache->val_type=RV_STR; @@ -469,8 +469,8 @@ inline static enum rval_type rval_get_btype(struct run_act_ctx* h, *ptype=RV_STR; return RV_STR; }else{ - *ptype=RV_INT; - return RV_INT; + *ptype=RV_LONG; + return RV_LONG; } }else{ *ptype=RV_NONE; @@ -489,7 +489,7 @@ inline static enum rval_type rval_get_btype(struct run_act_ctx* h, /** guess the type of an expression. - * @return RV_INT, RV_STR or RV_NONE (when type could not be found, + * @return RV_LONG, RV_STR or RV_NONE (when type could not be found, * e.g. avp or pvar) */ enum rval_type rve_guess_type( struct rval_expr* rve) @@ -500,10 +500,10 @@ enum rval_type rve_guess_type( struct rval_expr* rve) case RV_STR: case RV_SEL: return RV_STR; - case RV_INT: + case RV_LONG: case RV_BEXPR: case RV_ACTION_ST: - return RV_INT; + return RV_LONG; case RV_PVAR: case RV_AVP: case RV_NONE: @@ -541,8 +541,8 @@ enum rval_type rve_guess_type( struct rval_expr* rve) case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: - return RV_INT; + case RVE_LONG_OP: + return RV_LONG; case RVE_PLUS_OP: /* '+' evaluates to the type of the left operand */ return rve_guess_type(rve->left.rve); @@ -572,7 +572,7 @@ int rve_is_constant(struct rval_expr* rve) switch(rve->left.rval.type){ case RV_STR: return 1; - case RV_INT: + case RV_LONG: return 1; case RV_SEL: case RV_BEXPR: @@ -591,7 +591,7 @@ int rve_is_constant(struct rval_expr* rve) case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: case RVE_STR_OP: return rve_is_constant(rve->left.rve); case RVE_MINUS_OP: @@ -658,7 +658,7 @@ static int rve_op_unary(enum rval_expr_op op) case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: case RVE_STR_OP: return 1; case RVE_MINUS_OP: @@ -700,7 +700,7 @@ static int rve_op_unary(enum rval_expr_op op) /** * @brief Returns 1 if expression is valid (type-wise) - * @param type filled with the type of the expression (RV_INT, RV_STR or + * @param type filled with the type of the expression (RV_LONG, RV_STR or * RV_NONE if it's dynamic) * @param rve checked expression * @param bad_rve set on failure to the subexpression for which the @@ -709,7 +709,7 @@ static int rve_op_unary(enum rval_expr_op op) * @param exp_t set on failure to the expected type for the bad * subexpression * @return 0 or 1 and sets *type to the resulting type - * (RV_INT, RV_STR or RV_NONE if it can be found only at runtime) + * (RV_LONG, RV_STR or RV_NONE if it can be found only at runtime) */ int rve_check_type(enum rval_type* type, struct rval_expr* rve, struct rval_expr** bad_rve, @@ -730,12 +730,12 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, case RVE_BOOL_OP: case RVE_LNOT_OP: case RVE_BNOT_OP: - *type=RV_INT; + *type=RV_LONG; if (rve_check_type(&type1, rve->left.rve, bad_rve, bad_t, exp_t)){ if (type1==RV_STR){ if (bad_rve) *bad_rve=rve->left.rve; if (bad_t) *bad_t=type1; - if (exp_t) *exp_t=RV_INT; + if (exp_t) *exp_t=RV_LONG; return 0; } return 1; @@ -760,12 +760,12 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, case RVE_IEQ_OP: case RVE_IDIFF_OP: case RVE_IPLUS_OP: - *type=RV_INT; + *type=RV_LONG; if (rve_check_type(&type1, rve->left.rve, bad_rve, bad_t, exp_t)){ if (type1==RV_STR){ if (bad_rve) *bad_rve=rve->left.rve; if (bad_t) *bad_t=type1; - if (exp_t) *exp_t=RV_INT; + if (exp_t) *exp_t=RV_LONG; return 0; } if (rve_check_type(&type2, rve->right.rve, bad_rve, @@ -773,7 +773,7 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, if (type2==RV_STR){ if (bad_rve) *bad_rve=rve->right.rve; if (bad_t) *bad_t=type2; - if (exp_t) *exp_t=RV_INT; + if (exp_t) *exp_t=RV_LONG; return 0; } return 1; @@ -782,13 +782,13 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, return 0; case RVE_EQ_OP: case RVE_DIFF_OP: - *type=RV_INT; + *type=RV_LONG; if (rve_check_type(&type1, rve->left.rve, bad_rve, bad_t, exp_t)){ if (rve_check_type(&type2, rve->right.rve, bad_rve, bad_t, exp_t)){ if ((type2!=type1) && (type1!=RV_NONE) && (type2!=RV_NONE) && - !(type1==RV_STR && type2==RV_INT)){ + !(type1==RV_STR && type2==RV_LONG)){ if (bad_rve) *bad_rve=rve->right.rve; if (bad_t) *bad_t=type2; if (exp_t) *exp_t=type1; @@ -805,7 +805,7 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, exp_t)){ if ((type2!=type1) && (type1!=RV_NONE) && (type2!=RV_NONE) && - !(type1==RV_STR && type2==RV_INT)){ + !(type1==RV_STR && type2==RV_LONG)){ if (bad_rve) *bad_rve=rve->right.rve; if (bad_t) *bad_t=type2; if (exp_t) *exp_t=type1; @@ -823,13 +823,13 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, exp_t)){ if ((type2!=type1) && (type1!=RV_NONE) && (type2!=RV_NONE) && - !(type1==RV_STR && type2==RV_INT)){ + !(type1==RV_STR && type2==RV_LONG)){ if (bad_rve) *bad_rve=rve->right.rve; if (bad_t) *bad_t=type2; if (exp_t) *exp_t=type1; return 0; } - if (type1==RV_INT){ + if (type1==RV_LONG){ if (bad_rve) *bad_rve=rve->left.rve; if (bad_t) *bad_t=type1; if (exp_t) *exp_t=RV_STR; @@ -842,19 +842,19 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, case RVE_STREQ_OP: case RVE_STRDIFF_OP: case RVE_MATCH_OP: - *type=RV_INT; + *type=RV_LONG; if (rve_check_type(&type1, rve->left.rve, bad_rve, bad_t, exp_t)){ if (rve_check_type(&type2, rve->right.rve, bad_rve, bad_t, exp_t)){ if ((type2!=type1) && (type1!=RV_NONE) && (type2!=RV_NONE) && - !(type1==RV_STR && type2==RV_INT)){ + !(type1==RV_STR && type2==RV_LONG)){ if (bad_rve) *bad_rve=rve->right.rve; if (bad_t) *bad_t=type2; if (exp_t) *exp_t=type1; return 0; } - if (type1==RV_INT){ + if (type1==RV_LONG){ if (bad_rve) *bad_rve=rve->left.rve; if (bad_t) *bad_t=type1; if (exp_t) *exp_t=RV_STR; @@ -868,9 +868,9 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - *type=RV_INT; + *type=RV_LONG; if (rve_check_type(&type1, rve->left.rve, bad_rve, bad_t, exp_t)){ - if (type1==RV_INT){ + if (type1==RV_LONG){ if (bad_rve) *bad_rve=rve->left.rve; if (bad_t) *bad_t=type1; if (exp_t) *exp_t=RV_STR; @@ -879,8 +879,8 @@ int rve_check_type(enum rval_type* type, struct rval_expr* rve, return 1; } break; - case RVE_INT_OP: - *type=RV_INT; + case RVE_LONG_OP: + *type=RV_LONG; return 1; break; case RVE_STR_OP: @@ -931,7 +931,7 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg, s=0; ret=0; switch(rv->type){ - case RV_INT: + case RV_LONG: *i=rv->v.l; break; case RV_STR: @@ -964,7 +964,7 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg, goto rv_str; case RV_AVP: if (unlikely(cache && cache->cache_type==RV_CACHE_AVP)){ - if (likely(cache->val_type==RV_INT)){ + if (likely(cache->val_type==RV_LONG)){ *i=cache->c.avp_val.n; }else if (cache->val_type==RV_STR){ s=&cache->c.avp_val.s; @@ -989,7 +989,7 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg, break; case RV_PVAR: if (unlikely(cache && cache->cache_type==RV_CACHE_PVAR)){ - if (likely((cache->val_type==RV_INT) || + if (likely((cache->val_type==RV_LONG) || (cache->c.pval.flags & PV_VAL_INT))){ *i=cache->c.pval.ri; }else if (cache->val_type==RV_STR){ @@ -1141,7 +1141,7 @@ int rval_get_tmp_str(struct run_act_ctx* h, struct sip_msg* msg, } switch(rv->type){ - case RV_INT: + case RV_LONG: tmpv->s=sint2strbuf(rv->v.l, tmp_cache->i2s, sizeof(tmp_cache->i2s), &tmpv->len); tmp_cache->cache_type = RV_CACHE_INT2STR; @@ -1187,7 +1187,7 @@ int rval_get_tmp_str(struct run_act_ctx* h, struct sip_msg* msg, if (likely(cache && cache->cache_type==RV_CACHE_AVP)){ if (likely(cache->val_type==RV_STR)){ *tmpv=cache->c.avp_val.s; - }else if (cache->val_type==RV_INT){ + }else if (cache->val_type==RV_LONG){ i=cache->c.avp_val.n; tmpv->s=sint2strbuf(i, tmp_cache->i2s, sizeof(tmp_cache->i2s), &tmpv->len); @@ -1217,7 +1217,7 @@ int rval_get_tmp_str(struct run_act_ctx* h, struct sip_msg* msg, if (likely(cache && cache->cache_type==RV_CACHE_PVAR)){ if (likely(cache->val_type==RV_STR)){ *tmpv=cache->c.pval.rs; - }else if (cache->val_type==RV_INT){ + }else if (cache->val_type==RV_LONG){ i=cache->c.pval.ri; tmpv->s=sint2strbuf(i, tmp_cache->i2s, sizeof(tmp_cache->i2s), &tmpv->len); @@ -1339,11 +1339,11 @@ struct rvalue* rval_convert(struct run_act_ctx* h, struct sip_msg* msg, return v; } switch(type){ - case RV_INT: + case RV_LONG: if (unlikely(rval_get_int(h, msg, &i, v, c) < 0)) return 0; val.l=i; - return rval_new(RV_INT, &val, 0); + return rval_new(RV_LONG, &val, 0); case RV_STR: rval_cache_init(&tmp_cache); if (unlikely(rval_get_tmp_str(h, msg, &tmp, v, c, &tmp_cache) < 0)) @@ -1559,7 +1559,7 @@ inline static struct rvalue* rval_intop1(struct run_act_ctx* h, int i; i=0; - rv2=rval_convert(h, msg, RV_INT, v, 0); + rv2=rval_convert(h, msg, RV_LONG, v, 0); if (unlikely(rv2==0)){ LM_ERR("rval int conversion failed\n"); goto error; @@ -1573,7 +1573,7 @@ inline static struct rvalue* rval_intop1(struct run_act_ctx* h, ret=v; rv_ref(ret); }else{ - ret=rval_new(RV_INT, &rv2->v, 0); + ret=rval_new(RV_LONG, &rv2->v, 0); if (unlikely(ret==0)){ LM_ERR("eval out of memory\n"); goto error; @@ -1605,9 +1605,9 @@ inline static struct rvalue* rval_intop2(struct run_act_ctx* h, rv2=rv1=0; ret=0; - if ((rv1=rval_convert(h, msg, RV_INT, l, 0))==0) + if ((rv1=rval_convert(h, msg, RV_LONG, l, 0))==0) goto error; - if ((rv2=rval_convert(h, msg, RV_INT, r, 0))==0) + if ((rv2=rval_convert(h, msg, RV_LONG, r, 0))==0) goto error; if (unlikely(int_intop2(&i, op, rv1->v.l, rv2->v.l)<0)) goto error; @@ -1619,14 +1619,14 @@ inline static struct rvalue* rval_intop2(struct run_act_ctx* h, /* try reusing rv2 */ ret=rv2; rv_ref(ret); - }else if ((l->type==RV_INT) && (rv_chg_in_place(l))){ + }else if ((l->type==RV_LONG) && (rv_chg_in_place(l))){ ret=l; rv_ref(ret); - } else if ((r->type==RV_INT) && (rv_chg_in_place(r))){ + } else if ((r->type==RV_LONG) && (rv_chg_in_place(r))){ ret=r; rv_ref(ret); }else{ - ret=rval_new(RV_INT, &rv1->v, 0); + ret=rval_new(RV_LONG, &rv1->v, 0); if (unlikely(ret==0)){ LM_ERR("rv eval out of memory\n"); goto error; @@ -1957,7 +1957,7 @@ int rval_expr_eval_int( struct run_act_ctx* h, struct sip_msg* msg, break; ret=int_intop1(res, rve->op, i1); break; - case RVE_INT_OP: + case RVE_LONG_OP: ret=rval_expr_eval_int(h, msg, res, rve->left.rve); break; case RVE_MUL_OP: @@ -2234,7 +2234,7 @@ int rval_expr_eval_rvint( struct run_act_ctx* h, rv1=&rve->left.rval; rv_ref(rv1); type=rval_get_btype(h, msg, rv1, cache); - if (type==RV_INT){ + if (type==RV_LONG){ r=rval_get_int(h, msg, res_i, rv1, cache); rval_get_int_handle_ret(r, "rval expression conversion" " to int failed", rve); @@ -2279,7 +2279,7 @@ int rval_expr_eval_rvint( struct run_act_ctx* h, case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: /* operator forces integer type */ ret=rval_expr_eval_int(h, msg, res_i, rve); *res_rv=0; @@ -2413,12 +2413,12 @@ struct rvalue* rval_expr_eval(struct run_act_ctx* h, struct sip_msg* msg, case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: /* operator forces integer type */ r=rval_expr_eval_int(h, msg, &i, rve); if (likely(r==0)){ v.l=i; - ret=rval_new(RV_INT, &v, 0); + ret=rval_new(RV_LONG, &v, 0); if (unlikely(ret==0)){ LM_ERR("rv eval int expression: out of memory\n"); goto error; @@ -2442,7 +2442,7 @@ struct rvalue* rval_expr_eval(struct run_act_ctx* h, struct sip_msg* msg, rval_cache_init(&c1); type=rval_get_btype(h, msg, rv1, &c1); switch(type){ - case RV_INT: + case RV_LONG: r=rval_get_int(h, msg, &i, rv1, &c1); rval_get_int_handle_ret(r, "rval expression left side " "conversion to int failed", @@ -2467,7 +2467,7 @@ struct rvalue* rval_expr_eval(struct run_act_ctx* h, struct sip_msg* msg, rv_ref(ret); }else{ v.l=r; - ret=rval_new(RV_INT, &v, 0); + ret=rval_new(RV_LONG, &v, 0); if (unlikely(ret==0)){ rval_cache_clean(&c1); LM_ERR("rv eval int expression: out of memory\n"); @@ -2548,7 +2548,7 @@ struct rvalue* rval_expr_eval(struct run_act_ctx* h, struct sip_msg* msg, rval_cache_init(&c1); type=rval_get_btype(h, msg, rv1, &c1); switch(type){ - case RV_INT: + case RV_LONG: r=rval_get_int(h, msg, &i, rv1, &c1); rval_get_int_handle_ret(r, "rval expression left side " "conversion to int failed", @@ -2558,7 +2558,7 @@ struct rvalue* rval_expr_eval(struct run_act_ctx* h, struct sip_msg* msg, goto error; } v.l=i; - ret=rval_new(RV_INT, &v, 0); + ret=rval_new(RV_LONG, &v, 0); if (unlikely(ret==0)){ rval_cache_clean(&c1); LM_ERR("rv eval int expression: out of memory\n"); @@ -2645,7 +2645,7 @@ struct rval_expr* mk_rval_expr_v(enum rval_type rv_type, void* val, memset(rve, 0, sizeof(*rve)); flags=0; switch(rv_type){ - case RV_INT: + case RV_LONG: v.l=(long)val; break; case RV_STR: @@ -2711,7 +2711,7 @@ struct rval_expr* mk_rval_expr1(enum rval_expr_op op, struct rval_expr* rve1, case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: case RVE_STR_OP: break; default: @@ -2809,7 +2809,7 @@ static int rve_op_is_assoc(enum rval_expr_op op) case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: case RVE_STR_OP: /* one operand expression => cannot be assoc. */ return 0; @@ -2867,7 +2867,7 @@ static int rve_op_is_commutative(enum rval_expr_op op) case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: case RVE_STR_OP: /* one operand expression => cannot be commut. */ return 0; @@ -2929,12 +2929,12 @@ static int rve_can_optimize_int(struct rval_expr* rve) return 0; if (rve->left.rve->op != RVE_RVAL_OP) return 0; - if (rve->left.rve->left.rval.type!=RV_INT) + if (rve->left.rve->left.rval.type!=RV_LONG) return 0; if (rve->right.rve){ if (rve->right.rve->op != RVE_RVAL_OP) return 0; - if (rve->right.rve->left.rval.type!=RV_INT) + if (rve->right.rve->left.rval.type!=RV_LONG) return 0; } LM_DBG("left %d, right %d\n", @@ -2965,7 +2965,7 @@ static int rve_can_optimize_str(struct rval_expr* rve) if (rve->right.rve->op != RVE_RVAL_OP) return 0; if ((rve->right.rve->left.rval.type!=RV_STR) && - (rve->right.rve->left.rval.type!=RV_INT)) + (rve->right.rve->left.rval.type!=RV_LONG)) return 0; } return 1; @@ -2978,7 +2978,7 @@ static int fix_rval(struct rvalue* rv, struct rval_expr* rve) { LM_DBG("RV fixing type %d\n", rv->type); switch(rv->type){ - case RV_INT: + case RV_LONG: /*nothing to do*/ LM_DBG("RV is int: %d\n", (int)rv->v.l); return 0; @@ -3070,7 +3070,7 @@ static int rve_replace_with_ct_rv(struct rval_expr* rve, struct rvalue* rv) type=rv->type; flags=0; - if (rv->type==RV_INT){ + if (rv->type==RV_LONG){ if (rval_get_int(0, 0, &i, rv, 0)!=0){ LM_BUG("unexpected int evaluation failure (%d,%d-%d,%d)\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3219,7 +3219,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) }while(0) /* helper macro: replace in-place an int type rve with v (another rve).*/ -#define replace_int_rve(e, v) replace_rve_type_cast(e, v, INT) +#define replace_long_rve(e, v) replace_rve_type_cast(e, v, LONG) /* helper macro: replace in-place a str type rve with v (another rve).*/ #define replace_str_rve(e, v) replace_rve_type_cast(e, v, STR) @@ -3249,7 +3249,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) goto error; } op=rve->op; - if (rv->type==RV_INT){ + if (rv->type==RV_LONG){ i=rv->v.l; switch(op){ case RVE_MUL_OP: @@ -3263,7 +3263,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) /* $v * 1 -> (int)$v * 1 * $v -> (int)$v */ rve_destroy(ct_rve); - replace_int_rve(rve, v_rve); + replace_long_rve(rve, v_rve); ret=1; } break; @@ -3283,7 +3283,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) if (ct_rve==rve->right.rve){ /* $v / 1 -> (int)$v */ rve_destroy(ct_rve); - replace_int_rve(rve, v_rve); + replace_long_rve(rve, v_rve); ret=1; } } @@ -3308,7 +3308,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) if (ct_rve==rve->right.rve){ /* $v - 0 -> $v */ rve_destroy(ct_rve); - replace_int_rve(rve, v_rve); + replace_long_rve(rve, v_rve); ret=1; } /* ? 0 - $v -> -($v) ? */ @@ -3330,7 +3330,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) /* $v | 0 -> (int)$v * 0 | $v -> (int)$v */ rve_destroy(ct_rve); - replace_int_rve(rve, v_rve); + replace_long_rve(rve, v_rve); ret=1; } break; @@ -3345,7 +3345,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) /* $v && 1 -> (int)$v * 1 && $v -> (int)$v */ rve_destroy(ct_rve); - replace_int_rve(rve, v_rve); + replace_long_rve(rve, v_rve); ret=1; } break; @@ -3360,7 +3360,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) /* $v || 0 -> (int)$v * 0 && $v -> (int)$v */ rve_destroy(ct_rve); - replace_int_rve(rve, v_rve); + replace_long_rve(rve, v_rve); ret=1; } break; @@ -3371,11 +3371,11 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) * check if it's an IPLUS or the result is an integer * (which generally means unoptimized + ). */ - if ((i==0) && ((op==RVE_IPLUS_OP) || (rve_type==RV_INT))){ + if ((i==0) && ((op==RVE_IPLUS_OP) || (rve_type==RV_LONG))){ /* $v + 0 -> (int)$v * 0 + $v -> (int)$v */ rve_destroy(ct_rve); - replace_int_rve(rve, v_rve); + replace_long_rve(rve, v_rve); ret=1; } break; @@ -3387,7 +3387,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) if (ret==1 && dbg){ if (right){ if (rve->op==RVE_RVAL_OP){ - if (rve->left.rval.type==RV_INT) + if (rve->left.rval.type==RV_LONG) LM_DBG("FIXUP RVE: (%d,%d-%d,%d) optimized" " op%d($v, %d) -> %d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3399,9 +3399,9 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) rve->fpos.s_line, rve->fpos.s_col, rve->fpos.e_line, rve->fpos.e_col, op, i); - }else if (rve->op==RVE_INT_OP){ + }else if (rve->op==RVE_LONG_OP){ if (rve->left.rve->op==RVE_RVAL_OP && - rve->left.rve->left.rval.type==RV_INT) + rve->left.rve->left.rval.type==RV_LONG) LM_DBG("FIXUP RVE: (%d,%d-%d,%d) optimized" " op%d($v, %d) -> (int)%d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3422,7 +3422,7 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) } }else{ if (rve->op==RVE_RVAL_OP){ - if (rve->left.rval.type==RV_INT) + if (rve->left.rval.type==RV_LONG) LM_DBG("FIXUP RVE: (%d,%d-%d,%d) optimized" " op%d(%d, $v) -> %d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3434,9 +3434,9 @@ static int rve_opt_01(struct rval_expr* rve, enum rval_type rve_type) rve->fpos.s_line, rve->fpos.s_col, rve->fpos.e_line, rve->fpos.e_col, op, i); - }else if (rve->op==RVE_INT_OP){ + }else if (rve->op==RVE_LONG_OP){ if (rve->left.rve->op==RVE_RVAL_OP && - rve->left.rve->left.rval.type==RV_INT) + rve->left.rve->left.rval.type==RV_LONG) LM_DBG("FIXUP RVE: (%d,%d-%d,%d) optimized" " op%d(%d, $v) -> (int)%d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3606,7 +3606,7 @@ static int rve_optimize(struct rval_expr* rve) rval_destroy(rv); rv=0; trv=&rve->left.rval; - if (trv->type==RV_INT) + if (trv->type==RV_LONG) LM_DBG("FIXUP RVE (%d,%d-%d,%d): optimized constant int rve " "(old op %d) to %d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3647,7 +3647,7 @@ static int rve_optimize(struct rval_expr* rve) rve->right.rve->fpos.e_col); goto error; } - if (rv->type==RV_INT){ + if (rv->type==RV_LONG){ rv->v.l=-rv->v.l; if (rve_replace_with_ct_rv(rve->right.rve, rv)<0) goto error; @@ -3665,7 +3665,7 @@ static int rve_optimize(struct rval_expr* rve) /* e1 PLUS_OP e2 -> change op if we know e1 basic type */ if (rve->op==RVE_PLUS_OP){ l_type=rve_guess_type(rve->left.rve); - if (l_type==RV_INT){ + if (l_type==RV_LONG){ rve->op=RVE_IPLUS_OP; LM_DBG("FIXUP RVE (%d,%d-%d,%d): changed + into integer plus\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3681,7 +3681,7 @@ static int rve_optimize(struct rval_expr* rve) * e1 DIFF_OP e2 -> change op if we know e2 basic type */ if (rve->op==RVE_EQ_OP || rve->op==RVE_DIFF_OP){ l_type=rve_guess_type(rve->left.rve); - if (l_type==RV_INT){ + if (l_type==RV_LONG){ rve->op=(rve->op==RVE_EQ_OP)?RVE_IEQ_OP:RVE_IDIFF_OP; LM_DBG("FIXUP RVE (%d,%d-%d,%d): changed ==/!= into integer" " ==/!=\n", @@ -3738,7 +3738,7 @@ static int rve_optimize(struct rval_expr* rve) rve_destroy(tmp_rve.left.rve); rve->left.rve=rve->left.rve->left.rve; trv=&rve->right.rve->left.rval; - if (trv->type==RV_INT) + if (trv->type==RV_LONG) LM_DBG("FIXUP RVE (%d,%d-%d,%d): optimized int rve: " "op(op($v, a), b) with op($v, %d); op=%d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3776,7 +3776,7 @@ static int rve_optimize(struct rval_expr* rve) rval_destroy(rv); rv=0; trv=&rve->left.rve->left.rval; - if (trv->type==RV_INT) + if (trv->type==RV_LONG) LM_DBG("FIXUP RVE (%d,%d-%d,%d): optimized int rve: " "op(op(a, $v), b) with op(%d, $v); op=%d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3822,7 +3822,7 @@ static int rve_optimize(struct rval_expr* rve) rve_destroy(tmp_rve.right.rve); rve->right.rve=rve->right.rve->left.rve; trv=&rve->left.rve->left.rval; - if (trv->type==RV_INT) + if (trv->type==RV_LONG) LM_DBG("FIXUP RVE (%d,%d-%d,%d): optimized int rve: " "op(a, op($v, b)) with op(%d, $v); op=%d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3866,7 +3866,7 @@ static int rve_optimize(struct rval_expr* rve) rve_destroy(tmp_rve.right.rve); rve->right.rve=rve->right.rve->right.rve; trv=&rve->left.rve->left.rval; - if (trv->type==RV_INT) + if (trv->type==RV_LONG) LM_DBG("FIXUP RVE (%d,%d-%d,%d): optimized int rve: " "op(a, op(b, $v)) with op(%d, $v); op=%d\n", rve->fpos.s_line, rve->fpos.s_col, @@ -3927,7 +3927,7 @@ int fix_rval_expr(void* p) case RVE_STREMPTY_OP: case RVE_DEFINED_OP: case RVE_NOTDEFINED_OP: - case RVE_INT_OP: + case RVE_LONG_OP: case RVE_STR_OP: ret=fix_rval_expr((void*)rve->left.rve); if (ret<0) goto error; diff --git a/src/core/rvalue.h b/src/core/rvalue.h index f8591872df8..bb62ff89fa0 100644 --- a/src/core/rvalue.h +++ b/src/core/rvalue.h @@ -35,7 +35,7 @@ #include "action.h" enum rval_type{ - RV_NONE, RV_INT, RV_STR, /* basic types */ + RV_NONE, RV_LONG, RV_STR, /* basic types */ RV_BEXPR, RV_ACTION_ST, /* special values */ RV_SEL, RV_AVP, RV_PVAR }; @@ -82,7 +82,7 @@ enum rval_expr_op{ /* avp, pvars a.s.o */ RVE_DEFINED_OP, /**< one member, returns is_defined(val) (bool) */ RVE_NOTDEFINED_OP, /**< one member, returns is_not_defined(val) (bool) */ - RVE_INT_OP, /**< one member, returns (int)val (int) */ + RVE_LONG_OP, /**< one member, returns (int)val (int) */ RVE_STR_OP /**< one member, returns (str)val (str) */ }; @@ -273,7 +273,7 @@ int rve_has_side_effects(struct rval_expr* rve); /** * @brief Returns 1 if expression is valid (type-wise) - * @param type filled with the type of the expression (RV_INT, RV_STR or + * @param type filled with the type of the expression (RV_LONG, RV_STR or * RV_NONE if it's dynamic) * @param rve checked expression * @param bad_rve set on failure to the subexpression for which the @@ -282,7 +282,7 @@ int rve_has_side_effects(struct rval_expr* rve); * @param exp_t set on failure to the expected type for the bad * subexpression * @return 0 or 1 and sets *type to the resulting type - * (RV_INT, RV_STR or RV_NONE if it can be found only at runtime) + * (RV_LONG, RV_STR or RV_NONE if it can be found only at runtime) */ int rve_check_type(enum rval_type* type, struct rval_expr* rve, struct rval_expr** bad_rve, enum rval_type* bad_type,