[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev PATCH [dev21]: source caching, take 3
From: |
Scott Bigham |
Subject: |
lynx-dev PATCH [dev21]: source caching, take 3 |
Date: |
Mon, 12 Apr 1999 17:06:06 -0400 (EDT) |
Grmbl... with HTDisplayPartial() defined private in HTFormat.c, I had to
move a fair amount of code there from GridText.c; so I'm resubmitting
the patch as a replacement again. I've checked this one, and at least
on this end, patch -p0 had no problems.
This includes fixes for all the problems Leonid found, plus a fix to my
configure.in mods (BTW, what version of autoconf are you using, Tom?
I've got 2.12, and it choked on the [apparently no longer existent]
AC_DIVERT_HELP() macro). I looked over the users' guide, and I really
couldn't find any appropriate place to put a mention of this.
-sbigham
--- ./WWW/Library/Implementation/HTFormat.c.orig Tue Mar 30 12:10:37 1999
+++ ./WWW/Library/Implementation/HTFormat.c Mon Apr 12 11:49:00 1999
@@ -764,6 +764,50 @@
return rv;
}
+#ifdef SOURCE_CACHE
+/* Push data from an HTChunk down a stream
+** ---------------------------------------
+**
+** This routine is responsible for creating and PRESENTING any
+** graphic (or other) objects described by the file.
+**
+** State of memory and target stream on entry:
+** HTChunk* (chunk) and target (sink) assumed valid.
+**
+** Return values:
+** HT_LOADED All data sent.
+**
+** State of memory and target stream on return:
+** always chunk unchanged, target stream still valid.
+*/
+PUBLIC int HTMemCopy ARGS2(
+ HTChunk *, chunk,
+ HTStream *, sink)
+{
+ HTStreamClass targetClass = *(sink->isa);
+ int bytes = 0;
+ CONST char *data = chunk->data;
+
+ HTReadProgress(0, 0);
+ for (;;) {
+ /* Push the data down the stream a piece at a time, in case we're
+ ** running a large document on a slow machine.
+ */
+ int n = INPUT_BUFFER_SIZE;
+ if (n > chunk->size - bytes)
+ n = chunk->size - bytes;
+ if (n == 0)
+ break;
+ (*targetClass.put_block)(sink, data, n);
+ bytes += n;
+ data += n;
+ HTReadProgress(bytes, 0);
+ HTDisplayPartial();
+ }
+ return HT_LOADED;
+}
+#endif
+
#ifdef USE_ZLIB
/* Push data from a gzip file pointer down a stream
** -------------------------------------
@@ -1025,6 +1069,54 @@
else
return HT_LOADED;
}
+
+#ifdef SOURCE_CACHE
+/* Parse a document in memory given format and memory block pointer
+**
+** This routine is responsible for creating and PRESENTING any
+** graphic (or other) objects described by the file.
+**
+** State of memory and target stream on entry:
+** HTChunk* (chunk) assumed valid,
+** target (sink) usually NULL (will call stream stack).
+**
+** Return values:
+** -501 Stream stack failed (cannot present or convert).
+** HT_LOADED All data sent.
+**
+** Stat of memory and target stream on return:
+** always chunk unchanged; target freed, aborted, or NULL.
+*/
+PUBLIC int HTParseMem ARGS5(
+ HTFormat, rep_in,
+ HTFormat, format_out,
+ HTParentAnchor *, anchor,
+ HTChunk *, chunk,
+ HTStream *, sink)
+{
+ HTStream * stream;
+ HTStreamClass targetClass;
+ int rv;
+
+ stream = HTStreamStack(rep_in, format_out, sink, anchor);
+ if (!stream) {
+ char *buffer = 0;
+ HTSprintf0(&buffer, CANNOT_CONVERT_I_TO_O,
+ HTAtom_name(rep_in), HTAtom_name(format_out));
+ CTRACE(tfp, "HTFormat(in HTParseMem): %s\n", buffer);
+ rv = HTLoadError(sink, 501, buffer);
+ FREE(buffer);
+ return rv;
+ }
+
+ /* Push the data down the stream
+ */
+ targetClass = *(stream->isa);
+ rv = HTMemCopy(chunk, stream);
+ (*targetClass._free)(stream);
+ return HT_LOADED;
+}
+#endif
#ifdef USE_ZLIB
PRIVATE int HTCloseGzFile ARGS1(
--- ./WWW/Library/Implementation/HTFormat.h.orig Wed Mar 17 22:17:11 1999
+++ ./WWW/Library/Implementation/HTFormat.h Mon Apr 12 11:42:00 1999
@@ -312,6 +312,22 @@
HTStream* sink));
+#ifdef SOURCE_CACHE
+#include <HTChunk.h>
+/*
+
+HTFileCopy: Copy a file to a stream
+
+ This is used by the protocol engines to send data down a stream, typically
one which
+ has been generated by HTStreamStack. It is currently called by HTParseFile
+
+ */
+extern int HTMemCopy PARAMS((
+ HTChunk * chunk,
+ HTStream* sink));
+#endif
+
+
/*
HTCopyNoCR: Copy a socket to a stream, stripping CR characters.
@@ -376,6 +392,24 @@
HTParentAnchor *anchor,
FILE *fp,
HTStream* sink));
+
+#ifdef SOURCE_CACHE
+/*
+
+HTParseMem: Parse a document in memory
+
+ This routine is called by protocols modules to load an object. uses
+ HTStreamStack and HTMemCopy. Returns HT_LOADED if successful, can also
+ return <0 for failure.
+
+ */
+extern int HTParseMem PARAMS((
+ HTFormat format_in,
+ HTFormat format_out,
+ HTParentAnchor *anchor,
+ HTChunk* chunk,
+ HTStream* sink));
+#endif
#ifdef USE_ZLIB
--- ./src/GridText.c.orig Tue Mar 30 12:10:37 1999
+++ ./src/GridText.c Mon Apr 12 12:26:41 1999
@@ -46,6 +46,10 @@
#undef DEBUG_APPCH
+#ifdef SOURCE_CACHE
+#include <HTFile.h>
+#endif
+
#ifdef USE_COLOR_STYLE
#include <AttrList.h>
#include <LYHash.h>
@@ -114,6 +118,12 @@
PUBLIC BOOLEAN underline_on = OFF;
PUBLIC BOOLEAN bold_on = OFF;
+#ifdef SOURCE_CACHE
+PUBLIC char * source_cache_filename = NULL;
+PUBLIC HTChunk * source_cache_chunk = NULL;
+PUBLIC int LYCacheSource = SOURCE_CACHE_NONE;
+#endif
+
#if defined(USE_COLOR_STYLE)
#define MAX_STYLES_ON_LINE 64
@@ -173,6 +183,22 @@
*/
struct _HText {
HTParentAnchor * node_anchor;
+#ifdef SOURCE_CACHE
+ char * source_cache_file;
+ HTChunk * source_cache_chunk;
+ /*
+ * Parse settings when this HText was generated.
+ */
+ BOOLEAN clickable_images;
+ BOOLEAN pseudo_inline_alts;
+ BOOLEAN raw_mode;
+ BOOLEAN historical_comments;
+ BOOLEAN minimal_comments;
+ BOOLEAN soft_dquotes;
+ BOOLEAN old_dtd;
+ int lines; /* Screen size */
+ int cols;
+#endif
HTLine * last_line;
int Lines; /* Number of them */
int chars; /* Number of them */
@@ -483,6 +509,34 @@
self->stale = YES;
self->toolbar = NO;
self->tabs = NULL;
+#ifdef SOURCE_CACHE
+ /*
+ * Yes, this is a Gross And Disgusting Hack(TM), I know...
+ */
+ self->source_cache_file = NULL;
+ if (LYCacheSource == SOURCE_CACHE_FILE && source_cache_filename) {
+ StrAllocCopy(self->source_cache_file, source_cache_filename);
+ FREE(source_cache_filename);
+ }
+ self->source_cache_chunk = NULL;
+ if (LYCacheSource == SOURCE_CACHE_MEMORY && source_cache_chunk) {
+ self->source_cache_chunk = source_cache_chunk;
+ source_cache_chunk = NULL;
+ }
+
+ /*
+ * Remember the parse settings.
+ */
+ self->clickable_images = clickable_images;
+ self->pseudo_inline_alts = pseudo_inline_alts;
+ self->raw_mode = LYUseDefaultRawMode;
+ self->historical_comments = historical_comments;
+ self->minimal_comments = minimal_comments;
+ self->soft_dquotes = soft_dquotes;
+ self->old_dtd = Old_DTD;
+ self->lines = LYlines;
+ self->cols = LYcols;
+#endif
/*
* If we are going to render the List Page, always merge in hidden
* links to get the numbering consistent if form fields are numbered
@@ -729,6 +783,23 @@
HTMainAnchor = NULL;
}
+#ifdef SOURCE_CACHE
+ /*
+ * Clean up the source cache, if any.
+ */
+ if (self->source_cache_file) {
+ CTRACE(tfp, "Removing source cache file %s\n",
+ self->source_cache_file);
+ LYRemoveTemp(self->source_cache_file);
+ FREE(self->source_cache_file);
+ }
+ if (self->source_cache_chunk) {
+ CTRACE(tfp, "Removing memory source cache %p\n",
+ (void *)self->source_cache_chunk);
+ HTChunkFree(self->source_cache_chunk);
+ }
+#endif
+
FREE(self);
}
@@ -6189,6 +6260,148 @@
CTRACE(tfp, "HTuncache.. HTMainText already is NULL!\n");
}
}
+
+#ifdef SOURCE_CACHE
+PUBLIC BOOLEAN HTreparse_document NOARGS
+{
+ BOOLEAN ok = FALSE;
+
+ if (!HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
+ (LYCacheSource == SOURCE_CACHE_FILE &&
+ !HTMainText->source_cache_file) ||
+ (LYCacheSource == SOURCE_CACHE_MEMORY &&
+ !HTMainText->source_cache_chunk))
+ return FALSE;
+
+ if (LYCacheSource == SOURCE_CACHE_FILE && HTMainText->source_cache_file) {
+ FILE * fp;
+ HTFormat format;
+ int ret;
+
+ CTRACE(tfp, "Reparsing source cache file %s\n",
+ HTMainText->source_cache_file);
+
+ /*
+ * This is more or less copied out of HTLoadFile(), except we don't
+ * get a content encoding. This may be overkill...
+ */
+ if (HTMainText->node_anchor->content_type) {
+ format = HTAtom_for(HTMainText->node_anchor->content_type);
+ } else {
+ format = HTFileFormat(HTMainText->source_cache_file, NULL, NULL);
+ format = HTCharsetFormat(format, HTMainText->node_anchor,
+ UCLYhndl_HTFile_for_unspec);
+ }
+ CTRACE(tfp, " Content type is \"%s\"\n", format->name);
+
+ /*
+ * Pass the source cache filename on to the next HText. Mark it
+ * NULL here so that it won't get deleted by HText_free().
+ */
+ source_cache_filename = HTMainText->source_cache_file;
+ HTMainText->source_cache_file = NULL;
+
+ fp = fopen(source_cache_filename, "r");
+ if (!fp) {
+ CTRACE(tfp, " Cannot read file %s\n", source_cache_filename);
+ FREE(source_cache_filename);
+ return FALSE;
+ }
+ ret = HTParseFile(format, HTOutputFormat, HTMainText->node_anchor,
+ fp, NULL);
+ fclose(fp);
+ ok = (ret == HT_LOADED);
+ if (!ok)
+ FREE(source_cache_filename);
+ }
+
+ if (LYCacheSource == SOURCE_CACHE_MEMORY &&
+ HTMainText->source_cache_chunk) {
+ HTFormat format = WWW_HTML;
+ int ret;
+
+ CTRACE(tfp, "Reparsing from source memory cache %p\n",
+ (void *)HTMainText->source_cache_chunk);
+
+ /*
+ * Pass the source cache HTChunk on to the next HText. Clear it
+ * here so that it won't get deleted by HText_free().
+ */
+ source_cache_chunk = HTMainText->source_cache_chunk;
+ HTMainText->source_cache_chunk = NULL;
+
+ ret = HTParseMem(format, HTOutputFormat, HTMainText->node_anchor,
+ source_cache_chunk, NULL);
+ ok = (ret == HT_LOADED);
+ if (!ok) {
+ HTChunkFree(source_cache_chunk);
+ source_cache_chunk = NULL;
+ }
+ }
+
+ CTRACE(tfp, "Reparse %s\n", (ok ? "succeeded" : "failed"));
+ return ok;
+}
+
+PRIVATE void trace_setting_change ARGS3(
+ CONST char *, name,
+ BOOLEAN, prev_setting,
+ BOOLEAN, new_setting)
+{
+ if (prev_setting != new_setting)
+ CTRACE(tfp, "HTdocument_settings_changed: %s setting has changed (was
%s, now %s)\n",
+ name, prev_setting ? "ON" : "OFF", new_setting ? "ON" : "OFF");
+}
+
+PUBLIC BOOLEAN HTdocument_settings_changed NOARGS
+{
+ /*
+ * Annoying Hack(TM): If we don't have a source cache, we can't
+ * reparse anyway, so pretend the settings haven't changed.
+ */
+ if (!HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
+ (LYCacheSource == SOURCE_CACHE_FILE &&
+ !HTMainText->source_cache_file) ||
+ (LYCacheSource == SOURCE_CACHE_MEMORY &&
+ !HTMainText->source_cache_chunk))
+ return FALSE;
+
+ if (TRACE) {
+ /*
+ * If we're tracing, note everying that has changed.
+ */
+ trace_setting_change("CLICKABLE_IMAGES",
+ HTMainText->clickable_images, clickable_images);
+ trace_setting_change("PSEUDO_INLINE_ALTS",
+ HTMainText->pseudo_inline_alts,
+ pseudo_inline_alts);
+ trace_setting_change("RAW_MODE", HTMainText->raw_mode,
+ LYUseDefaultRawMode);
+ trace_setting_change("HISTORICAL_COMMENTS",
+ HTMainText->historical_comments,
+ historical_comments);
+ trace_setting_change("MINIMAL_COMMENTS",
+ HTMainText->minimal_comments, minimal_comments);
+ trace_setting_change("SOFT_DQUOTES",
+ HTMainText->soft_dquotes, soft_dquotes);
+ trace_setting_change("OLD_DTD", HTMainText->old_dtd, Old_DTD);
+ if (HTMainText->lines != LYlines || HTMainText->cols != LYcols)
+ CTRACE(tfp,
+ "HTdocument_settings_changed: Screen size has changed (was
%dx%d, now %dx%d)\n",
+ HTMainText->cols, HTMainText->lines, LYcols, LYlines);
+ }
+
+ return (HTMainText->clickable_images != clickable_images ||
+ HTMainText->pseudo_inline_alts != pseudo_inline_alts ||
+ HTMainText->raw_mode != LYUseDefaultRawMode ||
+ HTMainText->historical_comments != historical_comments ||
+ HTMainText->minimal_comments != minimal_comments ||
+ HTMainText->soft_dquotes != soft_dquotes ||
+ HTMainText->old_dtd != Old_DTD ||
+ HTMainText->lines != LYlines ||
+ HTMainText->cols != LYcols);
+}
+#endif
PUBLIC int HTisDocumentSource NOARGS
{
--- ./src/HTML.c.orig Wed Mar 17 22:17:11 1999
+++ ./src/HTML.c Mon Apr 12 13:03:29 1999
@@ -58,6 +58,10 @@
#define pHText_changeStyle(X,Y,Z) {}
#endif
+#ifdef SOURCE_CACHE
+#include <HTAccess.h>
+#endif
+
#include <LYexit.h>
#include <LYLeaks.h>
@@ -73,7 +77,14 @@
struct _HTStream {
CONST HTStreamClass * isa;
+#ifdef SOURCE_CACHE
+ FILE * fp;
+ HTChunk * chunk;
+ CONST HTStreamClass * actions;
+ HTStream * target;
+#else
/* .... */
+#endif
};
PRIVATE HTStyleSheet * styleSheet = NULL; /* Application-wide */
@@ -7300,6 +7311,152 @@
return (HTStructured*) me;
}
+#ifdef SOURCE_CACHE
+/*
+ * Pass-thru cache HTStream
+ */
+
+PRIVATE void CacheThru_free ARGS1(
+ HTStream *, me)
+{
+ if (me->fp)
+ LYCloseTempFP(me->fp);
+ (*me->actions->_free)(me->target);
+ FREE(me);
+}
+
+PRIVATE void CacheThru_abort ARGS2(
+ HTStream *, me,
+ HTError, e)
+{
+ if (me->fp)
+ LYCloseTempFP(me->fp);
+ (*me->actions->_abort)(me->target, e);
+ FREE(me);
+}
+
+PRIVATE void CacheThru_put_character ARGS2(
+ HTStream *, me,
+ char, c_in)
+{
+ if (me->fp)
+ fputc(c_in, me->fp);
+ else
+ HTChunkPutc(me->chunk, c_in);
+ (*me->actions->put_character)(me->target, c_in);
+}
+
+PRIVATE void CacheThru_put_string ARGS2(
+ HTStream *, me,
+ CONST char *, str)
+{
+ if (me->fp)
+ fputs(str, me->fp);
+ else
+ HTChunkPuts(me->chunk, str);
+ (*me->actions->put_string)(me->target, str);
+}
+
+PRIVATE void CacheThru_write ARGS3(
+ HTStream *, me,
+ CONST char *, str,
+ int, l)
+{
+ if (me->fp)
+ fwrite(str, 1, l, me->fp);
+ else
+ HTChunkPutb(me->chunk, str, l);
+ (*me->actions->put_block)(me->target, str, l);
+}
+
+PRIVATE CONST HTStreamClass PassThruCache =
+{
+ "PassThruCache",
+ CacheThru_free,
+ CacheThru_abort,
+ CacheThru_put_character,
+ CacheThru_put_string,
+ CacheThru_write
+};
+
+PRIVATE HTStream* CacheThru_new ARGS2(
+ HTParentAnchor *, anchor,
+ HTStream *, target)
+{
+ char filename[LY_MAXPATH];
+ HTStream *stream = NULL;
+ HTProtocol *p = (HTProtocol *)anchor->protocol;
+
+ /*
+ * Neatly and transparently vanish if source caching is disabled.
+ */
+ if (LYCacheSource == SOURCE_CACHE_NONE)
+ return target;
+
+ if (strcmp(p->name, "http") != 0) {
+ CTRACE(tfp, "Protocol is \"%s\"; not caching\n", p->name);
+ return target;
+ }
+
+ stream = (HTStream *) malloc(sizeof(*stream));
+ if (!stream)
+ outofmem(__FILE__, "CacheThru_new");
+
+ stream->isa = &PassThruCache;
+ stream->fp = NULL;
+ stream->chunk = NULL;
+ stream->target = target;
+ stream->actions = target->isa;
+
+ if (LYCacheSource == SOURCE_CACHE_FILE) {
+ if (source_cache_filename) {
+ CTRACE(tfp, "Reusing source cache file %s\n",
+ source_cache_filename);
+ FREE(stream);
+ return target;
+ }
+
+ /*
+ * We open the temp file in binary mode to make sure that
+ * end-of-line stuff and high-bit Latin-1 (or other) characters
+ * don't get munged; this way, the file should (knock on wood)
+ * contain exactly what came in from the network.
+ */
+ if (!(stream->fp = LYOpenTemp(filename, HTML_SUFFIX, "wb"))) {
+ CTRACE(tfp, "Cannot get source cache file for URL %s\n",
+ HTAnchor_address((HTAnchor *)anchor));
+ FREE(stream);
+ return target;
+ }
+
+ /*
+ * Yes, this is a Gross And Disgusting Hack(TM), I know...
+ */
+ StrAllocCopy(source_cache_filename, filename);
+
+ CTRACE(tfp, "Caching source for URL %s in file %s\n",
+ HTAnchor_address((HTAnchor *)anchor), filename);
+ }
+
+ if (LYCacheSource == SOURCE_CACHE_MEMORY) {
+ if (source_cache_chunk) {
+ CTRACE(tfp, "Reusing source memory cache %p\n",
+ (void *)source_cache_chunk);
+ FREE(stream);
+ return target;
+ }
+
+ /* I think this is right... */
+ source_cache_chunk = stream->chunk = HTChunkCreate(128);
+ CTRACE(tfp, "Caching source for URL %s in memory cache %p\n",
+ HTAnchor_address((HTAnchor *)anchor), (void *)stream->chunk);
+
+ }
+
+ return stream;
+}
+#endif
+
/* HTConverter for HTML to plain text
** ----------------------------------
**
@@ -7313,7 +7470,13 @@
HTParentAnchor *, anchor,
HTStream *, sink)
{
+#ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor,
+ HTML_new(anchor, pres->rep_out, sink)));
+#else
return SGML_new(&HTML_dtd, anchor, HTML_new(anchor, pres->rep_out, sink));
+#endif
}
/* HTConverter for HTML source to plain text
@@ -7372,7 +7535,13 @@
}
if (!intermediate)
return NULL;
+#ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor,
+ HTMLGenerator(intermediate)));
+#else
return SGML_new(&HTML_dtd, anchor, HTMLGenerator(intermediate));
+#endif
}
/* HTConverter for HTML to C code
@@ -7397,7 +7566,12 @@
html->comment_start = "/* ";
html->comment_end = " */\n"; /* Must start in col 1 for cpp */
/* HTML_put_string(html,html->comment_start); */
+#ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor, html));
+#else
return SGML_new(&HTML_dtd, anchor, html);
+#endif
}
/* Presenter for HTML
@@ -7414,7 +7588,13 @@
HTParentAnchor *, anchor,
HTStream *, sink GCC_UNUSED)
{
+#ifdef SOURCE_CACHE
+ return CacheThru_new(anchor,
+ SGML_new(&HTML_dtd, anchor,
+ HTML_new(anchor, WWW_PRESENT, NULL)));
+#else
return SGML_new(&HTML_dtd, anchor, HTML_new(anchor, WWW_PRESENT, NULL));
+#endif
}
#endif /* !GUI */
--- ./src/GridText.h.orig Tue Mar 30 12:10:37 1999
+++ ./src/GridText.h Sat Apr 10 19:24:50 1999
@@ -166,6 +166,10 @@
char * target));
extern int HTisDocumentSource NOPARAMS;
extern void HTuncache_current_document NOPARAMS;
+#ifdef SOURCE_CACHE
+extern BOOLEAN HTreparse_document NOPARAMS;
+extern BOOLEAN HTdocument_settings_changed NOPARAMS;
+#endif
extern int HText_getTopOfScreen NOPARAMS;
extern int HText_getLines PARAMS((HText * text));
extern int HText_getNumOfLines NOPARAMS;
--- ./src/LYMainLoop.c.orig Tue Mar 30 12:10:37 1999
+++ ./src/LYMainLoop.c Sun Apr 11 20:58:43 1999
@@ -1237,6 +1237,26 @@
}
}
+#ifdef SOURCE_CACHE
+ /*
+ * If the parse settings have changed since this HText was
+ * generated, we need to reparse and redraw it.
+ */
+ if (HTdocument_settings_changed()) {
+ HTUserMsg(gettext("Reparsing document under current settings..."));
+ if (HTreparse_document())
+ refresh_screen = TRUE;
+ else {
+ /*
+ * Urk. I have no idea how to recover from a failure here.
+ * At a guess, I'll try reloading.
+ */
+ cmd = LYK_RELOAD;
+ goto new_cmd;
+ }
+ }
+#endif
+
/*
* If the curdoc.line is different than Newline then there must
* have been a change since last update. Run HText_pageDisplay()
@@ -2049,6 +2069,12 @@
LYUCPushAssumed(HTMainAnchor);
HTOutputFormat = WWW_SOURCE;
}
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+#endif
LYforce_no_cache = TRUE;
FREE(curdoc.address); /* so it doesn't get pushed */
break;
@@ -2125,11 +2151,13 @@
0, 0) == FALSE) {
HTInfoMsg(WILL_NOT_RELOAD_DOC);
} else {
+#ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
newdoc.line = curdoc.line;
newdoc.link = curdoc.link;
+#endif
}
if (historical_comments)
historical_comments = FALSE;
@@ -2142,6 +2170,17 @@
HTAlert(historical_comments ?
HISTORICAL_ON_VALID_OFF : HISTORICAL_OFF_VALID_ON);
}
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+ newdoc.line = curdoc.line;
+ newdoc.link = curdoc.link;
+#endif
break;
case LYK_MINIMAL: /* toggle 'minimal' comments parsing */
@@ -2157,11 +2196,13 @@
0, 0) == FALSE) {
HTInfoMsg(WILL_NOT_RELOAD_DOC);
} else {
+#ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
newdoc.line = curdoc.line;
newdoc.link = curdoc.link;
+#endif
}
}
if (minimal_comments)
@@ -2175,6 +2216,17 @@
HTAlert(minimal_comments ?
MINIMAL_ON_BUT_HISTORICAL : MINIMAL_OFF_HISTORICAL_ON);
}
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+ newdoc.line = curdoc.line;
+ newdoc.link = curdoc.link;
+#endif
break;
case LYK_SOFT_DQUOTES:
@@ -2189,11 +2241,13 @@
1, 1) == FALSE) {
HTInfoMsg(WILL_NOT_RELOAD_DOC);
} else {
+#ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
newdoc.line = curdoc.line;
newdoc.link = curdoc.link;
+#endif
}
if (soft_dquotes)
soft_dquotes = FALSE;
@@ -2201,6 +2255,17 @@
soft_dquotes = TRUE;
HTUserMsg(soft_dquotes ?
SOFT_DOUBLE_QUOTE_ON : SOFT_DOUBLE_QUOTE_OFF);
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+ newdoc.line = curdoc.line;
+ newdoc.link = curdoc.link;
+#endif
break;
case LYK_SWITCH_DTD:
@@ -2223,9 +2288,11 @@
if (HTisDocumentSource() && LYPreparsedSource) {
HTOutputFormat = WWW_SOURCE;
}
+#ifndef SOURCE_CACHE
HTuncache_current_document();
StrAllocCopy(newdoc.address, curdoc.address);
FREE(curdoc.address);
+#endif
}
#ifdef NO_ASSUME_SAME_DOC
newdoc.line = 1;
@@ -2237,6 +2304,15 @@
Old_DTD = !Old_DTD;
HTSwitchDTD(!Old_DTD);
HTUserMsg(Old_DTD ? USING_DTD_0 : USING_DTD_1);
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+ HTuncache_current_document();
+ StrAllocCopy(newdoc.address, curdoc.address);
+ FREE(curdoc.address);
+#endif
break;
#ifdef NOT_DONE_YET
@@ -5447,6 +5523,12 @@
HTUserMsg(clickable_images ?
CLICKABLE_IMAGES_ON : CLICKABLE_IMAGES_OFF);
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+#endif
cmd = LYK_RELOAD;
goto new_cmd;
@@ -5458,6 +5540,12 @@
HTUserMsg(pseudo_inline_alts ?
PSEUDO_INLINE_ALTS_ON : PSEUDO_INLINE_ALTS_OFF);
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+#endif
cmd = LYK_RELOAD;
goto new_cmd;
@@ -5470,6 +5558,12 @@
HTUserMsg(LYRawMode ? RAWMODE_OFF : RAWMODE_ON);
HTMLSetCharacterHandling(current_char_set);
LYRawMode_flag = LYRawMode;
+#ifdef SOURCE_CACHE
+ if (HTreparse_document()) {
+ refresh_screen = TRUE;
+ break;
+ }
+#endif
cmd = LYK_RELOAD;
goto new_cmd;
}
--- ./src/LYReadCFG.c.orig Tue Mar 30 12:10:37 1999
+++ ./src/LYReadCFG.c Sun Apr 11 19:44:41 1999
@@ -763,6 +763,21 @@
return 0;
}
+#ifdef SOURCE_CACHE
+static int source_cache_fun ARGS1(
+ char *, value)
+{
+ if (!strncasecomp(value, "FILE", 4))
+ LYCacheSource = SOURCE_CACHE_FILE;
+ else if (!strncasecomp(value, "MEM", 3))
+ LYCacheSource = SOURCE_CACHE_MEMORY;
+ else if (!strncasecomp(value, "NONE", 4))
+ LYCacheSource = SOURCE_CACHE_NONE;
+
+ return 0;
+}
+#endif
+
static int suffix_fun ARGS1(
char *, value)
{
@@ -999,6 +1014,9 @@
PARSE_ENV("snewspost_proxy", CONF_ENV, 0 ),
PARSE_ENV("snewsreply_proxy", CONF_ENV, 0 ),
PARSE_SET("soft_dquotes", CONF_BOOL, soft_dquotes),
+#ifdef SOURCE_CACHE
+ PARSE_SET("source_cache", CONF_FUN, source_cache_fun),
+#endif
PARSE_STR("startfile", CONF_STR, startfile),
PARSE_SET("strip_dotdot_urls", CONF_BOOL, LYStripDotDotURLs),
PARSE_SET("substitute_underscores", CONF_BOOL, use_underscore),
--- ./src/LYMain.c.orig Tue Mar 30 12:10:37 1999
+++ ./src/LYMain.c Sun Apr 11 20:54:19 1999
@@ -1556,6 +1556,14 @@
no_multibook = TRUE;
}
+#ifdef SOURCE_CACHE
+ /*
+ * Disable source caching if not interactive.
+ */
+ if (dump_output_immediately)
+ LYCacheSource = SOURCE_CACHE_NONE;
+#endif
+
#ifdef VMS
set_vms_keys();
#endif /* VMS */
--- ./src/LYGlobalDefs.h.orig Thu Mar 4 05:39:45 1999
+++ ./src/LYGlobalDefs.h Sun Apr 11 22:24:41 1999
@@ -27,6 +27,10 @@
#define VISITED_LINKS_HELP "keystrokes/visited_help.html"
#endif /* LYHELP_H */
+#ifdef SOURCE_CACHE
+#include <HTChunk.h>
+#endif
+
#ifdef SOCKS
extern BOOLEAN socks_flag;
#endif /* SOCKS */
@@ -245,6 +249,14 @@
extern BOOLEAN historical_comments;
extern BOOLEAN minimal_comments;
extern BOOLEAN soft_dquotes;
+#ifdef SOURCE_CACHE
+extern char * source_cache_filename;
+extern HTChunk * source_cache_chunk;
+extern int LYCacheSource;
+#define SOURCE_CACHE_NONE 0
+#define SOURCE_CACHE_FILE 1
+#define SOURCE_CACHE_MEMORY 2
+#endif
extern BOOLEAN LYCancelDownload;
extern BOOLEAN LYRestricted;
extern BOOLEAN LYValidate;
--- ./configure.in.orig Tue Mar 30 12:10:37 1999
+++ ./configure.in Mon Apr 12 15:13:20 1999
@@ -567,6 +567,14 @@
AC_MSG_RESULT($use_alt_bindings)
test $use_alt_bindings != no && AC_DEFINE(EXP_ALT_BINDINGS)
+AC_MSG_CHECKING(if source caching should be used)
+CF_ARG_ENABLE(source-cache,
+[ --enable-source-cache cache HTML source for parse mode changes],
+ [use_source_cache=$enableval],
+ [use_source_cache=no])
+AC_MSG_RESULT($use_source_cache)
+test $use_source_cache != no && AC_DEFINE(SOURCE_CACHE)
+
AC_MSG_CHECKING(if color-style code should be used)
CF_ARG_ENABLE(color-style,
[ --enable-color-style use optional/experimental color style],
--- ./config.hin.orig Tue Mar 30 12:10:37 1999
+++ ./config.hin Sat Apr 10 00:27:33 1999
@@ -28,6 +28,7 @@
#undef EXEC_SCRIPTS /* CF_ARG_ENABLE(exec-scripts) */
#undef EXP_ADDRLIST_PAGE /* CF_ARG_ENABLE(addrlist-page) */
#undef EXP_ALT_BINDINGS /* CF_ARG_ENABLE(alt-bindings) */
+#undef SOURCE_CACHE /* CF_ARG_ENABLE(source-cache) */
#undef EXP_CHARTRANS_AUTOSWITCH /* CF_ARG_ENABLE(font-switch) */
#undef EXP_KEYBOARD_LAYOUT /* CF_ARG_ENABLE(kbd-layout) */
#undef EXP_LIBJS /* CF_ARG_ENABLE(libjs) */
--- ./lynx.cfg.orig Wed Mar 17 22:17:11 1999
+++ ./lynx.cfg Sun Apr 11 23:07:34 1999
@@ -513,6 +513,20 @@
#DEFAULT_CACHE_SIZE:10
#DEFAULT_VIRTUAL_MEMORY_SIZE:512000
+# SOURCE_CACHE sets the source caching behavior for Lynx:
+# FILE causes Lynx to keep a temporary file for each cached document
+# containing the HTML source of the document, which it uses to regenerate
+# the document when certain settings are changed (for instance,
+# historical vs. minimal vs. valid comment parsing) instead of reloading
+# the source from the network.
+# MEMORY is like FILE, except the document source is kept in memory. You
+# may wish to adjust DEFAULT_CACHE_SIZE and DEFAULT_VIRTUAL_MEMORY_SIZE
+# accordingly.
+# NONE is the default; the document source is not cached, and is reloaded
+# from the network when needed.
+#
+#SOURCE_CACHE:NONE
+
# If ALWAYS_RESUBMIT_POSTS is set TRUE, Lynx always will resubmit forms
# with method POST, dumping any cache from a previous submission of the
# form, including when the document returned by that form is sought with
- lynx-dev PATCH [dev21]: source caching, take 3,
Scott Bigham <=