Tag broadcasted events with UUID and hop
[src/app-framework-binder.git] / src / afb-export.c
index bfd7653..c146f7e 100644 (file)
@@ -163,7 +163,7 @@ struct afb_export
        } export;
 
        /* initial name */
-       char name[1];
+       char name[];
 };
 
 /*****************************************************************************/
@@ -1178,10 +1178,20 @@ static void listener_of_events(void *closure, const char *event, int eventid, st
        json_object_put(object);
 }
 
+static void listener_of_pushed_events(void *closure, const char *event, int eventid, struct json_object *object)
+{
+       listener_of_events(closure, event, eventid, object);
+}
+
+static void listener_of_broadcasted_events(void *closure, const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop)
+{
+       listener_of_events(closure, event, 0, object);
+}
+
 /* the interface for events */
 static const struct afb_evt_itf evt_itf = {
-       .broadcast = listener_of_events,
-       .push = listener_of_events
+       .broadcast = listener_of_broadcasted_events,
+       .push = listener_of_pushed_events
 };
 
 /* ensure an existing listener */
@@ -1271,7 +1281,7 @@ static struct afb_export *create(
                        return NULL;
        }
        lenapi = strlen(apiname);
-       export = calloc(1, sizeof *export + lenapi + (path == apiname || !path ? 0 : strlen(path)));
+       export = calloc(1, sizeof *export + 1 + lenapi + (path == apiname || !path ? 0 : 1 + strlen(path)));
        if (!export)
                errno = ENOMEM;
        else {