Browse code

core: adding xavp_clone_level_nodata_with_new_name

Julien Chavanton authored on 21/09/2019 04:57:46
Showing 2 changed files
... ...
@@ -693,11 +693,16 @@ struct str_list *xavp_get_list_key_names(sr_xavp_t *xavp)
693 693
 	return result;
694 694
 }
695 695
 
696
+sr_xavp_t *xavp_clone_level_nodata(sr_xavp_t *xold)
697
+{
698
+	return xavp_clone_level_nodata_with_new_name(xold, &xold->name);
699
+}
700
+
696 701
 /**
697 702
  * clone the xavp without values that are custom data
698 703
  * - only one list level is cloned, other sublists are ignored
699 704
  */
700
-sr_xavp_t *xavp_clone_level_nodata(sr_xavp_t *xold)
705
+sr_xavp_t *xavp_clone_level_nodata_with_new_name(sr_xavp_t *xold, str *dst_name)
701 706
 {
702 707
 	sr_xavp_t *xnew = NULL;
703 708
 	sr_xavp_t *navp = NULL;
... ...
@@ -713,13 +718,13 @@ sr_xavp_t *xavp_clone_level_nodata(sr_xavp_t *xold)
713 718
 		LM_INFO("xavp value type is 'data' - ignoring in clone\n");
714 719
 		return NULL;
715 720
 	}
716
-	xnew = xavp_new_value(&xold->name, &xold->val);
721
+	xnew = xavp_new_value(dst_name, &xold->val);
717 722
 	if(xnew==NULL)
718 723
 	{
719 724
 		LM_ERR("cannot create cloned root xavp\n");
720 725
 		return NULL;
721 726
 	}
722
-	LM_DBG("cloned root xavp [%.*s]\n", xold->name.len, xold->name.s);
727
+	LM_DBG("cloned root xavp [%.*s] >> [%.*s]\n", xold->name.len, xold->name.s, dst_name->len, dst_name->s);
723 728
 
724 729
 	if(xold->val.type!=SR_XTYPE_XAVP)
725 730
 	{
... ...
@@ -102,6 +102,7 @@ sr_xavp_t *xavp_extract(str *name, sr_xavp_t **list);
102 102
 void xavp_print_list(sr_xavp_t **head);
103 103
 
104 104
 sr_xavp_t *xavp_clone_level_nodata(sr_xavp_t *xold);
105
+sr_xavp_t *xavp_clone_level_nodata_with_new_name(sr_xavp_t *xold, str *dst_name);
105 106
 
106 107
 sr_xavp_t* xavp_get_child(str *rname, str *cname);
107 108
 sr_xavp_t* xavp_get_child_with_ival(str *rname, str *cname);