Commit | Line | Data |
---|---|---|
335a2da5 | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
335a2da5 | 3 | * |
0235b0db | 4 | * Copyright 2019 Philippe Proulx <pproulx@efficios.com> |
335a2da5 PP |
5 | */ |
6 | ||
7 | #include <babeltrace2/babeltrace.h> | |
8 | ||
c7e1be4b SM |
9 | #include "common/assert.h" |
10 | ||
087cd0f5 | 11 | #include "ctf-meta-configure-ir-trace.hpp" |
c7e1be4b | 12 | #include "plugins/ctf/common/metadata/ctf-meta.hpp" |
335a2da5 | 13 | |
4164020e | 14 | int ctf_trace_class_configure_ir_trace(struct ctf_trace_class *tc, bt_trace *ir_trace) |
335a2da5 | 15 | { |
4164020e SM |
16 | int ret = 0; |
17 | uint64_t i; | |
18 | ||
19 | BT_ASSERT(tc); | |
20 | BT_ASSERT(ir_trace); | |
21 | ||
22 | if (tc->is_uuid_set) { | |
23 | bt_trace_set_uuid(ir_trace, tc->uuid); | |
24 | } | |
25 | ||
26 | for (i = 0; i < tc->env_entries->len; i++) { | |
27 | struct ctf_trace_class_env_entry *env_entry = | |
28 | ctf_trace_class_borrow_env_entry_by_index(tc, i); | |
29 | ||
30 | switch (env_entry->type) { | |
31 | case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT: | |
32 | ret = bt_trace_set_environment_entry_integer(ir_trace, env_entry->name->str, | |
33 | env_entry->value.i); | |
34 | break; | |
35 | case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR: | |
36 | ret = bt_trace_set_environment_entry_string(ir_trace, env_entry->name->str, | |
37 | env_entry->value.str->str); | |
38 | break; | |
39 | default: | |
40 | bt_common_abort(); | |
41 | } | |
42 | ||
43 | if (ret) { | |
44 | goto end; | |
45 | } | |
46 | } | |
335a2da5 PP |
47 | |
48 | end: | |
4164020e | 49 | return ret; |
335a2da5 | 50 | } |