]>
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
63 * some of the content types have extra
64 * parts which need to be freed.
72 switch (ct
->c_subtype
) {
77 case MESSAGE_EXTERNAL
:
89 free (ct
->c_showproc
);
91 free (ct
->c_termproc
);
93 free (ct
->c_storeproc
);
98 /* free structures for content encodings */
99 free_encoding (ct
, 1);
107 if (ct
->c_dispo_type
)
108 free (ct
->c_dispo_type
);
109 free_pmlist (ct
->c_dispo_first
);
113 (void) m_unlink (ct
->c_file
);
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
;
164 if (ci
->ci_subtype
) {
165 free (ci
->ci_subtype
);
166 ci
->ci_subtype
= NULL
;
168 free_pmlist(ci
->ci_first_pm
);
169 if (ci
->ci_comment
) {
170 free (ci
->ci_comment
);
171 ci
->ci_comment
= NULL
;
185 if (!(t
= (struct text
*) ct
->c_ctparams
))
189 ct
->c_ctparams
= NULL
;
197 struct part
*part
, *next
;
199 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
206 free (m
->mp_content_before
);
207 free (m
->mp_content_after
);
209 for (part
= m
->mp_parts
; part
; part
= next
) {
210 next
= part
->mp_next
;
211 free_content (part
->mp_part
);
212 free ((char *) part
);
217 ct
->c_ctparams
= NULL
;
226 if (!(p
= (struct partial
*) ct
->c_ctparams
))
233 ct
->c_ctparams
= NULL
;
238 free_external (CT ct
)
242 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
245 free_content (e
->eb_content
);
252 ct
->c_ctparams
= NULL
;
267 free (pm
->pm_charset
);
278 * Free data structures related to encoding/decoding
279 * Content-Transfer-Encodings.
283 free_encoding (CT ct
, int toplevel
)
285 CE ce
= &ct
->c_cefile
;
294 (void) m_unlink (ce
->ce_file
);
300 ct
->c_ceopenfnx
= NULL
;
306 freects_done (int status
)