mgsve_plain
};
-#define MGSVE CC->MGSVE
+#define MGSVE ((struct citmgsve *)CC->session_specific_data)
/*****************************************************************************/
/* MANAGESIEVE Server */
/*****************************************************************************/
+
void sieve_outbuf_append(char *str)
{
size_t newlen = strlen(str)+1;
CC->internal_pgm = 1;
CC->cs_flags |= CS_STEALTH;
- MGSVE = malloc(sizeof(struct citmgsve));
+ CC->session_specific_data = malloc(sizeof(struct citmgsve));
memset(MGSVE, 0, sizeof(struct citmgsve));
cmd_mgsve_caps();
}
}
+/*
+ * This cleanup function blows away the temporary memory and files used by
+ * the server.
+ */
+void managesieve_cleanup_function(void) {
+
+ /* Don't do this stuff if this is not a managesieve session! */
+ if (CC->h_command_function != managesieve_command_loop) return;
+
+ lprintf(CTDL_DEBUG, "Performing managesieve cleanup hook\n");
+ free(MGSVE);
+}
+
+
#endif /* HAVE_LIBSIEVE */
const char* CitadelServiceManageSieve = "ManageSieve";
{
#ifdef HAVE_LIBSIEVE
-
- CtdlRegisterServiceHook(config.c_managesieve_port, /* MGSVE */
+ CtdlRegisterServiceHook(config.c_managesieve_port,
NULL,
managesieve_greeting,
managesieve_command_loop,
NULL,
CitadelServiceManageSieve);
+ CtdlRegisterSessionHook(managesieve_cleanup_function, EVT_STOP);
#else /* HAVE_LIBSIEVE */