]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Replace config_export_dup_module_parsers() with config_export_set_module_pars...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 15 May 2023 21:12:02 +0000 (00:12 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:21:56 +0000 (14:21 +0200)
Now that settings checks are done while parsing the config, the parsers no
longer change afterwards so there is no need to duplicate them.

src/config/config-dump-full.c
src/config/config-request.c
src/config/config-request.h
src/config/doveconf.c

index 441aa23eb658d098edfc0ea4c97a44ccb216219e..3fb2802e5faa49317df42cec618bdb9f1786ebf5 100644 (file)
@@ -282,7 +282,9 @@ int config_dump_full(struct config_parsed *config,
                                CONFIG_DUMP_SCOPE_CHANGED, flags,
                                config_dump_full_callback, &dump_ctx);
        }
-       config_export_dup_module_parsers(export_ctx, config);
+       struct config_filter_parser *filter_parser =
+               config_parsed_get_global_filter_parser(config);
+       config_export_set_module_parsers(export_ctx, filter_parser->module_parsers);
 
        string_t *path = t_str_new(128);
        const char *final_path = NULL;
index 0f83c3f14471859a92192214f95954ac10304e79..d49bbcf44a24b9f7217b4432e69b0362f80254b1 100644 (file)
@@ -25,7 +25,6 @@ struct config_export_context {
 
        enum config_dump_flags flags;
        const struct config_module_parser *module_parsers;
-       struct config_module_parser *dup_module_parsers;
        unsigned int section_idx;
 };
 
@@ -398,33 +397,6 @@ config_export_init(enum config_dump_scope scope,
        return ctx;
 }
 
-static struct config_module_parser *
-config_filter_parsers_dup(pool_t pool, struct config_filter_parser *global_filter)
-{
-       struct config_module_parser *dest;
-       unsigned int i, count;
-
-       for (count = 0; global_filter->module_parsers[count].root != NULL; count++) ;
-       dest = p_new(pool, struct config_module_parser, count + 1);
-       for (i = 0; i < count; i++) {
-               dest[i] = global_filter->module_parsers[i];
-               dest[i].parser =
-                       settings_parser_dup(global_filter->module_parsers[i].parser, pool);
-       }
-       return dest;
-}
-
-void config_export_dup_module_parsers(struct config_export_context *ctx,
-                                     struct config_parsed *config)
-{
-       struct config_filter_parser *global_filter =
-               config_parsed_get_global_filter_parser(config);
-
-       ctx->dup_module_parsers =
-               config_filter_parsers_dup(ctx->pool, global_filter);
-       ctx->module_parsers = ctx->dup_module_parsers;
-}
-
 void config_export_set_module_parsers(struct config_export_context *ctx,
                                      const struct config_module_parser *module_parsers)
 {
@@ -479,8 +451,6 @@ void config_export_free(struct config_export_context **_ctx)
 
        *_ctx = NULL;
 
-       if (ctx->dup_module_parsers != NULL)
-               config_module_parsers_free(ctx->dup_module_parsers);
        hash_table_destroy(&ctx->keys);
        pool_unref(&ctx->pool);
 }
index 0c0b07085116ab61a1c6d88f5a33bd8537575e68..8e7591879aeed48d022eca5b85e46cdfae09b4cf 100644 (file)
@@ -40,8 +40,6 @@ config_export_init(enum config_dump_scope scope,
                   enum config_dump_flags flags,
                   config_request_callback_t *callback, void *context)
        ATTR_NULL(1, 5);
-void config_export_dup_module_parsers(struct config_export_context *ctx,
-                                     struct config_parsed *config);
 void config_export_set_module_parsers(struct config_export_context *ctx,
                                      const struct config_module_parser *parsers);
 unsigned int config_export_get_parser_count(struct config_export_context *ctx);
index 2759eda3d249cd5fe359aabc717e72fdb554eaa2..f86938eb248ea8e2e1aa0161160501ed100d437e 100644 (file)
@@ -574,7 +574,10 @@ config_dump_human(enum config_dump_scope scope, const char *setting_name_filter,
        o_stream_cork(output);
 
        ctx = config_dump_human_init(scope);
-       config_export_dup_module_parsers(ctx->export_ctx, config);
+       struct config_filter_parser *filter_parser =
+               config_parsed_get_global_filter_parser(config);
+       config_export_set_module_parsers(ctx->export_ctx,
+                                        filter_parser->module_parsers);
        config_dump_human_output(ctx, output, 0, setting_name_filter, hide_passwords);
        config_dump_human_deinit(ctx);
 
@@ -603,7 +606,10 @@ config_dump_one(bool hide_key,
        bool dump_section = FALSE;
 
        ctx = config_dump_human_init(scope);
-       config_export_dup_module_parsers(ctx->export_ctx, config);
+       struct config_filter_parser *filter_parser =
+               config_parsed_get_global_filter_parser(config);
+       config_export_set_module_parsers(ctx->export_ctx,
+                                        filter_parser->module_parsers);
        if (config_export_all_parsers(&ctx->export_ctx, &section_idx) < 0)
                i_unreached(); /* settings aren't checked - this can't happen */
 
@@ -968,7 +974,9 @@ int main(int argc, char *argv[])
                ctx = config_export_init(scope, 0,
                                         config_request_simple_stdout,
                                         setting_name_filters);
-               config_export_dup_module_parsers(ctx, config);
+               struct config_filter_parser *filter_parser =
+                       config_parsed_get_global_filter_parser(config);
+               config_export_set_module_parsers(ctx, filter_parser->module_parsers);
                if (config_export_all_parsers(&ctx, &section_idx) < 0)
                        i_unreached();
                ret2 = 0;