NeoMutt  2023-03-22
Teaching an old dog new tricks
multipart.h File Reference

Manipulate multipart Emails. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


void mutt_generate_boundary (struct ParameterList *pl)
 Create a unique boundary id for a MIME part. More...
struct Bodymutt_make_multipart (struct Body *b)
 Create a multipart email. More...
struct Bodymutt_remove_multipart (struct Body *b)
 Extract the multipart body if it exists. More...

Detailed Description

Manipulate multipart Emails.

  • 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

Definition in file multipart.h.

Function Documentation

◆ mutt_generate_boundary()

void mutt_generate_boundary ( struct ParameterList *  pl)

Create a unique boundary id for a MIME part.

plMIME part

Definition at line 86 of file multipart.c.

88 char rs[MUTT_RANDTAG_LEN + 1];
90 mutt_rand_base32(rs, sizeof(rs) - 1);
91 rs[MUTT_RANDTAG_LEN] = 0;
92 mutt_param_set(pl, "boundary", rs);
void mutt_param_set(struct ParameterList *pl, const char *attribute, const char *value)
Set a Parameter.
Definition: parameter.c:110
void mutt_rand_base32(char *buf, size_t buflen)
Fill a buffer with a base32-encoded random string.
Definition: random.c:102
Definition: sendlib.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_make_multipart()

struct Body * mutt_make_multipart ( struct Body b)

Create a multipart email.

bBody of email to start
Return values
ptrNewly allocated Body

Definition at line 100 of file multipart.c.

102 struct Body *new_body = mutt_body_new();
103 new_body->type = TYPE_MULTIPART;
104 new_body->subtype = mutt_str_dup("mixed");
105 new_body->encoding = get_toplevel_encoding(b);
106 do
107 {
109 if (check_boundary(mutt_param_get(&new_body->parameter, "boundary"), b))
110 mutt_param_delete(&new_body->parameter, "boundary");
111 } while (!mutt_param_get(&new_body->parameter, "boundary"));
112 new_body->use_disp = false;
113 new_body->disposition = DISP_INLINE;
114 new_body->parts = b;
116 return new_body;
struct Body * mutt_body_new(void)
Create a new Body.
Definition: body.c:43
Type: 'multipart/*'.
Definition: mime.h:37
Content is inline.
Definition: mime.h:62
static bool check_boundary(const char *boundary, struct Body *b)
Check for duplicate boundary.
Definition: multipart.c:64
static int get_toplevel_encoding(struct Body *a)
Find the most restrictive encoding type.
Definition: multipart.c:43
void mutt_generate_boundary(struct ParameterList *pl)
Create a unique boundary id for a MIME part.
Definition: multipart.c:86
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
void mutt_param_delete(struct ParameterList *pl, const char *attribute)
Delete a matching Parameter.
Definition: parameter.c:142
The body of an email.
Definition: body.h:36
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:72
struct ParameterList parameter
Parameters of the content-type.
Definition: body.h:62
bool use_disp
Content-Disposition uses filename= ?
Definition: body.h:47
unsigned int disposition
content-disposition, ContentDisposition
Definition: body.h:42
char * subtype
content-type subtype
Definition: body.h:60
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_remove_multipart()

struct Body * mutt_remove_multipart ( struct Body b)

Extract the multipart body if it exists.

bBody to alter
Return values
ptrThe parts of the Body
The original Body is freed

Definition at line 126 of file multipart.c.

128 struct Body *t = NULL;
130 if (b->parts)
131 {
132 t = b;
133 b = b->parts;
134 t->parts = NULL;
135 mutt_body_free(&t);
136 }
137 return b;
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: