X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-export.c;h=bd5b61e0794fc4e3fb2db479e500da2685c22c86;hb=1874271ce06622664e3513e5335b29de2c55ace6;hp=adc840f0b431879106a090ea07b851851ca5a183;hpb=f23bc8bdcb4420b9a7ee825a6fdf7a2c47680f5f;p=src%2Fapp-framework-binder.git 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;