NeoMutt  2023-05-17-16-g61469c
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 MailboxView *mv, 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 1182 of file recvattach.c.

1184 /* Collapse the attachments if '$digest_collapse' is set AND if...
1185 * the outer container is of type 'multipart/digest' */
1186 bool digest = mutt_istr_equal(actx->email->body->subtype, "digest");
1188 const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
1189 for (int i = 0; i < actx->idxlen; i++)
1190 {
1191 actx->idx[i]->body->tagged = false;
1193 /* OR an inner container is of type 'multipart/digest' */
1194 actx->idx[i]->collapsed = (c_digest_collapse &&
1195 (digest ||
1196 ((actx->idx[i]->body->type == TYPE_MULTIPART) &&
1197 mutt_istr_equal(actx->idx[i]->body->subtype, "digest"))));
1198 }
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:810
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 114 of file recvattach.c.

116 char buf[256] = { 0 };
117 char *s = NULL;
119 mutt_update_v2r(actx);
121 for (int vindex = 0; vindex < actx->vcount; vindex++)
122 {
123 const int rindex = actx->v2r[vindex];
124 actx->idx[rindex]->num = vindex;
125 if ((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf))
126 {
127 if (actx->idx[rindex]->level)
128 {
129 s = buf + 2 * (actx->idx[rindex]->level - 1);
130 *s++ = (actx->idx[rindex]->body->next) ? MUTT_TREE_LTEE : MUTT_TREE_LLCORNER;
131 *s++ = MUTT_TREE_HLINE;
132 *s++ = MUTT_TREE_RARROW;
133 }
134 else
135 {
136 s = buf;
137 }
138 *s = '\0';
139 }
141 if (actx->idx[rindex]->tree)
142 {
143 if (!mutt_str_equal(actx->idx[rindex]->tree, buf))
144 mutt_str_replace(&actx->idx[rindex]->tree, buf);
145 }
146 else
147 {
148 actx->idx[rindex]->tree = mutt_str_dup(buf);
149 }
151 if (((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf)) &&
152 actx->idx[rindex]->level)
153 {
154 s = buf + 2 * (actx->idx[rindex]->level - 1);
155 *s++ = (actx->idx[rindex]->body->next) ? '\005' : '\006';
156 *s++ = '\006';
157 }
158 }
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:251
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:327
Lower left corner.
Definition: mutt_thread.h:56
Right arrow.
Definition: mutt_thread.h:62
Left T-piece.
Definition: mutt_thread.h:58
Horizontal line.
Definition: mutt_thread.h:59
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 MailboxView mv,
struct Email e,
FILE *  fp 

Show the attachments in a Menu.

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

Definition at line 468 of file dlg_attach.c.

471 if (!mv || !mv->mailbox || !e || !fp)
472 return;
474 struct Mailbox *m = mv->mailbox;
476 /* make sure we have parsed this message */
481 struct Menu *menu = dlg->wdata;
483 menu->tag = attach_tag;
485 struct AttachCtx *actx = mutt_actx_new();
486 actx->email = e;
487 actx->fp_root = fp;
488 mutt_update_recvattach_menu(actx, menu, true);
491 priv->menu = menu;
492 priv->actx = actx;
493 priv->sub = sub;
494 priv->mailbox = m;
495 menu->mdata = priv;
498 // NT_COLOR is handled by the SimpleDialog
502 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
503 sbar_set_title(sbar, _("Attachments"));
505 // ---------------------------------------------------------------------------
506 // Event Loop
507 int rc = 0;
508 int op = OP_NULL;
509 do
510 {
511 menu_tagging_dispatcher(menu->win, op);
512 window_redraw(NULL);
514 op = km_dokey(MENU_ATTACH);
515 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
516 if (op < 0)
517 continue;
518 if (op == OP_NULL)
519 {
521 continue;
522 }
525 rc = attach_function_dispatcher(dlg, op);
526 if (rc == FR_UNKNOWN)
527 rc = menu_function_dispatcher(menu->win, op);
528 if (rc == FR_UNKNOWN)
529 rc = global_function_dispatcher(NULL, op);
531 if (rc == FR_CONTINUE)
532 {
533 op = priv->op;
534 }
536 } while (rc != FR_DONE);
537 // ---------------------------------------------------------------------------
539 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:50
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:596
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:95
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:650
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:317
#define mutt_debug(LEVEL,...)
Definition: logging2.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:405
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:419
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_attach.c:111
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_attach.c:438
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:803
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1077
Log at debug level 1.
Definition: logging2.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:73
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:605
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:523
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:48
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1207
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
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:50
A mailbox.
Definition: mailbox.h:79
Definition: lib.h:70
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:97
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:122
void * mdata
Private data.
Definition: lib.h:138
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 1084 of file recvattach.c.

