NeoMutt  2023-03-22-27-g3cb248
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 104 of file attachments.c.

105{
107 return;
108
111}
static struct Notify * AttachmentsNotify
Definition: attachments.c:58
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 90 of file attachments.c.

91{
93
94 /* Lists of AttachMatch */
99}
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: attachments.c:54
struct ListHead InlineExclude
List of inline types to ignore.
Definition: attachments.c:57
struct ListHead AttachExclude
List of attachment types to be ignored.
Definition: attachments.c:55
struct ListHead InlineAllow
List of inline types to counted.
Definition: attachments.c:56
static void attachmatch_free(struct AttachMatch **ptr)
Free an AttachMatch - Implements list_free_t -.
Definition: attachments.c:67
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 286 of file attachments.c.

287{
288 if (!m)
289 return;
290
291 for (int i = 0; i < m->msg_count; i++)
292 {
293 struct Email *e = m->emails[i];
294 if (!e)
295 break;
296 e->attach_valid = false;
297 e->attach_total = 0;
298 }
299}
The envelope/body of an email.
Definition: email.h:37
bool attach_valid
true when the attachment count is valid
Definition: email.h:99
short attach_total
Number of qualifying attachments in message, if attach_valid.
Definition: email.h:114
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 250 of file attachments.c.

251{
252 if (!m || !e)
253 return 0;
254
255 bool keep_parts = false;
256
257 if (e->attach_valid)
258 return e->attach_total;
259
260 if (e->body->parts)
261 keep_parts = true;
262 else
264
267 {
269 }
270 else
271 {
272 e->attach_total = 0;
273 }
274
275 e->attach_valid = true;
276
277 if (!keep_parts)
279
280 return e->attach_total;
281}
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:592
static int count_body_parts(struct Body *body)
Count the MIME Body parts.
Definition: attachments.c:155
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 592 of file attachments.c.

593{
594 const bool right_type = (e->body->type == TYPE_MESSAGE) ||
595 (e->body->type == TYPE_MULTIPART);
596 const bool not_parsed = (e->body->parts == NULL);
597
598 if (right_type && fp && not_parsed)
599 {
600 mutt_parse_part(fp, e->body);
601 if (WithCrypto)
602 {
603 e->security = crypt_query(e->body);
604 }
605 }
606
607 e->attach_valid = false;
608}
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition: crypt.c:672
@ 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:1745
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: