Commit 014fc925 014fc9250450751f3f0bd6a9f36da8ba7cca7e49 by Sergey Poznyakoff

(mailbox_create): Rewritten using registrar_lookup()

1 parent a84aa11a
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -47,42 +47,22 @@
int
mailbox_create (mailbox_t *pmbox, const char *name)
{
int status = EINVAL;
record_t record = NULL;
int (*m_init) __P ((mailbox_t)) = NULL;
int (*u_init) __P ((url_t)) = NULL;
iterator_t iterator;
list_t list;
int found = 0;
if (pmbox == NULL)
return MU_ERR_OUT_PTR_NULL;
/* Look in the registrar, for a match */
registrar_get_list (&list);
status = list_get_iterator (list, &iterator);
if (status != 0)
return status;
for (iterator_first (iterator); !iterator_is_done (iterator);
iterator_next (iterator))
{
iterator_current (iterator, (void **)&record);
if (record_is_scheme (record, name))
if (registrar_lookup (name, &record) == 0)
{
int (*m_init) __P ((mailbox_t)) = NULL;
int (*u_init) __P ((url_t)) = NULL;
record_get_mailbox (record, &m_init);
record_get_url (record, &u_init);
if (m_init && u_init)
{
found = 1;
break;
}
}
}
iterator_destroy (&iterator);
if (found)
{
url_t url = NULL;
int status;
url_t url;
mailbox_t mbox;
/* Allocate memory for mbox. */
......@@ -92,7 +72,7 @@ mailbox_create (mailbox_t *pmbox, const char *name)
/* Initialize the internal lock now, so the concrete mailbox
could use it. */
status = monitor_create (&(mbox->monitor), 0, mbox);
status = monitor_create (&mbox->monitor, 0, mbox);
if (status != 0)
{
mailbox_destroy (&mbox);
......@@ -120,11 +100,12 @@ mailbox_create (mailbox_t *pmbox, const char *name)
mailbox_destroy (&mbox);
else
*pmbox = mbox;
}
else
status = MU_ERR_NO_HANDLER;
return status;
}
}
return MU_ERR_NO_HANDLER;
}
void
......