]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/imap/serv_imap.c
* Gratuitous style cleanup of some of the imap code
[citadel.git] / citadel / modules / imap / serv_imap.c
index e7e9ad901f0c00c5b5d05597464bd2f92829cb99..9bd44105a40b9682f39c2eecedd2692b91d7c766 100644 (file)
@@ -9,19 +9,19 @@
  * is perfect.  Indeed, with so much gratuitous complexity, *all* IMAP
  * implementations have bugs.
  *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -70,7 +70,6 @@
 #include "imap_metadata.h"
 #include "imap_misc.h"
 
-
 #include "ctdl_module.h"
 
 
@@ -221,10 +220,8 @@ void imap_add_single_msgid(long msgnum, void *userdata)
        ++IMAP->num_msgs;
        if (IMAP->num_msgs > IMAP->num_alloc) {
                IMAP->num_alloc += REALLOC_INCREMENT;
-               IMAP->msgids = realloc(IMAP->msgids,
-                                       (IMAP->num_alloc * sizeof(long)) );
-               IMAP->flags = realloc(IMAP->flags,
-                                       (IMAP->num_alloc * sizeof(long)) );
+               IMAP->msgids = realloc(IMAP->msgids, (IMAP->num_alloc * sizeof(long)) );
+               IMAP->flags = realloc(IMAP->flags, (IMAP->num_alloc * sizeof(long)) );
        }
        IMAP->msgids[IMAP->num_msgs - 1] = msgnum;
        IMAP->flags[IMAP->num_msgs - 1] = 0;
@@ -282,8 +279,7 @@ void imap_rescan_msgids(void)
        int num_recent = 0;
 
        if (IMAP->selected == 0) {
-               CtdlLogPrintf(CTDL_ERR,
-                       "imap_load_msgids() can't run; no room selected\n");
+               CtdlLogPrintf(CTDL_ERR, "imap_load_msgids() can't run; no room selected\n");
                return;
        }
 
@@ -367,6 +363,8 @@ void imap_rescan_msgids(void)
 
        /*
         * Now peruse the room for *new* messages only.
+        * This logic is probably the cause of Bug # 368
+        * [ http://bugzilla.citadel.org/show_bug.cgi?id=368 ]
         */
        if (num_msgs > 0) {
                for (j = 0; j < num_msgs; ++j) {
@@ -399,11 +397,6 @@ void imap_rescan_msgids(void)
 }
 
 
-
-
-
-
-
 /*
  * This cleanup function blows away the temporary memory and files used by
  * the IMAP server.
@@ -476,6 +469,7 @@ void imap_output_capability_string(void) {
         */
 }
 
+
 /*
  * implements the CAPABILITY command
  */
@@ -488,7 +482,6 @@ void imap_capability(int num_parms, char *parms[])
 }
 
 
-
 /*
  * Implements the ID command (specified by RFC2971)
  *
@@ -505,7 +498,6 @@ void imap_id(int num_parms, char *parms[])
 }
 
 
-
 /*
  * Here's where our IMAP session begins its happy day.
  */
@@ -531,6 +523,7 @@ void imap_greeting(void)
        cprintf("] %s IMAP4rev1 %s ready\r\n", config.c_fqdn, CITADEL);
 }
 
+
 /*
  * IMAPS is just like IMAP, except it goes crypto right away.
  */
@@ -607,6 +600,7 @@ void imap_authenticate(int num_parms, char *parms[])
        }
 }
 
+
 void imap_auth_plain(char *cmd)
 {
        char decoded_authstring[1024];
@@ -639,6 +633,7 @@ void imap_auth_plain(char *cmd)
        cprintf("%s NO authentication failed\r\n", IMAP->authseq);
 }
 
+
 void imap_auth_login_user(char *cmd)
 {
        char buf[SIZ];
@@ -651,6 +646,7 @@ void imap_auth_login_user(char *cmd)
        return;
 }
 
