Skip to content

Commit

Permalink
pv: xavp_slist_explode() stores tockes in xavp fields
Browse files Browse the repository at this point in the history
- no longer in root xavp list, but a sublist with tokes having name 'v'
  • Loading branch information
miconda committed Oct 14, 2020
1 parent 75d4082 commit 2b4ec1c
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions src/modules/pv/pv_xavp.c
Expand Up @@ -586,8 +586,10 @@ int pv_xavi_print(sip_msg_t* msg, char* s1, char *s2)
int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname)
{
str s;
sr_xavp_t *xavp_list=NULL;
sr_xavp_t *xavp=NULL;
sr_xval_t xval;
str itname = str_init("v");
int i;
int j;
int sfound;
Expand Down Expand Up @@ -620,7 +622,22 @@ int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname)
memset(&xval, 0, sizeof(sr_xval_t));
xval.type = SR_XTYPE_STR;
xval.v.s = s;
xavp = xavp_add_value_after(xname, &xval, xavp);
if(xavp_list == NULL) {
if(xavp_add_value(&itname, &xval, &xavp_list)==NULL) {
LM_ERR("failed to add item in the list: [%.*s]\n",
s.len, s.s);
return -1;
}
xavp = xavp_list;
} else {
xavp = xavp_add_value_after(&itname, &xval, xavp);
if(xavp == NULL) {
LM_ERR("failed to add item in the list: [%.*s]\n",
s.len, s.s);
xavp_destroy_list(&xavp_list);
return -1;
}
}
}
s.s = slist->s + i + 1;
}
Expand All @@ -637,7 +654,31 @@ int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname)
memset(&xval, 0, sizeof(sr_xval_t));
xval.type = SR_XTYPE_STR;
xval.v.s = s;
xavp = xavp_add_value_after(xname, &xval, xavp);
if(xavp_list == NULL) {
if(xavp_add_value(&itname, &xval, &xavp_list)==NULL) {
LM_ERR("failed to add item in the list: [%.*s]\n",
s.len, s.s);
return -1;
}
xavp = xavp_list;
} else {
xavp = xavp_add_value_after(&itname, &xval, xavp);
if(xavp == NULL) {
LM_ERR("failed to add item in the list: [%.*s]\n",
s.len, s.s);
xavp_destroy_list(&xavp_list);
return -1;
}
}
}

/* add main xavp in root list */
memset(&xval, 0, sizeof(sr_xval_t));
xval.type = SR_XTYPE_XAVP;
xval.v.xavp = xavp_list;
if(xavp_add_value(xname, &xval, NULL)==NULL) {
xavp_destroy_list(&xavp);
return -1;
}

return 0;
Expand Down

0 comments on commit 2b4ec1c

Please sign in to comment.