if (!strncasecomp((ct ? ct : ""), "application/gzip", 16) || !strncasecomp((ct ? ct : ""), "application/x-gzip", 18)) { method = 1; } else if (!strncasecomp((ct ? ct : ""), "application/compress", 20) || !strncasecomp((ct ? ct : ""), "application/x-compress", 22)) { method = 2;
if (!strncasecomp(ct, "application/gzip", 16) || !strncasecomp(ct, "application/x-gzip", 18)) { method = cftGzip; } else if (!strncasecomp(ct, "application/compress", 20) || !strncasecomp(ct, "application/x-compress", 22)) { method = cftCompress; } else if (!strncasecomp(ct, "application/bzip2", 17) || !strncasecomp(ct, "application/x-bzip2", 19)) { method = cftBzip2;
PUBLIC void HTCheckFnameForCompression ARGS3(	char **,		fname,	HTParentAnchor *,	anchor,	BOOL,			strip_ok){    char *fn = *fname;    char *dot = NULL, *cp = NULL;    CONST char *ct = NULL;    CONST char *ce = NULL;    BOOLEAN method = 0;    /*     *  Make sure we have a string and anchor. - FM     */    if (!(fn && *fn && anchor))	return;    /*     *  Make sure we have a file, not directory, name. -FM     */    if ((cp = strrchr(fn, '/')) != NULL) {	fn = (cp +1);	if (*fn == '\0') {	    return;	}    }    /*     *  Check the anchor's content_type and content_encoding     *  elements for a gzip or Unix compressed file. - FM     */    ct = HTAnchor_content_type(anchor);    ce = HTAnchor_content_encoding(anchor);    if (ce == NULL) {	/*	 *  No Content-Encoding, so check	 *  the Content-Type. - FM	 */	if (!strncasecomp((ct ? ct : ""), "application/gzip", 16) ||	    !strncasecomp((ct ? ct : ""), "application/x-gzip", 18)) {	    method = 1;	} else if (!strncasecomp((ct ? ct : ""),				 "application/compress", 20) ||		   !strncasecomp((ct ? ct : ""),				 "application/x-compress", 22)) {	    method = 2;	}    } else if (!strcasecomp(ce, "gzip") ||	       !strcasecomp(ce, "x-gzip")) {	    /*	     *  It's gzipped. - FM	     */	    method = 1;    } else if (!strcasecomp(ce, "compress") ||	       !strcasecomp(ce, "x-compress")) {	    /*	     *  It's Unix compressed. - FM	     */	    method = 2;    }    /*     *  If no Content-Encoding has been detected via the anchor     *  pointer, but strip_ok is not set, there is nothing left     *  to do. - kw     */    if (method == 0 && !strip_ok)	return;    /*     *  Seek the last dot, and check whether     *  we have a gzip or compress suffix. - FM     */    if ((dot = strrchr(fn, '.')) != NULL) {	if (!strcasecomp(dot, ".tgz") ||	    !strcasecomp(dot, ".gz") ||	    !strcasecomp(dot, ".Z")) {	    if (!method) {		/*		 *  It has a suffix which signifies a gzipped		 *  or compressed file for us, but the anchor		 *  claims otherwise, so tweak the suffix. - FM		 */		cp = (dot + 1);		*dot = '\0';		if (!strcasecomp(cp, "tgz")) {		    StrAllocCat(*fname, ".tar");		}	    }	    return;	}	if (strlen(dot) > 4) {	    cp = ((dot + strlen(dot)) - 3);	    if (!strcasecomp(cp, "-gz") ||		!strcasecomp(cp, "_gz")) {		if (!method) {		    /*		     *  It has a tail which signifies a gzipped		     *  file for us, but the anchor claims otherwise,		     *  so tweak the suffix. - FM		     */		    *dot = '\0';		} else {		    /*		     *  The anchor claims it's gzipped, and we		     *  believe it, so force this tail to the		     *  conventional suffix. - FM		     */#ifdef VMS		    *cp = '-';#else		    *cp = '.';#endif /* VMS */		    cp++;		    *cp = TOLOWER(*cp);		    cp++;		    *cp = TOLOWER(*cp);		}		return;	    }	}	if (strlen(dot) > 3) {	    cp = ((dot + strlen(dot)) - 2);	    if (!strcasecomp(cp, "-Z") ||		!strcasecomp(cp, "_Z")) {		if (!method) {		    /*		     *  It has a tail which signifies a compressed		     *  file for us, but the anchor claims otherwise,		     *  so tweak the suffix. - FM		     */		    *dot = '\0';		} else {		    /*		     *  The anchor claims it's compressed, and		     *  we believe it, so force this tail to the		     *  conventional suffix. - FM		     */#ifdef VMS		    *cp = '-';#else		    *cp = '.';#endif /* VMS */		    cp++;		    *cp = TOUPPER(*cp);		}		return;	    }	}    }    if (!method) {	/*	 *  Don't know what compression method	 *  was used, if any, so we won't do	 *  anything. - FM	 */	return;    }    /*     *  Add the appropriate suffix. - FM     */    if (!dot) {	StrAllocCat(*fname, ((method == 1) ? ".gz" : ".Z"));	return;    }    dot++;    if (*dot == '\0') {	StrAllocCat(*fname, ((method == 1) ? "gz" : "Z"));	return;    }#ifdef VMS    StrAllocCat(*fname, ((method == 1) ? "-gz" : "-Z"));#else    StrAllocCat(*fname, ((method == 1) ? ".gz" : ".Z"));#endif /* !VMS */    return;}