commands-util.c revision 8039af9679af6fb56116b353fe44f7dd4c08f031
/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "array.h"
#include "buffer.h"
#include "str.h"
#include "str-sanitize.h"
#include "mail-storage.h"
#include "commands-util.h"
#include "imap-parser.h"
#include "imap-sync.h"
#include "imap-util.h"
#include "mail-namespace.h"
/* Maximum length for mailbox name, including it's path. This isn't fully
exact since the user can create folder hierarchy with small names, then
rename them to larger names. Mail storages should set more strict limits
#define MAILBOX_MAX_NAME_LEN 512
struct mail_namespace *
{
struct mail_namespace *ns;
return ns;
return NULL;
}
struct mail_storage *
{
struct mail_namespace *ns;
}
const char *mailbox,
bool should_exist, bool should_not_exist)
{
struct mail_namespace *ns;
struct mailbox_list *list;
const char *orig_mailbox, *p;
return FALSE;
/* make sure it even looks valid */
if (*mailbox == '\0') {
return FALSE;
}
/* make sure there are no real separators used in the mailbox
name. */
for (p = orig_mailbox; *p != '\0'; p++) {
"NO Character not allowed "
"in mailbox name: '%c'",
return FALSE;
}
}
}
/* make sure two hierarchy separators aren't next to each others */
return FALSE;
}
}
return FALSE;
}
/* check what our storage thinks of it */
&mailbox_status) < 0) {
return FALSE;
}
switch (mailbox_status) {
case MAILBOX_NAME_EXISTS:
if (should_exist || !should_not_exist)
return TRUE;
break;
case MAILBOX_NAME_VALID:
if (!should_exist)
return TRUE;
"NO [TRYCREATE] Mailbox doesn't exist: ",
NULL));
break;
case MAILBOX_NAME_INVALID:
"NO Invalid mailbox name: ",
NULL));
break;
case MAILBOX_NAME_NOINFERIORS:
"NO Mailbox parent doesn't allow inferior mailboxes.");
break;
default:
i_unreached();
}
return FALSE;
}
{
return TRUE;
else {
return FALSE;
}
}
struct mailbox_list *list)
{
const char *error_string;
enum mail_error error;
}
struct mail_storage *storage)
{
const char *error_string;
enum mail_error error;
/* we can't do forced CLOSE, so have to disconnect */
"Mailbox is in inconsistent state, please relogin.");
return;
}
}
struct mail_storage *storage)
{
const char *error_string;
enum mail_error error;
/* we can't do forced CLOSE, so have to disconnect */
"Mailbox is in inconsistent state, please relogin.");
return;
}
}
enum mail_flags *flags_r,
const char *const **keywords_r)
{
const char *atom;
ARRAY_DEFINE(keywords, const char *);
*flags_r = 0;
*keywords_r = NULL;
"Flags list contains non-atoms.");
return FALSE;
}
if (*atom == '\\') {
/* system flag */
*flags_r |= MAIL_ANSWERED;
*flags_r |= MAIL_FLAGGED;
*flags_r |= MAIL_DELETED;
*flags_r |= MAIL_DRAFT;
else {
"BAD Invalid system flag ",
return FALSE;
}
} else {
/* keyword validity checks are done by lib-storage */
}
args++;
}
if (array_count(&keywords) == 0)
*keywords_r = NULL;
else {
}
return TRUE;
}
{
const char *const *names;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
#define SYSTEM_FLAGS "\\Answered \\Flagged \\Deleted \\Seen \\Draft"
{
const char *str;
/* no changes to keywords and we're not selecting a mailbox */
return;
}
"Read-only mailbox.");
} else {
")] Flags permitted.", NULL));
}
}
{
}
const char *const *
{
const unsigned int *kw_indexes;
const char *const *all_names;
/* convert indexes to names */
for (i = 0; i < kw_count; i++) {
}
(void)array_append_space(dest);
}
const char *name2)
{
const char *name1;
return FALSE;
return TRUE;
}
{
}
{
;
else {
}
}
}
{
else
}