There is only one root now, so the root parameter isn't necessary.
parser = &ctx->parsers[i];
T_BEGIN {
- void *set = settings_parser_get_root_set(parser->parser, parser->root);
+ void *set = settings_parser_get_set(parser->parser);
settings_export(ctx, parser->root, FALSE, set,
settings_parser_get_changes(parser->parser));
} T_END;
if (strcmp(l->root->module_name, module) != 0)
continue;
- set = settings_parser_get_root_set(l->parser, l->root);
+ set = settings_parser_get_set(l->parser);
for (def = l->root->defines; def->key != NULL; def++) {
if (strcmp(def->key, name) == 0) {
value = CONST_PTR_OFFSET(set, def->offset);
/* get the parsed output */
const struct test_settings *set =
- settings_parser_get_root_set(config_module_parsers[0].parser,
- config_module_parsers[0].root);
+ settings_parser_get_set(config_module_parsers[0].parser);
test_assert_strcmp(set->key, "value");
test_assert_strcmp(set->key2, "\\$escape \\escape \\\"escape\\\"");
test_assert_strcmp(set->key3, "yetanother value value nothervalue right here");
/* try again unexpanded */
test_assert(config_parse_file(TEST_CONFIG_FILE, 0, &error) == 1);
- set = settings_parser_get_root_set(config_module_parsers[0].parser,
- config_module_parsers[0].root);
+ set = settings_parser_get_set(config_module_parsers[0].parser);
test_assert_strcmp(set->key, "value");
test_assert_strcmp(set->key2, "\\$escape \\escape \\\"escape\\\"");
return -1;
}
- void *set = settings_parser_get_root_set(parser, info);
+ void *set = settings_parser_get_set(parser);
pool_t *pool_p = PTR_OFFSET(set, info->pool_offset1 - 1);
*pool_p = set_pool;
pool_unref(&ctx->parser_pool);
}
-void *settings_parser_get_root_set(const struct setting_parser_context *ctx,
- const struct setting_parser_info *root)
+void *settings_parser_get_set(const struct setting_parser_context *ctx)
{
- for (unsigned int i = 0; i < ctx->root_count; i++) {
- if (ctx->roots[i].info == root)
- return ctx->roots[i].set_struct;
- }
- i_panic("Couldn't find settings for root %s", root->module_name);
+ i_assert(ctx->root_count == 1);
+
+ return ctx->roots[0].set_struct;
}
void *settings_parser_get_changes(struct setting_parser_context *ctx)
void settings_parser_ref(struct setting_parser_context *ctx);
void settings_parser_unref(struct setting_parser_context **ctx);
-/* Returns settings for a specific root. The root is expected to exist, and it
- must be the same pointer as given to settings_parser_init*(). If it doesn't,
- the function panics. */
-void *settings_parser_get_root_set(const struct setting_parser_context *ctx,
- const struct setting_parser_info *root);
+/* Returns the current settings. */
+void *settings_parser_get_set(const struct setting_parser_context *ctx);
/* Return pointer to changes in the root setting structure. */
void *settings_parser_get_changes(struct setting_parser_context *ctx);
test_assert(settings_parser_check(ctx, pool, NULL));
/* check what we got */
- struct test_settings *settings =
- settings_parser_get_root_set(ctx, &root);
+ struct test_settings *settings = settings_parser_get_set(ctx);
test_assert(settings != NULL);
test_assert(settings->bool_true == TRUE);
if (!settings_parser_check(ctx, test_pool, &error))
i_fatal("Failed to parse settings: %s",
error);
- struct stats_settings *set =
- settings_parser_get_root_set(ctx, &stats_setting_parser_info);
+ struct stats_settings *set = settings_parser_get_set(ctx);
settings_parser_unref(&ctx);
return set;
}