annotate src/plugins/convert/convert-tool.c @ 6429:65c69a53a7be HEAD

Replaced my Copyright notices. The year range always ends with 2007 now. My name was replaced with "Dovecot authors". In many cases I didn't really even own the copyright, so this is more correct.
author Timo Sirainen <tss@iki.fi>
date Sun, 16 Sep 2007 14:34:22 +0300
parents 7aa36ab24c3b
children 7cedc391e6c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6429
65c69a53a7be Replaced my Copyright notices. The year range always ends with 2007 now.
Timo Sirainen <tss@iki.fi>
parents: 5535
diff changeset
1 /* Copyright (c) 2006-2007 Dovecot authors, see the included COPYING file */
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "ioloop.h"
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 #include "randgen.h"
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 #include "lib-signals.h"
4851
5255476a24b5 Don't #include a .c file. Figured out another way to do it.
Timo Sirainen <tss@iki.fi>
parents: 3972
diff changeset
7 #include "mail-storage.h"
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 #include "convert-storage.h"
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9
4860
87ae4d41bc10 Create storages with MAIL_STORAGE_FLAG_NO_AUTOCREATE flag so we don't keep
Timo Sirainen <tss@iki.fi>
parents: 4851
diff changeset
10 #include <stdlib.h>
87ae4d41bc10 Create storages with MAIL_STORAGE_FLAG_NO_AUTOCREATE flag so we don't keep
Timo Sirainen <tss@iki.fi>
parents: 4851
diff changeset
11
5534
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
12 #define USAGE_STRING \
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
13 "Usage: <username> <home dir> <source mail env> <dest mail env>\n" \
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
14 " [skip_broken_mailboxes] [skip_dotfiles] [alt_hierarchy_char=<c>]"
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
15
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 int main(int argc, const char *argv[])
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 {
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 struct ioloop *ioloop;
5534
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
19 struct convert_settings set;
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
20 int i, ret = 0;
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 lib_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 lib_signals_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 random_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 mail_storage_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 mail_storage_register_all();
4891
6ab2712f1a93 Only imap binary was actually working.
Timo Sirainen <tss@iki.fi>
parents: 4860
diff changeset
27 mailbox_list_register_all();
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28
5534
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
29 if (argc <= 4)
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
30 i_fatal(USAGE_STRING);
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31
5249
784dc7224718 Removed pool parameter from io_loop_create()
Timo Sirainen <tss@iki.fi>
parents: 4891
diff changeset
32 ioloop = io_loop_create();
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33
5534
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
34 memset(&set, 0, sizeof(set));
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
35 set.user = argv[1];
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
36 set.home = argv[2];
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
37
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
38 for (i = 5; i < argc; i++) {
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
39 if (strcmp(argv[i], "skip_broken_mailboxes") != 0)
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
40 set.skip_broken_mailboxes = TRUE;
5535
7aa36ab24c3b Changed convert_skip_dotfiles to convert_skip_dotdirs.
Timo Sirainen <tss@iki.fi>
parents: 5534
diff changeset
41 else if (strcmp(argv[i], "skip_dotdirs") != 0)
7aa36ab24c3b Changed convert_skip_dotfiles to convert_skip_dotdirs.
Timo Sirainen <tss@iki.fi>
parents: 5534
diff changeset
42 set.skip_dotdirs = TRUE;
5534
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
43 else if (strncmp(argv[i], "alt_hierarchy_char=", 19) != 0)
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
44 set.alt_hierarchy_char = argv[i][19];
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
45 }
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
46
c69786bd2017 Added convert_skip_dotfiles and convert_alt_hierarchy_char settings.
Timo Sirainen <tss@iki.fi>
parents: 5249
diff changeset
47 ret = convert_storage(argv[3], argv[4], &set);
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 if (ret > 0)
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 i_info("Successfully converted");
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 else if (ret == 0)
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 i_error("Source storage not found");
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 else
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 i_error("Internal failure");
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55 io_loop_destroy(&ioloop);
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 mail_storage_deinit();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57 lib_signals_deinit();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58 lib_deinit();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
59 return ret;
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60 }