]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added settings_parse_unalias().
authorTimo Sirainen <tss@iki.fi>
Mon, 5 Apr 2010 00:56:46 +0000 (03:56 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 5 Apr 2010 00:56:46 +0000 (03:56 +0300)
--HG--
branch : HEAD

src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h

index 7b24ca3c7f5177b58f8c239afd32bb39b46f777b..889e63961f8017845a173cbc89979d6a7e4a16e9 100644 (file)
@@ -714,6 +714,22 @@ bool settings_parse_is_valid_key(struct setting_parser_context *ctx,
        return settings_find_key(ctx, key, &def, &link);
 }
 
+const char *settings_parse_unalias(struct setting_parser_context *ctx,
+                                  const char *key)
+{
+       const struct setting_define *def;
+       struct setting_link *link;
+
+       if (!settings_find_key(ctx, key, &def, &link))
+               return NULL;
+
+       while (def->type == SET_ALIAS) {
+               i_assert(def != link->info->defines);
+               def--;
+       }
+       return def->key;
+}
+
 const void *
 settings_parse_get_value(struct setting_parser_context *ctx,
                         const char *key, enum setting_type *type_r)
index abc7522634535a083d60bff190c2e58718725f88..583632d201c5dcd63a790e5eb63f9ff6f3699860 100644 (file)
@@ -124,6 +124,10 @@ settings_parse_get_prev_info(struct setting_parser_context *ctx);
 /* Returns TRUE if the given key is a valid setting. */
 bool settings_parse_is_valid_key(struct setting_parser_context *ctx,
                                 const char *key);
+/* If key is an alias, return the primary key name. If key exists, return key
+   itself. If key doesn't exist, return NULL. */
+const char *settings_parse_unalias(struct setting_parser_context *ctx,
+                                  const char *key);
 /* Returns pointer to value for a key, or NULL if not found. */
 const void *
 settings_parse_get_value(struct setting_parser_context *ctx,