Remove caching of external MIME parts.
authormarkus schnalke <meillo@marmaro.de>
Wed, 11 Apr 2012 15:23:59 +0000 (17:23 +0200)
committermarkus schnalke <meillo@marmaro.de>
Wed, 11 Apr 2012 15:23:59 +0000 (17:23 +0200)
I.e. -rcache/-wcache switches and nmh-cache/nmh-private-cache profile entries.
External MIME parts are *very* rare nowadays, who cares about caching
them, anyway?

15 files changed:
config/config.c
h/Makefile.in
h/mh.h
h/mhcachesbr.h [deleted file]
man/mhlist.man1
man/mhshow.man1
man/mhstore.man1
uip/Makefile.in
uip/mhbuild.c
uip/mhcachesbr.c [deleted file]
uip/mhlist.c
uip/mhparse.c
uip/mhshow.c
uip/mhstore.c
uip/mhtest.c

index f38866b..70a9a40 100644 (file)
@@ -93,8 +93,6 @@ char *nsequence = "Sequence-Negation";
 
 /* profile entries for storage locations */
 char *nmhstorage   = "nmh-storage";
-char *nmhcache     = "nmh-cache";
-char *nmhprivcache = "nmh-private-cache";
 
 /* profile entry for external ftp access command */
 char *nmhaccessftp = "nmh-access-ftp";
index de70d7a..78db70b 100644 (file)
@@ -9,7 +9,7 @@ VPATH  = @srcdir@
 
 # header files included in distribution
 HDRS = addrsbr.h aliasbr.h crawl_folders.h dropsbr.h fmt_compile.h     \
-       fmt_scan.h mf.h mh.h mhcachesbr.h mhparse.h mime.h        \
+       fmt_scan.h mf.h mh.h mhparse.h mime.h        \
        nmh.h prototypes.h rcvmail.h         \
        scansbr.h signals.h tws.h utils.h
 
diff --git a/h/mh.h b/h/mh.h
index 0530051..14f42f4 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -298,8 +298,6 @@ extern char *mimetypequeryproc;
 extern char *msgprot;
 extern char *nmhaccessftp;
 extern char *nmhstorage;
-extern char *nmhcache;
-extern char *nmhprivcache;
 extern char *nsequence;
 extern char *profile;
 extern char *psequence;
diff --git a/h/mhcachesbr.h b/h/mhcachesbr.h
deleted file mode 100644 (file)
index 77caabf..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-** mhcachesbr.h -- definitions for manipulating MIME content cache
-*/
-
-/*
-** various cache policies
-*/
-static struct swit caches[] = {
-#define CACHE_NEVER    0
-       { "never", 0 },
-#define CACHE_PRIVATE  1
-       { "private", 0 },
-#define CACHE_PUBLIC   2
-       { "public", 0 },
-#define CACHE_ASK      3
-       { "ask", 0 },
-       { NULL, 0 }
-};
index e6016bc..b9b098c 100644 (file)
@@ -20,10 +20,6 @@ mhlist \- list information about MIME messages
 \&...
 .RB [ \-headers " | " \-noheaders ]
 .RB [ \-realsize " | " \-norealsize ]
-.RB [ \-rcache
-.IR policy ]
-.RB [ \-wcache
-.IR policy ]
 .RB [ \-verbose " | " \-noverbose ]
 .RB [ \-version ]
 .RB [ \-help ]
@@ -167,8 +163,6 @@ mhbuild(1), mhshow(1), mhstore(1), sendfiles(1)
 .RB ` msgs "' defaults to cur"
 .RB ` \-headers '
 .RB ` \-realsize '
-.RB ` \-rcache \ ask'
-.RB ` \-wcache \ ask'
 .RB ` \-noverbose '
 .fi
 
index 57bfa31..e3fbdb7 100644 (file)
@@ -20,10 +20,6 @@ mhshow \- display MIME messages
 \&...
 .RB [ \-form
 .IR formfile ]
-.RB [ \-rcache
-.IR policy ]
-.RB [ \-wcache
-.IR policy ]
 .RB [ \-version ]
 .RB [ \-help ]
 .ad
@@ -440,58 +436,6 @@ local filename
 .PP
 The program should terminate with an exit status of zero if the
 retrieval is successful, and a non-zero exit status otherwise.
