Fix remote+ records.
* libproto/remote/folder.c (remote_url_init): Remove. (_remote_is_scheme): New function. (_remote_mbox_record): Add _is_scheme method. * libproto/remote/mbox.c (remote_mbox_init): Remove useless check. * mailbox/assoc.c (mu_assoc_clear): Return immediately if assoc tab is NULL. * mailbox/mailbox.c (_create_mailbox0): Do not enforce exact record scheme match if the scheme ends with a plus sign.
Showing
5 changed files
with
42 additions
and
42 deletions
1 | 2008-10-05 Sergey Poznyakoff <gray@gnu.org.ua> | 1 | 2008-10-05 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 2 | ||
3 | Fix remote+ records. | ||
4 | |||
5 | * libproto/remote/folder.c (remote_url_init): Remove. | ||
6 | (_remote_is_scheme): New function. | ||
7 | (_remote_mbox_record): Add _is_scheme method. | ||
8 | * libproto/remote/mbox.c (remote_mbox_init): Remove useless | ||
9 | check. | ||
10 | * mailbox/assoc.c (mu_assoc_clear): Return immediately if assoc | ||
11 | tab is NULL. | ||
12 | * mailbox/mailbox.c (_create_mailbox0): Do not enforce exact record | ||
13 | scheme match if the scheme ends with a plus sign. | ||
14 | |||
15 | Minor fixes in configuration. | ||
16 | |||
3 | * doc/texinfo/programs.texi: Document Locking, ACL, and | 17 | * doc/texinfo/programs.texi: Document Locking, ACL, and |
4 | Tcp-wrappers. | 18 | Tcp-wrappers. |
5 | * mailbox/cfg_driver.c (mu_cfg_assert_value_type): Convert | 19 | * mailbox/cfg_driver.c (mu_cfg_assert_value_type): Convert | ... | ... |
... | @@ -35,44 +35,31 @@ | ... | @@ -35,44 +35,31 @@ |
35 | 35 | ||
36 | extern int remote_mbox_init (mu_mailbox_t mailbox); | 36 | extern int remote_mbox_init (mu_mailbox_t mailbox); |
37 | 37 | ||
38 | int | 38 | static int |
39 | remote_url_init (mu_url_t url) | 39 | remote_folder_init (mu_folder_t folder MU_ARG_UNUSED) |
40 | { | 40 | { |
41 | const char *name = mu_url_to_string (url); | ||
42 | const char *p; | ||
43 | size_t len = strlen (name); | ||
44 | int rc; | ||
45 | |||
46 | if (!name) | ||
47 | return 0; | ||
48 | /* reject the obvious */ | ||
49 | if (name == NULL | ||
50 | || len < MU_REMOTE_MBOX_PREFIX_LEN | ||
51 | || strncmp (MU_REMOTE_MBOX_PREFIX, name, MU_REMOTE_MBOX_PREFIX_LEN) != 0) | ||
52 | return EINVAL; | ||
53 | |||
54 | rc = mu_registrar_lookup (name + MU_REMOTE_MBOX_PREFIX_LEN, 0, NULL, NULL); | ||
55 | if (rc) | ||
56 | return rc; | ||
57 | |||
58 | p = strchr (name, ':'); | ||
59 | if (!p) | ||
60 | return EINVAL; | ||
61 | p++; | ||
62 | |||
63 | len = p - name; | ||
64 | url->scheme = malloc (len + 1); | ||
65 | if (!url->scheme) | ||
66 | return ENOMEM; | ||
67 | memcpy (url->scheme, name, len); | ||
68 | url->scheme[len] = 0; | ||
69 | |||
70 | return 0; | 41 | return 0; |
71 | } | 42 | } |
72 | 43 | ||
73 | static int | 44 | static int |
74 | remote_folder_init (mu_folder_t folder MU_ARG_UNUSED) | 45 | _remote_is_scheme (mu_record_t record, mu_url_t url, int flags) |
75 | { | 46 | { |
47 | char *scheme = url->scheme; | ||
48 | size_t scheme_len = scheme ? strlen (scheme) : 0; | ||
49 | int rc; | ||
50 | struct _mu_url s_url; | ||
51 | |||
52 | if (!scheme | ||
53 | || scheme_len < MU_REMOTE_MBOX_PREFIX_LEN | ||
54 | || memcmp (MU_REMOTE_MBOX_PREFIX, scheme, | ||
55 | MU_REMOTE_MBOX_PREFIX_LEN) != 0) | ||
56 | return EINVAL; | ||
57 | |||
58 | |||
59 | memcpy (&s_url, url, sizeof (s_url)); | ||
60 | s_url.scheme = scheme + MU_REMOTE_MBOX_PREFIX_LEN; | ||
61 | if (mu_registrar_lookup_url (&s_url, 0, NULL, NULL) == 0) | ||
62 | return MU_FOLDER_ATTRIBUTE_FILE; | ||
76 | return 0; | 63 | return 0; |
77 | } | 64 | } |
78 | 65 | ||
... | @@ -80,12 +67,12 @@ static struct _mu_record _remote_mbox_record = | ... | @@ -80,12 +67,12 @@ static struct _mu_record _remote_mbox_record = |
80 | { | 67 | { |
81 | MU_REMOTE_MBOX_PRIO, | 68 | MU_REMOTE_MBOX_PRIO, |
82 | MU_REMOTE_MBOX_PREFIX, | 69 | MU_REMOTE_MBOX_PREFIX, |
83 | remote_url_init, /* Mailbox init. */ | 70 | NULL, /* URL init. */ |
84 | remote_mbox_init, /* Mailbox init. */ | 71 | remote_mbox_init, /* Mailbox init. */ |
85 | NULL, /* Mailer init. */ | 72 | NULL, /* Mailer init. */ |
86 | remote_folder_init, /* Folder init. */ | 73 | remote_folder_init, /* Folder init. */ |
87 | NULL, /* No need for back pointer. */ | 74 | NULL, /* No need for back pointer. */ |
88 | NULL, /* _is_scheme method. */ | 75 | _remote_is_scheme, /* _is_scheme method. */ |
89 | NULL, /* _get_url method. */ | 76 | NULL, /* _get_url method. */ |
90 | NULL, /* _get_mailbox method. */ | 77 | NULL, /* _get_mailbox method. */ |
91 | NULL, /* _get_mailer method. */ | 78 | NULL, /* _get_mailer method. */ | ... | ... |
... | @@ -177,12 +177,6 @@ remote_mbox_init (mu_mailbox_t mailbox) | ... | @@ -177,12 +177,6 @@ remote_mbox_init (mu_mailbox_t mailbox) |
177 | return EINVAL; | 177 | return EINVAL; |
178 | 178 | ||
179 | s = mu_url_to_string (mailbox->url); | 179 | s = mu_url_to_string (mailbox->url); |
180 | if (rc) | ||
181 | { | ||
182 | MU_DEBUG1 (mailbox->debug, MU_DEBUG_ERROR, | ||
183 | "remote_mbox_init: cannot get url: %s\n", mu_strerror (rc)); | ||
184 | return rc; | ||
185 | } | ||
186 | 180 | ||
187 | MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "remote_mbox_init (%s)\n", s); | 181 | MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "remote_mbox_init (%s)\n", s); |
188 | 182 | ... | ... |
... | @@ -246,7 +246,7 @@ mu_assoc_clear (mu_assoc_t assoc) | ... | @@ -246,7 +246,7 @@ mu_assoc_clear (mu_assoc_t assoc) |
246 | { | 246 | { |
247 | unsigned i, hs; | 247 | unsigned i, hs; |
248 | 248 | ||
249 | if (!assoc) | 249 | if (!assoc || !assoc->tab) |
250 | return; | 250 | return; |
251 | 251 | ||
252 | hs = hash_size[assoc->hash_num]; | 252 | hs = hash_size[assoc->hash_num]; | ... | ... |
... | @@ -155,7 +155,12 @@ _create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name) | ... | @@ -155,7 +155,12 @@ _create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name) |
155 | } | 155 | } |
156 | 156 | ||
157 | /* Make sure scheme contains actual mailbox scheme */ | 157 | /* Make sure scheme contains actual mailbox scheme */ |
158 | if (strcmp (url->scheme, record->scheme)) | 158 | /* FIXME: It is appropriate not for all record types. For now we |
159 | assume that if the record scheme ends with a plus sign, this | ||
160 | should not be done. Probably it requires some flag in struct | ||
161 | _mu_record? */ | ||
162 | if (record->scheme[strlen(record->scheme)-1] != '+' | ||
163 | && strcmp (url->scheme, record->scheme)) | ||
159 | { | 164 | { |
160 | char *p = strdup (record->scheme); | 165 | char *p = strdup (record->scheme); |
161 | if (!p) | 166 | if (!p) | ... | ... |
-
Please register or sign in to post a comment