const char *path, *error;
path = master_service_get_config_path(master_service);
- if (config_parse_file(path, TRUE, NULL, &error) <= 0) {
+ if (config_parse_file(path, CONFIG_PARSE_FLAG_EXPAND_VALUES, NULL, &error) <= 0) {
o_stream_nsend_str(conn->output,
t_strconcat("-", error, "\n", NULL));
return 0;
}
}
-int config_parse_file(const char *path, bool expand_values,
+int config_parse_file(const char *path, enum config_parse_flags flags,
const char *const *modules, const char **error_r)
{
struct input_stack root;
i_zero(&root);
root.path = path;
ctx.cur_input = &root;
- ctx.expand_values = expand_values;
+ ctx.expand_values = (flags & CONFIG_PARSE_FLAG_EXPAND_VALUES) != 0;
ctx.modules = modules;
hash_table_create(&ctx.seen_settings, ctx.pool, 0, str_hash, strcmp);
#define IS_WHITE(c) ((c) == ' ' || (c) == '\t')
+enum config_parse_flags {
+ CONFIG_PARSE_FLAG_EXPAND_VALUES = BIT(0),
+};
+
struct config_module_parser {
const struct setting_parser_info *root;
struct setting_parser_context *parser;
int config_parse_net(const char *value, struct ip_addr *ip_r,
unsigned int *bits_r, const char **error_r);
-int config_parse_file(const char *path, bool expand_values,
+int config_parse_file(const char *path, enum config_parse_flags flags,
const char *const *modules, const char **error_r)
ATTR_NULL(3);
}
}
+ enum config_parse_flags flags = 0;
+ if (expand_vars)
+ flags |= CONFIG_PARSE_FLAG_EXPAND_VALUES;
if ((ret = config_parse_file(dump_defaults ? NULL : config_path,
- expand_vars, NULL,
+ flags, NULL,
&error)) == 0 &&
access(EXAMPLE_CONFIG_DIR, X_OK) == 0) {
i_fatal("%s (copy example configs from "EXAMPLE_CONFIG_DIR"/)",
config_parse_load_modules();
path = master_service_get_config_path(master_service);
- if (config_parse_file(path, TRUE, NULL, &error) <= 0)
+ if (config_parse_file(path, CONFIG_PARSE_FLAG_EXPAND_VALUES, NULL, &error) <= 0)
i_fatal("%s", error);
/* notify about our success only after successfully parsing the
putenv("bar=test2");
putenv("FOO$ENV:FOO=works");
- test_assert(config_parse_file(TEST_CONFIG_FILE, TRUE, NULL, &error) == 1);
+ test_assert(config_parse_file(TEST_CONFIG_FILE, CONFIG_PARSE_FLAG_EXPAND_VALUES, NULL, &error) == 1);
if (error != NULL)
i_error("config_parse_file(): %s", error);
test_assert_strcmp(set->protocols, "pop3 imap");
/* try again unexpanded */
- test_assert(config_parse_file(TEST_CONFIG_FILE, FALSE, NULL, &error) == 1);
+ test_assert(config_parse_file(TEST_CONFIG_FILE, 0, NULL, &error) == 1);
set = settings_parser_get(config_module_parsers[0].parser);
test_assert_strcmp(set->key, "value");