From: José Bollo Date: Fri, 22 Sep 2017 08:53:18 +0000 (+0200) Subject: afb-export: prepare to eventid X-Git-Tag: eel_4.99.2~30 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fapp-framework-binder.git;a=commitdiff_plain;h=1874271ce06622664e3513e5335b29de2c55ace6 afb-export: prepare to eventid Change-Id: I87c09c2edb198598b3d303ceff07fcd6ec6a40f1 Signed-off-by: José Bollo --- diff --git a/src/afb-export.c b/src/afb-export.c index adc840f0..bd5b61e0 100644 --- a/src/afb-export.c +++ b/src/afb-export.c @@ -132,18 +132,17 @@ static void old_vverbose_cb(void *closure, int level, const char *file, int line vverbose_cb(closure, level, file, line, NULL, fmt, args); } -static struct afb_event event_make_cb(void *closure, const char *name) +static struct afb_eventid *eventid_make_cb(void *closure, const char *name) { size_t plen, nlen; char *event; struct afb_export *export = closure; - struct afb_eventid *eventid; /* check daemon state */ if (export->state == Api_State_Pre_Init) { ERROR("[API %s] Bad call to 'afb_daemon_event_make(%s)', must not be in PreInit", export->apiname, name); errno = EINVAL; - return (struct afb_event){ .itf = NULL, .closure = NULL }; + return NULL; } /* makes the event name */ @@ -155,7 +154,12 @@ static struct afb_event event_make_cb(void *closure, const char *name) memcpy(event + plen + 1, name, nlen + 1); /* create the event */ - eventid = afb_evt_create_event(event); + return afb_evt_create_event(event); +} + +static struct afb_event event_make_cb(void *closure, const char *name) +{ + struct afb_eventid *eventid = eventid_make_cb(closure, name); return (struct afb_event){ .itf = eventid ? eventid->itf : NULL, .closure = eventid }; } @@ -246,14 +250,20 @@ static void hooked_old_vverbose_cb(void *closure, int level, const char *file, i hooked_vverbose_cb(closure, level, file, line, NULL, fmt, args); } -static struct afb_event hooked_event_make_cb(void *closure, const char *name) +static struct afb_eventid *hooked_eventid_make_cb(void *closure, const char *name) { struct afb_export *export = closure; - struct afb_event r = event_make_cb(closure, name); - afb_hook_ditf_event_make(export, name, r.closure); + struct afb_eventid *r = eventid_make_cb(closure, name); + afb_hook_ditf_event_make(export, name, r); return r; } +static struct afb_event hooked_event_make_cb(void *closure, const char *name) +{ + struct afb_eventid *eventid = hooked_eventid_make_cb(closure, name); + return (struct afb_event){ .itf = eventid ? eventid->itf : NULL, .closure = eventid }; +} + static int hooked_event_broadcast_cb(void *closure, const char *name, struct json_object *object) { int r;