1088 struct Body *m = NULL;
1089 struct Body *new_body = NULL;
1090 FILE *fp_new = NULL;
1093 for (m = parts; m; m = m->next)
1094 {
1095 bool need_secured = false;
1096 bool secured = false;
1099 {
1100 need_secured = true;
1102 if (type & SEC_ENCRYPT)
1103 {
1105 goto decrypt_failed;
1107 if (e->env)
1109 }
1111 secured = (crypt_smime_decrypt_mime(fp, &fp_new, m, &new_body) == 0);
1112 /* If the decrypt/verify-opaque doesn't generate mime output, an empty
1113 * text/plain type will still be returned by mutt_read_mime_header().
1114 * We can't distinguish an actual part from a failure, so only use a
1115 * text/plain that results from a single top-level part. */
1116 if (secured && (new_body->type == TYPE_TEXT) &&
1117 mutt_istr_equal("plain", new_body->subtype) && ((parts != m) || m->next))
1118 {
1119 mutt_body_free(&new_body);
1120 mutt_file_fclose(&fp_new);
1121 goto decrypt_failed;
1122 }
1124 if (secured && (type & SEC_ENCRYPT))
1125 e->security |= SMIME_ENCRYPT;
1126 }
1128 if (((WithCrypto & APPLICATION_PGP) != 0) &&
1130 {
1131 need_secured = true;
1134 goto decrypt_failed;
1136 secured = (crypt_pgp_decrypt_mime(fp, &fp_new, m, &new_body) == 0);
1138 if (secured)
1139 e->security |= PGP_ENCRYPT;
1140 }
1142 if (need_secured && secured)
1143 {
1144 mutt_actx_add_fp(actx, fp_new);
1145 mutt_actx_add_body(actx, new_body);
1146 mutt_generate_recvattach_list(actx, e, new_body, fp_new, parent_type, level, 1);
1147 continue;
1148 }
1150 decrypt_failed:
1151 /* Fall through and show the original parts if decryption fails */
1152 if (need_secured && !secured)
1153 mutt_error(_("Can't decrypt encrypted message"));
1155 struct AttachPtr *ap = mutt_aptr_new();
1156 mutt_actx_add_attach(actx, ap);
1158 ap->body = m;
1159 ap->fp = fp;
1160 m->aptr = ap;
1162 ap->level = level;
1163 ap->decrypted = decrypted;
1165 if (mutt_is_message_type(m->type, m->subtype))
1166 {
1168 level + 1, decrypted);
1169 e->security |= m->email->security;
1170 }
1171 else
1172 {
1173 mutt_generate_recvattach_list(actx, e, m->parts, fp, m->type, level + 1, decrypted);
1174 }
1175 }
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:599
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:135
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:433
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:494
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:150
#define mutt_error(...)
Definition: logging2.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:1475
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:1084
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:155
+ 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 1207 of file recvattach.c.

1209 if (init)
1210 {
1211 mutt_generate_recvattach_list(actx, actx->email, actx->email->body,
1212 actx->fp_root, -1, 0, 0);
1213 mutt_attach_init(actx);
1214 }
1216 mutt_update_tree(actx);
1218 menu->max = actx->vcount;
1220 const int index = menu_get_index(menu);
1221 if (index >= menu->max)
1222 menu_set_index(menu, menu->max - 1);
Redraw the index.
Definition: lib.h:57
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:179
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:169
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
Definition: recvattach.c:1182
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition: recvattach.c:114
int max
Number of entries in the menu.
Definition: lib.h:72
+ 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 927 of file recvattach.c.

929 struct AttachPtr *cur_att = current_attachment(actx, menu);
930 if (!mutt_edit_content_type(e, cur_att->body, cur_att->fp))
931 return;
933 /* The mutt_update_recvattach_menu() will overwrite any changes
934 * made to a decrypted cur_att->body, so warn the user. */
935 if (cur_att->decrypted)
936 {
937 mutt_message(_("Structural changes to decrypted attachments are not supported"));
938 mutt_sleep(1);
939 }
940 /* Editing the content type can rewrite the body structure. */
941 for (int i = 0; i < actx->idxlen; i++)
942 actx->idx[i]->body = NULL;
944 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: external.c:1089
#define mutt_message(...)
Definition: logging2.h:86
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1424
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 1234 of file recvattach.c.

1236 if (!ba || !actx || !menu)
1237 return -1;
1239 if (menu->tag_prefix)
1240 {
1241 for (int i = 0; i < actx->idxlen; i++)
1242 {
1243 struct Body *b = actx->idx[i]->body;
1244 if (b->tagged)
1245 {
1246 ARRAY_ADD(ba, b);
1247 }
1248 }
1249 }
1250 else
1251 {
1252 struct AttachPtr *cur = current_attachment(actx, menu);
1253 if (!cur)
1254 return -1;
1256 ARRAY_ADD(ba, cur->body);
1257 }
1259 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:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function: