aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-xreq.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-05-04 13:06:02 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-05-04 13:06:02 +0200
commit8a5d14c58817b7ee03f8e22ba734fdd8cc2bc780 (patch)
tree95ec6d12192174bedc036ae9cfd1a3f3f046fb73 /src/afb-xreq.c
parentc0562698d8e2613e488b320736255e6bbd49cb2c (diff)
Prepare xreq to be aware of the version
Change-Id: If8a1ac53e58ff644d7903aebd263d7d42308c756 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-xreq.c')
-rw-r--r--src/afb-xreq.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index 143048c2..d6cf91fd 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -439,7 +439,7 @@ void afb_xreq_subcall(struct afb_xreq *xreq, const char *api, const char *verb,
afb_req_subcall(to_req(xreq), api, verb, args, callback, cb_closure);
}
-int xreq_session_check(struct afb_xreq *xreq, int sessionflags)
+static int xreq_session_check_apply(struct afb_xreq *xreq, int sessionflags)
{
int loa;
@@ -470,11 +470,6 @@ int xreq_session_check(struct afb_xreq *xreq, int sessionflags)
}
}
- return 0;
-}
-
-void xreq_session_apply(struct afb_xreq *xreq, int sessionflags)
-{
if ((sessionflags & AFB_SESSION_RENEW) != 0) {
afb_context_refresh(&xreq->context);
}
@@ -482,26 +477,26 @@ void xreq_session_apply(struct afb_xreq *xreq, int sessionflags)
afb_context_change_loa(&xreq->context, 0);
afb_context_close(&xreq->context);
}
-}
-int xreq_session_check_apply(struct afb_xreq *xreq, int sessionflags)
-{
- int rc = xreq_session_check(xreq, sessionflags);
- if (!rc)
- xreq_session_apply(xreq, sessionflags);
-
- return rc;
+ return 0;
}
-void afb_xreq_call(struct afb_xreq *xreq, void (*method)(struct afb_req req))
+void afb_xreq_call_verb_v1(struct afb_xreq *xreq, const struct afb_verb_desc_v1 *verb)
{
- method(to_req(xreq));
+ if (!verb)
+ afb_xreq_fail_unknown_verb(xreq);
+ else
+ if (!xreq_session_check_apply(xreq, verb->session))
+ verb->callback(to_req(xreq));
}
-void afb_xreq_check_apply_call(struct afb_xreq *xreq, int sessionflags, void (*method)(struct afb_req req))
+void afb_xreq_call_verb_v2(struct afb_xreq *xreq, const struct afb_verb_v2 *verb)
{
- if (!xreq_session_check_apply(xreq, sessionflags))
- method(to_req(xreq));
+ if (!verb)
+ afb_xreq_fail_unknown_verb(xreq);
+ else
+ if (!xreq_session_check_apply(xreq, verb->session))
+ verb->callback(to_req(xreq));
}
void afb_xreq_init(struct afb_xreq *xreq, const struct afb_xreq_query_itf *queryitf)