virtual-config.c revision 8536cd46be13bc18aa538b279d7fdba7d54e268f
5e0ce63bb65db34d7f48b34bbb5545fa791781c4Timo Sirainen/* Copyright (c) 2008-2013 Dovecot authors, see the included COPYING file */
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvirtual_search_args_parse(const string_t *rule, const char **error_r)
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen input = i_stream_create_from_data(str_data(rule), str_len(rule));
a3ea111cfdbfd4f32baeb0bd7f1d72568c60a023Timo Sirainen imap_parser = imap_parser_create(input, NULL, (size_t)-1);
a3ea111cfdbfd4f32baeb0bd7f1d72568c60a023Timo Sirainen ret = imap_parser_finish_line(imap_parser, 0, 0, &args);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen *error_r = t_strdup(imap_parser_get_error(imap_parser, &fatal));
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen if (mail_search_build(mail_search_register_get_imap(),
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainenvirtual_config_add_rule(struct virtual_parse_context *ctx, const char **error_r)
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen unsigned int i, count;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen if (ctx->rule_idx == array_count(&ctx->mbox->backend_boxes)) {
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen crc32_str_more(ctx->mbox->search_args_crc32, str_c(ctx->rule));
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen search_args = virtual_search_args_parse(ctx->rule, error_r);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen *error_r = t_strconcat("Previous search rule is invalid: ",
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen /* update at all the mailboxes that were introduced since the previous
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen bboxes = array_get(&ctx->mbox->backend_boxes, &count);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen ctx->rule_idx = array_count(&ctx->mbox->backend_boxes);
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenvirtual_config_parse_line(struct virtual_parse_context *ctx, const char *line,
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen const char **error_r)
0c9754d1cf2ba0ff7873b6baa614ca10051a08fdTimo Sirainen struct mail_user *user = ctx->mbox->storage->storage.user;
6defed8fef1781cb1d34353784232e87c19f173bTimo Sirainen /* continues the previous search rule */
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen if (ctx->rule_idx == array_count(&ctx->mbox->backend_boxes)) {
6defed8fef1781cb1d34353784232e87c19f173bTimo Sirainen /* if there is no rule yet, it means we want the previous mailboxes
0c9754d1cf2ba0ff7873b6baa614ca10051a08fdTimo Sirainen to use the rule that comes later */
0c9754d1cf2ba0ff7873b6baa614ca10051a08fdTimo Sirainen if (virtual_config_add_rule(ctx, error_r) < 0)
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen /* new mailbox. the search args are added to it later. */
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen bbox = p_new(ctx->pool, struct virtual_backend_box, 1);
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen if (*line == '-' || *line == '+' || *line == '!') line++;
33ca6b017b6ebbd048651b5e3d16915001dbc291Timo Sirainen *error_r = t_strdup_printf("Mailbox name not UTF-8: %s",
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int i, count;
for (i = 0; i < count;) {
&count);
const char *name)
return TRUE;
return TRUE;
return FALSE;
unsigned int *idx_r)
unsigned int i, count;
for (i = 0; i < count; i++) {
*idx_r = i;
return TRUE;
*idx_r = i;
return TRUE;
return FALSE;
const char **patterns;
unsigned int i, j, count;
if (count == 0) {
for (i = 0; i < count; i++)
for (i = 0; i < count; i++)
unsigned int i, count;
for (i = 0; i < count; i++) {
unsigned int linenum = 0;
linenum++;
if (ret < 0) {
if (ret == 0) {
if (ret < 0) {
if (ret == 0)
return ret;
unsigned int i, count;
for (i = 0; i < count; i++) {