mhstore: Made -auto the default.
[mmh] / uip / mhstore.c
index ed36c96..6f6746d 100644 (file)
@@ -71,7 +71,7 @@ void freects_done(int) NORETURN;
 */
 static void pipeser(int);
 
-int autosw = 0;
+int autosw = 1;
 
 /*
 ** Cache of current directory.  This must be
@@ -106,7 +106,6 @@ int show_content_aux(CT, int, char *, char *);
 static void store_single_message(CT);
 static int store_switch(CT);
 static int store_generic(CT);
-static int store_application(CT);
 static int store_multi(CT);
 static int store_partial(CT);
 static int store_external(CT);
@@ -115,7 +114,6 @@ static int store_content(CT, CT);
 static int output_content_file(CT, int);
 static int output_content_folder(char *, char *);
 static int parse_format_string(CT, char *, char *, int, char *);
-static void get_storeproc(CT);
 static int copy_some_headers(FILE *, CT);
 static void store_all_messages(CT *);
 
@@ -384,8 +382,6 @@ store_all_messages(CT *cts)
        ** Check for the directory in which to
        ** store any contents.
        */
-       if (autosw)
-               dir = getcpy(cwd);
        if ((cp = context_find(nmhstorage)) && *cp)
                dir = getcpy(cp);
        else
@@ -450,9 +446,6 @@ store_switch(CT ct)
                break;
 
        case CT_APPLICATION:
-               return store_application(ct);
-               break;
-
        case CT_TEXT:
        case CT_AUDIO:
        case CT_IMAGE:
@@ -471,83 +464,35 @@ store_switch(CT ct)
 
 /*
 ** Generic routine to store a MIME content.
-** (audio, video, image, text, message/rfc922)
+** (application, audio, video, image, text, message/rfc922)
 */
 
 static int
 store_generic(CT ct)
 {
-       /*
-       ** Check if the content specifies a filename.
-       ** Don't bother with this for type "message"
-       ** (only "message/rfc822" will use store_generic).
-       */
-       if (autosw && ct->c_type != CT_MESSAGE)
-               get_storeproc(ct);
-
-       return store_content(ct, NULL);
-}
-
-
-/*
-** Store content of type "application"
-*/
-
-static int
-store_application(CT ct)
-{
-       char **ap, **ep;
+       char **ap, **ep, *cp;
        CI ci = &ct->c_ctinfo;
 
-       /* Check if the content specifies a filename */
-       if (autosw)
-               get_storeproc(ct);
-
        /*
-       ** If storeproc is not defined, and the content is type
-       ** "application/octet-stream", we also check for various
-       ** attribute/value pairs which specify if this a tar file.
+       ** Check if the content specifies a filename in its MIME parameters.
+       ** Don't bother with this for type "message"
+       ** (only the "message" subtype "rfc822" will use store_generic).
+       ** The storeproc may already be defined, if this content
+       ** is part of a "message/external", for instance.
        */
-       if (!ct->c_storeproc && ct->c_subtype == APPLICATION_OCTETS) {
-               int tarP = 0, zP = 0, gzP = 0;
-
+       if (autosw && ct->c_type != CT_MESSAGE && !ct->c_storeproc) {
+               /*
+               ** Check the attribute/value pairs, for the attribute "name".
+               ** If found, do a few sanity checks and copy the value into
+               ** the storeproc.
+               */
                for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
-                       /* check for "type=tar" attribute */
-                       if (!mh_strcasecmp(*ap, "type")) {
-                               if (mh_strcasecmp(*ep, "tar"))
-                                       break;
-
-                               tarP = 1;
-                               continue;
-                       }
-
-                       /* check for "conversions=compress" attribute */
-                       if ((!mh_strcasecmp(*ap, "conversions") ||
-                                       !mh_strcasecmp(*ap, "x-conversions"))
-                                       && (!mh_strcasecmp(*ep, "compress") ||
-                                       !mh_strcasecmp(*ep, "x-compress"))) {
-                               zP = 1;
-                               continue;
-                       }
-                       /* check for "conversions=gzip" attribute */
-                       if ((!mh_strcasecmp(*ap, "conversions") ||
-                                       !mh_strcasecmp(*ap, "x-conversions"))
-                                       && (!mh_strcasecmp(*ep, "gzip") ||
-                                       !mh_strcasecmp(*ep, "x-gzip"))) {
-                               gzP = 1;
-                               continue;
-                       }
-               }
-
-               if (tarP) {
-                       ct->c_showproc = getcpy(zP ? "%euncompress | tar tvf -" : (gzP ? "%egzip -dc | tar tvf -" : "%etar tvf -"));
-                       if (!ct->c_storeproc) {
-                               if (autosw) {
-                                       ct->c_storeproc = getcpy(zP ? "| uncompress | tar xvpf -" : (gzP ? "| gzip -dc | tar xvpf -" : "| tar xvpf -"));
-                                       ct->c_umask = 0022;
-                               } else {
-                                       ct->c_storeproc= getcpy(zP ? "%m%P.tar.Z" : (gzP ? "%m%P.tar.gz" : "%m%P.tar"));
-                               }
+                       if (mh_strcasecmp(*ap, "name")==0 &&
+                                       *(cp = *ep) != '/' && *cp != '.' &&
+                                       *cp != '|' && *cp != '!' &&
+                                       !strchr(cp, '%')) {
+                               ct->c_storeproc = getcpy(cp);
+                               break;
                        }
                }
        }
@@ -1301,41 +1246,6 @@ raw:
 
 
 /*
-** Check if the content specifies a filename
-** in its MIME parameters.
-*/
-
-static void
-get_storeproc(CT ct)
-{
-       char **ap, **ep, *cp;
-       CI ci = &ct->c_ctinfo;
-
-       /*
-       ** If the storeproc has already been defined,
-       ** we just return (for instance, if this content
-       ** is part of a "message/external".
-       */
-       if (ct->c_storeproc)
-               return;
-
-       /*
-       ** Check the attribute/value pairs, for the attribute "name".
-       ** If found, do a few sanity checks and copy the value into
-       ** the storeproc.
-       */
-       for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
-               if (!mh_strcasecmp(*ap, "name") && *(cp = *ep) != '/' &&
-                               *cp != '.' && *cp != '|' && *cp != '!' &&
-                               !strchr(cp, '%')) {
-                       ct->c_storeproc = getcpy(cp);
-                       return;
-               }
-       }
-}
-
-
-/*
 ** Copy some of the header fields of the initial message/partial
 ** message into the header of the reassembled message.
 */