6 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
8 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
21 #include <babeltrace/babeltrace.h>
22 #include <babeltrace/ctf-text/types.h>
25 int babeltrace_verbose
, babeltrace_debug
;
27 int convert_trace(struct trace_descriptor
*td_write
,
28 struct trace_collection
*trace_collection_read
)
30 struct babeltrace_iter
*iter
;
31 struct ctf_stream
*stream
;
32 struct ctf_stream_event
*event
;
33 struct ctf_text_stream_pos
*sout
;
34 struct trace_collection_pos begin_pos
;
37 sout
= container_of(td_write
, struct ctf_text_stream_pos
,
40 begin_pos
.type
= BT_SEEK_BEGIN
;
41 iter
= babeltrace_iter_create(trace_collection_read
, &begin_pos
, NULL
);
42 while (babeltrace_iter_read_event(iter
, &stream
, &event
) == 0) {
43 ret
= sout
->parent
.event_cb(&sout
->parent
, stream
);
45 fprintf(stdout
, "[error] Writing event failed.\n");
48 ret
= babeltrace_iter_next(iter
);
53 babeltrace_iter_destroy(iter
);
58 void __attribute__((constructor
)) init_babeltrace_lib(void)
60 if (getenv("BABELTRACE_VERBOSE"))
61 babeltrace_verbose
= 1;
62 if (getenv("BABELTRACE_DEBUG"))