/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "imap-common.h"
#include "str.h"
#include "istream.h"
#include "istream-sized.h"
#include "ostream.h"
#include "mailbox-list-iter.h"
#include "imap-utf7.h"
#include "imap-quote.h"
#include "imap-metadata.h"
struct imap_getmetadata_context {
unsigned int depth;
unsigned int entry_idx;
bool first_entry_sent;
bool failed;
};
static bool
static bool
{
const char *value;
while (!IMAP_ARG_IS_EOL(options)) {
options++;
"Invalid value for MAXSIZE option");
return FALSE;
}
options++;
"Invalid value for DEPTH option");
return FALSE;
}
else {
"Invalid value for DEPTH option");
return FALSE;
}
} else {
return FALSE;
}
options++;
}
return TRUE;
}
static bool
{
return FALSE;
}
return FALSE;
}
/* names are case-insensitive so we'll always lowercase them */
}
return TRUE;
}
static string_t *
{
if (!ctx->first_entry_sent) {
/* server metadata reply */
} else {
i_unreached();
}
/* nothing can be sent until untagged METADATA is finished */
} else {
}
return str;
}
static void
const char *entry)
{
/* client requested a specific entry that didn't exist.
we must return it as NIL. */
}
const char *entry, bool require_reply)
{
const char *error_string;
return;
}
}
return;
}
} else {
/* skip nonexistent entries */
if (require_reply)
return;
}
/* value length is larger than specified MAXSIZE,
skip this entry */
return;
}
} else {
}
}
static bool
{
switch (res) {
return TRUE;
i_unreached();
return FALSE;
i_error("read(%s) failed: %s",
"Internal GETMETADATA failure");
return TRUE;
/* client disconnected */
return TRUE;
}
i_unreached();
}
static int
const char *entry)
{
return 0;
}
}
const char *subentry;
/* DEPTH iteration */
do {
/* iteration finished, get to the next entry */
}
return -1;
}
}
return 0;
}
/* already iterating the entry */
return 1;
/* no iteration for the entry */
return -1;
} else {
/* we just sent the entry root. iterate its children. */
return 1;
}
}
{
}
{
} else if (ctx->largest_seen_size != 0) {
} else {
}
}
{
const char *const *entries;
unsigned int count;
int ret;
return TRUE;
}
return FALSE;
}
do {
T_BEGIN {
} T_END;
if (ret == 0)
return FALSE;
} while (ret > 0);
}
if (ctx->first_entry_sent)
}
return cmd_getmetadata_mailbox_iter_next(ctx);
return TRUE;
}
static bool
{
if (!cmd_getmetadata_continue(cmd)) {
return FALSE;
}
return TRUE;
}
static bool
{
return cmd_getmetadata_start(ctx);
}
static int
{
return -1;
}
static bool
{
int ret;
if (ret < 0) {
}
return ret != 0;
}
static bool
{
int ret;
continue;
if (ret > 0) {
/* we'll already recursively went through
all the mailboxes (FIXME: ugly and potentially
stack consuming) */
return TRUE;
} else if (ret == 0) {
/* need to send more data later */
return FALSE;
}
T_BEGIN {
"* NO Failed to open mailbox %s: %s",
} T_END;
}
return TRUE;
}
{
return FALSE;
return TRUE;
}
return TRUE;
args++;
}
return TRUE;
}
return TRUE;
}
}
return TRUE;
if (mailbox[0] == '\0') {
/* server attribute */
return cmd_getmetadata_server(ctx);
/* mailbox attribute */
return TRUE;
} else {
/* wildcards in mailbox name. this isn't supported by RFC 5464,
but it was in the earlier drafts and is already used by
some software (Horde). */
return cmd_getmetadata_mailbox_iter_next(ctx);
}
}