strfcpy (user, conn->mx.user, sizeof (user));
strfcpy (user, conn->account.user, sizeof (user));
int imap_authenticate (IMAP_DATA *idata, CONNECTION *conn){  char buf[LONG_STRING];  char user[SHORT_STRING], q_user[SHORT_STRING];  char ckey[SHORT_STRING];  char pass[SHORT_STRING], q_pass[SHORT_STRING];  int r = 1;  while (r != 0)  {    if (! (conn->mx.flags & M_IMAP_USER))    {      if (!ImapUser)      {	strfcpy (user, NONULL(Username), sizeof (user));	if (mutt_get_field (_("IMAP Username: "), user, sizeof (user), 0) != 0)	{	  user[0] = 0;	  return (-1);	}      }      else	strfcpy (user, ImapUser, sizeof (user));    }    else      strfcpy (user, conn->mx.user, sizeof (user));    if (!user[0])    {      if (!mutt_bit_isset (idata->capabilities, AUTH_ANON))      {	mutt_error _("Anonymous authentication not supported.");	return -1;      }            return imap_auth_anon (idata);    }    #ifdef USE_GSS    /* attempt GSSAPI authentication, if available */    if (mutt_bit_isset (idata->capabilities, AGSSAPI))    {      if ((r = imap_auth_gss (idata, user)))      {        mutt_error _("GSSAPI authentication failed.");        sleep (1);      }      else        return 0;    }    else      dprint (2, (debugfile, "GSSAPI authentication is not available\n"));#endif    /* attempt CRAM-MD5 if available */    if (mutt_bit_isset (idata->capabilities, ACRAM_MD5))    {      if (!(conn->mx.flags & M_IMAP_CRAM))      {	if (!ImapCRAMKey)	{	  ckey[0] = '\0';	  snprintf (buf, sizeof (buf), _("CRAM key for %s@%s: "), user,		    conn->mx.host);	  if (mutt_get_field (buf, ckey, sizeof (ckey), M_PASS) != 0)	    return -1;	}	else	  strfcpy (ckey, ImapCRAMKey, sizeof (ckey));      }      else        strfcpy (ckey, conn->mx.pass, sizeof (ckey));      if (*ckey)      {	if ((r = imap_auth_cram_md5 (idata, user, ckey)))	{	  mutt_error _("CRAM-MD5 authentication failed.");	  sleep (1);	  if (!(conn->mx.flags & M_IMAP_CRAM))	    FREE (&ImapCRAMKey);	  conn->mx.flags &= ~M_IMAP_CRAM;	}	else	{	  strfcpy (conn->mx.pass, ckey, sizeof (conn->mx.pass));	  conn->mx.flags |= M_IMAP_CRAM;	  return 0;	}      }      else      {	mutt_message _("Skipping CRAM-MD5 authentication.");	sleep (1);      }    }    else      dprint (2, (debugfile, "CRAM-MD5 authentication is not available\n"));            if (! (conn->mx.flags & M_IMAP_PASS))    {      if (!ImapPass)      {	pass[0]=0;	snprintf (buf, sizeof (buf), _("Password for %s@%s: "), user,          conn->mx.host);	if (mutt_get_field (buf, pass, sizeof (pass), M_PASS) != 0 ||	    !pass[0])	  return -1;      }      else	strfcpy (pass, ImapPass, sizeof (pass));    }    else      strfcpy (pass, conn->mx.pass, sizeof (pass));    imap_quote_string (q_user, sizeof (q_user), user);    imap_quote_string (q_pass, sizeof (q_pass), pass);    mutt_message _("Logging in...");#ifdef DEBUG    /* don't print the password unless we're at the ungodly debugging level     * of 5 or higher */    if (debuglevel < IMAP_LOG_PASS)      dprint (2, (debugfile, "Sending LOGIN command for %s...\n", user));#endif    snprintf (buf, sizeof (buf), "LOGIN %s %s", q_user, q_pass);    r = imap_exec (buf, sizeof (buf), idata, buf,      IMAP_CMD_FAIL_OK | IMAP_CMD_PASS);    if (r == -1)    {      /* connection or protocol problem */      imap_error ("imap_authenticate", buf);      return (-1);    }    else if (r == -2)    {      /* Login failed, try again */      mutt_error _("Login failed.");      sleep (1);      if (!(conn->mx.flags & M_IMAP_USER))	FREE (&ImapUser);      if (!(conn->mx.flags & M_IMAP_PASS))	FREE (&ImapPass);      conn->mx.flags &= ~M_IMAP_PASS;    }    else    {      /* If they have a successful login, we may as well cache the        * user/password. */      if (!(conn->mx.flags & M_IMAP_USER))	strfcpy (conn->mx.user, user, sizeof (conn->mx.user));      if (!(conn->mx.flags & M_IMAP_PASS))	strfcpy (conn->mx.pass, pass, sizeof (conn->mx.pass));            conn->mx.flags |= (M_IMAP_USER | M_IMAP_PASS);    }  }  return 0;}