74 char type[256] = { 0 };
81 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(b), b->
subtype);
87 FILE *fp_in = NULL, *fp_out = NULL;
95 struct stat st = { 0 };
96 if ((fstat(fileno(fp_in), &st) == 0) && (b->
stamp >= st.st_mtime))
111 return b->
unlink ? 0 : -1;
122 char type[256] = { 0 };
124 bool unlink_newfile =
false;
130 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(b), b->
subtype);
151 unlink_newfile =
true;
157 mutt_error(
_(
"Mailcap compose entry requires %%s"));
173 mutt_perror(
_(
"Failure to open file to parse headers"));
212 mutt_perror(
_(
"Failure to open file to strip headers"));
267 char type[256] = { 0 };
269 bool unlink_newfile =
false;
274 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(b), b->
subtype);
291 unlink_newfile =
true;
319 mutt_error(
_(
"No mailcap edit entry for %s"), type);
349 if (((i > 0) && (np->
data[i - 1] ==
'/') && (np->
data[i] ==
'*') &&
353 struct Body tmp = { 0 };
358 snprintf(
type, len,
"%s/%s",
396 rc = WIFEXITED(rc) ? WEXITSTATUS(rc) : -1;
422 bool use_mailcap =
false;
423 bool use_pipe =
false;
424 bool use_pager =
true;
425 char type[256] = { 0 };
426 char desc[512] = { 0 };
430 bool has_tempfile =
false;
431 bool unlink_pagerfile =
false;
447 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(b), b->
subtype);
449 char columns[16] = { 0 };
450 snprintf(columns,
sizeof(columns),
"%d", win->
state.
cols);
463 mutt_error(
_(
"No matching mailcap entry found. Viewing as text."));
478 mutt_error(
_(
"MIME type not defined. Can't view attachment."));
499 struct Body *related_ancestor = NULL;
504 if (related_ancestor)
523 if (fp && !use_mailcap && b->
filename)
538 int fd_temp = -1, fd_pager = -1;
544 if (use_pager || use_pipe)
548 O_CREAT | O_EXCL | O_WRONLY, 0600)) == -1))
553 unlink_pagerfile =
true;
555 if (use_pipe && ((fd_temp = open(
buf_string(tmpfile), 0)) == -1))
562 unlink_pagerfile =
true;
565 use_pager ? fd_pager : -1, -1,
EnvList);
583 snprintf(desc,
sizeof(desc),
_(
"---Command: %-20.20s Description: %s"),
588 snprintf(desc,
sizeof(desc),
_(
"---Command: %-30.30s Attachment: %s"),
628 struct State state = { 0 };
634 buf_string(pagerfile), errno, strerror(errno));
650 unlink_pagerfile =
true;
666 unlink_pagerfile =
true;
672 snprintf(desc,
sizeof(desc),
_(
"---Attachment: %s: %s"), b->
filename, type);
674 snprintf(desc,
sizeof(desc),
_(
"---Attachment: %s"), type);
699 unlink_pagerfile =
false;
719 if (unlink_pagerfile)
742 int out = -1, rc = 0;
743 bool is_flowed =
false;
744 bool unlink_unstuff =
false;
745 FILE *fp_filter = NULL, *fp_unstuff = NULL, *fp_in = NULL;
746 struct Buffer *unstuff_tempfile = NULL;
748 if (outfile && *outfile)
767 if (outfile && *outfile)
780 struct State state = { 0 };
793 unlink_unstuff =
true;
796 state.
fp_out = fp_unstuff;
821 const char *infile = NULL;
830 unlink_unstuff =
true;
854 if (outfile && *outfile)
876 if ((rc == 0) || c_wait_key)
922 char buf[8192] = { 0 };
933 if (!fgets(buf,
sizeof(buf), fp))
969 struct State state = { 0 };
1044 struct State state = { 0 };
1045 unsigned int saved_encoding = 0;
1046 struct Body *saved_parts = NULL;
1047 struct Email *e_saved = NULL;
1050 state.
flags = flags;
1082 struct stat st = { 0 };
1083 if (fstat(fileno(state.
fp_in), &st) == -1)
1097 saved_parts = b->
parts;
1119 b->
parts = saved_parts;
1143 char type[256] = { 0 };
1145 FILE *fp_in = NULL, *fp_out = NULL;
1146 bool unlink_newfile =
false;
1152 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(b), b->
subtype);
1166 FREE(&sanitized_fname);
1170 goto mailcap_cleanup;
1191 goto mailcap_cleanup;
1200 goto mailcap_cleanup;
1214 if ((rc2 != 0) || c_wait_key)
1245 unlink_newfile =
true;
1253 goto decode_cleanup;
1263 goto decode_cleanup;
struct Body * attach_body_ancestor(struct Body *start, struct Body *body, const char *subtype)
Find the ancestor of a body with specified subtype.
Handling of email attachments.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
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".
void cid_save_attachments(struct Body *body, struct CidMapList *cid_map_list)
Save all attachments in a "multipart/related" group with a Content-ID.
void cid_to_filename(struct Buffer *filename, const struct CidMapList *cid_map_list)
Replace Content-IDs with filenames.
void cid_map_list_clear(struct CidMapList *cid_map_list)
Empty a CidMapList.
Attachment Content-ID header functions.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string 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.
int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Make a copy of a message from a FILE pointer.
Duplicate the structure of an entire email.
#define CH_UPDATE
Update the status and x-status fields?
#define CH_NOSTATUS
Suppress the status and x-status fields.
#define CH_FROM
Retain the "From " message separator?
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
#define MUTT_CM_NO_FLAGS
No flags are set.
#define CH_NO_FLAGS
No flags are set.
Convenience wrapper for the core headers.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
@ MUTT_MMDF
'mmdf' Mailbox type
@ MUTT_MBOX
'mbox' Mailbox type
@ MUTT_MAILDIR
'Maildir' Mailbox type
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
void mutt_edit_file(const char *editor, const char *file)
Let the user edit a file.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void mutt_endwin(void)
Shutdown curses.
void mutt_body_free(struct Body **ptr)
Free a Body.
void email_free(struct Email **ptr)
Free an Email.
Structs that make up an email.
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
struct Body * mutt_read_mime_header(FILE *fp, bool digest)
Parse a MIME header.
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
bool envlist_set(char ***envp, const char *name, const char *value, bool overwrite)
Set an environment variable.
bool envlist_unset(char ***envp, const char *name)
Unset an environment variable.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
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.
int mutt_file_rename(const char *oldfile, const char *newfile)
Rename a file.
int mutt_file_symlink(const char *oldpath, const char *newpath)
Create a symlink.
int mutt_file_chmod_add(const char *path, mode_t mode)
Add permissions to a file.
int mutt_file_open(const char *path, uint32_t flags, mode_t mode)
Open a file.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
int mutt_file_fsync_close(FILE **fp)
Flush the data, before closing a file (and NULL the pointer)
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
bool is_from(const char *s, char *path, size_t pathlen, time_t *tp)
Is a string a 'From' header line?
struct ListHead TempAttachmentsList
List of temporary files for displaying attachments.
struct ListHead MimeLookupList
List of mime types that that shouldn't use the mailcap entry.
char ** EnvList
Private copy of the environment variables.
#define mutt_message(...)
#define mutt_debug(LEVEL,...)
Convenience wrapper for the gui headers.
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.
void mutt_decode_attachment(const struct Body *b, struct State *state)
Decode an email's attachment.
Decide how to display email content.
int imap_wait_keep_alive(pid_t pid)
Wait for a process to change state.
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
@ 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.
MailcapLookup
Mailcap actions.
@ MUTT_MC_PRINT
Mailcap print field.
@ MUTT_MC_EDIT
Mailcap edit field.
@ MUTT_MC_AUTOVIEW
Mailcap autoview field.
@ MUTT_MC_NO_FLAGS
No flags set.
@ MUTT_MC_COMPOSE
Mailcap compose field.
@ ENC_BASE64
Base-64 encoded text.
@ ENC_QUOTED_PRINTABLE
Quoted-printable text.
@ TYPE_AUDIO
Type: 'audio/*'.
@ TYPE_IMAGE
Type: 'image/*'.
@ TYPE_OTHER
Unknown Content-Type.
@ TYPE_MESSAGE
Type: 'message/*'.
@ TYPE_MODEL
Type: 'model/*'.
@ TYPE_MULTIPART
Type: 'multipart/*'.
@ TYPE_APPLICATION
Type: 'application/*'.
@ TYPE_TEXT
Type: 'text/*'.
@ TYPE_VIDEO
Type: 'video/*'.
#define is_multipart(body)
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.
#define STATE_PAGER
Output will be displayed in the Pager.
#define STATE_DISPLAY
Output is displayed to the user.
#define STATE_DISPLAY_ATTACH
We are displaying an attachment.
#define STATE_CHARCONV
Do character set conversions.
uint16_t StateFlags
Flags for State->flags, e.g. STATE_DISPLAY.
#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.
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)
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.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
bool mutt_edit_attachment(struct Body *b)
Edit an attachment.
void mutt_check_lookup_list(struct Body *b, char *type, size_t len)
Update the mime type.
int mutt_get_tmp_attachment(struct Body *b)
Get a temporary copy of an attachment.
int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, const char *outfile)
Pipe an attachment to a command.
int mutt_compose_attachment(struct Body *b)
Create an attachment.
void mutt_temp_attachments_cleanup(void)
Delete all temporary attachments.
static int wait_interactive_filter(pid_t pid)
Wait after an interactive filter.
int mutt_save_attachment(FILE *fp, struct Body *b, const char *path, enum SaveAttach opt, struct Email *e)
Save an attachment.
int mutt_decode_save_attachment(FILE *fp, struct Body *b, const char *path, StateFlags flags, enum SaveAttach opt)
Decode, then save an attachment.
int mutt_view_attachment(FILE *fp, struct Body *b, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx, struct MuttWindow *win)
View an attachment.
int mutt_print_attachment(FILE *fp, struct Body *b)
Print out an attachment.
void mutt_add_temp_attachment(const char *filename)
Add file to list of temporary attachments.
static FILE * save_attachment_open(const char *path, enum SaveAttach opt)
Open a file to write an attachment to.
Handling of email attachments.
SaveAttach
Options for saving attachments.
@ MUTT_SAVE_APPEND
Append to existing file.
@ MUTT_SAVE_OVERWRITE
Overwrite existing file.
@ MUTT_SAVE_NO_FLAGS
No flags set.
ViewAttachMode
Options for mutt_view_attachment()
@ MUTT_VA_MAILCAP
Force viewing using mailcap entry.
@ MUTT_VA_REGULAR
View using default method.
@ MUTT_VA_PAGER
View attachment in pager using copiousoutput mailcap.
@ MUTT_VA_AS_TEXT
Force viewing as text.
bool mutt_needs_mailcap(struct Body *b)
Does this type need a mailcap entry do display.
void mutt_adv_mktemp(struct Buffer *buf)
Create a temporary file.
Some miscellaneous functions.
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
#define MUTT_ADD_FROM
add a From_ line
#define MUTT_MSG_NO_FLAGS
No flags are set.
#define MUTT_APPEND
Open mailbox for appending messages.
#define MUTT_QUIET
Do not print any messages.
API for encryption/signing of emails.
#define SEC_ENCRYPT
Email is encrypted.
#define mutt_file_fopen_masked(PATH, MODE)
void mutt_param_free(struct ParameterList *pl)
Free a ParameterList.
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.
Prototypes for many functions.
int mutt_system(const char *cmd)
Run an external command.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
#define STAILQ_HEAD_INITIALIZER(head)
#define STAILQ_FOREACH(var, head, field)
#define TAILQ_EMPTY(head)
void mutt_rfc3676_space_stuff_attachment(struct Body *b, const char *filename)
Stuff attachments.
void mutt_rfc3676_space_unstuff_attachment(struct Body *b, const char *filename)
Unstuff attachments.
bool mutt_rfc3676_is_format_flowed(struct Body *b)
Is the Email "format-flowed"?
RFC3676 Format Flowed routines.
Convenience wrapper for the send headers.
enum ContentType mutt_lookup_mime_type(struct Body *b, const char *path)
Find the MIME type for an attachment.
void mutt_stamp_attachment(struct Body *b)
Timestamp an Attachment.
void mutt_sig_unblock_system(bool restore)
Restore previously blocked signals.
struct Body ** body_idx
Extra struct Body* used for decryption.
struct Body * parts
parts of a multipart or message/rfc822
LOFF_T offset
offset where the actual data begins
char * xtype
content-type if x-unknown
bool noconv
Don't do character set conversion.
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
time_t stamp
Time stamp of last encoding update.
LOFF_T length
length (in bytes) of attachment
struct ParameterList parameter
Parameters of the content-type.
struct Email * email
header information for message/rfc822
char * description
content-description
char * subtype
content-type subtype
unsigned int encoding
content-transfer-encoding, ContentEncoding
char * form_name
Content-Disposition form-data name param.
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.
char * data
Pointer to data.
The envelope/body of an email.
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
struct Body * body
List of MIME parts.
int msgno
Number displayed to the user.
char * path
Path of Email (for local Mailboxes)
enum MailboxType type
Mailbox type.
bool needsterminal
endwin() and system
char * composetypecommand
bool copiousoutput
needs pager, basically
bool xneomuttkeep
do not remove the file on command exit
bool xneomuttnowrap
do not wrap the output in the pager
A local copy of an email.
FILE * fp
pointer to the message data
struct WindowState state
Current state of the Window.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
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.
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.