From: Marco Bettini Date: Thu, 3 Oct 2024 13:42:47 +0000 (+0000) Subject: dict-ldap: dict_ldap_map_settings - Rename pattern to parsed_pattern X-Git-Tag: 2.4.0~150 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ea0203faf8ddd72ac5d083be2b4ddf416684e6c;p=thirdparty%2Fdovecot%2Fcore.git dict-ldap: dict_ldap_map_settings - Rename pattern to parsed_pattern --- diff --git a/src/lib-dict-backend/dict-ldap-settings.c b/src/lib-dict-backend/dict-ldap-settings.c index 51529c072b..2eb2209a28 100644 --- a/src/lib-dict-backend/dict-ldap-settings.c +++ b/src/lib-dict-backend/dict-ldap-settings.c @@ -43,7 +43,7 @@ struct setting_parser_ctx { #define DEF_UINT(name) DEF_STRUCT_UINT(name ,dict_ldap_map_settings) static const struct setting_def dict_ldap_map_setting_defs[] = { - DEF_STR(pattern), + DEF_STR(parsed_pattern), DEF_STR(filter), DEF_STR(username_attribute), DEF_STR(value_attribute), @@ -88,11 +88,11 @@ static const char *dict_ldap_attributes_map(struct setting_parser_ctx *ctx) /* go through the variables in the pattern, replace them with plain '$' character and add its ldap attribute */ - pattern = t_str_new(strlen(ctx->cur_map.pattern) + 1); + pattern = t_str_new(strlen(ctx->cur_map.parsed_pattern) + 1); attributes = array_get_modifiable(&ctx->cur_attributes, &count); p_array_init(&ctx->cur_map.parsed_pattern_keys, ctx->pool, count); - for (p = ctx->cur_map.pattern; *p != '\0';) { + for (p = ctx->cur_map.parsed_pattern; *p != '\0';) { if (*p != '$') { str_append_c(pattern, *p); p++; @@ -126,13 +126,13 @@ static const char *dict_ldap_attributes_map(struct setting_parser_ctx *ctx) } } - ctx->cur_map.pattern = p_strdup(ctx->pool, str_c(pattern)); + ctx->cur_map.parsed_pattern = p_strdup(ctx->pool, str_c(pattern)); return NULL; } static const char *dict_ldap_map_finish(struct setting_parser_ctx *ctx) { - if (ctx->cur_map.pattern == NULL) + if (ctx->cur_map.parsed_pattern == NULL) return "Missing setting: pattern"; if (ctx->cur_map.filter == NULL) ctx->cur_map.filter = dict_ldap_empty_filter; @@ -163,7 +163,7 @@ static const char *dict_ldap_map_finish(struct setting_parser_ctx *ctx) if (!array_is_created(&ctx->cur_map.parsed_pattern_keys)) { /* no attributes besides value. allocate the array anyway. */ p_array_init(&ctx->cur_map.parsed_pattern_keys, ctx->pool, 1); - if (strchr(ctx->cur_map.pattern, '$') != NULL) + if (strchr(ctx->cur_map.parsed_pattern, '$') != NULL) return "Missing attributes for pattern variables"; } array_push_back(&ctx->set->parsed_maps, &ctx->cur_map); diff --git a/src/lib-dict-backend/dict-ldap-settings.h b/src/lib-dict-backend/dict-ldap-settings.h index e75bb1bc2d..5f78fcee4e 100644 --- a/src/lib-dict-backend/dict-ldap-settings.h +++ b/src/lib-dict-backend/dict-ldap-settings.h @@ -2,9 +2,6 @@ #define DICT_LDAP_SETTINGS_H struct dict_ldap_map_settings { - /* pattern is in simplified form: all variables are stored as simple - '$' character. fields array is sorted by the variable index. */ - const char *pattern; const char *filter; const char *username_attribute; const char *value_attribute; @@ -15,6 +12,9 @@ struct dict_ldap_map_settings { /* parsed */ ARRAY_TYPE(const_string) parsed_pattern_keys; int parsed_scope; + + /* the variables are in the same order as parsed_pattern_keys. */ + const char *parsed_pattern; }; struct dict_ldap_settings { diff --git a/src/lib-dict-backend/dict-ldap.c b/src/lib-dict-backend/dict-ldap.c index 25b644d2a3..c051ec138e 100644 --- a/src/lib-dict-backend/dict-ldap.c +++ b/src/lib-dict-backend/dict-ldap.c @@ -65,7 +65,7 @@ dict_ldap_map_match(const struct dict_ldap_map_settings *map, const char *path, size_t len; array_clear(values); - pat = map->pattern; + pat = map->parsed_pattern; while (*pat != '\0' && *path != '\0') { if (*pat == '$') { /* variable */