Module: kamailio Branch: master Commit: 8f753d10b7dd44735d723dd781864ddd0202e769 URL: https://github.com/kamailio/kamailio/commit/8f753d10b7dd44735d723dd781864ddd...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: 2020-04-15T11:09:40+02:00
core: KEMI suport for ARRAY and DICT
---
Modified: src/core/kemi.c Modified: src/core/kemi.h
---
Diff: https://github.com/kamailio/kamailio/commit/8f753d10b7dd44735d723dd781864ddd... Patch: https://github.com/kamailio/kamailio/commit/8f753d10b7dd44735d723dd781864ddd...
---
diff --git a/src/core/kemi.c b/src/core/kemi.c index 8b5663a39f..d389c4b4e0 100644 --- a/src/core/kemi.c +++ b/src/core/kemi.c @@ -2390,6 +2390,34 @@ void sr_kemi_xval_null(sr_kemi_xval_t *xval, int rmode) } }
+/** + * + */ +void sr_kemi_dict_item_free(sr_kemi_dict_item_t *item) +{ + sr_kemi_dict_item_t *v; + + while(item) { + if (item->vtype == SR_KEMIP_ARRAY || item->vtype == SR_KEMIP_DICT) { + sr_kemi_dict_item_free(item->v.dict); + } + v = item; + item = item->next; + pkg_free(v); + } +} + +/** + * + */ +void sr_kemi_xval_free(sr_kemi_xval_t *xval) +{ + if(xval && (xval->vtype == SR_KEMIP_ARRAY || xval->vtype == SR_KEMIP_DICT)) + { + sr_kemi_dict_item_free(xval->v.dict); + } +} + /** * */ diff --git a/src/core/kemi.h b/src/core/kemi.h index 7824ce2f60..85cd521512 100644 --- a/src/core/kemi.h +++ b/src/core/kemi.h @@ -32,6 +32,8 @@ #define SR_KEMIP_BOOL (1<<2) /* type boolean (0/1) */ #define SR_KEMIP_XVAL (1<<3) /* type extended value (integer, str*, ...) */ #define SR_KEMIP_NULL (1<<4) /* type NULL */ +#define SR_KEMIP_DICT (1<<5) /* type dictionary */ +#define SR_KEMIP_ARRAY (1<<6) /* type array */
#define SR_KEMI_FALSE 0 #define SR_KEMI_TRUE 1 @@ -66,11 +68,24 @@ typedef union { str s; } sr_kemi_val_t;
+typedef struct sr_kemi_dict_item +{ + struct sr_kemi_dict_item *next; + str name; + int vtype; + union { + int n; + str s; + struct sr_kemi_dict_item *dict; + } v; +} sr_kemi_dict_item_t; + typedef struct sr_kemi_xval { int vtype; union { int n; str s; + sr_kemi_dict_item_t *dict; } v; } sr_kemi_xval_t;
@@ -208,5 +223,5 @@ sr_kemi_t* sr_kemi_exports_get_pv(void); #define SR_KEMI_XVAL_NULL_PRINT 1 #define SR_KEMI_XVAL_NULL_EMPTY 2 void sr_kemi_xval_null(sr_kemi_xval_t *xval, int rmode); - +void sr_kemi_xval_free(sr_kemi_xval_t *xval); #endif