ctx->str_vars_are_expanded = is_expanded;
}
+void settings_parse_set_key_expandeded(struct setting_parser_context *ctx,
+ pool_t pool, const char *key)
+{
+ const struct setting_define *def;
+ struct setting_link *link;
+ const char **val;
+
+ if (!settings_find_key(ctx, key, &def, &link))
+ return;
+
+ val = PTR_OFFSET(link->set_struct, def->offset);
+ if (def->type == SET_STR_VARS && *val != NULL) {
+ i_assert(**val == SETTING_STRVAR_UNEXPANDED[0] ||
+ **val == SETTING_STRVAR_EXPANDED[0]);
+ *val = p_strconcat(pool, SETTING_STRVAR_EXPANDED,
+ *val + 1, NULL);
+ }
+}
+
+void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
+ pool_t pool, const char *const *keys)
+{
+ for (; *keys != NULL; keys++)
+ settings_parse_set_key_expandeded(ctx, pool, *keys);
+}
+
+void settings_parse_var_skip(struct setting_parser_context *ctx)
+{
+ unsigned int i;
+
+ for (i = 0; i < ctx->root_count; i++) {
+ settings_var_expand(ctx->roots[i].info,
+ ctx->roots[i].set_struct, NULL, NULL);
+ }
+}
+
static void
settings_var_expand_info(const struct setting_parser_info *info,
pool_t pool, void *set,
if (*val == NULL)
break;
- if (**val == SETTING_STRVAR_UNEXPANDED[0]) {
+ if (table == NULL) {
+ i_assert(**val == SETTING_STRVAR_EXPANDED[0] ||
+ **val == SETTING_STRVAR_UNEXPANDED[0]);
+ *val += 1;
+ } else if (**val == SETTING_STRVAR_UNEXPANDED[0]) {
str_truncate(str, 0);
var_expand(str, *val + 1, table);
*val = p_strdup(pool, str_c(str));
}
}
-void settings_parse_set_key_expandeded(struct setting_parser_context *ctx,
- pool_t pool, const char *key)
-{
- const struct setting_define *def;
- struct setting_link *link;
- const char **val;
-
- if (!settings_find_key(ctx, key, &def, &link))
- return;
-
- val = PTR_OFFSET(link->set_struct, def->offset);
- if (def->type == SET_STR_VARS && *val != NULL) {
- i_assert(**val == SETTING_STRVAR_UNEXPANDED[0] ||
- **val == SETTING_STRVAR_EXPANDED[0]);
- *val = p_strconcat(pool, SETTING_STRVAR_EXPANDED,
- *val + 1, NULL);
- }
-}
-
-void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
- pool_t pool, const char *const *keys)
-{
- for (; *keys != NULL; keys++)
- settings_parse_set_key_expandeded(ctx, pool, *keys);
-}
-
void settings_var_expand(const struct setting_parser_info *info,
void *set, pool_t pool,
const struct var_expand_table *table)
pool_t pool, const char *key);
void settings_parse_set_keys_expandeded(struct setting_parser_context *ctx,
pool_t pool, const char *const *keys);
+/* Update variable string pointers to skip over the '1' or '0'.
+ This is mainly useful when you want to run settings_parser_check() without
+ actually knowing what the variables are. */
+void settings_parse_var_skip(struct setting_parser_context *ctx);
/* Expand all unexpanded variables using the given table. Update the string
pointers so that they can be used without skipping over the '1'. */
void settings_var_expand(const struct setting_parser_info *info,