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

init.h
pop/pop.h
pop/pop_auth.c

diff --git a/init.h b/init.h
index 95fe1e5ced5aef4d585f99a3e9b7675bac569e03..5b4590d04aa16570205b5ef2324b22e38525b0fa 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2960,7 +2960,7 @@ struct ConfigDef MuttVars[] = {
   ** methods if the previous methods are unavailable. If a method is
   ** available but authentication fails, NeoMutt will not connect to the POP server.
   */
-  { "pop_authenticators", DT_STRING, &C_PopAuthenticators, 0 },
+  { "pop_authenticators", DT_SLIST|SLIST_SEP_COLON, &C_PopAuthenticators, 0 },
   /*
   ** .pp
   ** This is a colon-delimited list of authentication methods NeoMutt may
index 84bb7b4281c12e2f2f5f654e79417272b350b0cb..0b4d8eca0c22f2cd61f72041fd02123dfd010221 100644 (file)
--- a/pop/pop.h
+++ b/pop/pop.h
@@ -47,7 +47,7 @@ extern char *        C_PopHost;
 extern bool          C_PopLast;
 
 /* These Config Variables are only used in pop/pop_auth.c */
-extern char *C_PopAuthenticators;
+extern struct Slist *C_PopAuthenticators;
 extern bool  C_PopAuthTryAll;
 
 /* These Config Variables are only used in pop/pop_lib.c */
index 8114278f9dffd452183198523ff660c517baa4d6..b9d180b792bb12a3f4fd684f46fac36b9857001c 100644 (file)
@@ -44,7 +44,7 @@
 #endif
 
 /* These Config Variables are only used in pop/pop_auth.c */
-char *C_PopAuthenticators; ///< Config: (pop) List of allowed authentication methods
+struct Slist *C_PopAuthenticators; ///< Config: (pop) List of allowed authentication methods
 bool C_PopAuthTryAll; ///< Config: (pop) Try all available authentication methods
 
 #ifdef USE_SASL
@@ -409,9 +409,6 @@ int pop_authenticate(struct PopAccountData *adata)
 {
   struct ConnAccount *acct = &adata->conn->account;
   const struct PopAuth *authenticator = NULL;
-  char *methods = NULL;
-  char *comma = NULL;
-  char *method = NULL;
   int attempts = 0;
   int ret = POP_A_UNAVAIL;
 
@@ -423,30 +420,25 @@ int pop_authenticate(struct PopAccountData *adata)
   if (C_PopAuthenticators)
   {
     /* Try user-specified list of authentication methods */
-    methods = mutt_str_strdup(C_PopAuthenticators);
-    method = methods;
-
-    while (method)
+    struct ListNode *np = NULL;
+    STAILQ_FOREACH(np, &C_PopAuthenticators->head, entries)
     {
-      comma = strchr(method, ':');
-      if (comma)
-        *comma++ = '\0';
-      mutt_debug(LL_DEBUG2, "Trying method %s\n", method);
+      mutt_debug(LL_DEBUG2, "Trying method %s\n", np->data);
       authenticator = pop_authenticators;
 
       while (authenticator->authenticate)
       {
         if (!authenticator->method ||
-            (mutt_str_strcasecmp(authenticator->method, method) == 0))
+            (mutt_str_strcasecmp(authenticator->method, np->data) == 0))
         {
-          ret = authenticator->authenticate(adata, method);
+          ret = authenticator->authenticate(adata, np->data);
           if (ret == POP_A_SOCKET)
           {
             switch (pop_connect(adata))
             {
               case 0:
               {
-                ret = authenticator->authenticate(adata, method);
+                ret = authenticator->authenticate(adata, np->data);
                 break;
               }
               case -2:
@@ -459,17 +451,12 @@ int pop_authenticate(struct PopAccountData *adata)
           if ((ret == POP_A_SUCCESS) || (ret == POP_A_SOCKET) ||
               ((ret == POP_A_FAILURE) && !C_PopAuthTryAll))
           {
-            comma = NULL;
             break;
           }
         }
         authenticator++;
       }
-
-      method = comma;
     }
-
-    FREE(&methods);
   }
   else
   {