dovecot-2.0: doveconf/config cleanups.
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 5 22:33:52 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/e5303fd61b5c
changeset: 9229:e5303fd61b5c
user: Timo Sirainen <tss at iki.fi>
date: Tue May 05 15:33:44 2009 -0400
description:
doveconf/config cleanups.
diffstat:
4 files changed, 16 insertions(+), 46 deletions(-)
src/config/config-parser.c | 20 ++++++--------------
src/config/config-parser.h | 2 +-
src/config/doveconf.c | 8 +++-----
src/config/main.c | 32 ++++++--------------------------
diffs (158 lines):
diff -r e91bca10d5a1 -r e5303fd61b5c src/config/config-parser.c
--- 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 @@ fix_relative_path(const char *path, stru
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 @@ void config_parse_file(const char *path,
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 @@ void config_parse_file(const char *path,
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 @@ prevfile:
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 @@ prevfile:
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 @@ prevfile:
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 '}'";
diff -r e91bca10d5a1 -r e5303fd61b5c src/config/config-parser.h
--- 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
diff -r e91bca10d5a1 -r e5303fd61b5c src/config/doveconf.c
--- 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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
}
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);
diff -r e91bca10d5a1 -r e5303fd61b5c src/config/main.c
--- 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 @@ static void client_connected(const struc
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();
More information about the dovecot-cvs
mailing list