Add reading loop to babeltrace binary
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 6 Sep 2016 20:11:57 +0000 (16:11 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:06 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
converter/babeltrace.c

index cd7bd7c48b3cd0746ce03cbb9b36435c55580cf5..36db88d11f6cf5d193a50d30213853e5d32ff677 100644 (file)
@@ -30,6 +30,7 @@
 #include <babeltrace/plugin/component-factory.h>
 #include <babeltrace/plugin/plugin.h>
 #include <babeltrace/plugin/component-class.h>
+#include <babeltrace/plugin/notification/iterator.h>
 #include <babeltrace/ref.h>
 #include <babeltrace/values.h>
 #include <stdlib.h>
@@ -201,6 +202,7 @@ int main(int argc, char **argv)
        struct bt_component_class *source_class = NULL, *sink_class = NULL;
        struct bt_component *source = NULL, *sink = NULL;
        struct bt_value *source_params = NULL, *sink_params = NULL;
+       struct bt_notification_iterator *it = NULL;
 
        ret = parse_options(argc, argv);
        if (ret < 0) {
@@ -280,6 +282,19 @@ int main(int argc, char **argv)
                goto end;
        }
 
+       it = bt_component_source_create_iterator(source);
+       if (!it) {
+               fprintf(stderr, "Failed to instantiate source iterator. Aborting...\n");
+               ret = -1;
+               goto end;
+       }
+
+       do {
+               struct bt_notification *notification =
+                               bt_notification_iterator_get_notification(it);
+               BT_PUT(notification);
+       } while (bt_notification_iterator_next(it) ==
+                       BT_NOTIFICATION_ITERATOR_STATUS_OK);
        /* teardown and exit */
 end:
        BT_PUT(component_factory);
@@ -289,5 +304,6 @@ end:
        BT_PUT(sink);
        BT_PUT(source_params);
        BT_PUT(sink_params);
+       BT_PUT(it);
        return ret ? 1 : 0;
 }
This page took 0.025687 seconds and 4 git commands to generate.