Optional file pointer to metadata
[babeltrace.git] / formats / ctf-text / ctf-text.c
index 1500d735c18c437be2fc9c0744498ce9ffd222e8..f1c1f037a1e979d5301650bae1b39f805a9b44de 100644 (file)
@@ -3,7 +3,9 @@
  *
  * CTF Text Format registration.
  *
- * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
+ *
+ * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -19,7 +21,7 @@
 #include <babeltrace/format.h>
 #include <babeltrace/ctf-text/types.h>
 #include <babeltrace/ctf/metadata.h>
-#include <babeltrace/babeltrace.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <inttypes.h>
 #include <uuid/uuid.h>
 #include <sys/mman.h>
@@ -32,7 +34,9 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-struct trace_descriptor *ctf_text_open_trace(const char *path, int flags);
+struct trace_descriptor *ctf_text_open_trace(const char *path, int flags,
+               void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
+                       int whence), FILE *metadata_fp);
 void ctf_text_close_trace(struct trace_descriptor *descriptor);
 
 static
@@ -99,36 +103,11 @@ int ctf_text_write_event(struct stream_pos *ppos,
        struct ctf_stream_class *stream_class = stream->stream_class;
        int field_nr_saved;
        struct ctf_event *event_class;
-       struct ctf_file_event *event;
-       uint64_t id = 0;
+       struct ctf_stream_event *event;
+       uint64_t id;
        int ret;
 
-       /* print event header */
-       if (stream->stream_event_header) {
-               struct definition_integer *integer_definition;
-               struct definition *variant;
-
-               /* lookup event id */
-               integer_definition = lookup_integer(&stream->stream_event_header->p, "id", FALSE);
-               if (integer_definition) {
-                       id = integer_definition->value._unsigned;
-               } else {
-                       struct definition_enum *enum_definition;
-
-                       enum_definition = lookup_enum(&stream->stream_event_header->p, "id", FALSE);
-                       if (enum_definition) {
-                               id = enum_definition->integer->value._unsigned;
-                       }
-               }
-
-               variant = lookup_variant(&stream->stream_event_header->p, "v");
-               if (variant) {
-                       integer_definition = lookup_integer(variant, "id", FALSE);
-                       if (integer_definition) {
-                               id = integer_definition->value._unsigned;
-                       }
-               }
-       }
+       id = stream->event_id;
 
        if (id >= stream_class->events_by_id->len) {
                fprintf(stdout, "[error] Event id %" PRIu64 " is outside range.\n", id);
@@ -145,7 +124,7 @@ int ctf_text_write_event(struct stream_pos *ppos,
                return -EINVAL;
        }
 
-       if (stream->timestamp) {
+       if (stream->has_timestamp) {
                if (pos->print_names)
                        fprintf(pos->fp, "timestamp = ");
                else
@@ -248,7 +227,9 @@ error:
 }
 
 
-struct trace_descriptor *ctf_text_open_trace(const char *path, int flags)
+struct trace_descriptor *ctf_text_open_trace(const char *path, int flags,
+               void (*move_pos_slow)(struct ctf_stream_pos *pos, size_t offset,
+                       int whence), FILE *metadata_fp)
 {
        struct ctf_text_stream_pos *pos;
        FILE *fp;
This page took 0.02466 seconds and 4 git commands to generate.