/*
* Copyright (C) 1996-8 Michael R. Elkins <me@cs.hmc.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "mutt.h"
#include "mutt_curses.h"
#include "mime.h"
#include "mailbox.h"
#include "mx.h"
#ifdef _PGPPATH
#include "pgp.h"
#endif
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <errno.h>
#include <pwd.h>
#include <sys/stat.h>
#include <fcntl.h>
BODY *mutt_new_body (void)
{
BODY *p = (BODY *) safe_calloc (1, sizeof (BODY));
p->disposition = DISPATTACH;
p->use_disp = 1;
return (p);
}
BODY *mutt_dup_body (BODY *b)
{
BODY *bn;
bn = mutt_new_body();
memcpy(bn, b, sizeof (BODY));
return bn;
}
void mutt_free_body (BODY **p)
{
BODY *a = *p, *b;
while (a)
{
b = a;
a = a->next;
if (b->parameter)
mutt_free_parameter (&b->parameter);
if (b->unlink && b->filename)
unlink (b->filename);
safe_free ((void **) &b->filename);
safe_free ((void **) &b->content);
safe_free ((void **) &b->xtype);
safe_free ((void **) &b->subtype);
safe_free ((void **) &b->description);
safe_free ((void **) &b->form_name);
if (b->hdr)
{
/* Don't free twice (b->hdr->content = b->parts) */
b->hdr->content = NULL;
mutt_free_header(&b->hdr);
}
if (b->parts)
mutt_free_body (&b->parts);
safe_free ((void **) &b);
}
*p = 0;
}
void mutt_free_parameter (PARAMETER **p)
{
PARAMETER *t = *p;
PARAMETER *o;
while (t)
{
safe_free ((void **) &t->attribute);
safe_free ((void **) &t->value);
o = t;
t = t->next;
safe_free ((void **) &o);
}
*