Browse code

pv: xavp_slist_explode() stores tockes in xavp fields

- no longer in root xavp list, but a sublist with tokes having name 'v'

Daniel-Constantin Mierla authored on 14/10/2020 14:09:16
Showing 1 changed files
... ...
@@ -586,8 +586,10 @@ int pv_xavi_print(sip_msg_t* msg, char* s1, char *s2)
586 586
 int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname)
587 587
 {
588 588
 	str s;
589
+	sr_xavp_t *xavp_list=NULL;
589 590
 	sr_xavp_t *xavp=NULL;
590 591
 	sr_xval_t xval;
592
+	str itname = str_init("v");
591 593
 	int i;
592 594
 	int j;
593 595
 	int sfound;
... ...
@@ -620,7 +622,22 @@ int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname)
620 622
 				memset(&xval, 0, sizeof(sr_xval_t));
621 623
 				xval.type = SR_XTYPE_STR;
622 624
 				xval.v.s = s;
623
-				xavp = xavp_add_value_after(xname, &xval, xavp);
625
+				if(xavp_list == NULL) {
626
+					if(xavp_add_value(&itname, &xval, &xavp_list)==NULL) {
627
+						LM_ERR("failed to add item in the list: [%.*s]\n",
628
+								s.len, s.s);
629
+						return -1;
630
+					}
631
+					xavp = xavp_list;
632
+				} else {
633
+					xavp = xavp_add_value_after(&itname, &xval, xavp);
634
+					if(xavp == NULL) {
635
+						LM_ERR("failed to add item in the list: [%.*s]\n",
636
+								s.len, s.s);
637
+						xavp_destroy_list(&xavp_list);
638
+						return -1;
639
+					}
640
+				}
624 641
 			}
625 642
 			s.s = slist->s + i + 1;
626 643
 		}
... ...
@@ -637,7 +654,31 @@ int xavp_slist_explode(str *slist, str *sep, str *mode, str *xname)
637 654
 		memset(&xval, 0, sizeof(sr_xval_t));
638 655
 		xval.type = SR_XTYPE_STR;
639 656
 		xval.v.s = s;
640
-		xavp = xavp_add_value_after(xname, &xval, xavp);
657
+		if(xavp_list == NULL) {
658
+			if(xavp_add_value(&itname, &xval, &xavp_list)==NULL) {
659
+				LM_ERR("failed to add item in the list: [%.*s]\n",
660
+						s.len, s.s);
661
+				return -1;
662
+			}
663
+			xavp = xavp_list;
664
+		} else {
665
+			xavp = xavp_add_value_after(&itname, &xval, xavp);
666
+			if(xavp == NULL) {
667
+				LM_ERR("failed to add item in the list: [%.*s]\n",
668
+						s.len, s.s);
669
+				xavp_destroy_list(&xavp_list);
670
+				return -1;
671
+			}
672
+		}
673
+	}
674
+
675
+	/* add main xavp in root list */
676
+	memset(&xval, 0, sizeof(sr_xval_t));
677
+	xval.type = SR_XTYPE_XAVP;
678
+	xval.v.xavp = xavp_list;
679
+	if(xavp_add_value(xname, &xval, NULL)==NULL) {
680
+		xavp_destroy_list(&xavp);
681
+		return -1;
641 682
 	}
642 683
 
643 684
 	return 0;