Clean-up: run format-cpp on the tree
[lttng-tools.git] / src / common / config / session-config.hpp
1 /*
2 * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef _CONFIG_H
9 #define _CONFIG_H
10
11 #include <common/config/config-session-abi.hpp>
12 #include <common/macros.hpp>
13
14 #include <stdint.h>
15
16 struct config_load_session_override_attr {
17 char *path_url;
18 char *ctrl_url;
19 char *data_url;
20 char *session_name;
21 };
22
23 /* Instance of a configuration writer. */
24 struct config_writer;
25
26 /*
27 * Create an instance of a configuration writer.
28 *
29 * fd_output File to which the XML content must be written. fd_output is
30 * owned by the caller.
31 *
32 * indent If other than 0 the XML will be pretty printed
33 * with indentation and newline.
34 *
35 * Returns an instance of a configuration writer on success, NULL on
36 * error.
37 */
38 struct config_writer *config_writer_create(int fd_output, int indent);
39
40 /*
41 * Destroy an instance of a configuration writer.
42 *
43 * writer An instance of a configuration writer.
44 *
45 * Returns zero if the XML document could be closed cleanly. Negative values
46 * indicate an error.
47 */
48 int config_writer_destroy(struct config_writer *writer);
49
50 /*
51 * Open an element tag.
52 *
53 * writer An instance of a configuration writer.
54 *
55 * element_name Element tag name.
56 *
57 * Returns zero if the XML element could be opened.
58 * Negative values indicate an error.
59 */
60 int config_writer_open_element(struct config_writer *writer, const char *element_name);
61
62 /*
63 * Write an element tag attribute.
64 *
65 * writer An instance of a configuration writer.
66 *
67 * name Attribute name.
68 *
69 * Returns zero if the XML element's attribute could be written.
70 * Negative values indicate an error.
71 */
72 int config_writer_write_attribute(struct config_writer *writer,
73 const char *name,
74 const char *value);
75
76 /*
77 * Close the current element tag.
78 *
79 * writer An instance of a configuration writer.
80 *
81 * Returns zero if the XML document could be closed cleanly.
82 * Negative values indicate an error.
83 */
84 int config_writer_close_element(struct config_writer *writer);
85
86 /*
87 * Write an element of type unsigned int.
88 *
89 * writer An instance of a configuration writer.
90 *
91 * element_name Element name.
92 *
93 * value Unsigned int value of the element
94 *
95 * Returns zero if the element's value could be written.
96 * Negative values indicate an error.
97 */
98 int config_writer_write_element_unsigned_int(struct config_writer *writer,
99 const char *element_name,
100 uint64_t value);
101
102 /*
103 * Write an element of type signed int.
104 *
105 * writer An instance of a configuration writer.
106 *
107 * element_name Element name.
108 *
109 * value Signed int value of the element
110 *
111 * Returns zero if the element's value could be written.
112 * Negative values indicate an error.
113 */
114 int config_writer_write_element_signed_int(struct config_writer *writer,
115 const char *element_name,
116 int64_t value);
117
118 /*
119 * Write an element of type boolean.
120 *
121 * writer An instance of a configuration writer.
122 *
123 * element_name Element name.
124 *
125 * value Boolean value of the element
126 *
127 * Returns zero if the element's value could be written.
128 * Negative values indicate an error.
129 */
130 int config_writer_write_element_bool(struct config_writer *writer,
131 const char *element_name,
132 int value);
133
134 /*
135 * Write an element of type string.
136 *
137 * writer An instance of a configuration writer.
138 *
139 * element_name Element name.
140 *
141 * value String value of the element
142 *
143 * Returns zero if the element's value could be written.
144 * Negative values indicate an error.
145 */
146 int config_writer_write_element_string(struct config_writer *writer,
147 const char *element_name,
148 const char *value);
149
150 /*
151 * Write an element of type double.
152 *
153 * writer An instance of a configuration writer.
154 *
155 * element_name Element name.
156 *
157 * value Double value of the element
158 *
159 * Returns zero if the element's value could be written.
160 * Negative values indicate an error.
161 */
162 int config_writer_write_element_double(struct config_writer *writer,
163 const char *element_name,
164 double value);
165
166 /*
167 * Load session configurations from a file.
168 *
169 * path Path to an LTTng session configuration file. All *.lttng files
170 * will be loaded if path is a directory. If path is NULL, the default
171 * paths will be searched in the following order:
172 * 1) $HOME/.lttng/sessions
173 * 2) /etc/lttng/sessions
174 *
175 * session_name Name of the session to load. Will load all
176 * sessions from path if NULL.
177 *
178 * overwrite Overwrite current session configuration if it exists.
179 * autoload Tell to load the auto session(s).
180 * overrides The override attribute structure specifying override parameters.
181 *
182 * Returns zero if the session could be loaded successfully. Returns
183 * a negative LTTNG_ERR code on error.
184 */
185 int config_load_session(const char *path,
186 const char *session_name,
187 int overwrite,
188 unsigned int autoload,
189 const struct config_load_session_override_attr *overrides);
190
191 #endif /* _CONFIG_H */
This page took 0.037965 seconds and 5 git commands to generate.