2 * Copyright (C) 2013 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <common/config/ini.h>
22 #include <common/macros.h>
25 /* section is NULL if the entry is not in a section */
32 * A config_entry_handler_cb receives config_entry structures belonging to the
33 * sections the handler has been registered to.
35 * The config_entry and its members are only valid for the duration of the call
36 * and must not be freed.
38 * config_entry_handler_cb may return negative value to indicate an error in
39 * the configuration file.
41 typedef int (*config_entry_handler_cb
)(const struct config_entry
*, void *);
44 * Read a section's entries in an INI configuration file.
46 * path may be NULL, in which case the following paths will be tried:
47 * 1) $HOME/.lttng/lttng.conf
48 * 2) /etc/lttng/lttng.conf
50 * handler will only be called with entries belonging to the provided section.
51 * If section is NULL, all entries will be relayed to handler. If section is
52 * "", only the global entries are relayed.
54 * Returns 0 on success. Negative values are error codes. If the return value
55 * is positive, it represents the line number on which a parsing error occured.
58 int config_get_section_entries(const char *path
, const char *section
,
59 config_entry_handler_cb handler
, void *user_data
);
62 * Parse a configuration value.
64 * This function expects either an unsigned integer or a boolean text option.
65 * The following strings are recognized: true, yes, on, false, no and off.
67 * Returns either the value of the parsed integer, or 0/1 if a boolean text
68 * string was recognized. Negative values indicate an error.
71 int config_parse_value(const char *value
);
73 #endif /* _CONFIG_H */