NeoMutt  2025-12-11-980-ge38c27
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
body.h File Reference

Representation of the body of an email. More...

#include "config.h"
#include <stdbool.h>
#include <time.h>
#include "mutt/lib.h"
#include "parameter.h"
+ Include dependency graph for body.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Body
 The body of an email. More...
 

Enumerations

enum  ExpandoDataBody {
  ED_BOD_ATTACH_COUNT = 1 , ED_BOD_ATTACH_QUALIFIES , ED_BOD_CHARSET_CONVERT , ED_BOD_DELETED ,
  ED_BOD_DESCRIPTION , ED_BOD_DISPOSITION , ED_BOD_FILE , ED_BOD_FILE_DISPOSITION ,
  ED_BOD_FILE_SIZE , ED_BOD_MIME_ENCODING , ED_BOD_MIME_MAJOR , ED_BOD_MIME_MINOR ,
  ED_BOD_TAGGED , ED_BOD_UNLINK
}
 Expando UIDs for Bodies. More...
 

Functions

 ARRAY_HEAD (BodyArray, struct Body *)
 
bool mutt_body_cmp_strict (const struct Body *b1, const struct Body *b2)
 Strictly compare two email Body's.
 
void mutt_body_free (struct Body **ptr)
 Free a Body.
 
char * mutt_body_get_charset (struct Body *b, char *buf, size_t buflen)
 Get a body's character set.
 
struct Bodymutt_body_new (void)
 Create a new Body.
 

Detailed Description

Representation of the body of an email.

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 body.h.

Enumeration Type Documentation

◆ ExpandoDataBody

Expando UIDs for Bodies.

See also
ED_BODY, ExpandoDomain
Enumerator
ED_BOD_ATTACH_COUNT 

Body.attach_count.

ED_BOD_ATTACH_QUALIFIES 

Body.attach_qualifies.

ED_BOD_CHARSET_CONVERT 

Body.type.

ED_BOD_DELETED 

Body.deleted.

ED_BOD_DESCRIPTION 

Body.description.

ED_BOD_DISPOSITION 

Body.disposition.

ED_BOD_FILE 

Body.filename.

ED_BOD_FILE_DISPOSITION 

Body.d_filename.

ED_BOD_FILE_SIZE 

Body.filename.

ED_BOD_MIME_ENCODING 

Body.encoding.

ED_BOD_MIME_MAJOR 

Body.type, Body.xtype.

ED_BOD_MIME_MINOR 

Body.subtype.

ED_BOD_TAGGED 

Body.tagged.

ED_BOD_UNLINK 

Body.unlink.

Definition at line 100 of file body.h.

101{
116};
@ ED_BOD_DESCRIPTION
Body.description.
Definition body.h:106
@ ED_BOD_CHARSET_CONVERT
Body.type.
Definition body.h:104
@ ED_BOD_DELETED
Body.deleted.
Definition body.h:105
@ ED_BOD_UNLINK
Body.unlink.
Definition body.h:115
@ ED_BOD_FILE_SIZE
Body.filename.
Definition body.h:110
@ ED_BOD_DISPOSITION
Body.disposition.
Definition body.h:107
@ ED_BOD_ATTACH_QUALIFIES
Body.attach_qualifies.
Definition body.h:103
@ ED_BOD_MIME_MAJOR
Body.type, Body.xtype.
Definition body.h:112
@ ED_BOD_TAGGED
Body.tagged.
Definition body.h:114
@ ED_BOD_ATTACH_COUNT
Body.attach_count.
Definition body.h:102
@ ED_BOD_FILE
Body.filename.
Definition body.h:108
@ ED_BOD_MIME_MINOR
Body.subtype.
Definition body.h:113
@ ED_BOD_FILE_DISPOSITION
Body.d_filename.
Definition body.h:109
@ ED_BOD_MIME_ENCODING
Body.encoding.
Definition body.h:111

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( BodyArray ,
struct Body *  )

◆ mutt_body_cmp_strict()

bool mutt_body_cmp_strict ( const struct Body * b1,
const struct Body * b2 )

Strictly compare two email Body's.

Parameters
b1First Body
b2Second Body
Return values
trueBody's are strictly identical

Definition at line 111 of file body.c.

