105 state_printf(state,
_(
"[-- Type: %s/%s%s%s, Encoding: %s, Size: %s --]\n"),
111 state_printf(state,
_(
"[-- Alternative Type #%d: %s/%s%s%s, Encoding: %s, Size: %s --]\n"),
113 charset ?
"; charset=" :
"", charset ? charset :
"",
129 const char *ib = NULL;
139 iconv(cd, NULL, NULL, &ob, &obl);
164 memmove(bufi, ib, ibl);
188 while (((c = fgetc(state->
fp_in)) != EOF) && len--)
190 if ((c ==
'\r') && len)
192 const int ch = fgetc(state->
fp_in);
200 ungetc(ch, state->
fp_in);
205 if (l ==
sizeof(bufi))
225 if ((s[0] ==
'=') && (s[1] ==
'\0'))
248 char *d = NULL, *s = NULL;
256 for (d = dest, s = src; *s;)
274 if (!soft && (last ==
'\n'))
279 if ((kind == 0) && (c ==
'\r'))
316 char line[256] = { 0 };
317 char decline[512] = { 0 };
331 if (!fgets(line,
MIN((ssize_t)
sizeof(line), len + 1), state->
fp_in))
334 size_t linelen = strlen(line);
339 const int last = (linelen != 0) ? line[linelen - 1] : 0;
344 while ((linelen > 0) &&
mutt_isspace(line[linelen - 1]))
346 line[linelen] =
'\0';
366 if ((ch < 32) || (ch > 95))
380 char tmps[128] = { 0 };
390 if (!fgets(tmps,
sizeof(tmps), state->
fp_in))
398 if (!fgets(tmps,
sizeof(tmps), state->
fp_in))
406 for (
unsigned char c = 0; (c < linelen) && *pt;)
408 for (
char l = 2; (l <= 6) && pt[0] && pt[1]; l += 2)
447 char tmp[1024] = { 0 };
456 while ((p = strtok(p,
",")))
475 if ((plen != 0) && (buf[plen] ==
'/'))
493 char type[256] = { 0 };
502 if (c_implicit_auto_view)
516 if (((i > 0) && (np->
data[i - 1] ==
'/') && (np->
data[i] ==
'*') &&
544 char buf[1024] = { 0 };
545 char type[256] = { 0 };
555 snprintf(type,
sizeof(type),
"%s/%s",
BODY_TYPE(b_email), b_email->
subtype);
620 while (fgets(buf,
sizeof(buf), fp_out))
629 if (fgets(buf,
sizeof(buf), fp_err))
639 while (fgets(buf,
sizeof(buf), fp_err))
650 if (fgets(buf,
sizeof(buf), fp_err))
705 while ((len > 0) && (buf[len - 1] ==
' '))
723 struct Body *b = NULL;
727 off_start = ftello(state->
fp_in);
758 chflags, state->
prefix, 0);
787 state_puts(state,
_(
"[-- Error: message/external-body has no access-type parameter --]\n"));
796 const char *fmt = NULL;
815 const long size = strtol(length, NULL, 10);
835 "[-- This %s/%s attachment (size %s byte) has been deleted --]\n"
837 "[-- This %s/%s attachment (size %s bytes) has been deleted --]\n"
858 "[-- This %s/%s attachment (size %s byte) has been deleted --]\n",
859 "[-- This %s/%s attachment (size %s bytes) has been deleted --]\n", size);
873 fmt =
_(
"[-- This %s/%s attachment has been deleted --]\n[-- on %4$s --]\n");
880 fmt =
_(
"[-- This %s/%s attachment has been deleted --]\n");
909 buf_printf(banner,
_(
"[-- This %s/%s attachment is not included, --]\n[-- and the indicated external source has expired --]\n"),
930 buf_printf(banner,
_(
"[-- This %s/%s attachment is not included, --]\n[-- and the indicated access-type %s is unsupported --]\n"),
952 struct Body *
const head = b_email;
953 struct Body *choice = NULL;
954 struct Body *b = NULL;
955 bool mustfree =
false;
986 char *c = strchr(np->
data,
'/');
989 wild = ((c[1] ==
'*') && (c[2] ==
'\0'));
990 btlen = c - np->
data;
1127 state_puts(state,
_(
"[-- Error: Could not display any parts of Multipart/Alternative --]\n"));
1143 struct Body *b = NULL;
1144 bool mustfree =
false;
1171 struct Body *choice = NULL;
1172 struct Body *first_part = NULL;
1173 struct Body *zxx_part = NULL;
1187 if (c_preferred_languages)
1204 mutt_debug(
LL_DEBUG2,
"RFC8255 >> comparing configuration preferred_language='%s' to mail part content-language='%s'\n",
1208 mutt_debug(
LL_DEBUG2,
"RFC8255 >> preferred_language='%s' matches content-language='%s' >> part selected to be displayed\n",
1236 else if (first_part)
1251 struct Body *b = NULL, *p = NULL;
1273 for (p = b->
parts, count = 1; p; p = p->
next, count++)
1278 if (p->description || p->filename || p->form_name)
1281 state_printf(state,
_(
"[-- Attachment #%d: %s --]\n"), count,
1282 p->description ? p->description :
1283 p->filename ? p->filename :
1306 mutt_error(
_(
"One or more parts of this message could not be displayed"));
1341 const char *save_prefix = NULL;
1343 size_t tmplength = 0;
1344 LOFF_T tmpoffset = 0;
1348 struct Buffer *tempfile = NULL;
1358 size_t tempsize = 0;
1366 const int orig_type = b->
type;
1376 state->
fp_out = open_memstream(&temp, &tempsize);
1402 save_prefix = state->
prefix;
1428 state->
fp_in = fmemopen(temp, tempsize,
"r");
1439 state->
prefix = save_prefix;
1452 state->
prefix = save_prefix;
1459 state->
prefix = save_prefix;
1462 b->
type = orig_type;
1468 rc = handler(b, state);
1562 char buf[5] = { 0 };
1575 for (i = 0; (i < 4) && (len > 0); len--)
1577 ch = fgetc(state->
fp_in);
1580 if ((ch >= 0) && (ch < 128) && ((
base64val(ch) != -1) || (ch ==
'=')))
1595 ch = (c1 << 2) | (c2 >> 4);
1597 if (cr && (ch !=
'\n'))
1602 if (istext && (ch ==
'\r'))
1611 ch = ((c2 & 0xf) << 4) | (c3 >> 2);
1613 if (cr && (ch !=
'\n'))
1618 if (istext && (ch ==
'\r'))
1627 ch = ((c3 & 0x3) << 6) | c4;
1629 if (cr && (ch !=
'\n'))
1634 if (istext && (ch ==
'\r'))
1639 if ((l + 8) >=
sizeof(bufi))
1664 bool plaintext =
false;
1668 static unsigned short recurse_level = 0;
1670 const int oflags = state->
flags;
1697 handler = encrypted_handler;
1699 else if (c_reflow_text &&
1735 else if (!
mutt_str_equal(
"inline", c_show_multipart_alternative) &&
1743 mutt_error(
_(
"Error: multipart/signed has no protocol"));
1750 handler = encrypted_handler;
1755 handler = encrypted_handler;
1778 handler = encrypted_handler;
1783 handler = encrypted_handler;
1795 encrypted_handler && !c_include_encrypted)
1809 if (is_attachment_display)
1813 buf_strcpy(msg,
_(
"[-- This is an attachment --]\n"));
1829 buf_printf(msg,
_(
"[-- This is an attachment (use '%s' to view this part) --]\n"),
1836 buf_printf(msg,
_(
"[-- %s/%s is unsupported (use '%s' to view this part) --]\n"),
1844 buf_strcpy(msg,
_(
"[-- This is an attachment (need 'view-attachments' bound to key) --]\n"));
1849 buf_printf(msg,
_(
"[-- %s/%s is unsupported (need 'view-attachments' bound to key) --]\n"),
1945 const char *charset = b->
charset;
GUI display the mailboxes in a side panel.
#define base64val(ch)
Convert base64 character to its numeric value.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
const struct Slist * cs_subset_slist(const struct ConfigSubset *sub, const char *name)
Get a string-list config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
const char * cc_charset(void)
Get the cached value of $charset.
const struct Slist * cc_assumed_charset(void)
Get the cached value of $assumed_charset.
int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end, CopyHeaderFlags chflags, const char *prefix, int wraplen)
Copy header from one file to another.
Duplicate the structure of an entire email.
#define CH_DECODE
Do RFC2047 header decoding.
#define CH_PREFIX
Quote header using $indent_string string?
#define CH_FROM
Retain the "From " message separator?
#define CH_WEED
Weed the headers?
#define CH_REORDER
Re-order output of headers (specified by 'header-order')
#define CH_DISPLAY
Display result to user.
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Convenience wrapper for the core headers.
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
SecurityFlags mutt_is_application_pgp(const struct Body *b)
Does the message use PGP?
bool mutt_isspace(int arg)
Wrapper for isspace(3)
bool mutt_isxdigit(int arg)
Wrapper for isxdigit(3)
void buf_strip_formatting(struct Buffer *dest, const char *src, bool strip_markers)
Removes ANSI and backspace formatting.
void mutt_body_free(struct Body **ptr)
Free a Body.
struct Body * mutt_body_new(void)
Create a new Body.
Representation of the body of an email.
Email private Module data.
struct Body * mutt_rfc822_parse_message(FILE *fp, struct Body *b)
Parse a Message/RFC822 body.
struct Body * mutt_parse_multipart(FILE *fp, const char *boundary, LOFF_T end_off, bool digest)
Parse a multipart structure.
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Miscellaneous email parsing routines.
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Representation of an email header (envelope)
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
int mutt_file_copy_bytes(FILE *fp_in, FILE *fp_out, size_t size)
Copy some content from one file to another.
long mutt_file_get_size_fp(FILE *fp)
Get the size of a file.
void mutt_file_sanitize_filename(char *path, bool slash)
Replace unsafe characters in a filename.
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
#define MUTT_RL_NO_FLAGS
No flags are set.
bool OptDontHandlePgpKeys
(pseudo) used to extract PGP keys
int crypt_pgp_application_handler(struct Body *b_email, struct State *state)
Wrapper for CryptModuleSpecs::application_handler() - Implements handler_t -.
static int alternative_handler(struct Body *b_email, struct State *state)
Handler for multipart alternative emails - Implements handler_t -.
int text_enriched_handler(struct Body *b_email, struct State *state)
Handler for enriched text - Implements handler_t -.
static int text_plain_handler(struct Body *b_email, struct State *state)
Handler for plain text - Implements handler_t -.
int crypt_smime_application_handler(struct Body *b_email, struct State *state)
Wrapper for CryptModuleSpecs::application_handler() - Implements handler_t -.
static int autoview_handler(struct Body *b_email, struct State *state)
Handler for autoviewable attachments - Implements handler_t -.
int crypt_pgp_encrypted_handler(struct Body *b_email, struct State *state)
Wrapper for CryptModuleSpecs::encrypted_handler() - Implements handler_t -.
static int external_body_handler(struct Body *b_email, struct State *state)
Handler for external-body emails - Implements handler_t -.
int rfc3676_handler(struct Body *b_email, struct State *state)
Handler for format=flowed - Implements handler_t -.
static int malformed_pgp_encrypted_handler(struct Body *b_email, struct State *state)
Handler for invalid pgp-encrypted emails - Implements handler_t -.
static int valid_pgp_encrypted_handler(struct Body *b_email, struct State *state)
Handler for valid pgp-encrypted emails - Implements handler_t -.
static int message_handler(struct Body *b_email, struct State *state)
Handler for message/rfc822 body parts - Implements handler_t -.
static int multipart_handler(struct Body *b_email, struct State *state)
Handler for multipart emails - Implements handler_t -.
static int multilingual_handler(struct Body *b_email, struct State *state)
Handler for multi-lingual emails - Implements handler_t -.
int mutt_signed_handler(struct Body *b_email, struct State *state)
Handler for "multipart/signed" - Implements handler_t -.
#define mutt_message(...)
#define mutt_debug(LEVEL,...)
Convenience wrapper for the gui headers.
static bool is_autoview(struct Body *b)
Should email body be filtered by mailcap.
bool mutt_prefer_as_attachment(struct Body *b)
Do we want this part as an attachment?
#define BUFI_SIZE
Input buffer size for handler operations.
static void decode_uuencoded(struct State *state, long len, bool istext, iconv_t cd)
Decode uuencoded text.
static void convert_to_state(iconv_t cd, char *bufi, size_t *l, struct State *state)
Convert text and write it to a file.
bool mutt_can_decode(struct Body *b)
Will decoding the attachment produce any output.
int mutt_body_handler(struct Body *b, struct State *state)
Handler for the Body of an email.
int(* handler_t)(struct Body *b_email, struct State *state)
void mutt_decode_base64(struct State *state, size_t len, bool istext, iconv_t cd)
Decode base64-encoded text.
static void print_part_line(struct State *state, struct Body *b_email, int n)
Print a separator for the Mime part.
#define TXT_PLAIN
Plain text format.
static int run_decode_and_handler(struct Body *b, struct State *state, handler_t handler, bool plaintext)
Run an appropriate decoder for an email.
#define TXT_HTML
HTML text format.
#define TXT_ENRICHED
Enriched text format.
#define BUFO_SIZE
Output buffer size for handler operations.
static unsigned char decode_byte(char ch)
Decode a uuencoded byte.
void mutt_decode_attachment(const struct Body *b, struct State *state)
Decode an email's attachment.
static void qp_decode_line(char *dest, char *src, size_t *l, int last)
Decode a line of quoted-printable text.
static void decode_quoted(struct State *state, long len, bool istext, iconv_t cd)
Decode an attachment encoded with quoted-printable.
static void decode_xbit(struct State *state, long len, bool istext, iconv_t cd)
Decode xbit-encoded text.
static bool is_mmnoask(const char *buf)
Metamail compatibility: should the attachment be autoviewed?
static int qp_decode_triple(char *s, char *d)
Decode a quoted-printable triplet.
Decide how to display email content.
bool keymap_expand_key(struct Keymap *km, struct Buffer *buf)
Get the key string bound to a Keymap.
@ LL_DEBUG2
Log at debug level 2.
@ LL_DEBUG1
Log at debug level 1.
void mailcap_entry_free(struct MailcapEntry **ptr)
Deallocate an struct MailcapEntry.
struct MailcapEntry * mailcap_entry_new(void)
Allocate memory for a new rfc1524 entry.
int mailcap_expand_command(struct Body *b, const char *filename, const char *type, struct Buffer *command)
Expand expandos in a command.
void mailcap_expand_filename(const char *nametemplate, const char *oldfile, struct Buffer *newfile)
Expand a new filename from a template or existing filename.
bool mailcap_lookup(struct Body *b, char *type, size_t typelen, struct MailcapEntry *entry, enum MailcapLookup opt)
Find given type in the list of mailcap files.
RFC1524 Mailcap routines.
@ MUTT_MC_AUTOVIEW
Mailcap autoview field.
#define FREE(x)
Free memory and set the pointer to NULL.
#define MIN(a, b)
Return the minimum of two values.
Constants and macros for managing MIME encoding.
@ ENC_UUENCODED
UUEncoded text.
@ ENC_BASE64
Base-64 encoded text.
@ ENC_QUOTED_PRINTABLE
Quoted-printable text.
#define MUTT_MIME_MAX_DEPTH
Maximum nesting depth for MIME parts to prevent stack overflow.
@ TYPE_MESSAGE
Type: 'message/*'.
@ TYPE_MULTIPART
Type: 'multipart/*'.
@ TYPE_APPLICATION
Type: 'application/*'.
@ TYPE_TEXT
Type: 'text/*'.
#define BODY_TYPE(body)
Get the type name of a body part.
@ DISP_ATTACH
Content is attached.
@ DISP_INLINE
Content is inline.
#define ENCODING(x)
Get the encoding name for an encoding type.
#define hexval(ch)
Convert hexadecimal character to its integer value.
@ MODULE_ID_EMAIL
ModuleEmail, Email code
size_t mutt_ch_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, const char **inrepls, const char *outrepl, int *iconverrno)
Change the encoding of a string.
iconv_t mutt_ch_iconv_open(const char *tocode, const char *fromcode, uint8_t flags)
Set up iconv for conversions.
const char * mutt_ch_get_default_charset(const struct Slist *const assumed_charset)
Get the default character set.
#define MUTT_ICONV_HOOK_FROM
apply charset-hooks to fromcode
#define ICONV_T_INVALID
Error value for iconv functions.
static bool iconv_t_valid(const iconv_t cd)
Is the conversion descriptor valid?
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr, char **envlist)
Run a command on a pipe (optionally connect stdin/stdout)
pid_t filter_create(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, char **envlist)
Set up filter program.
Convenience wrapper for the library headers.
bool slist_is_empty(const struct Slist *list)
Is the slist empty?
void state_attach_puts(struct State *state, const char *t)
Write a string to the state.
void state_mark_attach(struct State *state)
Write a unique marker around content.
int state_printf(struct State *state, const char *fmt,...)
Write a formatted string to the State.
void state_prefix_put(struct State *state, const char *buf, size_t buflen)
Write a prefixed fixed-string to the State.
#define STATE_WEED
Weed headers even when not in display mode.
#define state_puts(STATE, STR)
#define state_set_prefix(state)
#define STATE_DISPLAY
Output is displayed to the user.
#define STATE_DISPLAY_ATTACH
We are displaying an attachment.
#define STATE_FIRSTDONE
The first attachment has been done.
#define state_reset_prefix(state)
#define state_putc(STATE, STR)
#define STATE_REPLYING
Are we replying?
#define STATE_VERIFY
Perform signature verification.
#define STATE_CHARCONV
Do character set conversions.
#define STATE_PRINTING
Are we printing? - STATE_DISPLAY "light".
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
const char * mutt_str_getenv(const char *name)
Get an environment variable.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
Many unsorted constants and some structs.
void mutt_check_lookup_list(struct Body *b, char *type, size_t len)
Update the mime type.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
int mutt_str_pretty_size(struct Buffer *buf, size_t num)
Display an abbreviated size, like 3.4K.
bool mutt_is_text_part(const struct Body *b)
Is this part of an email in plain text?
Some miscellaneous functions.
API for encryption/signing of emails.
#define APPLICATION_PGP
Use PGP to encrypt/sign.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Store attributes associated with a MIME part.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define STAILQ_FOREACH(var, head, field)
RFC3676 Format Flowed routines.
char * language
content-language (RFC8255)
struct Body * parts
parts of a multipart or message/rfc822
LOFF_T offset
offset where the actual data begins
struct Envelope * mime_headers
Memory hole protected headers.
bool is_autocrypt
Flag autocrypt-decrypted messages for replying.
LOFF_T length
length (in bytes) of attachment
char * charset
Send mode: charset of attached file as stored on disk.
struct ParameterList parameter
Parameters of the content-type.
unsigned int disposition
content-disposition, ContentDisposition
bool nowrap
Do not wrap the output in the pager.
struct Body * next
next attachment in the list
char * subtype
content-type subtype
unsigned int encoding
content-transfer-encoding, ContentEncoding
bool goodsig
Good cryptographic signature.
long hdr_offset
Offset in stream where the headers begin.
unsigned int type
content-type primary type, ContentType
char * filename
When sending a message, this is the file to which this structure refers.
String manipulation buffer.
Email private Module data.
struct ListHead auto_view
List of mime types to auto view.
struct ListHead alternative_order
List of preferred mime types to display.
char * nametemplate
Filename template.
char * command
Command to run.
Container for Accounts, Notifications.
char ** env
Private copy of the environment variables.
struct ConfigSubset * sub
Inherited config items.
struct ListHead head
List containing values.
Keep track when processing files.
StateFlags flags
Flags, e.g. STATE_DISPLAY.
FILE * fp_out
File to write to.
FILE * fp_in
File to read from.
const char * prefix
String to add to the beginning of each output line.
int cs_subset_str_string_get(const struct ConfigSubset *sub, const char *name, struct Buffer *result)
Get a config item as a string.