lib: create_packet_message(): make assertion message less convoluted
[babeltrace.git] / cli / babeltrace-cfg.c
CommitLineData
c42c79ea
PP
1/*
2 * Babeltrace trace converter - parameter parsing
3 *
4 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
1670bffd 25#include <babeltrace/common-internal.h>
05e21286 26#include <babeltrace/babeltrace.h>
c42c79ea
PP
27#include <glib.h>
28#include "babeltrace-cfg.h"
29
c42c79ea 30static
9009cc24 31void destroy_gstring(void *data)
1670bffd
PP
32{
33 g_string_free(data, TRUE);
34}
35
c42c79ea
PP
36/*
37 * Extracts the various paths from the string arg, delimited by ':',
5a3ee633 38 * and appends them to the array value object plugin_paths.
c42c79ea 39 */
601b0d3c 40int bt_config_append_plugin_paths(
b19ff26f 41 bt_value *plugin_paths, const char *arg)
c42c79ea 42{
601b0d3c 43 int ret = 0;
1670bffd 44 GPtrArray *dirs = g_ptr_array_new_with_free_func(destroy_gstring);
1670bffd 45 size_t i;
c42c79ea 46
1670bffd 47 if (!dirs) {
601b0d3c 48 ret = -1;
1670bffd
PP
49 goto end;
50 }
c42c79ea 51
1670bffd
PP
52 ret = bt_common_append_plugin_path_dirs(arg, dirs);
53 if (ret) {
601b0d3c 54 ret = -1;
1670bffd
PP
55 goto end;
56 }
c42c79ea 57
1670bffd
PP
58 for (i = 0; i < dirs->len; i++) {
59 GString *dir = g_ptr_array_index(dirs, i);
c42c79ea 60
05e21286 61 ret = bt_value_array_append_string_element(
da91b29a 62 plugin_paths, dir->str);
601b0d3c
PP
63 if (ret != BT_VALUE_STATUS_OK) {
64 ret = -1;
65 goto end;
74aa915d 66 }
c42c79ea
PP
67 }
68
1670bffd
PP
69end:
70 g_ptr_array_free(dirs, TRUE);
601b0d3c 71 return ret;
c42c79ea
PP
72}
73
9009cc24 74void bt_config_connection_destroy(struct bt_config_connection *connection)
c42c79ea 75{
9009cc24
PP
76 if (!connection) {
77 return;
78 }
c42c79ea 79
9009cc24
PP
80 if (connection->upstream_comp_name) {
81 g_string_free(connection->upstream_comp_name, TRUE);
6e1bc0df 82 }
db0f160a 83
9009cc24
PP
84 if (connection->downstream_comp_name) {
85 g_string_free(connection->downstream_comp_name, TRUE);
c42c79ea
PP
86 }
87
9009cc24
PP
88 if (connection->upstream_port_glob) {
89 g_string_free(connection->upstream_port_glob, TRUE);
290725f7
PP
90 }
91
9009cc24
PP
92 if (connection->downstream_port_glob) {
93 g_string_free(connection->downstream_port_glob, TRUE);
290725f7
PP
94 }
95
9009cc24
PP
96 if (connection->arg) {
97 g_string_free(connection->arg, TRUE);
290725f7
PP
98 }
99
9009cc24 100 g_free(connection);
c42c79ea 101}
This page took 0.061268 seconds and 4 git commands to generate.