2 * Copyright EfficiOS, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #define BT_LOG_OUTPUT_LEVEL log_level
24 #define BT_LOG_TAG "COMMON/FORMAT-PLUGIN-COMP-CLS-NAME"
25 #include <logging/log.h>
27 #include "format-plugin-comp-cls-name.h"
29 #include <common/common.h>
33 const char *component_type_str(bt_component_class_type type
)
36 case BT_COMPONENT_CLASS_TYPE_SOURCE
:
38 case BT_COMPONENT_CLASS_TYPE_SINK
:
40 case BT_COMPONENT_CLASS_TYPE_FILTER
:
47 gchar
*format_plugin_comp_cls_opt(const char *plugin_name
,
48 const char *comp_cls_name
, bt_component_class_type type
,
49 enum bt_common_color_when use_colors
)
52 GString
*shell_plugin_name
= NULL
;
53 GString
*shell_comp_cls_name
= NULL
;
55 struct bt_common_color_codes codes
;
57 str
= g_string_new(NULL
);
63 shell_plugin_name
= bt_common_shell_quote(plugin_name
, false);
64 if (!shell_plugin_name
) {
69 shell_comp_cls_name
= bt_common_shell_quote(comp_cls_name
, false);
70 if (!shell_comp_cls_name
) {
74 bt_common_color_get_codes(&codes
, use_colors
);
76 g_string_append_printf(str
, "'%s%s%s%s",
79 component_type_str(type
),
82 if (shell_plugin_name
) {
83 g_string_append_printf(str
, ".%s%s%s",
85 shell_plugin_name
->str
,
89 g_string_append_printf(str
, ".%s%s%s'",
91 shell_comp_cls_name
->str
,
95 if (shell_plugin_name
) {
96 g_string_free(shell_plugin_name
, TRUE
);
99 if (shell_comp_cls_name
) {
100 g_string_free(shell_comp_cls_name
, TRUE
);
104 ret
= g_string_free(str
, FALSE
);