Use p_new instead of xmalloc()
[apps/madmutt.git] / account.c
index d87c3e3..17234fb 100644 (file)
--- a/account.c
+++ b/account.c
@@ -9,28 +9,18 @@
 
 /* remote host account manipulation (POP/IMAP) */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/ascii.h>
-#include <lib-lib/macros.h>
+#include <lib-lib/lib-lib.h>
+#include <lib-ui/enter.h>
+#include <lib-ui/curses.h>
 
 #include "mutt.h"
-#include "enter.h"
 #include "account.h"
-#include "url.h"
-
 
 /* mutt_account_match: compare account info (host/port/user/login) */
 int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2)
 {
     const char* user = NONULL (Username);
-#ifdef USE_IMAP
     const char* login = NONULL (Username);
-#endif
 
     if (a1->type != a2->type)
         return 0;
@@ -39,19 +29,15 @@ int mutt_account_match (const ACCOUNT * a1, const ACCOUNT * a2)
     if (a1->port != a2->port)
         return 0;
 
-#ifdef USE_IMAP
     if (a1->type == M_ACCT_TYPE_IMAP) {
         if (ImapUser && (ImapUser[0] != '\0'))
             user = ImapUser;
         if (ImapLogin && (ImapLogin[0] != '\0'))
             login = ImapLogin;
     }
-#endif
 
-#ifdef USE_POP
     if (a1->type == M_ACCT_TYPE_POP && PopUser)
         user = PopUser;
-#endif
 
 #ifdef USE_NNTP
     if (a1->type == M_ACCT_TYPE_NNTP && NntpUser)
@@ -103,23 +89,19 @@ void mutt_account_tourl (ACCOUNT * account, ciss_url_t * url)
     url->pass = NULL;
     url->port = 0;
 
-#ifdef USE_IMAP
     if (account->type == M_ACCT_TYPE_IMAP) {
         if (account->flags & M_ACCT_SSL)
             url->scheme = U_IMAPS;
         else
             url->scheme = U_IMAP;
     }
-#endif
 
-#ifdef USE_POP
     if (account->type == M_ACCT_TYPE_POP) {
         if (account->flags & M_ACCT_SSL)
             url->scheme = U_POPS;
         else
             url->scheme = U_POP;
     }
-#endif
 
 #ifdef USE_NNTP
     if (account->type == M_ACCT_TYPE_NNTP) {
@@ -142,19 +124,15 @@ void mutt_account_tourl (ACCOUNT * account, ciss_url_t * url)
 /* mutt_account_getuser: retrieve username into ACCOUNT, if necessary */
 int mutt_account_getuser (ACCOUNT * account)
 {
-    char prompt[SHORT_STRING];
+    char prompt[STRING];
 
     /* already set */
     if (account->flags & M_ACCT_USER)
         return 0;
-#ifdef USE_IMAP
     else if ((account->type == M_ACCT_TYPE_IMAP) && !m_strisempty(ImapUser))
         m_strcpy(account->user, sizeof(account->user), ImapUser);
-#endif
-#ifdef USE_POP
     else if ((account->type == M_ACCT_TYPE_POP) && !m_strisempty(PopUser))
         m_strcpy(account->user, sizeof(account->user), PopUser);
-#endif
 #ifdef USE_NNTP
     else if ((account->type == M_ACCT_TYPE_NNTP) && !m_strisempty(NntpUser))
         m_strcpy(account->user, sizeof(account->user), NntpUser);
@@ -178,7 +156,6 @@ int mutt_account_getlogin (ACCOUNT* account)
     /* already set */
     if (account->flags & M_ACCT_LOGIN)
         return 0;
-#ifdef USE_IMAP
     else if (account->type == M_ACCT_TYPE_IMAP)
     {
         if (!m_strisempty(ImapLogin)) {
@@ -186,7 +163,6 @@ int mutt_account_getlogin (ACCOUNT* account)
             account->flags |= M_ACCT_LOGIN;
         }
     }
-#endif
 
     if (!(account->flags & M_ACCT_LOGIN)) {
         mutt_account_getuser (account);
@@ -201,18 +177,14 @@ int mutt_account_getlogin (ACCOUNT* account)
 /* mutt_account_getpass: fetch password into ACCOUNT, if neccessary */
 int mutt_account_getpass (ACCOUNT * account)
 {
-    char prompt[SHORT_STRING];
+    char prompt[STRING];
 
     if (account->flags & M_ACCT_PASS)
         return 0;
-#ifdef USE_IMAP
     else if ((account->type == M_ACCT_TYPE_IMAP) && !m_strisempty(ImapPass))
         m_strcpy(account->pass, sizeof(account->pass), ImapPass);
-#endif
-#ifdef USE_POP
     else if ((account->type == M_ACCT_TYPE_POP) && !m_strisempty(PopPass))
         m_strcpy(account->pass, sizeof(account->pass), PopPass);
-#endif
 #ifdef USE_NNTP
     else if ((account->type == M_ACCT_TYPE_NNTP) && !m_strisempty(NntpPass))
         m_strcpy(account->pass, sizeof(account->pass), NntpPass);
@@ -234,5 +206,5 @@ int mutt_account_getpass (ACCOUNT * account)
 
 void mutt_account_unsetpass (ACCOUNT * account)
 {
-    account->flags &= !M_ACCT_PASS;
+    account->flags &= ~M_ACCT_PASS;
 }