Start ctf reader implementation stub
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 20 May 2015 02:32:07 +0000 (22:32 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 16:54:31 +0000 (12:54 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/plugin/plugin-system.h
plugins/ctf/reader.c

index 67406353b6133382ec8c1f4a75b6c959c9a658b2..a606a459d45df767708fce3bffb6a665e36824a9 100644 (file)
@@ -99,7 +99,7 @@ extern struct bt_plugin *bt_plugin_sink_create(const char *name,
 
 /* Notification iterator functions */
 /**
- * Allocate an notification iterator.
+ * Allocate a notification iterator.
  *
  * @param plugin               Plug-in instance
  * @param next_cb              Callback advancing to the next notification
index f642e3c7f893e139b6ccfcaeb543021f83d5c00b..181d400ab1afadbbde114c45466a4c124ffed79d 100644 (file)
-enum bt_plugin_type bt_plugin_get_type(void)
+#include <babeltrace/plugin/plugin-lib.h>
+#include <babeltrace/plugin/plugin-system.h>
+#include <glib.h>
+#include <stdio.h>
+
+const char *plugin_name = "ctf";
+
+struct ctf_reader {
+        FILE *err;
+};
+
+enum bt_plugin_type bt_plugin_lib_get_type(void)
 {
        return BT_PLUGIN_TYPE_SOURCE;
 }
 
-const char *bt_plugin_get_format_name(void)
+const char *bt_plugin_lib_get_format_name(void)
 {
-       return "ctf";
+       return plugin_name;
 }
 
-static struct bt_notification_iterator *create_iterator(struct bt_plugin *plugin)
+static
+void ctf_reader_destroy(struct bt_plugin *plugin)
 {
-       return NULL;
+       struct ctf_reader *reader;
+
+       if (!plugin) {
+               return;
+       }
+
+       reader = bt_plugin_get_private_data(plugin);
+       if (!reader) {
+               return;
+       }
+
+       g_free(reader);
 }
 
-static void destroy_mein_shitzle(struct bt_plugin *plugin)
+static
+struct bt_notification_iterator *ctf_reader_iterator_create(
+               struct bt_plugin *plugin)
 {
-       free(bt_plugin_get_data(plugin));
+       return NULL;
 }
 
-struct bt_plugin *bt_plugin_create(struct bt_ctf_field *params)
+/* Move this to bt_plugin */
+static
+enum bt_plugin_status ctf_reader_set_error_stream(
+               struct bt_plugin *plugin, FILE *stream)
 {
-       void *mein_shit = 0x4589;
+       struct ctf_reader *reader;
+       enum bt_plugin_status ret = BT_PLUGIN_STATUS_OK;
 
-       return bt_plugin_source_create("ctf", mein_shit, destroy_func,
-               create_iterator);
+       if (!plugin) {
+               ret = BT_PLUGIN_STATUS_INVAL;
+               goto end;
+       }
+
+       reader = bt_plugin_get_private_data(plugin);
+       if (!reader) {
+               ret = BT_PLUGIN_STATUS_ERROR;
+               goto end;
+       }
+
+       reader->stream = stream;
+end:
+       return ret;
 }
 
+struct bt_plugin *bt_plugin_lib_create(struct bt_object *params)
+{
+       enum bt_plugin_status ret;
+       struct bt_plugin *plugin = NULL;
+       struct ctf_reader *reader = g_new0(struct ctf_reader, 1);
+
+       if (!reader) {
+               goto error;
+       }
+
+       plugin = bt_plugin_source_create(plugin_name, reader,
+               ctf_reader_destroy, ctf_reader_iterator_create);
+       if (!plugin) {
+               goto error;
+       }
+       reader = NULL;
+
+       ret = bt_plugin_set_error_stream_cb(plugin,
+               ctf_reader_set_error_stream);
+       if (ret != BT_PLUGIN_STATUS_OK) {
+               goto error;
+       }
+end:
+       return plugin;
+error:
+       if (reader) {
+               ctf_reader_destroy(reader);
+       }
+       if (plugin) {
+               bt_plugin_put(plugin);
+               plugin = NULL;
+       }
+       goto end;
+}
This page took 0.026541 seconds and 4 git commands to generate.