From: Timo Sirainen Date: Thu, 21 Mar 2024 22:25:18 +0000 (+0200) Subject: lib-dict: Add dict_init_filter_auto() X-Git-Tag: 2.4.1~806 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f3ebb43e8aced98b021084bca9e82f9edd8eaed;p=thirdparty%2Fdovecot%2Fcore.git lib-dict: Add dict_init_filter_auto() --- diff --git a/src/lib-dict/dict.c b/src/lib-dict/dict.c index 5c8c75ccab..c23644d57a 100644 --- a/src/lib-dict/dict.c +++ b/src/lib-dict/dict.c @@ -181,9 +181,7 @@ static bool dict_settings_check(void *_set, pool_t pool ATTR_UNUSED, int dict_init_auto(struct event *event, struct dict **dict_r, const char **error_r) { - const struct dict *dict_driver; struct dict_settings *dict_set; - const char *error; i_assert(event != NULL); @@ -209,10 +207,21 @@ int dict_init_auto(struct event *event, struct dict **dict_r, return -1; } + int ret = dict_init_filter_auto(event, dict_name_first, dict_r, error_r); + settings_free(dict_set); + return ret; +} + +int dict_init_filter_auto(struct event *event, const char *dict_name, + struct dict **dict_r, const char **error_r) +{ + struct dict_settings *dict_set; + const struct dict *dict_driver; + const char *error; + /* Get settings for the first dict list filter */ event = event_create(event); - event_add_str(event, "dict", dict_name_first); - settings_free(dict_set); + event_add_str(event, "dict", dict_name); if (settings_get(event, &dict_setting_parser_info, 0, &dict_set, error_r) < 0) { event_unref(&event); diff --git a/src/lib-dict/dict.h b/src/lib-dict/dict.h index 6e57aed7b4..53a89f2f52 100644 --- a/src/lib-dict/dict.h +++ b/src/lib-dict/dict.h @@ -115,6 +115,10 @@ int dict_init_legacy(const char *uri, const struct dict_legacy_settings *set, driver initialization failed. */ int dict_init_auto(struct event *event, struct dict **dict_r, const char **error_r); +/* Initialize a specific named dict. This is intended to be used only by the + dict server. */ +int dict_init_filter_auto(struct event *event, const char *dict_name, + struct dict **dict_r, const char **error_r); /* Close dictionary. */ void dict_deinit(struct dict **dict); /* Wait for all pending asynchronous operations to finish. */