From: Timo Sirainen Date: Mon, 22 May 2023 19:40:05 +0000 (+0300) Subject: config: Change config_request_callback_t() to have a struct parameter X-Git-Tag: 2.4.0~1980 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ca41d240e893a9aa0b25e9d50079de2086d74aa;p=thirdparty%2Fdovecot%2Fcore.git config: Change config_request_callback_t() to have a struct parameter --- diff --git a/src/config/config-dump-full.c b/src/config/config-dump-full.c index b68b79f7cc..da4add212a 100644 --- a/src/config/config-dump-full.c +++ b/src/config/config-dump-full.c @@ -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); } } diff --git a/src/config/config-request.c b/src/config/config-request.c index 7804a35ed6..92ed46db99 100644 --- a/src/config/config-request.c +++ b/src/config/config-request.c @@ -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); } diff --git a/src/config/config-request.h b/src/config/config-request.h index d0394bd162..7a80bce667 100644 --- a/src/config/config-request.h +++ b/src/config/config-request.h @@ -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, diff --git a/src/config/doveconf.c b/src/config/doveconf.c index f624b7448a..1e9e3dd309 100644 --- a/src/config/doveconf.c +++ b/src/config/doveconf.c @@ -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;