NeoMutt  2019-11-11
Teaching an old dog new tricks
DOXYGEN
handler.h File Reference

Decide how to display email content. More...

#include <stddef.h>
#include <iconv.h>
#include <stdbool.h>
+ Include dependency graph for handler.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mutt_body_handler (struct Body *b, struct State *s)
 Handler for the Body of an email. More...
 
bool mutt_can_decode (struct Body *a)
 Will decoding the attachment produce any output. More...
 
void mutt_decode_attachment (struct Body *b, struct State *s)
 Decode an email's attachment. More...
 
void mutt_decode_base64 (struct State *s, size_t len, bool istext, iconv_t cd)
 Decode base64-encoded text. More...
 

Variables

bool C_HonorDisposition
 Config: Don't display MIME parts inline if they have a disposition of 'attachment'. More...
 
bool C_ImplicitAutoview
 Config: Display MIME attachments inline if a 'copiousoutput' mailcap entry exists. More...
 
bool C_IncludeEncrypted
 Config: Whether to include encrypted content when replying. More...
 
bool C_IncludeOnlyfirst
 Config: Only include the first attachment when replying. More...
 
struct SlistC_PreferredLanguages
 Config: Preferred languages for multilingual MIME. More...
 
bool C_ReflowText
 Config: Reformat paragraphs of 'format=flowed' text. More...
 
char * C_ShowMultipartAlternative
 Config: How to display 'multipart/alternative' MIME parts. More...
 

Detailed Description

Decide how to display email content.

Authors
  • Michael R. Elkins

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file handler.h.

Function Documentation

◆ mutt_body_handler()

int mutt_body_handler ( struct Body b,
struct State s 
)

Handler for the Body of an email.

Parameters
bBody of the email
sState to work with
Return values
0Success
-1Error

Definition at line 1551 of file handler.c.

