NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
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. More...
 
void attach_free (void)
 Free the attachments lists. More...
 
void mutt_attachments_reset (struct Mailbox *m)
 Reset the attachment count for all Emails. More...
 
int mutt_count_body_parts (struct Mailbox *m, struct Email *e, FILE *fp)
 Count the MIME Body parts. More...
 
void mutt_parse_mime_message (struct Mailbox *m, struct Email *e, FILE *fp)
 Parse a MIME email. More...
 

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.

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

37 {
38  NT_ATTACH_ADD = 1,
41 };
All Attachment regexes have been deleted.
Definition: attachments.h:40
Attachment regex has been deleted.
Definition: attachments.h:39
Attachment regex has been added.
Definition: attachments.h:38

Function Documentation

◆ attach_init()

void attach_init ( void  )

Set up the attachments lists.

Definition at line 106 of file attachments.c.

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

◆ attach_free()

void attach_free ( void  )

Free the attachments lists.

Definition at line 92 of file attachments.c.

93 {
95 
96  /* Lists of AttachMatch */
101 }
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 notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:73
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition: list.c:144
static struct Notify * AttachmentsNotify
Definition: attachments.c:60
struct ListHead InlineExclude
List of inline types to ignore.
Definition: attachments.c:59
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: attachments.c:57
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: attachments.c:56
void(* list_free_t)(void **ptr)
Prototype for a function to free List data.
Definition: list.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_attachments_reset()

void mutt_attachments_reset ( struct Mailbox m)

Reset the attachment count for all Emails.

Definition at line 287 of file attachments.c.

288 {
289  if (!m)
290  return;
291 
292  for (int i = 0; i < m->msg_count; i++)
293  {
294  struct Email *e = m->emails[i];
295  if (!e)
296  break;
297  e->attach_valid = false;
298  e->attach_total = 0;
299  }
300 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
int msg_count
Total number of messages.
Definition: mailbox.h:91
The envelope/body of an email.
Definition: email.h:37
short attach_total
Number of qualifying attachments in message, if attach_valid.
Definition: email.h:97
bool attach_valid
true when the attachment count is valid
Definition: email.h:70
+ Here is the caller graph for this function:

◆ mutt_count_body_parts()

int mutt_count_body_parts ( 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 253 of file attachments.c.

254 {
255  if (!m || !e)
256  return 0;
257 
258  bool keep_parts = false;
259 
260  if (e->attach_valid)
261  return e->attach_total;
262 
263  if (e->body->parts)
264  keep_parts = true;
265  else
266  mutt_parse_mime_message(m, e, fp);
267 
270  {
272  }
273  else
274  e->attach_total = 0;
275 
276  e->attach_valid = true;
277 
278  if (!keep_parts)
279  mutt_body_free(&e->body->parts);
280 
281  return e->attach_total;
282 }
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:591
struct ListHead InlineAllow
List of inline types to counted.
Definition: attachments.c:58
struct Body * body
List of MIME parts.
Definition: email.h:91
static int count_body_parts(struct Body *body)
Count the MIME Body parts.
Definition: attachments.c:157
short attach_total
Number of qualifying attachments in message, if attach_valid.
Definition: email.h:97
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
bool attach_valid
true when the attachment count is valid
Definition: email.h:70
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
struct ListHead InlineExclude
List of inline types to ignore.
Definition: attachments.c:59
#define STAILQ_EMPTY(head)
Definition: queue.h:348
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: attachments.c:57
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: attachments.c:56
+ 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 Mailbox m,
struct Email e,
FILE *  fp 
)

Parse a MIME email.

Parameters
mMailbox
eEmail
fpFile to parse

Definition at line 591 of file attachments.c.

592 {
593  const bool right_type =
594  (e->body->type == TYPE_MESSAGE) || (e->body->type == TYPE_MULTIPART);
595  const bool not_parsed = (e->body->parts == NULL);
596 
597  if (right_type && fp && not_parsed)
598  {
599  mutt_parse_part(fp, e->body);
600  if (WithCrypto)
601  {
602  e->security = crypt_query(e->body);
603  }
604  }
605 
606  e->attach_valid = false;
607 }
#define WithCrypto
Definition: lib.h:113
struct Body * body
List of MIME parts.
Definition: email.h:91
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
bool attach_valid
true when the attachment count is valid
Definition: email.h:70
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
unsigned int type
content-type primary type, ContentType
Definition: body.h:65
Type: &#39;message/*&#39;.
Definition: mime.h:35
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1678
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition: crypt.c:698
+ Here is the call graph for this function:
+ Here is the caller graph for this function: