]>
diplodocus.org Git - nmh/blob - uip/mhfree.c
3 * mhfree.c -- routines to free the data structures used to
4 * -- represent MIME messages
6 * This code is Copyright (c) 2002, by the authors of nmh. See the
7 * COPYRIGHT file in the root directory of the nmh distribution for
8 * complete copyright information.
14 #include <h/mhparse.h>
16 /* The list of top-level contents to display */
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
))
207 free (m
->mp_content_before
);
208 free (m
->mp_content_after
);
210 for (part
= m
->mp_parts
; part
; part
= next
) {
211 next
= part
->mp_next
;
212 free_content (part
->mp_part
);
213 free ((char *) part
);
218 ct
->c_ctparams
= NULL
;
227 if (!(p
= (struct partial
*) ct
->c_ctparams
))
234 ct
->c_ctparams
= NULL
;
239 free_external (CT ct
)
243 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
246 free_content (e
->eb_content
);
251 ct
->c_ctparams
= NULL
;
256 * Free data structures related to encoding/decoding
257 * Content-Transfer-Encodings.
261 free_encoding (CT ct
, int toplevel
)
265 if (!(ce
= ct
->c_cefile
))
275 unlink (ce
->ce_file
);
284 ct
->c_ceopenfnx
= NULL
;
290 freects_done (int status
)