[sr-dev] git:master:3e1438be: core: fixup helpers to get dynamic string parameter in own buffer

Daniel-Constantin Mierla miconda at gmail.com
Wed Oct 30 18:28:42 CET 2019


Module: kamailio
Branch: master
Commit: 3e1438bebdf611b83574ab44c8ed3eb3c7067391
URL: https://github.com/kamailio/kamailio/commit/3e1438bebdf611b83574ab44c8ed3eb3c7067391

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-10-30T18:28:18+01:00

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

---

Modified: src/core/mod_fix.c
Modified: src/core/mod_fix.h

---

Diff:  https://github.com/kamailio/kamailio/commit/3e1438bebdf611b83574ab44c8ed3eb3c7067391.diff
Patch: https://github.com/kamailio/kamailio/commit/3e1438bebdf611b83574ab44c8ed3eb3c7067391.patch

---

diff --git a/src/core/mod_fix.c b/src/core/mod_fix.c
index 27cdac471c..ca2cd6c104 100644
--- a/src/core/mod_fix.c
+++ b/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 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;
+}
diff --git a/src/core/mod_fix.h b/src/core/mod_fix.h
index f040fc1b3c..f09cf59e0c 100644
--- a/src/core/mod_fix.h
+++ b/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.*/
 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




More information about the sr-dev mailing list