virtual-config.c revision dd37e2ff291fbebac1b94e8aad50f3bdf7531049
/* Copyright (c) 2008-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "crc32.h"
#include "istream.h"
#include "str.h"
#include "unichar.h"
#include "imap-parser.h"
#include "imap-match.h"
#include "mail-namespace.h"
#include "mail-search-build.h"
#include "mail-search-parser.h"
#include "mailbox-list-iter.h"
#include "virtual-storage.h"
#include "virtual-plugin.h"
#include <unistd.h>
#include <fcntl.h>
struct virtual_parse_context {
struct virtual_mailbox *mbox;
unsigned int rule_idx;
char sep;
bool have_wildcards;
bool have_mailbox_defines;
};
static struct mail_search_args *
{
struct imap_parser *imap_parser;
struct mail_search_parser *parser;
struct mail_search_args *sargs;
const char *charset = "UTF-8";
bool fatal;
int ret;
return sargs;
}
(void)i_stream_read(input);
if (ret < 0) {
} else {
}
return sargs;
}
static int
{
struct virtual_backend_box *const *bboxes;
struct mail_search_args *search_args;
unsigned int i, count;
return 0;
}
if (search_args == NULL) {
return -1;
}
/* update at all the mailboxes that were introduced since the previous
rule. */
}
return 0;
}
static int
const char **error_r)
{
struct virtual_backend_box *bbox;
const char *name;
/* continues the previous search rule */
*error_r = "Search rule without a mailbox";
return -1;
}
return 0;
}
/* if there is no rule yet, it means we want the previous mailboxes
to use the rule that comes later */
return -1;
}
/* new mailbox. the search args are added to it later. */
line = "INBOX";
return -1;
}
return -1;
}
}
/* save messages here */
*error_r = "Multiple save mailboxes defined";
return -1;
}
}
*error_r = "Virtual mailbox can't point to itself";
return -1;
}
return 0;
}
static void
{
struct mailbox_virtual_pattern pattern;
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
else {
}
}
}
static void
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
for (i = 0; i < count;) {
else {
i++;
}
&count);
}
}
}
struct virtual_backend_box *wbox,
const char *name)
{
struct virtual_backend_box *bbox;
}
struct mail_namespace *iter_ns)
{
/* we match only one namespace for each pattern, except with shared
namespaces match also autocreated children */
return TRUE;
return TRUE;
config_ns->prefix_len == 0) {
/* prefix="" namespace was autocreated, so e.g. "*" would match
only that empty namespace. but we want "*" to also match
the inbox=yes namespace, so check it here separately. */
return TRUE;
}
return FALSE;
}
unsigned int *idx_r)
{
struct virtual_backend_box *const *boxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
*idx_r = i;
return TRUE;
}
} else {
*idx_r = i;
return TRUE;
}
}
}
return FALSE;
}
const char **error_r)
{
const enum mail_namespace_type iter_ns_types =
const enum mailbox_list_iter_flags iter_flags =
struct mailbox_list_iterate_context *iter;
struct virtual_backend_box *const *wboxes;
const char **patterns;
const struct mailbox_info *info;
unsigned int i, j, count;
/* get patterns we want to list */
if (count == 0) {
/* only negative wildcards - doesn't really make sense.
just ignore. */
return 0;
}
for (i = 0; i < count; i++)
/* match listed mailboxes to wildcards */
/* skip non-selectable mailboxes (especially mbox
directories) */
continue;
/* don't allow virtual folder to point to itself */
continue;
}
}
}
for (i = 0; i < count; i++)
if (mailbox_list_iter_deinit(&iter) < 0) {
return -1;
}
return 0;
}
{
struct virtual_backend_box *const *bboxes;
struct mail_search_args *old_args;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
{
struct virtual_parse_context ctx;
unsigned int linenum = 0;
if (fd == -1) {
"open(%s) failed: %m", path);
} else {
"stat(%s) failed: %m", box_path);
}
return -1;
}
linenum++;
if (*line == '#')
continue;
if (*line == '\0')
else
if (ret < 0) {
"%s: Error at line %u: %s",
break;
}
}
if (ret == 0) {
if (ret < 0) {
"%s: Error at line %u: %s",
}
}
if (ret < 0)
}
"%s: No mailboxes defined", path);
ret = -1;
}
if (ret == 0)
i_close_fd(&fd);
return ret;
}
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
/* mailbox wasn't opened */
return;
}
for (i = 0; i < count; i++) {
}
}