]>
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.
13 #include <h/mhparse.h>
15 /* The list of top-level contents to display */
21 void free_header (CT
);
22 void free_ctinfo (CT
);
23 void free_encoding (CT
, int);
24 void freects_done (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);
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
))
206 free (m
->mp_content_before
);
207 free (m
->mp_content_after
);
209 for (part
= m
->mp_parts
; part
; part
= next
) {
210 next
= part
->mp_next
;
211 free_content (part
->mp_part
);
212 free ((char *) part
);
217 ct
->c_ctparams
= NULL
;
226 if (!(p
= (struct partial
*) ct
->c_ctparams
))
233 ct
->c_ctparams
= NULL
;
238 free_external (CT ct
)
242 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
245 free_content (e
->eb_content
);
252 ct
->c_ctparams
= NULL
;
257 * Free data structures related to encoding/decoding
258 * Content-Transfer-Encodings.
262 free_encoding (CT ct
, int toplevel
)
264 CE ce
= &ct
->c_cefile
;
273 unlink (ce
->ce_file
);
279 ct
->c_ceopenfnx
= NULL
;
285 freects_done (int status
)