|
@@ -27,6 +27,8 @@
|
|
#include "../../dprint.h"
|
|
#include "../../dprint.h"
|
|
#include "../../dset.h"
|
|
#include "../../dset.h"
|
|
#include "../../flags.h"
|
|
#include "../../flags.h"
|
|
|
|
+#include "../../pvar.h"
|
|
|
|
+#include "../../lvalue.h"
|
|
#include "../../mod_fix.h"
|
|
#include "../../mod_fix.h"
|
|
#include "km_core.h"
|
|
#include "km_core.h"
|
|
|
|
|
|
@@ -95,3 +97,75 @@ int w_isdsturiset(struct sip_msg *msg, char *uri, str *s2)
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+int pv_printf_fixup(void** param, int param_no)
|
|
|
|
+{
|
|
|
|
+ pv_spec_t *spec=NULL;
|
|
|
|
+ pv_elem_t *pvmodel=NULL;
|
|
|
|
+ str tstr;
|
|
|
|
+
|
|
|
|
+ if(param_no==1)
|
|
|
|
+ {
|
|
|
|
+ spec = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
|
|
|
|
+ if(spec==NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("out of pkg\n");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ memset(spec, 0, sizeof(pv_spec_t));
|
|
|
|
+ tstr.s = (char*)(*param);
|
|
|
|
+ tstr.len = strlen(tstr.s);
|
|
|
|
+ if(pv_parse_spec(&tstr, spec)==NULL)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("unknown script variable in first parameter");
|
|
|
|
+ pkg_free(spec);
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(!pv_is_w(spec))
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("read-only script variable in first parameter");
|
|
|
|
+ pkg_free(spec);
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ *param = spec;
|
|
|
|
+ } else if(param_no==2) {
|
|
|
|
+ pvmodel = 0;
|
|
|
|
+ tstr.s = (char*)(*param);
|
|
|
|
+ tstr.len = strlen(tstr.s);
|
|
|
|
+ if(pv_parse_format(&tstr, &pvmodel)<0)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("error in second parameter");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ *param = pvmodel;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int w_pv_printf(struct sip_msg *msg, char *s1, str *s2)
|
|
|
|
+{
|
|
|
|
+ pv_spec_t *spec=NULL;
|
|
|
|
+ pv_elem_t *model=NULL;
|
|
|
|
+ pv_value_t val;
|
|
|
|
+
|
|
|
|
+ spec = (pv_spec_t*)s1;
|
|
|
|
+
|
|
|
|
+ model = (pv_elem_t*)s2;
|
|
|
|
+
|
|
|
|
+ memset(&val, 0, sizeof(pv_value_t));
|
|
|
|
+ if(pv_printf_s(msg, model, &val.rs)!=0)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("cannot eval second parameter\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+ val.flags = PV_VAL_STR;
|
|
|
|
+ if(spec->setf(msg, &spec->pvp, EQ_T, &val)<0)
|
|
|
|
+ {
|
|
|
|
+ LM_ERR("setting PV failed\n");
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 1;
|
|
|
|
+error:
|
|
|
|
+ return -1;
|
|
|
|
+}
|
|
|
|
+
|