NeoMutt  2024-04-16-36-g75b6fb
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 (const struct Mailbox *m, 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 39 of file attachments.h.

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

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:41
struct Notify * notify
Notifications handler.
Definition: neomutt.h:42
+ 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:48
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 289 of file attachments.c.

290{
291 if (!mv || !mv->mailbox)
292 return;
293
294 struct Mailbox *m = mv->mailbox;
295
296 for (int i = 0; i < m->msg_count; i++)
297 {
298 struct Email *e = m->emails[i];
299 if (!e)
300 break;
301 e->attach_valid = false;
302 e->attach_total = 0;
303 }
304}
The envelope/body of an email.
Definition: email.h:39
bool attach_valid
true when the attachment count is valid
Definition: email.h:103
short attach_total
Number of qualifying attachments in message, if attach_valid.
Definition: email.h:118
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 ( const struct Mailbox m,
struct Email e,
FILE *  fp 
)

Count the MIME Body parts.

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

Definition at line 252 of file attachments.c.

253{
254 if (!m || !e)
255 return 0;
256
257 bool keep_parts = false;
258
259 if (e->attach_valid)
260 return e->attach_total;
261
262 if (e->body->parts)
263 keep_parts = true;
264 else
266
269 {
271 }
272 else
273 {
274 e->attach_total = 0;
275 }
276
277 e->attach_valid = true;
278
279 if (!keep_parts)
281
282 return e->attach_total;
283}
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:597
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:72
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 597 of file attachments.c.

598{
599 const bool right_type = (e->body->type == TYPE_MESSAGE) ||
600 (e->body->type == TYPE_MULTIPART);
601 const bool not_parsed = (e->body->parts == NULL);
602
603 if (right_type && fp && not_parsed)
604 {
605 mutt_parse_part(fp, e->body);
606 if (WithCrypto)
607 {
608 e->security = crypt_query(e->body);
609 }
610 }
611
612 e->attach_valid = false;
613}
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition: crypt.c:673
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1817
@ TYPE_MESSAGE
Type: 'message/*'.
Definition: mime.h:35
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
#define WithCrypto
Definition: lib.h:116
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: