NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
DOXYGEN
email.c File Reference

Representation of an email. More...

#include "config.h"
#include <stdbool.h>
#include "mutt/mutt.h"
#include "email.h"
#include "body.h"
#include "envelope.h"
#include "tags.h"
+ Include dependency graph for email.c:

Go to the source code of this file.

Functions

void email_free (struct Email **ptr)
 Free an Email. More...
 
struct Emailemail_new (void)
 Create a new Email. More...
 
bool email_cmp_strict (const struct Email *e1, const struct Email *e2)
 Strictly compare message emails. More...
 
size_t email_size (const struct Email *e)
 compute the size of an email More...
 
void emaillist_clear (struct EmailList *el)
 Drop a private list of Emails. More...
 

Detailed Description

Representation of an email.

Authors
  • Michael R. Elkins

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 email.c.

Function Documentation

◆ email_free()

void email_free ( struct Email **  ptr)

Free an Email.

Parameters
[out]ptrEmail to free

Definition at line 41 of file email.c.

42 {
43  if (!ptr || !*ptr)
44  return;
45 
46  struct Email *e = *ptr;
47 
48  if (e->edata && e->free_edata)
49  e->free_edata(&e->edata);
50 
51  mutt_env_free(&e->env);
53  FREE(&e->maildir_flags);
54  FREE(&e->tree);
55  FREE(&e->path);
56 #ifdef MIXMASTER
57  mutt_list_free(&e->chain);
58 #endif
60 
61  FREE(ptr);
62 }
void(* free_edata)(void **)
Driver-specific data free function.
Definition: email.h:113
The envelope/body of an email.
Definition: email.h:39
struct Body * content
List of MIME parts.
Definition: email.h:92
void driver_tags_free(struct TagList *list)
Free tags from a header.
Definition: tags.c:103
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
struct Envelope * env
Envelope information.
Definition: email.h:91
struct TagList tags
For drivers that support server tagging.
Definition: email.h:108
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
char * tree
Character string to print thread tree.
Definition: email.h:95
void * edata
Driver-specific data.
Definition: email.h:112
char * maildir_flags
Unknown maildir flags.
Definition: email.h:110
char * path
Path of Email (for local Mailboxes)
Definition: email.h:93
#define FREE(x)
Definition: memory.h:40
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ email_new()

struct Email* email_new ( void  )

Create a new Email.

Return values
ptrNewly created Email

Definition at line 68 of file email.c.

69 {
70  struct Email *e = mutt_mem_calloc(1, sizeof(struct Email));
71 #ifdef MIXMASTER
72  STAILQ_INIT(&e->chain);
73 #endif
74  STAILQ_INIT(&e->tags);
75  return e;
76 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
The envelope/body of an email.
Definition: email.h:39
#define STAILQ_INIT(head)
Definition: queue.h:370
struct TagList tags
For drivers that support server tagging.
Definition: email.h:108
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ email_cmp_strict()

bool email_cmp_strict ( const struct Email e1,
const struct Email e2 
)

Strictly compare message emails.

Parameters
e1First Email
e2Second Email
Return values
trueEmails are strictly identical

Definition at line 84 of file email.c.

85 {
86  if (e1 && e2)
87  {
88  if ((e1->received != e2->received) || (e1->date_sent != e2->date_sent) ||
89  (e1->content->length != e2->content->length) ||
90  (e1->lines != e2->lines) || (e1->zhours != e2->zhours) ||
91  (e1->zminutes != e2->zminutes) || (e1->zoccident != e2->zoccident) ||
92  (e1->mime != e2->mime) || !mutt_env_cmp_strict(e1->env, e2->env) ||
94  {
95  return false;
96  }
97  else
98  return true;
99  }
100  else
101  {
102  if (!e1 && !e2)
103  return true;
104  else
105  return false;
106  }
107 }
int lines
How many lines in the body of this message?
Definition: email.h:86
struct Body * content
List of MIME parts.
Definition: email.h:92
bool mutt_env_cmp_strict(const struct Envelope *e1, const struct Envelope *e2)
Strictly compare two Envelopes.
Definition: envelope.c:241
bool zoccident
True, if west of UTC, False if east.
Definition: email.h:67
bool mutt_body_cmp_strict(const struct Body *b1, const struct Body *b2)
Strictly compare two email Body&#39;s.
Definition: body.c:108
bool mime
Has a MIME-Version header?
Definition: email.h:44
struct Envelope * env
Envelope information.
Definition: email.h:91
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:83
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
unsigned int zhours
Hours away from UTC.
Definition: email.h:65
unsigned int zminutes
Minutes away from UTC.
Definition: email.h:66
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ email_size()

size_t email_size ( const struct Email e)

compute the size of an email

Parameters
eEmail
Return values
numSize of the email, in bytes

Definition at line 114 of file email.c.

115 {
116  if (!e || !e->content)
117  return 0;
118  return e->content->length + e->content->offset - e->content->hdr_offset;
119 }
struct Body * content
List of MIME parts.
Definition: email.h:92
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
long hdr_offset
Offset in stream where the headers begin.
Definition: body.h:42
+ Here is the caller graph for this function:

◆ emaillist_clear()

void emaillist_clear ( struct EmailList *  el)

Drop a private list of Emails.

Parameters
elEmailList to empty

The Emails are not freed.

Definition at line 127 of file email.c.

128 {
129  if (!el)
130  return;
131 
132  struct EmailNode *en = NULL, *tmp = NULL;
133  STAILQ_FOREACH_SAFE(en, el, entries, tmp)
134  {
135  STAILQ_REMOVE(el, en, EmailNode, entries);
136  FREE(&en);
137  }
138  STAILQ_INIT(el);
139 }
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:400
#define STAILQ_INIT(head)
Definition: queue.h:370
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:360
#define FREE(x)
Definition: memory.h:40
List of Emails.
Definition: email.h:120
+ Here is the caller graph for this function: