4 * IMAP server for the Citadel/UX system
5 * Copyright (C) 2000-2001 by Art Cancro and others.
6 * This code is released under the terms of the GNU General Public License.
8 * WARNING: this is an incomplete implementation, still in progress. Parts of
9 * it work, but it's not really usable yet from a user perspective.
11 * WARNING: Mark Crispin is an idiot. IMAP is the most brain-damaged protocol
12 * you will ever have the profound lack of pleasure to encounter.
24 #include <sys/types.h>
33 #include "sysdep_decls.h"
34 #include "citserver.h"
37 #include "dynloader.h"
44 #include "internet_addressing.h"
45 #include "serv_imap.h"
46 #include "imap_tools.h"
47 #include "imap_fetch.h"
48 #include "imap_search.h"
49 #include "imap_store.h"
50 #include "imap_misc.h"
57 * If there is a message ID map in memory, free it
59 void imap_free_msgids(void) {
60 if (IMAP->msgids != NULL) {
65 if (IMAP->flags != NULL) {
73 * If there is a transmitted message in memory, free it
75 void imap_free_transmitted_message(void) {
76 if (IMAP->transmitted_message != NULL) {
77 phree(IMAP->transmitted_message);
78 IMAP->transmitted_message = NULL;
79 IMAP->transmitted_length = 0;
85 * Back end for imap_load_msgids()
87 * FIXME: this should be optimized by figuring out a way to allocate memory
88 * once rather than doing a reallok() for each message.
90 void imap_add_single_msgid(long msgnum, void *userdata) {
92 IMAP->num_msgs = IMAP->num_msgs + 1;
93 if (IMAP->msgids == NULL) {
94 IMAP->msgids = mallok(IMAP->num_msgs * sizeof(long));
97 IMAP->msgids = reallok(IMAP->msgids,
98 IMAP->num_msgs * sizeof(long));
100 if (IMAP->flags == NULL) {
101 IMAP->flags = mallok(IMAP->num_msgs * sizeof(long));
104 IMAP->flags = reallok(IMAP->flags,
105 IMAP->num_msgs * sizeof(long));
107 IMAP->msgids[IMAP->num_msgs - 1] = msgnum;
108 IMAP->flags[IMAP->num_msgs - 1] = 0;
114 * Set up a message ID map for the current room (folder)
116 void imap_load_msgids(void) {
118 if (IMAP->selected == 0) {
119 lprintf(5, "imap_load_msgids() can't run; no room selected\n");
123 imap_free_msgids(); /* If there was already a map, free it */
125 CtdlForEachMessage(MSGS_ALL, 0L, (-63), NULL, NULL,
126 imap_add_single_msgid, NULL);
128 lprintf(9, "imap_load_msgids() mapped %d messages\n", IMAP->num_msgs);
133 * Re-scan the selected room (folder) and see if it's been changed at all
135 void imap_rescan_msgids(void) {
137 int original_num_msgs = 0;
138 long original_highest = 0L;
142 if (IMAP->selected == 0) {
143 lprintf(5, "imap_load_msgids() can't run; no room selected\n");
149 * Check to see if any of the messages we know about have been expunged
151 if (IMAP->num_msgs > 0)
152 for (i=0; i<IMAP->num_msgs; ++i) {
154 count = CtdlForEachMessage(MSGS_EQ, IMAP->msgids[i],
155 (-63), NULL, NULL, NULL, NULL);
158 cprintf("* %d EXPUNGE\r\n", i+1);
160 /* Here's some nice stupid nonsense. When a message
161 * is expunged, we have to slide all the existing
162 * messages up in the message array.
165 memcpy(&IMAP->msgids[i], &IMAP->msgids[i+1],
166 (sizeof(long)*(IMAP->num_msgs-i)) );
167 memcpy(&IMAP->flags[i], &IMAP->flags[i+1],
168 (sizeof(long)*(IMAP->num_msgs-i)) );
176 * Remember how many messages were here before we re-scanned.
178 original_num_msgs = IMAP->num_msgs;
179 if (IMAP->num_msgs > 0) {
180 original_highest = IMAP->msgids[IMAP->num_msgs - 1];
183 original_highest = 0L;
187 * Now peruse the room for *new* messages only.
189 CtdlForEachMessage(MSGS_GT, original_highest, (-63), NULL, NULL,
190 imap_add_single_msgid, NULL);
193 * If new messages have arrived, tell the client about them.
195 if (IMAP->num_msgs > original_num_msgs) {
196 cprintf("* %d EXISTS\r\n", IMAP->num_msgs);
208 * This cleanup function blows away the temporary memory and files used by
211 void imap_cleanup_function(void) {
213 /* Don't do this stuff if this is not a IMAP session! */
214 if (CC->h_command_function != imap_command_loop) return;
216 lprintf(9, "Performing IMAP cleanup hook\n");
218 imap_free_transmitted_message();
219 lprintf(9, "Finished IMAP cleanup hook\n");
225 * Here's where our IMAP session begins its happy day.
227 void imap_greeting(void) {
229 strcpy(CC->cs_clientname, "IMAP session");
230 CtdlAllocUserData(SYM_IMAP, sizeof(struct citimap));
231 IMAP->authstate = imap_as_normal;
233 cprintf("* OK %s Citadel/UX IMAP4rev1 server ready\r\n",
239 * implements the LOGIN command (ordinary username/password login)
241 void imap_login(int num_parms, char *parms[]) {
242 if (CtdlLoginExistingUser(parms[2]) == login_ok) {
243 if (CtdlTryPassword(parms[3]) == pass_ok) {
244 cprintf("%s OK login successful\r\n", parms[0]);
249 cprintf("%s BAD Login incorrect\r\n", parms[0]);
254 * Implements the AUTHENTICATE command
256 void imap_authenticate(int num_parms, char *parms[]) {
259 if (num_parms != 3) {
260 cprintf("%s BAD incorrect number of parameters\r\n", parms[0]);
264 if (!strcasecmp(parms[2], "LOGIN")) {
265 encode_base64(buf, "Username:");
266 cprintf("+ %s\r\n", buf);
267 IMAP->authstate = imap_as_expecting_username;
268 strcpy(IMAP->authseq, parms[0]);
273 cprintf("%s NO AUTHENTICATE %s failed\r\n",
278 void imap_auth_login_user(char *cmd) {
281 decode_base64(buf, cmd);
282 CtdlLoginExistingUser(buf);
283 encode_base64(buf, "Password:");
284 cprintf("+ %s\r\n", buf);
285 IMAP->authstate = imap_as_expecting_password;
289 void imap_auth_login_pass(char *cmd) {
292 decode_base64(buf, cmd);
293 if (CtdlTryPassword(buf) == pass_ok) {
294 cprintf("%s OK authentication succeeded\r\n", IMAP->authseq);
297 cprintf("%s NO authentication failed\r\n", IMAP->authseq);
299 IMAP->authstate = imap_as_normal;
306 * implements the CAPABILITY command
308 void imap_capability(int num_parms, char *parms[]) {
309 cprintf("* CAPABILITY IMAP4 IMAP4REV1 AUTH=LOGIN\r\n");
310 cprintf("%s OK CAPABILITY completed\r\n", parms[0]);
318 * implements the SELECT command
320 void imap_select(int num_parms, char *parms[]) {
322 char augmented_roomname[ROOMNAMELEN];
326 struct quickroom QRscratch;
332 /* Convert the supplied folder name to a roomname */
333 i = imap_roomname(towhere, sizeof towhere, parms[2]);
335 cprintf("%s NO Invalid mailbox name.\r\n", parms[0]);
339 floornum = (i & 0x00ff);
340 roomflags = (i & 0xff00);
342 /* First try a regular match */
343 c = getroom(&QRscratch, towhere);
345 /* Then try a mailbox name match */
347 MailboxName(augmented_roomname, &CC->usersupp, towhere);
348 c = getroom(&QRscratch, augmented_roomname);
350 strcpy(towhere, augmented_roomname);
353 /* If the room exists, check security/access */
355 /* See if there is an existing user/room relationship */
356 ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
358 /* normal clients have to pass through security */
364 /* Fail here if no such room */
366 cprintf("%s NO ... no such room, or access denied\r\n",
373 * usergoto() formally takes us to the desired room, happily returning
374 * the number of messages and number of new messages.
376 usergoto(QRscratch.QRname, 0, &msgs, &new);
379 if (!strcasecmp(parms[1], "EXAMINE")) {
388 /* FIXME ... much more info needs to be supplied here */
389 cprintf("* %d EXISTS\r\n", msgs);
390 cprintf("* %d RECENT\r\n", new);
391 cprintf("* FLAGS (\\Deleted)\r\n");
392 cprintf("* OK [PERMANENTFLAGS (\\Deleted)] permanent flags\r\n");
393 cprintf("* OK [UIDVALIDITY 0] UIDs valid\r\n");
394 cprintf("%s OK [%s] %s completed\r\n",
396 (IMAP->readonly ? "READ-ONLY" : "READ-WRITE"),
403 * does the real work for expunge
405 int imap_do_expunge(void) {
407 int num_expunged = 0;
409 if (IMAP->num_msgs > 0) for (i=0; i<IMAP->num_msgs; ++i) {
410 if (IMAP->flags[i] & IMAP_DELETED) {
411 CtdlDeleteMessages(CC->quickroom.QRname,
412 IMAP->msgids[i], "");
417 if (num_expunged > 0) {
418 imap_rescan_msgids();
421 return(num_expunged);
426 * implements the EXPUNGE command syntax
428 void imap_expunge(int num_parms, char *parms[]) {
429 int num_expunged = 0;
431 cprintf("%s OK expunged %d messages.\r\n", parms[0], num_expunged);
436 * implements the CLOSE command
438 void imap_close(int num_parms, char *parms[]) {
440 /* Yes, we always expunge on close. */
446 cprintf("%s OK CLOSE completed\r\n", parms[0]);
453 * Used by LIST and LSUB to show the floors in the listing
455 void imap_list_floors(char *cmd, char *pattern) {
459 for (i=0; i<MAXFLOORS; ++i) {
461 if (fl->f_flags & F_INUSE) {
462 if (imap_mailbox_matches_pattern(pattern, fl->f_name)) {
463 cprintf("* %s (\\NoSelect) \"|\" ", cmd);
464 imap_strout(fl->f_name);
474 * Back end for imap_lsub()
476 * IMAP "subscribed folder" is equivocated to Citadel "known rooms." This
477 * may or may not be the desired behavior in the future.
479 void imap_lsub_listroom(struct quickroom *qrbuf, void *data) {
484 pattern = (char *)data;
486 /* Only list rooms to which the user has access!! */
487 ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
489 imap_mailboxname(buf, sizeof buf, qrbuf);
490 if (imap_mailbox_matches_pattern(pattern, buf)) {
491 cprintf("* LSUB (\\NoInferiors) \"|\" ");
500 * Implements the LSUB command
502 void imap_lsub(int num_parms, char *parms[]) {
505 cprintf("%s BAD arguments invalid\r\n", parms[0]);
508 sprintf(pattern, "%s%s", parms[2], parms[3]);
510 if (strlen(parms[3])==0) {
511 cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
515 imap_list_floors("LSUB", pattern);
516 ForEachRoom(imap_lsub_listroom, pattern);
519 cprintf("%s OK LSUB completed\r\n", parms[0]);
525 * Back end for imap_list()
527 void imap_list_listroom(struct quickroom *qrbuf, void *data) {
532 pattern = (char *)data;
534 /* Only list rooms to which the user has access!! */
535 ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
537 || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))) {
538 imap_mailboxname(buf, sizeof buf, qrbuf);
539 if (imap_mailbox_matches_pattern(pattern, buf)) {
540 cprintf("* LIST (\\NoInferiors) \"|\" ");
549 * Implements the LIST command
551 void imap_list(int num_parms, char *parms[]) {
554 cprintf("%s BAD arguments invalid\r\n", parms[0]);
557 sprintf(pattern, "%s%s", parms[2], parms[3]);
559 if (strlen(parms[3])==0) {
560 cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
564 imap_list_floors("LIST", pattern);
565 ForEachRoom(imap_list_listroom, pattern);
568 cprintf("%s OK LIST completed\r\n", parms[0]);
574 * Implements the CREATE command
577 void imap_create(int num_parms, char *parms[]) {
579 char roomname[ROOMNAMELEN];
584 ret = imap_roomname(roomname, sizeof roomname, parms[2]);
586 cprintf("%s NO Invalid mailbox name or location\r\n",
590 floornum = ( ret & 0x00ff ); /* lower 8 bits = floor number */
591 flags = ( ret & 0xff00 ); /* upper 8 bits = flags */
593 if (flags & IR_MAILBOX) {
594 newroomtype = 4; /* private mailbox */
597 newroomtype = 0; /* public folder */
600 lprintf(7, "Create new room <%s> on floor <%d> with type <%d>\n",
601 roomname, floornum, newroomtype);
603 ret = create_room(roomname, newroomtype, "", floornum, 1);
605 cprintf("%s NO Mailbox already exists, or create failed\r\n",
609 cprintf("%s OK CREATE completed\r\n", parms[0]);
615 * Locate a room by its IMAP folder name, and check access to it
617 int imap_grabroom(char *returned_roomname, char *foldername) {
619 char augmented_roomname[ROOMNAMELEN];
620 char roomname[ROOMNAMELEN];
622 struct quickroom QRscratch;
626 ret = imap_roomname(roomname, sizeof roomname, foldername);
631 /* First try a regular match */
632 c = getroom(&QRscratch, roomname);
634 /* Then try a mailbox name match */
636 MailboxName(augmented_roomname, &CC->usersupp, roomname);
637 c = getroom(&QRscratch, augmented_roomname);
639 strcpy(roomname, augmented_roomname);
642 /* If the room exists, check security/access */
644 /* See if there is an existing user/room relationship */
645 ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
647 /* normal clients have to pass through security */
653 /* Fail here if no such room */
655 strcpy(returned_roomname, "");
659 strcpy(returned_roomname, QRscratch.QRname);
666 * Implements the STATUS command (sort of)
669 void imap_status(int num_parms, char *parms[]) {
671 char roomname[ROOMNAMELEN];
673 char savedroom[ROOMNAMELEN];
676 ret = imap_grabroom(roomname, parms[2]);
678 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
684 * usergoto() formally takes us to the desired room, happily returning
685 * the number of messages and number of new messages. (If another
686 * folder is selected, save its name so we can return there!!!!!)
688 if (IMAP->selected) {
689 strcpy(savedroom, CC->quickroom.QRname);
691 usergoto(roomname, 0, &msgs, &new);
694 * Tell the client what it wants to know. In fact, tell it *more* than
695 * it wants to know. We happily IGnore the supplied status data item
696 * names and simply spew all possible data items. It's far easier to
697 * code and probably saves us some processing time too.
699 imap_mailboxname(buf, sizeof buf, &CC->quickroom);
700 cprintf("* STATUS ");
702 cprintf(" (MESSAGES %d ", msgs);
703 cprintf("RECENT 0 "); /* FIXME we need to implement this */
704 cprintf("UIDNEXT %ld ", CitControl.MMhighest + 1);
705 cprintf("UNSEEN %d)\r\n", new);
708 * If another folder is selected, go back to that room so we can resume
709 * our happy day without violent explosions.
711 if (IMAP->selected) {
712 usergoto(savedroom, 0, &msgs, &new);
716 * Oooh, look, we're done!
718 cprintf("%s OK STATUS completed\r\n", parms[0]);
724 * Implements the SUBSCRIBE command
727 void imap_subscribe(int num_parms, char *parms[]) {
729 char roomname[ROOMNAMELEN];
730 char savedroom[ROOMNAMELEN];
733 ret = imap_grabroom(roomname, parms[2]);
735 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
741 * usergoto() formally takes us to the desired room, which has the side
742 * effect of marking the room as not-zapped ... exactly the effect
745 if (IMAP->selected) {
746 strcpy(savedroom, CC->quickroom.QRname);
748 usergoto(roomname, 0, &msgs, &new);
751 * If another folder is selected, go back to that room so we can resume
752 * our happy day without violent explosions.
754 if (IMAP->selected) {
755 usergoto(savedroom, 0, &msgs, &new);
758 cprintf("%s OK SUBSCRIBE completed\r\n", parms[0]);
763 * Implements the UNSUBSCRIBE command
766 void imap_unsubscribe(int num_parms, char *parms[]) {
768 char roomname[ROOMNAMELEN];
769 char savedroom[ROOMNAMELEN];
772 ret = imap_grabroom(roomname, parms[2]);
774 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
780 * usergoto() formally takes us to the desired room.
782 if (IMAP->selected) {
783 strcpy(savedroom, CC->quickroom.QRname);
785 usergoto(roomname, 0, &msgs, &new);
788 * Now make the API call to zap the room
790 if (CtdlForgetThisRoom() == 0) {
791 cprintf("%s OK UNSUBSCRIBE completed\r\n", parms[0]);
794 cprintf("%s NO You may not unsubscribe from this folder.\r\n",
799 * If another folder is selected, go back to that room so we can resume
800 * our happy day without violent explosions.
802 if (IMAP->selected) {
803 usergoto(savedroom, 0, &msgs, &new);
810 * Implements the DELETE command
813 void imap_delete(int num_parms, char *parms[]) {
815 char roomname[ROOMNAMELEN];
816 char savedroom[ROOMNAMELEN];
819 ret = imap_grabroom(roomname, parms[2]);
821 cprintf("%s NO Invalid mailbox name, or access denied\r\n",
827 * usergoto() formally takes us to the desired room, happily returning
828 * the number of messages and number of new messages. (If another
829 * folder is selected, save its name so we can return there!!!!!)
831 if (IMAP->selected) {
832 strcpy(savedroom, CC->quickroom.QRname);
834 usergoto(roomname, 0, &msgs, &new);
837 * Now delete the room.
839 if (CtdlDoIHavePermissionToDeleteThisRoom(&CC->quickroom)) {
840 cprintf("%s OK DELETE completed\r\n", parms[0]);
841 delete_room(&CC->quickroom);
844 cprintf("%s NO Can't delete this folder.\r\n", parms[0]);
848 * If another folder is selected, go back to that room so we can resume
849 * our happy day without violent explosions.
851 if (IMAP->selected) {
852 usergoto(savedroom, 0, &msgs, &new);
859 * Implements the RENAME command
862 void imap_rename(int num_parms, char *parms[]) {
863 cprintf("%s NO The RENAME command is not yet implemented (FIXME)\r\n",
870 * Main command loop for IMAP sessions.
872 void imap_command_loop(void) {
878 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
879 if (client_gets(cmdbuf) < 1) {
880 lprintf(3, "IMAP socket is broken. Ending session.\r\n");
885 lprintf(5, "citserver[%3d]: %s\r\n", CC->cs_pid, cmdbuf);
886 while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
889 /* strip off l/t whitespace and CRLF */
890 if (cmdbuf[strlen(cmdbuf)-1]=='\n') cmdbuf[strlen(cmdbuf)-1]=0;
891 if (cmdbuf[strlen(cmdbuf)-1]=='\r') cmdbuf[strlen(cmdbuf)-1]=0;
894 /* If we're in the middle of a multi-line command, handle that */
895 if (IMAP->authstate == imap_as_expecting_username) {
896 imap_auth_login_user(cmdbuf);
899 if (IMAP->authstate == imap_as_expecting_password) {
900 imap_auth_login_pass(cmdbuf);
905 /* Ok, at this point we're in normal command mode. The first thing
906 * we do is print any incoming pages (yeah! we really do!)
908 imap_print_express_messages();
911 * Before processing the command that was just entered... if we happen
912 * to have a folder selected, we'd like to rescan that folder for new
913 * messages, and for deletions/changes of existing messages. This
914 * could probably be optimized somehow, but IMAP sucks...
916 if (IMAP->selected) {
917 imap_rescan_msgids();
920 /* Now for the command set. */
922 /* Grab the tag, command, and parameters. Check syntax. */
923 num_parms = imap_parameterize(parms, cmdbuf);
925 cprintf("BAD syntax error\r\n");
928 /* The commands below may be executed in any state */
930 else if ( (!strcasecmp(parms[1], "NOOP"))
931 || (!strcasecmp(parms[1], "CHECK")) ) {
932 cprintf("%s OK This command successfully did nothing.\r\n",
936 else if (!strcasecmp(parms[1], "LOGOUT")) {
937 cprintf("* BYE %s logging out\r\n", config.c_fqdn);
938 cprintf("%s OK thank you for using Citadel IMAP\r\n", parms[0]);
943 else if (!strcasecmp(parms[1], "LOGIN")) {
944 imap_login(num_parms, parms);
947 else if (!strcasecmp(parms[1], "AUTHENTICATE")) {
948 imap_authenticate(num_parms, parms);
951 else if (!strcasecmp(parms[1], "CAPABILITY")) {
952 imap_capability(num_parms, parms);
955 else if (!CC->logged_in) {
956 cprintf("%s BAD Not logged in.\r\n", parms[0]);
959 /* The commans below require a logged-in state */
961 else if (!strcasecmp(parms[1], "SELECT")) {
962 imap_select(num_parms, parms);
965 else if (!strcasecmp(parms[1], "EXAMINE")) {
966 imap_select(num_parms, parms);
969 else if (!strcasecmp(parms[1], "LSUB")) {
970 imap_lsub(num_parms, parms);
973 else if (!strcasecmp(parms[1], "LIST")) {
974 imap_list(num_parms, parms);
977 else if (!strcasecmp(parms[1], "CREATE")) {
978 imap_create(num_parms, parms);
981 else if (!strcasecmp(parms[1], "DELETE")) {
982 imap_delete(num_parms, parms);
985 else if (!strcasecmp(parms[1], "RENAME")) {
986 imap_rename(num_parms, parms);
989 else if (!strcasecmp(parms[1], "STATUS")) {
990 imap_status(num_parms, parms);
993 else if (!strcasecmp(parms[1], "SUBSCRIBE")) {
994 imap_subscribe(num_parms, parms);
997 else if (!strcasecmp(parms[1], "UNSUBSCRIBE")) {
998 imap_unsubscribe(num_parms, parms);
1001 else if (!strcasecmp(parms[1], "APPEND")) {
1002 imap_append(num_parms, parms);
1005 else if (IMAP->selected == 0) {
1006 cprintf("%s BAD no folder selected\r\n", parms[0]);
1009 /* The commands below require the SELECT state on a mailbox */
1011 else if (!strcasecmp(parms[1], "FETCH")) {
1012 imap_fetch(num_parms, parms);
1015 else if ( (!strcasecmp(parms[1], "UID"))
1016 && (!strcasecmp(parms[2], "FETCH")) ) {
1017 imap_uidfetch(num_parms, parms);
1020 else if (!strcasecmp(parms[1], "SEARCH")) {
1021 imap_search(num_parms, parms);
1024 else if ( (!strcasecmp(parms[1], "UID"))
1025 && (!strcasecmp(parms[2], "SEARCH")) ) {
1026 imap_uidsearch(num_parms, parms);
1029 else if (!strcasecmp(parms[1], "STORE")) {
1030 imap_store(num_parms, parms);
1033 else if ( (!strcasecmp(parms[1], "UID"))
1034 && (!strcasecmp(parms[2], "STORE")) ) {
1035 imap_uidstore(num_parms, parms);
1038 else if (!strcasecmp(parms[1], "COPY")) {
1039 imap_copy(num_parms, parms);
1042 else if ( (!strcasecmp(parms[1], "UID"))
1043 && (!strcasecmp(parms[2], "COPY")) ) {
1044 imap_uidcopy(num_parms, parms);
1047 else if (!strcasecmp(parms[1], "EXPUNGE")) {
1048 imap_expunge(num_parms, parms);
1051 else if (!strcasecmp(parms[1], "CLOSE")) {
1052 imap_close(num_parms, parms);
1055 /* End of commands. If we get here, the command is either invalid
1060 cprintf("%s BAD command unrecognized\r\n", parms[0]);
1063 /* If the client transmitted a message we can free it now */
1064 imap_free_transmitted_message();
1070 * This function is called by dynloader.c to register the IMAP module
1071 * with the Citadel server.
1073 char *Dynamic_Module_Init(void)
1075 SYM_IMAP = CtdlGetDynamicSymbol();
1076 CtdlRegisterServiceHook(config.c_imap_port,
1080 CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);