fix copytrace: set the byte order
[babeltrace.git] / plugins / libctfcopytrace / ctfcopytrace.c
index 4455dfb87132ce4705732c167cba2c9ac869cce6..9789e5c42df0e8c325afd7fb4847bf2c88f6e96c 100644 (file)
@@ -530,7 +530,8 @@ end:
 BT_HIDDEN
 struct bt_ctf_field *ctf_copy_packet_context(FILE *err,
                struct bt_ctf_packet *packet,
-               struct bt_ctf_stream *writer_stream)
+               struct bt_ctf_stream *writer_stream,
+               int skip_content_size)
 {
        enum bt_component_status ret;
        struct bt_ctf_field *packet_context = NULL, *writer_packet_context = NULL;
@@ -592,9 +593,9 @@ struct bt_ctf_field *ctf_copy_packet_context(FILE *err,
                                        __FILE__, __LINE__);
                        goto error;
                }
-               if (!strncmp(field_name, "content_size", strlen("content_size")) ||
-                               !strncmp(field_name, "packet_size",
-                                       strlen("packet_size"))) {
+               if (skip_content_size &&
+                               (!strncmp(field_name, "content_size", strlen("content_size")) ||
+                               !strncmp(field_name, "packet_size", strlen("packet_size")))) {
                        BT_PUT(field_type);
                        BT_PUT(field);
                        continue;
@@ -832,6 +833,7 @@ enum bt_component_status ctf_copy_trace(FILE *err, struct bt_ctf_trace *trace,
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
        int field_count, i, int_ret;
        struct bt_ctf_field_type *header_type = NULL;
+       enum bt_ctf_byte_order order;
 
        field_count = bt_ctf_trace_get_environment_field_count(trace);
        for (i = 0; i < field_count; i++) {
@@ -869,6 +871,20 @@ enum bt_component_status ctf_copy_trace(FILE *err, struct bt_ctf_trace *trace,
                }
        }
 
+       order = bt_ctf_trace_get_native_byte_order(trace);
+       if (order == BT_CTF_BYTE_ORDER_UNKNOWN) {
+               fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__);
+               ret = BT_COMPONENT_STATUS_ERROR;
+               goto end;
+       }
+
+       ret = bt_ctf_trace_set_native_byte_order(writer_trace, order);
+       if (ret) {
+               fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__);
+               ret = BT_COMPONENT_STATUS_ERROR;
+               goto end;
+       }
+
        header_type = bt_ctf_trace_get_packet_header_type(writer_trace);
        if (!header_type) {
                fprintf(err, "[error] %s in %s:%d\n", __func__, __FILE__, __LINE__);
This page took 0.025707 seconds and 4 git commands to generate.