+
 void imap_auth_login_pass(char *cmd)
 {
        char buf[SIZ];
@@ -676,15 +672,9 @@ void imap_starttls(int num_parms, char *parms[])
        char nosup_response[SIZ];
        char error_response[SIZ];
 
-       sprintf(ok_response,
-               "%s OK begin TLS negotiation now\r\n",
-               parms[0]);
-       sprintf(nosup_response,
-               "%s NO TLS not supported here\r\n",
-               parms[0]);
-       sprintf(error_response,
-               "%s BAD Internal error\r\n",
-               parms[0]);
+       sprintf(ok_response,    "%s OK begin TLS negotiation now\r\n",  parms[0]);
+       sprintf(nosup_response, "%s NO TLS not supported here\r\n",     parms[0]);
+       sprintf(error_response, "%s BAD Internal error\r\n",            parms[0]);
        CtdlModuleStartCryptoMsgs(ok_response, nosup_response, error_response);
 }
 
@@ -720,11 +710,11 @@ void imap_select(int num_parms, char *parms[])
 
        /* Then try a mailbox name match */
        if (c != 0) {
-               CtdlMailboxName(augmented_roomname, sizeof augmented_roomname,
-                           &CC->user, towhere);
+               CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CC->user, towhere);
                c = CtdlGetRoom(&QRscratch, augmented_roomname);
-               if (c == 0)
+               if (c == 0) {
                        strcpy(towhere, augmented_roomname);
+               }
        }
 
        /* If the room exists, check security/access */
@@ -740,8 +730,7 @@ void imap_select(int num_parms, char *parms[])
 
        /* Fail here if no such room */
        if (!ok) {
-               cprintf("%s NO ... no such room, or access denied\r\n",
-                       parms[0]);
+               cprintf("%s NO ... no such room, or access denied\r\n", parms[0]);
                return;
        }
 
@@ -785,11 +774,11 @@ void imap_select(int num_parms, char *parms[])
 
        cprintf("%s OK [%s] %s completed\r\n",
                parms[0],
-               (IMAP->readonly ? "READ-ONLY" : "READ-WRITE"), parms[1]);
+               (IMAP->readonly ? "READ-ONLY" : "READ-WRITE"), parms[1]
+       );
 }
 
 
-
 /*
  * Does the real work for expunge.
  */
@@ -823,8 +812,7 @@ int imap_do_expunge(void)
                imap_rescan_msgids();
        }
 
-       CtdlLogPrintf(CTDL_DEBUG, "Expunged %d messages from <%s>\n",
-               num_expunged, CC->room.QRname);
+       CtdlLogPrintf(CTDL_DEBUG, "Expunged %d messages from <%s>\n", num_expunged, CC->room.QRname);
        return (num_expunged);
 }
 
@@ -898,7 +886,6 @@ void imap_namespace(int num_parms, char *parms[])
 }
 
 
-
 /*
  * Implements the CREATE command
  *
@@ -1091,7 +1078,6 @@ void imap_status(int num_parms, char *parms[])
 }
 
 
-
 /*
  * Implements the SUBSCRIBE command
  *
@@ -1183,7 +1169,6 @@ void imap_unsubscribe(int num_parms, char *parms[])
 }
 
 
-
 /*
  * Implements the DELETE command
  *
@@ -1368,8 +1353,6 @@ void imap_rename(int num_parms, char *parms[])
 }
 
 
-
-
 /* 
  * Main command loop for IMAP sessions.
  */
@@ -1429,7 +1412,6 @@ void imap_command_loop(void)
                return;
        }
 
-
        /* Ok, at this point we're in normal command mode.
         * If the command just submitted does not contain a literal, we
         * might think about delivering some untagged stuff...
@@ -1660,7 +1642,6 @@ void imap_command_loop(void)
 
        gettimeofday(&tv2, NULL);
        total_time = (tv2.tv_usec + (tv2.tv_sec * 1000000)) - (tv1.tv_usec + (tv1.tv_sec * 1000000));
-       CtdlLogPrintf(CTDL_INFO, "IMAP: %s\n", cmdbuf); // FIXME FIXME FIXME REMOVE THIS NOW
        CtdlLogPrintf(CTDL_DEBUG, "IMAP command completed in %ld.%ld seconds\n",
                (total_time / 1000000),
                (total_time % 1000000)