dovecot-2.0: doveadm: mail commands can now be extended more eas...
dovecot at dovecot.org
dovecot at dovecot.org
Thu May 27 22:31:45 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/07c9d1115029
changeset: 11395:07c9d1115029
user: Timo Sirainen <tss at iki.fi>
date: Thu May 27 19:59:39 2010 +0100
description:
doveadm: mail commands can now be extended more easily by plugins.
Also plugins can now override the list of -A users.
diffstat:
src/doveadm/doveadm-mail-altmove.c | 22 +++-------
src/doveadm/doveadm-mail-expunge.c | 22 +++-------
src/doveadm/doveadm-mail-fetch.c | 16 ++++----
src/doveadm/doveadm-mail-mailbox.c | 24 ++++++------
src/doveadm/doveadm-mail-search.c | 22 +++-------
src/doveadm/doveadm-mail.c | 87 +++++++++++++++++++++++++++++--------------
src/doveadm/doveadm-mail.h | 38 ++++++++++++++++---
src/doveadm/doveadm-settings.c | 5 ++-
src/doveadm/doveadm-settings.h | 2 +
src/doveadm/doveadm.c | 16 ++++++++
src/doveadm/doveadm.h | 1 +
11 files changed, 155 insertions(+), 100 deletions(-)
diffs (truncated from 645 to 300 lines):
diff -r 85e22167529f -r 07c9d1115029 src/doveadm/doveadm-mail-altmove.c
--- a/src/doveadm/doveadm-mail-altmove.c Thu May 27 19:27:18 2010 +0100
+++ b/src/doveadm/doveadm-mail-altmove.c Thu May 27 19:59:39 2010 +0100
@@ -9,11 +9,6 @@
#include "doveadm-mail-iter.h"
#include "doveadm-mail.h"
-struct altmove_cmd_context {
- struct doveadm_mail_cmd_context ctx;
- struct mail_search_args *search_args;
-};
-
static int
cmd_altmove_box(const struct mailbox_info *info,
struct mail_search_args *search_args)
@@ -47,9 +42,8 @@
}
static void
-cmd_altmove_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
+cmd_altmove_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
{
- struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx;
const enum mailbox_list_iter_flags iter_flags =
MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_VIRTUAL_NAMES |
@@ -94,11 +88,9 @@
}
}
-static void cmd_altmove_init(struct doveadm_mail_cmd_context *_ctx,
+static void cmd_altmove_init(struct doveadm_mail_cmd_context *ctx,
const char *const args[])
{
- struct altmove_cmd_context *ctx = (struct altmove_cmd_context *)_ctx;
-
if (args[0] == NULL)
doveadm_mail_help_name("altmove");
ctx->search_args = doveadm_mail_build_search_args(args);
@@ -106,12 +98,12 @@
static struct doveadm_mail_cmd_context *cmd_altmove_alloc(void)
{
- struct altmove_cmd_context *ctx;
+ struct doveadm_mail_cmd_context *ctx;
- ctx = doveadm_mail_cmd_alloc(struct altmove_cmd_context);
- ctx->ctx.init = cmd_altmove_init;
- ctx->ctx.run = cmd_altmove_run;
- return &ctx->ctx;
+ ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
+ ctx->v.init = cmd_altmove_init;
+ ctx->v.run = cmd_altmove_run;
+ return ctx;
}
struct doveadm_mail_cmd cmd_altmove = {
diff -r 85e22167529f -r 07c9d1115029 src/doveadm/doveadm-mail-expunge.c
--- a/src/doveadm/doveadm-mail-expunge.c Thu May 27 19:27:18 2010 +0100
+++ b/src/doveadm/doveadm-mail-expunge.c Thu May 27 19:59:39 2010 +0100
@@ -9,11 +9,6 @@
#include "doveadm-mail-iter.h"
#include "doveadm-mail.h"
-struct expunge_cmd_context {
- struct doveadm_mail_cmd_context ctx;
- struct mail_search_args *search_args;
-};
-
static int
cmd_expunge_box(const struct mailbox_info *info,
struct mail_search_args *search_args)
@@ -167,9 +162,8 @@
}
static void
-cmd_expunge_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
+cmd_expunge_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
{
- struct expunge_cmd_context *ctx = (struct expunge_cmd_context *)_ctx;
const enum mailbox_list_iter_flags iter_flags =
MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_VIRTUAL_NAMES |
@@ -195,11 +189,9 @@
doveadm_mail_list_iter_deinit(&iter);
}
-static void cmd_expunge_init(struct doveadm_mail_cmd_context *_ctx,
+static void cmd_expunge_init(struct doveadm_mail_cmd_context *ctx,
const char *const args[])
{
- struct expunge_cmd_context *ctx = (struct expunge_cmd_context *)_ctx;
-
if (args[0] == NULL)
doveadm_mail_help_name("expunge");
@@ -209,12 +201,12 @@
static struct doveadm_mail_cmd_context *cmd_expunge_alloc(void)
{
- struct expunge_cmd_context *ctx;
+ struct doveadm_mail_cmd_context *ctx;
- ctx = doveadm_mail_cmd_alloc(struct expunge_cmd_context);
- ctx->ctx.init = cmd_expunge_init;
- ctx->ctx.run = cmd_expunge_run;
- return &ctx->ctx;
+ ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
+ ctx->v.init = cmd_expunge_init;
+ ctx->v.run = cmd_expunge_run;
+ return ctx;
}
struct doveadm_mail_cmd cmd_expunge = {
diff -r 85e22167529f -r 07c9d1115029 src/doveadm/doveadm-mail-fetch.c
--- a/src/doveadm/doveadm-mail-fetch.c Thu May 27 19:27:18 2010 +0100
+++ b/src/doveadm/doveadm-mail-fetch.c Thu May 27 19:59:39 2010 +0100
@@ -20,7 +20,6 @@
struct fetch_cmd_context {
struct doveadm_mail_cmd_context ctx;
- struct mail_search_args *search_args;
struct ostream *output;
struct mail *mail;
@@ -383,7 +382,8 @@
struct mail *mail;
struct mailbox_header_lookup_ctx *headers = NULL;
- if (doveadm_mail_iter_init(info, ctx->search_args, &trans, &iter) < 0)
+ if (doveadm_mail_iter_init(info, ctx->ctx.search_args,
+ &trans, &iter) < 0)
return -1;
if (array_count(&ctx->header_fields) > 1) {
@@ -445,7 +445,7 @@
struct doveadm_mail_list_iter *iter;
const struct mailbox_info *info;
- iter = doveadm_mail_list_iter_init(user, ctx->search_args, iter_flags);
+ iter = doveadm_mail_list_iter_init(user, _ctx->search_args, iter_flags);
while ((info = doveadm_mail_list_iter_next(iter)) != NULL) T_BEGIN {
(void)cmd_fetch_box(ctx, info);
} T_END;
@@ -471,11 +471,11 @@
doveadm_mail_help_name("fetch");
parse_fetch_fields(ctx, fetch_fields);
- ctx->search_args = doveadm_mail_build_search_args(args + 1);
+ _ctx->search_args = doveadm_mail_build_search_args(args + 1);
ctx->output = o_stream_create_fd(STDOUT_FILENO, 0, FALSE);
ctx->hdr = str_new(default_pool, 512);
- if (search_args_have_unique_fetch(ctx->search_args))
+ if (search_args_have_unique_fetch(_ctx->search_args))
ctx->prefix = "";
else {
random_fill_weak(prefix_buf, sizeof(prefix_buf));
@@ -492,9 +492,9 @@
struct fetch_cmd_context *ctx;
ctx = doveadm_mail_cmd_alloc(struct fetch_cmd_context);
- ctx->ctx.init = cmd_fetch_init;
- ctx->ctx.run = cmd_fetch_run;
- ctx->ctx.deinit = cmd_fetch_deinit;
+ ctx->ctx.v.init = cmd_fetch_init;
+ ctx->ctx.v.run = cmd_fetch_run;
+ ctx->ctx.v.deinit = cmd_fetch_deinit;
return &ctx->ctx;
}
diff -r 85e22167529f -r 07c9d1115029 src/doveadm/doveadm-mail-mailbox.c
--- a/src/doveadm/doveadm-mail-mailbox.c Thu May 27 19:27:18 2010 +0100
+++ b/src/doveadm/doveadm-mail-mailbox.c Thu May 27 19:59:39 2010 +0100
@@ -96,7 +96,7 @@
ctx = doveadm_mail_cmd_alloc_size(size);
ctx->getopt_args = "78s";
- ctx->parse_arg = cmd_mailbox_parse_arg;
+ ctx->v.parse_arg = cmd_mailbox_parse_arg;
return ctx;
}
@@ -166,8 +166,8 @@
struct list_cmd_context *ctx;
ctx = doveadm_mailbox_cmd_alloc(struct list_cmd_context);
- ctx->ctx.ctx.init = cmd_mailbox_list_init;
- ctx->ctx.ctx.run = cmd_mailbox_list_run;
+ ctx->ctx.ctx.v.init = cmd_mailbox_list_init;
+ ctx->ctx.ctx.v.run = cmd_mailbox_list_run;
return &ctx->ctx.ctx;
}
@@ -235,8 +235,8 @@
struct mailbox_cmd_context *ctx;
ctx = doveadm_mailbox_cmd_alloc(struct mailbox_cmd_context);
- ctx->ctx.ctx.init = cmd_mailbox_create_init;
- ctx->ctx.ctx.run = cmd_mailbox_create_run;
+ ctx->ctx.ctx.v.init = cmd_mailbox_create_init;
+ ctx->ctx.ctx.v.run = cmd_mailbox_create_run;
p_array_init(&ctx->mailboxes, ctx->ctx.ctx.pool, 16);
return &ctx->ctx.ctx;
}
@@ -297,8 +297,8 @@
struct mailbox_cmd_context *ctx;
ctx = doveadm_mailbox_cmd_alloc(struct mailbox_cmd_context);
- ctx->ctx.ctx.init = cmd_mailbox_delete_init;
- ctx->ctx.ctx.run = cmd_mailbox_delete_run;
+ ctx->ctx.ctx.v.init = cmd_mailbox_delete_init;
+ ctx->ctx.ctx.v.run = cmd_mailbox_delete_run;
p_array_init(&ctx->mailboxes, ctx->ctx.ctx.pool, 16);
return &ctx->ctx.ctx;
}
@@ -361,8 +361,8 @@
struct rename_cmd_context *ctx;
ctx = doveadm_mailbox_cmd_alloc(struct rename_cmd_context);
- ctx->ctx.ctx.init = cmd_mailbox_rename_init;
- ctx->ctx.ctx.run = cmd_mailbox_rename_run;
+ ctx->ctx.ctx.v.init = cmd_mailbox_rename_init;
+ ctx->ctx.ctx.v.run = cmd_mailbox_rename_run;
return &ctx->ctx.ctx;
}
@@ -423,9 +423,9 @@
ctx->ctx.subscriptions = subscriptions;
ctx->ctx.ctx.getopt_args = "78";
- ctx->ctx.ctx.parse_arg = cmd_mailbox_parse_arg;
- ctx->ctx.ctx.init = cmd_mailbox_subscribe_init;
- ctx->ctx.ctx.run = cmd_mailbox_subscribe_run;
+ ctx->ctx.ctx.v.parse_arg = cmd_mailbox_parse_arg;
+ ctx->ctx.ctx.v.init = cmd_mailbox_subscribe_init;
+ ctx->ctx.ctx.v.run = cmd_mailbox_subscribe_run;
p_array_init(&ctx->mailboxes, ctx->ctx.ctx.pool, 16);
return &ctx->ctx.ctx;
}
diff -r 85e22167529f -r 07c9d1115029 src/doveadm/doveadm-mail-search.c
--- a/src/doveadm/doveadm-mail-search.c Thu May 27 19:27:18 2010 +0100
+++ b/src/doveadm/doveadm-mail-search.c Thu May 27 19:59:39 2010 +0100
@@ -8,11 +8,6 @@
#include <stdio.h>
-struct search_cmd_context {
- struct doveadm_mail_cmd_context ctx;
- struct mail_search_args *search_args;
-};
-
static int
cmd_search_box(const struct mailbox_info *info,
struct mail_search_args *search_args)
@@ -42,9 +37,8 @@
}
static void
-cmd_search_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
+cmd_search_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
{
- struct search_cmd_context *ctx = (struct search_cmd_context *)_ctx;
const enum mailbox_list_iter_flags iter_flags =
MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_VIRTUAL_NAMES |
@@ -60,11 +54,9 @@
doveadm_mail_list_iter_deinit(&iter);
}
-static void cmd_search_init(struct doveadm_mail_cmd_context *_ctx,
+static void cmd_search_init(struct doveadm_mail_cmd_context *ctx,
const char *const args[])
{
- struct search_cmd_context *ctx = (struct search_cmd_context *)_ctx;
-
if (args[0] == NULL)
doveadm_mail_help_name("search");
@@ -73,12 +65,12 @@
static struct doveadm_mail_cmd_context *cmd_search_alloc(void)
{
- struct search_cmd_context *ctx;
+ struct doveadm_mail_cmd_context *ctx;
- ctx = doveadm_mail_cmd_alloc(struct search_cmd_context);
- ctx->ctx.init = cmd_search_init;
- ctx->ctx.run = cmd_search_run;
- return &ctx->ctx;
+ ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
+ ctx->v.init = cmd_search_init;
+ ctx->v.run = cmd_search_run;
+ return ctx;
}
struct doveadm_mail_cmd cmd_search = {
diff -r 85e22167529f -r 07c9d1115029 src/doveadm/doveadm-mail.c
--- a/src/doveadm/doveadm-mail.c Thu May 27 19:27:18 2010 +0100
+++ b/src/doveadm/doveadm-mail.c Thu May 27 19:59:39 2010 +0100
More information about the dovecot-cvs
mailing list