annotate src/plugins/convert/convert-tool.c @ 3972:a506ee4ec31e HEAD

Added "mail storage conversion" plugin. It can be used with IMAP, POP3 and/or LDA to convert one complete mail storage to another format. Also included a convert-tool command line tool to do it manually. Currently doesn't support preserving UID/UIDVALIDITY.
author Timo Sirainen <tss@iki.fi>
date Thu, 02 Feb 2006 22:42:44 +0200
parents
children 5255476a24b5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3972
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /* Copyright (C) 2006 Timo Sirainen */
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"
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #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
8
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 /* ugly, but automake doesn't like having it built as both static and
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 dynamic object.. */
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 #include "convert-storage.c"
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 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
14 {
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 struct ioloop *ioloop;
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 int ret = 0;
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 lib_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 lib_signals_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 random_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 mail_storage_init();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 mail_storage_register_all();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 if (argc <= 4) {
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 i_fatal("Usage: <username> <home dir> "
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 "<source mail env> <dest mail env>");
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 }
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29 ioloop = io_loop_create(system_pool);
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 ret = convert_storage(argv[1], argv[2], argv[3], argv[4]);
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32 if (ret > 0)
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 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
34 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
35 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
36 else
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 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
38
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 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
40 mail_storage_deinit();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 lib_signals_deinit();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42 lib_deinit();
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 return ret;
a506ee4ec31e Added "mail storage conversion" plugin. It can be used with IMAP, POP3
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 }