2 * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
11 #include <common/config/config-session-abi.h>
12 #include <common/macros.h>
15 struct config_load_session_override_attr
{
22 /* Instance of a configuration writer. */
26 * Create an instance of a configuration writer.
28 * fd_output File to which the XML content must be written. fd_output is
29 * owned by the caller.
31 * indent If other than 0 the XML will be pretty printed
32 * with indentation and newline.
34 * Returns an instance of a configuration writer on success, NULL on
37 struct config_writer
*config_writer_create(int fd_output
, int indent
);
40 * Destroy an instance of a configuration writer.
42 * writer An instance of a configuration writer.
44 * Returns zero if the XML document could be closed cleanly. Negative values
47 int config_writer_destroy(struct config_writer
*writer
);
50 * Open an element tag.
52 * writer An instance of a configuration writer.
54 * element_name Element tag name.
56 * Returns zero if the XML element could be opened.
57 * Negative values indicate an error.
59 int config_writer_open_element(struct config_writer
*writer
,
60 const char *element_name
);
63 * Write an element tag attribute.
65 * writer An instance of a configuration writer.
67 * name Attribute name.
69 * Returns zero if the XML element's attribute could be written.
70 * Negative values indicate an error.
72 int config_writer_write_attribute(struct config_writer
*writer
,
73 const char *name
, const char *value
);
76 * Close the current element tag.
78 * writer An instance of a configuration writer.
80 * Returns zero if the XML document could be closed cleanly.
81 * Negative values indicate an error.
83 int config_writer_close_element(struct config_writer
*writer
);
86 * Write an element of type unsigned int.
88 * writer An instance of a configuration writer.
90 * element_name Element name.
92 * value Unsigned int value of the element
94 * Returns zero if the element's value could be written.
95 * Negative values indicate an error.
97 int config_writer_write_element_unsigned_int(struct config_writer
*writer
,
98 const char *element_name
, uint64_t value
);
101 * Write an element of type signed int.
103 * writer An instance of a configuration writer.
105 * element_name Element name.
107 * value Signed int value of the element
109 * Returns zero if the element's value could be written.
110 * Negative values indicate an error.
112 int config_writer_write_element_signed_int(struct config_writer
*writer
,
113 const char *element_name
, int64_t value
);
116 * Write an element of type boolean.
118 * writer An instance of a configuration writer.
120 * element_name Element name.
122 * value Boolean value of the element
124 * Returns zero if the element's value could be written.
125 * Negative values indicate an error.
127 int config_writer_write_element_bool(struct config_writer
*writer
,
128 const char *element_name
, int value
);
131 * Write an element of type string.
133 * writer An instance of a configuration writer.
135 * element_name Element name.
137 * value String value of the element
139 * Returns zero if the element's value could be written.
140 * Negative values indicate an error.
142 int config_writer_write_element_string(struct config_writer
*writer
,
143 const char *element_name
, const char *value
);
146 * Write an element of type double.
148 * writer An instance of a configuration writer.
150 * element_name Element name.
152 * value Double value of the element
154 * Returns zero if the element's value could be written.
155 * Negative values indicate an error.
157 int config_writer_write_element_double(struct config_writer
*writer
,
158 const char *element_name
,
162 * Load session configurations from a file.
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
170 * session_name Name of the session to load. Will load all
171 * sessions from path if NULL.
173 * overwrite Overwrite current session configuration if it exists.
174 * autoload Tell to load the auto session(s).
175 * overrides The override attribute structure specifying override parameters.
177 * Returns zero if the session could be loaded successfully. Returns
178 * a negative LTTNG_ERR code on error.
180 int config_load_session(const char *path
, const char *session_name
,
181 int overwrite
, unsigned int autoload
,
182 const struct config_load_session_override_attr
*overrides
);
184 #endif /* _CONFIG_H */