Module: kamailio
Branch: master
Commit: f056213ca78c94419450f45fd3b26e9328c1a731
URL:
https://github.com/kamailio/kamailio/commit/f056213ca78c94419450f45fd3b26e9…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-06-12T09:49:38+02:00
core: xavp - helper functions to get last by name and add after an item
---
Modified: src/core/xavp.c
Modified: src/core/xavp.h
---
Diff:
https://github.com/kamailio/kamailio/commit/f056213ca78c94419450f45fd3b26e9…
Patch:
https://github.com/kamailio/kamailio/commit/f056213ca78c94419450f45fd3b26e9…
---
diff --git a/src/core/xavp.c b/src/core/xavp.c
index c8ff12365f..e6acefd9c9 100644
--- a/src/core/xavp.c
+++ b/src/core/xavp.c
@@ -162,6 +162,19 @@ int xavp_add_last(sr_xavp_t *xavp, sr_xavp_t **list)
return 0;
}
+int xavp_add_after(sr_xavp_t *nxavp, sr_xavp_t *pxavp)
+{
+ if(pxavp==NULL) {
+ nxavp->next = *_xavp_list_crt;
+ *_xavp_list_crt = nxavp;
+ } else {
+ nxavp->next = pxavp->next;
+ pxavp->next = nxavp;
+ }
+
+ return 0;
+}
+
sr_xavp_t *xavp_add_value(str *name, sr_xval_t *val, sr_xavp_t **list)
{
sr_xavp_t *avp=0;
@@ -305,6 +318,22 @@ sr_xavp_t *xavp_get_next(sr_xavp_t *start)
return NULL;
}
+sr_xavp_t *xavp_get_last(str *xname, sr_xavp_t **list)
+{
+ sr_xavp_t *prev;
+ sr_xavp_t *crt;
+
+ crt = xavp_get_internal(xname, list, 0, 0);
+
+ prev = NULL;
+
+ while(crt) {
+ prev = crt;
+ crt = xavp_get_next(prev);
+ }
+
+ return prev;
+}
int xavp_rm(sr_xavp_t *xa, sr_xavp_t **head)
{
diff --git a/src/core/xavp.h b/src/core/xavp.h
index 839e486523..2177461d69 100644
--- a/src/core/xavp.h
+++ b/src/core/xavp.h
@@ -76,12 +76,14 @@ void xavp_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);
+int xavp_add_after(sr_xavp_t *nxavp, sr_xavp_t *pxavp);
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);
sr_xavp_t *xavp_get_next(sr_xavp_t *start);
+sr_xavp_t *xavp_get_last(str *xname, sr_xavp_t **list);
int xavp_rm_by_name(str *name, int all, sr_xavp_t **head);
int xavp_rm_by_index(str *name, int idx, sr_xavp_t **head);
int xavp_rm(sr_xavp_t *xa, sr_xavp_t **head);