#include "hash.h"
#include "strescape.h"
#include "istream.h"
+#include "module-dir.h"
#include "settings-parser.h"
#include "all-settings.h"
#include "config-filter.h"
}
return 1;
}
+
+void config_parse_load_modules(void)
+{
+ struct module *modules, *m;
+ const struct setting_parser_info **roots;
+ ARRAY_DEFINE(new_roots, const struct setting_parser_info *);
+ unsigned int i;
+
+ modules = module_dir_load(CONFIG_MODULE_DIR, NULL, FALSE, NULL);
+ module_dir_init(modules);
+
+ i_array_init(&new_roots, 64);
+ for (m = modules; m != NULL; m = m->next) {
+ roots = module_get_symbol(m,
+ t_strdup_printf("%s_set_roots", m->name));
+ if (roots != NULL) {
+ for (i = 0; roots[i] != NULL; i++)
+ array_append(&new_roots, &roots[i], 1);
+ }
+ }
+ if (array_count(&new_roots) > 0) {
+ /* modules added new settings. add the defaults and start
+ using the new list. */
+ for (i = 0; all_roots[i] != NULL; i++)
+ array_append(&new_roots, &all_roots[i], 1);
+ (void)array_append_space(&new_roots);
+ all_roots = array_idx(&new_roots, 0);
+ }
+}
#ifndef CONFIG_PARSER_H
#define CONFIG_PARSER_H
+#define CONFIG_MODULE_DIR MODULEDIR"/settings"
+
struct config_module_parser {
const struct setting_parser_info *root;
struct setting_parser_context *parser;
int config_parse_file(const char *path, bool expand_files,
const char **error_r);
+void config_parse_load_modules(void);
+
#endif
fflush(stdout);
}
master_service_init_finish(master_service);
+ config_parse_load_modules();
if ((ret = config_parse_file(config_path, FALSE, &error)) == 0 &&
access(EXAMPLE_CONFIG_DIR, X_OK) == 0) {
master_service_init_log(master_service, "config: ");
master_service_init_finish(master_service);
+ config_parse_load_modules();
path = master_service_get_config_path(master_service);
if (config_parse_file(path, TRUE, &error) <= 0)
print "\tconfig_all_services, sizeof(config_all_services), { 0, }\n";
print "};\n";
-print "const struct setting_parser_info *all_roots[] = {\n";
+print "const struct setting_parser_info *all_default_roots[] = {\n";
foreach my $name (keys %parsers) {
my $module = $parsers{$name};
next if (!$module);
}
print "\tNULL\n";
print "};\n";
+print "const struct setting_parser_info *const *all_roots = all_default_roots;\n";