1552 {
1553  if (!b || !s)
1554  return -1;
1555 
1556  bool plaintext = false;
1557  handler_t handler = NULL;
1558  handler_t encrypted_handler = NULL;
1559  int rc = 0;
1560 
1561  int oflags = s->flags;
1562 
1563  /* first determine which handler to use to process this part */
1564 
1565  if (is_autoview(b))
1566  {
1567  handler = autoview_handler;
1568  s->flags &= ~MUTT_CHARCONV;
1569  }
1570  else if (b->type == TYPE_TEXT)
1571  {
1572  if (mutt_str_strcasecmp("plain", b->subtype) == 0)
1573  {
1574  /* avoid copying this part twice since removing the transfer-encoding is
1575  * the only operation needed. */
1576  if (((WithCrypto & APPLICATION_PGP) != 0) && mutt_is_application_pgp(b))
1577  {
1578  encrypted_handler = crypt_pgp_application_handler;
1579  handler = encrypted_handler;
1580  }
1581  else if (C_ReflowText &&
1582  (mutt_str_strcasecmp("flowed",
1583  mutt_param_get(&b->parameter, "format")) == 0))
1584  {
1585  handler = rfc3676_handler;
1586  }
1587  else
1588  {
1589  handler = text_plain_handler;
1590  }
1591  }
1592  else if (mutt_str_strcasecmp("enriched", b->subtype) == 0)
1593  handler = text_enriched_handler;
1594  else /* text body type without a handler */
1595  plaintext = false;
1596  }
1597  else if (b->type == TYPE_MESSAGE)
1598  {
1599  if (mutt_is_message_type(b->type, b->subtype))
1600  handler = message_handler;
1601  else if (mutt_str_strcasecmp("delivery-status", b->subtype) == 0)
1602  plaintext = true;
1603  else if (mutt_str_strcasecmp("external-body", b->subtype) == 0)
1604  handler = external_body_handler;
1605  }
1606  else if (b->type == TYPE_MULTIPART)
1607  {
1608  if ((mutt_str_strcmp("inline", C_ShowMultipartAlternative) != 0) &&
1609  (mutt_str_strcasecmp("alternative", b->subtype) == 0))
1610  {
1611  handler = alternative_handler;
1612  }
1613  else if ((mutt_str_strcmp("inline", C_ShowMultipartAlternative) != 0) &&
1614  (mutt_str_strcasecmp("multilingual", b->subtype) == 0))
1615  {
1616  handler = multilingual_handler;
1617  }
1618  else if ((WithCrypto != 0) && (mutt_str_strcasecmp("signed", b->subtype) == 0))
1619  {
1620  if (!mutt_param_get(&b->parameter, "protocol"))
1621  mutt_error(_("Error: multipart/signed has no protocol"));
1622  else if (s->flags & MUTT_VERIFY)
1623  handler = mutt_signed_handler;
1624  }
1626  {
1627  encrypted_handler = valid_pgp_encrypted_handler;
1628  handler = encrypted_handler;
1629  }
1631  {
1632  encrypted_handler = malformed_pgp_encrypted_handler;
1633  handler = encrypted_handler;
1634  }
1635 
1636  if (!handler)
1637  handler = multipart_handler;
1638 
1639  if ((b->encoding != ENC_7BIT) && (b->encoding != ENC_8BIT) && (b->encoding != ENC_BINARY))
1640  {
1641  mutt_debug(LL_DEBUG1, "Bad encoding type %d for multipart entity, assuming 7 bit\n",
1642  b->encoding);
1643  b->encoding = ENC_7BIT;
1644  }
1645  }
1646  else if ((WithCrypto != 0) && (b->type == TYPE_APPLICATION))
1647  {
1648  if (OptDontHandlePgpKeys && (mutt_str_strcasecmp("pgp-keys", b->subtype) == 0))
1649  {
1650  /* pass raw part through for key extraction */
1651  plaintext = true;
1652  }
1653  else if (((WithCrypto & APPLICATION_PGP) != 0) && mutt_is_application_pgp(b))
1654  {
1655  encrypted_handler = crypt_pgp_application_handler;
1656  handler = encrypted_handler;
1657  }
1658  else if (((WithCrypto & APPLICATION_SMIME) != 0) && mutt_is_application_smime(b))
1659  {
1660  encrypted_handler = crypt_smime_application_handler;
1661  handler = encrypted_handler;
1662  }
1663  }
1664 
1665  /* only respect disposition == attachment if we're not
1666  * displaying from the attachment menu (i.e. pager) */
1667  if ((!C_HonorDisposition || ((b->disposition != DISP_ATTACH) || OptViewAttach)) &&
1668  (plaintext || handler))
1669  {
1670  /* Prevent encrypted attachments from being included in replies
1671  * unless $include_encrypted is set. */
1672  if ((s->flags & MUTT_REPLYING) && (s->flags & MUTT_FIRSTDONE) &&
1673  encrypted_handler && !C_IncludeEncrypted)
1674  {
1675  goto cleanup;
1676  }
1677 
1678  rc = run_decode_and_handler(b, s, handler, plaintext);
1679  }
1680  /* print hint to use attachment menu for disposition == attachment
1681  * if we're not already being called from there */
1682  else if ((s->flags & MUTT_DISPLAY) || ((b->disposition == DISP_ATTACH) && !OptViewAttach &&
1683  C_HonorDisposition && (plaintext || handler)))
1684  {
1685  char keystroke[128];
1686  keystroke[0] = '\0';
1687  struct Buffer msg = mutt_buffer_make(256);
1688 
1689  if (!OptViewAttach)
1690  {
1691  if (km_expand_key(keystroke, sizeof(keystroke),
1692  km_find_func(MENU_PAGER, OP_VIEW_ATTACHMENTS)))
1693  {
1695  {
1696  /* L10N: %s expands to a keystroke/key binding, e.g. 'v'. */
1697  mutt_buffer_printf(&msg, _("[-- This is an attachment (use '%s' to view this part) --]\n"),
1698  keystroke);
1699  }
1700  else
1701  {
1702  /* L10N: %s/%s is a MIME type, e.g. "text/plain".
1703  The last %s expands to a keystroke/key binding, e.g. 'v'. */
1704  mutt_buffer_printf(&msg, _("[-- %s/%s is unsupported (use '%s' to view this part) --]\n"),
1705  TYPE(b), b->subtype, keystroke);
1706  }
1707  }
1708  else
1709  {
1711  {
1712  mutt_buffer_strcpy(&msg, _("[-- This is an attachment (need "
1713  "'view-attachments' bound to key) --]\n"));
1714  }
1715  else
1716  {
1717  /* L10N: %s/%s is a MIME type, e.g. "text/plain". */
1718  mutt_buffer_printf(&msg, _("[-- %s/%s is unsupported (need 'view-attachments' bound to key) --]\n"),
1719  TYPE(b), b->subtype);
1720  }
1721  }
1722  }
1723  else
1724  {
1726  {
1727  mutt_buffer_strcpy(&msg, _("[-- This is an attachment --]\n"));
1728  }
1729  else
1730  {
1731  /* L10N: %s/%s is a MIME type, e.g. "text/plain". */
1732  mutt_buffer_printf(&msg, _("[-- %s/%s is unsupported --]\n"), TYPE(b), b->subtype);
1733  }
1734  }
1735  state_mark_attach(s);
1736  state_printf(s, "%s", mutt_b2s(&msg));
1737  mutt_buffer_dealloc(&msg);
1738  }
1739 
1740 cleanup:
1741  s->flags = oflags | (s->flags & MUTT_FIRSTDONE);
1742  if (rc != 0)
1743  {
1744  mutt_debug(LL_DEBUG1, "Bailing on attachment of type %s/%s\n", TYPE(b),
1745  NONULL(b->subtype));
1746  }
1747 
1748  return rc;
1749 }
int state_printf(struct State *s, const char *fmt,...)
Write a formatted string to the State.
Definition: state.c:153
#define MUTT_DISPLAY
Output is displayed to the user.
Definition: state.h:32
#define NONULL(x)
Definition: string2.h:37
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1389
static bool is_autoview(struct Body *b)
Should email body be filtered by mailcap.
Definition: handler.c:484
static int alternative_handler(struct Body *a, struct State *s)
Handler for multipart alternative emails - Implements handler_t.
Definition: handler.c:925
#define MUTT_CHARCONV
Do character set conversions.
Definition: state.h:36
int(* handler_t)(struct Body *b, struct State *s)
typedef handler_t - Manage a PGP or S/MIME encrypted MIME part
Definition: handler.c:87
int crypt_pgp_application_handler(struct Body *m, struct State *s)
Wrapper for CryptModuleSpecs::application_handler()
Definition: cryptglue.c:227
7-bit text
Definition: mime.h:49
int mutt_signed_handler(struct Body *a, struct State *s)
Verify a "multipart/signed" body - Implements handler_t.
Definition: crypt.c:1122
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
String manipulation buffer.
Definition: buffer.h:33
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:477
#define _(a)
Definition: message.h:28
int text_enriched_handler(struct Body *a, struct State *s)
Handler for enriched text - Implements handler_t.
Definition: enriched.c:460
8-bit text
Definition: mime.h:50
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
int crypt_smime_application_handler(struct Body *m, struct State *s)
Wrapper for CryptModuleSpecs::application_handler()
Definition: cryptglue.c:436
unsigned int disposition
content-disposition
Definition: body.h:67
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
Pager pager (email viewer)
Definition: keymap.h:78
static int malformed_pgp_encrypted_handler(struct Body *b, struct State *s)
Handler for invalid pgp-encrypted emails - Implements handler_t.
Definition: handler.c:1455
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
Content is attached.
Definition: mime.h:63
WHERE bool OptDontHandlePgpKeys
(pseudo) used to extract PGP keys
Definition: options.h:34
unsigned int encoding
content-transfer-encoding
Definition: body.h:66
static int message_handler(struct Body *a, struct State *s)
Handler for message/rfc822 body parts - Implements handler_t.
Definition: handler.c:701
bool C_ReflowText
Config: Reformat paragraphs of &#39;format=flowed&#39; text.
Definition: handler.c:70
char * subtype
content-type subtype
Definition: body.h:37
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function&#39;s mapping in a Menu.
Definition: keymap.c:856
#define mutt_b2s(buf)
Definition: buffer.h:41
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:559
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:828
#define MUTT_VERIFY
Perform signature verification.
Definition: state.h:33
Type: &#39;text/*&#39;.
Definition: mime.h:38
static int valid_pgp_encrypted_handler(struct Body *b, struct State *s)
Handler for valid pgp-encrypted emails - Implements handler_t.
Definition: handler.c:1426
static int run_decode_and_handler(struct Body *b, struct State *s, handler_t handler, bool plaintext)
Run an appropriate decoder for an email.
Definition: handler.c:1287
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:514
static int multilingual_handler(struct Body *a, struct State *s)
Handler for multi-lingual emails - Implements handler_t.
Definition: handler.c:1106
bool C_IncludeEncrypted
Config: Whether to include encrypted content when replying.
Definition: handler.c:67
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:618
void state_mark_attach(struct State *s)
Write a unique marker around content.
Definition: state.c:41
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
bool C_HonorDisposition
Config: Don&#39;t display MIME parts inline if they have a disposition of &#39;attachment&#39;.
Definition: handler.c:65
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
Type: &#39;message/*&#39;.
Definition: mime.h:35
#define TYPE(body)
Definition: mime.h:83
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
Log at debug level 1.
Definition: logging.h:56
static int autoview_handler(struct Body *a, struct State *s)
Handler for autoviewable attachments - Implements handler_t.
Definition: handler.c:529
#define mutt_error(...)
Definition: logging.h:84
Binary.
Definition: mime.h:53
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
char * C_ShowMultipartAlternative
Config: How to display &#39;multipart/alternative&#39; MIME parts.
Definition: handler.c:71
#define MUTT_REPLYING
Are we replying?
Definition: state.h:38
static int multipart_handler(struct Body *a, struct State *s)
Handler for multipart emails - Implements handler_t.
Definition: handler.c:1204
WHERE bool OptViewAttach
(pseudo) signals that we are viewing attachments
Definition: options.h:53
#define MUTT_FIRSTDONE
The first attachment has been done.
Definition: state.h:39
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
int rfc3676_handler(struct Body *a, struct State *s)
Body handler implementing RFC3676 for format=flowed - Implements handler_t.
Definition: rfc3676.c:317
static int external_body_handler(struct Body *b, struct State *s)
Handler for external-body emails - Implements handler_t.
Definition: handler.c:754
static int text_plain_handler(struct Body *b, struct State *s)
Handler for plain text - Implements handler_t.
Definition: handler.c:675
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
#define WithCrypto
Definition: ncrypt.h:160
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_can_decode()

