]> granicus.if.org Git - neomutt/commitdiff
smtp: convert int->bool, remove global variable
authorPietro Cerutti <gahr@gahr.ch>
Wed, 18 Jul 2018 15:04:35 +0000 (15:04 +0000)
committerPietro Cerutti <gahr@gahr.ch>
Wed, 18 Jul 2018 15:04:35 +0000 (15:04 +0000)
smtp.c
smtp.h

diff --git a/smtp.c b/smtp.c
index 3931224b5d6fe69eaacfe42d7ed3c75cf8b69275..f1d587b5556117511f553c8b87bc2a508c8741b3 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -78,7 +78,6 @@ enum SmtpCapability
   CAPMAX
 };
 
-static int Esmtp = 0;
 static char *AuthMechs = NULL;
 static unsigned char Capabilities[(CAPMAX + 7) / 8];
 
@@ -326,21 +325,21 @@ static int smtp_fill_account(struct Account *account)
   return 0;
 }
 
-static int smtp_helo(struct Connection *conn)
+static int smtp_helo(struct Connection *conn, bool esmtp)
 {
   char buf[LONG_STRING];
   const char *fqdn = NULL;
 
   memset(Capabilities, 0, sizeof(Capabilities));
 
-  if (!Esmtp)
+  if (!esmtp)
   {
     /* if TLS or AUTH are requested, use EHLO */
     if (conn->account.flags & MUTT_ACCT_USER)
-      Esmtp = 1;
+      esmtp = true;
 #ifdef USE_SSL
     if (SslForceTls || SslStarttls != MUTT_NO)
-      Esmtp = 1;
+      esmtp = true;
 #endif
   }
 
@@ -348,7 +347,7 @@ static int smtp_helo(struct Connection *conn)
   if (!fqdn)
     fqdn = NONULL(ShortHostname);
 
-  snprintf(buf, sizeof(buf), "%s %s\r\n", Esmtp ? "EHLO" : "HELO", fqdn);
+  snprintf(buf, sizeof(buf), "%s %s\r\n", esmtp ? "EHLO" : "HELO", fqdn);
   /* XXX there should probably be a wrapper in mutt_socket.c that
    * repeatedly calls conn->write until all data is sent.  This
    * currently doesn't check for a short write.
@@ -568,7 +567,7 @@ error:
 }
 #endif /* USE_SASL */
 
-static int smtp_open(struct Connection *conn)
+static int smtp_open(struct Connection *conn, bool esmtp)
 {
   int rc;
 
@@ -580,7 +579,7 @@ static int smtp_open(struct Connection *conn)
   if (rc != 0)
     return rc;
 
-  rc = smtp_helo(conn);
+  rc = smtp_helo(conn, esmtp);
   if (rc != 0)
     return rc;
 
@@ -611,7 +610,7 @@ static int smtp_open(struct Connection *conn)
     }
 
     /* re-EHLO to get authentication mechanisms */
-    rc = smtp_helo(conn);
+    rc = smtp_helo(conn, esmtp);
     if (rc != 0)
       return rc;
   }
@@ -637,7 +636,7 @@ static int smtp_open(struct Connection *conn)
 
 int mutt_smtp_send(const struct Address *from, const struct Address *to,
                    const struct Address *cc, const struct Address *bcc,
-                   const char *msgfile, int eightbit)
+                   const char *msgfile, bool eightbit)
 {
   struct Connection *conn = NULL;
   struct Account account;
@@ -664,12 +663,10 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to,
   if (!conn)
     return -1;
 
-  Esmtp = eightbit;
-
   do
   {
     /* send our greeting */
-    rc = smtp_open(conn);
+    rc = smtp_open(conn, eightbit);
     if (rc != 0)
       break;
     FREE(&AuthMechs);
diff --git a/smtp.h b/smtp.h
index f4fbab0d308651573777d2c578f1ac86afe3a5a3..27b0a1b4244021a494f273f07ffc20f6aec84bfc 100644 (file)
--- a/smtp.h
+++ b/smtp.h
@@ -29,7 +29,7 @@ struct Address;
 extern char *SmtpAuthenticators;
 
 #ifdef USE_SMTP
-int mutt_smtp_send(const struct Address *from, const struct Address *to, const struct Address *cc, const struct Address *bcc, const char *msgfile, int eightbit);
+int mutt_smtp_send(const struct Address *from, const struct Address *to, const struct Address *cc, const struct Address *bcc, const char *msgfile, bool eightbit);
 #endif
 
 #endif /* MUTT_SMTP_H */