summaryrefslogtreecommitdiffstats
path: root/src/afb-xreq.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-06-02 15:38:13 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-06-02 15:38:13 +0200
commitd3c80685ed6067f4899635c0328bbd8b70a2ed90 (patch)
treed2e0a04cc8ccf032ec8f8893252d47cfb74d1e84 /src/afb-xreq.c
parent16899582de97ffa492768e5d96cec813f44417ea (diff)
Localize construction of afb_arg
Change-Id: I08f1bc228c419243044949aa3c4094873932d3f2 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-xreq.c')
-rw-r--r--src/afb-xreq.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index fbed6ed1..9c4cab8f 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -63,10 +63,23 @@ static struct json_object *xreq_json_cb(void *closure)
static struct afb_arg xreq_get_cb(void *closure, const char *name)
{
struct afb_xreq *xreq = closure;
+ struct afb_arg arg;
+ struct json_object *object, *value;
+
if (xreq->queryitf->get)
- return xreq->queryitf->get(xreq, name);
- else
- return afb_msg_json_get_arg(xreq_json_cb(closure), name);
+ arg = xreq->queryitf->get(xreq, name);
+ else {
+ object = xreq_json_cb(closure);
+ if (json_object_object_get_ex(object, name, &value)) {
+ arg.name = name;
+ arg.value = json_object_get_string(value);
+ } else {
+ arg.name = NULL;
+ arg.value = NULL;
+ }
+ arg.path = NULL;
+ }
+ return arg;
}
static void xreq_success_cb(void *closure, struct json_object *obj, const char *info)