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 * Set the \\Seen flag for messages which aren't new
87 void imap_set_seen_flags(void) {
91 CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
92 if (IMAP->num_msgs > 0) {
93 for (i=0; i<IMAP->num_msgs; ++i) {
94 if (is_msg_in_mset(vbuf.v_seen, IMAP->msgids[i])) {
95 IMAP->flags[i] |= IMAP_SEEN;
105 * Back end for imap_load_msgids()
107 * FIXME: this should be optimized by figuring out a way to allocate memory
108 * once rather than doing a reallok() for each message.
110 void imap_add_single_msgid(long msgnum, void *userdata) {
112 IMAP->num_msgs = IMAP->num_msgs + 1;
113 if (IMAP->msgids == NULL) {
114 IMAP->msgids = mallok(IMAP->num_msgs * sizeof(long));
117 IMAP->msgids = reallok(IMAP->msgids,
118 IMAP->num_msgs * sizeof(long));
120 if (IMAP->flags == NULL) {
121 IMAP->flags = mallok(IMAP->num_msgs * sizeof(long));
124 IMAP->flags = reallok(IMAP->flags,
125 IMAP->num_msgs * sizeof(long));
127 IMAP->msgids[IMAP->num_msgs - 1] = msgnum;
128 IMAP->flags[IMAP->num_msgs - 1] = 0;
134 * Set up a message ID map for the current room (folder)
136 void imap_load_msgids(void) {
138 if (IMAP->selected == 0) {
139 lprintf(5, "imap_load_msgids() can't run; no room selected\n");
143 imap_free_msgids(); /* If there was already a map, free it */
145 CtdlForEachMessage(MSGS_ALL, 0L, (-63), NULL, NULL,
146 imap_add_single_msgid, NULL);
148 imap_set_seen_flags();
149 lprintf(9, "imap_load_msgids() mapped %d messages\n", IMAP->num_msgs);
154 * Re-scan the selected room (folder) and see if it's been changed at all
156 void imap_rescan_msgids(void) {
158 int original_num_msgs = 0;
159 long original_highest = 0L;
163 if (IMAP->selected == 0) {
164 lprintf(5, "imap_load_msgids() can't run; no room selected\n");
170 * Check to see if any of the messages we know about have been expunged
172 if (IMAP->num_msgs > 0)
173 for (i=0; i<IMAP->num_msgs; ++i) {
175 count = CtdlForEachMessage(MSGS_EQ, IMAP->msgids[i],
176 (-63), NULL, NULL, NULL, NULL);
179 cprintf("* %d EXPUNGE\r\n", i+1);
181 /* Here's some nice stupid nonsense. When a message
182 * is expunged, we have to slide all the existing
183 * messages up in the message array.
186 memcpy(&IMAP->msgids[i], &IMAP->msgids[i+1],
187 (sizeof(long)*(IMAP->num_msgs-i)) );
188 memcpy(&IMAP->flags[i], &IMAP->flags[i+1],
189 (sizeof(long)*(IMAP->num_msgs-i)) );
197 * Remember how many messages were here before we re-scanned.
199 original_num_msgs = IMAP->num_msgs;
200 if (IMAP->num_msgs > 0) {
201 original_highest = IMAP->msgids[IMAP->num_msgs - 1];
204 original_highest = 0L;
208 * Now peruse the room for *new* messages only.
210 CtdlForEachMessage(MSGS_GT, original_highest, (-63), NULL, NULL,
211 imap_add_single_msgid, NULL);
213 imap_set_seen_flags();
216 * If new messages have arrived, tell the client about them.
218 if (IMAP->num_msgs > original_num_msgs) {
219 cprintf("* %d EXISTS\r\n", IMAP->num_msgs);
231 * This cleanup function blows away the temporary memory and files used by
234 void imap_cleanup_function(void) {
236 /* Don't do this stuff if this is not a IMAP session! */
237 if (CC->h_command_function != imap_command_loop) return;
239 lprintf(9, "Performing IMAP cleanup hook\n");
241 imap_free_transmitted_message();
242 lprintf(9, "Finished IMAP cleanup hook\n");
248 * Here's where our IMAP session begins its happy day.
250 void imap_greeting(void) {
252 strcpy(CC->cs_clientname, "IMAP session");
253 CtdlAllocUserData(SYM_IMAP, sizeof(struct citimap));
254 IMAP->authstate = imap_as_normal;
256 cprintf("* OK %s Citadel/UX IMAP4rev1 server ready\r\n",
262 * implements the LOGIN command (ordinary username/password login)
264 void imap_login(int num_parms, char *parms[]) {
265 if (CtdlLoginExistingUser(parms[2]) == login_ok) {
266 if (CtdlTryPassword(parms[3]) == pass_ok) {
267 cprintf("%s OK login successful\r\n", parms[0]);
272 cprintf("%s BAD Login incorrect\r\n", parms[0]);
277 * Implements the AUTHENTICATE command
279 void imap_authenticate(int num_parms, char *parms[]) {
282 if (num_parms != 3) {
283 cprintf("%s BAD incorrect number of parameters\r\n", parms[0]);
287 if (!strcasecmp(parms[2], "LOGIN")) {
288 encode_base64(buf, "Username:");
289 cprintf("+ %s\r\n", buf);
290 IMAP->authstate = imap_as_expecting_username;
291 strcpy(IMAP->authseq, parms[0]);
296 cprintf("%s NO AUTHENTICATE %s failed\r\n",
301 void imap_auth_login_user(char *cmd) {
304 decode_base64(buf, cmd);
305 CtdlLoginExistingUser(buf);
306 encode_base64(buf, "Password:");
307 cprintf("+ %s\r\n", buf);
308 IMAP->authstate = imap_as_expecting_password;
312 void imap_auth_login_pass(char *cmd) {
315 decode_base64(buf, cmd);
316 if (CtdlTryPassword(buf) == pass_ok) {
317 cprintf("%s OK authentication succeeded\r\n", IMAP->authseq);
320 cprintf("%s NO authentication failed\r\n", IMAP->authseq);
322 IMAP->authstate = imap_as_normal;
329 * implements the CAPABILITY command
331 void imap_capability(int num_parms, char *parms[]) {
332 cprintf("* CAPABILITY IMAP4 IMAP4REV1 AUTH=LOGIN\r\n");
333 cprintf("%s OK CAPABILITY completed\r\n", parms[0]);
341 * implements the SELECT command
343 void imap_select(int num_parms, char *parms[]) {
345 char augmented_roomname[ROOMNAMELEN];
349 struct quickroom QRscratch;
355 /* Convert the supplied folder name to a roomname */
356 i = imap_roomname(towhere, sizeof towhere, parms[2]);
358 cprintf("%s NO Invalid mailbox name.\r\n", parms[0]);
362 floornum = (i & 0x00ff);
363 roomflags = (i & 0xff00);
365 /* First try a regular match */
366 c = getroom(&QRscratch, towhere);
368 /* Then try a mailbox name match */
370 MailboxName(augmented_roomname, &CC->usersupp, towhere);
371 c = getroom(&QRscratch, augmented_roomname);
373 strcpy(towhere, augmented_roomname);
376 /* If the room exists, check security/access */
378 /* See if there is an existing user/room relationship */
379 ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
381 /* normal clients have to pass through security */
387 /* Fail here if no such room */
389 cprintf("%s NO ... no such room, or access denied\r\n",
396 * usergoto() formally takes us to the desired room, happily returning
397 * the number of messages and number of new messages.
399 usergoto(QRscratch.QRname, 0, &msgs, &new);
402 if (!strcasecmp(parms[1], "EXAMINE")) {
411 /* FIXME ... much more info needs to be supplied here */
412 cprintf("* %d EXISTS\r\n", msgs);
413 cprintf("* %d RECENT\r\n", new);
414 cprintf("* FLAGS (\\Deleted \\Seen)\r\n");
415 cprintf("* OK [PERMANENTFLAGS (\\Deleted \\Seen)] permanent flags\r\n");
416 cprintf("* OK [UIDVALIDITY 0] UIDs valid\r\n");
417 cprintf("%s OK [%s] %s completed\r\n",
419 (IMAP->readonly ? "READ-ONLY" : "READ-WRITE"),
426 * does the real work for expunge
428 int imap_do_expunge(void) {
430 int num_expunged = 0;
432 if (IMAP->num_msgs > 0) for (i=0; i<IMAP->num_msgs; ++i) {
433 if (IMAP->flags[i] & IMAP_DELETED) {
434 CtdlDeleteMessages(CC->quickroom.QRname,
435 IMAP->msgids[i], "");
440 if (num_expunged > 0) {
441 imap_rescan_msgids();
444 return(num_expunged);
449 * implements the EXPUNGE command syntax
451 void imap_expunge(int num_parms, char *parms[]) {
452 int num_expunged = 0;
454 cprintf("%s OK expunged %d messages.\r\n", parms[0], num_expunged);
459 * implements the CLOSE command
461 void imap_close(int num_parms, char *parms[]) {
463 /* Yes, we always expunge on close. */
469 cprintf("%s OK CLOSE completed\r\n", parms[0]);
476 * Used by LIST and LSUB to show the floors in the listing
478 void imap_list_floors(char *cmd, char *pattern) {
482 for (i=0; i<MAXFLOORS; ++i) {
484 if (fl->f_flags & F_INUSE) {
485 if (imap_mailbox_matches_pattern(pattern, fl->f_name)) {
486 cprintf("* %s (\\NoSelect) \"|\" ", cmd);
487 imap_strout(fl->f_name);
497 * Back end for imap_lsub()
499 * IMAP "subscribed folder" is equivocated to Citadel "known rooms." This
500 * may or may not be the desired behavior in the future.
502 void imap_lsub_listroom(struct quickroom *qrbuf, void *data) {
507 pattern = (char *)data;
509 /* Only list rooms to which the user has access!! */
510 ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
512 imap_mailboxname(buf, sizeof buf, qrbuf);
513 if (imap_mailbox_matches_pattern(pattern, buf)) {
514 cprintf("* LSUB (\\NoInferiors) \"|\" ");
523 * Implements the LSUB command
525 void imap_lsub(int num_parms, char *parms[]) {
528 cprintf("%s BAD arguments invalid\r\n", parms[0]);
531 sprintf(pattern, "%s%s", parms[2], parms[3]);
533 if (strlen(parms[3])==0) {
534 cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
538 imap_list_floors("LSUB", pattern);
539 ForEachRoom(imap_lsub_listroom, pattern);
542 cprintf("%s OK LSUB completed\r\n", parms[0]);
548 * Back end for imap_list()
550 void imap_list_listroom(struct quickroom *qrbuf, void *data) {
555 pattern = (char *)data;
557 /* Only list rooms to which the user has access!! */
558 ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
560 || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))) {
561 imap_mailboxname(buf, sizeof buf, qrbuf);
562 if (imap_mailbox_matches_pattern(pattern, buf)) {
563 cprintf("* LIST (\\NoInferiors) \"|\" ");
572 * Implements the LIST command
574 void imap_list(int num_parms, char *parms[]) {
577 cprintf("%s BAD arguments invalid\r\n", parms[0]);
580 sprintf(pattern, "%s%s", parms[2], parms[3]);
582 if (strlen(parms[3])==0) {
583 cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
587 imap_list_floors("LIST", pattern);
588 ForEachRoom(imap_list_listroom, pattern);
591 cprintf("%s OK LIST completed\r\n", parms[0]);
597 * Implements the CREATE command
600 void imap_create(int num_parms, char *parms[]) {
602 char roomname[ROOMNAMELEN];
607 ret = imap_roomname(roomname, sizeof roomname, parms[2]);
609 cprintf("%s NO Invalid mailbox name or location\r\n",
613 floornum = ( ret & 0x00ff ); /* lower 8 bits = floor number */
614 flags = ( ret & 0xff00 ); /* upper 8 bits = flags */
616 if (flags & IR_MAILBOX) {
617 newroomtype = 4; /* private mailbox */
620 newroomtype = 0; /* public folder */
623 lprintf(7, "Create new room <%s> on floor <%d> with type <%d>\n",
624 roomname, floornum, newroomtype);
626 ret = create_room(roomname, newroomtype, "", floornum, 1);
628 cprintf("%s NO Mailbox already exists, or create failed\r\n",
632 cprintf("%s OK CREATE completed\r\n", parms[0]);
638 * Locate a room by its IMAP folder name, and check access to it
640 int imap_grabroom(char *returned_roomname, char *foldername) {
642 char augmented_roomname[ROOMNAMELEN];
643 char roomname[ROOMNAMELEN];
645 struct quickroom QRscratch;
649 ret = imap_roomname(roomname, sizeof roomname, foldername);
654 /* First try a regular match */
655 c = getroom(&QRscratch, roomname);
657 /* Then try a mailbox name match */
659 MailboxName(augmented_roomname, &CC->usersupp, roomname);
660 c = getroom(&QRscratch, augmented_roomname);
662 strcpy(roomname, augmented_roomname);
665 /* If the room exists, check security/access */
667 /* See if there is an existing user/room relationship */
668 ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
670 /* normal clients have to pass through security */
676 /* Fail here if no such room */
678 strcpy(returned_roomname, "");
682 strcpy(returned_roomname, QRscratch.QRname);
689 * Implements the STATUS command (sort of)
692 void imap_status(int num_parms, char *parms[]) {
694 char roomname[ROOMNAMELEN];
696 char savedroom[ROOMNAMELEN];
699 ret = imap_grabroom(roomname, parms[2]);
701 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
707 * usergoto() formally takes us to the desired room, happily returning
708 * the number of messages and number of new messages. (If another
709 * folder is selected, save its name so we can return there!!!!!)
711 if (IMAP->selected) {
712 strcpy(savedroom, CC->quickroom.QRname);
714 usergoto(roomname, 0, &msgs, &new);
717 * Tell the client what it wants to know. In fact, tell it *more* than
718 * it wants to know. We happily IGnore the supplied status data item
719 * names and simply spew all possible data items. It's far easier to
720 * code and probably saves us some processing time too.
722 imap_mailboxname(buf, sizeof buf, &CC->quickroom);
723 cprintf("* STATUS ");
725 cprintf(" (MESSAGES %d ", msgs);
726 cprintf("RECENT 0 "); /* FIXME we need to implement this */
727 cprintf("UIDNEXT %ld ", CitControl.MMhighest + 1);
728 cprintf("UNSEEN %d)\r\n", new);
731 * If another folder is selected, go back to that room so we can resume
732 * our happy day without violent explosions.
734 if (IMAP->selected) {
735 usergoto(savedroom, 0, &msgs, &new);
739 * Oooh, look, we're done!
741 cprintf("%s OK STATUS completed\r\n", parms[0]);
747 * Implements the SUBSCRIBE command
750 void imap_subscribe(int num_parms, char *parms[]) {
752 char roomname[ROOMNAMELEN];
753 char savedroom[ROOMNAMELEN];
756 ret = imap_grabroom(roomname, parms[2]);
758 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
764 * usergoto() formally takes us to the desired room, which has the side
765 * effect of marking the room as not-zapped ... exactly the effect
768 if (IMAP->selected) {
769 strcpy(savedroom, CC->quickroom.QRname);
771 usergoto(roomname, 0, &msgs, &new);
774 * If another folder is selected, go back to that room so we can resume
775 * our happy day without violent explosions.
777 if (IMAP->selected) {
778 usergoto(savedroom, 0, &msgs, &new);
781 cprintf("%s OK SUBSCRIBE completed\r\n", parms[0]);
786 * Implements the UNSUBSCRIBE command
789 void imap_unsubscribe(int num_parms, char *parms[]) {
791 char roomname[ROOMNAMELEN];
792 char savedroom[ROOMNAMELEN];
795 ret = imap_grabroom(roomname, parms[2]);
797 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
803 * usergoto() formally takes us to the desired room.
805 if (IMAP->selected) {
806 strcpy(savedroom, CC->quickroom.QRname);
808 usergoto(roomname, 0, &msgs, &new);
811 * Now make the API call to zap the room
813 if (CtdlForgetThisRoom() == 0) {
814 cprintf("%s OK UNSUBSCRIBE completed\r\n", parms[0]);
817 cprintf("%s NO You may not unsubscribe from this folder.\r\n",
822 * If another folder is selected, go back to that room so we can resume
823 * our happy day without violent explosions.
825 if (IMAP->selected) {
826 usergoto(savedroom, 0, &msgs, &new);
833 * Implements the DELETE command
836 void imap_delete(int num_parms, char *parms[]) {
838 char roomname[ROOMNAMELEN];
839 char savedroom[ROOMNAMELEN];
842 ret = imap_grabroom(roomname, parms[2]);
844 cprintf("%s NO Invalid mailbox name, or access denied\r\n",
850 * usergoto() formally takes us to the desired room, happily returning
851 * the number of messages and number of new messages. (If another
852 * folder is selected, save its name so we can return there!!!!!)
854 if (IMAP->selected) {
855 strcpy(savedroom, CC->quickroom.QRname);
857 usergoto(roomname, 0, &msgs, &new);
860 * Now delete the room.
862 if (CtdlDoIHavePermissionToDeleteThisRoom(&CC->quickroom)) {
863 cprintf("%s OK DELETE completed\r\n", parms[0]);
864 delete_room(&CC->quickroom);
867 cprintf("%s NO Can't delete this folder.\r\n", parms[0]);
871 * If another folder is selected, go back to that room so we can resume
872 * our happy day without violent explosions.
874 if (IMAP->selected) {
875 usergoto(savedroom, 0, &msgs, &new);
882 * Implements the RENAME command
885 void imap_rename(int num_parms, char *parms[]) {
886 cprintf("%s NO The RENAME command is not yet implemented (FIXME)\r\n",
893 * Main command loop for IMAP sessions.
895 void imap_command_loop(void) {
901 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
902 if (client_gets(cmdbuf) < 1) {
903 lprintf(3, "IMAP socket is broken. Ending session.\r\n");
908 lprintf(5, "citserver[%3d]: %s\r\n", CC->cs_pid, cmdbuf);
909 while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
912 /* strip off l/t whitespace and CRLF */
913 if (cmdbuf[strlen(cmdbuf)-1]=='\n') cmdbuf[strlen(cmdbuf)-1]=0;
914 if (cmdbuf[strlen(cmdbuf)-1]=='\r') cmdbuf[strlen(cmdbuf)-1]=0;
917 /* If we're in the middle of a multi-line command, handle that */
918 if (IMAP->authstate == imap_as_expecting_username) {
919 imap_auth_login_user(cmdbuf);
922 if (IMAP->authstate == imap_as_expecting_password) {
923 imap_auth_login_pass(cmdbuf);
928 /* Ok, at this point we're in normal command mode. The first thing
929 * we do is print any incoming pages (yeah! we really do!)
931 imap_print_express_messages();
934 * Before processing the command that was just entered... if we happen
935 * to have a folder selected, we'd like to rescan that folder for new
936 * messages, and for deletions/changes of existing messages. This
937 * could probably be optimized somehow, but IMAP sucks...
939 if (IMAP->selected) {
940 imap_rescan_msgids();
943 /* Now for the command set. */
945 /* Grab the tag, command, and parameters. Check syntax. */
946 num_parms = imap_parameterize(parms, cmdbuf);
948 cprintf("BAD syntax error\r\n");
951 /* The commands below may be executed in any state */
953 else if ( (!strcasecmp(parms[1], "NOOP"))
954 || (!strcasecmp(parms[1], "CHECK")) ) {
955 cprintf("%s OK This command successfully did nothing.\r\n",
959 else if (!strcasecmp(parms[1], "LOGOUT")) {
960 cprintf("* BYE %s logging out\r\n", config.c_fqdn);
961 cprintf("%s OK thank you for using Citadel IMAP\r\n", parms[0]);
966 else if (!strcasecmp(parms[1], "LOGIN")) {
967 imap_login(num_parms, parms);
970 else if (!strcasecmp(parms[1], "AUTHENTICATE")) {
971 imap_authenticate(num_parms, parms);
974 else if (!strcasecmp(parms[1], "CAPABILITY")) {
975 imap_capability(num_parms, parms);
978 else if (!CC->logged_in) {
979 cprintf("%s BAD Not logged in.\r\n", parms[0]);
982 /* The commans below require a logged-in state */
984 else if (!strcasecmp(parms[1], "SELECT")) {
985 imap_select(num_parms, parms);
988 else if (!strcasecmp(parms[1], "EXAMINE")) {
989 imap_select(num_parms, parms);
992 else if (!strcasecmp(parms[1], "LSUB")) {
993 imap_lsub(num_parms, parms);
996 else if (!strcasecmp(parms[1], "LIST")) {
997 imap_list(num_parms, parms);
1000 else if (!strcasecmp(parms[1], "CREATE")) {
1001 imap_create(num_parms, parms);
1004 else if (!strcasecmp(parms[1], "DELETE")) {
1005 imap_delete(num_parms, parms);
1008 else if (!strcasecmp(parms[1], "RENAME")) {
1009 imap_rename(num_parms, parms);
1012 else if (!strcasecmp(parms[1], "STATUS")) {
1013 imap_status(num_parms, parms);
1016 else if (!strcasecmp(parms[1], "SUBSCRIBE")) {
1017 imap_subscribe(num_parms, parms);
1020 else if (!strcasecmp(parms[1], "UNSUBSCRIBE")) {
1021 imap_unsubscribe(num_parms, parms);
1024 else if (!strcasecmp(parms[1], "APPEND")) {
1025 imap_append(num_parms, parms);
1028 else if (IMAP->selected == 0) {
1029 cprintf("%s BAD no folder selected\r\n", parms[0]);
1032 /* The commands below require the SELECT state on a mailbox */
1034 else if (!strcasecmp(parms[1], "FETCH")) {
1035 imap_fetch(num_parms, parms);
1038 else if ( (!strcasecmp(parms[1], "UID"))
1039 && (!strcasecmp(parms[2], "FETCH")) ) {
1040 imap_uidfetch(num_parms, parms);
1043 else if (!strcasecmp(parms[1], "SEARCH")) {
1044 imap_search(num_parms, parms);
1047 else if ( (!strcasecmp(parms[1], "UID"))
1048 && (!strcasecmp(parms[2], "SEARCH")) ) {
1049 imap_uidsearch(num_parms, parms);
1052 else if (!strcasecmp(parms[1], "STORE")) {
1053 imap_store(num_parms, parms);
1056 else if ( (!strcasecmp(parms[1], "UID"))
1057 && (!strcasecmp(parms[2], "STORE")) ) {
1058 imap_uidstore(num_parms, parms);
1061 else if (!strcasecmp(parms[1], "COPY")) {
1062 imap_copy(num_parms, parms);
1065 else if ( (!strcasecmp(parms[1], "UID"))
1066 && (!strcasecmp(parms[2], "COPY")) ) {
1067 imap_uidcopy(num_parms, parms);
1070 else if (!strcasecmp(parms[1], "EXPUNGE")) {
1071 imap_expunge(num_parms, parms);
1074 else if (!strcasecmp(parms[1], "CLOSE")) {
1075 imap_close(num_parms, parms);
1078 /* End of commands. If we get here, the command is either invalid
1083 cprintf("%s BAD command unrecognized\r\n", parms[0]);
1086 /* If the client transmitted a message we can free it now */
1087 imap_free_transmitted_message();
1093 * This function is called by dynloader.c to register the IMAP module
1094 * with the Citadel server.
1096 char *Dynamic_Module_Init(void)
1098 SYM_IMAP = CtdlGetDynamicSymbol();
1099 CtdlRegisterServiceHook(config.c_imap_port,
1103 CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);