80 const int index = actx->
v2r[virt];
82 return actx->
idx[index];
93 int vindex, rindex, curlevel;
98 while (rindex < actx->idxlen)
100 actx->
v2r[vindex++] = rindex;
103 curlevel = actx->
idx[rindex]->
level;
107 }
while ((rindex < actx->idxlen) && (actx->
idx[rindex]->
level > curlevel));
124 char buf[256] = { 0 };
129 for (
int vindex = 0; vindex < actx->
vcount; vindex++)
131 const int rindex = actx->
v2r[vindex];
132 actx->
idx[rindex]->
num = vindex;
133 if ((2 * (actx->
idx[rindex]->
level + 2)) <
sizeof(buf))
137 s = buf + 2 * (actx->
idx[rindex]->
level - 1);
159 if (((2 * (actx->
idx[rindex]->
level + 2)) <
sizeof(buf)) &&
162 s = buf + 2 * (actx->
idx[rindex]->
level - 1);
175 if (!buf || !buf->
data || (buf->
data[0] ==
'/'))
180 if (c_attach_save_dir)
183 if (tmp->
dptr[-1] !=
'/')
239 struct Body b_fake = { 0 };
253 memset(&b_fake, 0,
sizeof(
struct Body));
290 if (directory && *directory)
306 prompt =
_(
"Save to file: ");
323 struct stat st = { 0 };
329 prompt =
_(
"Save to file: ");
347 prompt =
_(
"Save to file: ");
354 (e || !is_message) ? e : b->
email) == 0)
358 mutt_message(ngettext(
"Attachment saved",
"%d attachments saved", num), num);
364 prompt =
_(
"Save to file: ");
416 (e || !is_message) ? e : b->
email);
436 char *directory = NULL;
440 int saved_attachments = 0;
449 for (
int i = 0; !tag || (i < actx->
idxlen); i++)
453 fp = actx->
idx[i]->
fp;
460 if (tag && menu && b->
aptr)
467 if (c_attach_save_without_prompting)
509 fprintf(fp_out,
"%s", c_attach_sep);
529 saved_attachments = 1;
531 if (!c_attach_split || c_attach_save_without_prompting)
533 mutt_message(ngettext(
"Attachment saved",
"%d attachments saved", saved_attachments),
557 snprintf(warning,
sizeof(warning),
558 _(
"WARNING! You are about to overwrite %s, continue?"), b->
filename);
594 if (!state || !state->
fp_out)
598 FILE *fp_unstuff = NULL;
599 bool is_flowed =
false, unlink_unstuff =
false;
600 struct Buffer *unstuff_tempfile = NULL;
621 unlink_unstuff =
true;
623 FILE *filter_fp = state->
fp_out;
624 state->
fp_out = fp_unstuff;
627 state->
fp_out = filter_fp;
645 const char *infile = NULL;
651 unlink_unstuff =
true;
694 FILE *fp,
bool tag,
struct Body *top,
695 bool filter,
struct State *state)
698 for (
int i = 0; !tag || (i < actx->
idxlen); i++)
702 fp = actx->
idx[i]->
fp;
707 if (!filter && !c_attach_split)
726 struct Body *b,
bool filter)
728 struct State state = { 0 };
729 struct Buffer *buf = NULL;
738 if (
mw_get_field((filter ?
_(
"Filter through: ") :
_(
"Pipe to: ")), buf,
750 if (!filter && !c_attach_split)
778 char type[256] = { 0 };
780 for (
int i = 0; !tag || (i < actx->
idxlen); i++)
784 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(b), b->
subtype);
796 mutt_error(
_(
"I don't know how to print %s attachments"), type);
819 char type[256] = { 0 };
824 for (
int i = 0; !tag || (i < actx->
idxlen); i++)
828 fp = actx->
idx[i]->
fp;
833 snprintf(type,
sizeof(type),
"%s/%s",
TYPE(b), b->
subtype);
854 mutt_error(
"BUG in print_attachment_list(). Please report this. ");
890 char prompt[128] = { 0 };
891 struct State state = { 0 };
895 for (
int i = 0; i < actx->
idxlen; i++)
899 snprintf(prompt,
sizeof(prompt),
900 tag ? ngettext(
"Print tagged attachment?",
"Print %d tagged attachments?", tagmsgcount) :
901 _(
"Print attachment?"),
942 mutt_message(
_(
"Structural changes to decrypted attachments are not supported"));
946 for (
int i = 0; i < actx->
idxlen; i++)
969 case OP_DISPLAY_HEADERS:
973 case OP_ATTACHMENT_VIEW:
992 case OP_MAIN_NEXT_UNDELETED:
995 if (index < menu->max)
998 op = OP_ATTACHMENT_VIEW;
1008 case OP_MAIN_PREV_UNDELETED:
1014 op = OP_ATTACHMENT_VIEW;
1023 case OP_ATTACHMENT_EDIT_TYPE:
1035 op = OP_ATTACHMENT_VIEW;
1043 op = OP_ATTACHMENT_VIEW;
1046 case OP_ATTACHMENT_PRINT:
1050 op = OP_ATTACHMENT_VIEW;
1053 case OP_ATTACHMENT_SAVE:
1057 op = OP_ATTACHMENT_VIEW;
1060 case OP_CHECK_TRADITIONAL:
1068 case OP_ATTACHMENT_COLLAPSE:
1076 }
while (op != OP_NULL);
1095 struct Body *bp = NULL;
1096 struct Body *new_body = NULL;
1097 FILE *fp_new = NULL;
1100 for (bp = b; bp; bp = bp->
next)
1102 bool need_secured =
false;
1103 bool secured =
false;
1107 need_secured =
true;
1112 goto decrypt_failed;
1128 goto decrypt_failed;
1138 need_secured =
true;
1141 goto decrypt_failed;
1149 if (need_secured && secured)
1159 if (need_secured && !secured)
1196 for (
int i = 0; i < actx->
idxlen; i++)
1228 if (index >= menu->
max)
1243 if (!ba || !actx || !menu)
1248 for (
int i = 0; i < actx->
idxlen; i++)
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_SIZE(head)
The number of elements stored.
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new)
Save a File handle to the Attachment Context.
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
void mutt_actx_add_body(struct AttachCtx *actx, struct Body *b)
Add an email body to an Attachment Context.
void mutt_actx_entries_free(struct AttachCtx *actx)
Free entries in an Attachment Context.
Handling of email attachments.
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
const struct CompleteOps CompleteFileOps
Auto-Completion of Files.
Select a Mailbox from a list.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
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 char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path 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.
Convenience wrapper for the core headers.
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec)
Wrapper for CryptModuleSpecs::decrypt_mime()
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec)
Wrapper for CryptModuleSpecs::decrypt_mime()
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void mutt_endwin(void)
Shutdown curses.
int menu_redraw(struct Menu *menu)
Redraw the parts of the screen that have been flagged to be redrawn.
void mutt_body_free(struct Body **ptr)
Free a Body.
Structs that make up an email.
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Manage where the email is piped to external commands.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
int mutt_file_rename(const char *oldfile, const char *newfile)
Rename a file.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
char ** EnvList
Private copy of the environment variables.
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
#define mutt_message(...)
Convenience wrapper for the gui headers.
bool mutt_can_decode(struct Body *b)
Will decoding the attachment produce any output.
void mutt_decode_attachment(const struct Body *b, struct State *state)
Decode an email's attachment.
Decide how to display email content.
Read/write command history from/to a file.
@ HC_EXT_COMMAND
External commands.
void mutt_default_save(struct Buffer *path, struct Email *e)
Find the default save path for an email.
Parse and execute user-defined hooks.
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_PRINT
Mailcap print field.
@ ENC_BASE64
Base-64 encoded text.
@ ENC_QUOTED_PRINTABLE
Quoted-printable text.
@ TYPE_MULTIPART
Type: 'multipart/*'.
@ TYPE_TEXT
Type: 'text/*'.
void msgwin_clear_text(struct MuttWindow *win)
Clear the text in the Message Window.
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, char **envlist)
Set up filter program.
Convenience wrapper for the library headers.
const char * mutt_path_basename(const char *path)
Find the last component for a pathname.
#define state_puts(STATE, STR)
#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.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Many unsorted constants and some structs.
#define MUTT_COMP_NO_FLAGS
No flags are set.
#define MUTT_COMP_CLEAR
Clear input if printable character is pressed.
int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, const char *outfile)
Pipe an attachment to a command.
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.
Handling of email attachments.
SaveAttach
Options for saving attachments.
@ MUTT_SAVE_APPEND
Append to existing file.
@ MUTT_SAVE_NO_FLAGS
No flags set.
@ MUTT_VA_REGULAR
View using default method.
Create/manipulate threading in emails.
@ MUTT_TREE_LLCORNER
Lower left corner.
@ MUTT_TREE_RARROW
Right arrow.
@ MUTT_TREE_LTEE
Left T-piece.
@ MUTT_TREE_VLINE
Vertical line.
@ MUTT_TREE_HLINE
Horizontal line.
@ MUTT_TREE_SPACE
Blank space.
void mutt_sleep(short s)
Sleep for a while.
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
int mutt_check_overwrite(const char *attname, const char *path, struct Buffer *fname, enum SaveAttach *opt, char **directory)
Ask the user if overwriting is necessary.
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
Some miscellaneous functions.
API for encryption/signing of emails.
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
#define APPLICATION_PGP
Use PGP to encrypt/sign.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
#define SEC_ENCRYPT
Email is encrypted.
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.
@ MUTT_NO
User answered 'No', or assume 'No'.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Email *e, struct Body *b, FILE *fp, int parent_type, int level, bool decrypted)
Create a list of attachments.
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
static int save_attachment_flowed_helper(FILE *fp, struct Body *b, const char *path, enum SaveAttach flags, struct Email *e)
Helper for unstuffing attachments.
static void print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, struct State *state)
Print a list of Attachments.
static void query_pipe_attachment(const char *command, FILE *fp, struct Body *b, bool filter)
Ask the user if we should pipe the attachment.
static int save_without_prompting(FILE *fp, struct Body *b, struct Email *e)
Save the attachment, without prompting each time.
void mutt_save_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, struct Email *e, struct Menu *menu)
Save a list of attachments.
static void pipe_attachment_list(const char *command, struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, bool filter, struct State *state)
Pipe a list of attachments to a command.
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
int mutt_attach_display_loop(struct ConfigSubset *sub, struct Menu *menu, int op, struct Email *e, struct AttachCtx *actx, bool recv)
Event loop for the Attachment menu.
static void prepend_savedir(struct Buffer *buf)
Add $attach_save_dir to the beginning of a path.
void mutt_pipe_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, bool filter)
Pipe a list of attachments to a command.
static bool can_print(struct AttachCtx *actx, struct Body *b, bool tag)
Do we know how to print this attachment type?
static void pipe_attachment(FILE *fp, struct Body *b, struct State *state)
Pipe the attachment to a command.
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
void mutt_print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b)
Print a list of Attachments.
static int query_save_attachment(FILE *fp, struct Body *b, struct Email *e, char **directory)
Ask the user if we should save the attachment.
static bool has_a_message(struct Body *b)
Determine if the Body has a message (to save)
static void mutt_update_v2r(struct AttachCtx *actx)
Update the virtual list of attachments.
void recvattach_edit_content_type(struct AttachCtx *actx, struct Menu *menu, struct Email *e)
Edit the content type of an attachment.
int ba_add_tagged(struct BodyArray *ba, struct AttachCtx *actx, struct Menu *menu)
Get an array of tagged Attachments.
Routines for managing 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_update_encoding(struct Body *b, struct ConfigSubset *sub)
Update the encoding type.
short vcount
The number of virtual attachments.
FILE * fp_root
Used by recvattach for updating.
struct Email * email
Used by recvattach for updating.
struct AttachPtr ** idx
Array of attachments.
short idxlen
Number of attachmentes.
short * v2r
Mapping from virtual to real attachment.
An email to which things will be attached.
struct Body * body
Attachment.
bool collapsed
Group is collapsed.
char * tree
Tree characters to display.
int num
Attachment index number.
int level
Nesting depth of attachment.
FILE * fp
Used in the recvattach menu.
bool decrypted
Not part of message as stored in the email->body.
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
struct Body * parts
parts of a multipart or message/rfc822
struct AttachPtr * aptr
Menu information, used in recvattach.c.
struct Email * email
header information for message/rfc822
bool tagged
This attachment is tagged.
struct Body * next
next attachment in the list
char * subtype
content-type subtype
unsigned int encoding
content-transfer-encoding, ContentEncoding
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 * dptr
Current read/write position.
char * data
Pointer to data.
A set of inherited config items.
The envelope/body of an email.
struct Envelope * env
Envelope information.
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.
Input for the file completion function.
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.