BT_HIDDEN int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class) { struct bt_value *obj = NULL; int64_t ret = 0; if (!event_class) { ret = -1; goto end; } obj = bt_ctf_attributes_get_field_value(event_class->attributes, BT_CTF_EVENT_CLASS_ATTR_ID_INDEX); if (!obj) { goto end; } if (bt_value_integer_get(obj, &ret)) { ret = -1; } if (ret < 0) { /* means ID is not set */ ret = -1; goto end; } end: BT_PUT(obj); return ret; }
struct bt_value *bt_ctf_trace_get_environment_field_value( struct bt_ctf_trace *trace, int index) { struct bt_value *ret = NULL; if (!trace) { goto end; } ret = bt_ctf_attributes_get_field_value(trace->environment, index); end: return ret; }
BT_HIDDEN struct bt_value * bt_ctf_event_class_get_attribute_value(struct bt_ctf_event_class *event_class, int index) { struct bt_value *ret; if (!event_class) { ret = NULL; goto end; } ret = bt_ctf_attributes_get_field_value(event_class->attributes, index); end: return ret; }
BT_HIDDEN int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class, uint32_t id) { int ret = 0; struct bt_value *obj = NULL; struct bt_ctf_stream_class *stream_class = NULL; if (!event_class) { ret = -1; goto end; } stream_class = bt_ctf_event_class_get_stream_class(event_class); if (stream_class) { /* * We don't allow changing the id if the event class has already * been added to a stream class. */ ret = -1; goto end; } obj = bt_ctf_attributes_get_field_value(event_class->attributes, BT_CTF_EVENT_CLASS_ATTR_ID_INDEX); if (!obj) { goto end; } if (bt_value_integer_set(obj, id)) { ret = -1; goto end; } end: BT_PUT(obj); BT_PUT(stream_class); return ret; }
BT_HIDDEN const char *bt_ctf_event_class_get_name(struct bt_ctf_event_class *event_class) { struct bt_value *obj = NULL; const char *name = NULL; if (!event_class) { goto end; } obj = bt_ctf_attributes_get_field_value(event_class->attributes, BT_CTF_EVENT_CLASS_ATTR_NAME_INDEX); if (!obj) { goto end; } if (bt_value_string_get(obj, &name)) { name = NULL; } end: BT_PUT(obj); return name; }
static void append_env_metadata(struct bt_ctf_trace *trace, struct metadata_context *context) { int i; int env_size; env_size = bt_ctf_attributes_get_count(trace->environment); if (env_size <= 0) { return; } g_string_append(context->string, "env {\n"); for (i = 0; i < env_size; ++i) { struct bt_value *env_field_value_obj = NULL; const char *entry_name; entry_name = bt_ctf_attributes_get_field_name( trace->environment, i); env_field_value_obj = bt_ctf_attributes_get_field_value( trace->environment, i); if (!entry_name || !env_field_value_obj) { goto loop_next; } switch (bt_value_get_type(env_field_value_obj)) { case BT_VALUE_TYPE_INTEGER: { int ret; int64_t int_value; ret = bt_value_integer_get(env_field_value_obj, &int_value); if (ret) { goto loop_next; } g_string_append_printf(context->string, "\t%s = %" PRId64 ";\n", entry_name, int_value); break; } case BT_VALUE_TYPE_STRING: { int ret; const char *str_value; char *escaped_str = NULL; ret = bt_value_string_get(env_field_value_obj, &str_value); if (ret) { goto loop_next; } escaped_str = g_strescape(str_value, NULL); if (!escaped_str) { goto loop_next; } g_string_append_printf(context->string, "\t%s = \"%s\";\n", entry_name, escaped_str); free(escaped_str); break; } default: goto loop_next; } loop_next: BT_PUT(env_field_value_obj); } g_string_append(context->string, "};\n\n"); }