X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fmhstoresbr.c;h=5776ef357859f4e492e87ae0b275303e5219aa37;hp=d849609ffc1778130e10e8a83b25c9687493ff41;hb=08aa8c17c3241bb5c6a997ed2e01e25a4d0089ce;hpb=1691e80890e5d8ba258c51c214a3e91880e1db2b diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index d849609..5776ef3 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -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 @@ -12,12 +16,12 @@ #include #include #include -#include -#include +#include +#include #include #include +#include -extern int errno; /* * The list of top-level contents to display @@ -71,7 +75,6 @@ static int store_external (CT); static int ct_compar (CT *, CT *); static int store_content (CT, CT); static int output_content_file (CT, int); -static int check_folder (char *); static int output_content_folder (char *, char *); static int parse_format_string (CT, char *, char *, int, char *); static void get_storeproc (CT); @@ -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); } + } } } @@ -556,8 +570,7 @@ store_content (CT ct, CT p) folder = getfolder (1); /* Check if folder exists */ - if (check_folder (folder) == NOTOK) - return NOTOK; + create_folder(folder, 0, exit); /* Record the folder name */ ct->c_folder = add (folder, NULL); @@ -849,47 +862,6 @@ losing: /* - * Check if folder exists, and create - * if necessary. - */ - -static int -check_folder (char *folder) -{ - char *folderdir; - struct stat st; - - /* expand path to the folder */ - folderdir = m_mailpath (folder); - - /* Check if folder exists */ - if (stat (folderdir, &st) == NOTOK) { - int answer; - char *ep; - - if (errno != ENOENT) { - advise (folderdir, "error on folder"); - return NOTOK; - } - - ep = concat ("Create folder \"", folderdir, "\"? ", NULL); - answer = getanswer (ep); - free (ep); - - if (!answer) - return NOTOK; - - if (!makedir (folderdir)) { - advise (NULL, "unable to create folder %s", folderdir); - return NOTOK; - } - } - - return OK; -} - - -/* * Add a file to a folder. * * Return the new message number of the file @@ -906,7 +878,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, (char *)0); } else { advise (NULL, "unable to read folder %s", folder); return NOTOK;