]>
diplodocus.org Git - nmh/blob - uip/mhfree.c
1 /* mhfree.c -- routines to free the data structures used to
2 * -- represent MIME messages
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
12 #include <h/mhparse.h>
13 #include "sbr/m_mktemp.h"
16 /* The list of top-level contents to display */
22 static void free_header (CT
);
23 static void free_text (CT
);
24 static void free_multi (CT
);
25 static void free_partial (CT
);
26 static void free_external (CT
);
27 static void free_pmlist (PM
*);
31 * Primary routine to free a MIME content structure
41 * free all the header fields
48 ct
->c_partno
= ct
->c_vrsn
= ct
->c_ctline
= NULL
;
53 * some of the content types have extra
54 * parts which need to be freed.
62 switch (ct
->c_subtype
) {
67 case MESSAGE_EXTERNAL
:
74 /* Assume that the ct is for text. mhfixmsg(1) uses it for
75 decoding application content. */
82 free(ct
->c_storeproc
);
83 ct
->c_showproc
= ct
->c_termproc
= ct
->c_storeproc
= NULL
;
88 /* free structures for content encodings */
89 free_encoding (ct
, 1);
94 free(ct
->c_dispo_type
);
95 ct
->c_id
= ct
->c_descr
= ct
->c_dispo
= ct
->c_dispo_type
= NULL
;
96 free_pmlist (&ct
->c_dispo_first
);
100 (void) m_unlink (ct
->c_file
);
111 ct
->c_storage
= ct
->c_folder
= NULL
;
118 * Free the linked list of header fields
127 hp1
= ct
->c_first_hf
;
138 ct
->c_first_hf
= NULL
;
139 ct
->c_last_hf
= NULL
;
150 free(ci
->ci_subtype
);
151 ci
->ci_type
= ci
->ci_subtype
= NULL
;
152 free_pmlist(&ci
->ci_first_pm
);
153 free(ci
->ci_comment
);
155 ci
->ci_comment
= ci
->ci_magic
= NULL
;
164 if (!(t
= (struct text
*) ct
->c_ctparams
))
168 ct
->c_ctparams
= NULL
;
176 struct part
*part
, *next
;
178 if (!(m
= (struct multipart
*) ct
->c_ctparams
))
183 free (m
->mp_content_before
);
184 free (m
->mp_content_after
);
186 for (part
= m
->mp_parts
; part
; part
= next
) {
187 next
= part
->mp_next
;
188 free_content (part
->mp_part
);
194 ct
->c_ctparams
= NULL
;
203 if (!(p
= (struct partial
*) ct
->c_ctparams
))
209 ct
->c_ctparams
= NULL
;
214 free_external (CT ct
)
218 if (!(e
= (struct exbody
*) ct
->c_ctparams
))
221 free_content (e
->eb_content
);
225 ct
->c_ctparams
= NULL
;
237 free(pm
->pm_charset
);
250 * Free data structures related to encoding/decoding
251 * Content-Transfer-Encodings.
255 free_encoding (CT ct
, int toplevel
)
257 CE ce
= &ct
->c_cefile
;
266 (void) m_unlink (ce
->ce_file
);
272 ct
->c_ceopenfnx
= NULL
;
278 freects_done (int status
)
282 for (ctp
= cts
; ctp
&& *ctp
; ctp
++)