2 * BabelTrace - Common Trace Format (CTF)
4 * CTF Text Format registration.
6 * Copyright 2010, 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
19 #include <babeltrace/format.h>
20 #include <babeltrace/ctf-text/types.h>
21 #include <babeltrace/babeltrace.h>
23 #include <uuid/uuid.h>
26 #include <sys/types.h>
34 struct trace_descriptor
*ctf_text_open_trace(const char *path
, int flags
);
35 void ctf_text_close_trace(struct trace_descriptor
*descriptor
);
38 rw_dispatch read_dispatch_table
[] = {
39 /* All unimplemented */
43 rw_dispatch write_dispatch_table
[] = {
44 [ CTF_TYPE_INTEGER
] = ctf_text_integer_write
,
45 [ CTF_TYPE_FLOAT
] = ctf_text_float_write
,
46 [ CTF_TYPE_ENUM
] = ctf_text_enum_write
,
47 [ CTF_TYPE_STRING
] = ctf_text_string_write
,
48 [ CTF_TYPE_STRUCT
] = ctf_text_struct_write
,
49 [ CTF_TYPE_VARIANT
] = ctf_text_variant_write
,
50 [ CTF_TYPE_ARRAY
] = ctf_text_array_write
,
51 [ CTF_TYPE_SEQUENCE
] = ctf_text_sequence_write
,
55 struct format ctf_text_format
= {
56 .open_trace
= ctf_text_open_trace
,
57 .close_trace
= ctf_text_close_trace
,
60 struct trace_descriptor
*ctf_text_open_trace(const char *path
, int flags
)
62 struct ctf_text_stream_pos
*pos
;
65 pos
= g_new0(struct ctf_text_stream_pos
, 1);
67 switch (flags
& O_ACCMODE
) {
71 fp
= fopen(path
, "w");
75 pos
->parent
.rw_table
= write_dispatch_table
;
79 fprintf(stdout
, "[error] Incorrect open flags.\n");
83 return &pos
->trace_descriptor
;
89 void ctf_text_close_trace(struct trace_descriptor
*td
)
91 struct ctf_text_stream_pos
*pos
=
92 container_of(td
, struct ctf_text_stream_pos
, trace_descriptor
);
97 void __attribute__((constructor
)) ctf_text_init(void)
101 ctf_text_format
.name
= g_quark_from_static_string("text");
102 ret
= bt_register_format(&ctf_text_format
);