h/icalendar.h \
h/mf.h \
h/mh.h \
- h/mhcachesbr.h \
h/mhparse.h \
h/mime.h \
h/mts.h \
uip_anno_SOURCES = uip/anno.c uip/annosbr.c
uip_anno_LDADD = $(LDADD) $(POSTLINK)
-uip_burst_SOURCES = uip/burst.c uip/mhparse.c uip/mhmisc.c uip/mhfree.c \
- uip/mhcachesbr.c
+uip_burst_SOURCES = uip/burst.c \
+ uip/mhparse.c \
+ uip/mhmisc.c \
+ uip/mhfree.c \
+ #
uip_burst_LDADD = $(LDADD) $(ICONVLIB) $(POSTLINK)
uip_comp_SOURCES = uip/comp.c uip/whatnowproc.c uip/whatnowsbr.c uip/sendsbr.c \
uip_mark_SOURCES = uip/mark.c
uip_mark_LDADD = $(LDADD) $(POSTLINK)
-uip_mhbuild_SOURCES = uip/mhbuild.c uip/mhbuildsbr.c uip/mhcachesbr.c \
- uip/mhlistsbr.c uip/mhoutsbr.c uip/mhmisc.c \
- uip/mhfree.c uip/mhparse.c \
- uip/mhstoresbr.c uip/mhshowsbr.c
+uip_mhbuild_SOURCES = uip/mhbuild.c \
+ uip/mhbuildsbr.c \
+ uip/mhlistsbr.c \
+ uip/mhoutsbr.c \
+ uip/mhmisc.c \
+ uip/mhfree.c \
+ uip/mhparse.c \
+ uip/mhstoresbr.c \
+ uip/mhshowsbr.c \
+ #
uip_mhbuild_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK)
-uip_mhfixmsg_SOURCES = uip/mhfixmsg.c uip/mhparse.c uip/mhcachesbr.c \
- uip/mhoutsbr.c uip/mhmisc.c uip/mhfree.c \
- uip/mhshowsbr.c uip/mhlistsbr.c
+uip_mhfixmsg_SOURCES = uip/mhfixmsg.c \
+ uip/mhparse.c \
+ uip/mhoutsbr.c \
+ uip/mhmisc.c \
+ uip/mhfree.c \
+ uip/mhshowsbr.c \
+ uip/mhlistsbr.c \
+ #
uip_mhfixmsg_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK)
uip_mhical_SOURCES = uip/mhical.c
uip_mhical_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK)
-uip_mhlist_SOURCES = uip/mhlist.c uip/mhparse.c uip/mhcachesbr.c \
- uip/mhlistsbr.c uip/mhmisc.c uip/mhfree.c
+uip_mhlist_SOURCES = uip/mhlist.c \
+ uip/mhparse.c \
+ uip/mhlistsbr.c \
+ uip/mhmisc.c \
+ uip/mhfree.c \
+ #
uip_mhlist_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK)
-uip_mhn_SOURCES = uip/mhn.c uip/mhparse.c uip/mhcachesbr.c uip/mhshowsbr.c \
- uip/mhlistsbr.c uip/mhstoresbr.c uip/mhmisc.c uip/mhfree.c
+uip_mhn_SOURCES = uip/mhn.c \
+ uip/mhparse.c \
+ uip/mhshowsbr.c \
+ uip/mhlistsbr.c \
+ uip/mhstoresbr.c \
+ uip/mhmisc.c \
+ uip/mhfree.c \
+ #
uip_mhn_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK)
uip_mhparam_SOURCES = uip/mhparam.c
uip_mhpath_SOURCES = uip/mhpath.c
uip_mhpath_LDADD = $(LDADD) $(POSTLINK)
-uip_mhshow_SOURCES = uip/mhshow.c uip/mhparse.c uip/mhcachesbr.c \
- uip/mhshowsbr.c uip/mhlistsbr.c uip/mhmisc.c \
- uip/mhfree.c
+uip_mhshow_SOURCES = uip/mhshow.c \
+ uip/mhparse.c \
+ uip/mhshowsbr.c \
+ uip/mhlistsbr.c \
+ uip/mhmisc.c \
+ uip/mhfree.c \
+ #
uip_mhshow_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK)
-uip_mhstore_SOURCES = uip/mhstore.c uip/mhparse.c uip/mhcachesbr.c \
- uip/mhshowsbr.c uip/mhlistsbr.c uip/mhstoresbr.c \
- uip/mhmisc.c uip/mhfree.c
+uip_mhstore_SOURCES = uip/mhstore.c \
+ uip/mhparse.c \
+ uip/mhshowsbr.c \
+ uip/mhlistsbr.c \
+ uip/mhstoresbr.c \
+ uip/mhmisc.c \
+ uip/mhfree.c \
+ #
uip_mhstore_LDADD = $(LDADD) $(TERMLIB) $(ICONVLIB) $(POSTLINK)
uip_msgchk_SOURCES = uip/msgchk.c uip/popsbr.c
OBSOLETE FEATURES
-----------------
+- The MIME content cache functionality has been mostly non-functional since
+ the development on nmh, and consequently all of the content caching code
+ and related switches (-cache/-rcache/-wcache) have been removed.
+
-------------------
DEPRECATED FEATURES
-------------------
+++ /dev/null
-/* mhcachesbr.h -- definitions for manipulating MIME content cache
- */
-
-/*
- * various cache policies
- */
-
-#define CACHE_SWITCHES \
- X("never", 0, CACHE_NEVER) \
- X("private", 0, CACHE_PRIVATE) \
- X("public", 0, CACHE_PUBLIC) \
- X("ask", 0, CACHE_ASK) \
-
-#define X(sw, minchars, id) id,
-DEFINE_SWITCH_ENUM(CACHE);
-#undef X
-extern struct swit *cache_policy;
-
-void cache_all_messages(CT *cts);
-int find_cache(CT ct, int policy, int *writing, char *id,
- char *buffer, int buflen);
-
-extern int rcachesw;
-extern int wcachesw;
-
-extern char *cache_public;
-extern char *cache_private;
.RB [ \-noprefer ]
.RB [ \-headers " | " \-noheaders ]
.RB [ \-realsize " | " \-norealsize ]
-.RB [ \-rcache
-.IR policy ]
-.RB [ \-wcache
-.IR policy ]
.RB [ \-changecur " | " \-nochangecur ]
.RB [ \-verbose " | " \-noverbose ]
.RB [ \-disposition " | " \-nodisposition ]
.RB ` \-nocheck '
.RB ` \-headers '
.RB ` \-realsize '
-.RB ` \-rcache\ ask '
-.RB ` \-wcache\ ask '
.RB ` \-changecur '
.RB ` \-noverbose '
.RB ` \-nodisposition '
.\" %nmhwarning%
.
.SH NAME
-mhn \- display/list/store/cache nmh MIME messages
+mhn \- display/list/store nmh MIME messages
.SH SYNOPSIS
.HP 5
.na
.RB [ \-show " | " \-noshow ]
.RB [ \-list " | " \-nolist ]
.RB [ \-store " | " \-nostore ]
-.RB [ \-cache " | " \-nocache ]
.RB [ \-headers " | " \-noheaders ]
.RB [ \-realsize " | " \-norealsize ]
.RB [ \-serialonly " | " \-noserialonly ]
.IR formfile ]
.RB [ \-pause " | " \-nopause ]
.RB [ \-auto " | " \-noauto ]
-.RB [ \-rcache
-.IR policy ]
-.RB [ \-wcache
-.IR policy ]
.PP
.HP 5
.B mhn
.IR formfile ]
.RB [ \-markform
.IR formfile ]
-.RB [ \-rcache
-.IR policy ]
-.RB [ \-wcache
-.IR policy ]
.ad
.SH DESCRIPTION
The
will look for the \*(lqnmh-access-url\*(rq profile entry. See
.IR mhstore (1)
for more details.
-.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 publicly-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 latter is interpreted relative to the user's
-nmh directory, 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
^mhlproc:~^Default program to display message headers
^nmh-access-ftp:~^Program to retrieve contents via FTP
^nmh-access-url:~^Program to retrieve contents via HTTP
-^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
^moreproc:~^Default program to display text/plain content
.RB ` \-textonly '
.RB ` \-inlineonly '
.RB ` \-form\ mhl.headers '
-.RB ` \-rcache\ ask '
-.RB ` \-wcache\ ask '
.fi
.SH CONTEXT
If a folder is given, it will become the current folder. The last
.RB [ \-auto " | " \-noauto ]
.RB [ \-clobber
.IR always " | " auto " | " suffix " | " ask " | " never ]
-.RB [ \-rcache
-.IR policy ]
-.RB [ \-wcache
-.IR policy ]
.RB [ \-verbose " | " \-noverbose ]
.ad
.SH DESCRIPTION
is invoked with one argument: the URL of the content to retrieve. The program
should write the content to standard out, and should terminate with a 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 publicly-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 latter is interpreted relative to the user's
-nmh directory, if not rooted, e.g.,
-.PP
-.RS 5
-nmh-private-cache: .cache
-.RE
-.PP
-(which is the default value).
.SS "User Environment"
Because the environment in which
.B mhstore
^Current\-Folder:~^To find the default current folder
^nmh-access-ftp:~^Program to retrieve contents via FTP
^nmh-access-url:~^Program to retrieve contents via HTTP
-^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
.RB ` \-noauto '
.RB ` \-clobber\ always '
.RB ` \-nocheck '
-.RB ` \-rcache\ ask '
-.RB ` \-wcache\ ask '
.RB ` \-verbose '
.SH CONTEXT
If a folder is given, it will become the current folder. The last
list information about content of MIME messages
.TP
.IR mhn (1)
-display/list/store/cache MIME messages
+display/list/store MIME messages
.TP
.IR mhshow (1)
display MIME messages
#include "h/tws.h"
#include "h/mime.h"
#include "h/mhparse.h"
-#include "h/mhcachesbr.h"
#include "h/done.h"
#include "h/utils.h"
#include "sbr/m_maildir.h"
X("noverbose", 0, NVERBSW) \
X("disposition", 0, DISPOSW) \
X("nodisposition", 0, NDISPOSW) \
- X("rcache policy", 0, RCACHESW) \
- X("wcache policy", 0, WCACHESW) \
X("contentid", 0, CONTENTIDSW) \
X("nocontentid", 0, NCONTENTIDSW) \
X("headerencoding encoding-algorithm", 0, HEADERENCSW) \
bool verbosw = false;
bool dispo = false;
size_t maxunencoded = MAXTEXTPERLN;
- int *icachesw;
char *cp, buf[BUFSIZ];
char buffer[BUFSIZ], *compfile = NULL;
char **argp, **arguments;
directives = true;
continue;
- case RCACHESW:
- icachesw = &rcachesw;
- goto do_cache;
- case WCACHESW:
- icachesw = &wcachesw;
- do_cache: ;
- if (!(cp = *argp++) || *cp == '-')
- die("missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, cache_policy)) {
- case AMBIGSW:
- ambigsw (cp, cache_policy);
- done (1);
- case UNKWNSW:
- die("%s unknown", cp);
- default:
- break;
- }
- continue;
-
case CHECKSW:
case NCHECKSW:
/* Currently a NOP */
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 = mh_xstrdup(m_maildir(cache_private));
-
if (!context_find ("path"))
free (path ("./", TFOLDER));
#include "h/mhparse.h"
#include "h/done.h"
#include "h/utils.h"
-#include "h/mhcachesbr.h"
#include "mhmisc.h"
#include "sbr/m_mktemp.h"
#include "sbr/message_id.h"
+++ /dev/null
-/* 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 "sbr/m_gmprot.h"
-#include "sbr/m_getfld.h"
-#include "sbr/read_yes_or_no_if_tty.h"
-#include "sbr/trimcpy.h"
-#include "sbr/error.h"
-#include <fcntl.h>
-#include "h/mts.h"
-#include "h/tws.h"
-#include "h/mime.h"
-#include "h/mhparse.h"
-#include "h/mhcachesbr.h"
-#include "h/utils.h"
-#include "mhmisc.h"
-#include "sbr/lock_file.h"
-#include "sbr/m_mktemp.h"
-
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#endif
-#include <time.h>
-
-#define X(sw, minchars, id) { sw, minchars, id },
-DEFINE_SWITCH_ARRAY(CACHE, caches);
-#undef X
-struct swit *cache_policy = caches;
-
-extern int debugsw;
-
-/* 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;
-
-/*
- * 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) {
- inform("no %s: field in %s", ID_FIELD, ct->c_file);
- return;
- }
-
- if (!ce) {
- inform("unable to decode %s", ct->c_file);
- return;
- }
-
- if (find_cache (NULL, wcachesw != CACHE_NEVER ? wcachesw : CACHE_ASK,
- &cachetype, ct->c_id, cachefile, sizeof(cachefile))
- == NOTOK) {
- inform("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)
- if ((int) fwrite (buffer, sizeof(*buffer), cc, fp) < cc) {
- advise ("cache_content", "fwrite");
- }
- fflush (fp);
-
- if (ferror (gp)) {
- admonish (ce->ce_file, "error reading");
- (void) m_unlink (cachefile);
- } else {
- if (ferror (fp)) {
- admonish (cachefile, "error writing");
- (void) m_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 (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];
-
- /* Get buffer ready to go */
- bp = query;
- buflen = sizeof(query);
-
- /* Now, construct query */
- if (writing) {
- snprintf (bp, buflen, "Make cached, publicly-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 (!read_yes_or_no_if_tty (query))
- status = NOTOK;
- }
-
- if (status == OK && writing) {
- if (*writing && strchr(buffer, '/'))
- make_intermediates (buffer);
- (void) m_unlink (buffer);
- }
-
- free (id);
- return status;
-}
-
-
-static int
-find_cache_aux (int writing, char *directory, char *id,
- char *buffer, int buflen)
-{
- int mask;
- bool usemap;
- char mapfile[BUFSIZ], mapname[BUFSIZ];
- FILE *fp;
- int failed_to_lock = 0;
- static int partno, pid;
- static time_t clock = 0;
-
- usemap = true;
-
- 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 = lkfopendata (mapfile, "a", &failed_to_lock)) && errno == ENOENT) {
- int fd;
-
- if ((fd = creat (mapfile, 0666)) != NOTOK) {
- close (fd);
- fp = lkfopendata (mapfile, "a", &failed_to_lock);
- if (failed_to_lock) {
- adios (mapfile, "failed to lock");
- }
- }
- }
- umask (mask);
- if (!fp)
- return NOTOK;
- fprintf (fp, "%s: %s\n", mapname, id);
- lkfclosedata (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[NMH_BUFSIZ], name[NAMESZ];
- FILE *fp;
- m_getfld_state_t gstate;
- int failed_to_lock = 0;
-
- if (!(fp = lkfopendata (mapfile, "r", &failed_to_lock)))
- return NOTOK;
-
- gstate = m_getfld_state_init(fp);
- for (;;) {
- int result;
- char *cp, *dp;
- int bufsz = sizeof buf;
-
- switch (state = m_getfld2(&gstate, name, buf, &bufsz)) {
- case FLD:
- case FLDPLUS:
- strncpy (mapname, name, namelen);
- if (state != FLDPLUS)
- cp = buf;
- else {
- cp = mh_xstrdup(buf);
- while (state == FLDPLUS) {
- bufsz = sizeof buf;
- state = m_getfld2(&gstate, name, buf, &bufsz);
- 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) {
- lkfclosedata (fp, mapfile);
- return OK;
- }
- continue;
-
- case BODY:
- case FILEEOF:
- default:
- break;
- }
- break;
- }
- m_getfld_state_destroy (&gstate);
-
- lkfclosedata (fp, mapfile);
- return NOTOK;
-}
#include "h/tws.h"
#include "h/mime.h"
#include "h/mhparse.h"
-#include "h/mhcachesbr.h"
#include "h/done.h"
#include "h/utils.h"
#include "mhmisc.h"
X("type content", 0, TYPESW) \
X("prefer content", 0, PREFERSW) \
X("noprefer", 0, NPREFERSW) \
- X("rcache policy", 0, RCACHESW) \
- X("wcache policy", 0, WCACHESW) \
X("changecur", 0, CHGSW) \
X("nochangecur", 0, NCHGSW) \
X("version", 0, VERSIONSW) \
bool chgflag = true;
bool verbosw = false;
bool dispo = false;
- int msgnum, *icachesw;
+ int msgnum;
char *cp, *file = NULL, *folder = NULL;
char *maildir, buf[100], **argp;
char **arguments;
print_version(invo_name);
done (0);
- case RCACHESW:
- icachesw = &rcachesw;
- goto do_cache;
- case WCACHESW:
- icachesw = &wcachesw;
-do_cache:
- if (!(cp = *argp++) || *cp == '-')
- die("missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, cache_policy)) {
- case AMBIGSW:
- ambigsw (cp, cache_policy);
- done (1);
- case UNKWNSW:
- die("%s unknown", cp);
- default:
- break;
- }
- continue;
-
case CHECKSW:
case NCHECKSW:
/* Currently a NOP */
parts[npart] = NULL;
types[ntype] = NULL;
- /* 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 = mh_xstrdup(m_maildir(cache_private));
-
if (!context_find ("path"))
free (path ("./", TFOLDER));
-/* mhn.c -- display, list, cache, or store the contents of MIME messages
+/* mhn.c -- display, list, or store the contents of MIME messages
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
#include "h/fmt_scan.h"
#include "h/mime.h"
#include "h/mhparse.h"
-#include "h/mhcachesbr.h"
#include "h/done.h"
#include "h/utils.h"
#include "mhmisc.h"
#define MHN_SWITCHES \
X("auto", 0, AUTOSW) \
X("noauto", 0, NAUTOSW) \
- X("cache", 0, CACHESW) \
- X("nocache", 0, NCACHESW) \
X("check", -5, CHECKSW) \
X("nocheck", -7, NCHECKSW) \
X("headers", 0, HEADSW) \
X("form formfile", 0, FORMSW) \
X("part number", 0, PARTSW) \
X("type content", 0, TYPESW) \
- X("rcache policy", 0, RCACHESW) \
- X("wcache policy", 0, WCACHESW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
/* \
/*
* what action to take?
*/
-static bool cachesw;
static bool listsw;
static bool showsw;
static bool storesw;
bool sizesw = true;
bool headsw = true;
bool autosw = false;
- int msgnum, *icachesw;
+ int msgnum;
char *cp, *file = NULL, *folder = NULL;
char *maildir, buf[100], **argp;
char **arguments;
autosw = false;
continue;
- case CACHESW:
- cachesw = true;
- continue;
- case NCACHESW:
- cachesw = false;
- continue;
-
- case RCACHESW:
- icachesw = &rcachesw;
- goto do_cache;
- case WCACHESW:
- icachesw = &wcachesw;
-do_cache:
- if (!(cp = *argp++) || *cp == '-')
- die("missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, cache_policy)) {
- case AMBIGSW:
- ambigsw (cp, cache_policy);
- done (1);
- case UNKWNSW:
- die("%s unknown", cp);
- default:
- break;
- }
- continue;
-
case CHECKSW:
case NCHECKSW:
/* Currently a NOP */
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 = mh_xstrdup(m_maildir(cache_private));
-
/*
* Cache the current directory before we do any chdirs()'s.
*/
char *vec[MAXARGS];
int vecp;
- if (showsw || storesw || cachesw)
- die("cannot use -build with -show, -store, -cache");
+ if (showsw || storesw)
+ die("cannot use -build with -show, -store");
if (msgs.size < 1)
die("need to specify a %s composition file", invo_name);
if (msgs.size > 1)
/*
* Process a mhn composition file (old MH style)
*/
- if (msgs.size == 1 && !folder && !npart && !cachesw
+ if (msgs.size == 1 && !folder && !npart
&& !showsw && !storesw && !ntype && !file
&& (cp = getenv ("mhdraft"))
&& strcmp (cp, msgs.msgs[0]) == 0) {
* You can't give more than one of these flags
* at a time.
*/
- if (showsw + listsw + storesw + cachesw > 1)
- die("can only use one of -show, -list, -store, -cache at same time");
+ if (showsw + listsw + storesw > 1)
+ die("can only use one of -show, -list, -store at same time");
/* If no action is specified, assume -show */
- if (!listsw && !showsw && !storesw && !cachesw)
+ if (!listsw && !showsw && !storesw)
showsw = true;
userrs = true;
context_save (); /* save the context file */
}
- /*
- * Cache the message content
- */
- if (cachesw)
- cache_all_messages (cts);
-
/*
* Show the message content
*/
#include "h/mhparse.h"
#include "h/utils.h"
#include "mhmisc.h"
-#include "h/mhcachesbr.h"
#include "sbr/m_mktemp.h"
#include "mhfree.h"
#ifdef HAVE_ICONV
static int InitQuoted (CT);
static int openQuoted (CT, char **);
static int Init7Bit (CT);
-static int openExternal (CT, CT, CE, char **, int *);
+static int openExternal (CT, CE, char **, int *);
static int InitFile (CT);
static int openFile (CT, char **);
static int InitFTP (CT);
*/
static int
-openExternal (CT ct, CT cb, CE ce, char **file, int *fd)
+openExternal (CT ct, CE ce, char **file, int *fd)
{
- char cachefile[BUFSIZ];
-
if (ce->ce_fp) {
fseek (ce->ce_fp, 0L, SEEK_SET);
goto ready_already;
goto ready_already;
}
- if (find_cache(ct, rcachesw, NULL, cb->c_id,
- cachefile, sizeof(cachefile)) != NOTOK) {
- if ((ce->ce_fp = fopen (cachefile, "r"))) {
- ce->ce_file = mh_xstrdup(cachefile);
- ce->ce_unlink = 0;
- goto ready_already;
- }
- admonish (cachefile, "unable to fopen for reading");
- }
-
*fd = ce->ce_fp ? fileno (ce->ce_fp) : -1;
return OK;
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;
- switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
+ switch (openExternal (e->eb_parent, ce, file, &fd)) {
case NOTOK:
return NOTOK;
return NOTOK;
}
- if ((!e->eb_permission || 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)
- if ((int) fwrite (buffer, sizeof(*buffer), cc, fp) < cc) {
- advise ("openFile", "fwrite");
- }
- fflush (fp);
-
- if (ferror (gp)) {
- admonish (ce->ce_file, "error reading");
- (void) m_unlink (cachefile);
- } else if (ferror (fp)) {
- admonish (cachefile, "error writing");
- (void) m_unlink (cachefile);
- }
- fclose (fp);
- }
- umask (mask);
- }
-
fseek (ce->ce_fp, 0L, SEEK_SET);
*file = ce->ce_file;
return fileno (ce->ce_fp);
static int
openFTP (CT ct, char **file)
{
- int cachetype;
- bool caching;
int fd;
int len, buflen;
char *bp, *ftp, *user, *pass;
- char buffer[BUFSIZ], cachefile[BUFSIZ];
+ char buffer[BUFSIZ];
struct exbody *e;
CE ce = &ct->c_cefile;
static char *username = NULL;
if (!ftp)
return NOTOK;
- switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
+ switch (openExternal (e->eb_parent, ce, file, &fd)) {
case NOTOK:
return NOTOK;
}
ce->ce_unlink = (*file == NULL);
- caching = false;
- cachefile[0] = '\0';
- if ((!e->eb_permission || 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 = true;
- }
- }
if (*file)
ce->ce_file = mh_xstrdup(*file);
- else if (caching)
- ce->ce_file = mh_xstrdup(cachefile);
else {
char *tempfile;
if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
}
}
- 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)
- if ((int) fwrite (buffer, sizeof(*buffer), cc, fp) < cc) {
- advise ("openFTP", "fwrite");
- }
- fflush (fp);
-
- if (ferror (gp)) {
- admonish (ce->ce_file, "error reading");
- (void) m_unlink (cachefile);
- } else if (ferror (fp)) {
- admonish (cachefile, "error writing");
- (void) m_unlink (cachefile);
- }
- fclose (fp);
- }
- umask (mask);
- }
- }
-
fseek (ce->ce_fp, 0L, SEEK_SET);
*file = ce->ce_file;
return fileno (ce->ce_fp);
struct exbody *e = ct->c_ctexbody;
CE ce = &ct->c_cefile;
- switch (openExternal (e->eb_parent, e->eb_content, ce, file, &fd)) {
+ switch (openExternal (e->eb_parent, ce, file, &fd)) {
case NOTOK:
return NOTOK;
struct exbody *e = ct->c_ctexbody;
CE ce = &ct->c_cefile;
char *urlprog, *program;
- char buffer[BUFSIZ], cachefile[BUFSIZ];
int fd;
- bool caching;
- int cachetype;
struct msgs_array args = { 0, 0, NULL};
pid_t child_id;
return NOTOK;
}
- switch (openExternal(e->eb_parent, e->eb_content, ce, file, &fd)) {
+ switch (openExternal(e->eb_parent, ce, file, &fd)) {
case NOTOK:
return NOTOK;
}
ce->ce_unlink = (*file == NULL);
- caching = false;
- cachefile[0] = '\0';
-
- if (find_cache(NULL, wcachesw, &cachetype, e->eb_content->c_id,
- cachefile, sizeof(cachefile)) != NOTOK) {
- if (*file == NULL) {
- ce->ce_unlink = 0;
- caching = true;
- }
- }
if (*file)
ce->ce_file = mh_xstrdup(*file);
- else if (caching)
- ce->ce_file = mh_xstrdup(cachefile);
else {
char *tempfile;
if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
}
}
- 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;
-
- fseeko(gp, 0, SEEK_SET);
-
- while ((cc = fread(buffer, sizeof(*buffer),
- sizeof(buffer), gp)) > 0)
- if ((int) fwrite(buffer, sizeof(*buffer), cc, fp) < cc) {
- advise ("openURL", "fwrite");
- }
-
- fflush(fp);
-
- if (ferror(gp)) {
- admonish(ce->ce_file, "error reading");
- (void) m_unlink (cachefile);
- }
- }
- umask(mask);
- }
- }
-
fseeko(ce->ce_fp, 0, SEEK_SET);
*file = ce->ce_file;
return fileno(ce->ce_fp);
#include "h/fmt_scan.h"
#include "h/mime.h"
#include "h/mhparse.h"
-#include "h/mhcachesbr.h"
#include "h/done.h"
#include "h/utils.h"
#include "mhmisc.h"
X("type content", 0, TYPESW) \
X("prefer content", 0, PREFERSW) \
X("noprefer", 0, NPREFERSW) \
- X("rcache policy", 0, RCACHESW) \
- X("wcache policy", 0, WCACHESW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
/* \
int
main (int argc, char **argv)
{
- int msgnum, *icachesw, concatsw = -1, textonly = -1, inlineonly = -1;
+ int msgnum, concatsw = -1, textonly = -1, inlineonly = -1;
char *cp, *file = NULL;
char *maildir, buf[100], **argp;
char **arguments;
print_version(invo_name);
done (0);
- case RCACHESW:
- icachesw = &rcachesw;
- goto do_cache;
- case WCACHESW:
- icachesw = &wcachesw;
-do_cache:
- if (!(cp = *argp++) || *cp == '-')
- die("missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, cache_policy)) {
- case AMBIGSW:
- ambigsw (cp, cache_policy);
- done (1);
- case UNKWNSW:
- die("%s unknown", cp);
- default:
- break;
- }
- continue;
-
case CHECKSW:
case NCHECKSW:
/* Currently a NOP */
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 = mh_xstrdup(m_maildir(cache_private));
-
if (!context_find ("path"))
free (path ("./", TFOLDER));
#include "h/tws.h"
#include "h/mime.h"
#include "h/mhparse.h"
-#include "h/mhcachesbr.h"
#include "h/done.h"
#include "h/utils.h"
#include "mhmisc.h"
X("type content", 0, TYPESW) \
X("prefer content", 0, PREFERSW) \
X("noprefer", 0, NPREFERSW) \
- X("rcache policy", 0, RCACHESW) \
- X("wcache policy", 0, WCACHESW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
X("clobber always|auto|suffix|ask|never", 0, CLOBBERSW) \
int
main (int argc, char **argv)
{
- int msgnum, *icachesw;
+ int msgnum;
bool autosw = false;
/* verbosw defaults to 1 for backward compatibility. */
bool verbosw = true;
autosw = false;
continue;
- case RCACHESW:
- icachesw = &rcachesw;
- goto do_cache;
- case WCACHESW:
- icachesw = &wcachesw;
-do_cache:
- if (!(cp = *argp++) || *cp == '-')
- die("missing argument to %s", argp[-2]);
- switch (*icachesw = smatch (cp, cache_policy)) {
- case AMBIGSW:
- ambigsw (cp, cache_policy);
- done (1);
- case UNKWNSW:
- die("%s unknown", cp);
- default:
- break;
- }
- continue;
-
case CHECKSW:
case NCHECKSW:
/* Currently a NOP */
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 = mh_xstrdup(m_maildir(cache_private));
-
/*
* Cache the current directory before we do any chdirs()'s.
*/