evt: exposes name of events 59/5959/1
authorJosé Bollo <jose.bollo@iot.bzh>
Fri, 17 Jun 2016 20:06:41 +0000 (22:06 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Fri, 17 Jun 2016 20:08:58 +0000 (22:08 +0200)
Change-Id: I1976848be0e8aeb170da37e1254208035e0e741a
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-evt.c
src/afb-evt.h

index a99dc89..53ab0e0 100644 (file)
@@ -204,6 +204,14 @@ struct afb_event afb_evt_create_event(const char *name)
        return (struct afb_event){ .itf = &afb_evt_event_itf, .closure = evt };
 }
 
+/*
+ * Returns the name of the 'event'
+ */
+const char *afb_evt_event_name(struct afb_event event)
+{
+       return (event.itf != &afb_evt_event_itf) ? NULL : ((struct afb_evt_event *)event.closure)->name;
+}
+
 /*
  * Returns an instance of the listener defined by the 'send' callback
  * and the 'closure'.
index 8e10254..157a777 100644 (file)
@@ -30,6 +30,7 @@ extern struct afb_evt_listener *afb_evt_listener_addref(struct afb_evt_listener
 extern void afb_evt_listener_unref(struct afb_evt_listener *listener);
 
 extern struct afb_event afb_evt_create_event(const char *name);
+extern const char *afb_evt_event_name(struct afb_event event);
 
 extern int afb_evt_add_watch(struct afb_evt_listener *listener, struct afb_event event);
 extern int afb_evt_remove_watch(struct afb_evt_listener *listener, struct afb_event event);