| 1 | /* |
| 2 | * Copyright 2019 - Philippe Proulx <pproulx@efficios.com> |
| 3 | * |
| 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: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | */ |
| 14 | |
| 15 | #include <babeltrace2/babeltrace.h> |
| 16 | |
| 17 | #include "ctf-meta-configure-ir-trace.h" |
| 18 | |
| 19 | BT_HIDDEN |
| 20 | int ctf_trace_class_configure_ir_trace(struct ctf_trace_class *tc, |
| 21 | bt_trace *ir_trace) |
| 22 | { |
| 23 | int ret = 0; |
| 24 | uint64_t i; |
| 25 | |
| 26 | BT_ASSERT(tc); |
| 27 | BT_ASSERT(ir_trace); |
| 28 | |
| 29 | if (tc->is_uuid_set) { |
| 30 | bt_trace_set_uuid(ir_trace, tc->uuid); |
| 31 | } |
| 32 | |
| 33 | for (i = 0; i < tc->env_entries->len; i++) { |
| 34 | struct ctf_trace_class_env_entry *env_entry = |
| 35 | ctf_trace_class_borrow_env_entry_by_index(tc, i); |
| 36 | |
| 37 | switch (env_entry->type) { |
| 38 | case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT: |
| 39 | ret = bt_trace_set_environment_entry_integer( |
| 40 | ir_trace, env_entry->name->str, |
| 41 | env_entry->value.i); |
| 42 | break; |
| 43 | case CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR: |
| 44 | ret = bt_trace_set_environment_entry_string( |
| 45 | ir_trace, env_entry->name->str, |
| 46 | env_entry->value.str->str); |
| 47 | break; |
| 48 | default: |
| 49 | abort(); |
| 50 | } |
| 51 | |
| 52 | if (ret) { |
| 53 | goto end; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | end: |
| 58 | return ret; |
| 59 | } |