NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
attachments.h File Reference

Miscellaneous email parsing routines. More...

#include <stdio.h>
+ Include dependency graph for attachments.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 attach_init (void)
 Set up the attachments lists.
 
void attach_cleanup (void)
 Free the attachments lists.
 
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.
 

Detailed Description

Miscellaneous email parsing routines.

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 attachments.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 38 of file attachments.h.

39{
40 NT_ATTACH_ADD = 1,
43};
@ NT_ATTACH_DELETE
Attachment regex has been deleted.
Definition: attachments.h:41
@ NT_ATTACH_DELETE_ALL
All Attachment regexes have been deleted.
Definition: attachments.h:42
@ NT_ATTACH_ADD
Attachment regex has been added.
Definition: attachments.h:40

Function Documentation

◆ attach_init()

void attach_init ( void  )

Set up the attachments lists.

Definition at line 106 of file attachments.c.

107{
109 return;
110
113}
static struct Notify * AttachmentsNotify
Notifications: NotifyAttach.
Definition: attachments.c:60
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:95
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct Notify * notify
Notifications handler.
Definition: neomutt.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attach_cleanup()

void attach_cleanup ( void  )

Free the attachments lists.

Definition at line 92 of file attachments.c.

93{
95
96 /* Lists of AttachMatch */
101}
static struct ListHead AttachAllow
List of attachment types to be counted.
Definition: attachments.c:56
static struct ListHead InlineExclude
List of inline types to ignore.
Definition: attachments.c:59
static struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: attachments.c:57
static struct ListHead InlineAllow
List of inline types to counted.
Definition: attachments.c:58
static void attachmatch_free(struct AttachMatch **ptr)
Free an AttachMatch - Implements list_free_t -.
Definition: attachments.c:69
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition: list.c:144
void(* list_free_t)(void **ptr)
Definition: list.h:50
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_attachments_reset()

void mutt_attachments_reset ( struct MailboxView mv)

Reset the attachment count for all Emails.

Parameters
mvMailbox view

Definition at line 288 of file attachments.c.

289{
290 if (!mv || !mv->mailbox)
291 return;
292
293 struct Mailbox *m = mv->mailbox;
294
295 for (int i = 0; i < m->msg_count; i++)
296 {
297 struct Email *e = m->emails[i];
298 if (!e)
299 break;
300 e->attach_valid = false;
301 e->attach_total = 0;
302 }
303}
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:79
int msg_count
Total number of messages.
Definition: mailbox.h:88
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
+ 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 251 of file attachments.c.

252{
253 if (!e)
254 return 0;
255
256 bool keep_parts = false;
257
258 if (e->attach_valid)
259 return e->attach_total;
260
261 if (e->body->parts)
262 keep_parts = true;
263 else
265
268 {
270 }
271 else
272 {
273 e->attach_total = 0;
274 }
275
276 e->attach_valid = true;
277
278 if (!keep_parts)
280
281 return e->attach_total;
282}
static int count_body_parts(struct Body *b)
Count the MIME Body parts.
Definition: attachments.c:157
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:596
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:58
#define STAILQ_EMPTY(head)
Definition: queue.h:348
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
+ 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 596 of file attachments.c.

597{
598 const bool right_type = (e->body->type == TYPE_MESSAGE) ||
599 (e->body->type == TYPE_MULTIPART);
600 const bool not_parsed = (e->body->parts == NULL);
601
602 if (right_type && fp && not_parsed)
603 {
604 mutt_parse_part(fp, e->body);
605 if (WithCrypto)
606 {
607 e->security = crypt_query(e->body);
608 }
609 }
610
611 e->attach_valid = false;
612}
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:1822
@ TYPE_MESSAGE
Type: 'message/*'.
Definition: mime.h:35
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
#define WithCrypto
Definition: lib.h:122
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: