NeoMutt  2022-04-29-247-gc6aae8
Teaching an old dog new tricks
recvattach.h File Reference

Routines for managing attachments. More...

#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "format_flags.h"
+ Include dependency graph for recvattach.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


void mutt_attach_init (struct AttachCtx *actx)
 Create a new Attachment context. More...
void mutt_update_tree (struct AttachCtx *actx)
 Refresh the list of attachments. More...
const char * attach_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
 Format a string for the attachment menu - Implements format_t -. More...
void dlg_select_attachment (struct ConfigSubset *sub, struct Mailbox *m, struct Email *e, FILE *fp)
 Show the attachments in a Menu. More...
void mutt_generate_recvattach_list (struct AttachCtx *actx, struct Email *e, struct Body *parts, FILE *fp, int parent_type, int level, bool decrypted)
 Create a list of attachments. More...
struct AttachPtrcurrent_attachment (struct AttachCtx *actx, struct Menu *menu)
 Get the current attachment. More...
void mutt_update_recvattach_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Update the Attachment Menu. More...
void recvattach_edit_content_type (struct AttachCtx *actx, struct Menu *menu, struct Email *e)
 Edit the content type of an attachment. More...
int ba_add_tagged (struct BodyArray *ba, struct AttachCtx *actx, struct Menu *menu)
 Get an array of tagged Attachments. More...

Detailed Description

Routines for managing attachments.

  • Michael R. Elkins
  • Thomas Roessler

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

Definition in file recvattach.h.

Function Documentation

◆ mutt_attach_init()

void mutt_attach_init ( struct AttachCtx actx)

Create a new Attachment context.

actxAttachment context

Definition at line 1167 of file recvattach.c.

