2 * SPDX-License-Identifier: MIT
4 * Copyright EfficiOS, Inc.
7 #define BT_LOG_OUTPUT_LEVEL log_level
8 #define BT_LOG_TAG "COMMON/FORMAT-PLUGIN-COMP-CLS-NAME"
9 #include <logging/log.h>
11 #include "format-plugin-comp-cls-name.h"
13 #include <common/common.h>
17 const char *component_type_str(bt_component_class_type type
)
20 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
22 case BT_COMPONENT_CLASS_TYPE_SINK
:
24 case BT_COMPONENT_CLASS_TYPE_FILTER
:
31 gchar
*format_plugin_comp_cls_opt(const char *plugin_name
,
32 const char *comp_cls_name
, bt_component_class_type type
,
33 enum bt_common_color_when use_colors
)
36 GString
*shell_plugin_name
= NULL
;
37 GString
*shell_comp_cls_name
= NULL
;
39 struct bt_common_color_codes codes
;
41 str
= g_string_new(NULL
);
47 shell_plugin_name
= bt_common_shell_quote(plugin_name
, false);
48 if (!shell_plugin_name
) {
53 shell_comp_cls_name
= bt_common_shell_quote(comp_cls_name
, false);
54 if (!shell_comp_cls_name
) {
58 bt_common_color_get_codes(&codes
, use_colors
);
60 g_string_append_printf(str
, "'%s%s%s%s",
63 component_type_str(type
),
66 if (shell_plugin_name
) {
67 g_string_append_printf(str
, ".%s%s%s",
69 shell_plugin_name
->str
,
73 g_string_append_printf(str
, ".%s%s%s'",
75 shell_comp_cls_name
->str
,
79 if (shell_plugin_name
) {
80 g_string_free(shell_plugin_name
, TRUE
);
83 if (shell_comp_cls_name
) {
84 g_string_free(shell_comp_cls_name
, TRUE
);
88 ret
= g_string_free(str
, FALSE
);