NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
commands.h File Reference

Handle the attachments command. More...

#include <stdio.h>
#include "core/lib.h"
+ Include dependency graph for commands.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  NotifyAttach { NT_ATTACH_ADD = 1 , NT_ATTACH_DELETE , NT_ATTACH_DELETE_ALL }
 Attachments notification types. More...
 

Functions

void mutt_attachments_reset (struct MailboxView *mv)
 Reset the attachment count for all Emails.
 
int mutt_count_body_parts (struct Email *e, FILE *fp)
 Count the MIME Body parts.
 
void mutt_parse_mime_message (struct Email *e, FILE *fp)
 Parse a MIME email.
 
struct AttachMatchattachmatch_new (void)
 Create a new AttachMatch.
 
void attachmatch_free (struct AttachMatch **ptr)
 Free an AttachMatch - Implements list_free_t -.
 
enum CommandResult parse_mime_lookup (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'mime-lookup' command - Implements Command::parse() -.
 
enum CommandResult parse_unmime_lookup (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unmime-lookup' command - Implements Command::parse() -.
 

Detailed Description

Handle the attachments command.

Authors
  • Richard Russon

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 http://www.gnu.org/licenses/.

Definition in file commands.h.

Enumeration Type Documentation

◆ NotifyAttach

Attachments notification types.

Observers of NT_ATTACH will not be passed any Event data.

Note
Notifications are sent after the event.
Enumerator
NT_ATTACH_ADD 

Attachment regex has been added.

NT_ATTACH_DELETE 

Attachment regex has been deleted.

NT_ATTACH_DELETE_ALL 

All Attachment regexes have been deleted.

Definition at line 42 of file commands.h.

43{
44 NT_ATTACH_ADD = 1,
47};
@ NT_ATTACH_DELETE
Attachment regex has been deleted.
Definition commands.h:45
@ NT_ATTACH_DELETE_ALL
All Attachment regexes have been deleted.
Definition commands.h:46
@ NT_ATTACH_ADD
Attachment regex has been added.
Definition commands.h:44

Function Documentation

◆ mutt_attachments_reset()

void mutt_attachments_reset ( struct MailboxView * mv)

Reset the attachment count for all Emails.

Parameters
mvMailbox view

Definition at line 266 of file commands.c.

267{
268 if (!mv || !mv->mailbox)
269 return;
270
271 struct Mailbox *m = mv->mailbox;
272
273 for (int i = 0; i < m->msg_count; i++)
274 {
275 struct Email *e = m->emails[i];
276 if (!e)
277 break;
278 e->attach_valid = false;
279 e->attach_total = 0;
280 }
281}
The envelope/body of an email.
Definition email.h:39
bool attach_valid
true when the attachment count is valid
Definition email.h:100
short attach_total
Number of qualifying attachments in message, if attach_valid.
Definition email.h:115
struct Mailbox * mailbox
Current Mailbox.
Definition mview.h:51
A mailbox.
Definition mailbox.h:78
int msg_count
Total number of messages.
Definition mailbox.h:87
struct Email ** emails
Array of Emails.
Definition mailbox.h:95
+ Here is the caller graph for this function:

◆ mutt_count_body_parts()

int mutt_count_body_parts ( struct Email * e,
FILE * fp )

Count the MIME Body parts.

Parameters
eEmail
fpFile to parse
Return values
numNumber of MIME Body parts

Definition at line 226 of file commands.c.

227{
228 if (!e)
229 return 0;
230
232 ASSERT(md);
233
234 bool keep_parts = false;
235
236 if (e->attach_valid)
237 return e->attach_total;
238
239 if (e->body->parts)
240 keep_parts = true;
241 else
243
246 {
248 }
249 else
250 {
251 e->attach_total = 0;
252 }
253
254 e->attach_valid = true;
255
256 if (!keep_parts)
258
259 return e->attach_total;
260}
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition commands.c:627
static int count_body_parts(struct Body *b, int depth)
Count the MIME Body parts.
Definition commands.c:129
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition body.c:58
@ MODULE_ID_ATTACH
ModuleAttach, Attachments
Definition module_api.h:49
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:585
#define STAILQ_EMPTY(head)
Definition queue.h:382
#define ASSERT(COND)
Definition signal2.h:59
Attach private Module data.
Definition module_data.h:32
struct ListHead attach_allow
List of attachment types to be counted.
Definition module_data.h:33
struct ListHead attach_exclude
List of attachment types to be ignored.
Definition module_data.h:34
struct ListHead inline_allow
List of inline types to counted.
Definition module_data.h:35
struct ListHead inline_exclude
List of inline types to ignore.
Definition module_data.h:36
struct Body * parts
parts of a multipart or message/rfc822
Definition body.h:73
struct Body * body
List of MIME parts.
Definition email.h:69
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_parse_mime_message()

void mutt_parse_mime_message ( struct Email * e,
FILE * fp )

Parse a MIME email.

Parameters
eEmail
fpFile to parse

Definition at line 627 of file commands.c.

628{
629 const bool right_type = (e->body->type == TYPE_MESSAGE) ||
630 (e->body->type == TYPE_MULTIPART);
631 const bool not_parsed = (e->body->parts == NULL);
632
633 if (right_type && fp && not_parsed)
634 {
635 mutt_parse_part(fp, e->body);
636 if (WithCrypto)
637 {
638 e->security = crypt_query(e->body);
639 }
640 }
641
642 e->attach_valid = false;
643}
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition crypt.c:687
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition parse.c:1833
@ TYPE_MESSAGE
Type: 'message/*'.
Definition mime.h:35
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition mime.h:37
#define WithCrypto
Definition lib.h:124
unsigned int type
content-type primary type, ContentType
Definition body.h:40
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition email.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attachmatch_new()

struct AttachMatch * attachmatch_new ( void )

Create a new AttachMatch.

Return values
ptrNew AttachMatch

Definition at line 78 of file commands.c.

79{
80 return MUTT_MEM_CALLOC(1, struct AttachMatch);
81}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
An attachment matching a regex for attachment counter.
Definition commands.c:49
+ Here is the caller graph for this function: