3 * mhfree.c -- routines to free the data structures used to
4 * -- represent MIME messages
8 * This code is Copyright (c) 2002, by the authors of nmh. See the
9 * COPYRIGHT file in the root directory of the nmh distribution for
10 * complete copyright information.
16 #include <h/mhparse.h>
21 void free_content (CT);
22 void free_header (CT);
23 void free_ctinfo (CT);
24 void free_encoding (CT, int);
29 static void free_text (CT);
30 static void free_multi (CT);
31 static void free_partial (CT);
32 static void free_external (CT);
36 * Primary routine to free a MIME content structure
46 * free all the header fields
62 * some of the content types have extra
63 * parts which need to be freed.
71 switch (ct->c_subtype) {
76 case MESSAGE_EXTERNAL:
88 free (ct->c_showproc);
90 free (ct->c_termproc);
92 free (ct->c_storeproc);
97 /* free structures for content encodings */
98 free_encoding (ct, 1);
114 free (ct->c_storage);
123 * Free the linked list of header fields
132 hp1 = ct->c_first_hf;
143 ct->c_first_hf = NULL;
144 ct->c_last_hf = NULL;
159 if (ci->ci_subtype) {
160 free (ci->ci_subtype);
161 ci->ci_subtype = NULL;
163 for (ap = ci->ci_attrs; *ap; ap++) {
167 if (ci->ci_comment) {
168 free (ci->ci_comment);
169 ci->ci_comment = NULL;
183 if (!(t = (struct text *) ct->c_ctparams))
187 ct->c_ctparams = NULL;
195 struct part *part, *next;
197 if (!(m = (struct multipart *) ct->c_ctparams))
205 for (part = m->mp_parts; part; part = next) {
206 next = part->mp_next;
207 free_content (part->mp_part);
208 free ((char *) part);
213 ct->c_ctparams = NULL;
222 if (!(p = (struct partial *) ct->c_ctparams))
229 ct->c_ctparams = NULL;
234 free_external (CT ct)
238 if (!(e = (struct exbody *) ct->c_ctparams))
241 free_content (e->eb_content);
246 ct->c_ctparams = NULL;
251 * Free data structures related to encoding/decoding
252 * Content-Transfer-Encodings.
256 free_encoding (CT ct, int toplevel)
260 if (!(ce = ct->c_cefile))
270 unlink (ce->ce_file);
279 ct->c_ceopenfnx = NULL;