Module: kamailio
Branch: master
Commit: 2b48eadb445706d24542d1132c608e5821e68a92
URL:
https://github.com/kamailio/kamailio/commit/2b48eadb445706d24542d1132c608e5…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-04-01T07:56:30+02:00
core: $xavu() helper functions to get child values
- like for xavp and xavi
---
Modified: src/core/xavp.c
Modified: src/core/xavp.h
---
Diff:
https://github.com/kamailio/kamailio/commit/2b48eadb445706d24542d1132c608e5…
Patch:
https://github.com/kamailio/kamailio/commit/2b48eadb445706d24542d1132c608e5…
---
diff --git a/src/core/xavp.c b/src/core/xavp.c
index 26e89a8df3..b11b99929d 100644
--- a/src/core/xavp.c
+++ b/src/core/xavp.c
@@ -1448,6 +1448,56 @@ sr_xavp_t *xavu_set_child_sval(str *rname, str *cname, str *sval)
return xavu_set_child_xval(rname, cname, &xval);
}
+/**
+ * return child node of an xavp
+ * - $xavu(rname=>cname)
+ */
+sr_xavp_t* xavu_get_child(str *rname, str *cname)
+{
+ sr_xavp_t *ravp=NULL;
+
+ ravp = xavu_get(rname, NULL);
+ if(ravp==NULL || ravp->val.type!=SR_XTYPE_XAVP)
+ return NULL;
+
+ return xavu_get(cname, ravp->val.v.xavp);
+}
+
+
+/**
+ * return child node of an xavp if it has int value
+ * - $xavu(rname=>cname)
+ */
+sr_xavp_t* xavu_get_child_with_ival(str *rname, str *cname)
+{
+ sr_xavp_t *vavp=NULL;
+
+ vavp = xavu_get_child(rname, cname);
+
+ if(vavp==NULL || vavp->val.type!=SR_XTYPE_INT)
+ return NULL;
+
+ return vavp;
+}
+
+
+/**
+ * return child node of an xavp if it has string value
+ * - $xavu(rname=>cname)
+ */
+sr_xavp_t* xavu_get_child_with_sval(str *rname, str *cname)
+{
+ sr_xavp_t *vavp=NULL;
+
+ vavp = xavu_get_child(rname, cname);
+
+ if(vavp==NULL || vavp->val.type!=SR_XTYPE_STR)
+ return NULL;
+
+ return vavp;
+}
+
+
/**
* serialize the values in subfields of an xavu in name=value; format
* - rname - name of the root list xavu
diff --git a/src/core/xavp.h b/src/core/xavp.h
index 198f0c09c4..446b48eba3 100644
--- a/src/core/xavp.h
+++ b/src/core/xavp.h
@@ -131,6 +131,10 @@ sr_xavp_t *xavu_set_sval(str *rname, str *sval);
sr_xavp_t *xavu_set_child_xval(str *rname, str *cname, sr_xval_t *xval);
sr_xavp_t *xavu_set_child_ival(str *rname, str *cname, int ival);
sr_xavp_t *xavu_set_child_sval(str *rname, str *cname, str *sval);
+sr_xavp_t* xavu_get_child(str *rname, str *cname);
+sr_xavp_t* xavu_get_child_with_ival(str *rname, str *cname);
+sr_xavp_t* xavu_get_child_with_sval(str *rname, str *cname);
+
int xavu_serialize_fields(str *rname, char *obuf, int olen);
/** xavi api */