1169 /* Collapse the attachments if '$digest_collapse' is set AND if...
1170 * the outer container is of type 'multipart/digest' */
1171 bool digest = mutt_istr_equal(actx->email->body->subtype, "digest");
1173 const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
1174 for (int i = 0; i < actx->idxlen; i++)
1175 {
1176 actx->idx[i]->body->tagged = false;
1178 /* OR an inner container is of type 'multipart/digest' */
1179 actx->idx[i]->collapsed = (c_digest_collapse &&
1180 (digest ||
1181 ((actx->idx[i]->body->type == TYPE_MULTIPART) &&
1182 mutt_istr_equal(actx->idx[i]->body->subtype, "digest"))));
1183 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
Type: 'multipart/*'.
Definition: mime.h:37
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:819
struct Email * email
Used by recvattach for updating.
Definition: attach.h:52
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:55
short idxlen
Number of attachmentes.
Definition: attach.h:56
struct Body * body
Definition: attach.h:36
bool collapsed
Group is collapsed.
Definition: attach.h:44
bool tagged
This attachment is tagged.
Definition: body.h:89
char * subtype
content-type subtype
Definition: body.h:60
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
struct Body * body
List of MIME parts.
Definition: email.h:67
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_update_tree()

void mutt_update_tree ( struct AttachCtx actx)

Refresh the list of attachments.

actxAttachment context

Definition at line 112 of file recvattach.c.

114 char buf[256] = { 0 };
115 char *s = NULL;
117 mutt_update_v2r(actx);
119 for (int vindex = 0; vindex < actx->vcount; vindex++)
120 {
121 const int rindex = actx->v2r[vindex];
122 actx->idx[rindex]->num = vindex;
123 if ((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf))
124 {
125 if (actx->idx[rindex]->level)
126 {
127 s = buf + 2 * (actx->idx[rindex]->level - 1);
128 *s++ = (actx->idx[rindex]->body->next) ? MUTT_TREE_LTEE : MUTT_TREE_LLCORNER;
129 *s++ = MUTT_TREE_HLINE;
130 *s++ = MUTT_TREE_RARROW;
131 }
132 else
133 s = buf;
134 *s = '\0';
135 }
137 if (actx->idx[rindex]->tree)
138 {
139 if (!mutt_str_equal(actx->idx[rindex]->tree, buf))
140 mutt_str_replace(&actx->idx[rindex]->tree, buf);
141 }
142 else
143 actx->idx[rindex]->tree = mutt_str_dup(buf);
145 if (((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf)) &&
146 actx->idx[rindex]->level)
147 {
148 s = buf + 2 * (actx->idx[rindex]->level - 1);
149 *s++ = (actx->idx[rindex]->body->next) ? '\005' : '\006';
150 *s++ = '\006';
151 }
152 }
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:807
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:326
Lower left corner.
Definition: mutt_thread.h:44
Right arrow.
Definition: mutt_thread.h:50
Left T-piece.
Definition: mutt_thread.h:46
Horizontal line.
Definition: mutt_thread.h:47
static void mutt_update_v2r(struct AttachCtx *actx)
Update the virtual list of attachments.
Definition: recvattach.c:83
short vcount
The number of virtual attachments.
Definition: attach.h:60
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:59
char * tree
Tree characters to display.
Definition: attach.h:39
int num
Attachment index number.
Definition: attach.h:41
int level
Nesting depth of attachment.
Definition: attach.h:40
struct Body * next
next attachment in the list
Definition: body.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_select_attachment()

void dlg_select_attachment ( struct ConfigSubset sub,
struct Mailbox m,
struct Email e,
FILE *  fp 

Show the attachments in a Menu.

subConfig Subset
fpFile with the content of the email, or NULL

Definition at line 449 of file dlg_attach.c.

452 if (!m || !e || !fp)
453 return;
455 /* make sure we have parsed this message */
460 struct Menu *menu = dlg->wdata;
462 menu->tag = attach_tag;
464 struct AttachCtx *actx = mutt_actx_new();
465 actx->email = e;
466 actx->fp_root = fp;
467 mutt_update_recvattach_menu(actx, menu, true);
470 priv->menu = menu;
471 priv->actx = actx;
472 priv->sub = sub;
473 priv->mailbox = m;
474 menu->mdata = priv;
477 // NT_COLOR is handled by the SimpleDialog
481 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
482 sbar_set_title(sbar, _("Attachments"));
484 // ---------------------------------------------------------------------------
485 // Event Loop
486 int rc = 0;
487 int op = OP_NULL;
488 do
489 {
490 menu_tagging_dispatcher(menu->win, op);
491 window_redraw(NULL);
493 op = km_dokey(MENU_ATTACH);
494 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
495 if (op < 0)
496 continue;
497 if (op == OP_NULL)
498 {
500 continue;
501 }
504 rc = attach_function_dispatcher(dlg, op);
505 if (rc == FR_UNKNOWN)
506 rc = menu_function_dispatcher(menu->win, op);
507 if (rc == FR_UNKNOWN)
508 rc = global_function_dispatcher(NULL, op);
510 if (rc == FR_CONTINUE)
511 {
512 op = priv->op;
513 }
515 } while (rc != FR_DONE);
516 // ---------------------------------------------------------------------------
518 simple_dialog_free(&dlg);
struct AttachCtx * mutt_actx_new(void)
Create a new Attachment Context.
Definition: attach.c:189
struct AttachPrivateData * attach_private_data_new(void)
Create new Attach Data.
Definition: private_data.c:52
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:591
Exit the Dialog.
Definition: dispatcher.h:35
Unknown function.
Definition: dispatcher.h:33
Remain in the Dialog.
Definition: dispatcher.h:34
static const struct Mapping AttachHelp[]
Help Bar for the Attachment selection dialog.
Definition: dlg_attach.c:94
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int attach_function_dispatcher(struct MuttWindow *win, int op)
Perform a Attach function - Implements function_dispatcher_t -.
Definition: functions.c:641
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static void attach_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the attachment list - Implements Menu::make_entry() -.
Definition: dlg_attach.c:386
void attach_private_data_free(struct Menu *menu, void **ptr)
Free Attach Data - Implements Menu::mdata_free() -.
Definition: private_data.c:38
static int attach_tag(struct Menu *menu, int sel, int act)
Tag an attachment - Implements Menu::tag() -.
Definition: dlg_attach.c:400
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_attach.c:110
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_attach.c:419
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:658
message-hook: run before displaying a message
Definition: hook.h:45
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
Log at debug level 1.
Definition: logging.h:40
#define _(a)
Definition: message.h:28
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:189
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:78
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:46
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1192
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
A set of attachments.
Definition: attach.h:51
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:53
Private state data for Attachments.
Definition: private_data.h:34
int op
Op returned from the Pager, e.g. OP_NEXT_ENTRY.
Definition: private_data.h:39
struct Menu * menu
Current Menu.
Definition: private_data.h:35
struct ConfigSubset * sub
Config subset.
Definition: private_data.h:37
struct AttachCtx * actx
List of all Attachments.
Definition: private_data.h:36
struct Mailbox * mailbox
Current Mailbox.
Definition: private_data.h:38
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:121
void * mdata
Private data.
Definition: lib.h:137
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
Select an attachment.
Definition: type.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_generate_recvattach_list()

void mutt_generate_recvattach_list ( struct AttachCtx actx,
struct Email e,
struct Body parts,
FILE *  fp,
int  parent_type,
int  level,
bool  decrypted 

Create a list of attachments.

actxAttachment context
partsBody of email
fpFile to read from
parent_typeType, e.g. TYPE_MULTIPART
levelAttachment depth
decryptedTrue if attachment has been decrypted

Definition at line 1061 of file recvattach.c.

1065 struct Body *m = NULL;
1066 struct Body *new_body = NULL;
1067 FILE *fp_new = NULL;
1070 for (m = parts; m; m = m->next)
1071 {
1072 bool need_secured = false;
1073 bool secured = false;
1076 {
1077 need_secured = true;
1079 if (type & SEC_ENCRYPT)
1080 {
1082 goto decrypt_failed;
1084 if (e->env)
1086 }
1088 secured = (crypt_smime_decrypt_mime(fp, &fp_new, m, &new_body) == 0);
1089 /* If the decrypt/verify-opaque doesn't generate mime output, an empty
1090 * text/plain type will still be returned by mutt_read_mime_header().
1091 * We can't distinguish an actual part from a failure, so only use a
1092 * text/plain that results from a single top-level part. */
1093 if (secured && (new_body->type == TYPE_TEXT) &&
1094 mutt_istr_equal("plain", new_body->subtype) && ((parts != m) || m->next))
1095 {
1096 mutt_body_free(&new_body);
1097 mutt_file_fclose(&fp_new);
1098 goto decrypt_failed;
1099 }
1101 if (secured && (type & SEC_ENCRYPT))
1102 e->security |= SMIME_ENCRYPT;
1103 }
1105 if (((WithCrypto & APPLICATION_PGP) != 0) &&
1107 {
1108 need_secured = true;
1111 goto decrypt_failed;
1113 secured = (crypt_pgp_decrypt_mime(fp, &fp_new, m, &new_body) == 0);
1115 if (secured)
1116 e->security |= PGP_ENCRYPT;
1117 }
1119 if (need_secured && secured)
1120 {
1121 mutt_actx_add_fp(actx, fp_new);
1122 mutt_actx_add_body(actx, new_body);
1123 mutt_generate_recvattach_list(actx, e, new_body, fp_new, parent_type, level, 1);
1124 continue;
1125 }
1127 decrypt_failed:
1128 /* Fall through and show the original parts if decryption fails */
1129 if (need_secured && !secured)
1130 mutt_error(_("Can't decrypt encrypted message"));
1132 /* Strip out the top level multipart */
1133 if ((m->type == TYPE_MULTIPART) && m->parts && !need_secured &&
1134 ((parent_type == -1) && !mutt_istr_equal("alternative", m->subtype) &&
1135 !mutt_istr_equal("multilingual", m->subtype)))
1136 {
1137 mutt_generate_recvattach_list(actx, e, m->parts, fp, m->type, level, decrypted);
1138 }
1139 else
1140 {
1141 struct AttachPtr *ap = mutt_aptr_new();
1142 mutt_actx_add_attach(actx, ap);
1144 ap->body = m;
1145 ap->fp = fp;
1146 m->aptr = ap;
1148 ap->level = level;
1149 ap->decrypted = decrypted;
1151 if (m->type == TYPE_MULTIPART)
1152 mutt_generate_recvattach_list(actx, e, m->parts, fp, m->type, level + 1, decrypted);
1153 else if (mutt_is_message_type(m->type, m->subtype))
1154 {
1156 level + 1, decrypted);
1157 e->security |= m->email->security;
1158 }
1159 }
1160 }
void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body)
Add an email body to an Attachment Context.
Definition: attach.c:142
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
Definition: attach.c:65
void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new)
Save a File handle to the Attachment Context.
Definition: attach.c:121
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
Definition: attach.c:40
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
Definition: crypt.c:601
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:134
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:439
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:500
int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition: cryptglue.c:433
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:455
int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition: cryptglue.c:211
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
#define mutt_error(...)
Definition: logging.h:87
Type: 'text/*'.
Definition: mime.h:38
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: lib.h:76
Use PGP to encrypt/sign.
Definition: lib.h:90
Definition: lib.h:96
Use SMIME to encrypt/sign.
Definition: lib.h:91
Email is encrypted.
Definition: lib.h:78
Definition: lib.h:102
#define WithCrypto
Definition: lib.h:116
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1441
void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Email *e, struct Body *parts, FILE *fp, int parent_type, int level, bool decrypted)
Create a list of attachments.
Definition: recvattach.c:1061
An email to which things will be attached.
Definition: attach.h:35
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
bool decrypted
Not part of message as stored in the email->body.
Definition: attach.h:43
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:38
The body of an email.
Definition: body.h:36
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:72
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:74
struct Email * email
header information for message/rfc822
Definition: body.h:73
struct Envelope * env
Envelope information.
Definition: email.h:66
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current_attachment()

