MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / eval_elem

Function eval_elem

route.c:789–1119  ·  view source on GitHub ↗

! \brief * \return 0/1 (false/true) or -1 on error, -127 EXPR_DROP */

Source from the content-addressed store, hash-verified

787 * \return 0/1 (false/true) or -1 on error, -127 EXPR_DROP
788 */
789static int eval_elem(struct expr* e, struct sip_msg* msg, pv_value_t *val)
790{
791 int ret;
792/* int retl;
793 int retr; */
794 int ival;
795 pv_value_t lval;
796 pv_value_t rval;
797 char *p;
798 int i,n;
799
800 ret=E_BUG;
801 if (e->type!=ELEM_T){
802 LM_CRIT("invalid type\n");
803 goto error;
804 }
805
806 if(val) memset(val, 0, sizeof(pv_value_t));
807
808 switch(e->left.type){
809 case NUMBER_O:
810 ret=!(!e->right.v.n); /* !! to transform it in {0,1} */
811 break;
812 case ACTION_O:
813 ret=run_action_list( (struct action*)e->right.v.data, msg);
814 if(val)
815 {
816 val->flags = PV_TYPE_INT|PV_VAL_INT;
817 val->ri = ret;
818 }
819 if (ret<=0) ret=(ret==0)?EXPR_DROP:0;
820 else ret=1;
821 return ret;
822 case EXPR_O:
823 /* retl = retr = 0; */
824 memset(&lval, 0, sizeof(pv_value_t));
825 memset(&rval, 0, sizeof(pv_value_t));
826 if(e->left.v.data)
827 eval_expr((struct expr*)e->left.v.data,msg,&lval);
828 /* XXX why is retl used here ?? */
829 /* retl=eval_expr((struct expr*)e->left.v.data,msg,&lval); */
830 if(lval.flags == PV_VAL_NONE)
831 {
832 pv_value_destroy(&lval);
833 pv_value_destroy(&rval);
834 return 0;
835 }
836 if(e->op == BNOT_OP)
837 {
838 if(lval.flags&PV_VAL_INT)
839 {
840 if(val!=NULL)
841 {
842 val->flags = PV_TYPE_INT|PV_VAL_INT;
843 val->ri = ~lval.ri;
844 }
845 pv_value_destroy(&lval);
846 pv_value_destroy(&rval);

Callers 1

eval_exprFunction · 0.85

Calls 5

run_action_listFunction · 0.85
eval_exprFunction · 0.85
pv_value_destroyFunction · 0.85
pv_get_spec_valueFunction · 0.85
comp_scriptvarFunction · 0.85

Tested by

no test coverage detected