]>
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_header (CT
);
23 void free_ctinfo (CT
);
24 void free_encoding (CT
, int);
25 void freects_done (int);
30 static void free_text (CT
);
31 static void free_multi (CT
);
32 static void free_partial (CT
);
33 static void free_external (CT
);
34 static void free_pmlist (PM
*);
38 * Primary routine to free a MIME content structure
48 * free all the header fields
52 mh_xfree(ct
->c_partno
);
54 mh_xfree(ct
->c_ctline
);
55 ct
->c_partno
= ct
->c_vrsn
= ct
->c_ctline
= NULL
;
60 * some of the content types have extra
61 * parts which need to be freed.
69 switch (ct
->c_subtype
) {
74 case MESSAGE_EXTERNAL
:
85 mh_xfree(ct
->c_showproc
);
86 mh_xfree(ct
->c_termproc
);
87 mh_xfree(ct
->c_storeproc
);
88 ct
->c_showproc
= ct
->c_termproc
= ct
->c_storeproc
= NULL
;
90 mh_xfree(ct
->c_celine
);
93 /* free structures for content encodings */
94 free_encoding (ct
, 1);
97 mh_xfree(ct
->c_descr
);
98 mh_xfree(ct
->c_dispo
);
99 mh_xfree(ct
->c_dispo_type
);
100 ct
->c_id
= ct
->c_descr
= ct
->c_dispo
= ct
->c_dispo_type
= NULL
;
101 free_pmlist (&ct
->c_dispo_first
);
105 (void) m_unlink (ct
->c_file
);
114 mh_xfree(ct
->c_storage
);
115 mh_xfree(ct
->c_folder
);
116 ct
->c_storage
= ct
->c_folder
= NULL
;
123 * Free the linked list of header fields
132 hp1
= ct
->c_first_hf
;
143 ct
->c_first_hf
= NULL
;
144 ct
->c_last_hf
= NULL
;
154 mh_xfree(ci
->ci_type
);
155 mh_xfree(ci
->ci_subtype
);
156 ci
->ci_type
= ci
->ci_subtype
= NULL
;
157 free_pmlist(&ci
->ci_first_pm
);
158 mh_xfree(ci
->ci_comment
);
159 mh_xfree(ci
->ci_magic
);
160 ci
->ci_comment
= ci
->ci_magic
= NULL
;
169 if (!(t
= (struct text
*) ct
->c_ctparams
))
173 ct
->c_ctparams
= NULL
;
181 struct part
*part
, *next
;
183 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
186 mh_xfree(m
->mp_start
);
187 mh_xfree(m
->mp_stop
);
188 free (m
->mp_content_before
);
189 free (m
->mp_content_after
);
191 for (part
= m
->mp_parts
; part
; part
= next
) {
192 next
= part
->mp_next
;
193 free_content (part
->mp_part
);
199 ct
->c_ctparams
= NULL
;
208 if (!(p
= (struct partial
*) ct
->c_ctparams
))
211 mh_xfree(p
->pm_partid
);
214 ct
->c_ctparams
= NULL
;
219 free_external (CT ct
)
223 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
226 free_content (e
->eb_content
);
227 mh_xfree(e
->eb_body
);
230 ct
->c_ctparams
= NULL
;
240 mh_xfree(pm
->pm_name
);
241 mh_xfree(pm
->pm_value
);
242 mh_xfree(pm
->pm_charset
);
243 mh_xfree(pm
->pm_lang
);
255 * Free data structures related to encoding/decoding
256 * Content-Transfer-Encodings.
260 free_encoding (CT ct
, int toplevel
)
262 CE ce
= &ct
->c_cefile
;
271 (void) m_unlink (ce
->ce_file
);
277 ct
->c_ceopenfnx
= NULL
;
283 freects_done (int status
)
287 for (ctp
= cts
; ctp
&& *ctp
; ctp
++)