summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-09-22 10:53:18 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-10-09 14:08:32 +0200
commit1874271ce06622664e3513e5335b29de2c55ace6 (patch)
treed5c41d599f0fdb273193b7b34f877d1e124cea76
parentf23bc8bdcb4420b9a7ee825a6fdf7a2c47680f5f (diff)
afb-export: prepare to eventid
Change-Id: I87c09c2edb198598b3d303ceff07fcd6ec6a40f1 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-export.c24
1 files changed, 17 insertions, 7 deletions
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;