NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
mutt_body.h File Reference

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

#include <stdio.h>
+ Include dependency graph for mutt_body.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


int mutt_body_copy (FILE *fp, struct Body **tgt, struct Body *src)
 Create a send-mode duplicate from a receive-mode body. More...

Detailed Description

Representation of the body of an email.

  • 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 mutt_body.h.

Function Documentation

◆ mutt_body_copy()

int mutt_body_copy ( FILE *  fp,
struct Body **  tgt,
struct Body src 

Create a send-mode duplicate from a receive-mode body.

[in]fpFILE pointer to attachments
[out]tgtNew Body will be saved here
[in]srcSource Body to copy
Return values

Definition at line 48 of file mutt_body.c.

49 {
50  if (!tgt || !src)
51  return -1;
53  struct Body *b = NULL;
54  bool use_disp;
55  struct Buffer *tmp = mutt_buffer_pool_get();
57  if (src->filename)
58  {
59  use_disp = true;
60  mutt_buffer_strcpy(tmp, src->filename);
61  }
62  else
63  {
64  use_disp = false;
65  }
67  mutt_adv_mktemp(tmp);
68  if (mutt_save_attachment(fp, src, mutt_buffer_string(tmp), MUTT_SAVE_NO_FLAGS, NULL) == -1)
69  {
71  return -1;
72  }
74  *tgt = mutt_body_new();
75  b = *tgt;
77  memcpy(b, src, sizeof(struct Body));
78  TAILQ_INIT(&b->parameter);
79  b->parts = NULL;
80  b->next = NULL;
82  b->filename = mutt_buffer_strdup(tmp);
83  b->use_disp = use_disp;
84  b->unlink = true;
86  if (mutt_is_text_part(b))
87  b->noconv = true;
89  b->xtype = mutt_str_dup(b->xtype);
90  b->subtype = mutt_str_dup(b->subtype);
93  /* mutt_adv_mktemp() will mangle the filename in tmp,
94  * so preserve it in d_filename */
95  if (!b->d_filename && use_disp)
96  b->d_filename = mutt_str_dup(src->filename);
99  /* we don't seem to need the Email structure currently.
100  * XXX this may change in the future */
102  if (b->email)
103  b->email = NULL;
105  /* copy parameters */
106  struct Parameter *np = NULL, *new_param = NULL;
107  TAILQ_FOREACH(np, &src->parameter, entries)
108  {
109  new_param = mutt_param_new();
110  new_param->attribute = mutt_str_dup(np->attribute);
111  new_param->value = mutt_str_dup(np->value);
112  TAILQ_INSERT_HEAD(&b->parameter, new_param, entries);
113  }
117  return 0;
118 }
char * attribute
Parameter name.
Definition: parameter.h:34
void mutt_stamp_attachment(struct Body *a)
Timestamp an Attachment.
Definition: sendlib.c:892
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer&#39;s string.
Definition: buffer.c:432
struct Parameter * mutt_param_new(void)
Create a new Parameter.
Definition: parameter.c:39
No flags set.
Definition: mutt_attach.h:57
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
bool noconv
Don&#39;t do character set conversion.
Definition: body.h:73
String manipulation buffer.
Definition: buffer.h:33
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
struct Body * next
next attachment in the list
Definition: body.h:53
int mutt_save_attachment(FILE *fp, struct Body *m, const char *path, enum SaveAttach opt, struct Email *e)
Save an attachment.
Definition: mutt_attach.c:879
char * form_name
Content-Disposition form-data name param.
Definition: body.h:41
The body of an email.
Definition: body.h:34
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
struct Body * mutt_body_new(void)
Create a new Body.
Definition: body.c:43
#define TAILQ_INIT(head)
Definition: queue.h:765
char * subtype
content-type subtype
Definition: body.h:37
char * xtype
content-type if x-unknown
Definition: body.h:36
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
char * description
Definition: body.h:40
bool mutt_is_text_part(struct Body *b)
Is this part of an email in plain text?
Definition: muttlib.c:434
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
#define TAILQ_INSERT_HEAD(head, elm, field)
Definition: queue.h:796
char * value
Parameter value.
Definition: parameter.h:35
bool use_disp
Content-Disposition uses filename= ?
Definition: body.h:68
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition: body.h:69
Attribute associated with a MIME part.
Definition: parameter.h:32
void mutt_adv_mktemp(struct Buffer *buf)
Create a temporary file.
Definition: muttlib.c:83
char * d_filename
filename to be used for the content-disposition header.
Definition: body.h:47
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
struct Email * email
header information for message/rfc822
Definition: body.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function: