]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: Change config_request_callback_t() to have a struct parameter
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 22 May 2023 19:40:05 +0000 (22:40 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:22:31 +0000 (14:22 +0200)
src/config/config-dump-full.c
src/config/config-request.c
src/config/config-request.h
src/config/doveconf.c

index b68b79f7cc6398f92af0b76463b2da6703bd5b29..da4add212abd0a28239907b8f908e2d6d5b34573 100644 (file)
@@ -154,8 +154,7 @@ config_dump_full_write_filter(struct ostream *output,
 }
 
 static void
-config_dump_full_stdout_callback(const char *key, const char *value,
-                                enum config_key_type type ATTR_UNUSED,
+config_dump_full_stdout_callback(const struct config_export_setting *set,
                                 void *context)
 {
        struct dump_context *ctx = context;
@@ -167,12 +166,11 @@ config_dump_full_stdout_callback(const char *key, const char *value,
        }
        T_BEGIN {
                o_stream_nsend_str(ctx->output, t_strdup_printf(
-                       "%s=%s\n", key, str_tabescape(value)));
+                       "%s=%s\n", set->key, str_tabescape(set->value)));
        } T_END;
 }
 
-static void config_dump_full_callback(const char *key, const char *value,
-                                     enum config_key_type type ATTR_UNUSED,
+static void config_dump_full_callback(const struct config_export_setting *set,
                                      void *context)
 {
        struct dump_context *ctx = context;
@@ -187,17 +185,19 @@ static void config_dump_full_callback(const char *key, const char *value,
                ctx->filter_written = TRUE;
        }
        if (ctx->delayed_output != NULL &&
-           ((str_begins(key, "passdb", &suffix) &&
+           ((str_begins(set->key, "passdb", &suffix) &&
              (suffix[0] == '\0' || suffix[0] == '/')) ||
-            (str_begins(key, "userdb", &suffix) &&
+            (str_begins(set->key, "userdb", &suffix) &&
              (suffix[0] == '\0' || suffix[0] == '/')))) {
                /* For backwards compatibility: global passdbs and userdbs are
                   added after per-protocol ones, not before. */
-               str_append_data(ctx->delayed_output, key, strlen(key)+1);
-               str_append_data(ctx->delayed_output, value, strlen(value)+1);
+               str_append_data(ctx->delayed_output, set->key,
+                               strlen(set->key)+1);
+               str_append_data(ctx->delayed_output, set->value,
+                               strlen(set->value)+1);
        } else {
-               o_stream_nsend(ctx->output, key, strlen(key)+1);
-               o_stream_nsend(ctx->output, value, strlen(value)+1);
+               o_stream_nsend(ctx->output, set->key, strlen(set->key)+1);
+               o_stream_nsend(ctx->output, set->value, strlen(set->value)+1);
        }
 }
 
index 7804a35ed6d5a76b0de5354367112ae3c13a69a8..92ed46db99736fa063d5800b0bdeb4fff1d276e1 100644 (file)
@@ -267,7 +267,12 @@ settings_export(struct config_export_context *ctx,
                                hash_table_insert(ctx->keys, def->key, def->key);
 
                        /* for doveconf -n to see this KEY_LIST */
-                       ctx->callback(def->key, "", CONFIG_KEY_LIST, ctx->context);
+                       struct config_export_setting export_set = {
+                               .type = CONFIG_KEY_LIST,
+                               .key = def->key,
+                               .value = "",
+                       };
+                       ctx->callback(&export_set, ctx->context);
 
                        strings = array_get(val, &count);
                        i_assert(count % 2 == 0);
@@ -276,8 +281,12 @@ settings_export(struct config_export_context *ctx,
                                                      def->key,
                                                      SETTINGS_SEPARATOR,
                                                      strings[i]);
-                               ctx->callback(str, strings[i+1],
-                                             CONFIG_KEY_NORMAL, ctx->context);
+                               struct config_export_setting export_set = {
+                                       .type = CONFIG_KEY_NORMAL,
+                                       .key = str,
+                                       .value = strings[i+1],
+                               };
+                               ctx->callback(&export_set, ctx->context);
                        } T_END;
                        break;
                }
@@ -309,8 +318,12 @@ settings_export(struct config_export_context *ctx,
                                        type = CONFIG_KEY_FILTER_ARRAY;
                                else
                                        type = CONFIG_KEY_NORMAL;
-                               ctx->callback(def->key, str_c(ctx->value), type,
-                                       ctx->context);
+                               struct config_export_setting export_set = {
+                                       .type = type,
+                                       .key = def->key,
+                                       .value = str_c(ctx->value),
+                               };
+                               ctx->callback(&export_set, ctx->context);
                                if ((ctx->flags & CONFIG_DUMP_FLAG_DEDUPLICATE_KEYS) != 0)
                                        hash_table_insert(ctx->keys, def->key, def->key);
                        }
index d0394bd1625a1fd45b9dac245cedc6c99cd4ce11..7a80bce667aaee8655fc8da979b1fbf5c10c690c 100644 (file)
@@ -30,8 +30,14 @@ enum config_key_type {
        CONFIG_KEY_FILTER_ARRAY,
 };
 
-typedef void config_request_callback_t(const char *key, const char *value,
-                                      enum config_key_type type, void *context);
+struct config_export_setting {
+       enum config_key_type type;
+       const char *key;
+       const char *value;
+};
+
+typedef void config_request_callback_t(const struct config_export_setting *set,
+                                      void *context);
 
 bool config_export_type(string_t *str, const void *value,
                        const void *default_value,
index f624b7448afffa6518689ee0e506550c4b5960bf..1e9e3dd309d5ee4d19a09a41d954fc4c92f8a4fb 100644 (file)
@@ -58,18 +58,19 @@ static const char *const secrets[] = {
 
 
 static void
-config_request_get_strings(const char *key, const char *value,
-                          enum config_key_type type, void *context)
+config_request_get_strings(const struct config_export_setting *set,
+                          void *context)
 {
        struct config_dump_human_context *ctx = context;
+       const char *value;
 
-       switch (type) {
+       switch (set->type) {
        case CONFIG_KEY_NORMAL:
-               value = p_strdup_printf(ctx->pool, "%s=%s", key, value);
+               value = p_strdup_printf(ctx->pool, "%s=%s", set->key, set->value);
                break;
        case CONFIG_KEY_LIST:
                value = p_strdup_printf(ctx->pool, LIST_KEY_PREFIX"%s=%s",
-                                       key, value);
+                                       set->key, set->value);
                break;
        case CONFIG_KEY_FILTER_ARRAY:
                return;