changeset 10107:dcda7c495eb6 HEAD

struct setting_parser_info now specifies the module name.
author Timo Sirainen <tss@iki.fi>
date Tue, 20 Oct 2009 17:36:06 -0400
parents 5a25b4ec5694
children 9cd71f3a6f96
files src/auth/auth-settings.c src/config/all-settings.h src/config/config-filter.c src/config/config-parser.c src/config/config-parser.h src/config/config-request.c src/config/doveconf.c src/config/settings-get.pl src/dict/dict-settings.c src/imap/imap-settings.c src/lib-lda/lda-settings.c src/lib-master/master-service-settings.c src/lib-settings/settings-parser.c src/lib-settings/settings-parser.h src/lib-storage/index/dbox-multi/mdbox-settings.c src/lib-storage/index/maildir/maildir-settings.c src/lib-storage/index/mbox/mbox-settings.c src/lib-storage/mail-storage-settings.c src/lmtp/lmtp-settings.c src/login-common/login-settings.c src/master/master-settings.c src/pop3/pop3-settings.c src/ssl-params/ssl-params-settings.c
diffstat 23 files changed, 57 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/auth/auth-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -26,6 +26,7 @@
 };
 
 struct setting_parser_info auth_passdb_setting_parser_info = {
+	MEMBER(module_name) NULL,
 	MEMBER(defines) auth_passdb_setting_defines,
 	MEMBER(defaults) NULL,
 
@@ -48,6 +49,7 @@
 };
 
 struct setting_parser_info auth_userdb_setting_parser_info = {
+	MEMBER(module_name) NULL,
 	MEMBER(defines) auth_userdb_setting_defines,
 	MEMBER(defaults) NULL,
 
@@ -129,6 +131,7 @@
 };
 
 struct setting_parser_info auth_setting_parser_info = {
+	MEMBER(module_name) "auth",
 	MEMBER(defines) auth_setting_defines,
 	MEMBER(defaults) &auth_default_settings,
 
--- a/src/config/all-settings.h	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/config/all-settings.h	Tue Oct 20 17:36:06 2009 -0400
@@ -1,10 +1,6 @@
 #ifndef ALL_SETTINGS_H
 #define ALL_SETTINGS_H
 
-struct all_settings_root {
-	const char *module_name;
-	struct setting_parser_info *root;
-};
-extern const struct all_settings_root all_roots[];
+extern const struct setting_parser_info *all_roots[];
 
 #endif
--- a/src/config/config-filter.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/config/config-filter.c	Tue Oct 20 17:36:06 2009 -0400
@@ -148,7 +148,7 @@
 {
 	unsigned int i;
 
-	for (i = 0; dest[i].module_name != NULL; i++) {
+	for (i = 0; dest[i].root != NULL; i++) {
 		if (settings_parser_apply_changes(dest[i].parser,
 						  src->parsers[i].parser, pool,
 						  error_r) < 0) {
@@ -175,7 +175,7 @@
 
 	/* all of them should have the same number of parsers.
 	   duplicate our initial parsers from the first match */
-	for (count = 0; src[0]->parsers[count].module_name != NULL; count++) ;
+	for (count = 0; src[0]->parsers[count].root != NULL; count++) ;
 	dest = p_new(pool, struct config_module_parser, count + 1);
 	for (i = 0; i < count; i++) {
 		dest[i] = src[0]->parsers[i];
@@ -206,6 +206,6 @@
 {
 	unsigned int i;
 
-	for (i = 0; parsers[i].module_name != NULL; i++)
+	for (i = 0; parsers[i].root != NULL; i++)
 		settings_parser_deinit(&parsers[i].parser);
 }
--- a/src/config/config-parser.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/config/config-parser.c	Tue Oct 20 17:36:06 2009 -0400
@@ -27,7 +27,7 @@
 	struct config_section_stack *prev;
 
 	struct config_filter filter;
-	/* module_name=NULL-terminated list of parsers */
+	/* root=NULL-terminated list of parsers */
 	struct config_module_parser *parsers;
 	unsigned int pathlen;
 };
@@ -106,7 +106,7 @@
 	bool found = FALSE;
 	int ret;
 
-	for (l = ctx->cur_section->parsers; l->module_name != NULL; l++) {
+	for (l = ctx->cur_section->parsers; l->root != NULL; l++) {
 		ret = settings_parse_line(l->parser, line);
 		if (ret > 0) {
 			found = TRUE;
@@ -146,13 +146,12 @@
 	struct config_module_parser *dest;
 	unsigned int i, count;
 
-	for (count = 0; all_roots[count].module_name != NULL; count++) ;
+	for (count = 0; all_roots[count] != NULL; count++) ;
 
 	dest = p_new(pool, struct config_module_parser, count + 1);
 	for (i = 0; i < count; i++) {
-		dest[i].module_name = all_roots[i].module_name;
-		dest[i].root = all_roots[i].root;
-		dest[i].parser = settings_parser_init(pool, all_roots[i].root,
+		dest[i].root = all_roots[i];
+		dest[i].parser = settings_parser_init(pool, all_roots[i],
 						      settings_parser_flags);
 	}
 	return dest;
@@ -266,7 +265,7 @@
 			   const struct config_module_parser *p,
 			   const char **error_r)
 {
-	for (; p->module_name != NULL; p++) {
+	for (; p->root != NULL; p++) {
 		settings_parse_var_skip(p->parser);
 		if (!settings_parser_check(p->parser, ctx->pool, error_r))
 			return -1;
@@ -589,14 +588,13 @@
 	ctx.pool = pool_alloconly_create("config file parser", 1024*64);
 	ctx.path = path;
 
-	for (count = 0; all_roots[count].module_name != NULL; count++) ;
+	for (count = 0; all_roots[count] != NULL; count++) ;
 	ctx.root_parsers =
 		p_new(ctx.pool, struct config_module_parser, count+1);
 	for (i = 0; i < count; i++) {
-		ctx.root_parsers[i].module_name = all_roots[i].module_name;
-		ctx.root_parsers[i].root = all_roots[i].root;
+		ctx.root_parsers[i].root = all_roots[i];
 		ctx.root_parsers[i].parser =
-			settings_parser_init(ctx.pool, all_roots[i].root,
+			settings_parser_init(ctx.pool, all_roots[i],
 					     settings_parser_flags);
 	}
 
--- a/src/config/config-parser.h	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/config/config-parser.h	Tue Oct 20 17:36:06 2009 -0400
@@ -2,8 +2,7 @@
 #define CONFIG_PARSER_H
 
 struct config_module_parser {
-	const char *module_name;
-	struct setting_parser_info *root;
+	const struct setting_parser_info *root;
 	struct setting_parser_context *parser;
 	void *settings;
 };
--- a/src/config/config-request.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/config/config-request.c	Tue Oct 20 17:36:06 2009 -0400
@@ -22,10 +22,11 @@
 	void *context;
 };
 
-static bool parsers_are_connected(struct setting_parser_info *root,
-				  struct setting_parser_info *info)
+static bool parsers_are_connected(const struct setting_parser_info *root,
+				  const struct setting_parser_info *info)
 {
-	struct setting_parser_info *const *dep, *p;
+	const struct setting_parser_info *p;
+	struct setting_parser_info *const *dep;
 
 	/* we're trying to find info or its parents from root's dependencies. */
 
@@ -51,15 +52,15 @@
 {
 	struct config_module_parser *l;
 
-	if (strcmp(list->module_name, module) == 0)
+	if (strcmp(list->root->module_name, module) == 0)
 		return TRUE;
 	if (list->root == &master_service_setting_parser_info) {
 		/* everyone wants master service settings */
 		return TRUE;
 	}
 
-	for (l = config_module_parsers; l->module_name != NULL; l++) {
-		if (strcmp(l->module_name, module) != 0)
+	for (l = config_module_parsers; l->root != NULL; l++) {
+		if (strcmp(l->root->module_name, module) != 0)
 			continue;
 
 		/* see if we can find a way to get from the original parser
@@ -260,7 +261,7 @@
 	ctx.keys = hash_table_create(default_pool, ctx.pool, 0,
 				     str_hash, (hash_cmp_callback_t *)strcmp);
 
-	for (i = 0; parsers[i].module_name != NULL; i++) {
+	for (i = 0; parsers[i].root != NULL; i++) {
 		parser = &parsers[i];
 		if (*module != '\0' &&
 		    !config_module_parser_is_in_service(parser, module))
--- a/src/config/doveconf.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/config/doveconf.c	Tue Oct 20 17:36:06 2009 -0400
@@ -188,8 +188,8 @@
 	const char *const *value;
 	const void *set;
 
-	for (l = config_module_parsers; l->module_name != NULL; l++) {
-		if (strcmp(l->module_name, "mail") != 0)
+	for (l = config_module_parsers; l->root != NULL; l++) {
+		if (strcmp(l->root->module_name, "mail") != 0)
 			continue;
 
 		set = settings_parser_get(l->parser);
--- a/src/config/settings-get.pl	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/config/settings-get.pl	Tue Oct 20 17:36:06 2009 -0400
@@ -22,6 +22,7 @@
   my $externs = "";
   my $code = "";
   my %funcs;
+  my $cur_name = "";
   
   while (<$f>) {
     my $write = 0;
@@ -32,8 +33,7 @@
 	$state++;
       } elsif (/^(static )?struct setting_parser_info (.*) = {/) {
 	$state++;
-	my $name = $2;
-	$parsers{$name} = 1 if ($name !~ /\*/);
+	$cur_name = $2;
       } elsif (/^extern struct setting_parser_info (.*);/) {
 	$externs .= "extern struct setting_parser_info $1;\n";
       } elsif (/\/\* <settings checks> \*\//) {
@@ -55,6 +55,9 @@
     
     if ($state == 1 || $state == 3) {
       if ($state == 1) {
+	if (/MEMBER\(module_name\) "(.*)"/) {
+	  $parsers{$cur_name} = $1;
+	}
 	if (/DEFLIST.*".*",(.*)$/) {
 	  my $value = $1;
 	  if ($value =~ /.*&(.*)\)/) {
@@ -87,15 +90,12 @@
   close $f;
 }
 
-print "const struct all_settings_root all_roots[] = {\n";
+print "const struct setting_parser_info *all_roots[] = {\n";
 foreach my $name (keys %parsers) {
-  next if (!$parsers{$name});
+  my $module = $parsers{$name};
+  next if (!$module);
 
-  my $module = "";
-  if ($name =~ /^([^_]*)/) {
-    $module = $1;
-  }
-  print "  { \"$module\", &".$name." }, \n";
+  print "\t&".$name.", \n";
 }
-print "  { NULL, NULL }\n";
+print "\tNULL\n";
 print "};\n";
--- a/src/dict/dict-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/dict/dict-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -23,6 +23,7 @@
 };
 
 struct setting_parser_info dict_setting_parser_info = {
+	MEMBER(module_name) "dict",
 	MEMBER(defines) dict_setting_defines,
 	MEMBER(defaults) &dict_default_settings,
 
--- a/src/imap/imap-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/imap/imap-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -56,6 +56,7 @@
 };
 
 struct setting_parser_info imap_setting_parser_info = {
+	MEMBER(module_name) "imap",
 	MEMBER(defines) imap_setting_defines,
 	MEMBER(defaults) &imap_default_settings,
 
--- a/src/lib-lda/lda-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-lda/lda-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -49,6 +49,7 @@
 };
 
 struct setting_parser_info lda_setting_parser_info = {
+	MEMBER(module_name) "lda",
 	MEMBER(defines) lda_setting_defines,
 	MEMBER(defaults) &lda_default_settings,
 
--- a/src/lib-master/master-service-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-master/master-service-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -45,6 +45,7 @@
 };
 
 struct setting_parser_info master_service_setting_parser_info = {
+	MEMBER(module_name) "master",
 	MEMBER(defines) master_service_setting_defines,
 	MEMBER(defaults) &master_service_default_settings,
 
--- a/src/lib-settings/settings-parser.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-settings/settings-parser.c	Tue Oct 20 17:36:06 2009 -0400
@@ -51,6 +51,7 @@
 };
 
 static const struct setting_parser_info strlist_info = {
+	MEMBER(module_name) NULL,
 	MEMBER(defines) NULL,
 	MEMBER(defaults) NULL,
 
--- a/src/lib-settings/settings-parser.h	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-settings/settings-parser.h	Tue Oct 20 17:36:06 2009 -0400
@@ -50,6 +50,7 @@
 	  #name, offsetof(struct struct_name, name), NULL }
 
 struct setting_parser_info {
+	const char *module_name;
 	const struct setting_define *defines;
 	const void *defaults;
 
--- a/src/lib-storage/index/dbox-multi/mdbox-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-storage/index/dbox-multi/mdbox-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -33,6 +33,7 @@
 };
 
 static struct setting_parser_info mdbox_setting_parser_info = {
+	MEMBER(module_name) "mdbox",
 	MEMBER(defines) mdbox_setting_defines,
 	MEMBER(defaults) &mdbox_default_settings,
 
--- a/src/lib-storage/index/maildir/maildir-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-storage/index/maildir/maildir-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -28,6 +28,7 @@
 };
 
 static struct setting_parser_info maildir_setting_parser_info = {
+	MEMBER(module_name) "maildir",
 	MEMBER(defines) maildir_setting_defines,
 	MEMBER(defaults) &maildir_default_settings,
 
--- a/src/lib-storage/index/mbox/mbox-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-storage/index/mbox/mbox-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -36,6 +36,7 @@
 };
 
 static struct setting_parser_info mbox_setting_parser_info = {
+	MEMBER(module_name) "mbox",
 	MEMBER(defines) mbox_setting_defines,
 	MEMBER(defaults) &mbox_default_settings,
 
--- a/src/lib-storage/mail-storage-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lib-storage/mail-storage-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -65,6 +65,7 @@
 };
 
 struct setting_parser_info mail_storage_setting_parser_info = {
+	MEMBER(module_name) "mail",
 	MEMBER(defines) mail_storage_setting_defines,
 	MEMBER(defaults) &mail_storage_default_settings,
 
@@ -110,6 +111,7 @@
 };
 
 struct setting_parser_info mail_namespace_setting_parser_info = {
+	MEMBER(module_name) NULL,
 	MEMBER(defines) mail_namespace_setting_defines,
 	MEMBER(defaults) &mail_namespace_default_settings,
 
@@ -185,6 +187,7 @@
 };
 
 struct setting_parser_info mail_user_setting_parser_info = {
+	MEMBER(module_name) "mail",
 	MEMBER(defines) mail_user_setting_defines,
 	MEMBER(defaults) &mail_user_default_settings,
 
--- a/src/lmtp/lmtp-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/lmtp/lmtp-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -23,6 +23,7 @@
 };
 
 struct setting_parser_info lmtp_setting_parser_info = {
+	MEMBER(module_name) "lmtp",
 	MEMBER(defines) lmtp_setting_defines,
 	MEMBER(defaults) &lmtp_default_settings,
 
--- a/src/login-common/login-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/login-common/login-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -71,6 +71,7 @@
 };
 
 struct setting_parser_info login_setting_parser_info = {
+	MEMBER(module_name) "login",
 	MEMBER(defines) login_setting_defines,
 	MEMBER(defaults) &login_default_settings,
 
--- a/src/master/master-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/master/master-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -43,6 +43,7 @@
 };
 
 static struct setting_parser_info file_listener_setting_parser_info = {
+	MEMBER(module_name) NULL,
 	MEMBER(defines) file_listener_setting_defines,
 	MEMBER(defaults) &file_listener_default_settings,
 
@@ -72,6 +73,7 @@
 };
 
 static struct setting_parser_info inet_listener_setting_parser_info = {
+	MEMBER(module_name) NULL,
 	MEMBER(defines) inet_listener_setting_defines,
 	MEMBER(defaults) &inet_listener_default_settings,
 
@@ -145,6 +147,7 @@
 };
 
 struct setting_parser_info service_setting_parser_info = {
+	MEMBER(module_name) NULL,
 	MEMBER(defines) service_setting_defines,
 	MEMBER(defaults) &service_default_settings,
 
@@ -211,6 +214,7 @@
 };
 
 struct setting_parser_info master_setting_parser_info = {
+	MEMBER(module_name) "master",
 	MEMBER(defines) master_setting_defines,
 	MEMBER(defaults) &master_default_settings,
 
--- a/src/pop3/pop3-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/pop3/pop3-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -53,6 +53,7 @@
 };
 
 struct setting_parser_info pop3_setting_parser_info = {
+	MEMBER(module_name) "pop3",
 	MEMBER(defines) pop3_setting_defines,
 	MEMBER(defaults) &pop3_default_settings,
 
--- a/src/ssl-params/ssl-params-settings.c	Tue Oct 20 17:15:01 2009 -0400
+++ b/src/ssl-params/ssl-params-settings.c	Tue Oct 20 17:36:06 2009 -0400
@@ -24,6 +24,7 @@
 };
 
 struct setting_parser_info ssl_params_setting_parser_info = {
+	MEMBER(module_name) "ssl-params",
 	MEMBER(defines) ssl_params_setting_defines,
 	MEMBER(defaults) &ssl_params_default_settings,