Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/plugins/convert/convert-tool.c @ 8082:db66611fd195 HEAD
Added struct mail_user and fixed the code to support multiple users per process.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 12 Aug 2008 12:28:42 -0400 |
parents | 0e8339ad1932 |
children | bf83aa9c3f4a |
comparison
equal
deleted
inserted
replaced
8081:0d5fba71cb93 | 8082:db66611fd195 |
---|---|
16 | 16 |
17 int main(int argc, const char *argv[]) | 17 int main(int argc, const char *argv[]) |
18 { | 18 { |
19 struct ioloop *ioloop; | 19 struct ioloop *ioloop; |
20 struct convert_settings set; | 20 struct convert_settings set; |
21 struct mail_user *user; | |
21 struct mail_namespace *dest_ns; | 22 struct mail_namespace *dest_ns; |
22 enum mail_storage_flags dest_flags; | 23 enum mail_storage_flags dest_flags; |
23 enum file_lock_method lock_method; | 24 enum file_lock_method lock_method; |
24 const char *error; | 25 const char *error; |
25 int i, ret = 0; | 26 int i, ret = 0; |
35 i_fatal(USAGE_STRING); | 36 i_fatal(USAGE_STRING); |
36 | 37 |
37 ioloop = io_loop_create(); | 38 ioloop = io_loop_create(); |
38 | 39 |
39 memset(&set, 0, sizeof(set)); | 40 memset(&set, 0, sizeof(set)); |
40 set.user = argv[1]; | |
41 set.home = argv[2]; | |
42 | |
43 for (i = 5; i < argc; i++) { | 41 for (i = 5; i < argc; i++) { |
44 if (strcmp(argv[i], "skip_broken_mailboxes") != 0) | 42 if (strcmp(argv[i], "skip_broken_mailboxes") != 0) |
45 set.skip_broken_mailboxes = TRUE; | 43 set.skip_broken_mailboxes = TRUE; |
46 else if (strcmp(argv[i], "skip_dotdirs") != 0) | 44 else if (strcmp(argv[i], "skip_dotdirs") != 0) |
47 set.skip_dotdirs = TRUE; | 45 set.skip_dotdirs = TRUE; |
48 else if (strncmp(argv[i], "alt_hierarchy_char=", 19) != 0) | 46 else if (strncmp(argv[i], "alt_hierarchy_char=", 19) != 0) |
49 set.alt_hierarchy_char = argv[i][19]; | 47 set.alt_hierarchy_char = argv[i][19]; |
50 } | 48 } |
51 | 49 |
52 mail_storage_parse_env(&dest_flags, &lock_method); | 50 mail_storage_parse_env(&dest_flags, &lock_method); |
53 dest_ns = mail_namespaces_init_empty(pool_datastack_create()); | 51 user = mail_user_init(argv[1], argv[2]); |
54 if (mail_storage_create(dest_ns, NULL, argv[4], set.user, | 52 dest_ns = mail_namespaces_init_empty(pool_datastack_create(), user); |
53 | |
54 if (mail_storage_create(dest_ns, NULL, argv[4], | |
55 dest_flags, lock_method, &error) < 0) { | 55 dest_flags, lock_method, &error) < 0) { |
56 i_fatal("Failed to create destination " | 56 i_fatal("Failed to create destination " |
57 "mail storage with data '%s': %s", argv[4], error); | 57 "mail storage with data '%s': %s", argv[4], error); |
58 } | 58 } |
59 | 59 |
62 i_info("Successfully converted"); | 62 i_info("Successfully converted"); |
63 else if (ret == 0) | 63 else if (ret == 0) |
64 i_error("Source storage not found"); | 64 i_error("Source storage not found"); |
65 else | 65 else |
66 i_error("Internal failure"); | 66 i_error("Internal failure"); |
67 mail_namespaces_deinit(&dest_ns); | 67 mail_user_deinit(&user); |
68 | 68 |
69 io_loop_destroy(&ioloop); | 69 io_loop_destroy(&ioloop); |
70 mail_storage_deinit(); | 70 mail_storage_deinit(); |
71 lib_signals_deinit(); | 71 lib_signals_deinit(); |
72 lib_deinit(); | 72 lib_deinit(); |