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. It is now good enough to
9 * be usable with much of the popular IMAP client software available, but it
10 * is by no means perfect. Some commands (particularly SEARCH and RENAME)
11 * are implemented either incompletely or not at all.
13 * WARNING: Mark Crispin is an idiot. IMAP is the most brain-damaged protocol
14 * you will ever have the profound lack of pleasure to encounter.
26 #include <sys/types.h>
35 #include "sysdep_decls.h"
36 #include "citserver.h"
39 #include "dynloader.h"
46 #include "internet_addressing.h"
47 #include "serv_imap.h"
48 #include "imap_tools.h"
49 #include "imap_fetch.h"
50 #include "imap_search.h"
51 #include "imap_store.h"
52 #include "imap_misc.h"
59 * If there is a message ID map in memory, free it
61 void imap_free_msgids(void) {
62 if (IMAP->msgids != NULL) {
67 if (IMAP->flags != NULL) {
75 * If there is a transmitted message in memory, free it
77 void imap_free_transmitted_message(void) {
78 if (IMAP->transmitted_message != NULL) {
79 phree(IMAP->transmitted_message);
80 IMAP->transmitted_message = NULL;
81 IMAP->transmitted_length = 0;
87 * Set the \\Seen flag for messages which aren't new
89 void imap_set_seen_flags(void) {
93 CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
94 if (IMAP->num_msgs > 0) {
95 for (i=0; i<IMAP->num_msgs; ++i) {
96 if (is_msg_in_mset(vbuf.v_seen, IMAP->msgids[i])) {
97 IMAP->flags[i] |= IMAP_SEEN;
107 * Back end for imap_load_msgids()
109 * Optimization: instead of calling realloc() to add each message, we
110 * allocate space in the list for REALLOC_INCREMENT messages at a time. This
111 * allows the mapping to proceed much faster.
113 void imap_add_single_msgid(long msgnum, void *userdata) {
115 IMAP->num_msgs = IMAP->num_msgs + 1;
116 if (IMAP->msgids == NULL) {
117 IMAP->msgids = mallok(IMAP->num_msgs * sizeof(long)
118 * REALLOC_INCREMENT);
120 else if (IMAP->num_msgs % REALLOC_INCREMENT == 0) {
121 IMAP->msgids = reallok(IMAP->msgids,
122 (IMAP->num_msgs + REALLOC_INCREMENT) * sizeof(long));
124 if (IMAP->flags == NULL) {
125 IMAP->flags = mallok(IMAP->num_msgs * sizeof(long)
126 * REALLOC_INCREMENT);
128 else if (IMAP->num_msgs % REALLOC_INCREMENT == 0) {
129 IMAP->flags = reallok(IMAP->flags,
130 (IMAP->num_msgs + REALLOC_INCREMENT) * sizeof(long));
132 IMAP->msgids[IMAP->num_msgs - 1] = msgnum;
133 IMAP->flags[IMAP->num_msgs - 1] = 0;
139 * Set up a message ID map for the current room (folder)
141 void imap_load_msgids(void) {
143 if (IMAP->selected == 0) {
144 lprintf(5, "imap_load_msgids() can't run; no room selected\n");
148 imap_free_msgids(); /* If there was already a map, free it */
150 CtdlForEachMessage(MSGS_ALL, 0L, (-63), NULL, NULL,
151 imap_add_single_msgid, NULL);
153 imap_set_seen_flags();
154 lprintf(9, "imap_load_msgids() mapped %d messages\n", IMAP->num_msgs);
159 * Re-scan the selected room (folder) and see if it's been changed at all
161 void imap_rescan_msgids(void) {
163 int original_num_msgs = 0;
164 long original_highest = 0L;
168 if (IMAP->selected == 0) {
169 lprintf(5, "imap_load_msgids() can't run; no room selected\n");
175 * Check to see if any of the messages we know about have been expunged
177 if (IMAP->num_msgs > 0)
178 for (i=0; i<IMAP->num_msgs; ++i) {
180 count = CtdlForEachMessage(MSGS_EQ, IMAP->msgids[i],
181 (-63), NULL, NULL, NULL, NULL);
184 cprintf("* %d EXPUNGE\r\n", i+1);
186 /* Here's some nice stupid nonsense. When a message
187 * is expunged, we have to slide all the existing
188 * messages up in the message array.
191 memcpy(&IMAP->msgids[i], &IMAP->msgids[i+1],
192 (sizeof(long)*(IMAP->num_msgs-i)) );
193 memcpy(&IMAP->flags[i], &IMAP->flags[i+1],
194 (sizeof(long)*(IMAP->num_msgs-i)) );
202 * Remember how many messages were here before we re-scanned.
204 original_num_msgs = IMAP->num_msgs;
205 if (IMAP->num_msgs > 0) {
206 original_highest = IMAP->msgids[IMAP->num_msgs - 1];
209 original_highest = 0L;
213 * Now peruse the room for *new* messages only.
215 CtdlForEachMessage(MSGS_GT, original_highest, (-63), NULL, NULL,
216 imap_add_single_msgid, NULL);
218 imap_set_seen_flags();
221 * If new messages have arrived, tell the client about them.
223 if (IMAP->num_msgs > original_num_msgs) {
224 cprintf("* %d EXISTS\r\n", IMAP->num_msgs);
236 * This cleanup function blows away the temporary memory and files used by
239 void imap_cleanup_function(void) {
241 /* Don't do this stuff if this is not a IMAP session! */
242 if (CC->h_command_function != imap_command_loop) return;
244 lprintf(9, "Performing IMAP cleanup hook\n");
246 imap_free_transmitted_message();
247 lprintf(9, "Finished IMAP cleanup hook\n");
253 * Here's where our IMAP session begins its happy day.
255 void imap_greeting(void) {
257 strcpy(CC->cs_clientname, "IMAP session");
258 CtdlAllocUserData(SYM_IMAP, sizeof(struct citimap));
259 IMAP->authstate = imap_as_normal;
261 cprintf("* OK %s Citadel/UX IMAP4rev1 server ready\r\n",
267 * implements the LOGIN command (ordinary username/password login)
269 void imap_login(int num_parms, char *parms[]) {
270 if (CtdlLoginExistingUser(parms[2]) == login_ok) {
271 if (CtdlTryPassword(parms[3]) == pass_ok) {
272 cprintf("%s OK login successful\r\n", parms[0]);
277 cprintf("%s BAD Login incorrect\r\n", parms[0]);
282 * Implements the AUTHENTICATE command
284 void imap_authenticate(int num_parms, char *parms[]) {
287 if (num_parms != 3) {
288 cprintf("%s BAD incorrect number of parameters\r\n", parms[0]);
292 if (!strcasecmp(parms[2], "LOGIN")) {
293 encode_base64(buf, "Username:");
294 cprintf("+ %s\r\n", buf);
295 IMAP->authstate = imap_as_expecting_username;
296 strcpy(IMAP->authseq, parms[0]);
301 cprintf("%s NO AUTHENTICATE %s failed\r\n",
306 void imap_auth_login_user(char *cmd) {
309 decode_base64(buf, cmd);
310 CtdlLoginExistingUser(buf);
311 encode_base64(buf, "Password:");
312 cprintf("+ %s\r\n", buf);
313 IMAP->authstate = imap_as_expecting_password;
317 void imap_auth_login_pass(char *cmd) {
320 decode_base64(buf, cmd);
321 if (CtdlTryPassword(buf) == pass_ok) {
322 cprintf("%s OK authentication succeeded\r\n", IMAP->authseq);
325 cprintf("%s NO authentication failed\r\n", IMAP->authseq);
327 IMAP->authstate = imap_as_normal;
334 * implements the CAPABILITY command
336 void imap_capability(int num_parms, char *parms[]) {
337 cprintf("* CAPABILITY IMAP4 IMAP4REV1 AUTH=LOGIN\r\n");
338 cprintf("%s OK CAPABILITY completed\r\n", parms[0]);
346 * implements the SELECT command
348 void imap_select(int num_parms, char *parms[]) {
350 char augmented_roomname[ROOMNAMELEN];
354 struct quickroom QRscratch;
360 /* Convert the supplied folder name to a roomname */
361 i = imap_roomname(towhere, sizeof towhere, parms[2]);
363 cprintf("%s NO Invalid mailbox name.\r\n", parms[0]);
367 floornum = (i & 0x00ff);
368 roomflags = (i & 0xff00);
370 /* First try a regular match */
371 c = getroom(&QRscratch, towhere);
373 /* Then try a mailbox name match */
375 MailboxName(augmented_roomname, &CC->usersupp, towhere);
376 c = getroom(&QRscratch, augmented_roomname);
378 strcpy(towhere, augmented_roomname);
381 /* If the room exists, check security/access */
383 /* See if there is an existing user/room relationship */
384 ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
386 /* normal clients have to pass through security */
392 /* Fail here if no such room */
394 cprintf("%s NO ... no such room, or access denied\r\n",
401 * usergoto() formally takes us to the desired room, happily returning
402 * the number of messages and number of new messages.
404 usergoto(QRscratch.QRname, 0, &msgs, &new);
407 if (!strcasecmp(parms[1], "EXAMINE")) {
416 /* FIXME ... much more info needs to be supplied here */
417 cprintf("* %d EXISTS\r\n", msgs);
418 cprintf("* %d RECENT\r\n", new);
419 cprintf("* FLAGS (\\Deleted \\Seen)\r\n");
420 cprintf("* OK [PERMANENTFLAGS (\\Deleted \\Seen)] permanent flags\r\n");
421 cprintf("* OK [UIDVALIDITY 0] UIDs valid\r\n");
422 cprintf("%s OK [%s] %s completed\r\n",
424 (IMAP->readonly ? "READ-ONLY" : "READ-WRITE"),
431 * does the real work for expunge
433 int imap_do_expunge(void) {
435 int num_expunged = 0;
437 if (IMAP->num_msgs > 0) for (i=0; i<IMAP->num_msgs; ++i) {
438 if (IMAP->flags[i] & IMAP_DELETED) {
439 CtdlDeleteMessages(CC->quickroom.QRname,
440 IMAP->msgids[i], "");
445 if (num_expunged > 0) {
446 imap_rescan_msgids();
449 return(num_expunged);
454 * implements the EXPUNGE command syntax
456 void imap_expunge(int num_parms, char *parms[]) {
457 int num_expunged = 0;
459 cprintf("%s OK expunged %d messages.\r\n", parms[0], num_expunged);
464 * implements the CLOSE command
466 void imap_close(int num_parms, char *parms[]) {
468 /* Yes, we always expunge on close. */
474 cprintf("%s OK CLOSE completed\r\n", parms[0]);
481 * Used by LIST and LSUB to show the floors in the listing
483 void imap_list_floors(char *cmd, char *pattern) {
487 for (i=0; i<MAXFLOORS; ++i) {
489 if (fl->f_flags & F_INUSE) {
490 if (imap_mailbox_matches_pattern(pattern, fl->f_name)) {
491 cprintf("* %s (\\NoSelect) \"|\" ", cmd);
492 imap_strout(fl->f_name);
502 * Back end for imap_lsub()
504 * IMAP "subscribed folder" is equivocated to Citadel "known rooms." This
505 * may or may not be the desired behavior in the future.
507 void imap_lsub_listroom(struct quickroom *qrbuf, void *data) {
512 pattern = (char *)data;
514 /* Only list rooms to which the user has access!! */
515 ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
517 imap_mailboxname(buf, sizeof buf, qrbuf);
518 if (imap_mailbox_matches_pattern(pattern, buf)) {
519 cprintf("* LSUB (\\NoInferiors) \"|\" ");
528 * Implements the LSUB command
530 void imap_lsub(int num_parms, char *parms[]) {
533 cprintf("%s BAD arguments invalid\r\n", parms[0]);
536 sprintf(pattern, "%s%s", parms[2], parms[3]);
538 if (strlen(parms[3])==0) {
539 cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
543 imap_list_floors("LSUB", pattern);
544 ForEachRoom(imap_lsub_listroom, pattern);
547 cprintf("%s OK LSUB completed\r\n", parms[0]);
553 * Back end for imap_list()
555 void imap_list_listroom(struct quickroom *qrbuf, void *data) {
560 pattern = (char *)data;
562 /* Only list rooms to which the user has access!! */
563 ra = CtdlRoomAccess(qrbuf, &CC->usersupp);
565 || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))) {
566 imap_mailboxname(buf, sizeof buf, qrbuf);
567 if (imap_mailbox_matches_pattern(pattern, buf)) {
568 cprintf("* LIST (\\NoInferiors) \"|\" ");
577 * Implements the LIST command
579 void imap_list(int num_parms, char *parms[]) {
582 cprintf("%s BAD arguments invalid\r\n", parms[0]);
585 sprintf(pattern, "%s%s", parms[2], parms[3]);
587 if (strlen(parms[3])==0) {
588 cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
592 imap_list_floors("LIST", pattern);
593 ForEachRoom(imap_list_listroom, pattern);
596 cprintf("%s OK LIST completed\r\n", parms[0]);
602 * Implements the CREATE command
605 void imap_create(int num_parms, char *parms[]) {
607 char roomname[ROOMNAMELEN];
612 ret = imap_roomname(roomname, sizeof roomname, parms[2]);
614 cprintf("%s NO Invalid mailbox name or location\r\n",
618 floornum = ( ret & 0x00ff ); /* lower 8 bits = floor number */
619 flags = ( ret & 0xff00 ); /* upper 8 bits = flags */
621 if (flags & IR_MAILBOX) {
622 newroomtype = 4; /* private mailbox */
625 newroomtype = 0; /* public folder */
628 lprintf(7, "Create new room <%s> on floor <%d> with type <%d>\n",
629 roomname, floornum, newroomtype);
631 ret = create_room(roomname, newroomtype, "", floornum, 1);
633 cprintf("%s NO Mailbox already exists, or create failed\r\n",
637 cprintf("%s OK CREATE completed\r\n", parms[0]);
643 * Locate a room by its IMAP folder name, and check access to it
645 int imap_grabroom(char *returned_roomname, char *foldername) {
647 char augmented_roomname[ROOMNAMELEN];
648 char roomname[ROOMNAMELEN];
650 struct quickroom QRscratch;
654 ret = imap_roomname(roomname, sizeof roomname, foldername);
659 /* First try a regular match */
660 c = getroom(&QRscratch, roomname);
662 /* Then try a mailbox name match */
664 MailboxName(augmented_roomname, &CC->usersupp, roomname);
665 c = getroom(&QRscratch, augmented_roomname);
667 strcpy(roomname, augmented_roomname);
670 /* If the room exists, check security/access */
672 /* See if there is an existing user/room relationship */
673 ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
675 /* normal clients have to pass through security */
681 /* Fail here if no such room */
683 strcpy(returned_roomname, "");
687 strcpy(returned_roomname, QRscratch.QRname);
694 * Implements the STATUS command (sort of)
697 void imap_status(int num_parms, char *parms[]) {
699 char roomname[ROOMNAMELEN];
701 char savedroom[ROOMNAMELEN];
704 ret = imap_grabroom(roomname, parms[2]);
706 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
712 * usergoto() formally takes us to the desired room, happily returning
713 * the number of messages and number of new messages. (If another
714 * folder is selected, save its name so we can return there!!!!!)
716 if (IMAP->selected) {
717 strcpy(savedroom, CC->quickroom.QRname);
719 usergoto(roomname, 0, &msgs, &new);
722 * Tell the client what it wants to know. In fact, tell it *more* than
723 * it wants to know. We happily IGnore the supplied status data item
724 * names and simply spew all possible data items. It's far easier to
725 * code and probably saves us some processing time too.
727 imap_mailboxname(buf, sizeof buf, &CC->quickroom);
728 cprintf("* STATUS ");
730 cprintf(" (MESSAGES %d ", msgs);
731 cprintf("RECENT 0 "); /* FIXME we need to implement this */
732 cprintf("UIDNEXT %ld ", CitControl.MMhighest + 1);
733 cprintf("UNSEEN %d)\r\n", new);
736 * If another folder is selected, go back to that room so we can resume
737 * our happy day without violent explosions.
739 if (IMAP->selected) {
740 usergoto(savedroom, 0, &msgs, &new);
744 * Oooh, look, we're done!
746 cprintf("%s OK STATUS completed\r\n", parms[0]);
752 * Implements the SUBSCRIBE command
755 void imap_subscribe(int num_parms, char *parms[]) {
757 char roomname[ROOMNAMELEN];
758 char savedroom[ROOMNAMELEN];
761 ret = imap_grabroom(roomname, parms[2]);
763 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
769 * usergoto() formally takes us to the desired room, which has the side
770 * effect of marking the room as not-zapped ... exactly the effect
773 if (IMAP->selected) {
774 strcpy(savedroom, CC->quickroom.QRname);
776 usergoto(roomname, 0, &msgs, &new);
779 * If another folder is selected, go back to that room so we can resume
780 * our happy day without violent explosions.
782 if (IMAP->selected) {
783 usergoto(savedroom, 0, &msgs, &new);
786 cprintf("%s OK SUBSCRIBE completed\r\n", parms[0]);
791 * Implements the UNSUBSCRIBE command
794 void imap_unsubscribe(int num_parms, char *parms[]) {
796 char roomname[ROOMNAMELEN];
797 char savedroom[ROOMNAMELEN];
800 ret = imap_grabroom(roomname, parms[2]);
802 cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
808 * usergoto() formally takes us to the desired room.
810 if (IMAP->selected) {
811 strcpy(savedroom, CC->quickroom.QRname);
813 usergoto(roomname, 0, &msgs, &new);
816 * Now make the API call to zap the room
818 if (CtdlForgetThisRoom() == 0) {
819 cprintf("%s OK UNSUBSCRIBE completed\r\n", parms[0]);
822 cprintf("%s NO You may not unsubscribe from this folder.\r\n",
827 * If another folder is selected, go back to that room so we can resume
828 * our happy day without violent explosions.
830 if (IMAP->selected) {
831 usergoto(savedroom, 0, &msgs, &new);
838 * Implements the DELETE command
841 void imap_delete(int num_parms, char *parms[]) {
843 char roomname[ROOMNAMELEN];
844 char savedroom[ROOMNAMELEN];
847 ret = imap_grabroom(roomname, parms[2]);
849 cprintf("%s NO Invalid mailbox name, or access denied\r\n",
855 * usergoto() formally takes us to the desired room, happily returning
856 * the number of messages and number of new messages. (If another
857 * folder is selected, save its name so we can return there!!!!!)
859 if (IMAP->selected) {
860 strcpy(savedroom, CC->quickroom.QRname);
862 usergoto(roomname, 0, &msgs, &new);
865 * Now delete the room.
867 if (CtdlDoIHavePermissionToDeleteThisRoom(&CC->quickroom)) {
868 cprintf("%s OK DELETE completed\r\n", parms[0]);
869 delete_room(&CC->quickroom);
872 cprintf("%s NO Can't delete this folder.\r\n", parms[0]);
876 * If another folder is selected, go back to that room so we can resume
877 * our happy day without violent explosions.
879 if (IMAP->selected) {
880 usergoto(savedroom, 0, &msgs, &new);
887 * Implements the RENAME command
890 void imap_rename(int num_parms, char *parms[]) {
891 cprintf("%s NO The RENAME command is not yet implemented (FIXME)\r\n",
898 * Main command loop for IMAP sessions.
900 void imap_command_loop(void) {
906 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
907 if (client_gets(cmdbuf) < 1) {
908 lprintf(3, "IMAP socket is broken. Ending session.\r\n");
913 lprintf(5, "citserver[%3d]: %s\r\n", CC->cs_pid, cmdbuf);
914 while (strlen(cmdbuf) < 5) strcat(cmdbuf, " ");
917 /* strip off l/t whitespace and CRLF */
918 if (cmdbuf[strlen(cmdbuf)-1]=='\n') cmdbuf[strlen(cmdbuf)-1]=0;
919 if (cmdbuf[strlen(cmdbuf)-1]=='\r') cmdbuf[strlen(cmdbuf)-1]=0;
922 /* If we're in the middle of a multi-line command, handle that */
923 if (IMAP->authstate == imap_as_expecting_username) {
924 imap_auth_login_user(cmdbuf);
927 if (IMAP->authstate == imap_as_expecting_password) {
928 imap_auth_login_pass(cmdbuf);
933 /* Ok, at this point we're in normal command mode. The first thing
934 * we do is print any incoming pages (yeah! we really do!)
936 imap_print_express_messages();
939 * Before processing the command that was just entered... if we happen
940 * to have a folder selected, we'd like to rescan that folder for new
941 * messages, and for deletions/changes of existing messages. This
942 * could probably be optimized somehow, but IMAP sucks...
944 if (IMAP->selected) {
945 imap_rescan_msgids();
948 /* Now for the command set. */
950 /* Grab the tag, command, and parameters. Check syntax. */
951 num_parms = imap_parameterize(parms, cmdbuf);
953 cprintf("BAD syntax error\r\n");
956 /* The commands below may be executed in any state */
958 else if ( (!strcasecmp(parms[1], "NOOP"))
959 || (!strcasecmp(parms[1], "CHECK")) ) {
960 cprintf("%s OK This command successfully did nothing.\r\n",
964 else if (!strcasecmp(parms[1], "LOGOUT")) {
965 cprintf("* BYE %s logging out\r\n", config.c_fqdn);
966 cprintf("%s OK thank you for using Citadel IMAP\r\n", parms[0]);
971 else if (!strcasecmp(parms[1], "LOGIN")) {
972 imap_login(num_parms, parms);
975 else if (!strcasecmp(parms[1], "AUTHENTICATE")) {
976 imap_authenticate(num_parms, parms);
979 else if (!strcasecmp(parms[1], "CAPABILITY")) {
980 imap_capability(num_parms, parms);
983 else if (!CC->logged_in) {
984 cprintf("%s BAD Not logged in.\r\n", parms[0]);
987 /* The commans below require a logged-in state */
989 else if (!strcasecmp(parms[1], "SELECT")) {
990 imap_select(num_parms, parms);
993 else if (!strcasecmp(parms[1], "EXAMINE")) {
994 imap_select(num_parms, parms);
997 else if (!strcasecmp(parms[1], "LSUB")) {
998 imap_lsub(num_parms, parms);
1001 else if (!strcasecmp(parms[1], "LIST")) {
1002 imap_list(num_parms, parms);
1005 else if (!strcasecmp(parms[1], "CREATE")) {
1006 imap_create(num_parms, parms);
1009 else if (!strcasecmp(parms[1], "DELETE")) {
1010 imap_delete(num_parms, parms);
1013 else if (!strcasecmp(parms[1], "RENAME")) {
1014 imap_rename(num_parms, parms);
1017 else if (!strcasecmp(parms[1], "STATUS")) {
1018 imap_status(num_parms, parms);
1021 else if (!strcasecmp(parms[1], "SUBSCRIBE")) {
1022 imap_subscribe(num_parms, parms);
1025 else if (!strcasecmp(parms[1], "UNSUBSCRIBE")) {
1026 imap_unsubscribe(num_parms, parms);
1029 else if (!strcasecmp(parms[1], "APPEND")) {
1030 imap_append(num_parms, parms);
1033 else if (IMAP->selected == 0) {
1034 cprintf("%s BAD no folder selected\r\n", parms[0]);
1037 /* The commands below require the SELECT state on a mailbox */
1039 else if (!strcasecmp(parms[1], "FETCH")) {
1040 imap_fetch(num_parms, parms);
1043 else if ( (!strcasecmp(parms[1], "UID"))
1044 && (!strcasecmp(parms[2], "FETCH")) ) {
1045 imap_uidfetch(num_parms, parms);
1048 else if (!strcasecmp(parms[1], "SEARCH")) {
1049 imap_search(num_parms, parms);
1052 else if ( (!strcasecmp(parms[1], "UID"))
1053 && (!strcasecmp(parms[2], "SEARCH")) ) {
1054 imap_uidsearch(num_parms, parms);
1057 else if (!strcasecmp(parms[1], "STORE")) {
1058 imap_store(num_parms, parms);
1061 else if ( (!strcasecmp(parms[1], "UID"))
1062 && (!strcasecmp(parms[2], "STORE")) ) {
1063 imap_uidstore(num_parms, parms);
1066 else if (!strcasecmp(parms[1], "COPY")) {
1067 imap_copy(num_parms, parms);
1070 else if ( (!strcasecmp(parms[1], "UID"))
1071 && (!strcasecmp(parms[2], "COPY")) ) {
1072 imap_uidcopy(num_parms, parms);
1075 else if (!strcasecmp(parms[1], "EXPUNGE")) {
1076 imap_expunge(num_parms, parms);
1079 else if (!strcasecmp(parms[1], "CLOSE")) {
1080 imap_close(num_parms, parms);
1083 /* End of commands. If we get here, the command is either invalid
1088 cprintf("%s BAD command unrecognized\r\n", parms[0]);
1091 /* If the client transmitted a message we can free it now */
1092 imap_free_transmitted_message();
1098 * This function is called by dynloader.c to register the IMAP module
1099 * with the Citadel server.
1101 char *Dynamic_Module_Init(void)
1103 SYM_IMAP = CtdlGetDynamicSymbol();
1104 CtdlRegisterServiceHook(config.c_imap_port,
1108 CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);