Module: kamailio
Branch: master
Commit: 00da0530c7295b74b932307bad27580e14c3a987
URL: 
https://github.com/kamailio/kamailio/commit/00da0530c7295b74b932307bad27580e14c3a987

Author: Emmanuel Schmidbauer <[email protected]>
Committer: GitHub <[email protected]>
Date: 2018-01-30T10:09:10-05:00

Merge pull request #1418 from kamailio/json-update-api

json: pass str pointer to API

---

Modified: src/modules/json/api.h
Modified: src/modules/json/json_funcs.h
Modified: src/modules/json/json_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/00da0530c7295b74b932307bad27580e14c3a987.diff
Patch: 
https://github.com/kamailio/kamailio/commit/00da0530c7295b74b932307bad27580e14c3a987.patch

---

diff --git a/src/modules/json/api.h b/src/modules/json/api.h
index c900dd5c0d..0610eaffeb 100644
--- a/src/modules/json/api.h
+++ b/src/modules/json/api.h
@@ -26,7 +26,7 @@
 
 typedef struct json_object *(*json_parse_f) (const char *str);
 typedef struct json_object *(*json_get_object_f) (struct json_object 
*json_obj, const char *str);
-typedef str (*json_extract_field_f) (struct json_object *json_obj, char 
*json_name);
+typedef int (*json_extract_field_f) (struct json_object *json_obj, char 
*json_name, str *var);
 
 typedef struct json_api {
        json_parse_f json_parse;
diff --git a/src/modules/json/json_funcs.h b/src/modules/json/json_funcs.h
index 331d1e3df8..747232efac 100644
--- a/src/modules/json/json_funcs.h
+++ b/src/modules/json/json_funcs.h
@@ -29,18 +29,18 @@
 
 int json_get_field(struct sip_msg* msg, char* json, char* field, char* dst);
 
-#define json_extract_field(json_name, field)                                \
-       do {                                                                    
\
+#define json_extract_field(json_name, field)                            \
+       do {                                                                \
                struct json_object *obj = json_get_object(json_obj, json_name); 
\
-               field.s = (char *)json_object_get_string(obj);                  
    \
-               if(field.s == NULL) {                                           
    \
-                       LM_DBG("Json-c error - failed to extract field [%s]\n", 
        \
-                                       json_name);                             
                \
-                       field.s = "";                                           
        \
-               } else {                                                        
    \
-                       field.len = strlen(field.s);                            
        \
-               }                                                               
    \
-               LM_DBG("%s: [%s]\n", json_name, field.s ? field.s : "Empty");   
    \
+               field->s = (char *)json_object_get_string(obj);                 
\
+               if(field->s == NULL) {                                          
\
+                       LM_DBG("Json-c error - failed to extract field [%s]\n", 
    \
+                                       json_name);                             
            \
+                       field->s = "";                                          
    \
+               } else {                                                        
\
+                       field->len = strlen(field->s);                          
    \
+               }                                                               
\
+               LM_DBG("%s: [%s]\n", json_name, field->s ? field->s : "Empty"); 
\
        } while(0);
 
 
diff --git a/src/modules/json/json_mod.c b/src/modules/json/json_mod.c
index 051da4dd59..f5de53d692 100644
--- a/src/modules/json/json_mod.c
+++ b/src/modules/json/json_mod.c
@@ -65,10 +65,9 @@ struct module_exports exports = {
                0                                                /* per-child 
init function */
 };
 
-str _json_extract_field(struct json_object *json_obj, char *json_name) {
-       str val = {0, 0};
+int _json_extract_field(struct json_object *json_obj, char *json_name, str 
*val) {
        json_extract_field(json_name, val);
-       return val;
+       return 0;
 }
 
 /**


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to