Browse code

core: added a fuction that adds an xavp with an xavp value

Daniel-Constantin Mierla authored on 28/12/2012 18:21:28
Showing 2 changed files
... ...
@@ -183,6 +183,38 @@ sr_xavp_t *xavp_add_value(str *name, sr_xval_t *val, sr_xavp_t **list)
183 183
 	return avp;
184 184
 }
185 185
 
186
+sr_xavp_t *xavp_add_xavp_value(str *rname, str *name, sr_xval_t *val, sr_xavp_t **list)
187
+{
188
+	sr_xavp_t *ravp=0;
189
+	sr_xavp_t *cavp=0;
190
+	sr_xval_t rval;
191
+
192
+	cavp = xavp_new_value(name, val);
193
+	if (cavp==NULL)
194
+		return NULL;
195
+
196
+	memset(&rval, 0, sizeof(sr_xval_t));
197
+	rval.type = SR_XTYPE_XAVP;
198
+	rval.v.xavp = cavp;
199
+
200
+	ravp = xavp_new_value(rname, &rval);
201
+	if (ravp==NULL) {
202
+		xavp_destroy_list(&cavp);
203
+		return NULL;
204
+	}
205
+
206
+	/* Prepend new value to the list */
207
+	if(list) {
208
+		ravp->next = *list;
209
+		*list = ravp;
210
+	} else {
211
+		ravp->next = *_xavp_list_crt;
212
+		*_xavp_list_crt = ravp;
213
+	}
214
+
215
+	return ravp;
216
+}
217
+
186 218
 sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val, sr_xavp_t **list)
187 219
 {
188 220
 	sr_xavp_t *avp;
... ...
@@ -81,6 +81,7 @@ void avpx_free(sr_xavp_t *xa);
81 81
 int xavp_add(sr_xavp_t *xavp, sr_xavp_t **list);
82 82
 int xavp_add_last(sr_xavp_t *xavp, sr_xavp_t **list);
83 83
 sr_xavp_t *xavp_add_value(str *name, sr_xval_t *val, sr_xavp_t **list);
84
+sr_xavp_t *xavp_add_xavp_value(str *rname, str *name, sr_xval_t *val, sr_xavp_t **list);
84 85
 sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val, sr_xavp_t **list);
85 86
 sr_xavp_t *xavp_get(str *name, sr_xavp_t *start);
86 87
 sr_xavp_t *xavp_get_by_index(str *name, int idx, sr_xavp_t **start);