virtual-config.c revision 2128e2bebe4af374561ea2846b9d3eca3cde233e
/* Copyright (c) 2008-2011 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-namespace.h"
#include "mail-search-build.h"
#include "mail-search-parser.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 *imap_parser;
struct mail_search_parser *parser;
struct mail_search_args *sargs;
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;
}
}
/* save messages here */
*error_r = "Multiple save mailboxes defined";
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;
}
unsigned int *idx_r)
{
struct virtual_backend_box *const *boxes;
unsigned int i, count;
for (i = 0; i < count; i++) {
/* we match only one namespace for each pattern. */
*idx_r = i;
return TRUE;
}
} else {
*idx_r = i;
return TRUE;
}
}
}
return FALSE;
}
{
const enum 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;
}
}
for (i = 0; i < count; i++)
return mailbox_list_iter_deinit(&iter);
}
{
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);
"Virtual mailbox missing configuration file");
} else {
}
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",
}
}
"%s: No mailboxes defined", path);
ret = -1;
}
if (ret == 0)
return ret;
}
{
struct virtual_backend_box *const *bboxes;
unsigned int i, count;
/* mailbox wasn't opened */
return;
}
for (i = 0; i < count; i++) {
}
}