virtual-config.c revision 4a6f18b8c03dbb81b1e4f90242fe7788589d7876
/* Copyright (c) 2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "crc32.h"
#include "istream.h"
#include "str.h"
#include "imap-parser.h"
#include "imap-match.h"
#include "mail-search-build.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;
};
static struct mail_search_args *
{
struct imap_parser *parser;
struct mail_search_args *sargs;
bool fatal;
int ret;
(void)i_stream_read(input);
if (ret < 0) {
error_r) < 0)
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;
if (*line == ' ') {
/* 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. */
}
return 0;
}
static void
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
for (i = 0; i < count;) {
i++;
else {
&count);
}
}
}
struct virtual_backend_box *wbox,
const char *name)
{
struct virtual_backend_box *bbox;
}
{
struct mailbox_list_iterate_context *iter;
struct virtual_backend_box *const *wboxes;
const char **patterns;
const struct mailbox_info *info;
unsigned int i, count;
/* get patterns we want to list */
for (i = 0; i < count; i++)
/* match listed mailboxes to wildcards */
for (i = 0; i < count; i++) {
/* we match only one namespace for each pattern.
skip non-selectable mailboxes (especially mbox
directories) */
}
}
}
for (i = 0; i < count; i++)
return mailbox_list_iter_deinit(&iter);
}
{
struct virtual_parse_context ctx;
unsigned int linenum = 0;
if (fd == -1) {
"Virtual mailbox missing configuration file");
return -1;
}
"open(%s) failed: %m", path);
return -1;
}
linenum++;
if (*line == '#')
continue;
if (*line == '\0')
else
if (ret < 0) {
"%s: Error at line %u: %s",
break;
}
}
if (ret == 0)
"%s: No mailboxes defined", path);
ret = -1;
}
return ret;
}
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}