From 1c6757afa67bdaba78ca9d902165126e54bd8061 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sun, 17 Oct 2004 22:13:44 -0400 Subject: snapshot of project "lynx", label v2-8-6dev_7 --- WWW/Library/Implementation/HTFile.c | 790 ++++++++++++++++-------------------- 1 file changed, 361 insertions(+), 429 deletions(-) (limited to 'WWW/Library/Implementation/HTFile.c') diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c index bf10952f..de4c9b6d 100644 --- a/WWW/Library/Implementation/HTFile.c +++ b/WWW/Library/Implementation/HTFile.c @@ -812,6 +812,29 @@ const char *HTFileSuffix(HTAtom *rep, return ""; /* Dunno */ } +/* + * Trim version from VMS filenames to avoid confusing comparisons. + */ +#ifdef VMS +static const char *VMS_trim_version(const char *filename) +{ + const char *result = filename; + char *version = strchr(filename, ';'); + + if (version != 0) { + static char *stripped; + + StrAllocCopy(stripped, filename); + stripped[(const char *) version - filename] = '\0'; + result = (const char *) stripped; + } + return result; +} +#define VMS_DEL_VERSION(name) name = VMS_trim_version(name) +#else +#define VMS_DEL_VERSION(name) /* nothing */ +#endif + /* Determine file format from file name. * ------------------------------------- * @@ -832,9 +855,7 @@ HTFormat HTFileFormat(const char *filename, int i; int lf; -#ifdef VMS - char *semicolon = NULL; -#endif /* VMS */ + VMS_DEL_VERSION(filename); if (pencoding) *pencoding = NULL; @@ -845,15 +866,6 @@ HTFormat HTFileFormat(const char *filename, *pencoding = WWW_ENC_8BIT; return WWW_HTML; } -#ifdef VMS - /* - * Trim at semicolon if a version number was included, so it doesn't - * interfere with the code for getting the MIME type. - FM - */ - if ((semicolon = strchr(filename, ';')) != NULL) - *semicolon = '\0'; -#endif /* VMS */ - #ifndef NO_INIT if (!HTSuffixes) HTFileInit(); @@ -873,10 +885,6 @@ HTFormat HTFileFormat(const char *filename, if (pdesc) *pdesc = suff->desc; if (suff->rep) { -#ifdef VMS - if (semicolon != NULL) - *semicolon = ';'; -#endif /* VMS */ return suff->rep; /* OK -- found */ } for (j = 0; j < n; j++) { /* Got encoding, need representation */ @@ -894,10 +902,6 @@ HTFormat HTFileFormat(const char *filename, *pencoding != WWW_ENC_7BIT && !IsUnityEnc(suff->encoding)) *pencoding = suff->encoding; -#ifdef VMS - if (semicolon != NULL) - *semicolon = ';'; -#endif /* VMS */ return suff->rep; } } @@ -915,13 +919,11 @@ HTFormat HTFileFormat(const char *filename, /* * Set default encoding unless found with suffix already. */ - if (pencoding && !*pencoding) - *pencoding = suff->encoding ? suff->encoding - : HTAtom_for("binary"); -#ifdef VMS - if (semicolon != NULL) - *semicolon = ';'; -#endif /* VMS */ + if (pencoding && !*pencoding) { + *pencoding = (suff->encoding + ? suff->encoding + : HTAtom_for("binary")); + } return suff->rep ? suff->rep : WWW_BINARY; } @@ -1207,6 +1209,8 @@ CompressFileType HTCompressFileType(char *filename, size_t len = strlen(filename); char *ftype = filename + len; + VMS_DEL_VERSION(filename); + if ((len > 4) && !strcasecomp((ftype - 3), "bz2") && strchr(dots, ftype[-4]) != 0) { @@ -1217,6 +1221,11 @@ CompressFileType HTCompressFileType(char *filename, && strchr(dots, ftype[-3]) != 0) { result = cftGzip; ftype -= 3; + } else if ((len > 3) + && !strcasecomp((ftype - 2), "zz") + && strchr(dots, ftype[-3]) != 0) { + result = cftDeflate; + ftype -= 3; } else if ((len > 2) && !strcmp((ftype - 1), "Z") && strchr(dots, ftype[-2]) != 0) { @@ -1225,11 +1234,42 @@ CompressFileType HTCompressFileType(char *filename, } *suffix = ftype; + CTRACE((tfp, "HTCompressFileType(%s) returns %d:%s\n", filename, result, *suffix)); return result; } +/* + * Check if the token from "Content-Encoding" corresponds to a compression + * type. RFC 2068 (and cut/paste into RFC 2616) lists these: + * gzip + * compress + * deflate + * as well as "identity" (but that does nothing). + */ +CompressFileType HTEncodingToCompressType(const char *coding) +{ + CompressFileType result = cftNone; + + if (coding == 0) { + result = cftNone; + } else if (!strcasecomp(coding, "gzip") || + !strcasecomp(coding, "x-gzip")) { + result = cftGzip; + } else if (!strcasecomp(coding, "compress") || + !strcasecomp(coding, "x-compress")) { + result = cftCompress; + } else if (!strcasecomp(coding, "bzip2") || + !strcasecomp(coding, "x-bzip2")) { + result = cftBzip2; + } else if (!strcasecomp(coding, "deflate") || + !strcasecomp(coding, "x-deflate")) { + result = cftDeflate; + } + return result; +} + /* Determine write access to a file. * --------------------------------- * @@ -2079,6 +2119,269 @@ int HTStat(const char *filename, } #endif +#ifdef VMS +#define FOPEN_MODE(bin) "r", "shr=put", "shr=upd" +#define DOT_STRING "._-" /* FIXME: should we check if suffix is after ']' or ':' ? */ +#else +#define FOPEN_MODE(bin) (bin ? BIN_R : "r") +#define DOT_STRING "." +#endif + +static int decompressAndParse(HTParentAnchor *anchor, + HTFormat format_out, + HTStream *sink, + char *nodename GCC_UNUSED, + char *filename, + HTAtom *myEncoding, + HTFormat format, + int *statusp) +{ + HTAtom *encoding = 0; + +#ifdef USE_ZLIB + FILE *zzfp = 0; + gzFile gzfp = 0; +#endif /* USE_ZLIB */ +#ifdef USE_BZLIB + BZFILE *bzfp = 0; +#endif /* USE_ZLIB */ +#if defined(USE_ZLIB) || defined(USE_BZLIB) + CompressFileType internal_decompress = cftNone; + BOOL failed_decompress = NO; +#endif + char *dot = 0; + char *localname = filename; + int bin; + FILE *fp; + +#ifdef VMS + /* + * Assume that the file is in Unix-style syntax if it contains a '/' after + * the leading one. @@ + */ + localname = (strchr(localname + 1, '/') + ? HTVMS_name(nodename, localname) + : localname + 1); +#endif /* VMS */ + + bin = HTCompressFileType(filename, ".", &dot) != cftNone; + fp = fopen(localname, FOPEN_MODE(bin)); + +#ifdef VMS + /* + * If the file wasn't VMS syntax, then perhaps it is Ultrix. + */ + if (!fp) { + char *ultrixname = 0; + + CTRACE((tfp, "HTLoadFile: Can't open as %s\n", localname)); + HTSprintf0(&ultrixname, "%s::\"%s\"", nodename, filename); + fp = fopen(ultrixname, FOPEN_MODE(bin)); + if (!fp) { + CTRACE((tfp, "HTLoadFile: Can't open as %s\n", ultrixname)); + } + FREE(ultrixname); + } +#endif /* VMS */ + CTRACE((tfp, "HTLoadFile: Opening `%s' gives %p\n", localname, fp)); + if (fp) { /* Good! */ + if (HTEditable(localname)) { + HTAtom *put = HTAtom_for("PUT"); + HTList *methods = HTAnchor_methods(anchor); + + if (HTList_indexOf(methods, put) == (-1)) { + HTList_addObject(methods, put); + } + } + /* + * Fake a Content-Encoding for compressed files. - FM + */ + if (!IsUnityEnc(myEncoding)) { + /* + * We already know from the call to HTFileFormat that + * this is a compressed file, no need to look at the filename + * again. - kw + */ + CompressFileType method = HTEncodingToCompressType(HTAtom_name(myEncoding)); + +#define isDOWNLOAD(m) (strcmp(format_out->name, "www/download") && (method == m)) +#ifdef USE_ZLIB + if (isDOWNLOAD(cftGzip)) { + fclose(fp); + gzfp = gzopen(localname, BIN_R); + + CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", + localname, gzfp)); + internal_decompress = cftGzip; + } else if (isDOWNLOAD(cftDeflate)) { + zzfp = fp; + fp = 0; + + CTRACE((tfp, "HTLoadFile: zzopen of `%s' gives %p\n", + localname, zzfp)); + internal_decompress = cftDeflate; + } else +#endif /* USE_ZLIB */ +#ifdef USE_BZLIB + if (isDOWNLOAD(cftBzip2)) { + fclose(fp); + bzfp = BZ2_bzopen(localname, BIN_R); + + CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n", + localname, bzfp)); + internal_decompress = cftBzip2; + } else +#endif /* USE_BZLIB */ + { + StrAllocCopy(anchor->content_type, format->name); + StrAllocCopy(anchor->content_encoding, HTAtom_name(myEncoding)); + format = HTAtom_for("www/compressed"); + } + } else { + CompressFileType cft = HTCompressFileType(localname, DOT_STRING, &dot); + + if (cft != cftNone) { + char *cp = NULL; + + StrAllocCopy(cp, localname); + cp[dot - localname] = '\0'; + format = HTFileFormat(cp, &encoding, NULL); + FREE(cp); + format = HTCharsetFormat(format, anchor, + UCLYhndl_HTFile_for_unspec); + StrAllocCopy(anchor->content_type, format->name); + } + + switch (cft) { + case cftCompress: + StrAllocCopy(anchor->content_encoding, "x-compress"); + format = HTAtom_for("www/compressed"); + break; + case cftDeflate: + StrAllocCopy(anchor->content_encoding, "x-deflate"); +#ifdef USE_ZLIB + if (strcmp(format_out->name, "www/download") != 0) { + zzfp = fp; + fp = 0; + + CTRACE((tfp, "HTLoadFile: zzopen of `%s' gives %p\n", + localname, zzfp)); + internal_decompress = cftDeflate; + } +#else /* USE_ZLIB */ + format = HTAtom_for("www/compressed"); +#endif /* USE_ZLIB */ + break; + case cftGzip: + StrAllocCopy(anchor->content_encoding, "x-gzip"); +#ifdef USE_ZLIB + if (strcmp(format_out->name, "www/download") != 0) { + fclose(fp); + gzfp = gzopen(localname, BIN_R); + + CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", + localname, gzfp)); + internal_decompress = cftGzip; + } +#else /* USE_ZLIB */ + format = HTAtom_for("www/compressed"); +#endif /* USE_ZLIB */ + break; + case cftBzip2: + StrAllocCopy(anchor->content_encoding, "x-bzip2"); +#ifdef USE_BZLIB + if (strcmp(format_out->name, "www/download") != 0) { + fclose(fp); + bzfp = BZ2_bzopen(localname, BIN_R); + + CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n", + localname, bzfp)); + internal_decompress = cftBzip2; + } +#else /* USE_BZLIB */ + format = HTAtom_for("www/compressed"); +#endif /* USE_BZLIB */ + break; + case cftNone: + break; + } + } +#if defined(USE_ZLIB) || defined(USE_BZLIB) + if (internal_decompress != cftNone) { + switch (internal_decompress) { +#ifdef USE_ZLIB + case cftDeflate: + failed_decompress = (zzfp == 0); + break; + case cftCompress: + case cftGzip: + failed_decompress = (gzfp == 0); + break; +#endif +#ifdef USE_BZLIB + case cftBzip2: + failed_decompress = (bzfp == 0); + break; +#endif + default: + failed_decompress = YES; + break; + } + if (failed_decompress) { + *statusp = HTLoadError(NULL, + -(HT_ERROR), + FAILED_OPEN_COMPRESSED_FILE); + } else { + char *sugfname = NULL; + + if (anchor->SugFname) { + StrAllocCopy(sugfname, anchor->SugFname); + } else { + char *anchor_path = HTParse(anchor->address, "", + PARSE_PATH + PARSE_PUNCTUATION); + char *lastslash; + + HTUnEscape(anchor_path); + lastslash = strrchr(anchor_path, '/'); + if (lastslash) + StrAllocCopy(sugfname, lastslash + 1); + FREE(anchor_path); + } + FREE(anchor->content_encoding); + if (sugfname && *sugfname) + HTCheckFnameForCompression(&sugfname, anchor, + TRUE); + if (sugfname && *sugfname) + StrAllocCopy(anchor->SugFname, sugfname); + FREE(sugfname); +#ifdef USE_BZLIB + if (bzfp) + *statusp = HTParseBzFile(format, format_out, + anchor, + bzfp, sink); +#endif +#ifdef USE_ZLIB + if (gzfp) + *statusp = HTParseGzFile(format, format_out, + anchor, + gzfp, sink); + else if (zzfp) + *statusp = HTParseZzFile(format, format_out, + anchor, + zzfp, sink); +#endif + } + } else +#endif /* USE_ZLIB || USE_BZLIB */ + { + *statusp = HTParseFile(format, format_out, anchor, fp, sink); + fclose(fp); + } + return TRUE; + } /* If successful open */ + return FALSE; +} + /* Load a document. * ---------------- * @@ -2102,7 +2405,6 @@ int HTLoadFile(const char *addr, HTFormat format; char *nodename = NULL; char *newname = NULL; /* Simplified name of file */ - HTAtom *encoding; /* @@ not used yet */ HTAtom *myEncoding = NULL; /* enc of this file, may be gzip etc. */ int status = -1; char *dot; @@ -2110,16 +2412,6 @@ int HTLoadFile(const char *addr, #ifdef VMS struct stat stat_info; #endif /* VMS */ -#ifdef USE_ZLIB - gzFile gzfp = 0; -#endif /* USE_ZLIB */ -#ifdef USE_BZLIB - BZFILE *bzfp = 0; -#endif /* USE_ZLIB */ -#if defined(USE_ZLIB) || defined(USE_BZLIB) - CompressFileType internal_decompress = cftNone; - BOOL failed_decompress = NO; -#endif /* * Reduce the filename to a basic form (hopefully unique!). @@ -2231,222 +2523,19 @@ int HTLoadFile(const char *addr, } } - /* - * Assume that the file is in Unix-style syntax if it contains a '/' after - * the leading one. @@ - */ - { - FILE *fp; - char *vmsname = strchr(filename + 1, '/') ? - HTVMS_name(nodename, filename) : filename + 1; - - fp = fopen(vmsname, "r", "shr=put", "shr=upd"); - - /* - * If the file wasn't VMS syntax, then perhaps it is Ultrix. - */ - if (!fp) { - char *ultrixname = 0; - - CTRACE((tfp, "HTLoadFile: Can't open as %s\n", vmsname)); - HTSprintf0(&ultrixname, "%s::\"%s\"", nodename, filename); - fp = fopen(ultrixname, "r", "shr=put", "shr=upd"); - if (!fp) { - CTRACE((tfp, "HTLoadFile: Can't open as %s\n", - ultrixname)); - } - FREE(ultrixname); - } - if (fp) { - char *semicolon = NULL; - - if (HTEditable(vmsname)) { - HTAtom *put = HTAtom_for("PUT"); - HTList *methods = HTAnchor_methods(anchor); - - if (HTList_indexOf(methods, put) == (-1)) { - HTList_addObject(methods, put); - } - } - /* - * Trim vmsname at semicolon if a version number was included, so - * it doesn't interfere with the check for a compressed file. - FM - */ - if ((semicolon = strchr(vmsname, ';')) != NULL) - *semicolon = '\0'; - /* - * Fake a Content-Encoding for compressed files. - FM - */ - if (!IsUnityEnc(myEncoding)) { - /* - * We already know from the call to HTFileFormat above that - * this is a compressed file, no need to look at the filename - * again. - kw - */ -#ifdef USE_ZLIB - if (strcmp(format_out->name, "www/download") != 0 && - (!strcmp(HTAtom_name(myEncoding), "gzip") || - !strcmp(HTAtom_name(myEncoding), "x-gzip"))) { - fclose(fp); - if (semicolon != NULL) - *semicolon = ';'; - gzfp = gzopen(vmsname, BIN_R); - - CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", - vmsname, (void *) gzfp)); - internal_decompress = cftGzip; - } else -#endif /* USE_ZLIB */ -#ifdef USE_BZLIB - if (strcmp(format_out->name, "www/download") != 0 && - (!strcmp(HTAtom_name(myEncoding), "bzip2") || - !strcmp(HTAtom_name(myEncoding), "x-bzip2"))) { - fclose(fp); - if (semicolon != NULL) - *semicolon = ';'; - bzfp = BZ2_bzopen(vmsname, BIN_R); - - CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n", - vmsname, (void *) bzfp)); - use_zread = YES; - } else -#endif /* USE_BZLIB */ - { - StrAllocCopy(anchor->content_type, format->name); - StrAllocCopy(anchor->content_encoding, HTAtom_name(myEncoding)); - format = HTAtom_for("www/compressed"); - } - } else { - /* FIXME: should we check if suffix is after ']' or ':' ? */ - CompressFileType cft = HTCompressFileType(vmsname, "._-", &dot); - - if (cft != cftNone) { - char *cp = NULL; - - StrAllocCopy(cp, vmsname); - cp[dot - vmsname] = '\0'; - format = HTFileFormat(cp, &encoding, NULL); - FREE(cp); - format = HTCharsetFormat(format, anchor, - UCLYhndl_HTFile_for_unspec); - StrAllocCopy(anchor->content_type, format->name); - } - - switch (cft) { - case cftCompress: - StrAllocCopy(anchor->content_encoding, "x-compress"); - format = HTAtom_for("www/compressed"); - break; - case cftGzip: - StrAllocCopy(anchor->content_encoding, "x-gzip"); -#ifdef USE_ZLIB - if (strcmp(format_out->name, "www/download") != 0) { - fclose(fp); - if (semicolon != NULL) - *semicolon = ';'; - gzfp = gzopen(vmsname, BIN_R); - - CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", - vmsname, (void *) gzfp)); - internal_decompress = cftGzip; - } -#else /* USE_ZLIB */ - format = HTAtom_for("www/compressed"); -#endif /* USE_ZLIB */ - break; - case cftBzip2: - StrAllocCopy(anchor->content_encoding, "x-bzip2"); -#ifdef USE_BZLIB - if (strcmp(format_out->name, "www/download") != 0) { - fclose(fp); - if (semicolon != NULL) - *semicolon = ';'; - bzfp = BZ2_bzopen(vmsname, BIN_R); - - CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n", - vmsname, (void *) bzfp)); - internal_decompress = cfgBzip2; - } -#else /* USE_BZLIB */ - format = HTAtom_for("www/compressed"); -#endif /* USE_BZLIB */ - break; - case cftNone: - break; - } - } - if (semicolon != NULL) - *semicolon = ';'; - FREE(filename); - FREE(nodename); -#if defined(USE_ZLIB) || defined(USE_BZLIB) - if (internal_decompress != cftNone) { - switch (internal_decompress) { -#ifdef USE_ZLIB - case cftCompress: - case cftGzip: - failed_decompress = (gzfp == 0); - break; -#endif -#ifdef USE_BZLIB - case cftBzip2: - failed_decompress = (bzfp == 0); - break; -#endif - default: - failed_decompress = YES; - break; - } - if (failed_decompress) { - status = HTLoadError(NULL, - -(HT_ERROR), - FAILED_OPEN_COMPRESSED_FILE); - } else { - char *sugfname = NULL; - - if (anchor->SugFname) { - StrAllocCopy(sugfname, anchor->SugFname); - } else { - char *anchor_path = HTParse(anchor->address, "", - PARSE_PATH + PARSE_PUNCTUATION); - char *lastslash; - - HTUnEscape(anchor_path); - lastslash = strrchr(anchor_path, '/'); - if (lastslash) - StrAllocCopy(sugfname, lastslash + 1); - FREE(anchor_path); - } - FREE(anchor->content_encoding); - if (sugfname && *sugfname) - HTCheckFnameForCompression(&sugfname, anchor, - TRUE); - if (sugfname && *sugfname) - StrAllocCopy(anchor->SugFname, sugfname); - FREE(sugfname); -#ifdef USE_BZLIB - if (bzfp) - status = HTParseBzFile(format, format_out, - anchor, - bzfp, sink); -#endif -#ifdef USE_ZLIB - if (gzfp) - status = HTParseGzFile(format, format_out, - anchor, - gzfp, sink); -#endif - } - } else -#endif /* USE_ZLIB || USE_BZLIB */ - { - status = HTParseFile(format, format_out, anchor, fp, sink); - fclose(fp); - } - return status; - } /* If successful open */ + if (decompressAndParse(anchor, + format_out, + sink, + nodename, + filename, + myEncoding, + format, + &status)) { + FREE(nodename); FREE(filename); + return status; } + FREE(filename); #else /* not VMS: */ @@ -2540,6 +2629,9 @@ int HTLoadFile(const char *addr, case cftGzip: atomname = "application/x-gzip"; break; + case cftDeflate: + atomname = "application/x-deflate"; + break; case cftBzip2: atomname = "application/x-bzip2"; break; @@ -2678,184 +2770,19 @@ int HTLoadFile(const char *addr, /* End of directory reading section */ #endif /* HAVE_READDIR */ - { - int bin = HTCompressFileType(localname, ".", &dot) != cftNone; - FILE *fp = fopen(localname, (bin ? BIN_R : "r")); - - CTRACE((tfp, "HTLoadFile: Opening `%s' gives %p\n", - localname, (void *) fp)); - if (fp) { /* Good! */ - if (HTEditable(localname)) { - HTAtom *put = HTAtom_for("PUT"); - HTList *methods = HTAnchor_methods(anchor); - - if (HTList_indexOf(methods, put) == (-1)) { - HTList_addObject(methods, put); - } - } - /* - * Fake a Content-Encoding for compressed files. - FM - */ - if (!IsUnityEnc(myEncoding)) { - /* - * We already know from the call to HTFileFormat above that - * this is a compressed file, no need to look at the - * filename again. - kw - */ -#ifdef USE_ZLIB - if (strcmp(format_out->name, "www/download") != 0 && - (!strcmp(HTAtom_name(myEncoding), "gzip") || - !strcmp(HTAtom_name(myEncoding), "x-gzip"))) { - fclose(fp); - gzfp = gzopen(localname, BIN_R); - - CTRACE((tfp, "HTLoadFile: gzopen of `%s' gives %p\n", - localname, (void *) gzfp)); - internal_decompress = cftGzip; - } else -#endif /* USE_ZLIB */ -#ifdef USE_BZLIB - if (strcmp(format_out->name, "www/download") != 0 && - (!strcmp(HTAtom_name(myEncoding), "bzip2") || - !strcmp(HTAtom_name(myEncoding), "x-bzip2"))) { - fclose(fp); - bzfp = BZ2_bzopen(localname, BIN_R); - - CTRACE((tfp, "HTLoadFile: bzopen of `%s' gives %p\n", - localname, (void *) bzfp)); - internal_decompress = cftBzip2; - } else -#endif /* USE_BZLIB */ - { - StrAllocCopy(anchor->content_type, format->name); - StrAllocCopy(anchor->content_encoding, HTAtom_name(myEncoding)); - format = HTAtom_for("www/compressed"); - } - } else { - CompressFileType cft = HTCompressFileType(localname, ".", &dot); - - if (cft != cftNone) { - char *cp = NULL; - - StrAllocCopy(cp, localname); - cp[dot - localname] = '\0'; - format = HTFileFormat(cp, &encoding, NULL); - FREE(cp); - format = HTCharsetFormat(format, anchor, - UCLYhndl_HTFile_for_unspec); - StrAllocCopy(anchor->content_type, format->name); - } - - switch (cft) { - case cftCompress: - StrAllocCopy(anchor->content_encoding, "x-compress"); - format = HTAtom_for("www/compressed"); - break; - case cftGzip: - StrAllocCopy(anchor->content_encoding, "x-gzip"); -#ifdef USE_ZLIB - if (strcmp(format_out->name, "www/download") != 0) { - fclose(fp); - gzfp = gzopen(localname, BIN_R); - - CTRACE((tfp, - "HTLoadFile: gzopen of `%s' gives %p\n", - localname, (void *) gzfp)); - internal_decompress = cftGzip; - } -#else /* USE_ZLIB */ - format = HTAtom_for("www/compressed"); -#endif /* USE_ZLIB */ - break; - case cftBzip2: - StrAllocCopy(anchor->content_encoding, "x-bzip2"); -#ifdef USE_BZLIB - if (strcmp(format_out->name, "www/download") != 0) { - fclose(fp); - bzfp = BZ2_bzopen(localname, BIN_R); - - CTRACE((tfp, - "HTLoadFile: bzopen of `%s' gives %p\n", - localname, (void *) bzfp)); - internal_decompress = cftBzip2; - } -#else /* USE_BZLIB */ - format = HTAtom_for("www/compressed"); -#endif /* USE_BZLIB */ - break; - case cftNone: - break; - } - } - FREE(localname); - FREE(nodename); -#if defined(USE_ZLIB) || defined(USE_BZLIB) - if (internal_decompress != cftNone) { - switch (internal_decompress) { -#ifdef USE_ZLIB - case cftGzip: - failed_decompress = (gzfp == 0); - break; -#endif -#ifdef USE_BZLIB - case cftBzip2: - failed_decompress = (bzfp == 0); - break; -#endif - default: - failed_decompress = YES; - break; - } - if (failed_decompress) { - status = HTLoadError(NULL, - -(HT_ERROR), - FAILED_OPEN_COMPRESSED_FILE); - } else { - char *sugfname = NULL; - - if (anchor->SugFname) { - StrAllocCopy(sugfname, anchor->SugFname); - } else { - char *anchor_path = HTParse(anchor->address, "", - PARSE_PATH + PARSE_PUNCTUATION); - char *lastslash; - - HTUnEscape(anchor_path); - lastslash = strrchr(anchor_path, '/'); - if (lastslash) - StrAllocCopy(sugfname, lastslash + 1); - FREE(anchor_path); - } - FREE(anchor->content_encoding); - if (sugfname && *sugfname) - HTCheckFnameForCompression(&sugfname, anchor, - TRUE); - if (sugfname && *sugfname) - StrAllocCopy(anchor->SugFname, sugfname); - FREE(sugfname); -#ifdef USE_BZLIB - if (bzfp) - status = HTParseBzFile(format, format_out, - anchor, - bzfp, sink); -#endif -#ifdef USE_ZLIB - if (gzfp) - status = HTParseGzFile(format, format_out, - anchor, - gzfp, sink); -#endif - } - } else -#endif /* USE_ZLIB */ - { - status = HTParseFile(format, format_out, anchor, fp, sink); - fclose(fp); - } - return status; - } /* If successful open */ + if (decompressAndParse(anchor, + format_out, + sink, + nodename, + localname, + myEncoding, + format, + &status)) { + FREE(nodename); FREE(localname); - } /* scope of fp */ + return status; + } + FREE(localname); } /* local unix file system */ #endif /* !NO_UNIX_IO */ #endif /* VMS */ @@ -2966,6 +2893,11 @@ void HTInitProgramPaths(void) path = GZIP_PATH; break; #endif +#ifdef INFLATE_PATH + case ppINFLATE: + path = INFLATE_PATH; + break; +#endif #ifdef INSTALL_PATH case ppINSTALL: path = INSTALL_PATH; -- cgit 1.4.1-2-gfad0 html/016dilated_reagent.cc.html?h=hlt&id=e5c11a5137d538b7713dd8708ca767c208824c06'>^
201458e3 ^

204dae92 ^



201458e3 ^
204dae92 ^











201458e3 ^
204dae92 ^



9e751bb8 ^


1c2d788b ^
9e751bb8 ^







1c2d788b ^
9e751bb8 ^






1c2d788b ^
9e751bb8 ^





204dae92 ^
598f1b53 ^
204dae92 ^



2c678a4e ^
204dae92 ^



201458e3 ^
204dae92 ^
1c2d788b ^
9e751bb8 ^
204dae92 ^

1c2d788b ^
9e751bb8 ^
204dae92 ^

9e751bb8 ^


1c2d788b ^
9e751bb8 ^





204dae92 ^
2c678a4e ^
9e751bb8 ^





1c2d788b ^
9e751bb8 ^




204dae92 ^




201458e3 ^
598f1b53 ^
204dae92 ^
9e751bb8 ^
1c2d788b ^
9e751bb8 ^
204dae92 ^

9e751bb8 ^
204dae92 ^
9e751bb8 ^
204dae92 ^

76755b28 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220