b = h->content;
mutt_error _("Confused when attempting to delete attachment, h & m can't be NULL"); return -1;
static int copy_delete_attach(HEADER *h, HEADER *p, BODY *m, FILE *fpin,                              FILE *fpout, int flags){  long offset = 0;  BODY *b;  char buf[STRING];  long orig_length = 0;  long orig_offset = 0;  long new_length = 0;  long new_offset = 0;  int x;  new_offset = ftell (fpout);  if (h == NULL)  {    if (m == NULL)    {      mutt_error _("Confused when attempting to delete attachment, h & m can't be NULL");      return -1;    }    b = m;  }  else  {    b = h->content;  }  orig_length = b->length;  orig_offset = b->offset;  dprint (1, (debugfile, "orig length: %ld  orig offset: %ld\n", orig_length, orig_offset));  /* Find first deleted attachment */  if (b->parts == NULL)  {    mutt_error _("Deleting non-multipart messages not yet supported");    return -1;  }  b = b->parts;  while (b != NULL)  {    while (b && !b->deleted && !b->parts) b = b->next;    if (b)    {      /* Copy message from current to deleted attachment headers */      offset = ftell (fpin);      mutt_copy_bytes (fpin, fpout, b->hdr_offset - offset);      new_length += b->hdr_offset - offset;      if (!b->deleted && b->parts)      {	x = ftell (fpout);	if (mutt_copy_hdr (fpin, fpout, ftell (fpin), b->offset, 	    CH_UPDATE_LEN, NULL) == -1)	  return -1;	new_length += (ftell (fpout) - x);	x = fprintf (fpout, "\n");	if (x > 0)	  new_length += x;	if (copy_delete_attach(b->hdr, h, b, fpin, fpout, flags) == -1)	  return -1;	new_length += b->parts->length;      }      else      {	if (h) h->lines = 0;	mutt_make_string (buf, sizeof (buf), NONULL (DeleteFmt), NULL,			  (p) ? p : h);	/* Go through deleted attachment headers, weed Content-Length,	 * Content-Type and Content-Transfer-Encoding 	 * Also, keep track of what we write to update the length */	x = ftell (fpout);	if (mutt_copy_hdr (fpin, fpout, ftell (fpin), b->offset, 	    CH_UPDATE_LEN | CH_MIME , NULL) == -1)	  return -1;	new_length += (ftell (fpout) - x);	x = fprintf (fpout, "\n%s\n", buf);	if (x > 0)	  new_length += x;	/* Skip the deleted body */	fseek (fpin, (b->offset + b->length), SEEK_SET);	if (flags & M_CM_UPDATE)	  b->deleted = 0;      }      b = b->next;    }  }  /* Copy til end of message */  offset = ftell(fpin);  mutt_copy_bytes (fpin, fpout, (orig_offset+orig_length) - offset);  new_length +=  (orig_offset+orig_length) - offset;  /*   * Update the content-length and offset.  This offset will be wrong for   * mbox/mh type folders, but will be corrected in mbox_sync_mailbox()   *   */  if (flags & M_CM_UPDATE)  {    dprint (1, (debugfile, "new length: %ld  new offset: %ld\n", new_length, new_offset));    if (h)    {      h->content->length = new_length;      h->content->offset = new_offset;      h->attach_del = 0;    }    else if (m)    {      m->parts->length = new_length;      m->parts->offset = new_offset;    }  }  return 0;}