]>
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_content (CT
);
23 void free_header (CT
);
24 void free_ctinfo (CT
);
25 void free_encoding (CT
, int);
26 void freects_done (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);
118 free (ct
->c_storage
);
127 * Free the linked list of header fields
136 hp1
= ct
->c_first_hf
;
147 ct
->c_first_hf
= NULL
;
148 ct
->c_last_hf
= NULL
;
163 if (ci
->ci_subtype
) {
164 free (ci
->ci_subtype
);
165 ci
->ci_subtype
= NULL
;
167 for (ap
= ci
->ci_attrs
; *ap
; ap
++) {
171 if (ci
->ci_comment
) {
172 free (ci
->ci_comment
);
173 ci
->ci_comment
= NULL
;
187 if (!(t
= (struct text
*) ct
->c_ctparams
))
191 ct
->c_ctparams
= NULL
;
199 struct part
*part
, *next
;
201 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
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
);
250 ct
->c_ctparams
= NULL
;
255 * Free data structures related to encoding/decoding
256 * Content-Transfer-Encodings.
260 free_encoding (CT ct
, int toplevel
)
264 if (!(ce
= ct
->c_cefile
))
274 unlink (ce
->ce_file
);
283 ct
->c_ceopenfnx
= NULL
;
289 freects_done (int status
)