copytrace: option to skip the copy of packet/content size
[babeltrace.git] / plugins / libctfcopytrace / ctfcopytrace.h
CommitLineData
91b73004
JD
1#ifndef BABELTRACE_LIB_COPY_TRACE_H
2#define BABELTRACE_LIB_COPY_TRACE_H
3
4/*
5 * BabelTrace - Library to create a copy of a CTF trace
6 *
7 * Copyright 2017 Julien Desfossez <jdesfossez@efficios.com>
8 *
9 * Author: Julien Desfossez <jdesfossez@efficios.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28 */
29
30#include <stdbool.h>
31#include <babeltrace/babeltrace-internal.h>
7b077a9d 32#include <babeltrace/graph/component.h>
91b73004
JD
33#include <babeltrace/ctf-writer/writer.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*
40 * Create a copy of the clock_class passed in parameter.
41 *
42 * Returns NULL on error.
43 */
44struct bt_ctf_clock_class *ctf_copy_clock_class(FILE *err,
45 struct bt_ctf_clock_class *clock_class);
46
47/*
48 * Copy all the clock classes from the input trace and add them to the writer
49 * object.
50 *
51 * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on
52 * error.
53 */
9ac68eb1 54BT_HIDDEN
91b73004
JD
55enum bt_component_status ctf_copy_clock_classes(FILE *err,
56 struct bt_ctf_trace *writer_trace,
57 struct bt_ctf_stream_class *writer_stream_class,
58 struct bt_ctf_trace *trace);
59
60/*
61 * Create a copy of the event class passed in paramater.
62 *
63 * Returns NULL on error.
64 */
9ac68eb1 65BT_HIDDEN
91b73004
JD
66struct bt_ctf_event_class *ctf_copy_event_class(FILE *err,
67 struct bt_ctf_event_class *event_class);
68
69/*
70 * Copy all the event classes from the input stream class and add them to the
71 * writer_stream_class.
72 *
73 * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on
74 * error.
75 */
9ac68eb1 76BT_HIDDEN
91b73004
JD
77enum bt_component_status ctf_copy_event_classes(FILE *err,
78 struct bt_ctf_stream_class *stream_class,
79 struct bt_ctf_stream_class *writer_stream_class);
80
81/*
82 * Create a copy of the stream class passed in parameter.
83 *
84 * Returns NULL or error.
85 */
9ac68eb1 86BT_HIDDEN
91b73004 87struct bt_ctf_stream_class *ctf_copy_stream_class(FILE *err,
b2f1f465
JD
88 struct bt_ctf_stream_class *stream_class,
89 struct bt_ctf_trace *writer_trace,
90 bool override_ts64);
91b73004
JD
91
92/*
93 * Copy the value of a packet context field and add it to the
94 * writer_packet_context. Only supports unsigned integers for now.
95 *
96 * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on
97 * error.
98 */
9ac68eb1 99BT_HIDDEN
91b73004
JD
100enum bt_component_status ctf_copy_packet_context_field(FILE *err,
101 struct bt_ctf_field *field, const char *field_name,
102 struct bt_ctf_field *writer_packet_context,
103 struct bt_ctf_field_type *writer_packet_context_type);
104
105/*
106 * Copy all the field values of the packet context from the packet passed in
107 * parameter and set it to the current packet in the writer stream.
ab80adac
JD
108 * The content_size and packet_size fields are not copied if skip_content_size
109 * is not 0.
91b73004
JD
110 *
111 * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on
112 * error.
113 */
9ac68eb1 114BT_HIDDEN
b2f1f465 115struct bt_ctf_field *ctf_copy_packet_context(FILE *err,
91b73004 116 struct bt_ctf_packet *packet,
ab80adac
JD
117 struct bt_ctf_stream *writer_stream,
118 int skip_content_size);
91b73004
JD
119
120/*
121 * Create and return a copy of the event passed in parameter. The caller has to
122 * append it to the writer_stream.
123 *
124 * Returns NULL on error.
125 */
9ac68eb1 126BT_HIDDEN
91b73004 127struct bt_ctf_event *ctf_copy_event(FILE *err, struct bt_ctf_event *event,
b2f1f465
JD
128 struct bt_ctf_event_class *writer_event_class,
129 bool override_ts64);
91b73004 130
0f29db56
JD
131/*
132 * Copies the content of the event header to writer_event_header.
133 *
134 * Returns 0 on success, -1 on error.
135 */
9ac68eb1 136BT_HIDDEN
0f29db56
JD
137int ctf_copy_event_header(FILE *err, struct bt_ctf_event *event,
138 struct bt_ctf_event_class *writer_event_class,
139 struct bt_ctf_event *writer_event,
140 struct bt_ctf_field *event_header);
141
91b73004
JD
142/*
143 * Copy the environment and the packet header from the input trace to the
144 * writer_trace.
145 *
146 * Returns BT_COMPONENT_STATUS_OK on success, and BT_COMPONENT_STATUS_ERROR on
147 * error.
148 */
9ac68eb1 149BT_HIDDEN
91b73004
JD
150enum bt_component_status ctf_copy_trace(FILE *err, struct bt_ctf_trace *trace,
151 struct bt_ctf_trace *writer_trace);
152
153#ifdef __cplusplus
154}
155#endif
156
157#endif /* BABELTRACE_LIB_COPY_TRACE_H */
This page took 0.03034 seconds and 4 git commands to generate.