i tried to implement eval function that evaluates a string given as
first param and writes the result to second param (see below). the idea
is to first get the string argument, then run spve fixup on it and,
finally, get and store the result. unfortunately nothing sensible
comes out and even orig and type of the spve fixup result are bogus.
the fist INFO output shows that the string value to be evaluated is got
correctly. also all function calls succeed.
obviously the above logic or its realization has something wrong in it.
does someone have any ideas where the problems are?
-- juha
/*
* Evaluates first param (string) and saves result to second param (pvar)
*/
int eval(struct sip_msg* _m, char* _string, char* _dst)
{
str value, result;
char **param;
pv_spec_t *dst;
pv_value_t val;
fparam_t *fp;
if (fixup_get_svalue(_m, (gparam_p)_string, &value) != 0) {
LM_ERR("cannot get parameter value\n");
return -1;
}
param = &(value.s);
LM_INFO("param value as string is <%s>\n", *param);
if (fixup_spve_null((void **)param, 1) != 0) {
LM_ERR("failed to evaluate parameter <%.*s>\n", value.len, value.s);
return -1;
}
fp = (fparam_t *)param;
LM_INFO("orig <%s>, type <%d>\n", fp->orig, fp->type);
if (get_str_fparam(&result, _m, fp) != 0) {
LM_ERR("cannot get result value\n");
return -1;
}
val.rs.s = result.s;
val.rs.len = result.len;
LM_INFO("eval result: %.*s\n", val.rs.len, val.rs.s);
val.flags = PV_VAL_STR;
dst = (pv_spec_t *)_dst;
dst->setf(_m, &dst->pvp, (int)EQ_T, &val);
return 1;
}
Show replies by date