3 * IMAP server for the Citadel/UX system
4 * Copyright (C) 2000 by Art Cancro and others.
5 * This code is released under the terms of the GNU General Public License.
7 * Current status of standards conformance:
9 * *** ABSOLUTELY NOTHING WORKS ***
21 #include <sys/types.h>
29 #include "sysdep_decls.h"
30 #include "citserver.h"
33 #include "dynloader.h"
40 #include "internet_addressing.h"
41 #include "serv_imap.h"
48 * This cleanup function blows away the temporary memory and files used by
51 void imap_cleanup_function(void) {
53 /* Don't do this stuff if this is not a IMAP session! */
54 if (CC->h_command_function != imap_command_loop) return;
56 lprintf(9, "Performing IMAP cleanup hook\n");
59 lprintf(9, "Finished IMAP cleanup hook\n");
65 * Here's where our IMAP session begins its happy day.
67 void imap_greeting(void) {
69 strcpy(CC->cs_clientname, "IMAP session");
71 CtdlAllocUserData(SYM_IMAP, sizeof(struct citimap));
73 cprintf("don't go here! this doesn't work!\r\n");
80 * Main command loop for IMAP sessions.
82 void imap_command_loop(void) {
86 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
87 if (client_gets(cmdbuf) < 1) {
88 lprintf(3, "IMAP socket is broken. Ending session.\r\n");
92 lprintf(5, "citserver[%3d]: %s\r\n", CC->cs_pid, cmdbuf);
93 while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
95 if (!strncasecmp(cmdbuf, "NOOP", 4)) { /* FIXME */
96 cprintf("+OK This command successfully did nothing.\r\n");
99 else if (!strncasecmp(cmdbuf, "QUIT", 4)) { /* FIXME */
100 cprintf("+OK Goodbye...\r\n");
105 /* FIXME ... implement login commands HERE */
107 else if (!CC->logged_in) { /* FIXME */
108 cprintf("-ERR Not logged in.\r\n");
111 /* FIXME ... implement commands requiring login here */
115 cprintf("500 I'm afraid I can't do that, Dave.\r\n");
122 char *Dynamic_Module_Init(void)
124 SYM_IMAP = CtdlGetDynamicSymbol();
125 CtdlRegisterServiceHook(143, /* FIXME */
129 CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);