Commit | Line | Data |
---|---|---|
1501a7f3 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
1501a7f3 | 3 | * |
c922647d | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
1501a7f3 | 5 | * |
1501a7f3 JG |
6 | */ |
7 | ||
8 | #ifndef _CONFIG_H | |
9 | #define _CONFIG_H | |
10 | ||
c9e313bc SM |
11 | #include <common/config/config-session-abi.hpp> |
12 | #include <common/macros.hpp> | |
28f23191 | 13 | |
36f2332b | 14 | #include <stdint.h> |
1501a7f3 | 15 | |
a2a75fa4 JR |
16 | struct config_load_session_override_attr { |
17 | char *path_url; | |
18 | char *ctrl_url; | |
19 | char *data_url; | |
2aaf5fc7 | 20 | char *session_name; |
a2a75fa4 JR |
21 | }; |
22 | ||
36f2332b JG |
23 | /* Instance of a configuration writer. */ |
24 | struct config_writer; | |
25 | ||
36f2332b JG |
26 | /* |
27 | * Create an instance of a configuration writer. | |
28 | * | |
1d12100d JR |
29 | * fd_output File to which the XML content must be written. fd_output is |
30 | * owned by the caller. | |
36f2332b | 31 | * |
705bb62f JRJ |
32 | * indent If other than 0 the XML will be pretty printed |
33 | * with indentation and newline. | |
34 | * | |
36f2332b JG |
35 | * Returns an instance of a configuration writer on success, NULL on |
36 | * error. | |
37 | */ | |
705bb62f | 38 | struct config_writer *config_writer_create(int fd_output, int indent); |
36f2332b JG |
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 | */ | |
36f2332b JG |
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 | * | |
e10b6a1c | 57 | * Returns zero if the XML element could be opened. |
36f2332b JG |
58 | * Negative values indicate an error. |
59 | */ | |
28f23191 | 60 | int config_writer_open_element(struct config_writer *writer, const char *element_name); |
36f2332b | 61 | |
e10b6a1c JG |
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 | */ | |
e10b6a1c | 72 | int config_writer_write_attribute(struct config_writer *writer, |
28f23191 JG |
73 | const char *name, |
74 | const char *value); | |
e10b6a1c | 75 | |
36f2332b JG |
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 | */ | |
36f2332b JG |
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 | */ | |
36f2332b | 98 | int config_writer_write_element_unsigned_int(struct config_writer *writer, |
28f23191 JG |
99 | const char *element_name, |
100 | uint64_t value); | |
36f2332b JG |
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. | |
ca806b0b | 113 | */ |
36f2332b | 114 | int config_writer_write_element_signed_int(struct config_writer *writer, |
28f23191 JG |
115 | const char *element_name, |
116 | int64_t value); | |
36f2332b JG |
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 | */ | |
36f2332b | 130 | int config_writer_write_element_bool(struct config_writer *writer, |
28f23191 JG |
131 | const char *element_name, |
132 | int value); | |
36f2332b JG |
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 | */ | |
36f2332b | 146 | int config_writer_write_element_string(struct config_writer *writer, |
28f23191 JG |
147 | const char *element_name, |
148 | const char *value); | |
36f2332b | 149 | |
2b166400 JR |
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 | */ | |
2b166400 | 162 | int config_writer_write_element_double(struct config_writer *writer, |
28f23191 JG |
163 | const char *element_name, |
164 | double value); | |
2b166400 | 165 | |
dcf266c0 JG |
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 | * | |
40b4155f | 178 | * overwrite Overwrite current session configuration if it exists. |
ab38c13f | 179 | * autoload Tell to load the auto session(s). |
1b08cbce | 180 | * overrides The override attribute structure specifying override parameters. |
dcf266c0 JG |
181 | * |
182 | * Returns zero if the session could be loaded successfully. Returns | |
183 | * a negative LTTNG_ERR code on error. | |
184 | */ | |
28f23191 JG |
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); | |
dcf266c0 | 190 | |
1501a7f3 | 191 | #endif /* _CONFIG_H */ |