112{
113 if (!b1 || !b2)
114 return false;
115
116 if ((b1->type != b2->type) || (b1->encoding != b2->encoding) ||
117 !mutt_str_equal(b1->subtype, b2->subtype) ||
119 !mutt_param_cmp_strict(&b1->parameter, &b2->parameter) || (b1->length != b2->length))
120 {
121 return false;
122 }
123 return true;
124}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:666
bool mutt_param_cmp_strict(const struct ParameterList *pl1, const struct ParameterList *pl2)
Strictly compare two ParameterLists.
Definition parameter.c:166
LOFF_T length
length (in bytes) of attachment
Definition body.h:53
struct ParameterList parameter
Parameters of the content-type.
Definition body.h:63
char * description
content-description
Definition body.h:55
char * subtype
content-type subtype
Definition body.h:61
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition body.h:41
unsigned int type
content-type primary type, ContentType
Definition body.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_body_free()

void mutt_body_free ( struct Body ** ptr)

Free a Body.

Parameters
[out]ptrBody to free

Definition at line 58 of file body.c.

59{
60 if (!ptr || !*ptr)
61 return;
62
63 struct Body *a = *ptr;
64 struct Body *b = NULL;
65
66 while (a)
67 {
68 b = a;
69 a = a->next;
70
72 if (b->filename)
73 {
74 if (b->unlink)
75 unlink(b->filename);
76 mutt_debug(LL_DEBUG1, "%sunlinking %s\n", b->unlink ? "" : "not ", b->filename);
77 }
78
79 FREE(&b->content_id);
80 FREE(&b->filename);
81 FREE(&b->d_filename);
82 FREE(&b->charset);
83 FREE(&b->content);
84 FREE(&b->xtype);
85 FREE(&b->subtype);
86 FREE(&b->language);
87 FREE(&b->description);
88 FREE(&b->form_name);
89
90 if (b->email)
91 {
92 /* Don't free twice (b->email->body = b->parts) */
93 b->email->body = NULL;
94 email_free(&b->email);
95 }
96
99 FREE(&b);
100 }
101
102 *ptr = NULL;
103}
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition body.c:58
void email_free(struct Email **ptr)
Free an Email.
Definition email.c:46
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition envelope.c:125
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void mutt_param_free(struct ParameterList *pl)
Free a ParameterList.
Definition parameter.c:62
The body of an email.
Definition body.h:36
char * language
content-language (RFC8255)
Definition body.h:78
char * content_id
Content-Id (RFC2392)
Definition body.h:58
char * d_filename
filename to be used for the content-disposition header If NULL, filename is used instead.
Definition body.h:56
struct Body * parts
parts of a multipart or message/rfc822
Definition body.h:73
char * xtype
content-type if x-unknown
Definition body.h:62
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition body.h:68
struct Envelope * mime_headers
Memory hole protected headers.
Definition body.h:76
char * charset
Send mode: charset of attached file as stored on disk.
Definition body.h:79
struct Email * email
header information for message/rfc822
Definition body.h:74
struct Content * content
Detailed info about the content of the attachment.
Definition body.h:70
struct Body * next
next attachment in the list
Definition body.h:72
char * form_name
Content-Disposition form-data name param.
Definition body.h:60
char * filename
When sending a message, this is the file to which this structure refers.
Definition body.h:59
struct Body * body
List of MIME parts.
Definition email.h:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_body_get_charset()

char * mutt_body_get_charset ( struct Body * b,
char * buf,
size_t buflen )

Get a body's character set.

Parameters
bBody to examine
bufBuffer for the result
buflenLength of the buffer
Return values
ptrBuffer containing character set
NULLOn error, or if not a text type

Definition at line 134 of file body.c.

135{
136 char *p = NULL;
137
138 if (b && (b->type != TYPE_TEXT))
139 return NULL;
140
141 if (b)
142 p = mutt_param_get(&b->parameter, "charset");
143
144 if (p)
145 mutt_ch_canonical_charset(buf, buflen, p);
146 else
147 mutt_str_copy(buf, "us-ascii", buflen);
148
149 return buf;
150}
@ TYPE_TEXT
Type: 'text/*'.
Definition mime.h:38
void mutt_ch_canonical_charset(char *buf, size_t buflen, const char *name)
Canonicalise the charset of a string.
Definition charset.c:361
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition string.c:587
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition parameter.c:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_body_new()

struct Body * mutt_body_new ( void )

Create a new Body.

Return values
ptrNewly allocated Body

Definition at line 44 of file body.c.

45{
46 struct Body *p = MUTT_MEM_CALLOC(1, struct Body);
47
49 p->use_disp = true;
51 return p;
52}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ DISP_ATTACH
Content is attached.
Definition mime.h:63
#define TAILQ_INIT(head)
Definition queue.h:822
bool use_disp
Content-Disposition uses filename= ?
Definition body.h:47
unsigned int disposition
content-disposition, ContentDisposition
Definition body.h:42
+ Here is the caller graph for this function: