]> diplodocus.org Git - nmh/blobdiff - uip/mhfree.c
Try using -man instead of -mandoc in test-manpages on OpenBSD
[nmh] / uip / mhfree.c
index aef86cd84ac42f5c0ad582618de2a19080553aa6..5fa2a59cfa3bc1ff3059aede1c28d8748e21a0f1 100644 (file)
@@ -3,23 +3,25 @@
  * mhfree.c -- routines to free the data structures used to
  *          -- represent MIME messages
  *
  * mhfree.c -- routines to free the data structures used to
  *          -- represent MIME messages
  *
- * $Id$
+ * This code is Copyright (c) 2002, by the authors of nmh.  See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
  */
 
 #include <h/mh.h>
  */
 
 #include <h/mh.h>
-#include <errno.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 
 #include <h/mime.h>
 #include <h/mhparse.h>
 
-extern int errno;
+/* The list of top-level contents to display */
+CT *cts = NULL;
 
 /*
  * prototypes
  */
 
 /*
  * prototypes
  */
-void free_content (CT);
 void free_header (CT);
 void free_ctinfo (CT);
 void free_encoding (CT, int);
 void free_header (CT);
 void free_ctinfo (CT);
 void free_encoding (CT, int);
+void freects_done (int);
 
 /*
  * static prototypes
 
 /*
  * static prototypes
@@ -99,6 +101,8 @@ free_content (CT ct)
        free (ct->c_id);
     if (ct->c_descr)
        free (ct->c_descr);
        free (ct->c_id);
     if (ct->c_descr)
        free (ct->c_descr);
+    if (ct->c_dispo)
+       free (ct->c_dispo);
 
     if (ct->c_file) {
        if (ct->c_unlink)
 
     if (ct->c_file) {
        if (ct->c_unlink)
@@ -199,6 +203,8 @@ free_multi (CT ct)
        free (m->mp_start);
     if (m->mp_stop)
        free (m->mp_stop);
        free (m->mp_start);
     if (m->mp_stop)
        free (m->mp_stop);
+    free (m->mp_content_before);
+    free (m->mp_content_after);
        
     for (part = m->mp_parts; part; part = next) {
        next = part->mp_next;
        
     for (part = m->mp_parts; part; part = next) {
        next = part->mp_next;
@@ -239,6 +245,8 @@ free_external (CT ct)
     free_content (e->eb_content);
     if (e->eb_body)
        free (e->eb_body);
     free_content (e->eb_content);
     if (e->eb_body)
        free (e->eb_body);
+    if (e->eb_url)
+       free (e->eb_url);
 
     free ((char *) e);
     ct->c_ctparams = NULL;
 
     free ((char *) e);
     ct->c_ctparams = NULL;
@@ -253,10 +261,7 @@ free_external (CT ct)
 void
 free_encoding (CT ct, int toplevel)
 {
 void
 free_encoding (CT ct, int toplevel)
 {
-    CE ce;
-
-    if (!(ce = ct->c_cefile))
-       return;
+    CE ce = &ct->c_cefile;
 
     if (ce->ce_fp) {
        fclose (ce->ce_fp);
 
     if (ce->ce_fp) {
        fclose (ce->ce_fp);
@@ -267,12 +272,23 @@ free_encoding (CT ct, int toplevel)
        if (ce->ce_unlink)
            unlink (ce->ce_file);
        free (ce->ce_file);
        if (ce->ce_unlink)
            unlink (ce->ce_file);
        free (ce->ce_file);
+       ce->ce_file = NULL;
     }
 
     }
 
-    if (toplevel) {
-       free ((char *) ce);
-       ct->c_cefile = NULL;
-    } else {
+    if (! toplevel) {
        ct->c_ceopenfnx = NULL;
     }
 }
        ct->c_ceopenfnx = NULL;
     }
 }
+
+
+void
+freects_done (int status)
+{
+    CT *ctp;
+
+    if ((ctp = cts))
+       for (; *ctp; ctp++)
+           free_content (*ctp);
+
+    exit (status);
+}