Change-Id: If8a1ac53e58ff644d7903aebd263d7d42308c756
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
struct api_so_v1 *desc = closure;
verb = search(desc, xreq->verb);
struct api_so_v1 *desc = closure;
verb = search(desc, xreq->verb);
- if (!verb)
- afb_xreq_fail_unknown_verb(xreq);
- else
- if (!xreq_session_check_apply(xreq, verb->session))
- afb_xreq_call(xreq, verb->callback);
+ afb_xreq_call_verb_v1(xreq, verb);
}
static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset)
}
static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset)
const struct afb_verb_v2 *verb;
verb = search(desc, xreq->verb);
const struct afb_verb_v2 *verb;
verb = search(desc, xreq->verb);
- if (!verb)
- afb_xreq_fail_unknown_verb(xreq);
- else
- if (!xreq_session_check_apply(xreq, verb->session))
- afb_xreq_call(xreq, verb->callback);
+ afb_xreq_call_verb_v2(xreq, verb);
}
static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset)
}
static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset)
afb_req_subcall(to_req(xreq), api, verb, args, callback, cb_closure);
}
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)
- return 0;
-}
-
-void xreq_session_apply(struct afb_xreq *xreq, int sessionflags)
-{
if ((sessionflags & AFB_SESSION_RENEW) != 0) {
afb_context_refresh(&xreq->context);
}
if ((sessionflags & AFB_SESSION_RENEW) != 0) {
afb_context_refresh(&xreq->context);
}
afb_context_change_loa(&xreq->context, 0);
afb_context_close(&xreq->context);
}
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;
-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)
+ 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)
}
void afb_xreq_init(struct afb_xreq *xreq, const struct afb_xreq_query_itf *queryitf)
extern void afb_xreq_process(struct afb_xreq *xreq, struct afb_apiset *apiset);
extern void afb_xreq_process(struct afb_xreq *xreq, struct afb_apiset *apiset);
-extern int xreq_session_check(struct afb_xreq *xreq, int sessionflags);
-extern void xreq_session_apply(struct afb_xreq *xreq, int sessionflags);
-extern int xreq_session_check_apply(struct afb_xreq *xreq, int sessionflags);
-
-extern void afb_xreq_call(struct afb_xreq *xreq, void (*callback)(struct afb_req req));
-extern void afb_xreq_check_apply_call(struct afb_xreq *xreq, int sessionflags, void (*callback)(struct afb_req req));
+extern void afb_xreq_call_verb_v1(struct afb_xreq *xreq, const struct afb_verb_desc_v1 *verb);
+extern void afb_xreq_call_verb_v2(struct afb_xreq *xreq, const struct afb_verb_v2 *verb);