Commit 85d30d29 85d30d2919f22544355df1d31ba3615d9dc2d4a9 by Sergey Poznyakoff

(mailbox_folder_create): New function

(mailbox_create): Use mailbox_folder_create.
1 parent dee15093
...@@ -40,6 +40,23 @@ ...@@ -40,6 +40,23 @@
40 40
41 #include <mailbox0.h> 41 #include <mailbox0.h>
42 42
43 int
44 mailbox_folder_create (folder_t *pfolder, const char *name)
45 {
46 int rc;
47 char *p, *fname = strdup (name);
48
49 if (!fname)
50 return ENOMEM;
51
52 p = strrchr (fname, '/'); /* FIXME: Is this always appropriate? */
53 if (p)
54 *p = 0;
55 rc = folder_create (pfolder, fname);
56 free (fname);
57 return rc;
58 }
59
43 /* The Mailbox Factory. 60 /* The Mailbox Factory.
44 Create an iterator for registrar and see if any url scheme match, 61 Create an iterator for registrar and see if any url scheme match,
45 Then we call the mailbox's url_create() to parse the URL. Last 62 Then we call the mailbox's url_create() to parse the URL. Last
...@@ -52,7 +69,7 @@ mailbox_create (mailbox_t *pmbox, const char *name) ...@@ -52,7 +69,7 @@ mailbox_create (mailbox_t *pmbox, const char *name)
52 if (pmbox == NULL) 69 if (pmbox == NULL)
53 return MU_ERR_OUT_PTR_NULL; 70 return MU_ERR_OUT_PTR_NULL;
54 71
55 if (registrar_lookup (name, &record) == 0) 72 if (registrar_lookup (name, &record, MU_FOLDER_ATTRIBUTE_FILE))
56 { 73 {
57 int (*m_init) __P ((mailbox_t)) = NULL; 74 int (*m_init) __P ((mailbox_t)) = NULL;
58 int (*u_init) __P ((url_t)) = NULL; 75 int (*u_init) __P ((url_t)) = NULL;
...@@ -91,7 +108,7 @@ mailbox_create (mailbox_t *pmbox, const char *name) ...@@ -91,7 +108,7 @@ mailbox_create (mailbox_t *pmbox, const char *name)
91 108
92 /* Create the folder before initializing the concrete mailbox. 109 /* Create the folder before initializing the concrete mailbox.
93 The mailbox needs it's back pointer. */ 110 The mailbox needs it's back pointer. */
94 status = folder_create (&mbox->folder, name); 111 status = mailbox_folder_create (&mbox->folder, name);
95 112
96 if (status == 0) 113 if (status == 0)
97 status = m_init (mbox); /* Create the concrete mailbox type. */ 114 status = m_init (mbox); /* Create the concrete mailbox type. */
......