Mercurial > dovecot > core-2.2
changeset 10336:e18645b47984 HEAD
config: Allow settings plugins to specify also new default services.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 16 Nov 2009 18:38:06 -0500 |
parents | 12434655f2e5 |
children | 69c2aa08cf2c |
files | configure.in src/config/all-settings.h src/config/config-parser.c src/config/settings-get.pl src/lib-master/service-settings.h src/master/master-settings.h |
diffstat | 6 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.in Mon Nov 16 18:37:12 2009 -0500 +++ b/configure.in Mon Nov 16 18:38:06 2009 -0500 @@ -2513,7 +2513,9 @@ dnl ** dnl get a list of setting .[ch] files, but list .h files first -SETTING_FILES=`find $srcdir/src -name '*settings.[[ch]]' ! -name all-settings.[[ch]] | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g' -e 's/^\(.*\)\(.\)$/\2 \1\2/' | sort -r | sed s/^..//|tr '\n' ' '` +FILES1=`find $srcdir/src -name '*settings.[[ch]]'|grep "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | sort -r | sed s/^..//` +FILES2=`find $srcdir/src -name '*settings.[[ch]]'|grep -v "$srcdir/src/lib-" | sed 's/^\(.*\)\(.\)$/\2 \1\2/' | grep -v all-settings | sort -r | sed s/^..//` +SETTING_FILES=`echo $FILES1 $FILES2 | sed -e s,$srcdir/src,./src,g -e 's,./src,$(top_srcdir)/src,g' | tr '\n' ' '` AC_SUBST(SETTING_FILES) dnl **
--- a/src/config/all-settings.h Mon Nov 16 18:37:12 2009 -0500 +++ b/src/config/all-settings.h Mon Nov 16 18:38:06 2009 -0500 @@ -3,5 +3,6 @@ extern const struct setting_parser_info *const *all_roots; extern const struct setting_parser_info *all_default_roots[]; +extern ARRAY_TYPE(service_settings) *default_services; #endif
--- a/src/config/config-parser.c Mon Nov 16 18:37:12 2009 -0500 +++ b/src/config/config-parser.c Mon Nov 16 18:38:06 2009 -0500 @@ -8,6 +8,7 @@ #include "istream.h" #include "module-dir.h" #include "settings-parser.h" +#include "service-settings.h" #include "all-settings.h" #include "config-filter.h" #include "config-parser.h" @@ -756,19 +757,27 @@ struct module *modules, *m; const struct setting_parser_info **roots; ARRAY_DEFINE(new_roots, const struct setting_parser_info *); - unsigned int i; + ARRAY_TYPE(service_settings) new_services; + struct service_settings *const *services, *service_set; + unsigned int i, count; modules = module_dir_load(CONFIG_MODULE_DIR, NULL, FALSE, NULL); module_dir_init(modules); i_array_init(&new_roots, 64); + i_array_init(&new_services, 64); for (m = modules; m != NULL; m = m->next) { - roots = module_get_symbol(m, + roots = module_get_symbol_quiet(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); } + + service_set = module_get_symbol_quiet(m, + t_strdup_printf("%s_service_settings", m->name)); + if (service_set != NULL) + array_append(&new_services, &service_set, 1); } if (array_count(&new_roots) > 0) { /* modules added new settings. add the defaults and start @@ -778,4 +787,11 @@ (void)array_append_space(&new_roots); all_roots = array_idx(&new_roots, 0); } + if (array_count(&new_services) > 0) { + /* module added new services. update the defaults. */ + services = array_get(default_services, &count); + for (i = 0; i < count; i++) + array_append(&new_services, &services[i], 1); + *default_services = new_services; + } }
--- a/src/config/settings-get.pl Mon Nov 16 18:37:12 2009 -0500 +++ b/src/config/settings-get.pl Mon Nov 16 18:38:06 2009 -0500 @@ -78,6 +78,8 @@ } } + s/^static const (struct master_settings master_default_settings)/$1/; + $write = 1; if (/};/) { $state = 0; @@ -115,3 +117,4 @@ print "\tNULL\n"; print "};\n"; print "const struct setting_parser_info *const *all_roots = all_default_roots;\n"; +print "ARRAY_TYPE(service_settings) *default_services = &master_default_settings.services;\n";
--- a/src/lib-master/service-settings.h Mon Nov 16 18:37:12 2009 -0500 +++ b/src/lib-master/service-settings.h Mon Nov 16 18:38:06 2009 -0500 @@ -53,5 +53,6 @@ enum service_type parsed_type; unsigned int login_dump_core:1; }; +ARRAY_DEFINE_TYPE(service_settings, struct service_settings *); #endif
--- a/src/master/master-settings.h Mon Nov 16 18:37:12 2009 -0500 +++ b/src/master/master-settings.h Mon Nov 16 18:38:06 2009 -0500 @@ -20,7 +20,7 @@ unsigned int first_valid_uid, last_valid_uid; unsigned int first_valid_gid, last_valid_gid; - ARRAY_DEFINE(services, struct service_settings *); + ARRAY_TYPE(service_settings) services; char **protocols_split; };