2 * mhfree.c -- routines to free the data structures used to
3 * -- represent MIME messages
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
13 #include <h/mhparse.h>
15 /* The list of top-level contents to display */
21 void free_content (CT);
22 void free_header (CT);
23 void free_ctinfo (CT);
24 void free_encoding (CT, int);
25 void freects_done (int);
30 static void free_text (CT);
31 static void free_multi (CT);
32 static void free_partial (CT);
33 static void free_external (CT);
37 * Primary routine to free a MIME content structure
47 * free all the header fields
63 * some of the content types have extra
64 * parts which need to be freed.
72 switch (ct->c_subtype) {
77 case MESSAGE_EXTERNAL:
89 free (ct->c_showproc);
91 free (ct->c_termproc);
93 free (ct->c_storeproc);
98 /* free structures for content encodings */
99 free_encoding (ct, 1);
117 free (ct->c_storage);
126 * Free the linked list of header fields
135 hp1 = ct->c_first_hf;
146 ct->c_first_hf = NULL;
147 ct->c_last_hf = NULL;
162 if (ci->ci_subtype) {
163 free (ci->ci_subtype);
164 ci->ci_subtype = NULL;
166 for (ap = ci->ci_attrs; *ap; ap++) {
170 if (ci->ci_comment) {
171 free (ci->ci_comment);
172 ci->ci_comment = NULL;
186 if (!(t = (struct text *) ct->c_ctparams))
190 ct->c_ctparams = NULL;
198 struct part *part, *next;
200 if (!(m = (struct multipart *) ct->c_ctparams))
208 for (part = m->mp_parts; part; part = next) {
209 next = part->mp_next;
210 free_content (part->mp_part);
211 free ((char *) part);
216 ct->c_ctparams = NULL;
225 if (!(p = (struct partial *) ct->c_ctparams))
232 ct->c_ctparams = NULL;
237 free_external (CT ct)
241 if (!(e = (struct exbody *) ct->c_ctparams))
244 free_content (e->eb_content);
249 ct->c_ctparams = NULL;
254 * Free data structures related to encoding/decoding
255 * Content-Transfer-Encodings.
259 free_encoding (CT ct, int toplevel)
263 if (!(ce = ct->c_cefile))
273 unlink (ce->ce_file);
282 ct->c_ceopenfnx = NULL;
288 freects_done (int status)