+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+
+ if (!text) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+
+ switch (bt_notification_get_type(notification)) {
+ case BT_NOTIFICATION_TYPE_PACKET_START:
+ puts("<packet>");
+ break;
+ case BT_NOTIFICATION_TYPE_PACKET_END:
+ puts("</packet>");
+ break;
+ case BT_NOTIFICATION_TYPE_EVENT:
+ {
+ struct bt_ctf_event *event = bt_notification_event_get_event(
+ notification);
+
+ if (!event) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+ ret = text_print_event(text, event);
+ bt_put(event);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ break;
+ }
+ case BT_NOTIFICATION_TYPE_STREAM_END:
+ puts("</stream>");
+ break;
+ default:
+ puts("Unhandled notification type");
+ }
+end:
+ return ret;
+}
+
+static
+enum bt_component_status run(struct bt_component *component)
+{
+ enum bt_component_status ret;
+ struct bt_notification *notification = NULL;
+ struct bt_notification_iterator *it;
+ struct text_component *text = bt_component_get_private_data(component);
+
+ ret = bt_component_sink_get_input_iterator(component, 0, &it);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+
+ if (!text->processed_first_event) {
+ ret = bt_notification_iterator_next(it);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto end;
+ }
+ } else {
+ text->processed_first_event = true;
+ }
+
+ notification = bt_notification_iterator_get_notification(it);
+ if (!notification) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+
+ ret = handle_notification(text, notification);
+end:
+ bt_put(it);
+ bt_put(notification);
+ return ret;