about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GridText.c21
-rw-r--r--src/HTFWriter.c90
-rw-r--r--src/HTInit.c4
-rw-r--r--src/LYMain.c2
-rw-r--r--src/LYOptions.c1
-rw-r--r--src/LYReadCFG.c4
-rw-r--r--src/LYUtils.c6
-rw-r--r--src/LYrcFile.c1
-rw-r--r--src/LYrcFile.h1
9 files changed, 79 insertions, 51 deletions
diff --git a/src/GridText.c b/src/GridText.c
index a10322a1..4e5e3ba8 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -6737,8 +6737,9 @@ void HTCheckFnameForCompression(char **fname,
 				BOOL strip_ok)
 {
     char *fn = *fname;
-    char *dot = NULL, *cp = NULL;
-    char *suffix;
+    char *dot = NULL;
+    char *cp = NULL;
+    char *suffix = "";
     const char *ct = NULL;
     const char *ce = NULL;
     CompressFileType method = cftNone;
@@ -6778,16 +6779,7 @@ void HTCheckFnameForCompression(char **fname,
 	    method = cftBzip2;
 	}
     } else if (ce != 0) {
-	if (!strcasecomp(ce, "gzip") ||
-	    !strcasecomp(ce, "x-gzip")) {
-	    method = cftGzip;
-	} else if (!strcasecomp(ce, "compress") ||
-		   !strcasecomp(ce, "x-compress")) {
-	    method = cftCompress;
-	} else if (!strcasecomp(ce, "bzip2") ||
-		   !strcasecomp(ce, "x-bzip2")) {
-	    method = cftBzip2;
-	}
+	method = HTEncodingToCompressType(ce);
     }
 
     /*
@@ -6856,12 +6848,15 @@ void HTCheckFnameForCompression(char **fname,
     }
 
     switch (method) {
-    default:
+    case cftNone:
 	suffix = "";
 	break;
     case cftCompress:
 	suffix = ".Z";
 	break;
+    case cftDeflate:
+	suffix = ".zz";
+	break;
     case cftGzip:
 	suffix = ".gz";
 	break;
diff --git a/src/HTFWriter.c b/src/HTFWriter.c
index f494b1e7..4b3b98c1 100644
--- a/src/HTFWriter.c
+++ b/src/HTFWriter.c
@@ -172,7 +172,8 @@ static void HTFWriter_free(HTStream *me)
 		 */
 		StrAllocCopy(path, me->anchor->FileCache);
 		if ((len = strlen(path)) > 3 &&
-		    !strcasecomp(&path[len - 2], "gz")) {
+		    (!strcasecomp(&path[len - 2], "gz") ||
+		     !strcasecomp(&path[len - 2], "zz"))) {
 #ifdef USE_ZLIB
 		    if (!skip_loadfile) {
 			use_zread = YES;
@@ -955,11 +956,11 @@ HTStream *HTCompressed(HTPresentation *pres,
     HTFormat format;
     char *type = NULL;
     HTPresentation *Pres = NULL;
+    HTPresentation *Pnow = NULL;
     int n, i;
     BOOL can_present = FALSE;
     char fnam[LY_MAXPATH];
     char temp[LY_MAXPATH];	/* actually stores just a suffix */
-    const char *program;
     const char *suffix;
     char *uncompress_mask = NULL;
     char *compress_suffix = "";
@@ -980,44 +981,67 @@ HTStream *HTCompressed(HTPresentation *pres,
     }
     n = HTList_count(HTPresentations);
     for (i = 0; i < n; i++) {
-	Pres = (HTPresentation *) HTList_objectAt(HTPresentations, i);
-	if (!strcasecomp(Pres->rep->name, anchor->content_type) &&
-	    Pres->rep_out == WWW_PRESENT) {
+	Pnow = (HTPresentation *) HTList_objectAt(HTPresentations, i);
+	if (!strcasecomp(Pnow->rep->name, anchor->content_type) &&
+	    Pnow->rep_out == WWW_PRESENT) {
+	    const char *program = "";
+
+	    /*
+	     * Pick the best presentation.  User-defined mappings are at the
+	     * end of the list, and unless the quality is lower, we prefer
+	     * those.
+	     */
+	    if (Pres == 0)
+		Pres = Pnow;
+	    else if (Pres->quality > Pnow->quality)
+		continue;
+	    else
+		Pres = Pnow;
 	    /*
 	     * We have a presentation mapping for it.  - FM
 	     */
 	    can_present = TRUE;
-	    if ((!strcasecomp(anchor->content_encoding, "x-gzip") ||
-		 !strcasecomp(anchor->content_encoding, "gzip")) &&
-		(program = HTGetProgramPath(ppGZIP)) != NULL) {
-		/*
-		 * It's compressed with the modern gzip.  - FM
-		 */
-		StrAllocCopy(uncompress_mask, program);
-		StrAllocCat(uncompress_mask, " -d --no-name %s");
-		compress_suffix = "gz";
+	    switch (HTEncodingToCompressType(anchor->content_encoding)) {
+	    case cftGzip:
+		if ((program = HTGetProgramPath(ppGZIP)) != NULL) {
+		    /*
+		     * It's compressed with the modern gzip.  - FM
+		     */
+		    StrAllocCopy(uncompress_mask, program);
+		    StrAllocCat(uncompress_mask, " -d --no-name %s");
+		    compress_suffix = "gz";
+		}
 		break;
-	    }
-	    if ((!strcasecomp(anchor->content_encoding, "x-bzip2") ||
-		 !strcasecomp(anchor->content_encoding, "bzip2")) &&
-		(program = HTGetProgramPath(ppBZIP2)) != NULL) {
-		StrAllocCopy(uncompress_mask, program);
-		StrAllocCat(uncompress_mask, " -d %s");
-		compress_suffix = "bz2";
+	    case cftDeflate:
+		if ((program = HTGetProgramPath(ppINFLATE)) != NULL) {
+		    /*
+		     * It's compressed with a zlib wrapper.
+		     */
+		    StrAllocCopy(uncompress_mask, program);
+		    StrAllocCat(uncompress_mask, " %s");
+		    compress_suffix = "zz";
+		}
 		break;
-	    }
-	    if ((!strcasecomp(anchor->content_encoding, "x-compress") ||
-		 !strcasecomp(anchor->content_encoding, "compress")) &&
-		(program = HTGetProgramPath(ppUNCOMPRESS)) != NULL) {
-		/*
-		 * It's compressed the old fashioned Unix way.  - FM
-		 */
-		StrAllocCopy(uncompress_mask, program);
-		StrAllocCat(uncompress_mask, " %s");
-		compress_suffix = "Z";
+	    case cftBzip2:
+		if ((program = HTGetProgramPath(ppBZIP2)) != NULL) {
+		    StrAllocCopy(uncompress_mask, program);
+		    StrAllocCat(uncompress_mask, " -d %s");
+		    compress_suffix = "bz2";
+		}
+		break;
+	    case cftCompress:
+		if ((program = HTGetProgramPath(ppUNCOMPRESS)) != NULL) {
+		    /*
+		     * It's compressed the old fashioned Unix way.  - FM
+		     */
+		    StrAllocCopy(uncompress_mask, program);
+		    StrAllocCat(uncompress_mask, " %s");
+		    compress_suffix = "Z";
+		}
+		break;
+	    case cftNone:
 		break;
 	    }
-	    break;
 	}
     }
     if (can_present == FALSE ||	/* no presentation mapping */
@@ -1087,6 +1111,7 @@ HTStream *HTCompressed(HTPresentation *pres,
     } else if (!strncasecomp(anchor->content_type, "text/", 5)) {
 	middle = TEXT_SUFFIX + 1;
     } else if (!strncasecomp(anchor->content_type, "application/", 12)) {
+	/* FIXME: why is this BEFORE HTFileSuffix? */
 	middle = BIN_SUFFIX + 1;
     } else if ((suffix =
 		HTFileSuffix(HTAtom_for(anchor->content_type), NULL)) &&
@@ -1158,6 +1183,7 @@ HTStream *HTCompressed(HTPresentation *pres,
     } else
 #endif
 #ifdef USE_ZLIB
+	/* FIXME: allow deflate here, e.g., 'z' */
 	if (compress_suffix[0] == 'g'	/* must be gzip */
 	    && !me->viewer_command) {
 	/*
diff --git a/src/HTInit.c b/src/HTInit.c
index a1380cd7..85ef10de 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -1093,8 +1093,10 @@ void HTFileInit(void)
 
 	SET_SUFFIX5(".zip",	"application/zip",		"binary", "Zip File");
 
-	SET_SUFFIX1(".bz2",	"application/x-bzip2",		"binary");
+	SET_SUFFIX1(".zz",	"application/x-deflate",	"binary");
+	SET_SUFFIX1(".zz",	"application/deflate",		"binary");
 
+	SET_SUFFIX1(".bz2",	"application/x-bzip2",		"binary");
 	SET_SUFFIX1(".bz2",	"application/bzip2",		"binary");
 
 #ifdef TRADITIONAL_SUFFIXES
diff --git a/src/LYMain.c b/src/LYMain.c
index 38a4fc0f..5bfa4ac0 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -4140,7 +4140,7 @@ static BOOL parse_arg(char **argv,
 		if ((countp != 0) && (next_arg != 0))
 		    (*countp)++;
 	    }
-	    CTRACE((tfp, "...arg:%s\n", next_arg != 0 ? next_arg : "<null>"));
+	    CTRACE((tfp, "...arg:%s\n", NONNULL(next_arg)));
 	}
 
 	/* ignore option if it's not our turn */
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 99f0140d..25f995fa 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -2383,6 +2383,7 @@ static OptValues encoding_values[] =
     {encodingNONE, N_("None"), "encoding_none"},
 #if defined(USE_ZLIB) || defined(GZIP_PATH)
     {encodingGZIP, N_("gzip"), "encoding_gzip"},
+    {encodingDEFLATE, N_("deflate"), "encoding_deflate"},
 #endif
 #if defined(USE_ZLIB) || defined(COMPRESS_PATH)
     {encodingCOMPRESS, N_("compress"), "encoding_compress"},
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 83fd3def..0ce9e480 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -1331,6 +1331,7 @@ static Config_Type Config_Table [] =
      PARSE_Env(RC_HTTP_PROXY,           0),
      PARSE_Env(RC_HTTPS_PROXY,          0),
      PARSE_REQ(RC_INCLUDE,              0),
+     PARSE_PRG(RC_INFLATE_PATH,         ppINFLATE),
      PARSE_TIM(RC_INFOSECS,             InfoSecs),
      PARSE_PRG(RC_INSTALL_PATH,         ppINSTALL),
      PARSE_STR(RC_JUMP_PROMPT,          jumpprompt),
@@ -1662,7 +1663,7 @@ void LYSetConfigValue(char *name,
 {
     Config_Type *tbl = lookup_config(name);
     ParseUnionPtr q = ParseUnionOf(tbl);
-    char *temp;
+    char *temp = 0;
 
     switch (tbl->type) {
     case CONF_BOOL:
@@ -1878,6 +1879,7 @@ static void do_read_cfg(char *cfg_filename,
 	case CONF_STR:
 	case CONF_ENV:
 	case CONF_ENV2:
+	case CONF_PRG:
 	case CONF_ADD_ITEM:
 	case CONF_ADD_TRUSTED:
 	    LYSetConfigValue(name, value);
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 448575c4..7f456979 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -2665,7 +2665,7 @@ BOOLEAN inlocaldomain(void)
     } else {
 	CTRACE((tfp,
 		"Could not get ttyname (returned %s) or open UTMP file %s\n",
-		((cp != 0) ? cp : "<null>"), UTMP_FILE));
+		NONNULL(cp), UTMP_FILE));
     }
 
     return (FALSE);
@@ -7490,9 +7490,9 @@ void LYmsec_delay(unsigned msec)
     struct timeval tv;
     unsigned long usec = 1000UL * msec;
 
-    tv.tv_sec  = usec / 1000000UL;
+    tv.tv_sec = usec / 1000000UL;
     tv.tv_usec = usec % 1000000UL;
-    select (0, NULL, NULL, NULL, &tv);
+    select(0, NULL, NULL, NULL, &tv);
 #endif
 }
 
diff --git a/src/LYrcFile.c b/src/LYrcFile.c
index e47b99e5..c7437d92 100644
--- a/src/LYrcFile.c
+++ b/src/LYrcFile.c
@@ -86,6 +86,7 @@ Config_Enum tbl_preferred_encoding[] = {
     { "none",		encodingNONE },
 #if defined(USE_ZLIB) || defined(GZIP_PATH)
     { "gzip",		encodingGZIP },
+    { "deflate",	encodingDEFLATE },
 #endif
 #if defined(USE_ZLIB) || defined(COMPRESS_PATH)
     { "compress",	encodingCOMPRESS },
diff --git a/src/LYrcFile.h b/src/LYrcFile.h
index 8b7df5c4..22b18b15 100644
--- a/src/LYrcFile.h
+++ b/src/LYrcFile.h
@@ -91,6 +91,7 @@
 #define RC_HTTPS_PROXY                  "https_proxy"
 #define RC_HTTP_PROXY                   "http_proxy"
 #define RC_INCLUDE                      "include"
+#define RC_INFLATE_PATH                 "inflate_path"
 #define RC_INFOSECS                     "infosecs"
 #define RC_INSTALL_PATH                 "install_path"
 #define RC_JUMPBUFFER                   "jumpbuffer"