Add stream packet header accessors
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 6 Jan 2015 22:17:57 +0000 (17:17 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 6 Jan 2015 22:18:45 +0000 (17:18 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/stream.c
include/babeltrace/ctf-ir/stream.h

index 80d13111c1a4ee18b310fb74e3f16cfb2b461077..18c9edfd96000e03b8e6bd65dd81dd4e0f6d4bb6 100644 (file)
@@ -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;
index 9cf025547a8d446ba06b7a15c62801d993a104e9..73fc5369d324b83ac6bf68d724e18cdf86d067a9 100644 (file)
@@ -137,6 +137,31 @@ extern int bt_ctf_stream_set_event_context(
                struct bt_ctf_stream *stream,
                struct bt_ctf_field *event_context);
 
+/*
+ * bt_ctf_stream_get_packet_header: get a stream's packet header.
+ *
+ * @param stream Stream instance.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_stream_get_packet_header(
+               struct bt_ctf_stream *stream);
+
+/*
+ * bt_ctf_stream_set_packet_header: set a stream's packet header.
+ *
+ * The packet header's type must match the trace's packet header
+ * type.
+ *
+ * @param stream Stream instance.
+ * @param packet_header Packet header instance.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern int bt_ctf_stream_set_packet_header(
+               struct bt_ctf_stream *stream,
+               struct bt_ctf_field *packet_header);
+
 /*
  * bt_ctf_stream_flush: flush a stream.
  *
This page took 0.026087 seconds and 4 git commands to generate.