]> granicus.if.org Git - neomutt/commitdiff
smtp_authenticators -> slist
authorRichard Russon <rich@flatcap.org>
Mon, 10 Jun 2019 19:41:48 +0000 (20:41 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 12 Jun 2019 23:23:35 +0000 (00:23 +0100)
Convert `$smtp_authenticators` to use the new DT_SLIST type (string list).

init.h
smtp.c
smtp.h

diff --git a/init.h b/init.h
index 709796709951223b8734dd719ad231fd84698abd..95fe1e5ced5aef4d585f99a3e9b7675bac569e03 100644 (file)
--- a/init.h
+++ b/init.h
@@ -4054,7 +4054,7 @@ struct ConfigDef MuttVars[] = {
   */
 #endif
 #ifdef USE_SMTP
-  { "smtp_authenticators", DT_STRING, &C_SmtpAuthenticators, 0 },
+  { "smtp_authenticators", DT_SLIST|SLIST_SEP_COLON, &C_SmtpAuthenticators, 0 },
   /*
   ** .pp
   ** This is a colon-delimited list of authentication methods NeoMutt may
diff --git a/smtp.c b/smtp.c
index 444e3067f96ccc3d692d65af11736ebf8fe57830..8dc942a95ebdc04ec60b1826372a3cfc24949a8a 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -56,7 +56,7 @@
 #endif
 
 /* These Config Variables are only used in smtp.c */
-char *C_SmtpAuthenticators; ///< Config: (smtp) List of allowed authentication methods
+struct Slist *C_SmtpAuthenticators; ///< Config: (smtp) List of allowed authentication methods
 
 #define smtp_success(x) ((x) / 100 == 2)
 #define SMTP_READY 334
@@ -589,47 +589,36 @@ static int smtp_auth(struct Connection *conn)
 
   if (C_SmtpAuthenticators)
   {
-    char *methods = mutt_str_strdup(C_SmtpAuthenticators);
-    char *method = NULL;
-    char *delim = NULL;
-
-    for (method = methods; method; method = delim)
+    struct ListNode *np = NULL;
+    STAILQ_FOREACH(np, &C_SmtpAuthenticators->head, entries)
     {
-      delim = strchr(method, ':');
-      if (delim)
-        *delim++ = '\0';
-      if (method[0] == '\0')
-        continue;
+      mutt_debug(LL_DEBUG2, "Trying method %s\n", np->data);
 
-      mutt_debug(LL_DEBUG2, "Trying method %s\n", method);
-
-      if (strcmp(method, "oauthbearer") == 0)
+      if (strcmp(np->data, "oauthbearer") == 0)
       {
         r = smtp_auth_oauth(conn);
       }
-      else if (strcmp(method, "plain") == 0)
+      else if (strcmp(np->data, "plain") == 0)
       {
         r = smtp_auth_plain(conn);
       }
       else
       {
 #ifdef USE_SASL
-        r = smtp_auth_sasl(conn, method);
+        r = smtp_auth_sasl(conn, np->data);
 #else
-        mutt_error(_("SMTP authentication method %s requires SASL"), method);
+        mutt_error(_("SMTP authentication method %s requires SASL"), np->data);
         continue;
 #endif
       }
 
-      if ((r == SMTP_AUTH_FAIL) && delim)
+      if ((r == SMTP_AUTH_FAIL) && (C_SmtpAuthenticators->count > 1))
       {
-        mutt_error(_("%s authentication failed, trying next method"), method);
+        mutt_error(_("%s authentication failed, trying next method"), np->data);
       }
       else if (r != SMTP_AUTH_UNAVAIL)
         break;
     }
-
-    FREE(&methods);
   }
   else
   {
diff --git a/smtp.h b/smtp.h
index cf74ed8b3ae13f0ba7b0aa113ef6dff868ee7897..a6476c2ad729c405260aaa822ee36c4e68ba4a63 100644 (file)
--- a/smtp.h
+++ b/smtp.h
@@ -27,7 +27,7 @@
 struct AddressList;
 
 /* These Config Variables are only used in smtp.c */
-extern char *C_SmtpAuthenticators;
+extern struct Slist *C_SmtpAuthenticators;
 
 #ifdef USE_SMTP
 int mutt_smtp_send(const struct AddressList *from, const struct AddressList *to,