/*
* cum_attachs_size: Cumulative Attachments Size
*
- *
* Returns the total number of bytes used by the attachments in the
- * attachment list.
+ * attachment list _after_ content-transfer-encodings have been
+ * applied.
+ *
*/
static unsigned long cum_attachs_size (MUTTMENU *menu)
unsigned short i;
ATTACHPTR **idx = menu->data;
CONTENT *info;
+ BODY *b;
for (i = 0, s = 0; i < menu->max; i++)
{
- if ((info = idx[i]->content->content))
+ b = idx[i]->content;
+
+ if (!b->content)
+ b->content = mutt_get_content_info (b->filename, b);
+
+ if ((info = b->content))
{
- switch (idx[i]->content->encoding)
+ switch (b->encoding)
{
case ENCQUOTEDPRINTABLE:
- s += 3 * (info->lobin + info->hibin) + info->ascii;
+ s += 3 * (info->lobin + info->hibin) + info->ascii + info->crlf;
break;
case ENCBASE64:
- s += (4 * (info->lobin + info->hibin + info->ascii)) / 3;
+ s += (4 * (info->lobin + info->hibin + info->ascii + info->crlf)) / 3;
break;
default:
- s += info->lobin + info->hibin + info->ascii;
+ s += info->lobin + info->hibin + info->ascii + info->crlf;
break;
}
}
{
long hibin; /* 8-bit characters */
long lobin; /* unprintable 7-bit chars (eg., control chars) */
+ long crlf; /* '\r' and '\n' characters */
long ascii; /* number of ascii chars */
long linemax; /* length of the longest line in the file */
unsigned int space : 1; /* whitespace at the end of lines? */
BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
BODY *mutt_read_mime_header (FILE *, int);
+CONTENT *mutt_get_content_info (const char *fname, BODY *b);
+
LIST *mutt_make_references(ENVELOPE *e);
ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
}
/* analyze the contents of a file to determine which MIME encoding to use */
-static CONTENT *mutt_get_content_info (const char *fname, BODY *b)
+CONTENT *mutt_get_content_info (const char *fname, BODY *b)
{
CONTENT *info;
FILE *fp;
linelen++;
if (ch == '\n')
{
+ info->crlf++;
if (whitespace) info->space = 1;
if (dot) info->dot = 1;
if (linelen > info->linemax) info->linemax = linelen;
}
else if (ch == '\r')
{
+ info->crlf++;
info->cr = 1;
if ((ch = fgetc (fp)) == EOF)
{
safe_free ((void **) &a->content);
a->content = info;
- info = NULL;
- safe_free ((void **) &info);
}
BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
if (att->type == TYPETEXT)
mutt_set_body_charset(att, get_text_charset(att, info));
-
-#ifdef HAVE_PGP
- /*
- * save the info in case this message is signed. we will want to do Q-P
- * encoding if any lines begin with "From " so the signature won't be munged,
- * for example.
- */
- att->content = info;
- info = NULL;
-#endif
- safe_free ((void **) &info);
+ att->content = info;
return (att);
}