mutt_mktemp (file);
BODY *b = hdr->content; file[0] = 0; if (b->filename) strfcpy (file, b->filename, sizeof (file)); mutt_adv_mktemp (file, sizeof(file));
int mutt_prepare_edit_message (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr){  PARAMETER *par;  MESSAGE *msg = mx_open_message (ctx, hdr->msgno);  char file[_POSIX_PATH_MAX];  if (msg == NULL)    return (-1);  fseek (msg->fp, hdr->offset, 0);  newhdr->env = mutt_read_rfc822_header (msg->fp, newhdr, 1);  if (hdr->content->type == TYPEMESSAGE || hdr->content->type == TYPEMULTIPART)  {    BODY *b;    mutt_parse_part (msg->fp, hdr->content);    /* Now that we know what was in the other message, convert to the new     * message.     */    newhdr->content = hdr->content->parts;    for (b = hdr->content->parts; b; b = b->next)    {      file[0] = '\0';      if (b->filename)	strfcpy (file, b->filename, sizeof (file));      else	/* avoid Content-Disposition: header with temporary filename */	b->use_disp = 0;      mutt_adv_mktemp (file, sizeof(file));      if (mutt_save_attachment (msg->fp, b, file, 0, NULL) == -1)      {	mutt_free_envelope (&newhdr->env);	mutt_free_body (&newhdr->content);	mx_close_message (&msg);	return (-1);      }      safe_free ((void *) &b->filename);      b->filename = safe_strdup (file);      b->unlink = 1;      if (mutt_is_text_type (b->type, b->subtype))	b->noconv = 1;            mutt_stamp_attachment (b);      mutt_free_body (&b->parts);    }    hdr->content->parts = NULL;    if (hdr->content->type == TYPEMESSAGE && hdr->content->hdr)      hdr->content->hdr->content = NULL;  }  else  {    mutt_mktemp (file);    if (mutt_save_attachment (msg->fp, hdr->content, file, 0, NULL) == -1)    {      mutt_free_envelope (&newhdr->env);      mx_close_message (&msg);      return (-1);    }    newhdr->content = mutt_make_file_attach (file);        FREE (&newhdr->content->subtype);    FREE (&newhdr->content->xtype);        newhdr->content->type = hdr->content->type;    newhdr->content->xtype = safe_strdup (hdr->content->xtype);    newhdr->content->subtype = safe_strdup (hdr->content->subtype);    for (par = hdr->content->parameter; par; par = par->next)      mutt_set_parameter (par->attribute, par->value, &newhdr->content->parameter);    if (mutt_is_text_type (newhdr->content->type, newhdr->content->subtype))      newhdr->content->noconv = 1;        newhdr->content->use_disp = 0;	/* no content-disposition */    newhdr->content->unlink = 1;	/* delete when we are done */  }  mx_close_message (&msg);  return 0;}