NeoMutt  2020-06-26-89-g172cd3
Teaching an old dog new tricks
DOXYGEN
mutt_parse.h File Reference

Miscellaneous email parsing routines. More...

#include "mutt/lib.h"
#include "email/lib.h"
+ Include dependency graph for mutt_parse.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  AttachMatch
 An attachment matching a regex for attachment counter. More...
 

Functions

int mutt_count_body_parts (struct Mailbox *m, struct Email *e)
 Count the MIME Body parts. More...
 
void mutt_parse_mime_message (struct Mailbox *m, struct Email *e)
 Parse a MIME email. More...
 
void mutt_attachmatch_free (struct AttachMatch **ptr)
 Free an AttachMatch - Implements list_free_t. More...
 

Variables

struct ListHead AttachAllow
 List of attachment types to be counted. More...
 
struct ListHead AttachExclude
 List of attachment types to be ignored. More...
 
struct ListHead InlineAllow
 List of inline types to counted. More...
 
struct ListHead InlineExclude
 List of inline types to ignore. 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 mutt_parse.h.

Function Documentation

◆ mutt_count_body_parts()

int mutt_count_body_parts ( struct Mailbox m,
struct Email e 
)

Count the MIME Body parts.

Parameters
mMailbox
eEmail
Return values
numNumber of MIME Body parts

Definition at line 205 of file mutt_parse.c.

206 {
207  bool keep_parts = false;
208 
209  if (e->attach_valid)
210  return e->attach_total;
211 
212  if (e->content->parts)
213  keep_parts = true;
214  else
216 
219  {
221  }
222  else
223  e->attach_total = 0;
224 
225  e->attach_valid = true;
226 
227  if (!keep_parts)
229 
230  return e->attach_total;
231 }
struct ListHead InlineAllow
List of inline types to counted.
Definition: mutt_parse.c:40
struct Body * content
List of MIME parts.
Definition: email.h:90
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:48
static int count_body_parts(struct Body *body)
Count the MIME Body parts.
Definition: mutt_parse.c:116
short attach_total
Number of qualifying attachments in message, if attach_valid.
Definition: email.h:96
struct ListHead InlineExclude
List of inline types to ignore.
Definition: mutt_parse.c:41
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 AttachExclude
List of attachment types to be ignored.
Definition: mutt_parse.c:39
#define STAILQ_EMPTY(head)
Definition: queue.h:345
struct ListHead AttachAllow
List of attachment types to be counted.
Definition: mutt_parse.c:38
+ 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 
)

Parse a MIME email.

Parameters
mMailbox
eEmail

Definition at line 48 of file mutt_parse.c.

49 {
50  do
51  {
52  if ((e->content->type != TYPE_MESSAGE) && (e->content->type != TYPE_MULTIPART))
53  break; /* nothing to do */
54 
55  if (e->content->parts)
56  break; /* The message was parsed earlier. */
57 
58  struct Message *msg = mx_msg_open(m, e->msgno);
59  if (msg)
60  {
61  mutt_parse_part(msg->fp, e->content);
62 
63  if (WithCrypto)
64  e->security = crypt_query(e->content);
65 
66  mx_msg_close(m, &msg);
67  }
68  } while (false);
69 
70  e->attach_valid = false;
71 }
#define WithCrypto
Definition: lib.h:118
struct Body * content
List of MIME parts.
Definition: email.h:90
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1180
A local copy of an email.
Definition: mx.h:83
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: 'message/*'.
Definition: mime.h:35
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1375
Type: 'multipart/*'.
Definition: mime.h:37
FILE * fp
pointer to the message data
Definition: mx.h:85
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:683
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1132
int msgno
Number displayed to the user.
Definition: email.h:86
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_attachmatch_free()

void mutt_attachmatch_free ( struct AttachMatch **  ptr)

Free an AttachMatch - Implements list_free_t.

Parameters
ptrAttachMatch to free
Note
We don't free minor because it is either a pointer into major, or a static string.

Definition at line 240 of file mutt_parse.c.

241 {
242  if (!ptr || !*ptr)
243  return;
244 
245  struct AttachMatch *am = *ptr;
246  regfree(&am->minor_regex);
247  FREE(&am->major);
248  FREE(ptr);
249 }
const char * major
Definition: mutt_parse.h:36
regex_t minor_regex
Definition: mutt_parse.h:39
#define FREE(x)
Definition: memory.h:40
An attachment matching a regex for attachment counter.
Definition: mutt_parse.h:34
+ Here is the caller graph for this function:

Variable Documentation

◆ AttachAllow

struct ListHead AttachAllow

List of attachment types to be counted.

Definition at line 38 of file mutt_parse.c.

◆ AttachExclude

struct ListHead AttachExclude

List of attachment types to be ignored.

Definition at line 39 of file mutt_parse.c.

◆ InlineAllow

struct ListHead InlineAllow

List of inline types to counted.

Definition at line 40 of file mutt_parse.c.

◆ InlineExclude

struct ListHead InlineExclude

List of inline types to ignore.

Definition at line 41 of file mutt_parse.c.