]>
diplodocus.org Git - nmh/blob - uip/mhfree.c
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>
23 void free_content (CT
);
24 void free_header (CT
);
25 void free_ctinfo (CT
);
26 void free_encoding (CT
, int);
31 static void free_text (CT
);
32 static void free_multi (CT
);
33 static void free_partial (CT
);
34 static void free_external (CT
);
38 * Primary routine to free a MIME content structure
48 * free all the header fields
64 * some of the content types have extra
65 * parts which need to be freed.
73 switch (ct
->c_subtype
) {
78 case MESSAGE_EXTERNAL
:
90 free (ct
->c_showproc
);
92 free (ct
->c_termproc
);
94 free (ct
->c_storeproc
);
99 /* free structures for content encodings */
100 free_encoding (ct
, 1);
116 free (ct
->c_storage
);
125 * Free the linked list of header fields
134 hp1
= ct
->c_first_hf
;
145 ct
->c_first_hf
= NULL
;
146 ct
->c_last_hf
= NULL
;
161 if (ci
->ci_subtype
) {
162 free (ci
->ci_subtype
);
163 ci
->ci_subtype
= NULL
;
165 for (ap
= ci
->ci_attrs
; *ap
; ap
++) {
169 if (ci
->ci_comment
) {
170 free (ci
->ci_comment
);
171 ci
->ci_comment
= NULL
;
185 if (!(t
= (struct text
*) ct
->c_ctparams
))
189 ct
->c_ctparams
= NULL
;
197 struct part
*part
, *next
;
199 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
207 for (part
= m
->mp_parts
; part
; part
= next
) {
208 next
= part
->mp_next
;
209 free_content (part
->mp_part
);
210 free ((char *) part
);
215 ct
->c_ctparams
= NULL
;
224 if (!(p
= (struct partial
*) ct
->c_ctparams
))
231 ct
->c_ctparams
= NULL
;
236 free_external (CT ct
)
240 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
243 free_content (e
->eb_content
);
248 ct
->c_ctparams
= NULL
;
253 * Free data structures related to encoding/decoding
254 * Content-Transfer-Encodings.
258 free_encoding (CT ct
, int toplevel
)
262 if (!(ce
= ct
->c_cefile
))
272 unlink (ce
->ce_file
);
281 ct
->c_ceopenfnx
= NULL
;