NeoMutt  2022-04-29-249-gaae397
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 (const struct Mailbox *m, struct Email *e, FILE *fp)
 Count the MIME Body parts. More...
 
void mutt_parse_mime_message (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.

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 105 of file attachments.c.

106{
108 return;
109
112}
static struct Notify * AttachmentsNotify
Definition: attachments.c:59
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:60
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:93
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
+ 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 91 of file attachments.c.

92{
94
95 /* Lists of AttachMatch */
100}
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: attachments.c:55
struct ListHead InlineExclude
List of inline types to ignore.
Definition: attachments.c:58
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: attachments.c:56
struct ListHead InlineAllow
List of inline types to counted.
Definition: attachments.c:57
static void attachmatch_free(struct AttachMatch **ptr)
Free an AttachMatch - Implements list_free_t -.
Definition: attachments.c:68
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:73
+ 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 285 of file attachments.c.

286{
287 if (!m)
288 return;
289
290 for (int i = 0; i < m->msg_count; i++)
291 {
292 struct Email *e = m->emails[i];
293 if (!e)
294 break;
295 e->attach_valid = false;
296 e->attach_total = 0;
297 }
298}
The envelope/body of an email.
Definition: email.h:37
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
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 251 of file attachments.c.

252{
253 if (!m || !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 e->attach_total = 0;
273
274 e->attach_valid = true;
275
276 if (!keep_parts)
278
279 return e->attach_total;
280}
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:591
static int count_body_parts(struct Body *body)
Count the MIME Body parts.
Definition: attachments.c:156
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
#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:67
+ 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 591 of file attachments.c.

592{
593 const bool right_type = (e->body->type == TYPE_MESSAGE) ||
594 (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}
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition: crypt.c:675
@ TYPE_MESSAGE
Type: 'message/*'.
Definition: mime.h:35
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
#define WithCrypto
Definition: lib.h:116
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1736
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:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function: