]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Code cleanup: Moved "mailbox mutf7" command to separate file.
authorTimo Sirainen <tss@iki.fi>
Fri, 23 Jul 2010 14:51:38 +0000 (15:51 +0100)
committerTimo Sirainen <tss@iki.fi>
Fri, 23 Jul 2010 14:51:38 +0000 (15:51 +0100)
It's not really a "mail command", so it shouldn't be in the same file as them.

src/doveadm/Makefile.am
src/doveadm/doveadm-mail-mailbox.c
src/doveadm/doveadm-mutf7.c [new file with mode: 0644]

index 43755d28f2ff32b5a4b739971ad027b07aef96a5..1f3bef9171b0acebb8503209dc378144dc0e5c01 100644 (file)
@@ -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 \
index a8dd0ec98c031ef35e30f18b9027c73d4e02fb50..5e7f8a43be5c8bb55f80d8e9ed6645cac0e78e88 100644 (file)
@@ -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] [<mailbox mask> [...]]"
@@ -512,7 +469,3 @@ struct doveadm_mail_cmd cmd_mailbox_unsubscribe = {
        cmd_mailbox_unsubscribe_alloc, "mailbox unsubscribe",
        "<mailbox> [...]"
 };
-struct doveadm_cmd doveadm_cmd_mailbox_mutf7 = {
-       cmd_mailbox_mutf7, "mailbox mutf7",
-       "[-7|-8] <name> [...]"
-};
diff --git a/src/doveadm/doveadm-mutf7.c b/src/doveadm/doveadm-mutf7.c
new file mode 100644 (file)
index 0000000..826428d
--- /dev/null
@@ -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 <stdio.h>
+#include <unistd.h>
+
+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] <name> [...]"
+};