]>
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
);
33 static void free_pmlist (PM
*);
37 * Primary routine to free a MIME content structure
47 * free all the header fields
69 * some of the content types have extra
70 * parts which need to be freed.
78 switch (ct
->c_subtype
) {
83 case MESSAGE_EXTERNAL
:
95 free (ct
->c_showproc
);
96 ct
->c_showproc
= NULL
;
99 free (ct
->c_termproc
);
100 ct
->c_termproc
= NULL
;
102 if (ct
->c_storeproc
) {
103 free (ct
->c_storeproc
);
104 ct
->c_storeproc
= NULL
;
112 /* free structures for content encodings */
113 free_encoding (ct
, 1);
127 if (ct
->c_dispo_type
) {
128 free (ct
->c_dispo_type
);
129 ct
->c_dispo_type
= NULL
;
131 free_pmlist (&ct
->c_dispo_first
);
135 (void) m_unlink (ct
->c_file
);
145 free (ct
->c_storage
);
146 ct
->c_storage
= NULL
;
158 * Free the linked list of header fields
167 hp1
= ct
->c_first_hf
;
178 ct
->c_first_hf
= NULL
;
179 ct
->c_last_hf
= NULL
;
193 if (ci
->ci_subtype
) {
194 free (ci
->ci_subtype
);
195 ci
->ci_subtype
= NULL
;
197 free_pmlist(&ci
->ci_first_pm
);
198 if (ci
->ci_comment
) {
199 free (ci
->ci_comment
);
200 ci
->ci_comment
= NULL
;
214 if (!(t
= (struct text
*) ct
->c_ctparams
))
218 ct
->c_ctparams
= NULL
;
226 struct part
*part
, *next
;
228 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
235 free (m
->mp_content_before
);
236 free (m
->mp_content_after
);
238 for (part
= m
->mp_parts
; part
; part
= next
) {
239 next
= part
->mp_next
;
240 free_content (part
->mp_part
);
241 free ((char *) part
);
246 ct
->c_ctparams
= NULL
;
255 if (!(p
= (struct partial
*) ct
->c_ctparams
))
262 ct
->c_ctparams
= NULL
;
267 free_external (CT ct
)
271 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
274 free_content (e
->eb_content
);
281 ct
->c_ctparams
= NULL
;
296 free (pm
->pm_charset
);
310 * Free data structures related to encoding/decoding
311 * Content-Transfer-Encodings.
315 free_encoding (CT ct
, int toplevel
)
317 CE ce
= &ct
->c_cefile
;
326 (void) m_unlink (ce
->ce_file
);
332 ct
->c_ceopenfnx
= NULL
;
338 freects_done (int status
)
342 for (ctp
= cts
; ctp
&& *ctp
; ctp
++)