]> granicus.if.org Git - mutt/commitdiff
Unify logout stuff in _one_ function. From Vsevolod Volkov.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 11 Jul 2000 20:38:49 +0000 (20:38 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 11 Jul 2000 20:38:49 +0000 (20:38 +0000)
imap/imap.c
imap/imap_private.h
imap/socket.c

index b4015a1120a5a12c93ab9220567a09350b1257c3..051a32e9858714c1cdf8d62a42b0a649943ea247 100644 (file)
@@ -816,25 +816,30 @@ int imap_open_mailbox_append (CONTEXT *ctx)
   return 0;
 }
 
-int imap_close_connection (CONTEXT *ctx)
+void imap_logout (CONNECTION *conn)
 {
   char buf[LONG_STRING];
   char seq[8];
 
+  imap_make_sequence (seq, sizeof (seq));
+  snprintf (buf, sizeof (buf), "%s LOGOUT\r\n", seq);
+  mutt_socket_write (conn, buf);
+  do
+  {
+    if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
+      break;
+  }
+  while (mutt_strncmp (seq, buf, SEQLEN) != 0);
+}
+
+int imap_close_connection (CONTEXT *ctx)
+{
   dprint (1, (debugfile, "imap_close_connection(): closing connection\n"));
   /* if the server didn't shut down on us, close the connection gracefully */
   if (CTX_DATA->status != IMAP_BYE)
   {
     mutt_message _("Closing connection to IMAP server...");
-    imap_make_sequence (seq, sizeof (seq));
-    snprintf (buf, sizeof (buf), "%s LOGOUT\r\n", seq);
-    mutt_socket_write (CTX_DATA->conn, buf);
-    do
-    {
-      if (mutt_socket_readln (buf, sizeof (buf), CTX_DATA->conn) < 0)
-       break;
-    }
-    while (mutt_strncmp (seq, buf, SEQLEN) != 0);
+    imap_logout (CTX_DATA->conn);
     mutt_clear_error ();
   }
   mutt_socket_close (CTX_DATA->conn);
index 08fd34128f83db0100b770494cb67ad56de2985d..1d5cc24ed5e37d9365634b2dd3f144c87700212d 100644 (file)
@@ -178,6 +178,7 @@ int imap_parse_list_response(CONNECTION* conn, char* buf, int buflen,
   char** name, int* noselect, int* noinferiors, char* delim);
 int imap_read_bytes (FILE* fp, CONNECTION* conn, long bytes);
 int imap_reopen_mailbox (CONTEXT *ctx, int *index_hint);
+void imap_logout (CONNECTION* conn);
 
 /* auth.c */
 int imap_authenticate (IMAP_DATA *idata, CONNECTION *conn);
index e752bcf13529073f97a3dd640a0894a6c8870e04..0fad0a6467d63b4bf939db3e905e4a70fc50a175 100644 (file)
@@ -151,8 +151,6 @@ CONNECTION* mutt_socket_find (const IMAP_MBOX* mx, int newconn)
 void imap_logout_all (void) 
 {
   CONNECTION* conn;
-  char buf[SHORT_STRING];
-  char seq[SEQLEN+1];
   
   conn = Connections;
 
@@ -163,17 +161,8 @@ void imap_logout_all (void)
       mutt_message (_("Closing connection to %s..."),
                    conn->mx.host);
       
-      imap_make_sequence (seq, sizeof (seq));
-      snprintf (buf, sizeof (buf), "%s LOGOUT\r\n", seq);
-
-      mutt_socket_write (conn, buf);
-
-      do
-      {
-       if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
-         break;
-      }
-      while (mutt_strncmp (buf, seq, SEQLEN) != 0);
+      imap_logout (conn);
+      
       mutt_clear_error ();
 
       mutt_socket_close (conn);