]> granicus.if.org Git - mutt/commitdiff
patch-bac.notes-20010515.1
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 15 May 2001 20:41:54 +0000 (20:41 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 15 May 2001 20:41:54 +0000 (20:41 +0000)
imap/browse.c
imap/util.c
mutt_socket.c

index 284ba2ddacbd66403b1c66efd830fe6de4298235..daf02a2f5da7dbc266025897fda61478af63da24 100644 (file)
@@ -42,6 +42,7 @@ int imap_browse (char* path, struct browser_state* state)
 {
   IMAP_DATA* idata;
   char buf[LONG_STRING];
+  char buf2[LONG_STRING];
   char nsbuf[LONG_STRING];
   char mbox[LONG_STRING];
   char list_cmd[5];
@@ -154,7 +155,7 @@ int imap_browse (char* path, struct browser_state* state)
 
       if (showparents)
       {
-       dprint (2, (debugfile, "imap_init_browse: adding parent %s\n", mbox));
+       dprint (3, (debugfile, "imap_init_browse: adding parent %s\n", mbox));
        imap_add_folder (idata->delim, mbox, 1, 0, state, 1);
       }
 
@@ -198,14 +199,18 @@ int imap_browse (char* path, struct browser_state* state)
     /* Listing the home namespace, so INBOX should be included. Home 
      * namespace is not "", so we have to list it explicitly. We ask the 
      * server to see if it has descendants. */
-    dprint (4, (debugfile, "imap_init_browse: adding INBOX\n"));
+    dprint (3, (debugfile, "imap_browse: adding INBOX\n"));
     if (browse_add_list_result (idata, "LIST \"\" \"INBOX\"", state, 0))
       goto fail;
   }
 
   nsup = state->entrylen;
 
-  snprintf (buf, sizeof (buf), "%s \"\" \"%s%%\"", list_cmd, mbox);
+  dprint (3, (debugfile, "imap_browse: Quoting mailbox scan: %s -> ", mbox));
+  snprintf (buf, sizeof (buf), "%s%%", mbox);
+  imap_quote_string (buf2, sizeof (buf2), buf);
+  dprint (3, (debugfile, "%s\n", buf2));
+  snprintf (buf, sizeof (buf), "%s \"\" %s", list_cmd, buf2);
   if (browse_add_list_result (idata, buf, state, 0))
     goto fail;
 
@@ -219,7 +224,7 @@ int imap_browse (char* path, struct browser_state* state)
       if (nsi[i].listable && !nsi[i].home_namespace) {
        imap_add_folder(nsi[i].delim, nsi[i].prefix, nsi[i].noselect,
                        nsi[i].noinferiors, state, 0);
-       dprint (4, (debugfile, "imap_init_browse: adding namespace: %s\n",
+       dprint (3, (debugfile, "imap_browse: adding namespace: %s\n",
                    nsi[i].prefix));
       }
   }
index 97a0bce310cc5ee93b56501b91f199630cc97123..46a4c6e7a12846c0d28a9264f6888c0627419d1f 100644 (file)
@@ -391,25 +391,24 @@ void imap_qualify_path (char *dest, size_t len, IMAP_MBOX *mx, char* path)
 
 /* imap_quote_string: quote string according to IMAP rules:
  *   surround string with quotes, escape " and \ with \ */
-void imap_quote_string (char *dest, size_t slen, const char *src)
+void imap_quote_string (char *dest, size_t dlen, const char *src)
 {
   char quote[] = "\"\\", *pt;
   const char *s;
-  size_t len = slen;
 
   pt = dest;
   s  = src;
 
   *pt++ = '"';
   /* save room for trailing quote-char */
-  len -= 2;
+  dlen -= 2;
   
-  for (; *s && len; s++)
+  for (; *s && dlen; s++)
   {
     if (strchr (quote, *s))
     {
-      len -= 2;
-      if (!len)
+      dlen -= 2;
+      if (!dlen)
        break;
       *pt++ = '\\';
       *pt++ = *s;
@@ -417,7 +416,7 @@ void imap_quote_string (char *dest, size_t slen, const char *src)
     else
     {
       *pt++ = *s;
-      len--;
+      dlen--;
     }
   }
   *pt++ = '"';
index e628d65eb277e9b0741eefc1f0942539388a4591..44771459f724e5b791eef5bf9d09978dcb50f255 100644 (file)
@@ -65,6 +65,7 @@ int mutt_socket_close (CONNECTION* conn)
 int mutt_socket_write_d (CONNECTION *conn, const char *buf, int dbg)
 {
   int rc;
+  int len;
 
   dprint (dbg, (debugfile,"> %s", buf));
 
@@ -74,14 +75,22 @@ int mutt_socket_write_d (CONNECTION *conn, const char *buf, int dbg)
     return -1;
   }
 
-  if ((rc = conn->write (conn, buf, mutt_strlen (buf))) < 0)
+  len = mutt_strlen (buf);
+  if ((rc = conn->write (conn, buf, len)) < 0)
   {
-    dprint (1, (debugfile, "mutt_socket_write: error writing, closing socket\n"));
+    dprint (1, (debugfile,
+      "mutt_socket_write: error writing, closing socket\n"));
     mutt_socket_close (conn);
 
     return -1;
   }
 
+  if (rc < len)
+  {
+    dprint (1, (debugfile,
+      "mutt_socket_write: ERROR: wrote %d of %d bytes!\n", rc, len));
+  }
+
   return rc;
 }