diff options
Diffstat (limited to 'WWW')
-rw-r--r-- | WWW/Library/Implementation/HTAccess.c | 8 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFile.c | 10 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFormat.c | 62 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFormat.h | 2 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTUtils.h | 1 |
5 files changed, 71 insertions, 12 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 0c85ae52..0ebb2c17 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -831,6 +831,14 @@ PRIVATE BOOL HTLoadDocument ARGS4( } return YES; } + if (status == HT_PARTIAL_CONTENT) { + HTAlert("Loading incomplete."); + if (TRACE) { + fprintf(stderr, "HTAccess: `%s' has been accessed, partial content.\n", + full_address); + } + return YES; + } if (status == HT_NO_DATA) { if (TRACE) { diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index a09d169d..60c71e9a 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -1535,6 +1535,7 @@ PUBLIC int HTLoadFile ARGS4( int len; char *cp = NULL; char *semicolon = NULL; + int status; if (HTEditable(vmsname)) { HTAtom * put = HTAtom_for("PUT"); @@ -1590,9 +1591,9 @@ PUBLIC int HTLoadFile ARGS4( *semicolon = ';'; FREE(filename); FREE(nodename); - HTParseFile(format, format_out, anchor, fp, sink); + status = HTParseFile(format, format_out, anchor, fp, sink); fclose(fp); - return HT_LOADED; + return status; } /* If successfull open */ FREE(filename); } @@ -2045,6 +2046,7 @@ open_file: if (fp) { /* Good! */ int len; char *cp = NULL; + int status; if (HTEditable(localname)) { HTAtom * put = HTAtom_for("PUT"); @@ -2085,9 +2087,9 @@ open_file: } FREE(localname); FREE(nodename); - HTParseFile(format, format_out, anchor, fp, sink); + status = HTParseFile(format, format_out, anchor, fp, sink); fclose(fp); - return HT_LOADED; + return status; } /* If succesfull open */ } /* scope of fp */ } /* local unix file system */ diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c index 8fb47e10..527ae13c 100644 --- a/WWW/Library/Implementation/HTFormat.c +++ b/WWW/Library/Implementation/HTFormat.c @@ -585,11 +585,14 @@ finished: ** ** */ -PUBLIC void HTFileCopy ARGS2( +PUBLIC int HTFileCopy ARGS2( FILE *, fp, HTStream*, sink) { - HTStreamClass targetClass; + HTStreamClass targetClass; + char line[256]; + int bytes = 0, nreads = 0, nprogr = 0; + int rv = HT_OK; /* Push the data down the stream */ @@ -599,19 +602,58 @@ PUBLIC void HTFileCopy ARGS2( */ for (;;) { int status = fread(input_buffer, 1, INPUT_BUFFER_SIZE, fp); + nreads ++; if (status == 0) { /* EOF or error */ - if (ferror(fp) == 0) + if (ferror(fp) == 0) { + rv = HT_LOADED; break; + } if (TRACE) fprintf(stderr, "HTFormat: Read error, read returns %d\n", ferror(fp)); + rv = HT_PARTIAL_CONTENT; break; } (*targetClass.put_block)(sink, input_buffer, status); + + bytes += status; + if (nreads >= 100) { + /* + * Show progres messages for local files, and check for + * user interruption. + * Start doing so only after a certain number of reads + * have been done, and don't update it on every read - + * normally reading in a local file should be speedy. + */ + if (nprogr == 0) { + if (bytes < 1024000) { + sprintf(line, "Read %d bytes of data.", bytes); + } else { + sprintf(line, "Read %d KB of data. %s", + bytes/1024, + "(Press 'z' if you want to abort loading.)"); + } + HTProgress(line); + if (HTCheckForInterrupt()) { + _HTProgress ("Data transfer interrupted."); + if (bytes) + rv = HT_INTERRUPTED; + else + rv = HT_PARTIAL_CONTENT; + break; + } + nprogr++; + } else if (nprogr == 25) { + nprogr = 0; + } else { + nprogr++; + } + } } /* next bufferload */ - + + return rv; } /* Push data from a socket down a stream STRIPPING CR @@ -718,6 +760,7 @@ PUBLIC int HTParseFile ARGS5( { HTStream * stream; HTStreamClass targetClass; + int rv; stream = HTStreamStack(rep_in, format_out, @@ -744,9 +787,14 @@ PUBLIC int HTParseFile ARGS5( ** The current method smells anyway. */ targetClass = *(stream->isa); /* Copy pointers to procedures */ - HTFileCopy(fp, stream); - (*targetClass._free)(stream); - + rv = HTFileCopy(fp, stream); + if (rv == -1 || rv == HT_INTERRUPTED) + (*targetClass._abort)(stream, NULL); + else + (*targetClass._free)(stream); + + if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED)) + return HT_PARTIAL_CONTENT; return HT_LOADED; } diff --git a/WWW/Library/Implementation/HTFormat.h b/WWW/Library/Implementation/HTFormat.h index 2a9f11ab..24972f06 100644 --- a/WWW/Library/Implementation/HTFormat.h +++ b/WWW/Library/Implementation/HTFormat.h @@ -291,7 +291,7 @@ HTFileCopy: Copy a file to a stream has been generated by HTStreamStack. It is currently called by HTParseFile */ -extern void HTFileCopy PARAMS(( +extern int HTFileCopy PARAMS(( FILE* fp, HTStream* sink)); diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h index 536dad08..ec013fc5 100644 --- a/WWW/Library/Implementation/HTUtils.h +++ b/WWW/Library/Implementation/HTUtils.h @@ -359,6 +359,7 @@ Sucess (>=0) and failure (<0) codes #define HT_REDIRECTING 29996 #define HT_LOADED 29997 /* Instead of a socket */ +#define HT_PARTIAL_CONTENT 206 /* Partial Content */ #define HT_INTERRUPTED -29998 #define HT_NOT_LOADED -29999 #define HT_OK 0 /* Generic success*/ |