Mercurial > dovecot > core-2.2
changeset 9229:e5303fd61b5c HEAD
doveconf/config cleanups.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 05 May 2009 15:33:44 -0400 |
parents | e91bca10d5a1 |
children | d83bfe8c38c2 |
files | src/config/config-parser.c src/config/config-parser.h src/config/doveconf.c src/config/main.c |
diffstat | 4 files changed, 16 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/src/config/config-parser.c Tue May 05 15:28:26 2009 -0400 +++ b/src/config/config-parser.c Tue May 05 15:33:44 2009 -0400 @@ -71,7 +71,7 @@ return t_strconcat(t_strdup_until(input->path, p+1), path, NULL); } -void config_parse_file(const char *path, const char *service) +void config_parse_file(const char *path) { enum settings_parser_flags parser_flags = SETTINGS_PARSER_FLAG_IGNORE_UNKNOWN_KEYS; @@ -84,7 +84,7 @@ unsigned int counter = 0, auth_counter = 0, cur_counter; const char *errormsg, *name, *type_name; char *line, *key, *p; - int fd, ret, ignore; + int fd, ret; string_t *str, *full_line; size_t len; pool_t pool; @@ -112,7 +112,7 @@ str = t_str_new(256); full_line = t_str_new(512); - errormsg = NULL; ignore = 0; + errormsg = NULL; newfile: input->input = i_stream_create_fd(fd, (size_t)-1, TRUE); i_stream_set_return_partial_line(input->input, TRUE); @@ -217,10 +217,8 @@ str_append(str, key); str_append_c(str, '='); str_append(str, line); - if (ignore > 0) { - /* ignore this setting */ - } else if (pathlen == 0 && - strncmp(str_c(str), "auth_", 5) == 0) { + if (pathlen == 0 && + strncmp(str_c(str), "auth_", 5) == 0) { /* verify that the setting is valid, but delay actually adding it */ const char *s = t_strdup(str_c(str) + 5); @@ -252,11 +250,8 @@ if (*line != '{') errormsg = "Expecting '='"; - else if (ignore > 0) { - ignore++; - } else if (strcmp(key, "protocol") == 0) { + if (strcmp(key, "protocol") == 0) { array_append(&pathlen_stack, &pathlen, 1); - ignore = strcmp(name, service) != 0; } else { array_append(&pathlen_stack, &pathlen, 1); @@ -317,9 +312,6 @@ unsigned int pathlen_count; const unsigned int *arr; - if (ignore > 0) - ignore--; - arr = array_get(&pathlen_stack, &pathlen_count); if (pathlen_count == 0) errormsg = "Unexpected '}'";
--- a/src/config/config-parser.h Tue May 05 15:28:26 2009 -0400 +++ b/src/config/config-parser.h Tue May 05 15:33:44 2009 -0400 @@ -1,6 +1,6 @@ #ifndef CONFIG_PARSER_H #define CONFIG_PARSER_H -void config_parse_file(const char *path, const char *service); +void config_parse_file(const char *path); #endif
--- a/src/config/doveconf.c Tue May 05 15:28:26 2009 -0400 +++ b/src/config/doveconf.c Tue May 05 15:33:44 2009 -0400 @@ -180,7 +180,8 @@ char **exec_args = NULL; int c; - service = master_service_init("config", 0, argc, argv); + service = master_service_init("config", MASTER_SERVICE_FLAG_STANDALONE, + argc, argv); getopt_str = t_strconcat("anp:e", master_service_getopt_string(), NULL); while ((c = getopt(argc, argv, getopt_str)) > 0) { @@ -202,12 +203,9 @@ } if (argv[optind] != NULL) exec_args = &argv[optind]; - - master_service_init_log(service, "doveconf: ", 0); master_service_init_finish(service); - config_parse_file(master_service_get_config_path(service), - service_name); + config_parse_file(master_service_get_config_path(service)); if (exec_args == NULL) config_dump_human(service_name, flags);
--- a/src/config/main.c Tue May 05 15:28:26 2009 -0400 +++ b/src/config/main.c Tue May 05 15:33:44 2009 -0400 @@ -13,12 +13,6 @@ static struct master_service *service; -static void main_init(const char *service_name) -{ - config_parse_file(master_service_get_config_path(service), - service_name); -} - static void client_connected(const struct master_service_connection *conn) { config_connection_create(conn->fd); @@ -26,31 +20,17 @@ int main(int argc, char *argv[]) { - const char *getopt_str, *service_name = ""; - char **exec_args = NULL; int c; service = master_service_init("config", 0, argc, argv); + while ((c = getopt(argc, argv, master_service_getopt_string())) > 0) { + if (!master_service_parse_option(service, c, optarg)) + exit(FATAL_DEFAULT); + } - getopt_str = t_strconcat("anp:e", master_service_getopt_string(), NULL); - while ((c = getopt(argc, argv, getopt_str)) > 0) { - if (c == 'e') - break; - switch (c) { - case 'p': - service_name = optarg; - break; - default: - if (!master_service_parse_option(service, c, optarg)) - exit(FATAL_DEFAULT); - } - } - if (argv[optind] != NULL) - exec_args = &argv[optind]; - - master_service_init_log(service, "doveconf: ", 0); + master_service_init_log(service, "config: ", 0); master_service_init_finish(service); - main_init(service_name); + config_parse_file(master_service_get_config_path(service)); master_service_run(service, client_connected); config_connections_destroy_all();