X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fir%2Fstream.c;h=18c9edfd96000e03b8e6bd65dd81dd4e0f6d4bb6;hb=0ce5791baa59e384c6702a89b66e2b1ae08d0c02;hp=80d13111c1a4ee18b310fb74e3f16cfb2b461077;hpb=d246b1115dbace6a7d67828cfd3fb1d5dc1c4f58;p=babeltrace.git diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index 80d13111..18c9edfd 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -617,6 +617,50 @@ end: return ret; } +struct bt_ctf_field *bt_ctf_stream_get_packet_header( + struct bt_ctf_stream *stream) +{ + struct bt_ctf_field *packet_header = NULL; + + if (!stream) { + goto end; + } + + packet_header = stream->packet_header; + if (packet_header) { + bt_ctf_field_get(packet_header); + } +end: + return packet_header; +} + +int bt_ctf_stream_set_packet_header(struct bt_ctf_stream *stream, + struct bt_ctf_field *field) +{ + int ret = 0; + struct bt_ctf_field_type *field_type = NULL; + + if (!stream || !field) { + ret = -1; + goto end; + } + + field_type = bt_ctf_field_get_type(field); + if (field_type != stream->trace->packet_header_type) { + ret = -1; + goto end; + } + + bt_ctf_field_get(field); + bt_ctf_field_put(stream->packet_header); + stream->packet_header = field; +end: + if (field_type) { + bt_ctf_field_type_put(field_type); + } + return ret; +} + int bt_ctf_stream_flush(struct bt_ctf_stream *stream) { int ret = 0;