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