bool mutt_can_decode ( struct Body a)

Will decoding the attachment produce any output.

Parameters
aBody of email to test
Return values
trueDecoding the attachment will produce output

Definition at line 1756 of file handler.c.

1757 {
1758  if (is_autoview(a))
1759  return true;
1760  if (a->type == TYPE_TEXT)
1761  return true;
1762  if (a->type == TYPE_MESSAGE)
1763  return true;
1764  if (a->type == TYPE_MULTIPART)
1765  {
1766  if (WithCrypto)
1767  {
1768  if ((mutt_str_strcasecmp(a->subtype, "signed") == 0) ||
1769  (mutt_str_strcasecmp(a->subtype, "encrypted") == 0))
1770  {
1771  return true;
1772  }
1773  }
1774 
1775  for (struct Body *b = a->parts; b; b = b->next)
1776  {
1777  if (mutt_can_decode(b))
1778  return true;
1779  }
1780  }
1781  else if ((WithCrypto != 0) && (a->type == TYPE_APPLICATION))
1782  {
1783  if (((WithCrypto & APPLICATION_PGP) != 0) && mutt_is_application_pgp(a))
1784  return true;
1786  return true;
1787  }
1788 
1789  return false;
1790 }
static bool is_autoview(struct Body *b)
Should email body be filtered by mailcap.
Definition: handler.c:484
struct Body * next
next attachment in the list
Definition: body.h:53
The body of an email.
Definition: body.h:34
char * subtype
content-type subtype
Definition: body.h:37
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:559
Type: &#39;text/*&#39;.
Definition: mime.h:38
bool mutt_can_decode(struct Body *a)
Will decoding the attachment produce any output.
Definition: handler.c:1756
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:618
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
Type: &#39;message/*&#39;.
Definition: mime.h:35
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
#define WithCrypto
Definition: ncrypt.h:160
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_decode_attachment()

