struct config_export_context *export_ctx;
int ret = 0;
- struct config_filter empty_filter;
- i_zero(&empty_filter);
- filters = config_filter_find_subset(config_filter, &empty_filter);
+ filters = config_filter_find_subset(config_filter);
/* first filter should be the global one */
i_assert(filters[0] != NULL && filters[0]->filter.service == NULL);
const char **import_environment_r)
{
struct config_export_context *export_ctx;
- struct config_filter empty_filter;
const char *error;
unsigned int section_idx = 0;
int fd = -1;
CONFIG_DUMP_SCOPE_CHANGED, flags,
config_dump_full_callback, &dump_ctx);
}
- i_zero(&empty_filter);
- if (config_export_by_filter(export_ctx, config_filter, &empty_filter) < 0) {
+ if (config_export_by_filter(export_ctx, config_filter) < 0) {
config_export_free(&export_ctx);
str_free(&dump_ctx.delayed_output);
return -1;
}
struct ostream *output = dump_ctx.output;
- i_zero(&empty_filter);
o_stream_cork(output);
*import_environment_r =
}
static struct config_filter_parser *const *
-config_filter_find_all(struct config_filter_context *ctx, pool_t pool,
- const struct config_filter *filter)
+config_filter_find_all(struct config_filter_context *ctx, pool_t pool)
{
ARRAY_TYPE(config_filter_parsers) matches;
- unsigned int i;
p_array_init(&matches, pool, 8);
- for (i = 0; ctx->parsers[i] != NULL; i++) {
- const struct config_filter *mask = &ctx->parsers[i]->filter;
-
- if (!config_filter_match_service(mask, filter))
- continue;
-
- if (config_filter_match_rest(mask, filter))
- array_push_back(&matches, &ctx->parsers[i]);
- }
+ array_push_back(&matches, &ctx->parsers[0]);
array_sort(&matches, config_filter_parser_cmp);
array_append_zero(&matches);
}
struct config_filter_parser *const *
-config_filter_find_subset(struct config_filter_context *ctx,
- const struct config_filter *filter)
+config_filter_find_subset(struct config_filter_context *ctx)
{
ARRAY_TYPE(config_filter_parsers) matches;
- struct config_filter tmp_mask;
unsigned int i;
t_array_init(&matches, 8);
- for (i = 0; ctx->parsers[i] != NULL; i++) {
- const struct config_filter *mask = &ctx->parsers[i]->filter;
-
- if (filter->service != NULL) {
- if (!config_filter_match_service(mask, filter))
- continue;
- }
-
- tmp_mask = *mask;
- if (filter->local_name == NULL)
- tmp_mask.local_name = NULL;
- if (filter->local_bits == 0)
- tmp_mask.local_bits = 0;
- if (filter->remote_bits == 0)
- tmp_mask.remote_bits = 0;
+ for (i = 0; ctx->parsers[i] != NULL; i++)
+ array_push_back(&matches, &ctx->parsers[i]);
- if (config_filter_match_rest(&tmp_mask, filter))
- array_push_back(&matches, &ctx->parsers[i]);
- }
array_sort(&matches, config_filter_parser_cmp_rev);
array_append_zero(&matches);
return array_front(&matches);
}
int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool,
- const struct config_filter *filter,
struct config_module_parser **parsers_r,
const char **error_r)
{
with an error. Merging SET_STRLIST types requires
settings_parser_apply_changes() to work a bit unintuitively by
letting the destination settings override the source settings. */
- src = config_filter_find_all(ctx, pool, filter);
+ src = config_filter_find_all(ctx, pool);
/* all of them should have the same number of parsers.
duplicate our initial parsers from the first match */
/* Build new parsers from all existing ones matching the given filter. */
int config_filter_parsers_get(struct config_filter_context *ctx, pool_t pool,
- const struct config_filter *filter,
struct config_module_parser **parsers_r,
const char **error_r) ATTR_NULL(3);
void config_filter_parsers_free(struct config_module_parser *parsers);
/* Return a list of filters that are a subset of the given filter. */
struct config_filter_parser *const *
-config_filter_find_subset(struct config_filter_context *ctx,
- const struct config_filter *filter);
+config_filter_find_subset(struct config_filter_context *ctx);
/* Returns TRUE if filter matches mask. */
bool config_filter_match(const struct config_filter *mask,
}
int config_export_by_filter(struct config_export_context *ctx,
- struct config_filter_context *config_filter,
- const struct config_filter *filter)
+ struct config_filter_context *config_filter)
{
const char *error;
- if (config_filter_parsers_get(config_filter, ctx->pool, filter,
+ if (config_filter_parsers_get(config_filter, ctx->pool,
&ctx->dup_parsers, &error) < 0) {
i_error("%s", error);
return -1;
config_request_callback_t *callback, void *context)
ATTR_NULL(1, 5);
int config_export_by_filter(struct config_export_context *ctx,
- struct config_filter_context *config_filter,
- const struct config_filter *filter);
+ struct config_filter_context *config_filter);
void config_export_set_parsers(struct config_export_context *ctx,
const struct config_module_parser *parsers);
unsigned int config_export_get_parser_count(struct config_export_context *ctx);
config_dump_human_sections(struct ostream *output,
bool hide_passwords)
{
- struct config_filter empty_filter = {};
struct config_filter_parser *const *filters;
struct config_dump_human_context *ctx;
unsigned int indent;
- filters = config_filter_find_subset(config_filter, &empty_filter);
+ filters = config_filter_find_subset(config_filter);
/* first filter should be the global one */
i_assert(filters[0] != NULL && filters[0]->filter.service == NULL);
bool hide_passwords)
{
struct config_dump_human_context *ctx;
- struct config_filter empty_filter = {};
struct ostream *output;
const char *str;
int ret = 0;
o_stream_cork(output);
ctx = config_dump_human_init(scope);
- if ((ret = config_export_by_filter(ctx->export_ctx, config_filter, &empty_filter)) < 0)
+ if ((ret = config_export_by_filter(ctx->export_ctx, config_filter)) < 0)
config_export_free(&ctx->export_ctx);
else
config_dump_human_output(ctx, output, 0, setting_name_filter, hide_passwords);
bool hide_passwords)
{
struct config_dump_human_context *ctx;
- struct config_filter empty_filter = {};
const char *str;
size_t len;
unsigned int section_idx = 0;
bool dump_section = FALSE;
ctx = config_dump_human_init(scope);
- if (config_export_by_filter(ctx->export_ctx, config_filter, &empty_filter) < 0) {
+ if (config_export_by_filter(ctx->export_ctx, config_filter) < 0) {
config_export_free(&ctx->export_ctx);
return -1;
}
ret2 = -1;
} else if (simple_output) {
struct config_export_context *ctx;
- struct config_filter empty_filter = {};
unsigned int section_idx = 0;
ctx = config_export_init(scope, 0,
config_request_simple_stdout,
setting_name_filters);
- if ((ret2 = config_export_by_filter(ctx, config_filter,
- &empty_filter)) < 0)
+ if ((ret2 = config_export_by_filter(ctx, config_filter)) < 0)
config_export_free(&ctx);
else {
if (config_export_all_parsers(&ctx, §ion_idx) < 0)