Added support for optional Content_Disposition header in mhbuild directive.s
[mmh] / uip / mhstore.c
index a52e00b..b756956 100644 (file)
@@ -3,6 +3,10 @@
  * mhstore.c -- store the contents of 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/md5.h>
 #include <errno.h>
 #include <signal.h>
-#include <zotnet/mts/mts.h>
-#include <zotnet/tws/tws.h>
+#include <h/mts.h>
+#include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 #include <h/mhcachesbr.h>
+#include <h/utils.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
@@ -54,7 +59,7 @@ static struct swit switches[] = {
 #define VERSIONSW              11
     { "version", 0 },
 #define        HELPSW                 12
-    { "help", 4 },
+    { "help", 0 },
 
 /*
  * switches for debugging
@@ -65,8 +70,6 @@ static struct swit switches[] = {
 };
 
 
-extern int errno;
-
 /* mhparse.c */
 extern int checksw;
 extern char *tmp;      /* directory to place temp files */
@@ -145,8 +148,7 @@ main (int argc, char **argv)
      */
     nummsgs = 0;
     maxmsgs = MAXMSGS;
-    if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs)))))
-       adios (NULL, "unable to allocate storage");
+    msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs)));
 
     /*
      * Parse arguments
@@ -249,9 +251,8 @@ do_cache:
             */
            if (nummsgs >= maxmsgs) {
                maxmsgs += MAXMSGS;
-               if (!(msgs = (char **) realloc (msgs,
-                       (size_t) (maxmsgs * sizeof(*msgs)))))
-                   adios (NULL, "unable to reallocate msgs storage");
+               msgs = (char **) mh_xrealloc (msgs,
+                   (size_t) (maxmsgs * sizeof(*msgs)));
            }
            msgs[nummsgs++] = cp;
        }
@@ -407,8 +408,7 @@ do_cache:
        context_save ();                  /* save the context file  */
     }
 
-    done (0);
-    /* NOTREACHED */
+    return done (0);
 }
 
 
@@ -427,7 +427,7 @@ pipeser (int i)
 }
 
 
-void
+int
 done (int status)
 {
     CT *ctp;
@@ -437,4 +437,5 @@ done (int status)
            free_content (*ctp);
 
     exit (status);
+    return 1;  /* dead code to satisfy the compiler */
 }