lib: rename include dir to babeltrace2
[babeltrace.git] / plugins / text / pretty / pretty.c
index ece1f1e6e46db945709a8ce14651c01e1f2ed8d6..7c548391ab79e4cecf8d33a0fccd47715b011cf6 100644 (file)
@@ -1,8 +1,4 @@
 /*
- * pretty.c
- *
- * Babeltrace CTF Text Output Plugin
- *
  * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * SOFTWARE.
  */
 
-#include <babeltrace/plugin/plugin-dev.h>
-#include <babeltrace/graph/component.h>
-#include <babeltrace/graph/private-component.h>
-#include <babeltrace/graph/private-component-sink.h>
-#include <babeltrace/graph/component-sink.h>
-#include <babeltrace/graph/port.h>
-#include <babeltrace/graph/private-port.h>
-#include <babeltrace/graph/connection.h>
-#include <babeltrace/graph/private-connection.h>
-#include <babeltrace/graph/notification.h>
-#include <babeltrace/graph/notification-iterator.h>
-#include <babeltrace/graph/notification-event.h>
-#include <babeltrace/values.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/common-internal.h>
+#define BT_LOG_TAG "PLUGIN-TEXT-PRETTY-SINK"
+#include "logging.h"
+
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/common-internal.h>
 #include <plugins-common.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <glib.h>
-#include <assert.h>
+#include <babeltrace2/assert-internal.h>
 
 #include "pretty.h"
 
