#include <babeltrace/plugin/notification/notification.h>
#include <stdio.h>
#include <stdbool.h>
-
-static
-enum bt_component_status ctf_text_init(struct bt_component *,
- struct bt_value *params);
-
-/* Initialize plug-in entry points. */
-BT_PLUGIN_NAME("ctf-text");
-BT_PLUGIN_DESCRIPTION("Babeltrace text output plug-in.");
-BT_PLUGIN_AUTHOR("Jérémie Galarneau");
-BT_PLUGIN_LICENSE("MIT");
-
-BT_PLUGIN_COMPONENT_CLASSES_BEGIN
-BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY("text", "Formats CTF-IR to text. Formerly known as ctf-text.", ctf_text_init)
-BT_PLUGIN_COMPONENT_CLASSES_END
+#include <glib.h>
enum loglevel {
LOGLEVEL_EMERG = 0,
[LOGLEVEL_DEBUG] = "TRACE_DEBUG",
};
-struct ctf_text_component {
+struct text_options {
bool opt_print_all_field_names : 1;
bool opt_print_scope_field_names : 1;
bool opt_print_header_field_names : 1;
bool opt_print_delta_field : 1;
};
+struct text_component {
+ struct text_options options;
+};
+
+static
+struct text_component *create_text(void)
+{
+ return g_new0(struct text_component, 1);
+}
+
+static
+void destroy_text_data(struct text_component *data)
+{
+ g_free(data);
+}
+
+static void destroy_text(struct bt_component *component)
+{
+ void *data = bt_component_get_private_data(component);
+
+ destroy_text_data(data);
+}
+
static
-enum bt_component_status ctf_text_init(
- struct bt_component *component, struct bt_value *params)
+enum bt_component_status handle_notification(struct bt_component *component,
+ struct bt_notification *notification)
{
- printf("ctf_text_init\n");
return BT_COMPONENT_STATUS_OK;
}
+
+static
+enum bt_component_status text_component_init(
+ struct bt_component *component, struct bt_value *params)
+{
+ enum bt_component_status ret;
+ struct text_component *text = create_text();
+
+ if (!text) {
+ ret = BT_COMPONENT_STATUS_NOMEM;
+ goto end;
+ }
+
+ ret = bt_component_set_destroy_cb(component,
+ destroy_text);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto error;
+ }
+
+ ret = bt_component_set_private_data(component, text);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto error;
+ }
+
+ ret = bt_component_sink_set_handle_notification_cb(component,
+ handle_notification);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto error;
+ }
+end:
+ return ret;
+error:
+ destroy_text_data(text);
+ return ret;
+}
+
+/* Initialize plug-in entry points. */
+BT_PLUGIN_NAME("ctf-text");
+BT_PLUGIN_DESCRIPTION("Babeltrace text output plug-in.");
+BT_PLUGIN_AUTHOR("Jérémie Galarneau");
+BT_PLUGIN_LICENSE("MIT");
+
+BT_PLUGIN_COMPONENT_CLASSES_BEGIN
+BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY("text", "Formats CTF-IR to text. Formerly known as ctf-text.", text_component_init)
+BT_PLUGIN_COMPONENT_CLASSES_END