(mu_folder_create_from_record): New function.
(mu_folder_create): Interface to mu_folder_create_from_record
Showing
1 changed file
with
15 additions
and
9 deletions
... | @@ -53,16 +53,16 @@ static struct mu_monitor folder_lock = MU_MONITOR_INITIALIZER; | ... | @@ -53,16 +53,16 @@ static struct mu_monitor folder_lock = MU_MONITOR_INITIALIZER; |
53 | they maybe cases where you want a different folder for the same URL, there | 53 | they maybe cases where you want a different folder for the same URL, there |
54 | is not easy way to do this. */ | 54 | is not easy way to do this. */ |
55 | int | 55 | int |
56 | mu_folder_create (mu_folder_t *pfolder, const char *name) | 56 | mu_folder_create_from_record (mu_folder_t *pfolder, const char *name, |
57 | mu_record_t record) | ||
57 | { | 58 | { |
58 | mu_record_t record; | 59 | if (!pfolder) |
59 | |||
60 | if (pfolder == NULL) | ||
61 | return MU_ERR_OUT_PTR_NULL; | 60 | return MU_ERR_OUT_PTR_NULL; |
62 | 61 | ||
62 | if (record || | ||
63 | /* Look in the registrar list(iterator), for a possible concrete mailbox | 63 | /* Look in the registrar list(iterator), for a possible concrete mailbox |
64 | implementation that could match the URL. */ | 64 | implementation that could match the URL. */ |
65 | if (mu_registrar_lookup (name, MU_FOLDER_ATTRIBUTE_DIRECTORY, &record, NULL) | 65 | mu_registrar_lookup (name, MU_FOLDER_ATTRIBUTE_DIRECTORY, &record, NULL) |
66 | == 0) | 66 | == 0) |
67 | { | 67 | { |
68 | int (*f_init) (mu_folder_t) = NULL; | 68 | int (*f_init) (mu_folder_t) = NULL; |
... | @@ -98,14 +98,14 @@ mu_folder_create (mu_folder_t *pfolder, const char *name) | ... | @@ -98,14 +98,14 @@ mu_folder_create (mu_folder_t *pfolder, const char *name) |
98 | 98 | ||
99 | /* Create a new folder. */ | 99 | /* Create a new folder. */ |
100 | 100 | ||
101 | /* Allocate memory for folder. */ | 101 | /* Allocate memory for the folder. */ |
102 | folder = calloc (1, sizeof (*folder)); | 102 | folder = calloc (1, sizeof (*folder)); |
103 | if (folder != NULL) | 103 | if (folder != NULL) |
104 | { | 104 | { |
105 | folder->url = url; | 105 | folder->url = url; |
106 | /* Initialize the internal foilder lock, now so the | 106 | /* Initialize the internal foilder lock, now so the |
107 | concrete folder could use it. */ | 107 | concrete folder could use it. */ |
108 | status = mu_monitor_create (&(folder->monitor), 0, folder); | 108 | status = mu_monitor_create (&folder->monitor, 0, folder); |
109 | if (status == 0) | 109 | if (status == 0) |
110 | { | 110 | { |
111 | /* Create the concrete folder type. */ | 111 | /* Create the concrete folder type. */ |
... | @@ -124,9 +124,9 @@ mu_folder_create (mu_folder_t *pfolder, const char *name) | ... | @@ -124,9 +124,9 @@ mu_folder_create (mu_folder_t *pfolder, const char *name) |
124 | if (status) | 124 | if (status) |
125 | { | 125 | { |
126 | if (folder->monitor) | 126 | if (folder->monitor) |
127 | mu_monitor_destroy (&(folder->monitor), folder); | 127 | mu_monitor_destroy (&folder->monitor, folder); |
128 | if (folder->url) | 128 | if (folder->url) |
129 | mu_url_destroy (&(folder->url)); | 129 | mu_url_destroy (&folder->url); |
130 | free (folder); | 130 | free (folder); |
131 | } | 131 | } |
132 | } | 132 | } |
... | @@ -137,6 +137,12 @@ mu_folder_create (mu_folder_t *pfolder, const char *name) | ... | @@ -137,6 +137,12 @@ mu_folder_create (mu_folder_t *pfolder, const char *name) |
137 | return MU_ERR_NOENT; | 137 | return MU_ERR_NOENT; |
138 | } | 138 | } |
139 | 139 | ||
140 | int | ||
141 | mu_folder_create (mu_folder_t *pfolder, const char *name) | ||
142 | { | ||
143 | return mu_folder_create_from_record (pfolder, name, NULL); | ||
144 | } | ||
145 | |||
140 | /* The folder is destroy if it is the last reference. */ | 146 | /* The folder is destroy if it is the last reference. */ |
141 | void | 147 | void |
142 | mu_folder_destroy (mu_folder_t *pfolder) | 148 | mu_folder_destroy (mu_folder_t *pfolder) | ... | ... |
-
Please register or sign in to post a comment