stable now but there are GIANT PIECES MISSING
[citadel.git] / citadel / modules / imap / imap_list.c
index f66f121339f778cae5fcfbf3da642df731d6e188..1be8bab29bed6275d1c8489cb486505cf9cf623c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Implements the LIST and LSUB commands.
  *
- * Copyright (c) 2000-2009 by Art Cancro and others.
+ * Copyright (c) 2000-2017 by Art Cancro and others.
  *
  *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
+#include <time.h>
 #include <sys/wait.h>
 #include <ctype.h>
 #include <string.h>
@@ -97,7 +86,7 @@ void imap_list_floors(char *verb, int num_patterns, StrBuf **patterns)
                        }
                        if (match) {
                                IAPrintf("* %s (\\NoSelect \\HasChildren) \"/\" ", verb);
-                               plain_imap_strout(fl->f_name);
+                               IPutStr(fl->f_name, (fl->f_name)?strlen(fl->f_name):0);
                                IAPuts("\r\n");
                        }
                }
@@ -168,7 +157,8 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data)
        }
 
        if (yes_output_this_room) {
-               imap_mailboxname(MailboxName, sizeof MailboxName, qrbuf);
+               long len;
+               len = imap_mailboxname(MailboxName, sizeof MailboxName, qrbuf);
                match = 0;
                for (i=0; i<ImapFilter->num_patterns; ++i) {
                        if (imap_mailbox_matches_pattern(ChrPtr(ImapFilter->patterns[i]), MailboxName)) {
@@ -177,7 +167,7 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data)
                }
                if (match) {
                        IAPrintf("* %s (%s) \"/\" ", ImapFilter->verb, return_options);
-                       plain_imap_strout(MailboxName);
+                       IPutStr(MailboxName, len);
                        IAPuts("\r\n");
                }
        }
@@ -189,13 +179,13 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data)
  */
 void imap_list(int num_parms, ConstStr *Params)
 {
-       citimap *Imap = IMAP;
+       struct CitContext *CCC = CC;
+       citimap *Imap = CCCIMAP;
        int i, j, paren_nest;
        ImapRoomListFilter ImapFilter;
        int selection_left = (-1);
        int selection_right = (-1);
        int return_left = (-1);
-       int return_right = (-1);
        int root_pos = 2;
        int patterns_left = 3;
        int patterns_right = 3;
@@ -388,7 +378,6 @@ void imap_list(int num_parms, ConstStr *Params)
                        }
 
                        if (paren_nest == 0) {
-                               return_right = i;       /* found end of patterns */
                                i = num_parms + 1;      /* break out of the loop */
                        }
                }
@@ -421,9 +410,8 @@ void imap_list(int num_parms, ConstStr *Params)
         */
        for (i=0; i<ImapFilter.num_patterns; ++i) {
                FreeStrBuf(&ImapFilter.patterns[i]);
-               free(ImapFilter.patterns);
-
        }
+       free(ImapFilter.patterns);
 
        IReplyPrintf("OK %s completed", ImapFilter.verb);
 }