]>
diplodocus.org Git - nmh/blob - uip/mhfree.c
aa5d9ea22b3ed80e6f8a85e09998273e5af1f0a4
2 * mhfree.c -- routines to free the data structures used to
3 * -- represent MIME messages
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * 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
51 mh_xfree(ct
->c_partno
);
53 mh_xfree(ct
->c_ctline
);
54 ct
->c_partno
= ct
->c_vrsn
= ct
->c_ctline
= NULL
;
59 * some of the content types have extra
60 * parts which need to be freed.
68 switch (ct
->c_subtype
) {
73 case MESSAGE_EXTERNAL
:
80 /* Assume that the ct is for text. mhfixmsg(1) uses it for
81 decoding application content. */
86 mh_xfree(ct
->c_showproc
);
87 mh_xfree(ct
->c_termproc
);
88 mh_xfree(ct
->c_storeproc
);
89 ct
->c_showproc
= ct
->c_termproc
= ct
->c_storeproc
= NULL
;
91 mh_xfree(ct
->c_celine
);
94 /* free structures for content encodings */
95 free_encoding (ct
, 1);
98 mh_xfree(ct
->c_descr
);
99 mh_xfree(ct
->c_dispo
);
100 mh_xfree(ct
->c_dispo_type
);
101 ct
->c_id
= ct
->c_descr
= ct
->c_dispo
= ct
->c_dispo_type
= NULL
;
102 free_pmlist (&ct
->c_dispo_first
);
106 (void) m_unlink (ct
->c_file
);
115 mh_xfree(ct
->c_storage
);
116 mh_xfree(ct
->c_folder
);
117 ct
->c_storage
= ct
->c_folder
= NULL
;
124 * Free the linked list of header fields
133 hp1
= ct
->c_first_hf
;
144 ct
->c_first_hf
= NULL
;
145 ct
->c_last_hf
= NULL
;
155 mh_xfree(ci
->ci_type
);
156 mh_xfree(ci
->ci_subtype
);
157 ci
->ci_type
= ci
->ci_subtype
= NULL
;
158 free_pmlist(&ci
->ci_first_pm
);
159 mh_xfree(ci
->ci_comment
);
160 mh_xfree(ci
->ci_magic
);
161 ci
->ci_comment
= ci
->ci_magic
= NULL
;
170 if (!(t
= (struct text
*) ct
->c_ctparams
))
174 ct
->c_ctparams
= NULL
;
182 struct part
*part
, *next
;
184 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
187 mh_xfree(m
->mp_start
);
188 mh_xfree(m
->mp_stop
);
189 free (m
->mp_content_before
);
190 free (m
->mp_content_after
);
192 for (part
= m
->mp_parts
; part
; part
= next
) {
193 next
= part
->mp_next
;
194 free_content (part
->mp_part
);
200 ct
->c_ctparams
= NULL
;
209 if (!(p
= (struct partial
*) ct
->c_ctparams
))
212 mh_xfree(p
->pm_partid
);
215 ct
->c_ctparams
= NULL
;
220 free_external (CT ct
)
224 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
227 free_content (e
->eb_content
);
228 mh_xfree(e
->eb_body
);
231 ct
->c_ctparams
= NULL
;
241 mh_xfree(pm
->pm_name
);
242 mh_xfree(pm
->pm_value
);
243 mh_xfree(pm
->pm_charset
);
244 mh_xfree(pm
->pm_lang
);
256 * Free data structures related to encoding/decoding
257 * Content-Transfer-Encodings.
261 free_encoding (CT ct
, int toplevel
)
263 CE ce
= &ct
->c_cefile
;
272 (void) m_unlink (ce
->ce_file
);
278 ct
->c_ceopenfnx
= NULL
;
284 freects_done (int status
)
288 for (ctp
= cts
; ctp
&& *ctp
; ctp
++)