#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <libcitadel.h>
#include "citadel.h"
#include "server.h"
#include "citserver.h"
#include "policy.h"
#include "database.h"
#include "msgbase.h"
-#include "tools.h"
#include "internet_addressing.h"
#include "imap_tools.h" /* Needed for imap_parameterize */
#include "genstamp.h"
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();
}
if (strlen(argbuf) >= 7) {
}
else {
- CtdlEncodeBase64(username_prompt, "Username:", 9);
+ CtdlEncodeBase64(username_prompt, "Username:", 9, 0);
cprintf("334 %s\r\n", username_prompt);
}
return;
}
+/*
+ * 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 */
+#endif /* HAVE_LIBSIEVE */
+const char* CitadelServiceManageSieve = "ManageSieve";
CTDL_MODULE_INIT(managesieve)
{
#ifdef HAVE_LIBSIEVE
-
- CtdlRegisterServiceHook(config.c_managesieve_port, /* MGSVE */
+ CtdlRegisterServiceHook(config.c_managesieve_port,
NULL,
managesieve_greeting,
managesieve_command_loop,
- NULL);
+ NULL,
+ CitadelServiceManageSieve);
+ CtdlRegisterSessionHook(managesieve_cleanup_function, EVT_STOP);
#else /* HAVE_LIBSIEVE */