dovecot: s/mask/pattern/ for mailbox listing.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Jun 30 00:48:21 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/978722ad6184
changeset: 5839:978722ad6184
user: Timo Sirainen <tss at iki.fi>
date: Fri Jun 29 19:41:22 2007 +0300
description:
s/mask/pattern/ for mailbox listing.
diffstat:
11 files changed, 167 insertions(+), 159 deletions(-)
src/imap/cmd-list.c | 167 +++++++++++-----------
src/lib-storage/list/index-mailbox-list.c | 30 +--
src/lib-storage/list/mailbox-list-fs-iter.c | 16 +-
src/lib-storage/list/mailbox-list-fs.c | 28 +--
src/lib-storage/list/mailbox-list-fs.h | 2
src/lib-storage/list/mailbox-list-maildir-iter.c | 16 +-
src/lib-storage/list/mailbox-list-maildir.c | 14 -
src/lib-storage/list/mailbox-list-maildir.h | 2
src/lib-storage/mailbox-list-private.h | 9 -
src/lib-storage/mailbox-list.c | 29 +--
src/lib-storage/mailbox-list.h | 13 -
diffs (truncated from 833 to 300 lines):
diff -r 4906791b8256 -r 978722ad6184 src/imap/cmd-list.c
--- a/src/imap/cmd-list.c Fri Jun 29 19:26:27 2007 +0300
+++ b/src/imap/cmd-list.c Fri Jun 29 19:41:22 2007 +0300
@@ -12,7 +12,7 @@ struct cmd_list_context {
struct cmd_list_context {
struct client_command_context *cmd;
const char *ref;
- const char *mask;
+ const char *pattern;
enum mailbox_list_flags list_flags;
struct mail_namespace *ns;
@@ -267,7 +267,7 @@ list_insert_ns_prefix(string_t *name_str
return FALSE;
}
} else if (!ctx->cur_ns_match_inbox) {
- /* The mask doesn't match INBOX (eg. prefix.%).
+ /* The pattern doesn't match INBOX (eg. prefix.%).
We still want to list prefix.INBOX if it has
children. Otherwise we don't want to list
this INBOX at all. */
@@ -313,7 +313,7 @@ list_namespace_mailboxes(struct cmd_list
flags = info->flags;
if (*ctx->ns->prefix != '\0') {
- /* With masks containing '*' we do the checks here
+ /* With patterns containing '*' we do the checks here
so prefix is included in matching */
if (ctx->glob != NULL &&
imap_match(ctx->glob, name) != IMAP_MATCH_YES)
@@ -361,54 +361,56 @@ list_namespace_mailboxes(struct cmd_list
return ret < 0 ? -1 : 1;
}
-static bool list_mask_has_wildcards(const char *mask)
-{
- for (; *mask != '\0'; mask++) {
- if (*mask == '%' || *mask == '*')
+static bool list_pattern_has_wildcards(const char *pattern)
+{
+ for (; *pattern != '\0'; pattern++) {
+ if (*pattern == '%' || *pattern == '*')
return TRUE;
}
return FALSE;
}
static void
-skip_namespace_prefix(const char **prefix, const char **mask,
+skip_namespace_prefix(const char **prefix, const char **pattern,
bool inbox_check, char sep)
{
- size_t mask_len, prefix_len;
+ size_t pattern_len, prefix_len;
bool match;
prefix_len = strlen(*prefix);
- mask_len = strlen(*mask);
-
- if (mask_len < prefix_len) {
- /* eg. namespace prefix = "INBOX.", mask = "INBOX" */
+ pattern_len = strlen(*pattern);
+
+ if (pattern_len < prefix_len) {
+ /* eg. namespace prefix = "INBOX.", pattern = "INBOX" */
return;
}
- match = strncmp(*prefix, *mask, prefix_len) == 0;
+ match = strncmp(*prefix, *pattern, prefix_len) == 0;
if (!match && inbox_check) {
/* try INBOX check. */
match = prefix_len >= 5 &&
- strncasecmp(*prefix, *mask, 5) == 0 &&
- strncmp(*prefix + 5, *mask + 5, prefix_len - 5) == 0 &&
+ strncasecmp(*prefix, *pattern, 5) == 0 &&
+ strncmp(*prefix + 5, *pattern + 5,
+ prefix_len - 5) == 0 &&
strncasecmp(*prefix, "INBOX", 5) == 0 &&
((*prefix)[5] == sep || (*prefix)[5] == '\0');
}
if (match) {
*prefix += prefix_len;
- *mask += prefix_len;
+ *pattern += prefix_len;
}
}
static bool
-skip_namespace_prefix_refmask(struct cmd_list_context *ctx,
- const char **cur_ns_prefix_p,
- const char **cur_ref_p, const char **cur_mask_p)
+skip_namespace_prefix_refpattern(struct cmd_list_context *ctx,
+ const char **cur_ns_prefix_p,
+ const char **cur_ref_p,
+ const char **cur_pattern_p)
{
const char *cur_ns_prefix = *cur_ns_prefix_p;
const char *cur_ref = *cur_ref_p;
- const char *cur_mask = *cur_mask_p;
+ const char *cur_pattern = *cur_pattern_p;
if (*ctx->ns->prefix == '\0')
return TRUE;
@@ -433,25 +435,25 @@ skip_namespace_prefix_refmask(struct cmd
}
if (*cur_ns_prefix != '\0') {
- /* skip namespace prefix using mask */
+ /* skip namespace prefix using pattern */
const char *old_ns_prefix = cur_ns_prefix;
- const char *old_mask = cur_mask;
+ const char *old_pattern = cur_pattern;
i_assert(*cur_ref == '\0');
- skip_namespace_prefix(&cur_ns_prefix, &cur_mask,
+ skip_namespace_prefix(&cur_ns_prefix, &cur_pattern,
cur_ref == ctx->ref, ctx->ns->sep);
- if (*cur_mask == '\0' && *cur_ns_prefix == '\0') {
+ if (*cur_pattern == '\0' && *cur_ns_prefix == '\0') {
/* trying to list the namespace prefix itself. */
cur_ns_prefix = old_ns_prefix;
- cur_mask = old_mask;
+ cur_pattern = old_pattern;
}
}
*cur_ns_prefix_p = cur_ns_prefix;
*cur_ref_p = cur_ref;
- *cur_mask_p = cur_mask;
+ *cur_pattern_p = cur_pattern;
return TRUE;
}
@@ -464,19 +466,19 @@ list_use_inboxcase(struct cmd_list_conte
(ctx->ns->flags & NAMESPACE_FLAG_INBOX) == 0)
return IMAP_MATCH_NO;
- /* if the original reference and mask combined produces something
+ /* if the original reference and pattern combined produces something
that matches INBOX, the INBOX casing is on. */
inbox_glob = imap_match_init(ctx->cmd->pool,
- t_strconcat(ctx->ref, ctx->mask, NULL),
+ t_strconcat(ctx->ref, ctx->pattern, NULL),
TRUE, ctx->ns->sep);
return imap_match(inbox_glob, "INBOX");
}
static void
-skip_mask_wildcard_prefix(const char *cur_ns_prefix, char sep,
- const char **cur_mask_p)
-{
- const char *cur_mask = *cur_mask_p;
+skip_pattern_wildcard_prefix(const char *cur_ns_prefix, char sep,
+ const char **cur_pattern_p)
+{
+ const char *cur_pattern = *cur_pattern_p;
unsigned int count;
for (count = 1; *cur_ns_prefix != '\0'; cur_ns_prefix++) {
@@ -486,38 +488,38 @@ skip_mask_wildcard_prefix(const char *cu
for (; count > 0; count--) {
/* skip over one hierarchy */
- while (*cur_mask != '\0' && *cur_mask != '*' &&
- *cur_mask != sep)
- cur_mask++;
-
- if (*cur_mask == '*') {
+ while (*cur_pattern != '\0' && *cur_pattern != '*' &&
+ *cur_pattern != sep)
+ cur_pattern++;
+
+ if (*cur_pattern == '*') {
/* we'll just request "*" and filter it
ourself. otherwise this gets too complex. */
- cur_mask = "*";
+ cur_pattern = "*";
break;
}
- if (*cur_mask == '\0') {
- /* mask ended too early. we won't be listing
+ if (*cur_pattern == '\0') {
+ /* pattern ended too early. we won't be listing
any mailboxes. */
break;
}
- cur_mask++;
- }
-
- *cur_mask_p = cur_mask;
+ cur_pattern++;
+ }
+
+ *cur_pattern_p = cur_pattern;
}
static void list_namespace_init(struct cmd_list_context *ctx)
{
struct mail_namespace *ns = ctx->ns;
- const char *cur_ns_prefix, *cur_ref, *cur_mask;
+ const char *cur_ns_prefix, *cur_ref, *cur_pattern;
enum imap_match_result match;
enum imap_match_result inbox_match;
size_t len;
cur_ns_prefix = ns->prefix;
cur_ref = ctx->ref;
- cur_mask = ctx->mask;
+ cur_pattern = ctx->pattern;
if ((ctx->ns->flags & NAMESPACE_FLAG_HIDDEN) != 0 &&
(ctx->list_flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) {
@@ -530,22 +532,22 @@ static void list_namespace_init(struct c
if ((ns->flags & NAMESPACE_FLAG_INBOX) != 0)
ctx->seen_inbox_namespace = TRUE;
- if (!skip_namespace_prefix_refmask(ctx, &cur_ns_prefix,
- &cur_ref, &cur_mask))
+ if (!skip_namespace_prefix_refpattern(ctx, &cur_ns_prefix,
+ &cur_ref, &cur_pattern))
return;
inbox_match = list_use_inboxcase(ctx);
ctx->cur_ns_match_inbox = inbox_match == IMAP_MATCH_YES;
- ctx->glob = imap_match_init(ctx->cmd->pool, ctx->mask,
+ ctx->glob = imap_match_init(ctx->cmd->pool, ctx->pattern,
(inbox_match == IMAP_MATCH_YES ||
inbox_match == IMAP_MATCH_PARENT) &&
- cur_mask == ctx->mask, ns->sep);
+ cur_pattern == ctx->pattern, ns->sep);
if (*cur_ns_prefix != '\0') {
/* namespace prefix still wasn't completely skipped over.
- for example cur_ns_prefix=INBOX/, mask=%/% or mask=IN%.
- Check that mask matches namespace prefix. */
+ for example cur_ns_prefix=INBOX/, pattern=%/% or pattern=IN%.
+ Check that pattern matches namespace prefix. */
i_assert(*cur_ref == '\0');
/* drop the trailing separator in namespace prefix.
@@ -553,7 +555,7 @@ static void list_namespace_init(struct c
(LIST "" foo/ needs to return "foo/" entry) */
len = strlen(cur_ns_prefix);
if (cur_ns_prefix[len-1] == ns->sep &&
- strcmp(cur_mask, cur_ns_prefix) != 0) {
+ strcmp(cur_pattern, cur_ns_prefix) != 0) {
ctx->cur_ns_skip_trailing_sep = TRUE;
cur_ns_prefix = t_strndup(cur_ns_prefix, len-1);
}
@@ -561,7 +563,7 @@ static void list_namespace_init(struct c
/* hidden and non-listable namespaces should still be seen
without wildcards. */
match = ((ns->flags & NAMESPACE_FLAG_LIST) == 0 &&
- list_mask_has_wildcards(cur_mask)) ?
+ list_pattern_has_wildcards(cur_pattern)) ?
IMAP_MATCH_NO : imap_match(ctx->glob, cur_ns_prefix);
if (match < 0)
return;
@@ -576,24 +578,26 @@ static void list_namespace_init(struct c
if (*cur_ns_prefix != '\0') {
/* We didn't skip over the whole namespace prefix. For example
- cur_ns_prefix=INBOX/ and mask=%/% or IN*.
-
- We have already verified that the mask matches the namespace
- prefix, so we'll just have to skip over as many hierarchies
- from mask as there exists in namespace prefix. */
+ cur_ns_prefix=INBOX/ and pattern=%/% or IN*.
+
+ We have already verified that the pattern matches the
+ namespace prefix, so we'll just have to skip over as many
+ hierarchies from pattern as there exists in namespace
+ prefix. */
i_assert(*cur_ref == '\0');
- skip_mask_wildcard_prefix(cur_ns_prefix, ns->sep, &cur_mask);
-
- if (*cur_mask == '\0' && ctx->cur_ns_match_inbox) {
+ skip_pattern_wildcard_prefix(cur_ns_prefix, ns->sep,
+ &cur_pattern);
+
+ if (*cur_pattern == '\0' && ctx->cur_ns_match_inbox) {
/* ns_prefix="INBOX/" and we wanted to list "%".
This is an optimization to avoid doing an empty
listing followed by another INBOX listing later. */
- cur_mask = "INBOX";
- }
- }
-
- if (*cur_mask != '*' || strcmp(ctx->mask, "*") == 0) {
- /* a) we don't have '*' in mask
+ cur_pattern = "INBOX";
+ }
+ }
+
+ if (*cur_pattern != '*' || strcmp(ctx->pattern, "*") == 0) {
More information about the dovecot-cvs
mailing list