core: added a fuction that adds an xavp with an xavp value
authorDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 28 Dec 2012 18:21:28 +0000 (19:21 +0100)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 28 Dec 2012 18:21:28 +0000 (19:21 +0100)
xavp.c
xavp.h

diff --git a/xavp.c b/xavp.c
index f04ac90..9b36562 100644 (file)
--- a/xavp.c
+++ b/xavp.c
@@ -183,6 +183,38 @@ sr_xavp_t *xavp_add_value(str *name, sr_xval_t *val, sr_xavp_t **list)
        return avp;
 }
 
+sr_xavp_t *xavp_add_xavp_value(str *rname, str *name, sr_xval_t *val, sr_xavp_t **list)
+{
+       sr_xavp_t *ravp=0;
+       sr_xavp_t *cavp=0;
+       sr_xval_t rval;
+
+       cavp = xavp_new_value(name, val);
+       if (cavp==NULL)
+               return NULL;
+
+       memset(&rval, 0, sizeof(sr_xval_t));
+       rval.type = SR_XTYPE_XAVP;
+       rval.v.xavp = cavp;
+
+       ravp = xavp_new_value(rname, &rval);
+       if (ravp==NULL) {
+               xavp_destroy_list(&cavp);
+               return NULL;
+       }
+
+       /* Prepend new value to the list */
+       if(list) {
+               ravp->next = *list;
+               *list = ravp;
+       } else {
+               ravp->next = *_xavp_list_crt;
+               *_xavp_list_crt = ravp;
+       }
+
+       return ravp;
+}
+
 sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val, sr_xavp_t **list)
 {
        sr_xavp_t *avp;
diff --git a/xavp.h b/xavp.h
index 0ffce2a..b581c08 100644 (file)
--- a/xavp.h
+++ b/xavp.h
@@ -81,6 +81,7 @@ void avpx_free(sr_xavp_t *xa);
 int xavp_add(sr_xavp_t *xavp, sr_xavp_t **list);
 int xavp_add_last(sr_xavp_t *xavp, sr_xavp_t **list);
 sr_xavp_t *xavp_add_value(str *name, sr_xval_t *val, sr_xavp_t **list);
+sr_xavp_t *xavp_add_xavp_value(str *rname, str *name, sr_xval_t *val, sr_xavp_t **list);
 sr_xavp_t *xavp_set_value(str *name, int idx, sr_xval_t *val, sr_xavp_t **list);
 sr_xavp_t *xavp_get(str *name, sr_xavp_t *start);
 sr_xavp_t *xavp_get_by_index(str *name, int idx, sr_xavp_t **start);