From: Timo Sirainen Date: Fri, 23 Jul 2010 14:51:38 +0000 (+0100) Subject: doveadm: Code cleanup: Moved "mailbox mutf7" command to separate file. X-Git-Tag: 2.0.rc4~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12fdf0f2dd2450c82e60462176b810c9cbbdd4bf;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Code cleanup: Moved "mailbox mutf7" command to separate file. It's not really a "mail command", so it shouldn't be in the same file as them. --- diff --git a/src/doveadm/Makefile.am b/src/doveadm/Makefile.am index 43755d28f2..1f3bef9171 100644 --- a/src/doveadm/Makefile.am +++ b/src/doveadm/Makefile.am @@ -65,6 +65,7 @@ doveadm_SOURCES = \ doveadm-mail-mailbox-status.c \ doveadm-mail-list-iter.c \ doveadm-mail-search.c \ + doveadm-mutf7.c \ doveadm-penalty.c \ doveadm-print.c \ doveadm-print-flow.c \ diff --git a/src/doveadm/doveadm-mail-mailbox.c b/src/doveadm/doveadm-mail-mailbox.c index a8dd0ec98c..5e7f8a43be 100644 --- a/src/doveadm/doveadm-mail-mailbox.c +++ b/src/doveadm/doveadm-mail-mailbox.c @@ -445,49 +445,6 @@ static struct doveadm_mail_cmd_context *cmd_mailbox_unsubscribe_alloc(void) return cmd_mailbox_subscriptions_alloc(FALSE); } -static void cmd_mailbox_mutf7(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_mutf7); - } - } - argv += optind; - - if (argv[0] == NULL) - help(&doveadm_cmd_mailbox_mutf7); - - 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] [-s] [ [...]]" @@ -512,7 +469,3 @@ struct doveadm_mail_cmd cmd_mailbox_unsubscribe = { cmd_mailbox_unsubscribe_alloc, "mailbox unsubscribe", " [...]" }; -struct doveadm_cmd doveadm_cmd_mailbox_mutf7 = { - cmd_mailbox_mutf7, "mailbox mutf7", - "[-7|-8] [...]" -}; diff --git a/src/doveadm/doveadm-mutf7.c b/src/doveadm/doveadm-mutf7.c new file mode 100644 index 0000000000..826428de1e --- /dev/null +++ b/src/doveadm/doveadm-mutf7.c @@ -0,0 +1,57 @@ +/* Copyright (c) 2009-2010 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "str.h" +#include "imap-utf7.h" +#include "doveadm.h" + +#include +#include + +static void cmd_mailbox_mutf7(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_mutf7); + } + } + argv += optind; + + if (argv[0] == NULL) + help(&doveadm_cmd_mailbox_mutf7); + + 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_cmd doveadm_cmd_mailbox_mutf7 = { + cmd_mailbox_mutf7, "mailbox mutf7", + "[-7|-8] [...]" +};