X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Ftrace.c;h=fb897dabeea5e91ab804c9c1c4a06dcfde75dc21;hb=4ed90fb3c1b2f7912d65b905d960274ce3738e0d;hp=8d5f72705c5078b59cf848bfa60a897c293c0212;hpb=3487c9f3e9e3c1ab1e55488d1f81de56792ddbcf;p=babeltrace.git diff --git a/formats/ctf/ir/trace.c b/formats/ctf/ir/trace.c index 8d5f7270..fb897dab 100644 --- a/formats/ctf/ir/trace.c +++ b/formats/ctf/ir/trace.c @@ -159,7 +159,7 @@ struct bt_ctf_stream *bt_ctf_trace_create_stream(struct bt_ctf_trace *trace, if (stream_id < 0) { /* Try to assign a new stream id */ - if (bt_ctf_stream_class_set_id(stream->stream_class, + if (_bt_ctf_stream_class_set_id(stream->stream_class, trace->next_stream_id++)) { goto error; } @@ -259,7 +259,7 @@ error: int bt_ctf_trace_add_environment_field_integer(struct bt_ctf_trace *trace, const char *name, - int64_t value) + int64_t value) { struct environment_variable *var = NULL; int ret = 0; @@ -295,6 +295,95 @@ error: return ret; } +int bt_ctf_trace_get_environment_field_count(struct bt_ctf_trace *trace) +{ + int ret = 0; + + if (!trace) { + ret = -1; + goto end; + } + + ret = trace->environment->len; +end: + return ret; +} + +enum bt_environment_field_type +bt_ctf_trace_get_environment_field_type(struct bt_ctf_trace *trace, int index) +{ + struct environment_variable *var; + enum bt_environment_field_type type = BT_ENVIRONMENT_FIELD_TYPE_UNKNOWN; + + if (!trace || index < 0 || index >= trace->environment->len) { + goto end; + } + + var = g_ptr_array_index(trace->environment, index); + type = var->type; +end: + return type; +} + +const char * +bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace, + int index) +{ + struct environment_variable *var; + const char *ret = NULL; + + if (!trace || index < 0 || index >= trace->environment->len) { + goto end; + } + + var = g_ptr_array_index(trace->environment, index); + ret = var->name->str; +end: + return ret; +} + +const char * +bt_ctf_trace_get_environment_field_value_string(struct bt_ctf_trace *trace, + int index) +{ + struct environment_variable *var; + const char *ret = NULL; + + if (!trace || index < 0 || index >= trace->environment->len) { + goto end; + } + + var = g_ptr_array_index(trace->environment, index); + if (var->type != BT_ENVIRONMENT_FIELD_TYPE_STRING) { + goto end; + } + ret = var->value.string->str; +end: + return ret; +} + +int +bt_ctf_trace_get_environment_field_value_integer(struct bt_ctf_trace *trace, + int index, int64_t *value) +{ + struct environment_variable *var; + int ret = 0; + + if (!trace || !value || index < 0 || index >= trace->environment->len) { + ret = -1; + goto end; + } + + var = g_ptr_array_index(trace->environment, index); + if (var->type != BT_ENVIRONMENT_FIELD_TYPE_INTEGER) { + ret = -1; + goto end; + } + *value = var->value.integer; +end: + return ret; +} + int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace, struct bt_ctf_clock *clock) { @@ -478,6 +567,28 @@ end: return metadata; } +enum bt_ctf_byte_order bt_ctf_trace_get_byte_order(struct bt_ctf_trace *trace) +{ + enum bt_ctf_byte_order ret = BT_CTF_BYTE_ORDER_UNKNOWN; + + if (!trace) { + goto end; + } + + switch (trace->byte_order) { + case BIG_ENDIAN: + ret = BT_CTF_BYTE_ORDER_BIG_ENDIAN; + break; + case LITTLE_ENDIAN: + ret = BT_CTF_BYTE_ORDER_LITTLE_ENDIAN; + break; + default: + break; + } +end: + return ret; +} + int bt_ctf_trace_set_byte_order(struct bt_ctf_trace *trace, enum bt_ctf_byte_order byte_order) {