*/
static void pipeser(int);
-int autosw = 0;
+int autosw = 1;
/*
** Cache of current directory. This must be
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 *);
** 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
static int
store_generic(CT ct)
{
+ char **ap, **vp, *cp;
+ CI ci = &ct->c_ctinfo;
+
/*
- ** Check if the content specifies a filename.
+ ** Check if the content specifies a filename in its MIME parameters.
** Don't bother with this for type "message"
- ** (only "message/rfc822" will use store_generic).
+ ** (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 (autosw && ct->c_type != CT_MESSAGE)
- get_storeproc(ct);
+ if (autosw && ct->c_type != CT_MESSAGE && !ct->c_storeproc) {
+ /*
+ ** Check the attribute/value pairs, for the attribute "name".
+ ** If found, take the basename, do a few sanity checks and
+ ** copy the value into c_storeproc.
+ */
+ for (ap = ci->ci_attrs, vp = ci->ci_values; *ap; ap++,vp++) {
+ if (mh_strcasecmp(*ap, "name")!=0) {
+ continue;
+ }
+ cp = mhbasename(*vp);
+ if (*cp && *cp!='.' && *cp!='|' && *cp!='!' &&
+ !strchr(cp, '%')) {
+ /* filename looks good: use it */
+ ct->c_storeproc = getcpy(cp);
+ }
+ break;
+ }
+ }
return store_content(ct, NULL);
}
if (autosw) {
char *cp;
- if ((cp = e->eb_name) && *cp != '/' && *cp != '.' &&
- *cp != '|' && *cp != '!' && !strchr(cp, '%')) {
+ cp = mhbasename(e->eb_name);
+ if (*cp && *cp!='.' && *cp!='|' && *cp!='!' &&
+ !strchr(cp, '%')) {
+ /* filename looks good: use it */
if (!ct->c_storeproc)
ct->c_storeproc = getcpy(cp);
if (!p->c_storeproc)
FILE *fp;
/*
- ** If the pathname is absolute, make sure
- ** all the relevant directories exist.
+ ** If the pathname contains directories, make sure
+ ** all of them exist.
*/
if (strchr(ct->c_storage, '/') && make_intermediates(ct->c_storage)
== NOTOK)
/*
-** 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.
*/