From: Richard Russon Date: Mon, 21 Jan 2019 23:31:59 +0000 (+0000) Subject: simplify bitfields in smtp X-Git-Tag: 2019-10-25~372^2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c01dc959827e0343805d595048e2bc179efe2d0;p=neomutt simplify bitfields in smtp --- diff --git a/smtp.c b/smtp.c index e61b46696..61f949c46 100644 --- a/smtp.c +++ b/smtp.c @@ -85,7 +85,7 @@ enum SmtpCapability }; static char *AuthMechs = NULL; -static unsigned char Capabilities[(SMTP_CAP_MAX + 7) / 8]; +static unsigned int Capabilities; /** * valid_smtp_code - Is the is a valid SMTP return code? @@ -132,19 +132,19 @@ static int smtp_get_resp(struct Connection *conn) size_t plen; if (mutt_str_startswith(s, "8BITMIME", CASE_IGNORE)) - mutt_bit_set(Capabilities, SMTP_CAP_EIGHTBITMIME); + Capabilities |= SMTP_CAP_EIGHTBITMIME; else if ((plen = mutt_str_startswith(s, "AUTH ", CASE_IGNORE))) { - mutt_bit_set(Capabilities, SMTP_CAP_AUTH); + Capabilities |= SMTP_CAP_AUTH; FREE(&AuthMechs); AuthMechs = mutt_str_strdup(s + plen); } else if (mutt_str_startswith(s, "DSN", CASE_IGNORE)) - mutt_bit_set(Capabilities, SMTP_CAP_DSN); + Capabilities |= SMTP_CAP_DSN; else if (mutt_str_startswith(s, "STARTTLS", CASE_IGNORE)) - mutt_bit_set(Capabilities, SMTP_CAP_STARTTLS); + Capabilities |= SMTP_CAP_STARTTLS; else if (mutt_str_startswith(s, "SMTPUTF8", CASE_IGNORE)) - mutt_bit_set(Capabilities, SMTP_CAP_SMTPUTF8); + Capabilities |= SMTP_CAP_SMTPUTF8; if (!valid_smtp_code(buf, n, &n)) return SMTP_ERR_CODE; @@ -178,7 +178,7 @@ static int smtp_rcpt_to(struct Connection *conn, const struct Address *a) a = a->next; continue; } - if (mutt_bit_isset(Capabilities, SMTP_CAP_DSN) && DsnNotify) + if ((Capabilities & SMTP_CAP_DSN) && DsnNotify) snprintf(buf, sizeof(buf), "RCPT TO:<%s> NOTIFY=%s\r\n", a->mailbox, DsnNotify); else snprintf(buf, sizeof(buf), "RCPT TO:<%s>\r\n", a->mailbox); @@ -367,7 +367,7 @@ static int smtp_helo(struct Connection *conn, bool esmtp) char buf[LONG_STRING]; const char *fqdn = NULL; - memset(Capabilities, 0, sizeof(Capabilities)); + Capabilities = 0; if (!esmtp) { @@ -683,7 +683,7 @@ static int smtp_open(struct Connection *conn, bool esmtp) rc = MUTT_NO; else if (SslForceTls) rc = MUTT_YES; - else if (mutt_bit_isset(Capabilities, SMTP_CAP_STARTTLS) && + else if ((Capabilities & SMTP_CAP_STARTTLS) && (rc = query_quadoption(SslStarttls, _("Secure connection with TLS?"))) == MUTT_ABORT) { @@ -713,7 +713,7 @@ static int smtp_open(struct Connection *conn, bool esmtp) if (conn->account.flags & MUTT_ACCT_USER) { - if (!mutt_bit_isset(Capabilities, SMTP_CAP_AUTH)) + if (!(Capabilities & SMTP_CAP_AUTH)) { mutt_error(_("SMTP server does not support authentication")); return -1; @@ -775,14 +775,14 @@ int mutt_smtp_send(const struct Address *from, const struct Address *to, /* send the sender's address */ int len = snprintf(buf, sizeof(buf), "MAIL FROM:<%s>", envfrom); - if (eightbit && mutt_bit_isset(Capabilities, SMTP_CAP_EIGHTBITMIME)) + if (eightbit && (Capabilities & SMTP_CAP_EIGHTBITMIME)) { mutt_str_strncat(buf, sizeof(buf), " BODY=8BITMIME", 15); len += 14; } - if (DsnReturn && mutt_bit_isset(Capabilities, SMTP_CAP_DSN)) + if (DsnReturn && (Capabilities & SMTP_CAP_DSN)) len += snprintf(buf + len, sizeof(buf) - len, " RET=%s", DsnReturn); - if (mutt_bit_isset(Capabilities, SMTP_CAP_SMTPUTF8) && + if ((Capabilities & SMTP_CAP_SMTPUTF8) && (address_uses_unicode(envfrom) || addresses_use_unicode(to) || addresses_use_unicode(cc) || addresses_use_unicode(bcc))) {