less horrible strncpy's
[apps/madmutt.git] / account.c
index c22b57d..8d8a847 100644 (file)
--- a/account.c
+++ b/account.c
 
 #include <lib-lib/mem.h>
 #include <lib-lib/str.h>
+#include <lib-lib/ascii.h>
 #include <lib-lib/macros.h>
 
 #include "mutt.h"
 #include "enter.h"
-#include "ascii.h"
 #include "account.h"
 #include "url.h"
 
@@ -57,11 +57,11 @@ int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2)
 #endif
 
   if (a1->flags & a2->flags & M_ACCT_USER)
-    return (!str_cmp (a1->user, a2->user));
+    return (!m_strcmp(a1->user, a2->user));
   if (a1->flags & M_ACCT_USER)
-    return (!str_cmp (a1->user, user));
+    return (!m_strcmp(a1->user, user));
   if (a2->flags & M_ACCT_USER)
-    return (!str_cmp (a2->user, user));
+    return (!m_strcmp(a2->user, user));
 
   return 1;
 }
@@ -147,21 +147,21 @@ int mutt_account_getuser (ACCOUNT * account)
   if (account->flags & M_ACCT_USER)
     return 0;
 #ifdef USE_IMAP
-  else if ((account->type == M_ACCT_TYPE_IMAP) && ImapUser && (ImapUser[0] != '\0'))
+  else if ((account->type == M_ACCT_TYPE_IMAP) && m_strlen(ImapUser))
     strfcpy (account->user, ImapUser, sizeof (account->user));
 #endif
 #ifdef USE_POP
-  else if ((account->type == M_ACCT_TYPE_POP) && PopUser)
+  else if ((account->type == M_ACCT_TYPE_POP) && m_strlen(PopUser))
     strfcpy (account->user, PopUser, sizeof (account->user));
 #endif
 #ifdef USE_NNTP
-  else if ((account->type == M_ACCT_TYPE_NNTP) && NntpUser)
+  else if ((account->type == M_ACCT_TYPE_NNTP) && m_strlen(NntpUser))
     strfcpy (account->user, NntpUser, sizeof (account->user));
 #endif
   /* prompt (defaults to unix username), copy into account->user */
   else {
     snprintf (prompt, sizeof (prompt), _("Username at %s: "), account->host);
-    strfcpy (account->user, NONULL (Username), sizeof (account->user));
+    strfcpy (account->user, NONULL(Username), sizeof (account->user));
     if (mutt_get_field_unbuffered (prompt, account->user,
                                     sizeof (account->user), 0))
       return -1;
@@ -205,15 +205,15 @@ int mutt_account_getpass (ACCOUNT * account)
   if (account->flags & M_ACCT_PASS)
     return 0;
 #ifdef USE_IMAP
-  else if ((account->type == M_ACCT_TYPE_IMAP) && ImapPass)
+  else if ((account->type == M_ACCT_TYPE_IMAP) && m_strlen(ImapPass))
     strfcpy (account->pass, ImapPass, sizeof (account->pass));
 #endif
 #ifdef USE_POP
-  else if ((account->type == M_ACCT_TYPE_POP) && PopPass)
+  else if ((account->type == M_ACCT_TYPE_POP) && m_strlen(PopPass))
     strfcpy (account->pass, PopPass, sizeof (account->pass));
 #endif
 #ifdef USE_NNTP
-  else if ((account->type == M_ACCT_TYPE_NNTP) && NntpPass)
+  else if ((account->type == M_ACCT_TYPE_NNTP) && m_strlen(NntpPass))
     strfcpy (account->pass, NntpPass, sizeof (account->pass));
 #endif
   else {