#define ENVELOPE_NIL_REPLY \
"(NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL)"
-#define IMAP_FETCH_HANDLER_COUNT 11
-extern const struct imap_fetch_handler
- imap_fetch_default_handlers[IMAP_FETCH_HANDLER_COUNT];
-static buffer_t *fetch_handlers = NULL;
+static buffer_t *fetch_handlers;
static int imap_fetch_handler_cmp(const void *p1, const void *p2)
{
void *data;
size_t size;
- if (fetch_handlers == NULL)
- fetch_handlers = buffer_create_dynamic(default_pool, 128);
buffer_append(fetch_handlers, handlers, sizeof(*handlers) * count);
data = buffer_get_modifiable_data(fetch_handlers, &size);
struct client *client = cmd->client;
struct imap_fetch_context *ctx;
- if (fetch_handlers == NULL) {
- imap_fetch_handlers_register(imap_fetch_default_handlers,
- N_ELEMENTS(imap_fetch_default_handlers));
- }
-
ctx = p_new(cmd->pool, struct imap_fetch_context, 1);
ctx->client = client;
ctx->cmd = cmd;
return TRUE;
}
-const struct imap_fetch_handler
-imap_fetch_default_handlers[IMAP_FETCH_HANDLER_COUNT] = {
+static const struct imap_fetch_handler
+imap_fetch_default_handlers[] = {
{ "BODY", fetch_body_init },
{ "BODYSTRUCTURE", fetch_bodystructure_init },
{ "ENVELOPE", fetch_envelope_init },
{ "X-MAILBOX", fetch_x_mailbox_init },
{ "X-SAVEDATE", fetch_x_savedate_init }
};
+
+void imap_fetch_handlers_init(void)
+{
+ fetch_handlers = buffer_create_dynamic(default_pool, 128);
+ imap_fetch_handlers_register(imap_fetch_default_handlers,
+ N_ELEMENTS(imap_fetch_default_handlers));
+}
+
+void imap_fetch_handlers_deinit(void)
+{
+ buffer_free(&fetch_handlers);
+}
#include "mail-user.h"
#include "mail-storage-service.h"
#include "imap-commands.h"
+#include "imap-fetch.h"
#include <stdio.h>
#include <stdlib.h>
/* plugins may want to add commands, so this needs to be called early */
commands_init();
+ imap_fetch_handlers_init();
mail_user = mail_storage_service_init_user(service, &input, set_roots,
storage_service_flags);
main_deinit();
mail_storage_service_deinit_user();
+ imap_fetch_handlers_deinit();
commands_deinit();
master_service_deinit(&service);