ctf-text plugin stub
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 23 Jul 2015 20:54:47 +0000 (16:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 16:57:26 +0000 (12:57 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/plugin/plugin-system.h
include/babeltrace/plugin/plugin.h
plugins/Makefile.am
plugins/ctf/Makefile.am
plugins/ctf/text/text.c

index d2970b5895b57b1ad653a7bd187610c0acaed81b..b5158d8b47beaeb06ba3bd9c32f6b915be6f1fc4 100644 (file)
@@ -55,8 +55,9 @@ typedef void (*bt_component_destroy_cb)(struct bt_component *component);
  * deinitialization callback must be set by this function.
  *
  * @param component    Component instance
+ * @returns            One of #bt_component_status values
  */
-typedef struct bt_component *(*bt_component_source_init_cb)(
+typedef enum bt_component_status (*bt_component_source_init_cb)(
                struct bt_component *component);
 
 /**
@@ -66,8 +67,9 @@ typedef struct bt_component *(*bt_component_source_init_cb)(
  * deinitialization callback must be set by this function.
  *
  * @param component    Component instance
+ * @returns            One of #bt_component_status values
  */
-typedef struct bt_component *(*bt_component_sink_init_cb)(
+typedef enum bt_component_status (*bt_component_sink_init_cb)(
                struct bt_component *component);
 
 /**
index 945deb940a956fe580e66336b4658e506a0796e7..1642b7a0cf4956dd454fe925e792555e243e820f 100644 (file)
@@ -39,8 +39,8 @@ typedef void (*bt_plugin_exit_func)(void);
 #define BT_PLUGIN_NAME(_x)     const char *__bt_plugin_name = (_x)
 #define BT_PLUGIN_AUTHOR(_x)   const char *__bt_plugin_author = (_x)
 #define BT_PLUGIN_LICENSE(_x)  const char *__bt_plugin_license = (_x)
-#define BT_PLUGIN_INIT(_x)      bt_plugin_init __bt_plugin_init = (_x)
-#define BT_PLUGIN_EXIT(_x)      bt_plugin_exit __bt_plugin_exit = (_x)
+#define BT_PLUGIN_INIT(_x)      bt_plugin_init_func __bt_plugin_init = (_x)
+#define BT_PLUGIN_EXIT(_x)      bt_plugin_exit_func __bt_plugin_exit = (_x)
 
 #define BT_PLUGIN_COMPONENT_CLASSES_BEGIN                      \
        enum bt_component_status __bt_plugin_register_component_classes(\
@@ -61,6 +61,5 @@ typedef void (*bt_plugin_exit_func)(void);
 }\
        \
        BT_PLUGIN_INIT(__bt_plugin_register_component_classes);\
-       BT_PLUGIN_EXIT(NULL);
 
 #endif /* BABELTRACE_PLUGIN_H */
index 88643977fa8bae81ae642d6171e81fa5dcfeb327..a3fe4270d1393f8f517989add673ef7fc7b2f015 100644 (file)
@@ -1,6 +1,6 @@
 AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include
 
-SUBDIRS = .
+SUBDIRS = . ctf
 
 lib_LTLIBRARIES = libbabeltrace-plugin.la
 
index 072d81753782bc3bd5bbdbeab6fc95b33f19c2e3..b43d126e6728c083a62d4109b5f512d1fb8b629c 100644 (file)
@@ -1,18 +1,3 @@
 AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include
 
-SUBDIRS = reader text
-
-# Shared code between all CTF plug-ins
-#libbabeltrace_plugin_ctf_la_SOURCES = \
-       plugin.c \
-       source.c \
-       sink.c \
-       iterator.c
-
-# Request that the linker keeps all static librarie objects.
-#libbabeltrace_plugin_la_LDFLAGS = \
-       -Wl,--no-as-needed -version-info $(BABELTRACE_LIBRARY_VERSION)
-
-#libbabeltrace_plugin_ctf_la_LIBADD = \
-       $(top_builddir)/lib/libbabeltrace.la \
-       $(top_builddir)/ctf/ir/libctf-ir.la
+SUBDIRS = text
index f80ed589d59565d2861ce76cb39a76ed43cda5b0..03086ad5dea4f3a6676805b3564672c75b64a312 100644 (file)
  * SOFTWARE.
  */
 
-#include <babeltrace/plugin/plugin-lib.h>
-#include <babeltrace/plugin/plugin-system.h>
 #include <babeltrace/plugin/plugin.h>
+#include <babeltrace/plugin/component.h>
 #include <babeltrace/plugin/sink.h>
+#include <babeltrace/plugin/notification/notification.h>
 #include <glib.h>
 #include <stdio.h>
 
 const char *plugin_name = "ctf-text";
 
+static enum bt_component_status ctf_text_init(struct bt_component *);
+static void ctf_text_exit(void);
+
+BT_PLUGIN_NAME("ctf-text");
+BT_PLUGIN_AUTHOR("Jérémie Galarneau");
+BT_PLUGIN_LICENSE("MIT License");
+BT_PLUGIN_EXIT(ctf_text_exit);
+
+BT_PLUGIN_COMPONENT_CLASSES_BEGIN
+BT_PLUGIN_SINK_COMPONENT_CLASS_ENTRY(plugin_name, ctf_text_init)
+BT_PLUGIN_COMPONENT_CLASSES_END
+
+
 enum loglevel {
         LOGLEVEL_EMERG                  = 0,
         LOGLEVEL_ALERT                  = 1,
@@ -54,115 +67,50 @@ enum loglevel {
 };
 
 const char *loglevel_str [] = {
-       [LOGLEVEL_EMERG] = "TRACE_EMERG",
-       [LOGLEVEL_ALERT] = "TRACE_ALERT",
-       [LOGLEVEL_CRIT] = "TRACE_CRIT",
-       [LOGLEVEL_ERR] = "TRACE_ERR",
-       [LOGLEVEL_WARNING] = "TRACE_WARNING",
-       [LOGLEVEL_NOTICE] = "TRACE_NOTICE",
-       [LOGLEVEL_INFO] = "TRACE_INFO",
-       [LOGLEVEL_DEBUG_SYSTEM] = "TRACE_DEBUG_SYSTEM",
-       [LOGLEVEL_DEBUG_PROGRAM] = "TRACE_DEBUG_PROGRAM",
-       [LOGLEVEL_DEBUG_PROCESS] = "TRACE_DEBUG_PROCESS",
-       [LOGLEVEL_DEBUG_MODULE] = "TRACE_DEBUG_MODULE",
-       [LOGLEVEL_DEBUG_UNIT] = "TRACE_DEBUG_UNIT",
-       [LOGLEVEL_DEBUG_FUNCTION] = "TRACE_DEBUG_FUNCTION",
-       [LOGLEVEL_DEBUG_LINE] = "TRACE_DEBUG_LINE",
-       [LOGLEVEL_DEBUG] = "TRACE_DEBUG",
+       [LOGLEVEL_EMERG] =              "TRACE_EMERG",
+       [LOGLEVEL_ALERT] =              "TRACE_ALERT",
+       [LOGLEVEL_CRIT] =               "TRACE_CRIT",
+       [LOGLEVEL_ERR] =                "TRACE_ERR",
+       [LOGLEVEL_WARNING] =            "TRACE_WARNING",
+       [LOGLEVEL_NOTICE] =             "TRACE_NOTICE",
+       [LOGLEVEL_INFO] =               "TRACE_INFO",
+       [LOGLEVEL_DEBUG_SYSTEM] =       "TRACE_DEBUG_SYSTEM",
+       [LOGLEVEL_DEBUG_PROGRAM] =      "TRACE_DEBUG_PROGRAM",
+       [LOGLEVEL_DEBUG_PROCESS] =      "TRACE_DEBUG_PROCESS",
+       [LOGLEVEL_DEBUG_MODULE] =       "TRACE_DEBUG_MODULE",
+       [LOGLEVEL_DEBUG_UNIT] =         "TRACE_DEBUG_UNIT",
+       [LOGLEVEL_DEBUG_FUNCTION] =     "TRACE_DEBUG_FUNCTION",
+       [LOGLEVEL_DEBUG_LINE] =         "TRACE_DEBUG_LINE",
+       [LOGLEVEL_DEBUG] =              "TRACE_DEBUG",
 };
 
-struct ctf_text {
-       int opt_print_all_field_names;
-       int opt_print_scope_field_names;
-       int opt_print_header_field_names;
-       int opt_print_context_field_names;
-       int opt_print_payload_field_names;
-       int opt_print_all_fields;
-       int opt_print_trace_field;
-       int opt_print_trace_domain_field;
-       int opt_print_trace_procname_field;
-       int opt_print_trace_vpid_field;
-       int opt_print_trace_hostname_field;
-       int opt_print_trace_default_fields;
-       int opt_print_loglevel_field;
-       int opt_print_emf_field;
-       int opt_print_callsite_field;
-       int opt_print_delta_field;
+struct ctf_text_component {
+       bool opt_print_all_field_names : 1;
+       bool opt_print_scope_field_names : 1;
+       bool opt_print_header_field_names : 1;
+       bool opt_print_context_field_names : 1;
+       bool opt_print_payload_field_names : 1;
+       bool opt_print_all_fields : 1;
+       bool opt_print_trace_field : 1;
+       bool opt_print_trace_domain_field : 1;
+       bool opt_print_trace_procname_field : 1;
+       bool opt_print_trace_vpid_field : 1;
+       bool opt_print_trace_hostname_field : 1;
+       bool opt_print_trace_default_fields : 1;
+       bool opt_print_loglevel_field : 1;
+       bool opt_print_emf_field : 1;
+       bool opt_print_callsite_field : 1;
+       bool opt_print_delta_field : 1;
 };
 
 static
-void ctf_text_destroy(struct bt_plugin *plugin)
+enum bt_component_status ctf_text_init(struct bt_component *component)
 {
-       struct ctf_text *text;
-
-       if (!plugin) {
-               return;
-       }
-
-        text = bt_plugin_get_private_data(plugin);
-       if (!text) {
-               return;
-       }
-
-       g_free(text);
+       return BT_COMPONENT_STATUS_OK;
 }
 
 static
-int ctf_text_handle_notification(struct bt_plugin *plugin,
-               struct bt_notification *notification)
-{
-       return BT_PLUGIN_STATUS_OK;
-}
-
-enum bt_plugin_type bt_plugin_lib_get_type(void)
-{
-       return BT_PLUGIN_TYPE_SINK;
-}
-
-const char *bt_plugin_lib_get_format_name(void)
+void ctf_text_exit(void)
 {
-       return plugin_name;
-}
-
-static
-int text_init(struct ctf_text *text, struct bt_object *params)
-{
-       int ret = 0;
-
-       if (!text || !params) {
-               ret = -1;
-               goto end;
-       }
-
-       text->opt_print_trace_default_fields = 1;
-       text->opt_print_delta_field = 1;
-end:
-       return ret;
-}
-
-struct bt_plugin *bt_plugin_lib_create(struct bt_object *params)
-{
-       int ret;
-       struct bt_plugin *plugin = NULL;
-       struct ctf_text *text = g_new0(struct ctf_text, 1);
-
-       /* Set default text output options */
-       ret = text_init(text, params);
-       if (ret) {
-               goto error;
-       }
-
-       plugin = bt_plugin_sink_create(plugin_name, text,
-               ctf_text_destroy, ctf_text_handle_notification);
-       if (!plugin) {
-               goto error;
-       }
-
-end:
-       return plugin;
-error:
-       if (text) {
-               g_free(text);
-       }
-       goto end;
+       printf("in ctf_text_exit\n");
 }
This page took 0.030261 seconds and 4 git commands to generate.