From: Timo Sirainen Date: Sun, 2 Mar 2025 08:43:58 +0000 (+0200) Subject: config: Pass dovecot_config_version to config_export_init() X-Git-Tag: 2.4.1~114 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2a712574fd30e9b9c4bf040fddbc9421293d582b;p=thirdparty%2Fdovecot%2Fcore.git config: Pass dovecot_config_version to config_export_init() Simplifies the next commit. --- diff --git a/src/config/config-dump-full.c b/src/config/config-dump-full.c index ec7f6b27ed..2032fa2415 100644 --- a/src/config/config-dump-full.c +++ b/src/config/config-dump-full.c @@ -448,6 +448,7 @@ config_dump_full_handle_error(struct dump_context *dump_ctx, struct config_dump_full_context { struct config_parsed *config; + const char *dovecot_config_version; struct ostream *output; enum config_dump_full_dest dest; @@ -536,12 +537,12 @@ config_dump_full_sections(struct config_dump_full_context *ctx, if (dest == CONFIG_DUMP_FULL_DEST_STDOUT) { export_ctx = config_export_init( CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES, - 0, + 0, ctx->dovecot_config_version, config_dump_full_stdout_callback, &dump_ctx); } else { export_ctx = config_export_init( CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES, - 0, + 0, ctx->dovecot_config_version, config_dump_full_callback, &dump_ctx); } config_export_set_module_parsers(export_ctx, @@ -606,22 +607,26 @@ int config_dump_full(struct config_parsed *config, const char **import_environment_r) { struct config_export_context *export_ctx; - const char *error; + const char *dovecot_config_version, *error; int fd = -1; struct dump_context dump_ctx = { .delayed_output = str_new(default_pool, 256), }; + if (!config_parsed_get_version(config, &dovecot_config_version)) + dovecot_config_version = ""; + if (dest == CONFIG_DUMP_FULL_DEST_STDOUT) { export_ctx = config_export_init( CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES, - flags, config_dump_full_stdout_callback, - &dump_ctx); + flags, dovecot_config_version, + config_dump_full_stdout_callback, &dump_ctx); } else { export_ctx = config_export_init( CONFIG_DUMP_SCOPE_SET_AND_DEFAULT_OVERRIDES, - flags, config_dump_full_callback, &dump_ctx); + flags, dovecot_config_version, + config_dump_full_callback, &dump_ctx); } struct config_filter_parser *filter_parser = config_parsed_get_global_filter_parser(config); @@ -686,6 +691,7 @@ int config_dump_full(struct config_parsed *config, struct config_dump_full_context ctx = { .config = config, + .dovecot_config_version = dovecot_config_version, .output = output, .dest = dest, .filters = config_parsed_get_filter_parsers(config), diff --git a/src/config/config-request.c b/src/config/config-request.c index 0fe6ded4d7..2eeb80aeba 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -18,6 +18,7 @@ struct config_export_context { string_t *value; HASH_TABLE(const char *, const char *) keys; enum config_dump_scope scope; + const char *dovecot_config_version; config_request_callback_t *callback; void *context; @@ -362,6 +363,7 @@ settings_export(struct config_export_context *ctx, struct config_export_context * config_export_init(enum config_dump_scope scope, enum config_dump_flags flags, + const char *dovecot_config_version, config_request_callback_t *callback, void *context) { struct config_export_context *ctx; @@ -375,6 +377,7 @@ config_export_init(enum config_dump_scope scope, ctx->callback = callback; ctx->context = context; ctx->scope = scope; + ctx->dovecot_config_version = p_strdup(pool, dovecot_config_version); ctx->value = str_new(pool, 256); if ((ctx->flags & CONFIG_DUMP_FLAG_DEDUPLICATE_KEYS) != 0) hash_table_create(&ctx->keys, ctx->pool, 0, str_hash, strcmp); diff --git a/src/config/config-request.h b/src/config/config-request.h index 8d7c463fb0..72951a055b 100644 --- a/src/config/config-request.h +++ b/src/config/config-request.h @@ -53,10 +53,11 @@ bool config_export_type(string_t *str, const void *value, struct config_export_context * config_export_init(enum config_dump_scope scope, enum config_dump_flags flags, + const char *dovecot_config_version, config_request_callback_t *callback, void *context) ATTR_NULL(1, 5); -#define config_export_init(scope, flags, callback, context) \ - config_export_init(scope, flags, \ +#define config_export_init(scope, flags, version, callback, context) \ + config_export_init(scope, flags, version, \ (config_request_callback_t *)callback, \ TRUE ? context : CALLBACK_TYPECHECK(callback, \ void (*)(const struct config_export_setting *, typeof(context)))) diff --git a/src/config/doveconf.c b/src/config/doveconf.c index 951656ccd6..ad0d1b4c5d 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -175,8 +175,12 @@ config_dump_human_init(enum config_dump_scope scope, { struct config_dump_human_context *ctx; enum config_dump_flags flags; + const char *dovecot_config_version; pool_t pool; + if (!config_parsed_get_version(config, &dovecot_config_version)) + dovecot_config_version = ""; + pool = pool_alloconly_create(MEMPOOL_GROWING"config human strings", 1024*32); ctx = p_new(pool, struct config_dump_human_context, 1); ctx->pool = pool; @@ -185,6 +189,7 @@ config_dump_human_init(enum config_dump_scope scope, flags = CONFIG_DUMP_FLAG_DEDUPLICATE_KEYS; ctx->export_ctx = config_export_init(scope, flags, + dovecot_config_version, config_request_get_strings, ctx); config_export_set_module_parsers(ctx->export_ctx, filter_parser->module_parsers);