cmd-list.c revision d84ee3fb73403edd1bdc4fbec9a78c1ca0a07ba3
/* Copyright (C) 2002-2004 Timo Sirainen */
#include "common.h"
#include "str.h"
#include "strescape.h"
#include "imap-quote.h"
#include "imap-match.h"
#include "commands.h"
#include "namespace.h"
enum {
_MAILBOX_LIST_HIDE_CHILDREN = 0x1000000,
_MAILBOX_LIST_LISTEXT = 0x0800000
};
struct cmd_list_context {
const char *ref;
const char *mask;
enum mailbox_list_flags list_flags;
struct mailbox_list_context *list_ctx;
struct imap_match_glob *glob;
unsigned int lsub:1;
unsigned int inbox:1;
unsigned int inbox_found:1;
unsigned int match_inbox:1;
};
static const char *
{
const char *str;
if (flags & MAILBOX_PLACEHOLDER) {
if ((list_flags & _MAILBOX_LIST_LISTEXT) == 0)
}
if ((flags & MAILBOX_NONEXISTENT) != 0 &&
(list_flags & _MAILBOX_LIST_LISTEXT) == 0) {
flags &= ~MAILBOX_NONEXISTENT;
}
if ((list_flags & _MAILBOX_LIST_HIDE_CHILDREN) != 0)
str = t_strconcat(
NULL);
}
static int
enum mailbox_list_flags *list_flags)
{
const char *atom;
"List options contains non-atoms.");
return FALSE;
}
else {
return FALSE;
}
args++;
}
return TRUE;
}
static int
{
struct mailbox_list *list;
const char *name;
int ret;
return 1;
t_push();
str_truncate(name_str, 0);
char *p = str_c_modifyable(name_str);
for (; *p != '\0'; p++) {
}
}
/* With masks containing '*' we do the checks here
so prefix is included in matching */
continue;
continue;
name = "INBOX";
}
str_truncate(str, 0);
/* buffer is full, continue later */
t_pop();
return 0;
}
}
/* INBOX always exists */
str_truncate(str, 0);
}
t_pop();
}
{
}
}
static void
struct cmd_list_context *ctx)
{
enum imap_match_result match;
enum mailbox_list_flags list_flags;
unsigned int count;
/* reference parameter didn't match with
namespace prefix. skip this. */
return;
}
}
}
else {
if (match == IMAP_MATCH_YES) {
/* The prefix itself matches */
enum mailbox_flags flags;
/* FIXME: INBOX prefix - we should get real
mailbox flags.. */
} else {
}
}
}
if (match < 0)
return;
count = 0;
if (*cur_prefix != '\0') {
/* we'll have to fix mask */
count++;
}
if (count == 0)
count = 1;
while (count > 0) {
if (*cur_ref != '\0') {
while (*cur_ref != '\0' &&
;
} else {
cur_mask++;
if (*cur_mask == '*') {
cur_mask = "*";
break;
}
if (*cur_mask == '\0')
break;
cur_mask++;
}
count--;
}
}
/* a) we don't have '*' in mask
b) we want to display everything
we don't need to do separate matching ourself */
}
}
{
int ret;
return TRUE;
}
if (ret == 0)
return FALSE;
}
"OK List completed." :
"OK Lsub completed.");
return TRUE;
}
{
enum mailbox_list_flags list_flags;
struct cmd_list_context *ctx;
/* [(<options>)] <reference> <mailbox wildcards> */
return FALSE;
if (lsub) {
/* LSUB - we don't care about flags */
/* LIST - allow children flags, but don't require them */
list_flags = 0;
} else {
&list_flags))
return TRUE;
args++;
/* don't show children flags unless explicitly specified */
if ((list_flags & MAILBOX_LIST_CHILDREN) == 0)
}
return TRUE;
}
/* special request to return the hierarchy delimiter and
mailbox root name. Mailbox root name is somewhat strange
concept which probably no other client uses than Pine.
Just try our best to emulate UW-IMAP behavior and hopefully
we're fine. */
const char *empty = "";
}
/* public namespace, use it as the root name */
FALSE);
} else {
/* private namespace, or empty namespace
prefix. use the mailbox name's first part
as the root. */
if (p == NULL)
else {
FALSE);
}
}
}
} else {
if (!cmd_list_continue(cmd)) {
/* unfinished */
return FALSE;
}
return TRUE;
}
return TRUE;
}
{
}