Skip to content

Commit

Permalink
core: fixup helpers to get dynamic string parameter in own buffer
Browse files Browse the repository at this point in the history
(cherry picked from commit 3e1438b)
  • Loading branch information
miconda committed Nov 12, 2019
1 parent 4ca6ad0 commit 7bc98c4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/core/mod_fix.c
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions src/core/mod_fix.h
Expand Up @@ -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

0 comments on commit 7bc98c4

Please sign in to comment.