fix: context.h add missing documentation for packet_seek parameter
[babeltrace.git] / include / babeltrace / context.h
CommitLineData
b469d2dd
JD
1#ifndef _BABELTRACE_CONTEXT_H
2#define _BABELTRACE_CONTEXT_H
3
4/*
5 * BabelTrace
6 *
7 * context header
8 *
9 * Copyright 2012 EfficiOS Inc. and Linux Foundation
10 *
11 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 * Julien Desfossez <julien.desfossez@efficios.com>
13 *
6cba487f
MD
14 * Permission is hereby granted, free of charge, to any person obtaining
15 * a copy of this software and associated documentation files (the
16 * "Software"), to deal in the Software without restriction, including
17 * without limitation the rights to use, copy, modify, merge, publish,
18 * distribute, sublicense, and/or sell copies of the Software, and to
19 * permit persons to whom the Software is furnished to do so, subject to
20 * the following conditions:
b469d2dd 21 *
6cba487f
MD
22 * The above copyright notice and this permission notice shall be
23 * included in all copies or substantial portions of the Software.
b469d2dd
JD
24 */
25
613f532b
MD
26#include <unistd.h>
27
08c22d05
MD
28/* struct bt_context is opaque to the user */
29struct bt_context;
613f532b 30struct stream_pos;
b469d2dd
JD
31
32/*
33 * bt_context_create : create a Babeltrace context
34 *
6cba487f
MD
35 * Allocate a new context. The creation of the context sets the refcount
36 * to 1.
b469d2dd
JD
37 *
38 * Returns an allocated context on success and NULL on error
39 */
6cba487f 40struct bt_context *bt_context_create(void);
b469d2dd
JD
41
42/*
6cba487f 43 * bt_context_add_trace : Add a trace by path to the context
b469d2dd 44 *
2f5d314f
MD
45 * Open a trace.
46 *
47 * packet_seek can be NULL to use the default packet_seek handler
48 * provided by the trace format. If non-NULL, it is used as an override
49 * of the handler for seeks across packets. It takes as parameter a
50 * stream position, the packet index it needs to seek to (for SEEK_SET),
51 * and a "whence" parameter (either SEEK_CUR: seek to next packet, or
52 * SEEK_SET: seek to packet at packet index).
6cba487f 53 *
1059a2bf
JD
54 * Return: the trace handle id (>= 0) on success, a negative
55 * value on error.
6cba487f
MD
56 */
57int bt_context_add_trace(struct bt_context *ctx, const char *path,
613f532b
MD
58 const char *format,
59 void (*packet_seek)(struct stream_pos *pos,
20d0dcf9 60 size_t index, int whence));
6cba487f 61
6cba487f
MD
62/*
63 * bt_context_remove_trace: Remove a trace from the context.
64 *
65 * Effectively closing the trace.
b469d2dd 66 */
6cba487f 67void bt_context_remove_trace(struct bt_context *ctx, int trace_id);
b469d2dd
JD
68
69/*
6cba487f
MD
70 * bt_context_get and bt_context_put : increments and decrement the
71 * refcount of the context
b469d2dd 72 *
6cba487f
MD
73 * These functions ensures that the context won't be destroyed when it
74 * is in use. The same number of get and put (plus one extra put to
75 * release the initial reference done at creation) has to be done to
76 * destroy a context.
b469d2dd 77 *
6cba487f
MD
78 * When the context refcount is decremented to 0 by a bt_context_put,
79 * the context is freed.
b469d2dd 80 */
6cba487f
MD
81void bt_context_get(struct bt_context *ctx);
82void bt_context_put(struct bt_context *ctx);
b469d2dd
JD
83
84#endif /* _BABELTRACE_CONTEXT_H */
This page took 0.026135 seconds and 4 git commands to generate.