Bläddra i källkod

core: fixup helpers to get dynamic string parameter in own buffer

Daniel-Constantin Mierla 5 år sedan
förälder
incheckning
3e1438bebd
2 ändrade filer med 42 tillägg och 0 borttagningar
  1. 39 0
      src/core/mod_fix.c
  2. 3 0
      src/core/mod_fix.h

+ 39 - 0
src/core/mod_fix.c

@@ -716,3 +716,42 @@ int fixup_free_none_spve(void** param, int param_no)
 		return fixup_free_spve_null(param, 1);
 		return fixup_free_spve_null(param, 1);
 	return 0;
 	return 0;
 }
 }
+
+
+/**
+ *
+ */
+int fixup_vstr_all(void** param, int param_no)
+{
+	str s;
+	pv_elem_t *xm;
+
+	s.s = (char*)(*param);
+	s.len = strlen(s.s);
+	if(pv_parse_format(&s, &xm)<0) {
+		LM_ERR("invalid parameter format [%s]\n", (char*)(*param));
+		return E_UNSPEC;
+	}
+	*param = (void*)xm;
+	return 0;
+}
+
+/**
+ *
+ */
+int fixup_free_vstr_all(void** param, int param_no)
+{
+	pv_elem_free_all((pv_elem_t*)(*param));
+	return 0;
+}
+/**
+ *
+ */
+int fixup_get_vstr_buf(sip_msg_t *msg, gparam_t *p, char *buf, int blen)
+{
+	if(pv_printf(msg, (pv_elem_t*)p, buf, &blen)<0) {
+		LM_ERR("unable to get the value\n");
+		return -1;
+	}
+	return -1;
+}

+ 3 - 0
src/core/mod_fix.h

@@ -156,4 +156,7 @@ int fixup_free_none_spve(void** param, int param_no);
 /** get the corresp. free fixup function.*/
 /** get the corresp. free fixup function.*/
 free_fixup_function mod_fix_get_fixup_free(fixup_function f);
 free_fixup_function mod_fix_get_fixup_free(fixup_function f);
 
 
+int fixup_vstr_all(void** param, int param_no);
+int fixup_free_vstr_all(void** param, int param_no);
+int fixup_get_vstr_buf(sip_msg_t *msg, gparam_t *p, char *buf, int blen);
 #endif
 #endif