From be63003e3f1841b43614f0e11b0a291e11f1dad1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Fri, 22 Sep 2017 09:37:54 +0200 Subject: [PATCH] Provide conversions for afb_event and afb_req MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Provision is made here to convert, trivially: afb_event -> afb_eventid* afb_req -> afb_request* The opposite conversions aren't provided to favor new interfaces. Change-Id: Ib67c2317f782e2edfd1ba0e49e10b321a3b770a3 Signed-off-by: José Bollo --- include/afb/afb-event.h | 8 ++++++++ include/afb/afb-req.h | 8 ++++++++ src/afb-trace.c | 7 +++++-- src/afb-xreq.c | 8 ++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/afb/afb-event.h b/include/afb/afb-event.h index c3686fdd..2e7f6ab9 100644 --- a/include/afb/afb-event.h +++ b/include/afb/afb-event.h @@ -28,6 +28,14 @@ struct afb_event struct afb_eventid *closure; /* the closure argument for functions of 'itf' */ }; +/* + * Converts the 'event' to an afb_eventid. + */ +static inline struct afb_eventid *afb_event_to_eventid(struct afb_event event) +{ + return event.closure; +} + /* * Checks wether the 'event' is valid or not. * diff --git a/include/afb/afb-req.h b/include/afb/afb-req.h index 71dd31d1..6f98e900 100644 --- a/include/afb/afb-req.h +++ b/include/afb/afb-req.h @@ -30,6 +30,14 @@ struct afb_req struct afb_request *closure; /* the closure argument for functions of 'itf' */ }; +/* + * Converts the 'req' to an afb_request. + */ +static inline struct afb_request *afb_req_to_request(struct afb_req req) +{ + return req.closure; +} + /* * Checks whether the request 'req' is valid or not. * diff --git a/src/afb-trace.c b/src/afb-trace.c index 2c2bb52b..4869d9a8 100644 --- a/src/afb-trace.c +++ b/src/afb-trace.c @@ -27,7 +27,8 @@ #include #include -#include +#define AFB_BINDING_VERSION 0 +#include #include "afb-hook.h" #include "afb-cred.h" @@ -1088,6 +1089,7 @@ static struct tag *trace_get_tag(struct afb_trace *trace, const char *name, int */ static struct event *trace_get_event(struct afb_trace *trace, const char *name, int alloc) { + struct afb_event e; struct event *event; /* search the event */ @@ -1098,7 +1100,8 @@ static struct event *trace_get_event(struct afb_trace *trace, const char *name, if (!event && alloc) { event = malloc(sizeof * event); if (event) { - event->evtid = afb_evt_to_evtid(trace->daemon->itf->event_make(trace->daemon->closure, name).closure); + e = afb_daemon_make_event_v1(*trace->daemon, name); + event->evtid = afb_evt_to_evtid(afb_event_to_eventid(e)); if (event->evtid) { event->next = trace->events; trace->events = event; diff --git a/src/afb-xreq.c b/src/afb-xreq.c index ed5f30b0..f9f2324a 100644 --- a/src/afb-xreq.c +++ b/src/afb-xreq.c @@ -424,7 +424,7 @@ static int xreq_session_set_LOA_cb(struct afb_request *closure, unsigned level) static int xreq_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid); static int xreq_subscribe_cb(struct afb_request *closure, struct afb_event event) { - return xreq_subscribe_eventid_cb(closure, event.closure); + return xreq_subscribe_eventid_cb(closure, afb_event_to_eventid(event)); } static int xreq_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid) @@ -447,7 +447,7 @@ int afb_xreq_subscribe(struct afb_xreq *xreq, struct afb_eventid *eventid) static int xreq_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid); static int xreq_unsubscribe_cb(struct afb_request *closure, struct afb_event event) { - return xreq_unsubscribe_eventid_cb(closure, event.closure); + return xreq_unsubscribe_eventid_cb(closure, afb_event_to_eventid(event)); } static int xreq_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid) @@ -642,7 +642,7 @@ static int xreq_hooked_session_set_LOA_cb(struct afb_request *closure, unsigned static int xreq_hooked_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid); static int xreq_hooked_subscribe_cb(struct afb_request *closure, struct afb_event event) { - return xreq_hooked_subscribe_eventid_cb(closure, event.closure); + return xreq_hooked_subscribe_eventid_cb(closure, afb_event_to_eventid(event)); } static int xreq_hooked_subscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid) @@ -655,7 +655,7 @@ static int xreq_hooked_subscribe_eventid_cb(struct afb_request *closure, struct static int xreq_hooked_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid); static int xreq_hooked_unsubscribe_cb(struct afb_request *closure, struct afb_event event) { - return xreq_hooked_unsubscribe_eventid_cb(closure, event.closure); + return xreq_hooked_unsubscribe_eventid_cb(closure, afb_event_to_eventid(event)); } static int xreq_hooked_unsubscribe_eventid_cb(struct afb_request *closure, struct afb_eventid *eventid) -- 2.16.6