+GQuark stream_packet_context_quarks[STREAM_PACKET_CONTEXT_QUARKS_LEN];
+
 static
 const char *plugin_options[] = {
        "color",
@@ -76,11 +65,22 @@ const char *plugin_options[] = {
        "field-callsite",
 };
 
+static
+const char * const in_port_name = "in";
+
 static
 void destroy_pretty_data(struct pretty_component *pretty)
 {
-       bt_put(pretty->input_iterator);
-       (void) g_string_free(pretty->string, TRUE);
+       bt_self_component_port_input_message_iterator_put_ref(pretty->iterator);
+
+       if (pretty->string) {
+               (void) g_string_free(pretty->string, TRUE);
+       }
+
+       if (pretty->tmp_string) {
+               (void) g_string_free(pretty->tmp_string, TRUE);
+       }
+
        if (pretty->out != stdout) {
                int ret;
 
@@ -106,6 +106,10 @@ struct pretty_component *create_pretty(void)
        if (!pretty->string) {
                goto error;
        }
+       pretty->tmp_string = g_string_new("");
+       if (!pretty->tmp_string) {
+               goto error;
+       }
 end:
        return pretty;
 
@@ -115,118 +119,137 @@ error:
 }
 
 BT_HIDDEN
-void pretty_finalize(struct bt_private_component *component)
+void pretty_finalize(bt_self_component_sink *comp)
 {
-       void *data = bt_private_component_get_user_data(component);
-
-       destroy_pretty_data(data);
+       destroy_pretty_data(
+               bt_self_component_get_data(
+                       bt_self_component_sink_as_self_component(comp)));
 }
 
 static
-enum bt_component_status handle_notification(struct pretty_component *pretty,
-               struct bt_notification *notification)
+bt_self_component_status handle_message(
+               struct pretty_component *pretty,
+               const bt_message *message)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       bt_self_component_status ret = BT_SELF_COMPONENT_STATUS_OK;
 
-       assert(pretty);
+       BT_ASSERT(pretty);
 
-       if (bt_notification_get_type(notification) == BT_NOTIFICATION_TYPE_EVENT) {
-               ret = pretty_print_event(pretty, notification);
+       switch (bt_message_get_type(message)) {
+       case BT_MESSAGE_TYPE_EVENT:
+               if (pretty_print_event(pretty, message)) {
+                       ret = BT_SELF_COMPONENT_STATUS_ERROR;
+               }
+               break;
+       case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
+               BT_LOGD_STR("Message iterator inactivity message.");
+               break;
+       case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
+       case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
+               if (pretty_print_discarded_items(pretty, message)) {
+                       ret = BT_SELF_COMPONENT_STATUS_ERROR;
+               }
+               break;
+       default:
+               break;
        }
 
        return ret;
 }
 
 BT_HIDDEN
-void pretty_port_connected(
-               struct bt_private_component *component,
-               struct bt_private_port *self_port,
-               struct bt_port *other_port)
+bt_self_component_status pretty_graph_is_configured(
+               bt_self_component_sink *comp)
 {
-       struct bt_private_connection *connection;
+       bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
        struct pretty_component *pretty;
-       static const enum bt_notification_type notif_types[] = {
-               BT_NOTIFICATION_TYPE_EVENT,
-               BT_NOTIFICATION_TYPE_SENTINEL,
-       };
-
-       pretty = bt_private_component_get_user_data(component);
-       assert(pretty);
-       assert(!pretty->input_iterator);
-       connection = bt_private_port_get_private_connection(self_port);
-       assert(connection);
-       pretty->input_iterator =
-               bt_private_connection_create_notification_iterator(connection,
-                       notif_types);
 
-       if (!pretty->input_iterator) {
-               pretty->error = true;
+       pretty = bt_self_component_get_data(
+                       bt_self_component_sink_as_self_component(comp));
+       BT_ASSERT(pretty);
+       BT_ASSERT(!pretty->iterator);
+       pretty->iterator = bt_self_component_port_input_message_iterator_create(
+               bt_self_component_sink_borrow_input_port_by_name(comp,
+                       in_port_name));
+       if (!pretty->iterator) {
+               status = BT_SELF_COMPONENT_STATUS_NOMEM;
        }
 
-       bt_put(connection);
+       return status;
 }
 
 BT_HIDDEN
-enum bt_component_status pretty_consume(struct bt_private_component *component)
+bt_self_component_status pretty_consume(
+               bt_self_component_sink *comp)
 {
-       enum bt_component_status ret;
-       struct bt_notification *notification = NULL;
-       struct bt_notification_iterator *it;
-       struct pretty_component *pretty =
-               bt_private_component_get_user_data(component);
-       enum bt_notification_iterator_status it_ret;
-
-       if (unlikely(pretty->error)) {
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
-       }
-
-       it = pretty->input_iterator;
-       it_ret = bt_notification_iterator_next(it);
+       bt_self_component_status ret;
+       bt_message_array_const msgs;
+       bt_self_component_port_input_message_iterator *it;
+       struct pretty_component *pretty = bt_self_component_get_data(
+               bt_self_component_sink_as_self_component(comp));
+       bt_message_iterator_status it_ret;
+       uint64_t count = 0;
+       uint64_t i = 0;
+
+       it = pretty->iterator;
+       it_ret = bt_self_component_port_input_message_iterator_next(it,
+               &msgs, &count);
 
        switch (it_ret) {
-       case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
-               ret = BT_COMPONENT_STATUS_ERROR;
+       case BT_MESSAGE_ITERATOR_STATUS_OK:
+               break;
+       case BT_MESSAGE_ITERATOR_STATUS_NOMEM:
+               ret = BT_SELF_COMPONENT_STATUS_NOMEM;
                goto end;
-       case BT_NOTIFICATION_ITERATOR_STATUS_END:
-               ret = BT_COMPONENT_STATUS_END;
-               BT_PUT(pretty->input_iterator);
+       case BT_MESSAGE_ITERATOR_STATUS_AGAIN:
+               ret = BT_SELF_COMPONENT_STATUS_AGAIN;
                goto end;
-       case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
-               ret = BT_COMPONENT_STATUS_AGAIN;
+       case BT_MESSAGE_ITERATOR_STATUS_END:
+               ret = BT_SELF_COMPONENT_STATUS_END;
+               BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_PUT_REF_AND_RESET(
+                       pretty->iterator);
                goto end;
-       case BT_NOTIFICATION_ITERATOR_STATUS_OK:
-               break;
        default:
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = BT_SELF_COMPONENT_STATUS_ERROR;
                goto end;
        }
 
-       notification = bt_notification_iterator_get_notification(it);
-       assert(notification);
-       ret = handle_notification(pretty, notification);
+       BT_ASSERT(it_ret == BT_MESSAGE_ITERATOR_STATUS_OK);
+
+       for (i = 0; i < count; i++) {
+               ret = handle_message(pretty, msgs[i]);
+               if (ret) {
+                       goto end;
+               }
+
+               bt_message_put_ref(msgs[i]);
+       }
 
 end:
-       bt_put(notification);
+       for (; i < count; i++) {
+               bt_message_put_ref(msgs[i]);
+       }
+
        return ret;
 }
 
 static
-enum bt_component_status add_params_to_map(struct bt_value *plugin_opt_map)
+int add_params_to_map(bt_value *plugin_opt_map)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       int ret = 0;
        unsigned int i;
 
        for (i = 0; i < BT_ARRAY_SIZE(plugin_options); i++) {
                const char *key = plugin_options[i];
-               enum bt_value_status status;
+               bt_value_status status;
 
-               status = bt_value_map_insert(plugin_opt_map, key, bt_value_null);
+               status = bt_value_map_insert_entry(plugin_opt_map, key,
+                       bt_value_null);
                switch (status) {
                case BT_VALUE_STATUS_OK:
                        break;
                default:
-                       ret = BT_COMPONENT_STATUS_ERROR;
+                       ret = -1;
                        goto end;
                }
        }
@@ -235,12 +258,13 @@ end:
 }
 
 static
-bt_bool check_param_exists(const char *key, struct bt_value *object, void *data)
+bt_bool check_param_exists(const char *key, const bt_value *object,
+               void *data)
 {
        struct pretty_component *pretty = data;
-       struct bt_value *plugin_opt_map = pretty->plugin_opt_map;
 
-       if (!bt_value_map_get(plugin_opt_map, key)) {
+       if (!bt_value_map_has_entry(pretty->plugin_opt_map,
+                                   key)) {
                fprintf(pretty->err,
                        "[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
        }
@@ -248,66 +272,44 @@ bt_bool check_param_exists(const char *key, struct bt_value *object, void *data)
 }
 
 static
-enum bt_component_status apply_one_string(const char *key,
-               struct bt_value *params,
-               char **option)
+void apply_one_string(const char *key, const bt_value *params, char **option)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       struct bt_value *value = NULL;
-       enum bt_value_status status;
+       const bt_value *value = NULL;
        const char *str;
 
-       value = bt_value_map_get(params, key);
+       value = bt_value_map_borrow_entry_value_const(params, key);
        if (!value) {
                goto end;
        }
        if (bt_value_is_null(value)) {
                goto end;
        }
-       status = bt_value_string_get(value, &str);
-       switch (status) {
-       case BT_VALUE_STATUS_OK:
-               break;
-       default:
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
-       }
+       str = bt_value_string_get(value);
        *option = g_strdup(str);
+
 end:
-       bt_put(value);
-       return ret;
+       return;
 }
 
 static
-enum bt_component_status apply_one_bool(const char *key,
-               struct bt_value *params,
-               bool *option,
+void apply_one_bool(const char *key, const bt_value *params, bool *option,
                bool *found)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       struct bt_value *value = NULL;
-       enum bt_value_status status;
+       const bt_value *value = NULL;
        bt_bool bool_val;
 
-       value = bt_value_map_get(params, key);
+       value = bt_value_map_borrow_entry_value_const(params, key);
        if (!value) {
                goto end;
        }
-       status = bt_value_bool_get(value, &bool_val);
-       switch (status) {
-       case BT_VALUE_STATUS_OK:
-               break;
-       default:
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
-       }
+       bool_val = bt_value_bool_get(value);
        *option = (bool) bool_val;
        if (found) {
                *found = true;
        }
+
 end:
-       bt_put(value);
-       return ret;
+       return;
 }
 
 static
@@ -318,9 +320,9 @@ void warn_wrong_color_param(struct pretty_component *pretty)
 }
 
 static
-enum bt_component_status open_output_file(struct pretty_component *pretty)
+int open_output_file(struct pretty_component *pretty)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+       int ret = 0;
 
        if (!pretty->options.output_path) {
                goto end;
@@ -334,123 +336,96 @@ enum bt_component_status open_output_file(struct pretty_component *pretty)
        goto end;
 
 error:
-       ret = BT_COMPONENT_STATUS_ERROR;
+       ret = -1;
+
 end:
        return ret;
 }
 
 static
-enum bt_component_status apply_params(struct pretty_component *pretty,
-               struct bt_value *params)
+int apply_params(struct pretty_component *pretty, const bt_value *params)
 {
-       enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       enum bt_value_status status;
+       int ret = 0;
+       bt_value_status status;
        bool value, found;
        char *str = NULL;
 
        pretty->plugin_opt_map = bt_value_map_create();
        if (!pretty->plugin_opt_map) {
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = -1;
                goto end;
        }
        ret = add_params_to_map(pretty->plugin_opt_map);
-       if (ret != BT_COMPONENT_STATUS_OK) {
+       if (ret) {
                goto end;
        }
        /* Report unknown parameters. */
-       status = bt_value_map_foreach(params, check_param_exists, pretty);
+       status = bt_value_map_foreach_entry_const(params,
+               check_param_exists, pretty);
        switch (status) {
        case BT_VALUE_STATUS_OK:
                break;
        default:
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = -1;
                goto end;
        }
        /* Known parameters. */
        pretty->options.color = PRETTY_COLOR_OPT_AUTO;
-       if (bt_value_map_has_key(params, "color")) {
-               struct bt_value *color_value;
+       if (bt_value_map_has_entry(params, "color")) {
+               const bt_value *color_value;
                const char *color;
 
-               color_value = bt_value_map_get(params, "color");
+               color_value = bt_value_map_borrow_entry_value_const(params,
+                       "color");
                if (!color_value) {
                        goto end;
                }
 
-               status = bt_value_string_get(color_value, &color);
-               if (status) {
-                       warn_wrong_color_param(pretty);
+               color = bt_value_string_get(color_value);
+
+               if (strcmp(color, "never") == 0) {
+                       pretty->options.color = PRETTY_COLOR_OPT_NEVER;
+               } else if (strcmp(color, "auto") == 0) {
+                       pretty->options.color = PRETTY_COLOR_OPT_AUTO;
+               } else if (strcmp(color, "always") == 0) {
+                       pretty->options.color = PRETTY_COLOR_OPT_ALWAYS;
                } else {
-                       if (strcmp(color, "never") == 0) {
-                               pretty->options.color = PRETTY_COLOR_OPT_NEVER;
-                       } else if (strcmp(color, "auto") == 0) {
-                               pretty->options.color = PRETTY_COLOR_OPT_AUTO;
-                       } else if (strcmp(color, "always") == 0) {
-                               pretty->options.color = PRETTY_COLOR_OPT_ALWAYS;
-                       } else {
-                               warn_wrong_color_param(pretty);
-                       }
+                       warn_wrong_color_param(pretty);
                }
-
-               bt_put(color_value);
        }
 
-       ret = apply_one_string("path", params, &pretty->options.output_path);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_string("path", params, &pretty->options.output_path);
        ret = open_output_file(pretty);
-       if (ret != BT_COMPONENT_STATUS_OK) {
+       if (ret) {
                goto end;
        }
 
        value = false;          /* Default. */
-       ret = apply_one_bool("no-delta", params, &value, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("no-delta", params, &value, NULL);
        pretty->options.print_delta_field = !value;     /* Reverse logic. */
 
        value = false;          /* Default. */
-       ret = apply_one_bool("clock-cycles", params, &value, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("clock-cycles", params, &value, NULL);
        pretty->options.print_timestamp_cycles = value;
 
        value = false;          /* Default. */
-       ret = apply_one_bool("clock-seconds", params, &value, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("clock-seconds", params, &value, NULL);
        pretty->options.clock_seconds = value;
 
        value = false;          /* Default. */
-       ret = apply_one_bool("clock-date", params, &value, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("clock-date", params, &value, NULL);
        pretty->options.clock_date = value;
 
        value = false;          /* Default. */
-       ret = apply_one_bool("clock-gmt", params, &value, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("clock-gmt", params, &value, NULL);
        pretty->options.clock_gmt = value;
 
        value = false;          /* Default. */
-       ret = apply_one_bool("verbose", params, &value, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("verbose", params, &value, NULL);
        pretty->options.verbose = value;
 
        /* Names. */
-       ret = apply_one_string("name-default", params, &str);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_string("name-default", params, &str);
        if (!str) {
                pretty->options.name_default = PRETTY_DEFAULT_UNSET;
        } else if (!strcmp(str, "show")) {
@@ -458,7 +433,7 @@ enum bt_component_status apply_params(struct pretty_component *pretty,
        } else if (!strcmp(str, "hide")) {
                pretty->options.name_default = PRETTY_DEFAULT_HIDE;
        } else {
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = -1;
                goto end;
        }
        g_free(str);
@@ -484,55 +459,40 @@ enum bt_component_status apply_params(struct pretty_component *pretty,
                pretty->options.print_scope_field_names = false;
                break;
        default:
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = -1;
                goto end;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("name-payload", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("name-payload", params, &value, &found);
        if (found) {
                pretty->options.print_payload_field_names = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("name-context", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("name-context", params, &value, &found);
        if (found) {
                pretty->options.print_context_field_names = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("name-header", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("name-header", params, &value, &found);
        if (found) {
                pretty->options.print_header_field_names = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("name-scope", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("name-scope", params, &value, &found);
        if (found) {
                pretty->options.print_scope_field_names = value;
        }
 
        /* Fields. */
-       ret = apply_one_string("field-default", params, &str);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_string("field-default", params, &str);
        if (!str) {
                pretty->options.field_default = PRETTY_DEFAULT_UNSET;
        } else if (!strcmp(str, "show")) {
@@ -540,7 +500,7 @@ enum bt_component_status apply_params(struct pretty_component *pretty,
        } else if (!strcmp(str, "hide")) {
                pretty->options.field_default = PRETTY_DEFAULT_HIDE;
        } else {
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = -1;
                goto end;
        }
        g_free(str);
@@ -578,92 +538,68 @@ enum bt_component_status apply_params(struct pretty_component *pretty,
                pretty->options.print_callsite_field = false;
                break;
        default:
-               ret = BT_COMPONENT_STATUS_ERROR;
+               ret = -1;
                goto end;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-trace", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-trace", params, &value, &found);
        if (found) {
                pretty->options.print_trace_field = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-trace:hostname", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-trace:hostname", params, &value, &found);
        if (found) {
                pretty->options.print_trace_hostname_field = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-trace:domain", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-trace:domain", params, &value, &found);
        if (found) {
                pretty->options.print_trace_domain_field = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-trace:procname", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-trace:procname", params, &value, &found);
        if (found) {
                pretty->options.print_trace_procname_field = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-trace:vpid", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-trace:vpid", params, &value, &found);
        if (found) {
                pretty->options.print_trace_vpid_field = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-loglevel", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-loglevel", params, &value, &found);
        if (found) {
                pretty->options.print_loglevel_field = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-emf", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-emf", params, &value, &found);
        if (found) {
                pretty->options.print_emf_field = value;
        }
 
        value = false;
        found = false;
-       ret = apply_one_bool("field-callsite", params, &value, &found);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto end;
-       }
+       apply_one_bool("field-callsite", params, &value, &found);
        if (found) {
                pretty->options.print_callsite_field = value;
        }
 
 end:
-       bt_put(pretty->plugin_opt_map);
+       bt_value_put_ref(pretty->plugin_opt_map);
        pretty->plugin_opt_map = NULL;
        g_free(str);
        return ret;
@@ -706,29 +642,25 @@ void init_stream_packet_context_quarks(void)
 }
 
 BT_HIDDEN
-enum bt_component_status pretty_init(
-               struct bt_private_component *component,
-               struct bt_value *params,
+bt_self_component_status pretty_init(
+               bt_self_component_sink *comp,
+               const bt_value *params,
                UNUSED_VAR void *init_method_data)
 {
-       enum bt_component_status ret;
+       bt_self_component_status ret;
        struct pretty_component *pretty = create_pretty();
-       void *priv_port;
 
        if (!pretty) {
-               ret = BT_COMPONENT_STATUS_NOMEM;
+               ret = BT_SELF_COMPONENT_STATUS_NOMEM;
                goto end;
        }
 
-       priv_port = bt_private_component_sink_add_input_private_port(component,
-               "in", NULL);
-       if (!priv_port) {
-               ret = BT_COMPONENT_STATUS_NOMEM;
+       ret = bt_self_component_sink_add_input_port(comp, in_port_name,
+               NULL, NULL);
+       if (ret != BT_SELF_COMPONENT_STATUS_OK) {
                goto end;
        }
 
-       bt_put(priv_port);
-
        pretty->out = stdout;
        pretty->err = stderr;
 
@@ -738,21 +670,19 @@ enum bt_component_status pretty_init(
        pretty->delta_real_timestamp = -1ULL;
        pretty->last_real_timestamp = -1ULL;
 
-       ret = apply_params(pretty, params);
-       if (ret != BT_COMPONENT_STATUS_OK) {
+       if (apply_params(pretty, params)) {
+               ret = BT_SELF_COMPONENT_STATUS_ERROR;
                goto error;
        }
 
        set_use_colors(pretty);
-       ret = bt_private_component_set_user_data(component, pretty);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               goto error;
-       }
-
+       bt_self_component_set_data(
+               bt_self_component_sink_as_self_component(comp), pretty);
        init_stream_packet_context_quarks();
 
 end:
        return ret;
+
 error:
        destroy_pretty_data(pretty);
        return ret;
This page took 0.032749 seconds and 4 git commands to generate.