struct AttachPtr * current_attachment ( struct AttachCtx actx,
struct Menu menu 

Get the current attachment.

actxAttachment context
Return values
ptrCurrent Attachment

Definition at line 69 of file recvattach.c.

71 const int virt = menu_get_index(menu);
72 const int index = actx->v2r[virt];
74 return actx->idx[index];
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_update_recvattach_menu()

void mutt_update_recvattach_menu ( struct AttachCtx actx,
struct Menu menu,
bool  init 

Update the Attachment Menu.

actxAttachment context
menuMenu listing Attachments
initIf true, create a new Attachments context

Definition at line 1192 of file recvattach.c.

1194 if (init)
1195 {
1196 mutt_generate_recvattach_list(actx, actx->email, actx->email->body,
1197 actx->fp_root, -1, 0, 0);
1198 mutt_attach_init(actx);
1199 }
1201 mutt_update_tree(actx);
1203 menu->max = actx->vcount;
1205 const int index = menu_get_index(menu);
1206 if (index >= menu->max)
1207 menu_set_index(menu, menu->max - 1);
Redraw the index.
Definition: lib.h:56
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:178
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:168
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
Definition: recvattach.c:1167
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition: recvattach.c:112
int max
Number of entries in the menu.
Definition: lib.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recvattach_edit_content_type()

void recvattach_edit_content_type ( struct AttachCtx actx,
struct Menu menu,
struct Email e 

Edit the content type of an attachment.

actxAttachment context
menuMenu listing Attachments

Definition at line 908 of file recvattach.c.

910 struct AttachPtr *cur_att = current_attachment(actx, menu);
911 if (!mutt_edit_content_type(e, cur_att->body, cur_att->fp))
912 return;
914 /* The mutt_update_recvattach_menu() will overwrite any changes
915 * made to a decrypted cur_att->body, so warn the user. */
916 if (cur_att->decrypted)
917 {
918 mutt_message(_("Structural changes to decrypted attachments are not supported"));
919 mutt_sleep(1);
920 }
921 /* Editing the content type can rewrite the body structure. */
922 for (int i = 0; i < actx->idxlen; i++)
923 actx->idx[i]->body = NULL;
925 mutt_update_recvattach_menu(actx, menu, true);
void mutt_actx_entries_free(struct AttachCtx *actx)
Free entries in an Attachment Context.
Definition: attach.c:162
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Definition: commands.c:1105
#define mutt_message(...)
Definition: logging.h:86
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1455
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
Definition: recvattach.c:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ba_add_tagged()

int ba_add_tagged ( struct BodyArray *  ba,
struct AttachCtx actx,
struct Menu menu 

Get an array of tagged Attachments.

baEmpty BodyArray to populate
actxList of Attachments
Return values
numNumber of selected Attachments

Definition at line 1219 of file recvattach.c.

1221 if (!ba || !actx || !menu)
1222 return -1;
1224 if (menu->tag_prefix)
1225 {
1226 for (int i = 0; i < actx->idxlen; i++)
1227 {
1228 struct Body *b = actx->idx[i]->body;
1229 if (b->tagged)
1230 {
1231 ARRAY_ADD(ba, b);
1232 }
1233 }
1234 }
1235 else
1236 {
1237 struct AttachPtr *cur = current_attachment(actx, menu);
1238 if (!cur)
1239 return -1;
1241 ARRAY_ADD(ba, cur->body);
1242 }
1244 return ARRAY_SIZE(ba);
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:155
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:86
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function: