dovecot-2.0: doveadm: Added convert command to convert mailbox n...
dovecot at dovecot.org
dovecot at dovecot.org
Thu May 13 12:50:56 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/0741e7003efa
changeset: 11297:0741e7003efa
user: Timo Sirainen <tss at iki.fi>
date: Thu May 13 11:47:53 2010 +0200
description:
doveadm: Added convert command to convert mailbox names between mUTF-7/UTF-8
diffstat:
src/doveadm/doveadm-mail-mailbox.c | 47 +++++++++++++++++++++++
src/doveadm/doveadm.c | 1 +
src/doveadm/doveadm.h | 1 +
3 files changed, 49 insertions(+), 0 deletions(-)
diffs (83 lines):
diff -r f491253bb457 -r 0741e7003efa src/doveadm/doveadm-mail-mailbox.c
--- a/src/doveadm/doveadm-mail-mailbox.c Thu May 13 11:47:30 2010 +0200
+++ b/src/doveadm/doveadm-mail-mailbox.c Thu May 13 11:47:53 2010 +0200
@@ -335,6 +335,49 @@
return &ctx->ctx.ctx;
}
+static void cmd_mailbox_convert(int argc, char *argv[])
+{
+ string_t *str;
+ bool from_utf8;
+ unsigned int i;
+ int c;
+
+ from_utf8 = TRUE;
+ while ((c = getopt(argc, argv, "78")) > 0) {
+ switch (c) {
+ case '7':
+ from_utf8 = FALSE;
+ break;
+ case '8':
+ from_utf8 = TRUE;
+ break;
+ default:
+ help(&doveadm_cmd_mailbox_convert);
+ }
+ }
+ argv += optind;
+
+ if (argv[0] == NULL)
+ help(&doveadm_cmd_mailbox_convert);
+
+ str = t_str_new(128);
+ for (i = 0; argv[i] != NULL; i++) {
+ str_truncate(str, 0);
+ if (from_utf8) {
+ if (imap_utf8_to_utf7(argv[i], str) < 0) {
+ i_error("Mailbox name not valid UTF-8: %s",
+ argv[i]);
+ }
+ } else {
+ if (imap_utf7_to_utf8(argv[i], str) < 0) {
+ i_error("Mailbox name not valid mUTF-7: %s",
+ argv[i]);
+ }
+ }
+ printf("%s\n", str_c(str));
+ }
+}
+
struct doveadm_mail_cmd cmd_mailbox_list = {
cmd_mailbox_list_alloc, "mailbox list",
"[-7|-8] [<mailbox> [...]]"
@@ -351,3 +394,7 @@
cmd_mailbox_rename_alloc, "mailbox rename",
"[-7|-8] <old name> <new name>"
};
+struct doveadm_cmd doveadm_cmd_mailbox_convert = {
+ cmd_mailbox_convert, "mailbox convert",
+ "[-7|-8] <name> [...]", NULL
+};
diff -r f491253bb457 -r 0741e7003efa src/doveadm/doveadm.c
--- a/src/doveadm/doveadm.c Thu May 13 11:47:30 2010 +0200
+++ b/src/doveadm/doveadm.c Thu May 13 11:47:53 2010 +0200
@@ -201,6 +201,7 @@
doveadm_register_cmd(&doveadm_cmd_who);
doveadm_register_cmd(&doveadm_cmd_penalty);
doveadm_register_cmd(&doveadm_cmd_kick);
+ doveadm_register_cmd(&doveadm_cmd_mailbox_convert);
doveadm_mail_init();
doveadm_load_modules();
diff -r f491253bb457 -r 0741e7003efa src/doveadm/doveadm.h
--- a/src/doveadm/doveadm.h Thu May 13 11:47:30 2010 +0200
+++ b/src/doveadm/doveadm.h Thu May 13 11:47:53 2010 +0200
@@ -19,6 +19,7 @@
extern struct doveadm_cmd doveadm_cmd_who;
extern struct doveadm_cmd doveadm_cmd_penalty;
extern struct doveadm_cmd doveadm_cmd_kick;
+extern struct doveadm_cmd doveadm_cmd_mailbox_convert;
extern bool doveadm_verbose, doveadm_debug;
More information about the dovecot-cvs
mailing list