Commit fe794428 fe794428652597296a86ede2f4a922f88faa18c0 by Sergey Poznyakoff

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.
1 parent 98f645ab
2008-10-05 Sergey Poznyakoff <gray@gnu.org.ua>
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.
Minor fixes in configuration.
* doc/texinfo/programs.texi: Document Locking, ACL, and
Tcp-wrappers.
* mailbox/cfg_driver.c (mu_cfg_assert_value_type): Convert
......
......@@ -35,44 +35,31 @@
extern int remote_mbox_init (mu_mailbox_t mailbox);
int
remote_url_init (mu_url_t url)
static int
remote_folder_init (mu_folder_t folder MU_ARG_UNUSED)
{
const char *name = mu_url_to_string (url);
const char *p;
size_t len = strlen (name);
int rc;
if (!name)
return 0;
/* reject the obvious */
if (name == NULL
|| len < MU_REMOTE_MBOX_PREFIX_LEN
|| strncmp (MU_REMOTE_MBOX_PREFIX, name, MU_REMOTE_MBOX_PREFIX_LEN) != 0)
return EINVAL;
rc = mu_registrar_lookup (name + MU_REMOTE_MBOX_PREFIX_LEN, 0, NULL, NULL);
if (rc)
return rc;
p = strchr (name, ':');
if (!p)
return EINVAL;
p++;
len = p - name;
url->scheme = malloc (len + 1);
if (!url->scheme)
return ENOMEM;
memcpy (url->scheme, name, len);
url->scheme[len] = 0;
return 0;
}
static int
remote_folder_init (mu_folder_t folder MU_ARG_UNUSED)
_remote_is_scheme (mu_record_t record, mu_url_t url, int flags)
{
char *scheme = url->scheme;
size_t scheme_len = scheme ? strlen (scheme) : 0;
int rc;
struct _mu_url s_url;
if (!scheme
|| scheme_len < MU_REMOTE_MBOX_PREFIX_LEN
|| memcmp (MU_REMOTE_MBOX_PREFIX, scheme,
MU_REMOTE_MBOX_PREFIX_LEN) != 0)
return EINVAL;
memcpy (&s_url, url, sizeof (s_url));
s_url.scheme = scheme + MU_REMOTE_MBOX_PREFIX_LEN;
if (mu_registrar_lookup_url (&s_url, 0, NULL, NULL) == 0)
return MU_FOLDER_ATTRIBUTE_FILE;
return 0;
}
......@@ -80,12 +67,12 @@ static struct _mu_record _remote_mbox_record =
{
MU_REMOTE_MBOX_PRIO,
MU_REMOTE_MBOX_PREFIX,
remote_url_init, /* Mailbox init. */
NULL, /* URL init. */
remote_mbox_init, /* Mailbox init. */
NULL, /* Mailer init. */
remote_folder_init, /* Folder init. */
NULL, /* No need for back pointer. */
NULL, /* _is_scheme method. */
_remote_is_scheme, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
......
......@@ -177,12 +177,6 @@ remote_mbox_init (mu_mailbox_t mailbox)
return EINVAL;
s = mu_url_to_string (mailbox->url);
if (rc)
{
MU_DEBUG1 (mailbox->debug, MU_DEBUG_ERROR,
"remote_mbox_init: cannot get url: %s\n", mu_strerror (rc));
return rc;
}
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "remote_mbox_init (%s)\n", s);
......
......@@ -246,7 +246,7 @@ mu_assoc_clear (mu_assoc_t assoc)
{
unsigned i, hs;
if (!assoc)
if (!assoc || !assoc->tab)
return;
hs = hash_size[assoc->hash_num];
......
......@@ -155,7 +155,12 @@ _create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name)
}
/* Make sure scheme contains actual mailbox scheme */
if (strcmp (url->scheme, record->scheme))
/* FIXME: It is appropriate not for all record types. For now we
assume that if the record scheme ends with a plus sign, this
should not be done. Probably it requires some flag in struct
_mu_record? */
if (record->scheme[strlen(record->scheme)-1] != '+'
&& strcmp (url->scheme, record->scheme))
{
char *p = strdup (record->scheme);
if (!p)
......