78 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
84 FILE *fp_in = NULL, *fp_out = NULL;
85 if ((fp_in = fopen(a->
filename,
"r")) &&
92 struct stat st = { 0 };
93 if ((fstat(fileno(fp_in), &st) == 0) && (a->
stamp >= st.st_mtime))
106 return a->
unlink ? 0 : -1;
119 bool unlink_newfile =
false;
125 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
145 unlink_newfile =
true;
150 mutt_error(
_(
"Mailcap compose entry requires %%s"));
163 struct Body *b = NULL;
168 mutt_perror(
_(
"Failure to open file to parse headers"));
207 mutt_perror(
_(
"Failure to open file to strip headers"));
264 bool unlink_newfile =
false;
269 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
285 unlink_newfile =
true;
312 mutt_error(
_(
"No mailcap edit entry for %s"), type);
343 if (((i > 0) && (np->
data[i - 1] ==
'/') && (np->
data[i] ==
'*') &&
347 struct Body tmp = { 0 };
352 snprintf(
type, len,
"%s/%s",
391 waitpid(pid, &rc, 0);
394 rc = WIFEXITED(rc) ? WEXITSTATUS(rc) : -1;
420 bool use_mailcap =
false;
421 bool use_pipe =
false;
422 bool use_pager =
true;
428 bool has_tempfile =
false;
429 bool unlink_pagerfile =
false;
445 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
448 snprintf(columns,
sizeof(columns),
"%d", win->
state.
cols);
461 mutt_error(
_(
"No matching mailcap entry found. Viewing as text."));
474 mutt_error(
_(
"MIME type not defined. Can't view attachment."));
495 struct Body *related_ancestor = NULL;
500 if (related_ancestor)
519 if (fp && !use_mailcap && a->
filename)
532 int fd_temp = -1, fd_pager = -1;
538 if (use_pager || use_pipe)
541 O_CREAT | O_EXCL | O_WRONLY)) == -1))
546 unlink_pagerfile =
true;
555 unlink_pagerfile =
true;
558 use_pipe ? fd_temp : -1, use_pager ? fd_pager : -1, -1);
576 snprintf(desc,
sizeof(desc),
_(
"---Command: %-20.20s Description: %s"),
581 snprintf(desc,
sizeof(desc),
_(
"---Command: %-30.30s Attachment: %s"),
621 struct State decode_state = { 0 };
631 decode_state.
fp_in = fp;
647 unlink_pagerfile =
true;
659 unlink_pagerfile =
true;
665 snprintf(desc,
sizeof(desc),
_(
"---Attachment: %s: %s"), a->
filename, type);
667 snprintf(desc,
sizeof(desc),
_(
"---Attachment: %s"), type);
692 unlink_pagerfile =
false;
710 if (unlink_pagerfile)
733 int out = -1, rc = 0;
734 bool is_flowed =
false;
735 bool unlink_unstuff =
false;
736 FILE *fp_filter = NULL, *fp_unstuff = NULL, *fp_in = NULL;
737 struct Buffer *unstuff_tempfile = NULL;
739 if (outfile && *outfile)
758 if (outfile && *outfile)
771 struct State s = { 0 };
779 if (fp_unstuff == NULL)
784 unlink_unstuff =
true;
794 if (fp_unstuff == NULL)
813 const char *infile = NULL;
822 unlink_unstuff =
true;
829 fp_in = fopen(infile,
"r");
844 if (outfile && *outfile)
866 if ((rc == 0) || c_wait_key)
880 return fopen(path,
"a");
882 return fopen(path,
"w");
923 if (!fgets(buf,
sizeof(buf), fp))
959 struct State s = { 0 };
988 FILE *fp_old = fopen(m->
filename,
"r");
1034 struct State s = { 0 };
1035 unsigned int saved_encoding = 0;
1036 struct Body *saved_parts = NULL;
1037 struct Email *e_saved = NULL;
1040 s.
flags = displaying;
1067 struct stat st = { 0 };
1068 if (fstat(fileno(s.
fp_in), &st) == -1)
1082 saved_parts = m->
parts;
1109 m->
parts = saved_parts;
1135 FILE *fp_in = NULL, *fp_out = NULL;
1136 bool unlink_newfile =
false;
1142 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
1156 FREE(&sanitized_fname);
1161 goto mailcap_cleanup;
1182 goto mailcap_cleanup;
1191 goto mailcap_cleanup;
1205 if ((rc2 != 0) || c_wait_key)
1236 unlink_newfile =
true;
1244 goto decode_cleanup;
1255 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.
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
static const char * mutt_buffer_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.
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.
bool mutt_envlist_unset(const char *name)
Unset an environment variable.
bool mutt_envlist_set(const char *name, const char *value, bool overwrite)
Set an environment variable.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
int mutt_file_open(const char *path, uint32_t flags)
Open a file.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
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.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
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)
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
pid_t filter_create(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr)
Run a command on a pipe (optionally connect stdin/stdout)
bool is_from(const char *s, char *path, size_t pathlen, time_t *tp)
Is a string a 'From' header line?
#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.
void mutt_decode_attachment(struct Body *b, struct State *s)
Decode an email's attachment.
int mutt_body_handler(struct Body *b, struct State *s)
Handler for the Body of an email.
Decide how to display email content.
int imap_wait_keepalive(pid_t pid)
Wait for a process to change state.
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
@ LL_DEBUG2
Log at debug level 2.
@ LL_DEBUG1
Log at debug level 1.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
@ MUTT_MMDF
'mmdf' Mailbox type
@ MUTT_MBOX
'mbox' Mailbox type
@ MUTT_MAILDIR
'Maildir' Mailbox type
struct MailcapEntry * mailcap_entry_new(void)
Allocate memory for a new rfc1524 entry.
bool mailcap_lookup(struct Body *a, char *type, size_t typelen, struct MailcapEntry *entry, enum MailcapLookup opt)
Find given type in the list of mailcap files.
void mailcap_entry_free(struct MailcapEntry **ptr)
Deallocate an struct MailcapEntry.
int mailcap_expand_command(struct Body *a, 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.
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)
Convenience wrapper for the library headers.
#define MUTT_CHARCONV
Do character set conversions.
#define MUTT_DISPLAY
Output is displayed to the user.
#define MUTT_DISPLAY_ATTACH
We are displaying an attachment.
#define MUTT_PRINTING
Are we printing? - MUTT_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)
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
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.
int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, char *outfile)
Pipe an attachment to a command.
void mutt_check_lookup_list(struct Body *b, char *type, size_t len)
Update the mime type.
int mutt_decode_save_attachment(FILE *fp, struct Body *m, const char *path, int displaying, enum SaveAttach opt)
Decode, then save an attachment.
int mutt_print_attachment(FILE *fp, struct Body *a)
Print out an attachment.
static int wait_interactive_filter(pid_t pid)
Wait after an interactive filter.
static FILE * save_attachment_open(const char *path, enum SaveAttach opt)
Open a file to write an attachment to.
int mutt_get_tmp_attachment(struct Body *a)
Get a temporary copy of an attachment.
void mutt_add_temp_attachment(const char *filename)
Add file to list of temporary attachments.
int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx, struct MuttWindow *win)
View an attachment.
int mutt_compose_attachment(struct Body *a)
Create an attachment.
void mutt_unlink_temp_attachments(void)
Delete all temporary attachments.
int mutt_save_attachment(FILE *fp, struct Body *m, const char *path, enum SaveAttach opt, struct Email *e)
Save an attachment.
int mutt_edit_attachment(struct Body *a)
Edit an attachment.
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.
Hundreds of global variables to back the user variables.
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.
bool mutt_needs_mailcap(struct Body *m)
Does this type need a mailcap entry do display.
void mutt_adv_mktemp(struct Buffer *buf)
Create a temporary file.
Some miscellaneous functions.
#define mutt_buffer_mktemp(buf)
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
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.
void mutt_param_free(struct ParameterList *pl)
Free a ParameterList.
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.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from 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 mutt_yesorno(const char *msg, 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.
void mutt_stamp_attachment(struct Body *a)
Timestamp an Attachment.
enum ContentType mutt_lookup_mime_type(struct Body *att, const char *path)
Find the MIME type for 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. MUTT_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.