]>
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>
18 /* The list of top-level contents to display */
24 void free_content (CT
);
25 void free_header (CT
);
26 void free_ctinfo (CT
);
27 void free_encoding (CT
, int);
28 void freects_done (int);
33 static void free_text (CT
);
34 static void free_multi (CT
);
35 static void free_partial (CT
);
36 static void free_external (CT
);
40 * Primary routine to free a MIME content structure
50 * free all the header fields
66 * some of the content types have extra
67 * parts which need to be freed.
75 switch (ct
->c_subtype
) {
80 case MESSAGE_EXTERNAL
:
92 free (ct
->c_showproc
);
94 free (ct
->c_termproc
);
96 free (ct
->c_storeproc
);
101 /* free structures for content encodings */
102 free_encoding (ct
, 1);
120 free (ct
->c_storage
);
129 * Free the linked list of header fields
138 hp1
= ct
->c_first_hf
;
149 ct
->c_first_hf
= NULL
;
150 ct
->c_last_hf
= NULL
;
165 if (ci
->ci_subtype
) {
166 free (ci
->ci_subtype
);
167 ci
->ci_subtype
= NULL
;
169 for (ap
= ci
->ci_attrs
; *ap
; ap
++) {
173 if (ci
->ci_comment
) {
174 free (ci
->ci_comment
);
175 ci
->ci_comment
= NULL
;
189 if (!(t
= (struct text
*) ct
->c_ctparams
))
193 ct
->c_ctparams
= NULL
;
201 struct part
*part
, *next
;
203 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
211 for (part
= m
->mp_parts
; part
; part
= next
) {
212 next
= part
->mp_next
;
213 free_content (part
->mp_part
);
214 free ((char *) part
);
219 ct
->c_ctparams
= NULL
;
228 if (!(p
= (struct partial
*) ct
->c_ctparams
))
235 ct
->c_ctparams
= NULL
;
240 free_external (CT ct
)
244 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
247 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
)
266 if (!(ce
= ct
->c_cefile
))
276 unlink (ce
->ce_file
);
285 ct
->c_ceopenfnx
= NULL
;
291 freects_done (int status
)