Module: kamailio
Branch: master
Commit: 26b09ae0d9b36dfed9688536e7f8cd6ff22d89fd
URL:
https://github.com/kamailio/kamailio/commit/26b09ae0d9b36dfed9688536e7f8cd6…
Author: Emmanuel Schmidbauer <emmanuel(a)getweave.com>
Committer: Emmanuel Schmidbauer <emmanuel(a)getweave.com>
Date: 2018-01-29T12:42:29-07:00
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/26b09ae0d9b36dfed9688536e7f8cd6…
Patch:
https://github.com/kamailio/kamailio/commit/26b09ae0d9b36dfed9688536e7f8cd6…
---
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;
}
/**