]>
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
:
81 /* Assume that the ct is for text. mhfixmsg(1) uses it for
82 decoding application content. */
87 mh_xfree(ct
->c_showproc
);
88 mh_xfree(ct
->c_termproc
);
89 mh_xfree(ct
->c_storeproc
);
90 ct
->c_showproc
= ct
->c_termproc
= ct
->c_storeproc
= NULL
;
92 mh_xfree(ct
->c_celine
);
95 /* free structures for content encodings */
96 free_encoding (ct
, 1);
99 mh_xfree(ct
->c_descr
);
100 mh_xfree(ct
->c_dispo
);
101 mh_xfree(ct
->c_dispo_type
);
102 ct
->c_id
= ct
->c_descr
= ct
->c_dispo
= ct
->c_dispo_type
= NULL
;
103 free_pmlist (&ct
->c_dispo_first
);
107 (void) m_unlink (ct
->c_file
);
116 mh_xfree(ct
->c_storage
);
117 mh_xfree(ct
->c_folder
);
118 ct
->c_storage
= ct
->c_folder
= NULL
;
125 * Free the linked list of header fields
134 hp1
= ct
->c_first_hf
;
145 ct
->c_first_hf
= NULL
;
146 ct
->c_last_hf
= NULL
;
156 mh_xfree(ci
->ci_type
);
157 mh_xfree(ci
->ci_subtype
);
158 ci
->ci_type
= ci
->ci_subtype
= NULL
;
159 free_pmlist(&ci
->ci_first_pm
);
160 mh_xfree(ci
->ci_comment
);
161 mh_xfree(ci
->ci_magic
);
162 ci
->ci_comment
= ci
->ci_magic
= NULL
;
171 if (!(t
= (struct text
*) ct
->c_ctparams
))
175 ct
->c_ctparams
= NULL
;
183 struct part
*part
, *next
;
185 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
188 mh_xfree(m
->mp_start
);
189 mh_xfree(m
->mp_stop
);
190 free (m
->mp_content_before
);
191 free (m
->mp_content_after
);
193 for (part
= m
->mp_parts
; part
; part
= next
) {
194 next
= part
->mp_next
;
195 free_content (part
->mp_part
);
201 ct
->c_ctparams
= NULL
;
210 if (!(p
= (struct partial
*) ct
->c_ctparams
))
213 mh_xfree(p
->pm_partid
);
216 ct
->c_ctparams
= NULL
;
221 free_external (CT ct
)
225 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
228 free_content (e
->eb_content
);
229 mh_xfree(e
->eb_body
);
232 ct
->c_ctparams
= NULL
;
242 mh_xfree(pm
->pm_name
);
243 mh_xfree(pm
->pm_value
);
244 mh_xfree(pm
->pm_charset
);
245 mh_xfree(pm
->pm_lang
);
257 * Free data structures related to encoding/decoding
258 * Content-Transfer-Encodings.
262 free_encoding (CT ct
, int toplevel
)
264 CE ce
= &ct
->c_cefile
;
273 (void) m_unlink (ce
->ce_file
);
279 ct
->c_ceopenfnx
= NULL
;
285 freects_done (int status
)
289 for (ctp
= cts
; ctp
&& *ctp
; ctp
++)