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> | |
36f2332b | 13 | #include <stdint.h> |
1501a7f3 | 14 | |
a2a75fa4 JR |
15 | struct config_load_session_override_attr { |
16 | char *path_url; | |
17 | char *ctrl_url; | |
18 | char *data_url; | |
2aaf5fc7 | 19 | char *session_name; |
a2a75fa4 JR |
20 | }; |
21 | ||
36f2332b JG |
22 | /* Instance of a configuration writer. */ |
23 | struct config_writer; | |
24 | ||
36f2332b JG |
25 | /* |
26 | * Create an instance of a configuration writer. | |
27 | * | |
1d12100d JR |
28 | * fd_output File to which the XML content must be written. fd_output is |
29 | * owned by the caller. | |
36f2332b | 30 | * |
705bb62f JRJ |
31 | * indent If other than 0 the XML will be pretty printed |
32 | * with indentation and newline. | |
33 | * | |
36f2332b JG |
34 | * Returns an instance of a configuration writer on success, NULL on |
35 | * error. | |
36 | */ | |
705bb62f | 37 | struct config_writer *config_writer_create(int fd_output, int indent); |
36f2332b JG |
38 | |
39 | /* | |
40 | * Destroy an instance of a configuration writer. | |
41 | * | |
42 | * writer An instance of a configuration writer. | |
43 | * | |
44 | * Returns zero if the XML document could be closed cleanly. Negative values | |
45 | * indicate an error. | |
46 | */ | |
36f2332b JG |
47 | int config_writer_destroy(struct config_writer *writer); |
48 | ||
49 | /* | |
50 | * Open an element tag. | |
51 | * | |
52 | * writer An instance of a configuration writer. | |
53 | * | |
54 | * element_name Element tag name. | |
55 | * | |
e10b6a1c | 56 | * Returns zero if the XML element could be opened. |
36f2332b JG |
57 | * Negative values indicate an error. |
58 | */ | |
36f2332b JG |
59 | int config_writer_open_element(struct config_writer *writer, |
60 | const char *element_name); | |
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 JG |
72 | int config_writer_write_attribute(struct config_writer *writer, |
73 | const char *name, const char *value); | |
74 | ||
36f2332b JG |
75 | /* |
76 | * Close the current element tag. | |
77 | * | |
78 | * writer An instance of a configuration writer. | |
79 | * | |
80 | * Returns zero if the XML document could be closed cleanly. | |
81 | * Negative values indicate an error. | |
82 | */ | |
36f2332b JG |
83 | int config_writer_close_element(struct config_writer *writer); |
84 | ||
85 | /* | |
86 | * Write an element of type unsigned int. | |
87 | * | |
88 | * writer An instance of a configuration writer. | |
89 | * | |
90 | * element_name Element name. | |
91 | * | |
92 | * value Unsigned int value of the element | |
93 | * | |
94 | * Returns zero if the element's value could be written. | |
95 | * Negative values indicate an error. | |
96 | */ | |
36f2332b JG |
97 | int config_writer_write_element_unsigned_int(struct config_writer *writer, |
98 | const char *element_name, uint64_t value); | |
99 | ||
100 | /* | |
101 | * Write an element of type signed int. | |
102 | * | |
103 | * writer An instance of a configuration writer. | |
104 | * | |
105 | * element_name Element name. | |
106 | * | |
107 | * value Signed int value of the element | |
108 | * | |
109 | * Returns zero if the element's value could be written. | |
110 | * Negative values indicate an error. | |
ca806b0b | 111 | */ |
36f2332b JG |
112 | int config_writer_write_element_signed_int(struct config_writer *writer, |
113 | const char *element_name, int64_t value); | |
114 | ||
115 | /* | |
116 | * Write an element of type boolean. | |
117 | * | |
118 | * writer An instance of a configuration writer. | |
119 | * | |
120 | * element_name Element name. | |
121 | * | |
122 | * value Boolean value of the element | |
123 | * | |
124 | * Returns zero if the element's value could be written. | |
125 | * Negative values indicate an error. | |
126 | */ | |
36f2332b JG |
127 | int config_writer_write_element_bool(struct config_writer *writer, |
128 | const char *element_name, int value); | |
129 | ||
130 | /* | |
131 | * Write an element of type string. | |
132 | * | |
133 | * writer An instance of a configuration writer. | |
134 | * | |
135 | * element_name Element name. | |
136 | * | |
137 | * value String value of the element | |
138 | * | |
139 | * Returns zero if the element's value could be written. | |
140 | * Negative values indicate an error. | |
141 | */ | |
36f2332b JG |
142 | int config_writer_write_element_string(struct config_writer *writer, |
143 | const char *element_name, const char *value); | |
144 | ||
2b166400 JR |
145 | /* |
146 | * Write an element of type double. | |
147 | * | |
148 | * writer An instance of a configuration writer. | |
149 | * | |
150 | * element_name Element name. | |
151 | * | |
152 | * value Double value of the element | |
153 | * | |
154 | * Returns zero if the element's value could be written. | |
155 | * Negative values indicate an error. | |
156 | */ | |
2b166400 JR |
157 | int config_writer_write_element_double(struct config_writer *writer, |
158 | const char *element_name, | |
159 | double value); | |
160 | ||
dcf266c0 JG |
161 | /* |
162 | * Load session configurations from a file. | |
163 | * | |
164 | * path Path to an LTTng session configuration file. All *.lttng files | |
165 | * will be loaded if path is a directory. If path is NULL, the default | |
166 | * paths will be searched in the following order: | |
167 | * 1) $HOME/.lttng/sessions | |
168 | * 2) /etc/lttng/sessions | |
169 | * | |
170 | * session_name Name of the session to load. Will load all | |
171 | * sessions from path if NULL. | |
172 | * | |
40b4155f | 173 | * overwrite Overwrite current session configuration if it exists. |
ab38c13f | 174 | * autoload Tell to load the auto session(s). |
1b08cbce | 175 | * overrides The override attribute structure specifying override parameters. |
dcf266c0 JG |
176 | * |
177 | * Returns zero if the session could be loaded successfully. Returns | |
178 | * a negative LTTNG_ERR code on error. | |
179 | */ | |
dcf266c0 | 180 | int config_load_session(const char *path, const char *session_name, |
1b08cbce JR |
181 | int overwrite, unsigned int autoload, |
182 | const struct config_load_session_override_attr *overrides); | |
dcf266c0 | 183 | |
1501a7f3 | 184 | #endif /* _CONFIG_H */ |