38 #include "mutt/mutt.h" 76 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
88 FILE *fp_in = NULL, *fp_out = NULL;
89 if ((fp_in = fopen(a->
filename,
"r")) &&
96 if (a->
stamp >= st.st_mtime)
107 return a->
unlink ? 0 : -1;
120 bool unlink_newfile =
false;
126 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"));
196 fseeko(fp, b->
offset, SEEK_SET);
202 mutt_perror(
_(
"Failure to open file to strip headers"));
222 mutt_message(
_(
"No mailcap compose entry for %s, creating empty file"), type);
259 bool unlink_newfile =
false;
264 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
279 unlink_newfile =
true;
305 mutt_error(
_(
"No mailcap edit entry for %s"), type);
336 if (((i > 0) && (np->
data[i - 1] ==
'/') && (np->
data[i] ==
'*') &&
340 struct Body tmp = { 0 };
345 snprintf(type, len,
"%s/%s",
389 bool use_mailcap =
false;
390 bool use_pipe =
false;
391 bool use_pager =
true;
397 bool unlink_tempfile =
false;
412 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
415 snprintf(columns,
sizeof(columns),
"%d", win->
cols);
427 mutt_error(
_(
"No matching mailcap entry found. Viewing as text."));
440 mutt_error(
_(
"MIME type not defined. Can't view attachment."));
464 unlink_tempfile =
true;
481 if (fp && !use_mailcap && a->
filename)
494 int fd_temp = -1, fd_pager = -1;
499 if (use_pager || use_pipe)
502 O_CREAT | O_EXCL | O_WRONLY)) == -1))
507 if (use_pipe && ((fd_temp = open(
mutt_b2s(tmpfile), 0)) == -1))
516 use_pipe ? fd_temp : -1,
517 use_pager ? fd_pager : -1, -1);
535 snprintf(desc,
sizeof(desc),
_(
"---Command: %-20.20s Description: %s"),
540 snprintf(desc,
sizeof(desc),
_(
"---Command: %-30.30s Attachment: %s"),
577 struct State decode_state = { 0 };
583 mutt_b2s(pagerfile), errno, strerror(errno));
587 decode_state.
fp_in = fp;
592 errno, strerror(errno));
619 snprintf(desc,
sizeof(desc),
_(
"---Attachment: %s: %s"), a->
filename, type);
621 snprintf(desc,
sizeof(desc),
_(
"---Attachment: %s"), type);
628 struct Pager info = { 0 };
652 else if (unlink_tempfile)
686 if (outfile && *outfile)
702 struct State s = { 0 };
707 if (outfile && *outfile)
729 if (outfile && *outfile)
738 if (outfile && *outfile)
759 if (outfile && *outfile)
780 return fopen(path,
"a");
782 return fopen(path,
"w");
821 if (fseeko(fp, m->
offset, SEEK_SET) < 0)
823 if (!fgets(buf,
sizeof(buf), fp))
860 struct State s = { 0 };
885 FILE *fp_old = fopen(m->
filename,
"r");
931 struct State s = { 0 };
932 unsigned int saved_encoding = 0;
933 struct Body *saved_parts = NULL;
934 struct Email *e_saved = NULL;
937 s.
flags = displaying;
940 s.
fp_out = fopen(path,
"a");
942 s.
fp_out = fopen(path,
"w");
978 saved_parts = m->
parts;
1005 m->
parts = saved_parts;
1031 FILE *fp_in = NULL, *fp_out = NULL;
1032 bool unlink_newfile =
false;
1038 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(a), a->
subtype);
1055 goto mailcap_cleanup;
1059 unlink_newfile =
true;
1065 goto mailcap_cleanup;
1076 fp_in = fopen(
mutt_b2s(newfile),
"r");
1081 goto mailcap_cleanup;
1090 goto mailcap_cleanup;
1113 else if (unlink_newfile)
1139 fp_in = fopen(
mutt_b2s(newfile),
"r");
1143 goto decode_cleanup;
1153 goto decode_cleanup;
#define MUTT_APPEND
Open mailbox for appending messages.
pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
bool xneomuttkeep
do not remove the file on command exit
#define MUTT_MSG_NO_FLAGS
No flags are set.
void mutt_decode_attachment(struct Body *b, struct State *s)
Decode an email's attachment.
struct MailcapEntry * mailcap_entry_new(void)
Allocate memory for a new rfc1524 entry.
void mutt_stamp_attachment(struct Body *a)
Timestamp an Attachment.
#define mutt_buffer_mktemp(buf)
#define MUTT_DISPLAY
Output is displayed to the user.
char * filename
when sending a message, this is the file to which this structure refers
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
The envelope/body of an email.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
GUI miscellaneous curses (window drawing) routines.
#define MUTT_CHARCONV
Do character set conversions.
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Structs that make up an email.
The "currently-open" mailbox.
#define is_multipart(body)
int mutt_file_fsync_close(FILE **fp)
Flush the data, before closing a file (and NULL the pointer)
#define mutt_message(...)
int mutt_file_rename(const char *oldfile, const char *newfile)
Rename a file.
User answered 'Yes', or assume 'Yes'.
Pass files through external commands (filters)
char * composetypecommand
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
bool noconv
Don't do character set conversion.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
RFC1524 Mailcap routines.
int mutt_edit_attachment(struct Body *a)
Edit an attachment.
String manipulation buffer.
LOFF_T offset
offset where the actual data begins
#define CH_FROM
Retain the "From " message separator?
#define CH_NOSTATUS
Suppress the status and x-status fields.
ViewAttachMode
Options for mutt_view_attachment()
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
FILE * fp_out
File to write to.
#define CH_UPDATE
Update the status and x-status fields?
A division of the screen.
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
#define MUTT_PRINTING
Are we printing? - MUTT_DISPLAY "light".
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.
View using default method.
#define SEC_ENCRYPT
Email is encrypted.
char * form_name
Content-Disposition form-data name param.
#define MUTT_CM_NO_FLAGS
No flags are set.
FILE * fp_in
File to read from.
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Convenience wrapper for the config headers.
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.
int mailcap_expand_command(struct Body *a, const char *filename, const char *type, struct Buffer *command)
Expand expandos in a command.
Hundreds of global variables to back the user variables.
void mailcap_expand_filename(const char *nametemplate, const char *oldfile, struct Buffer *newfile)
Expand a new filename from a template or existing filename.
Some miscellaneous functions.
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
int mutt_get_tmp_attachment(struct Body *a)
Get a temporary copy of an attachment.
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
bool copiousoutput
needs pager, basically
enum MailboxType magic
Mailbox type.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Convenience wrapper for the core headers.
void mutt_param_free(struct ParameterList *pl)
Free a ParameterList.
unsigned int encoding
content-transfer-encoding
int mutt_file_chmod(const char *path, mode_t mode)
Set permissions of a file.
struct Message * mx_msg_open_new(struct Mailbox *m, struct Email *e, MsgOpenFlags flags)
Open a new message.
void mutt_add_temp_attachment(const char *filename)
Add file to list of temporary attachments.
'Maildir' Mailbox type
char * subtype
content-type subtype
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
void mutt_file_sanitize_filename(char *path, bool slash)
Replace unsafe characters in a filename.
Prototypes for many functions.
int mutt_str_strncasecmp(const char *a, const char *b, size_t l)
Compare two strings ignoring case (to a maximum), safely.
WHERE struct Context * Context
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
A local copy of an email.
void mutt_endwin(void)
Shutdown curses/slang.
LOFF_T length
length (in bytes) of attachment
bool mutt_envlist_unset(const char *name)
Unset an environment variable.
void mailcap_entry_free(struct MailcapEntry **ptr)
Deallocate an struct MailcapEntry.
#define CH_NO_FLAGS
No flags are set.
int mutt_decode_save_attachment(FILE *fp, struct Body *m, const char *path, int displaying, enum SaveAttach opt)
Decode, then save an attachment.
bool mutt_can_decode(struct Body *a)
Will decoding the attachment produce any output.
char * data
Pointer to data.
char * xtype
content-type if x-unknown
struct Body * parts
parts of a multipart or message/rfc822
pid_t mutt_create_filter_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)
'mmdf' Mailbox type
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
Handling of email attachments.
#define MUTT_QUIET
Do not print any messages.
API for encryption/signing of emails.
#define STAILQ_FOREACH(var, head, field)
char * description
content-description
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Force viewing using mailcap entry.
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
unsigned int type
content-type primary type
'mbox' Mailbox type
Type: 'message/*'.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Keep track when processing files.
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Type: 'multipart/*'.
Duplicate the structure of an entire email.
int mutt_file_open(const char *path, int flags)
Open a file.
void mutt_check_lookup_list(struct Body *b, char *type, size_t len)
Update the mime type.
int mutt_do_pager(const char *banner, const char *tempfile, PagerFlags do_color, struct Pager *info)
Display some page-able text to the user.
enum ContentType mutt_lookup_mime_type(struct Body *att, const char *path)
Find the MIME type for an attachment.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
char * mutt_str_strdup(const char *str)
Copy a string, safely.
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
time_t stamp
Time stamp of last encoding update.
bool mutt_needs_mailcap(struct Body *m)
Does this type need a mailcap entry do display.
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
WHERE char * C_PrintCommand
Config: External command to print a message.
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
WHERE char * C_Editor
Config: External command to use as an email editor.
FILE * fp
pointer to the message data
void mutt_adv_mktemp(struct Buffer *buf)
Create a temporary file.
struct Mailbox * mx_path_resolve(const char *path)
XXX.
Keep track when processing files.
int mutt_file_chmod_add(const char *path, mode_t mode)
Add permissions to a file.
WHERE bool OptViewAttach
(pseudo) signals that we are viewing attachments
bool mutt_envlist_set(const char *name, const char *value, bool overwrite)
Set an environment variable.
int mutt_body_handler(struct Body *b, struct State *s)
Handler for the Body of an email.
static FILE * save_attachment_open(const char *path, enum SaveAttach opt)
Open a file to write an attachment to.
bool is_from(const char *s, char *path, size_t pathlen, time_t *tp)
Is a string a 'From' header line?
Handling of global boolean variables.
#define mutt_debug(LEVEL,...)
Miscellaneous functions for sending an email.
void mutt_body_free(struct Body **ptr)
Free a Body.
#define TAILQ_EMPTY(head)
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
int mutt_file_symlink(const char *oldpath, const char *newpath)
Create a symlink.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
#define MUTT_ADD_FROM
add a From_ line
void email_free(struct Email **ptr)
Free an Email.
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Decide how to display email content.
struct ParameterList parameter
parameters of the content-type
struct Email * email
header information for message/rfc822
void mutt_edit_file(const char *editor, const char *file)
Let the user edit a file.
int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, char *outfile)
Pipe an attachment to a command.
bool needsterminal
endwin() and system
int mutt_system(const char *cmd)
Run an external command.
Type: 'application/*'.
struct Body * mutt_read_mime_header(FILE *fp, bool digest)
Parse a MIME header.
int mutt_compose_attachment(struct Body *a)
Create an attachment.
int msgno
Number displayed to the user.
SaveAttach
Options for saving 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_print_attachment(FILE *fp, struct Body *a)
Print out an attachment.