Propagate error from packet_seek in case of truncated packet
[babeltrace.git] / include / babeltrace / error.h
1 #ifndef BABELTRACE_ERROR_H
2 #define BABELTRACE_ERROR_H
3
4 /*
5 * BabelTrace
6 *
7 * Global error accessors.
8 *
9 * Copyright 2018 EfficiOS Inc. and Linux Foundation
10 *
11 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33 enum bt_packet_seek_error {
34 BT_PACKET_SEEK_ERROR = 1,
35 BT_PACKET_SEEK_ERROR_TRUNCATED_PACKET = 2,
36 };
37
38 /*
39 * bt_packet_seek_get_error: get the return code of the last packet_seek use.
40 *
41 * The packet seek functions defined by the various formats don't return a
42 * value. An implementation that can fail to seek can set a per-thread
43 * packet_seek error to be checked by the caller.
44 *
45 * The error is cleared after access in order to preserve the compatibility
46 * with implementation that don't set an error.
47 */
48 int bt_packet_seek_get_error(void);
49
50 /*
51 * bt_packet_seek_set_error: set the return code of the last packet_seek use.
52 *
53 * This function sets the per-thread packet_seek error. A value of 0 indicates
54 * no error. Implementations of packet_seek are encouraged to use a negative
55 * value to indicate an error.
56 */
57 void bt_packet_seek_set_error(int error);
58
59 #endif /* BABELTRACE_ERROR_H */
This page took 0.030268 seconds and 4 git commands to generate.