Module: kamailio Branch: 5.1 Commit: 502fe8478aa9eb48b53aee1da97945c115996dfa URL: https://github.com/kamailio/kamailio/commit/502fe8478aa9eb48b53aee1da97945c1...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2020-02-10T13:36:00+01:00
core: fixup helpers to get dynamic string parameter in own buffer
(cherry picked from commit 3e1438bebdf611b83574ab44c8ed3eb3c7067391)
---
Modified: src/core/mod_fix.c Modified: src/core/mod_fix.h
---
Diff: https://github.com/kamailio/kamailio/commit/502fe8478aa9eb48b53aee1da97945c1... Patch: https://github.com/kamailio/kamailio/commit/502fe8478aa9eb48b53aee1da97945c1...
---
diff --git a/src/core/mod_fix.c b/src/core/mod_fix.c index b07adcfc26..93256affc3 100644 --- a/src/core/mod_fix.c +++ b/src/core/mod_fix.c @@ -664,3 +664,62 @@ int fixup_free_spve_pvar(void** param, int param_no) return fixup_free_pvar_null(param, 1); return E_UNSPEC; } + +/** + * + */ +int fixup_none_spve(void** param, int param_no) +{ + if(param_no==2) + return fixup_spve_null(param, 1); + return 0; +} + +/** + * + */ +int fixup_free_none_spve(void** param, int param_no) +{ + if(param_no==2) + 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 869dd78527..5afb2c8a56 100644 --- a/src/core/mod_fix.h +++ b/src/core/mod_fix.h @@ -149,4 +149,7 @@ int fixup_free_spve_pvar(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