void mutt_decode_attachment ( struct Body b,
struct State s 
)

Decode an email's attachment.

Parameters
bBody of the email
sState of text being processed

Definition at line 1797 of file handler.c.

1798 {
1799  int istext = mutt_is_text_part(b);
1800  iconv_t cd = (iconv_t)(-1);
1801 
1802  if (istext && s->flags & MUTT_CHARCONV)
1803  {
1804  char *charset = mutt_param_get(&b->parameter, "charset");
1805  if (!charset && C_AssumedCharset)
1806  charset = mutt_ch_get_default_charset();
1807  if (charset && C_Charset)
1809  }
1810  else if (istext && b->charset)
1812 
1813  fseeko(s->fp_in, b->offset, SEEK_SET);
1814  switch (b->encoding)
1815  {
1816  case ENC_QUOTED_PRINTABLE:
1817  decode_quoted(s, b->length,
1818  istext || (((WithCrypto & APPLICATION_PGP) != 0) &&
1820  cd);
1821  break;
1822  case ENC_BASE64:
1823  mutt_decode_base64(s, b->length,
1824  istext || (((WithCrypto & APPLICATION_PGP) != 0) &&
1826  cd);
1827  break;
1828  case ENC_UUENCODED:
1829  decode_uuencoded(s, b->length,
1830  istext || (((WithCrypto & APPLICATION_PGP) != 0) &&
1832  cd);
1833  break;
1834  default:
1835  decode_xbit(s, b->length,
1836  istext || (((WithCrypto & APPLICATION_PGP) != 0) &&
1838  cd);
1839  break;
1840  }
1841 
1842  if (cd != (iconv_t)(-1))
1843  iconv_close(cd);
1844 }
char * C_AssumedCharset
Config: If a message is missing a character set, assume this character set.
Definition: charset.c:53
static void decode_xbit(struct State *s, long len, bool istext, iconv_t cd)
Decode xbit-encoded text.
Definition: handler.c:171
static void decode_uuencoded(struct State *s, long len, bool istext, iconv_t cd)
Decode uuencoded text.
Definition: handler.c:372
#define MUTT_CHARCONV
Do character set conversions.
Definition: state.h:36
static void decode_quoted(struct State *s, long len, bool istext, iconv_t cd)
Decode an attachment encoded with quoted-printable.
Definition: handler.c:308
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
FILE * fp_in
File to read from.
Definition: state.h:46
void mutt_decode_base64(struct State *s, size_t len, bool istext, iconv_t cd)
Decode base64-encoded text.
Definition: handler.c:1487
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
unsigned int encoding
content-transfer-encoding
Definition: body.h:66
Base-64 encoded text.
Definition: mime.h:52
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:559
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, int flags)
Set up iconv for conversions.
Definition: charset.c:559
char * charset
Send mode: charset of attached file as stored on disk.
Definition: body.h:49
bool mutt_is_text_part(struct Body *b)
Is this part of an email in plain text?
Definition: muttlib.c:453
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
Quoted-printable text.
Definition: mime.h:51
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
char * mutt_ch_get_default_charset(void)
Get the default character set.
Definition: charset.c:434
char * C_Charset
Config: Default character set for displaying text on screen.
Definition: charset.c:54
#define MUTT_ICONV_HOOK_FROM
apply charset-hooks to fromcode
Definition: charset.h:81
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
#define WithCrypto
Definition: ncrypt.h:160
UUEncoded text.
Definition: mime.h:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_decode_base64()

void mutt_decode_base64 ( struct State s,
size_t  len,
bool  istext,
iconv_t  cd 
)

Decode base64-encoded text.

Parameters
sState to work with
lenLength of text to decode
istextMime part is plain text
cdIconv conversion descriptor

Definition at line 1487 of file handler.c.

1488 {
1489  char buf[5];
1490  int ch, i;
1491  char bufi[BUFI_SIZE];
1492  size_t l = 0;
1493 
1494  buf[4] = '\0';
1495 
1496  if (istext)
1497  state_set_prefix(s);
1498 
1499  while (len > 0)
1500  {
1501  for (i = 0; (i < 4) && (len > 0); len--)
1502  {
1503  ch = fgetc(s->fp_in);
1504  if (ch == EOF)
1505  break;
1506  if ((ch >= 0) && (ch < 128) && ((base64val(ch) != -1) || (ch == '=')))
1507  buf[i++] = ch;
1508  }
1509  if (i != 4)
1510  {
1511  /* "i" may be zero if there is trailing whitespace, which is not an error */
1512  if (i != 0)
1513  mutt_debug(LL_DEBUG2, "didn't get a multiple of 4 chars\n");
1514  break;
1515  }
1516 
1517  const int c1 = base64val(buf[0]);
1518  const int c2 = base64val(buf[1]);
1519  ch = (c1 << 2) | (c2 >> 4);
1520  bufi[l++] = ch;
1521 
1522  if (buf[2] == '=')
1523  break;
1524  const int c3 = base64val(buf[2]);
1525  ch = ((c2 & 0xf) << 4) | (c3 >> 2);
1526  bufi[l++] = ch;
1527 
1528  if (buf[3] == '=')
1529  break;
1530  const int c4 = base64val(buf[3]);
1531  ch = ((c3 & 0x3) << 6) | c4;
1532  bufi[l++] = ch;
1533 
1534  if ((l + 8) >= sizeof(bufi))
1535  convert_to_state(cd, bufi, &l, s);
1536  }
1537 
1538  convert_to_state(cd, bufi, &l, s);
1539  convert_to_state(cd, 0, 0, s);
1540 
1541  state_reset_prefix(s);
1542 }
#define state_reset_prefix(state)
Definition: state.h:54
FILE * fp_in
File to read from.
Definition: state.h:46
Log at debug level 2.
Definition: logging.h:57
#define BUFI_SIZE
Definition: handler.c:73
#define state_set_prefix(state)
Definition: state.h:53
#define base64val(ch)
Definition: base64.h:30
static void convert_to_state(iconv_t cd, char *bufi, size_t *l, struct State *s)
Convert text and write it to a file.
Definition: handler.c:122
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_HonorDisposition

bool C_HonorDisposition

Config: Don't display MIME parts inline if they have a disposition of 'attachment'.

Definition at line 65 of file handler.c.

◆ C_ImplicitAutoview

bool C_ImplicitAutoview

Config: Display MIME attachments inline if a 'copiousoutput' mailcap entry exists.

Definition at line 66 of file handler.c.

◆ C_IncludeEncrypted

bool C_IncludeEncrypted

Config: Whether to include encrypted content when replying.

Definition at line 67 of file handler.c.

◆ C_IncludeOnlyfirst

bool C_IncludeOnlyfirst

Config: Only include the first attachment when replying.

Definition at line 68 of file handler.c.

◆ C_PreferredLanguages

struct Slist* C_PreferredLanguages

Config: Preferred languages for multilingual MIME.

Definition at line 69 of file handler.c.

◆ C_ReflowText

bool C_ReflowText

Config: Reformat paragraphs of 'format=flowed' text.

Definition at line 70 of file handler.c.

◆ C_ShowMultipartAlternative

char* C_ShowMultipartAlternative

Config: How to display 'multipart/alternative' MIME parts.

Definition at line 71 of file handler.c.