[dovecot-cvs] dovecot/src/lib-storage mailbox-tree.c,NONE,1.1
mailbox-tree.h,NONE,1.1 Makefile.am,1.8,1.9
mail-storage.h,1.52,1.53 proxy-mail-storage.c,1.1,1.2
cras at procontrol.fi
cras at procontrol.fi
Sun Jul 27 03:53:07 EEST 2003
Update of /home/cvs/dovecot/src/lib-storage
In directory danu:/tmp/cvs-serv8554/lib-storage
Modified Files:
Makefile.am mail-storage.h proxy-mail-storage.c
Added Files:
mailbox-tree.c mailbox-tree.h
Log Message:
API change: Mailbox list sorting must now always done by storage itself if
it's needed.
Maildir listing rewritten.
--- NEW FILE: mailbox-tree.c ---
/* Copyright (C) 2003 Timo Sirainen */
#include "lib.h"
#include "str.h"
#include "mailbox-tree.h"
struct mailbox_tree_context {
pool_t pool;
char separator;
struct mailbox_node *nodes;
};
struct mailbox_tree_context *mailbox_tree_init(char separator)
{
struct mailbox_tree_context *ctx;
pool_t pool;
pool = pool_alloconly_create("mailbox_tree", 10240);
ctx = p_new(pool, struct mailbox_tree_context, 1);
ctx->pool = pool;
ctx->separator = separator;
return ctx;
}
void mailbox_tree_deinit(struct mailbox_tree_context *ctx)
{
pool_unref(ctx->pool);
}
static struct mailbox_node *
mailbox_tree_traverse(struct mailbox_tree_context *ctx, const char *path,
int create, int *created)
{
struct mailbox_node **node;
const char *name;
string_t *str;
if (created != NULL)
*created = FALSE;
if (path == NULL)
return ctx->nodes;
t_push();
if (strncasecmp(path, "INBOX", 5) == 0 &&
(path[5] == '\0' || path[5] == ctx->separator))
path = t_strdup_printf("INBOX%s", path+5);
node = &ctx->nodes;
str = t_str_new(strlen(path)+1);
for (name = path;; path++) {
if (*path != ctx->separator && *path != '\0')
continue;
str_truncate(str, 0);
str_append_n(str, name, (size_t) (path - name));
name = str_c(str);
/* find the node */
while (*node != NULL) {
if (strcmp((*node)->name, name) == 0)
break;
node = &(*node)->next;
}
if (*node == NULL) {
/* not found, create it */
if (!create)
break;
*node = p_new(ctx->pool, struct mailbox_node, 1);
(*node)->name = p_strdup(ctx->pool, name);
if (*path != '\0')
(*node)->flags = MAILBOX_PLACEHOLDER;
else {
if (created != NULL)
*created = TRUE;
}
}
if (*path == '\0')
break;
name = path+1;
node = &(*node)->children;
}
t_pop();
return *node;
}
struct mailbox_node *
mailbox_tree_get(struct mailbox_tree_context *ctx, const char *path,
int *created)
{
return mailbox_tree_traverse(ctx, path, TRUE, created);
}
struct mailbox_node *
mailbox_tree_update(struct mailbox_tree_context *ctx, const char *path)
{
return mailbox_tree_traverse(ctx, path, FALSE, NULL);
}
--- NEW FILE: mailbox-tree.h ---
#ifndef __MAILBOX_TREE_H
#define __MAILBOX_TREE_H
#include "mail-storage.h"
struct mailbox_node {
struct mailbox_node *next;
struct mailbox_node *children;
char *name;
enum mailbox_flags flags;
};
struct mailbox_tree_context *mailbox_tree_init(char separator);
void mailbox_tree_deinit(struct mailbox_tree_context *ctx);
struct mailbox_node *
mailbox_tree_get(struct mailbox_tree_context *ctx, const char *path,
int *created);
struct mailbox_node *
mailbox_tree_update(struct mailbox_tree_context *ctx, const char *path);
#endif
Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Makefile.am 26 Jul 2003 18:23:10 -0000 1.8
+++ Makefile.am 26 Jul 2003 23:53:05 -0000 1.9
@@ -11,6 +11,7 @@
mail-save.c \
mail-search.c \
mail-storage.c \
+ mailbox-tree.c \
proxy-mail.c \
proxy-mail-storage.c \
proxy-mailbox.c
@@ -19,6 +20,7 @@
mail-save.h \
mail-search.h \
mail-storage.h \
+ mailbox-tree.h \
proxy-mail.h \
proxy-mail-storage.h \
proxy-mailbox.h
Index: mail-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- mail-storage.h 26 Jul 2003 16:55:11 -0000 1.52
+++ mail-storage.h 26 Jul 2003 23:53:05 -0000 1.53
@@ -179,14 +179,11 @@
/* Initialize new mailbox list request. mask may contain '%' and '*'
wildcards as defined in RFC2060. Matching against "INBOX" is
- case-insensitive, but anything else is not. *sorted is set to TRUE
- if the output will contain parent mailboxes always before their
- children. */
+ case-insensitive, but anything else is not. */
struct mailbox_list_context *
(*list_mailbox_init)(struct mail_storage *storage,
const char *mask,
- enum mailbox_list_flags flags,
- int *sorted);
+ enum mailbox_list_flags flags);
/* Deinitialize mailbox list request. Returns FALSE if some error
occured while listing. */
int (*list_mailbox_deinit)(struct mailbox_list_context *ctx);
Index: proxy-mail-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/proxy-mail-storage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- proxy-mail-storage.c 26 Jul 2003 18:23:10 -0000 1.1
+++ proxy-mail-storage.c 26 Jul 2003 23:53:05 -0000 1.2
@@ -53,11 +53,11 @@
static struct mailbox_list_context *
_list_mailbox_init(struct mail_storage *storage, const char *mask,
- enum mailbox_list_flags flags, int *sorted)
+ enum mailbox_list_flags flags)
{
struct proxy_mail_storage *s = (struct proxy_mail_storage *) storage;
- return s->storage->list_mailbox_init(s->storage, mask, flags, sorted);
+ return s->storage->list_mailbox_init(s->storage, mask, flags);
}
static int _set_subscribed(struct mail_storage *storage,
More information about the dovecot-cvs
mailing list