*
*/
-#include "ini-config.h"
+#include "ini-config.hpp"
+
+#include <common/defaults.hpp>
+#include <common/error.hpp>
+#include <common/ini-config/ini.hpp>
+#include <common/macros.hpp>
+#include <common/utils.hpp>
-#include <common/defaults.h>
-#include <common/error.h>
-#include <common/ini-config/ini.h>
-#include <common/macros.h>
-#include <common/utils.h>
#include <ctype.h>
LTTNG_EXPORT const char *config_str_yes = "yes";
LTTNG_EXPORT const char *config_str_false = "false";
LTTNG_EXPORT const char *config_str_off = "off";
+namespace {
struct handler_filter_args {
- const char* section;
+ const char *section;
config_entry_handler_cb handler;
void *user_data;
};
+} /* namespace */
static int config_entry_handler_filter(struct handler_filter_args *args,
- const char *section, const char *name, const char *value)
+ const char *section,
+ const char *name,
+ const char *value)
{
int ret = 0;
struct config_entry entry = { section, name, value };
return ret;
}
-int config_get_section_entries(const char *override_path, const char *section,
- config_entry_handler_cb handler, void *user_data)
+int config_get_section_entries(const char *override_path,
+ const char *section,
+ config_entry_handler_cb handler,
+ void *user_data)
{
int ret = 0;
const char *path;
- FILE *config_file = NULL;
+ FILE *config_file = nullptr;
struct handler_filter_args filter = { section, handler, user_data };
/* First, try system-wide conf. file. */
* continue and try the next possible conf. file.
*/
(void) ini_parse_file(config_file,
- (ini_entry_handler) config_entry_handler_filter,
- (void *) &filter);
+ (ini_entry_handler) config_entry_handler_filter,
+ (void *) &filter);
fclose(config_file);
}
if (path) {
char fullpath[PATH_MAX];
- ret = snprintf(fullpath, sizeof(fullpath),
- DEFAULT_DAEMON_HOME_CONFIGPATH, path);
+ ret = snprintf(fullpath, sizeof(fullpath), DEFAULT_DAEMON_HOME_CONFIGPATH, path);
if (ret < 0) {
PERROR("snprintf user conf. path");
goto error;
* continue and try the next possible conf. file.
*/
(void) ini_parse_file(config_file,
- (ini_entry_handler) config_entry_handler_filter,
- (void *) &filter);
+ (ini_entry_handler) config_entry_handler_filter,
+ (void *) &filter);
fclose(config_file);
}
}
if (config_file) {
DBG("Loading daemon command line conf file at %s", override_path);
(void) ini_parse_file(config_file,
- (ini_entry_handler) config_entry_handler_filter,
- (void *) &filter);
+ (ini_entry_handler) config_entry_handler_filter,
+ (void *) &filter);
fclose(config_file);
} else {
- ERR("Failed to open daemon configuration file at %s",
- override_path);
+ ERR("Failed to open daemon configuration file at %s", override_path);
ret = -ENOENT;
goto error;
}
goto end;
}
- lower_str = (char *) zmalloc(len + 1);
+ lower_str = zmalloc<char>(len + 1);
if (!lower_str) {
PERROR("zmalloc");
ret = -errno;
lower_str[i] = tolower(value[i]);
}
- if (!strcmp(lower_str, config_str_yes) ||
- !strcmp(lower_str, config_str_true) ||
- !strcmp(lower_str, config_str_on)) {
+ if (!strcmp(lower_str, config_str_yes) || !strcmp(lower_str, config_str_true) ||
+ !strcmp(lower_str, config_str_on)) {
ret = 1;
- } else if (!strcmp(lower_str, config_str_no) ||
- !strcmp(lower_str, config_str_false) ||
- !strcmp(lower_str, config_str_off)) {
+ } else if (!strcmp(lower_str, config_str_no) || !strcmp(lower_str, config_str_false) ||
+ !strcmp(lower_str, config_str_off)) {
ret = 0;
} else {
ret = -1;