-.SS "The Content Cache"
-When
-.B mhshow
-encounters an external content containing a
-\*(lqContent-ID:\*(rq field, and if the content allows caching, then
-depending on the caching behavior of
-.BR mhshow ,
-the content might be read from or written to a cache.
-.PP
-The caching behavior of
-.B mhshow
-is controlled with the
-.B \-rcache
-and
-.B \-wcache
-switches, which define the policy for reading from,
-and writing to, the cache, respectively.  One of four policies may be
-specified: \*(lqpublic\*(rq, indicating that
-.B mhshow
-should make use
-of a publically-accessible content cache; \*(lqprivate\*(rq, indicating
-that
-.B mhshow
-should make use of the user's private content cache;
-\*(lqnever\*(rq, indicating that
-.B mhshow
-should never make use of
-caching; and, \*(lqask\*(rq, indicating that
-.B mhshow
-should ask the user.
-.PP
-There are two directories where contents may be cached: the profile entry
-\*(lqnmh-cache\*(rq names a directory containing world-readable contents, and,
-the profile entry \*(lqnmh-private-cache\*(rq names a directory containing
-private contents.  The former should be an absolute (rooted) directory
-name.
-.PP
-For example,
-.PP
-.RS 5
-nmh-cache: /tmp
-.RE
-.PP
-might be used if you didn't care that the cache got wiped after each
-reboot of the system.  The private cache is interpreted relative to the user's
-mail storage, if not rooted, e.g.,
-.PP
-.RS 5
-nmh-private-cache: .cache
-.RE
-.PP
-(which is the default value).
 .SS "User Environment"
 Because the display environment in which
 .B mhshow
@@ -546,8 +490,6 @@ installation.
 ^Current\-Folder:~^To find the default current folder
 ^Unseen\-Sequence:~^To name sequences denoting unseen messages
 ^nmh-access-ftp:~^Program to retrieve contents via FTP
-^nmh-cache~^Public directory to store cached external contents
-^nmh-private-cache~^Personal directory to store cached external contents
 ^mhshow-charset-<charset>~^Template for environment to render character sets
 ^mhshow-show-<type>*~^Template for displaying contents
 ^Pager:~^Default program to display text/plain content
@@ -561,9 +503,7 @@ mhbuild(1), mhl(1), mhlist(1), mhstore(1), sendfiles(1)
 .RB ` +folder "' defaults to the current folder"
 .RB ` msgs "' defaults to cur"
 .RB ` \-form \ mhl.headers'
-.RB ` \-rcache \ ask'
 .RB ` \-noverbose '
-.RB ` \-wcache \ ask'
 .fi
 
 .SH CONTEXT
index 0a338e7..fcd833d 100644 (file)
@@ -19,10 +19,6 @@ mhstore \- store contents of MIME messages into files
 .IR content ]
 \&...
 .RB [ \-auto " | " \-noauto ]
-.RB [ \-rcache
-.IR policy ]
-.RB [ \-wcache
-.IR policy ]
 .RB [ \-version ]
 .RB [ \-help ]
 .ad
@@ -384,58 +380,6 @@ local filename
 .PP
 The program should terminate with an exit status of zero if the
 retrieval is successful, and a non-zero exit status otherwise.
-.SS "The Content Cache"
-When
-.B mhstore
-encounters an external content containing a
-\*(lqContent-ID:\*(rq field, and if the content allows caching, then
-depending on the caching behavior of
-.BR mhstore ,
-the content might be read from or written to a cache.
-.PP
-The caching behavior of
-.B mhstore
-is controlled with the
-.B \-rcache
-and
-.B \-wcache
-switches, which define the policy for reading from,
-and writing to, the cache, respectively.  One of four policies may be
-specified: \*(lqpublic\*(rq, indicating that
-.B mhstore
-should make use
-of a publically-accessible content cache; \*(lqprivate\*(rq, indicating
-that
-.B mhstore
-should make use of the user's private content cache;
-\*(lqnever\*(rq, indicating that
-.B mhstore
-should never make use of
-caching; and, \*(lqask\*(rq, indicating that
-.B mhstore
-should ask the user.
-.PP
-There are two directories where contents may be cached: the profile entry
-\*(lqnmh-cache\*(rq names a directory containing world-readable contents, and,
-the profile entry \*(lqnmh-private-cache\*(rq names a directory containing
-private contents.  The former should be an absolute (rooted) directory
-name.
-.PP
-For example,
-.PP
-.RS 5
-nmh-cache: /tmp
-.RE
-.PP
-might be used if you didn't care that the cache got wiped after each
-reboot of the system.  The private chace is interpreted relative to the user's
-mail storage, if not rooted, e.g.,
-.PP
-.RS 5
-nmh-private-cache: .cache
-.RE
-.PP
-(which is the default value).
 .SS "User Environment"
 Because the display environment in which
 .B mhstore
@@ -478,8 +422,6 @@ installation.
 ^Path:~^To determine the user's mail storage
 ^Current\-Folder:~^To find the default current folder
 ^nmh-access-ftp:~^Program to retrieve contents via FTP
-^nmh-cache~^Public directory to store cached external contents
-^nmh-private-cache~^Personal directory to store cached external contents
 ^nmh-storage~^Directory to store contents
 ^mhstore-store-<type>*~^Template for storing contents
 .fi
@@ -492,8 +434,6 @@ mhbuild(1), mhlist(1), mhshow(1), sendfiles(1)
 .RB ` +folder "' defaults to the current folder"
 .RB ` msgs "' defaults to cur"
 .RB ` \-noauto '
-.RB ` \-rcache \ ask'
-.RB ` \-wcache \ ask'
 
 .SH CONTEXT
 If a folder is given, it will become the current folder.  The last
index 6d6347d..66db186 100644 (file)
@@ -66,7 +66,7 @@ SCMDS = inc
 SRCS = ali.c aliasbr.c anno.c ap.c burst.c comp.c \
        dist.c distsbr.c dp.c dropsbr.c flist.c fmtdump.c \
        folder.c forw.c inc.c mark.c mmh.sh mmhwrap.sh mhbuild.c \
-       mhcachesbr.c mhfree.c mhl.c mhlist.c mhlistsbr.c \
+       mhfree.c mhl.c mhlist.c mhlistsbr.c \
        mhmail.c mhmisc.c mhoutsbr.c mhparam.c mhparse.c \
        mhpath.c mhshow.c mhshowsbr.c mhstore.c mhtest.c \
        msgchk.c new.c packf.c pick.c print-mimetype.sh \
@@ -134,14 +134,14 @@ mmhwrap: mmhwrap.sh
        sed "s,%bindir%,"$(bindir)"," $(srcdir)/mmhwrap.sh >mmhwrap
        chmod +x mmhwrap
 
-mhbuild: mhbuild.o mhcachesbr.o mhlistsbr.o mhoutsbr.o mhmisc.o mhfree.o mhparse.o termsbr.o $(LOCALLIBS)
-       $(LINK) mhbuild.o mhcachesbr.o mhlistsbr.o mhoutsbr.o mhmisc.o mhfree.o mhparse.o $(LINKLIBS) $(TERMLIB)
+mhbuild: mhbuild.o mhlistsbr.o mhoutsbr.o mhmisc.o mhfree.o mhparse.o termsbr.o $(LOCALLIBS)
+       $(LINK) mhbuild.o mhlistsbr.o mhoutsbr.o mhmisc.o mhfree.o mhparse.o $(LINKLIBS) $(TERMLIB)
 
 mhl: mhl.o termsbr.o $(LOCALLIBS)
        $(LINK) mhl.o termsbr.o $(LINKLIBS) $(TERMLIB)
 
-mhlist: mhlist.o mhparse.o mhcachesbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
-       $(LINK) mhlist.o mhparse.o mhcachesbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
+mhlist: mhlist.o mhparse.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
+       $(LINK) mhlist.o mhparse.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
 
 mhmail: mhmail.o $(LOCALLIBS)
        $(LINK) mhmail.o $(LINKLIBS)
@@ -152,14 +152,14 @@ mhparam: mhparam.o $(LOCALLIBS)
 mhpath: mhpath.o $(LOCALLIBS)
        $(LINK) mhpath.o $(LINKLIBS)
 
-mhshow: mhshow.o mhparse.o mhcachesbr.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
-       $(LINK) mhshow.o mhparse.o mhcachesbr.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
+mhshow: mhshow.o mhparse.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
+       $(LINK) mhshow.o mhparse.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
 
-mhstore: mhstore.o mhparse.o mhcachesbr.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
-       $(LINK) mhstore.o mhparse.o mhcachesbr.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
+mhstore: mhstore.o mhparse.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
+       $(LINK) mhstore.o mhparse.o mhshowsbr.o mhlistsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
 
-mhtest: mhtest.o mhparse.o mhcachesbr.o mhoutsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
-       $(LINK) mhtest.o mhparse.o mhcachesbr.o mhoutsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
+mhtest: mhtest.o mhparse.o mhoutsbr.o mhmisc.o mhfree.o termsbr.o $(LOCALLIBS)
+       $(LINK) mhtest.o mhparse.o mhoutsbr.o mhmisc.o mhfree.o termsbr.o $(LINKLIBS) $(TERMLIB)
 
 msgchk: msgchk.o $(LOCALLIBS)
        $(LINK) msgchk.o $(LINKLIBS)
index e6caba3..e12f272 100644 (file)
@@ -21,7 +21,6 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
-#include <h/mhcachesbr.h>
 #include <h/utils.h>
 
 #ifdef HAVE_SYS_TIME_H
@@ -54,19 +53,15 @@ static struct swit switches[] = {
        { "verbose", 0 },
 #define NVERBSW  11
        { "noverbose", 0 },
-#define RCACHESW  12
-       { "rcache policy", 0 },
-#define WCACHESW  13
-       { "wcache policy", 0 },
-#define CONTENTIDSW  14
+#define CONTENTIDSW  12
        { "contentid", 0 },
-#define NCONTENTIDSW  15
+#define NCONTENTIDSW  13
        { "nocontentid", 0 },
-#define VERSIONSW  16
+#define VERSIONSW  14
        { "version", 0 },
-#define HELPSW  17
+#define HELPSW  15
        { "help", 0 },
-#define DEBUGSW  18
+#define DEBUGSW  16
        { "debug", -5 },
        { NULL, 0 }
 };
@@ -91,9 +86,6 @@ static char prefix[] = "----- =_aaaaaaaaaa";
 int make_intermediates(char *);
 void content_error(char *, CT, char *, ...);
 
-/* mhcachesbr.c */
-int find_cache(CT, int, int *, char *, char *, int);
-
 /* ftpsbr.c */
 int ftp_get(char *, char *, char *, char *, char *, char *, int, int);
 
@@ -115,13 +107,6 @@ static int build_headers(CT);
 static CT build_mime(char *);
 
 
-
-/* mhcachesbr.c */
-extern int rcachesw;
-extern int wcachesw;
-extern char *cache_public;
-extern char *cache_private;
-
 int debugsw = 0;
 int verbosw = 0;
 
@@ -159,7 +144,6 @@ int
 main(int argc, char **argv)
 {
        int sizesw = 1, headsw = 1;
-       int *icachesw;
        char *cp, buf[BUFSIZ];
        char buffer[BUFSIZ], *compfile = NULL;
        char **argp, **arguments;
@@ -206,26 +190,6 @@ main(int argc, char **argv)
                                print_version(invo_name);
                                done(1);
 
-                       case RCACHESW:
-                               icachesw = &rcachesw;
-                               goto do_cache;
-                       case WCACHESW:
-                               icachesw = &wcachesw;
-                       do_cache: ;
-                               if (!(cp = *argp++) || *cp == '-')
-                                       adios(NULL, "missing argument to %s",
-                                                       argp[-2]);
-                               switch (*icachesw = smatch(cp, caches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, caches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "%s unknown", cp);
-                               default:
-                                       break;
-                               }
-                               continue;
-
                        case EBCDICSW:
                                ebcdicsw++;
                                continue;
@@ -311,15 +275,6 @@ main(int argc, char **argv)
                fclose(fp);
        }
 
-       /* Check for public cache location */
-       if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
-               cache_public = NULL;
-
-       /* Check for private cache location */
-       if (!(cache_private = context_find(nmhprivcache)))
-               cache_private = ".cache";
-       cache_private = getcpy(toabsdir(cache_private));
-
        /*
        ** Check for storage directory.  If defined, we
        ** will store temporary files there.  Else we
diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c
deleted file mode 100644 (file)
index 8d25132..0000000
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
-** mhcachesbr.c -- routines to manipulate the MIME content cache
-**
-** 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 <fcntl.h>
-#include <h/signals.h>
-#include <errno.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <h/tws.h>
-#include <h/mime.h>
-#include <h/mhparse.h>
-#include <h/mhcachesbr.h>
-#include <h/utils.h>
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <time.h>
-
-extern int debugsw;
-
-extern pid_t xpid;  /* mhshowsbr.c or mhbuild.c */
-
-/* cache policies */
-int rcachesw = CACHE_ASK;
-int wcachesw = CACHE_ASK;
-
-/*
-** Location of public and private cache.  These must
-** be set before these routines are called.
-*/
-char *cache_public;
-char *cache_private;
-
-
-/* mhparse.c (OR) mhbuild.c */
-int pidcheck (int);
-
-/* mhmisc.c */
-int part_ok(CT, int);
-int type_ok(CT, int);
-int make_intermediates(char *);
-void content_error(char *, CT, char *, ...);
-void flush_errors(void);
-
-/*
-** prototypes
-*/
-void cache_all_messages(CT *);
-int find_cache(CT, int, int *, char *, char *, int);
-
-/*
-** static prototypes
-*/
-static void cache_content(CT);
-static int find_cache_aux(int, char *, char *, char *, int);
-static int find_cache_aux2(char *, char *, char *, int);
-
-
-/*
-** Top level entry point to cache content
-** from a group of messages
-*/
-
-void
-cache_all_messages(CT *cts)
-{
-       CT ct, *ctp;
-
-       for (ctp = cts; *ctp; ctp++) {
-               ct = *ctp;
-               if (type_ok(ct, 1)) {
-                       cache_content(ct);
-                       if (ct->c_fp) {
-                               fclose(ct->c_fp);
-                               ct->c_fp = NULL;
-                       }
-                       if (ct->c_ceclosefnx)
-                               (*ct->c_ceclosefnx) (ct);
-               }
-       }
-       flush_errors();
-}
-
-
-/*
-** Entry point to cache content from external sources.
-*/
-
-static void
-cache_content(CT ct)
-{
-       int cachetype;
-       char *file, cachefile[BUFSIZ];
-       CE ce = ct->c_cefile;
-
-       if (!ct->c_id) {
-               advise(NULL, "no %s: field in %s", ID_FIELD, ct->c_file);
-               return;
-       }
-
-       if (!ce) {
-               advise(NULL, "unable to decode %s", ct->c_file);
-               return;
-       }
-
-/* THIS NEEDS TO BE FIXED */
-#if 0
-       if (ct->c_ceopenfnx == openMail) {
-               advise(NULL, "a radish may no know Greek, but I do...");
-               return;
-       }
-#endif
-
-       if (find_cache(NULL, wcachesw != CACHE_NEVER ? wcachesw : CACHE_ASK,
-                       &cachetype, ct->c_id, cachefile, sizeof(cachefile))
-                       == NOTOK) {
-               advise(NULL, "unable to cache %s's contents", ct->c_file);
-               return;
-       }
-       if (wcachesw != CACHE_NEVER && wcachesw != CACHE_ASK) {
-               fflush(stdout);
-               fprintf(stderr, "caching message %s as file %s\n", ct->c_file,
-                               cachefile);
-       }
-
-       if (ce->ce_file) {
-               int mask = umask(cachetype ? ~m_gmprot() : 0222);
-               FILE *fp;
-
-               if (debugsw)
-                       fprintf(stderr, "caching by copying %s...\n",
-                                       ce->ce_file);
-
-               file = NULL;
-               if ((*ct->c_ceopenfnx) (ct, &file) == NOTOK)
-                       goto reset_umask;
-
-               if ((fp = fopen(cachefile, "w"))) {
-                       int cc;
-                       char buffer[BUFSIZ];
-                       FILE *gp = ce->ce_fp;
-
-                       fseek(gp, 0L, SEEK_SET);
-
-                       while ((cc = fread(buffer, sizeof(*buffer),
-                               sizeof(buffer), gp)) > 0)
-                               fwrite(buffer, sizeof(*buffer), cc, fp);
-                       fflush(fp);
-
-                       if (ferror(gp)) {
-                               admonish(ce->ce_file, "error reading");
-                               unlink(cachefile);
-                       } else {
-                               if (ferror(fp)) {
-                                       admonish(cachefile, "error writing");
-                                       unlink(cachefile);
-                               }
-                       }
-                       fclose(fp);
-               } else
-                       content_error(cachefile, ct,
-                                       "unable to fopen for writing");
-reset_umask:
-               umask(mask);
-       } else {
-               if (debugsw)
-                       fprintf(stderr, "in place caching...\n");
-
-               file = cachefile;
-               if ((*ct->c_ceopenfnx) (ct, &file) != NOTOK)
-                       chmod(cachefile, cachetype ? m_gmprot() : 0444);
-       }
-}
-
-
-int
-find_cache(CT ct, int policy, int *writing, char *id, char *buffer, int buflen)
-{
-       int status = NOTOK;
-
-       if (id == NULL)
-               return NOTOK;
-       id = trimcpy(id);
-
-       if (debugsw)
-               fprintf(stderr, "find_cache %s(%d) %s %s\n",
-                               caches[policy].sw, policy,
-                               writing ? "writing" : "reading", id);
-
-       switch (policy) {
-       case CACHE_NEVER:
-       default:
-               break;
-
-       case CACHE_ASK:
-       case CACHE_PUBLIC:
-               if (cache_private && !writing &&
-                               find_cache_aux(writing ? 2 : 0,
-                               cache_private, id, buffer, buflen) == OK) {
-                       if (access(buffer, R_OK) != NOTOK) {
-got_private:
-                               if (writing)
-                                       *writing = 1;
-got_it:
-                               status = OK;
-                               break;
-                       }
-               }
-               if (cache_public && find_cache_aux(writing ? 1 : 0,
-                               cache_public, id, buffer, buflen) == OK) {
-                       if (writing || access(buffer, R_OK) != NOTOK) {
-                               if (writing)
-                                       *writing = 0;
-                               goto got_it;
-                       }
-               }
-               break;
-
-       case CACHE_PRIVATE:
-               if (cache_private && find_cache_aux(writing ? 2 : 0,
-                               cache_private, id, buffer, buflen) == OK) {
-                       if (writing || access(buffer, R_OK) != NOTOK)
-                               goto got_private;
-               }
-               break;
-
-       }
-
-       if (status == OK && policy == CACHE_ASK) {
-               int len, buflen;
-               char *bp, query[BUFSIZ];
-
-               if (xpid) {
-                       if (xpid < 0)
-                               xpid = -xpid;
-                       pidcheck(pidwait(xpid, NOTOK));
-                       xpid = 0;
-               }
-
-               /* Get buffer ready to go */
-               bp = query;
-               buflen = sizeof(query);
-
-               /* Now, construct query */
-               if (writing) {
-                       snprintf(bp, buflen, "Make cached, publically-accessible copy");
-               } else {
-                       struct stat st;
-
-                       snprintf(bp, buflen, "Use cached copy");
-                       len = strlen(bp);
-                       bp += len;
-                       buflen -= len;
-
-                       if (ct->c_partno) {
-                               snprintf(bp, buflen, " of content %s",
-                                               ct->c_partno);
-                               len = strlen(bp);
-                               bp += len;
-                               buflen -= len;
-                       }
-
-                       stat(buffer, &st);
-                       snprintf(bp, buflen, " (size %lu octets)",
-                               (unsigned long) st.st_size);
-               }
-               len = strlen(bp);
-               bp += len;
-               buflen -= len;
-
-               snprintf(bp, buflen, "\n    in file %s? ", buffer);
-
-               /* Now, check answer */
-               if (!getanswer(query))
-                       status = NOTOK;
-       }
-
-       if (status == OK && writing) {
-               if (*writing && strchr(buffer, '/'))
-                       make_intermediates(buffer);
-               unlink(buffer);
-       }
-
-       free(id);
-       return status;
-}
-
-
-static int
-find_cache_aux(int writing, char *directory, char *id, char *buffer,
-               int buflen)
-{
-       int mask, usemap;
-       char mapfile[BUFSIZ], mapname[BUFSIZ];
-       FILE *fp;
-       static int partno, pid;
-       static time_t clock = 0;
-       usemap = 1;
-
-       if (debugsw)
-               fprintf(stderr, "find_cache_aux %s usemap=%d\n",
-                               directory, usemap);
-
-       snprintf(mapfile, sizeof(mapfile), "%s/cache.map", directory);
-       if (find_cache_aux2(mapfile, id, mapname, sizeof(mapname)) == OK)
-               goto done_map;
-
-       if (!writing) {
-               if (usemap)
-                       return NOTOK;
-
-use_raw:
-               snprintf(buffer, buflen, "%s/%s", directory, id);
-               return OK;
-       }
-
-       if (!usemap && access(mapfile, W_OK) == NOTOK)
-               goto use_raw;
-
-       if (clock != 0) {
-               time_t now;
-
-               time(&now);
-               if (now > clock)
-                       clock = 0;
-       } else {
-               pid = getpid();
-       }
-
-       if (clock == 0) {
-               time(&clock);
-               partno = 0;
-       } else {
-               if (partno > 0xff) {
-                       clock++;
-                       partno = 0;
-               }
-       }
-
-       snprintf(mapname, sizeof(mapname), "%08x%04x%02x",
-                       (unsigned int) (clock & 0xffffffff),
-                       (unsigned int) (pid & 0xffff),
-                       (unsigned int) (partno++ & 0xff));
-
-       if (debugsw)
-               fprintf(stderr, "creating mapping %s->%s\n", mapname, id);
-
-       make_intermediates(mapfile);
-       mask = umask(writing == 2 ? 0077 : 0);
-       if (!(fp = lkfopen(mapfile, "a")) && errno == ENOENT) {
-               int fd;
-
-               if ((fd = creat(mapfile, 0666)) != NOTOK) {
-                       close(fd);
-                       fp = lkfopen(mapfile, "a");
-               }
-       }
-       umask(mask);
-       if (!fp)
-               return NOTOK;
-       fprintf(fp, "%s: %s\n", mapname, id);
-       lkfclose(fp, mapfile);
-
-done_map:
-       if (*mapname == '/')
-               strncpy(buffer, mapname, buflen);
-       else
-               snprintf(buffer, buflen, "%s/%s", directory, mapname);
-       if (debugsw)
-               fprintf(stderr, "use %s\n", buffer);
-
-       return OK;
-}
-
-
-static int
-find_cache_aux2(char *mapfile, char *id, char *mapname, int namelen)
-{
-       int state;
-       char buf[BUFSIZ], name[NAMESZ];
-       FILE *fp;
-
-       if (!(fp = lkfopen(mapfile, "r")))
-               return NOTOK;
-
-       for (state = FLD;;) {
-               int result;
-               char *cp, *dp;
-
-               switch (state = m_getfld(state, name, buf, sizeof(buf), fp)) {
-               case FLD:
-               case FLDPLUS:
-               case FLDEOF:
-                       strncpy(mapname, name, namelen);
-                       if (state != FLDPLUS)
-                               cp = buf;
-                       else {
-                               cp = getcpy(buf);
-                               while (state == FLDPLUS) {
-                                       state = m_getfld(state, name, buf,
-                                                       sizeof(buf), fp);
-                                       cp = add(buf, cp);
-                               }
-                       }
-                       dp = trimcpy(cp);
-                       if (cp != buf)
-                               free(cp);
-                       if (debugsw)
-                               fprintf(stderr, "compare %s to %s <- %s\n",
-                                               id, dp, mapname);
-                       result = strcmp(id, dp);
-                       free(dp);
-                       if (result == 0) {
-                               lkfclose(fp, mapfile);
-                               return OK;
-                       }
-                       if (state != FLDEOF)
-                               continue;
-                       /* else fall... */
-
-               case BODY:
-               case BODYEOF:
-               case FILEEOF:
-               default:
-                       break;
-               }
-               break;
-       }
-
-       lkfclose(fp, mapfile);
-       return NOTOK;
-}
index 66f9d89..99b2cc7 100644 (file)
@@ -14,7 +14,6 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
-#include <h/mhcachesbr.h>
 #include <h/utils.h>
 
 static struct swit switches[] = {
@@ -36,15 +35,11 @@ static struct swit switches[] = {
        { "part number", 0 },
 #define TYPESW  8
        { "type content", 0 },
-#define RCACHESW  9
-       { "rcache policy", 0 },
-#define WCACHESW  10
-       { "wcache policy", 0 },
-#define VERSIONSW  11
+#define VERSIONSW  9
        { "version", 0 },
-#define HELPSW  12
+#define HELPSW  10
        { "help", 0 },
-#define DEBUGSW  13
+#define DEBUGSW  11
        { "debug", -5 },
        { NULL, 0 }
 };
@@ -53,12 +48,6 @@ static struct swit switches[] = {
 /* mhparse.c */
 extern char *tmp;  /* directory to place temp files */
 
-/* mhcachesbr.c */
-extern int rcachesw;
-extern int wcachesw;
-extern char *cache_public;
-extern char *cache_private;
-
 /* mhmisc.c */
 extern int npart;
 extern int ntype;
@@ -104,7 +93,7 @@ int
 main(int argc, char **argv)
 {
        int sizesw = 1, headsw = 1;
-       int msgnum, *icachesw;
+       int msgnum;
        char *cp, *file = NULL, *folder = NULL;
        char *maildir, buf[100], **argp;
        char **arguments;
@@ -145,25 +134,6 @@ main(int argc, char **argv)
                                print_version(invo_name);
                                done(1);
 
-                       case RCACHESW:
-                               icachesw = &rcachesw;
-                               goto do_cache;
-                       case WCACHESW:
-                               icachesw = &wcachesw;
-do_cache:
-                               if (!(cp = *argp++) || *cp == '-')
-                                       adios(NULL, "missing argument to %s", argp[-2]);
-                               switch (*icachesw = smatch(cp, caches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, caches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "%s unknown", cp);
-                               default:
-                                       break;
-                               }
-                               continue;
-
                        case HEADSW:
                                headsw = 1;
                                continue;
@@ -229,15 +199,6 @@ do_cache:
 
        set_endian();
 
-       /* Check for public cache location */
-       if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
-               cache_public = NULL;
-
-       /* Check for private cache location */
-       if (!(cache_private = context_find(nmhprivcache)))
-               cache_private = ".cache";
-       cache_private = getcpy(toabsdir(cache_private));
-
        /*
        ** Check for storage directory.  If specified,
        ** then store temporary files there.  Else we
index 2ee95f4..01170a1 100644 (file)
@@ -23,10 +23,6 @@ extern int endian;  /* mhmisc.c */
 
 extern pid_t xpid;  /* mhshowsbr.c  */
 
-/* cache policies */
-extern int rcachesw;  /* mhcachesbr.c */
-extern int wcachesw;  /* mhcachesbr.c */
-
 /*
 ** Directory to place temp files.  This must
 ** be set before these routines are called.
@@ -80,9 +76,6 @@ struct k2v SubApplication[] = {
 };
 
 
-/* mhcachesbr.c */
-int find_cache(CT, int, int *, char *, char *, int);
-
 /* mhmisc.c */
 int part_ok(CT, int);
 int type_ok(CT, int);
@@ -2270,8 +2263,6 @@ clean_up:
 static int
 openExternal(CT ct, CT cb, CE ce, char **file, int *fd)
 {
-       char cachefile[BUFSIZ];
-
        if (ce->ce_fp) {
                fseek(ce->ce_fp, 0L, SEEK_SET);
                goto ready_already;
@@ -2286,17 +2277,6 @@ openExternal(CT ct, CT cb, CE ce, char **file, int *fd)
                goto ready_already;
        }
 
-       if (find_cache(ct, rcachesw, (int *) 0, cb->c_id,
-                       cachefile, sizeof(cachefile)) != NOTOK) {
-               if ((ce->ce_fp = fopen(cachefile, "r"))) {
-                       ce->ce_file = getcpy(cachefile);
-                       ce->ce_unlink = 0;
-                       goto ready_already;
-               } else {
-                       admonish(cachefile, "unable to fopen for reading");
-               }
-       }
-
        return OK;
 
 ready_already:
@@ -2319,8 +2299,7 @@ InitFile(CT ct)
 static int
 openFile(CT ct, char **file)
 {
-       int fd, cachetype;
-       char cachefile[BUFSIZ];
+       int fd;
        struct exbody *e = ct->c_ctexbody;
        CE ce = ct->c_cefile;
 
@@ -2346,39 +2325,6 @@ openFile(CT ct, char **file)
                return NOTOK;
        }
 
-       if ((!e->eb_permission ||
-                       mh_strcasecmp(e->eb_permission, "read-write")) &&
-                       find_cache(NULL, wcachesw, &cachetype,
-                       e->eb_content->c_id, cachefile, sizeof(cachefile))
-                       != NOTOK) {
-               int mask;
-               FILE *fp;
-
-               mask = umask(cachetype ? ~m_gmprot() : 0222);
-               if ((fp = fopen(cachefile, "w"))) {
-                       int cc;
-                       char buffer[BUFSIZ];
-                       FILE *gp = ce->ce_fp;
-
-                       fseek(gp, 0L, SEEK_SET);
-
-                       while ((cc = fread(buffer, sizeof(*buffer),
-                                       sizeof(buffer), gp)) > 0)
-                               fwrite(buffer, sizeof(*buffer), cc, fp);
-                       fflush(fp);
-
-                       if (ferror(gp)) {
-                               admonish(ce->ce_file, "error reading");
-                               unlink(cachefile);
-                       } else if (ferror(fp)) {
-                               admonish(cachefile, "error writing");
-                               unlink(cachefile);
-                       }
-                       fclose(fp);
-               }
-               umask(mask);
-       }
-
        fseek(ce->ce_fp, 0L, SEEK_SET);
        *file = ce->ce_file;
        return fileno(ce->ce_fp);
@@ -2398,10 +2344,10 @@ InitFTP(CT ct)
 static int
 openFTP(CT ct, char **file)
 {
-       int cachetype, caching, fd;
+       int fd;
        int len, buflen;
        char *bp, *ftp, *user, *pass;
-       char buffer[BUFSIZ], cachefile[BUFSIZ];
+       char buffer[BUFSIZ];
        struct exbody *e;
        CE ce;
        static char *username = NULL;
@@ -2491,23 +2437,9 @@ openFTP(CT ct, char **file)
        }
 
        ce->ce_unlink = (*file == NULL);
-       caching = 0;
-       cachefile[0] = '\0';
-       if ((!e->eb_permission ||
-                       mh_strcasecmp(e->eb_permission, "read-write")) &&
-                       find_cache(NULL, wcachesw, &cachetype,
-                       e->eb_content->c_id, cachefile, sizeof(cachefile))
-                       != NOTOK) {
-               if (*file == NULL) {
-                       ce->ce_unlink = 0;
-                       caching = 1;
-               }
-       }
 
        if (*file)
                ce->ce_file = getcpy(*file);
-       else if (caching)
-               ce->ce_file = getcpy(cachefile);
        else
                ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
 
@@ -2554,38 +2486,6 @@ openFTP(CT ct, char **file)
                break;
        }
 
-       if (cachefile[0]) {
-               if (caching)
-                       chmod(cachefile, cachetype ? m_gmprot() : 0444);
-               else {
-                       int mask;
-                       FILE *fp;
-
-                       mask = umask(cachetype ? ~m_gmprot() : 0222);
-                       if ((fp = fopen(cachefile, "w"))) {
-                               int cc;
-                               FILE *gp = ce->ce_fp;
-
-                               fseek(gp, 0L, SEEK_SET);
-
-                               while ((cc= fread(buffer, sizeof(*buffer),
-                                               sizeof(buffer), gp)) > 0)
-                                       fwrite(buffer, sizeof(*buffer), cc, fp);
-                               fflush(fp);
-
-                               if (ferror(gp)) {
-                                       admonish(ce->ce_file, "error reading");
-                                       unlink(cachefile);
-                               } else if (ferror(fp)) {
-                                       admonish(cachefile, "error writing");
-                                       unlink(cachefile);
-                               }
-                               fclose(fp);
-                       }
-                       umask(mask);
-               }
-       }
-
        fseek(ce->ce_fp, 0L, SEEK_SET);
        *file = ce->ce_file;
        return fileno(ce->ce_fp);
index ac6b0c3..53f96f2 100644 (file)
@@ -14,7 +14,6 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
-#include <h/mhcachesbr.h>
 #include <h/utils.h>
 
 static struct swit switches[] = {
@@ -30,15 +29,11 @@ static struct swit switches[] = {
        { "part number", 0 },
 #define TYPESW  5
        { "type content", 0 },
-#define RCACHESW  6
-       { "rcache policy", 0 },
-#define WCACHESW  7
-       { "wcache policy", 0 },
-#define VERSIONSW  8
+#define VERSIONSW  6
        { "version", 0 },
-#define HELPSW  9
+#define HELPSW  7
        { "help", 0 },
-#define DEBUGSW  10
+#define DEBUGSW  8
        { "debug", -5 },
        { NULL, 0 }
 };
@@ -47,12 +42,6 @@ static struct swit switches[] = {
 /* mhparse.c */
 extern char *tmp;  /* directory to place temp files */
 
-/* mhcachesbr.c */
-extern int rcachesw;
-extern int wcachesw;
-extern char *cache_public;
-extern char *cache_private;
-
 /* mhshowsbr.c */
 extern int nolist;
 extern char *formsw;
@@ -95,7 +84,7 @@ static void pipeser(int);
 int
 main(int argc, char **argv)
 {
-       int msgnum, *icachesw;
+       int msgnum;
        char *cp, *file = NULL, *folder = NULL;
        char *maildir, buf[100], **argp;
        char **arguments;
@@ -137,26 +126,6 @@ main(int argc, char **argv)
                                print_version(invo_name);
                                done(1);
 
-                       case RCACHESW:
-                               icachesw = &rcachesw;
-                               goto do_cache;
-                       case WCACHESW:
-                               icachesw = &wcachesw;
-do_cache:
-                               if (!(cp = *argp++) || *cp == '-')
-                                       adios(NULL, "missing argument to %s",
-                                                       argp[-2]);
-                               switch (*icachesw = smatch(cp, caches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, caches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "%s unknown", cp);
-                               default:
-                                       break;
-                               }
-                               continue;
-
                        case PARTSW:
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(NULL, "missing argument to %s",
@@ -242,15 +211,6 @@ do_cache:
                fclose(fp);
        }
 
-       /* Check for public cache location */
-       if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
-               cache_public = NULL;
-
-       /* Check for private cache location */
-       if (!(cache_private = context_find(nmhprivcache)))
-               cache_private = ".cache";
-       cache_private = getcpy(toabsdir(cache_private));
-
        /*
        ** Check for storage directory.  If specified,
        ** then store temporary files there.  Else we
index 950483b..ed36c96 100644 (file)
@@ -15,7 +15,6 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
-#include <h/mhcachesbr.h>
 #include <h/utils.h>
 
 static struct swit switches[] = {
@@ -29,15 +28,11 @@ static struct swit switches[] = {
        { "part number", 0 },
 #define TYPESW  4
        { "type content", 0 },
-#define RCACHESW  5
-       { "rcache policy", 0 },
-#define WCACHESW  6
-       { "wcache policy", 0 },
-#define VERSIONSW  7
+#define VERSIONSW  5
        { "version", 0 },
-#define HELPSW  8
+#define HELPSW  6
        { "help", 0 },
-#define DEBUGSW  9
+#define DEBUGSW  7
        { "debug", -5 },
        { NULL, 0 }
 };
@@ -46,12 +41,6 @@ static struct swit switches[] = {
 /* mhparse.c */
 extern char *tmp;  /* directory to place temp files */
 
-/* mhcachesbr.c */
-extern int rcachesw;
-extern int wcachesw;
-extern char *cache_public;
-extern char *cache_private;
-
 /* mhmisc.c */
 extern int npart;
 extern int ntype;
@@ -134,7 +123,7 @@ static void store_all_messages(CT *);
 int
 main(int argc, char **argv)
 {
-       int msgnum, *icachesw;
+       int msgnum;
        char *cp, *file = NULL, *folder = NULL;
        char *maildir, buf[100], **argp;
        char **arguments;
@@ -183,26 +172,6 @@ main(int argc, char **argv)
                                autosw = 0;
                                continue;
 
-                       case RCACHESW:
-                               icachesw = &rcachesw;
-                               goto do_cache;
-                       case WCACHESW:
-                               icachesw = &wcachesw;
-do_cache:
-                               if (!(cp = *argp++) || *cp == '-')
-                                       adios(NULL, "missing argument to %s",
-                                                       argp[-2]);
-                               switch (*icachesw = smatch(cp, caches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, caches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "%s unknown", cp);
-                               default:
-                                       break;
-                               }
-                               continue;
-
                        case PARTSW:
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(NULL, "missing argument to %s",
@@ -269,15 +238,6 @@ do_cache:
                fclose(fp);
        }
 
-       /* Check for public cache location */
-       if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
-               cache_public = NULL;
-
-       /* Check for private cache location */
-       if (!(cache_private = context_find(nmhprivcache)))
-               cache_private = ".cache";
-       cache_private = getcpy(toabsdir(cache_private));
-
        /*
        ** Cache the current directory before we do any chdirs()'s.
        */
index c7afd66..a19475b 100644 (file)
@@ -14,7 +14,6 @@
 #include <h/tws.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
-#include <h/mhcachesbr.h>
 #include <h/utils.h>
 
 static struct swit switches[] = {
@@ -30,15 +29,11 @@ static struct swit switches[] = {
        { "part number", 0 },
 #define TYPESW  5
        { "type content", 0 },
-#define RCACHESW  6
-       { "rcache policy", 0 },
-#define WCACHESW  7
-       { "wcache policy", 0 },
-#define VERSIONSW  8
+#define VERSIONSW  6
        { "version", 0 },
-#define HELPSW  9
+#define HELPSW  7
        { "help", 0 },
-#define DEBUGSW  10
+#define DEBUGSW  8
        { "debug", -5 },
        { NULL, 0 }
 };
@@ -49,12 +44,6 @@ int ebcdicsw = 0;  /* hack for linking purposes */
 /* mhparse.c */
 extern char *tmp;  /* directory to place temp files */
 
-/* mhcachesbr.c */
-extern int rcachesw;
-extern int wcachesw;
-extern char *cache_public;
-extern char *cache_private;
-
 /* mhmisc.c */
 extern int npart;
 extern int ntype;
@@ -100,7 +89,7 @@ static void pipeser(int);
 int
 main(int argc, char **argv)
 {
-       int msgnum, *icachesw;
+       int msgnum;
        char *cp, *file = NULL, *folder = NULL;
        char *maildir, buf[100], *outfile = NULL;
        char **argp, **arguments;
@@ -141,26 +130,6 @@ main(int argc, char **argv)
                                print_version(invo_name);
                                done(1);
 
-                       case RCACHESW:
-                               icachesw = &rcachesw;
-                               goto do_cache;
-                       case WCACHESW:
-                               icachesw = &wcachesw;
-do_cache:
-                               if (!(cp = *argp++) || *cp == '-')
-                                       adios(NULL, "missing argument to %s",
-                                                       argp[-2]);
-                               switch (*icachesw = smatch(cp, caches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, caches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "%s unknown", cp);
-                               default:
-                                       break;
-                               }
-                               continue;
-
                        case PARTSW:
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(NULL, "missing argument to %s", argp[-2]);
@@ -221,15 +190,6 @@ do_cache:
        if (outfile == NULL)
                adios(NULL, "must specify output file");
 
-       /* Check for public cache location */
-       if ((cache_public = context_find(nmhcache)) && *cache_public != '/')
-               cache_public = NULL;
-
-       /* Check for private cache location */
-       if (!(cache_private = context_find(nmhprivcache)))
-               cache_private = ".cache";
-       cache_private = getcpy(toabsdir(cache_private));
-
        /*
        ** Check for storage directory.  If specified,
        ** then store temporary files there.  Else we