From 98a4cbefe4c162067144bf5e1b7341c8dd8767bb Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 13 Jan 2017 15:24:27 -0500 Subject: [PATCH] ir: stream: add bt_ctf_stream_is_writer() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This function indicates whether or not the stream is in "CTF writer mode", that is, its trace parent was created by a CTF writer object and it has an open file descriptor. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/stream.c | 14 ++++++++++++++ include/babeltrace/ctf-writer/stream.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index d4dbc447..5e9e1337 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -1000,3 +1000,17 @@ const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream) end: return name; } + +int bt_ctf_stream_is_writer(struct bt_ctf_stream *stream) +{ + int ret = -1; + + if (!stream) { + goto end; + } + + ret = (stream->pos.fd >= 0); + +end: + return ret; +} diff --git a/include/babeltrace/ctf-writer/stream.h b/include/babeltrace/ctf-writer/stream.h index f8ad7b83..56b6bff8 100644 --- a/include/babeltrace/ctf-writer/stream.h +++ b/include/babeltrace/ctf-writer/stream.h @@ -152,6 +152,8 @@ extern int bt_ctf_stream_set_packet_context( */ extern int bt_ctf_stream_flush(struct bt_ctf_stream *stream); +extern int bt_ctf_stream_is_writer(struct bt_ctf_stream *stream); + /* * bt_ctf_stream_get and bt_ctf_stream_put: increment and decrement the * stream's reference count. -- 2.34.1