[bug #4302] errno is not always an extern int
[mmh] / uip / mhstoresbr.c
index d849609..fc78ac1 100644 (file)
@@ -3,6 +3,10 @@
  * mhstoresbr.c -- routines to save/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 <errno.h>
 #include <setjmp.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>
 
-extern int errno;
 
 /*
  * The list of top-level contents to display
@@ -218,7 +221,7 @@ store_application (CT ct)
      * attribute/value pairs which specify if this a tar file.
      */
     if (!ct->c_storeproc && ct->c_subtype == APPLICATION_OCTETS) {
-       int tarP = 0, zP = 0;
+       int tarP = 0, zP = 0, gzP = 0;
 
        for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
            /* check for "type=tar" attribute */
@@ -236,19 +239,30 @@ store_application (CT ct)
                zP = 1;
                continue;
            }
+           /* check for "conversions=gzip" attribute */
+           if ((!strcasecmp (*ap, "conversions") || !strcasecmp (*ap, "x-conversions"))
+               && (!strcasecmp (*ep, "gzip") || !strcasecmp (*ep, "x-gzip"))) {
+               gzP = 1;
+               continue;
+           }
        }
 
        if (tarP) {
            ct->c_showproc = add (zP ? "%euncompress | tar tvf -"
-                                 : "%etar tvf -", NULL);
-           if (!ct->c_storeproc)
+                                 : (gzP ? "%egzip -dc | tar tvf -"
+                                    : "%etar tvf -"), NULL);
+           if (!ct->c_storeproc) {
                if (autosw) {
                    ct->c_storeproc = add (zP ? "| uncompress | tar xvpf -"
-                                          : "| tar xvpf -", NULL);
+                                          : (gzP ? "| gzip -dc | tar xvpf -"
+                                             : "| tar xvpf -"), NULL);
                    ct->c_umask = 0022;
                } else {
-                   ct->c_storeproc = add (zP ? "%m%P.tar.Z" : "%m%P.tar", NULL);
+                   ct->c_storeproc= add (zP ? "%m%P.tar.Z"
+                                         : (gzP ? "%m%P.tar.gz"
+                                            : "%m%P.tar"), NULL);
                }
+           }
        }
     }
 
@@ -906,7 +920,7 @@ output_content_folder (char *folder, char *filename)
     /* Read the folder. */
     if ((mp = folder_read (folder))) {
        /* Link file into folder */
-       msgnum = folder_addmsg (&mp, filename, 0, 0, 0);
+       msgnum = folder_addmsg (&mp, filename, 0, 0, 0, 0);
     } else {
        advise (NULL, "unable to read folder %s", folder);
        return NOTOK;