about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTFile.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1998-11-10 19:47:00 -0500
committerThomas E. Dickey <dickey@invisible-island.net>1998-11-10 19:47:00 -0500
commitd3f9d5478df478427c2aa5db4507ddd0a38f0eb6 (patch)
treee27eacd6bbda653dd77f11cc020b9e0a59f7f4fc /WWW/Library/Implementation/HTFile.c
parent18024037b515bfff83e0230b35151babe6005e18 (diff)
downloadlynx-snapshots-d3f9d5478df478427c2aa5db4507ddd0a38f0eb6.tar.gz
snapshot of project "lynx", label v2-8-2dev_2
Diffstat (limited to 'WWW/Library/Implementation/HTFile.c')
-rw-r--r--WWW/Library/Implementation/HTFile.c293
1 files changed, 124 insertions, 169 deletions
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 039e9b65..70811025 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -20,6 +20,8 @@
 **			 the device or top directory.
 */
 
+#include <HTUtils.h>
+
 #ifndef VMS
 /* #define LONG_LIST */ /* Define this for long style unix listings (ls -l) */
 /* #define NO_PARENT_DIR_REFERENCE */ /* Define this for no parent links */
@@ -27,13 +29,10 @@
 
 #ifdef DOSPATH
 #define HAVE_READDIR 1
-#include <dirent.h>
 #define USE_DIRENT
 #include <HTDOS.h>
 #endif /* DOSPATH */
 
-#include <HTUtils.h>
-#include <tcp.h>
 #include <HTFile.h>		/* Implemented here */
 #ifdef VMS
 #include <stat.h>
@@ -53,14 +52,6 @@
 #define INFINITY 512		/* file name length @@ FIXME */
 #define MULTI_SUFFIX ".multi"	/* Extension for scanning formats */
 
-#define HT_EM_SPACE ((char)2)
-
-#define FREE(x) if (x) {free(x); x = NULL;}
-
-#ifdef VMS
-#include <HTVMSUtils.h>
-#endif /* VMS */
-
 #include <HTParse.h>
 #include <HTTCP.h>
 #ifndef DECNET
@@ -81,6 +72,7 @@
 #include <LYexit.h>
 #include <LYCharSets.h>
 #include <LYGlobalDefs.h>
+#include <LYStrings.h>
 #include <LYUtils.h>
 #include <LYLeaks.h>
 
@@ -100,6 +92,10 @@ typedef struct _HTSuffix {
 #endif /* NGROUPS_MAX */
 #endif /* NGROUPS */
 
+#ifndef GETGROUPS_T
+#define GETGROUPS_T int
+#endif
+
 #include <HTML.h>		/* For directory object building */
 
 #define PUTC(c) (*target->isa->put_character)(target, c)
@@ -121,15 +117,10 @@ PUBLIC int HTDirAccess = HT_DIR_OK;
 
 #ifdef DIRED_SUPPORT
 PUBLIC int HTDirReadme = HT_DIR_README_NONE;
-#define FILES_FIRST 1
-#define MIXED_STYLE 2
-extern BOOLEAN lynx_edit_mode;
-extern BOOLEAN dir_list_style;
 #else
 PUBLIC int HTDirReadme = HT_DIR_README_TOP;
 #endif /* DIRED_SUPPORT */
 
-extern BOOLEAN LYRawMode;
 extern BOOL HTPassEightBitRaw;
 extern HTCJKlang HTCJK;
 
@@ -223,6 +214,7 @@ PRIVATE void LYListFmtParse ARGS5(
 			s++;
 		c = *s; 	/* the format char. or \0 */
 		*s = '\0';
+		buf[0] = '\0';
 
 		switch (c) {
 		case '\0':
@@ -236,7 +228,7 @@ PRIVATE void LYListFmtParse ARGS5(
 			PUTS(buf);
 			END(HTML_A);
 #ifdef S_IFLNK
-			if (c != 'A' && (st.st_mode & S_IFMT) == S_IFLNK &&
+			if (c != 'A' && S_ISLNK(st.st_mode) &&
 			    (len = readlink(file, buf, sizeof(buf))) >= 0) {
 				PUTS(" -> ");
 				buf[len] = '\0';
@@ -270,7 +262,7 @@ PRIVATE void LYListFmtParse ARGS5(
 			break;
 
 		case 'K':	/* size in Kilobytes but not for directories */
-			if ((st.st_mode & S_IFMT) == S_IFDIR) {
+			if (S_ISDIR(st.st_mode)) {
 				sprintf(fmt, "%%%ss ", start);
 				sprintf(buf, fmt, "");
 				break;
@@ -565,59 +557,60 @@ PRIVATE int HTCreatePath ARGS1(CONST char *,path)
 **  On exit:
 **	Returns a malloc'ed string which must be freed by the caller.
 */
-PUBLIC char * HTLocalName ARGS1(
-	CONST char *,	name)
+PUBLIC char * HTnameOfFile_WWW ARGS3(
+	CONST char *,	name,
+	BOOL,		WWW_prefix,
+	BOOL,		expand_all)
 {
     char * acc_method = HTParse(name, "", PARSE_ACCESS);
     char * host = HTParse(name, "", PARSE_HOST);
     char * path = HTParse(name, "", PARSE_PATH+PARSE_PUNCTUATION);
+    char * home;
+    char * result = NULL;
 
-    HTUnEscape(path);	/* Interpret % signs */
+    if (expand_all)
+    	HTUnEscape(path);		/* Interpret all % signs */
+    else
+	HTUnEscapeSome(path, "/");	/* Interpret % signs for path delims */
 
-    if (0 == strcmp(acc_method, "file")) { /* local file */
-	FREE(acc_method);
+    if (0 == strcmp(acc_method, "file")	/* local file */
+     || !*acc_method) {			/* implicitly local? */
 	if ((0 == strcasecomp(host, HTHostName())) ||
 	    (0 == strcasecomp(host, "localhost")) || !*host) {
-	    FREE(host);
-	    if (TRACE)
-		fprintf(stderr, "Node `%s' means path `%s'\n", name, path);
+	    CTRACE(tfp, "Node `%s' means path `%s'\n", name, path);
 #ifdef DOSPATH
-	    {
-		char *ret_path = NULL;
-		StrAllocCopy(ret_path, HTDOS_name(path));
-		if (TRACE) {
-		    fprintf(stderr, "HTDOS_name changed `%s' to `%s'\n",
-			    path, ret_path);
-		}
-		FREE(path);
-		return(ret_path);
-	    }
+	    StrAllocCopy(result, HTDOS_name(path));
+#else
+#ifdef __EMX__
+	    if (path[0] == '/'
+	     && isalpha(path[1])
+	     && path[2] == ':') /* pesky leading slash */
+		StrAllocCopy(result, path+1);
+	    else
+		StrAllocCopy(result, path);
+	    CTRACE(tfp, "EMX hack changed `%s' to `%s'\n", path, result);
 #else
-	    return(path);
+	    StrAllocCopy(result, path);
+#endif /* __EMX__ */
 #endif /* DOSPATH */
-	} else {
-	    char * result = (char *)malloc(
+	} else if (WWW_prefix) {
+	    result = (char *)malloc(
 				strlen("/Net/")+strlen(host)+strlen(path)+1);
-	      if (result == NULL)
-		  outofmem(__FILE__, "HTLocalName");
+	    if (result == NULL)
+		outofmem(__FILE__, "HTLocalName");
 	    sprintf(result, "%s%s%s", "/Net/", host, path);
-	    FREE(host);
-	    FREE(path);
-	    if (TRACE)
-		fprintf(stderr, "Node `%s' means file `%s'\n", name, result);
-	    return result;
+	    CTRACE(tfp, "Node `%s' means file `%s'\n", name, result);
+	} else {
+	    StrAllocCopy(result, path);
 	}
-    } else {  /* other access */
-	char * result;
+    } else if (WWW_prefix) {  /* other access */
 #ifdef VMS
-	char * home =  getenv("HOME");
-	if (!home)
+	if ((home = getenv("HOME")) == 0)
 	    home = HTCacheRoot;
 	else
 	    home = HTVMS_wwwName(home);
 #else
-	CONST char * home =  (CONST char*)getenv("HOME");
-	if (!home)
+	if ((home = getenv("HOME")) == 0)
 	    home = "/tmp";
 #endif /* VMS */
 	result = (char *)malloc(
@@ -625,11 +618,15 @@ PUBLIC char * HTLocalName ARGS1(
 	if (result == NULL)
 	    outofmem(__FILE__, "HTLocalName");
 	sprintf(result, "%s/WWW/%s/%s%s", home, acc_method, host, path);
-	FREE(path);
-	FREE(acc_method);
-	FREE(host);
-	return result;
+    } else {
+	StrAllocCopy(result, path);
     }
+
+    FREE(host);
+    FREE(path);
+    FREE(acc_method);
+
+    return result;
 }
 
 /*	Make a WWW name from a full local path name.
@@ -663,8 +660,7 @@ PUBLIC char * WWW_nameOfFile ARGS1(
 	    outofmem(__FILE__, "WWW_nameOfFile");
 	sprintf(result, "file://%s%s", HTHostName(), name);
     }
-    if (TRACE)
-	fprintf(stderr, "File `%s'\n\tmeans node `%s'\n", name, result);
+    CTRACE(tfp, "File `%s'\n\tmeans node `%s'\n", name, result);
     return result;
 }
 
@@ -859,17 +855,13 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
     char *cp = NULL, *cp1, *cp2, *cp3 = NULL, *cp4;
     BOOL chartrans_ok = FALSE;
     int chndl = -1;
-    int i;
 
     FREE(anchor->charset);
     StrAllocCopy(cp, format->name);
-    for (i = 0; cp[i]; i++)
-	cp[i] = TOLOWER(cp[i]);
+    LYLowerCase(cp);
     if (((cp1 = strchr(cp, ';')) != NULL) &&
 	(cp2 = strstr(cp1, "charset")) != NULL) {
-	if (TRACE)
-	    fprintf(stderr,
-		    "HTCharsetFormat: Extended MIME Content-Type is %s\n",
+	CTRACE(tfp, "HTCharsetFormat: Extended MIME Content-Type is %s\n",
 		    format->name);
 	cp2 += 7;
 	while (*cp2 == ' ' || *cp2 == '=')
@@ -896,6 +888,12 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
 	    **	Got something but we don't recognize it.
 	    */
 	    chndl = UCLYhndl_for_unrec;
+	    if (chndl < 0)
+	    /*
+	    **  UCLYhndl_for_unrec not defined :-(
+	    **  fallback to UCLYhndl_for_unspec which always valid.
+	    */
+	    chndl = UCLYhndl_for_unspec;  /* always >= 0 */
 	    if (UCCanTranslateFromTo(chndl, current_char_set)) {
 		chartrans_ok = YES;
 		HTAnchor_setUCInfoStage(anchor, chndl,
@@ -940,35 +938,9 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
 		    HTPassEightBitRaw = TRUE;
 		}
 	    } else if (p_out->enc == UCT_ENC_CJK) {
-		if (LYRawMode) {
-		    if ((!strcmp(p_in->MIMEname, "euc-jp") ||
-			 !strcmp(p_in->MIMEname, "shift_jis")) &&
-			(!strcmp(p_out->MIMEname, "euc-jp") ||
-			 !strcmp(p_out->MIMEname, "shift_jis"))) {
-			HTCJK = JAPANESE;
-		    } else if (!strcmp(p_in->MIMEname, "euc-cn") &&
-			       !strcmp(p_out->MIMEname, "euc-cn")) {
-			HTCJK = CHINESE;
-		    } else if (!strcmp(p_in->MIMEname, "big-5") &&
-			       !strcmp(p_out->MIMEname, "big-5")) {
-			HTCJK = TAIPEI;
-		    } else if (!strcmp(p_in->MIMEname, "euc-kr") &&
-			       !strcmp(p_out->MIMEname, "euc-kr")) {
-			HTCJK = KOREAN;
-		    } else {
-			HTCJK = NOCJK;
-		    }
-		} else {
-		    HTCJK = NOCJK;
-		}
+		Set_HTCJK(p_in->MIMEname, p_out->MIMEname);
 	    }
-	/*
-	**  Check for an iso-8859-# we don't know. - FM
-	*/
-	} else if (!strncmp(cp4, "iso-8859-", 9) &&
-		   isdigit((unsigned char)cp4[9]) &&
-		   !strncmp(LYchar_set_names[current_char_set],
-			    "Other ISO Latin", 15)) {
+	} else {
 	    /*
 	    **	Hope it's a match, for now. - FM
 	    */
@@ -1033,9 +1005,8 @@ PUBLIC float HTFileValue ARGS1(
 	suff = (HTSuffix *)HTList_objectAt(HTSuffixes, i);
 	ls = strlen(suff->suffix);
 	if ((ls <= lf) && 0==strcmp(suff->suffix, filename + lf - ls)) {
-	    if (TRACE)
-		fprintf(stderr, "File: Value of %s is %.3f\n",
-				filename, suff->quality);
+	    CTRACE(tfp, "File: Value of %s is %.3f\n",
+			filename, suff->quality);
 	    return suff->quality;		/* OK -- found */
 	}
     }
@@ -1082,11 +1053,7 @@ PUBLIC BOOL HTEditable ARGS1(
 #ifdef NO_GROUPS
     return NO;		/* Safe answer till we find the correct algorithm */
 #else
-#ifdef NeXT
-    int 	groups[NGROUPS];
-#else
-    gid_t	groups[NGROUPS];
-#endif /* NeXT */
+    GETGROUPS_T groups[NGROUPS];
     uid_t	myUid;
     int 	ngroups;			/* The number of groups  */
     struct stat fileStatus;
@@ -1100,14 +1067,16 @@ PUBLIC BOOL HTEditable ARGS1(
 
     if (TRACE) {
 	int i2;
-	fprintf(stderr,
+	fprintf(tfp,
 	    "File mode is 0%o, uid=%d, gid=%d. My uid=%d, %d groups (",
-	    (unsigned int) fileStatus.st_mode, fileStatus.st_uid,
-	    fileStatus.st_gid,
-	    myUid, ngroups);
+	    (unsigned int) fileStatus.st_mode,
+	    (int) fileStatus.st_uid,
+	    (int) fileStatus.st_gid,
+	    (int) myUid,
+	    (int) ngroups);
 	for (i2 = 0; i2 < ngroups; i2++)
-	    fprintf(stderr, " %d", groups[i2]);
-	fprintf(stderr, ")\n");
+	    fprintf(tfp, " %d", (int) groups[i2]);
+	fprintf(tfp, ")\n");
     }
 
     if (fileStatus.st_mode & 0002)		/* I can write anyway? */
@@ -1124,8 +1093,7 @@ PUBLIC BOOL HTEditable ARGS1(
 		return YES;
 	}
     }
-    if (TRACE)
-	fprintf(stderr, "\tFile is not editable.\n");
+    CTRACE(tfp, "\tFile is not editable.\n");
     return NO;					/* If no excuse, can't do */
 #endif /* NO_GROUPS */
 }
@@ -1260,11 +1228,11 @@ PUBLIC BOOL HTDirTitles ARGS3(
       char * printable = NULL;
 
 #ifdef DIRED_SUPPORT
-      if (0 == strncasecomp(path, "/%2F", 4))
-	  StrAllocCopy(printable, (path+1));
-      else
-	  StrAllocCopy(printable, path);
-      if (0 == strncasecomp(printable, "/vmsysu%2b", 10) ||
+      printable = HTfullURL_toFile(
+	    (0 == strncasecomp(path, "/%2F", 4))	/* "//" ? */
+	    ? (path+1)
+	    : path);
+      if (0 == strncasecomp(printable, "/vmsysu:", 8) ||
 	  0 == strncasecomp(printable, "/anonymou.", 10)) {
 	  StrAllocCopy(cp, (printable+1));
 	  StrAllocCopy(printable, cp);
@@ -1272,14 +1240,14 @@ PUBLIC BOOL HTDirTitles ARGS3(
       }
 #else
       StrAllocCopy(printable, (current ? current + 1 : ""));
+      HTUnEscape(printable);
 #endif /* DIRED_SUPPORT */
 
       START(HTML_HEAD);
       PUTS("\n");
-      HTUnEscape(printable);
       START(HTML_TITLE);
-      PUTS(*printable ? printable : "Welcome");
-      PUTS(" directory");
+      PUTS(*printable ? printable : gettext("Welcome"));
+      PUTS(gettext(" directory"));
       END(HTML_TITLE);
       PUTS("\n");
       END(HTML_HEAD);
@@ -1287,13 +1255,13 @@ PUBLIC BOOL HTDirTitles ARGS3(
 
 #ifdef DIRED_SUPPORT
       START(HTML_H2);
-      PUTS(*printable ? "Current directory is " : "");
-      PUTS(*printable ? printable : "Welcome");
+      PUTS(*printable ? gettext("Current directory is ") : "");
+      PUTS(*printable ? printable : gettext("Welcome"));
       END(HTML_H2);
       PUTS("\n");
 #else
       START(HTML_H1);
-      PUTS(*printable ? printable : "Welcome");
+      PUTS(*printable ? printable : gettext("Welcome"));
       END(HTML_H1);
       PUTS("\n");
 #endif /* DIRED_SUPPORT */
@@ -1403,7 +1371,7 @@ PUBLIC BOOL HTDirTitles ARGS3(
 	HTStartAnchor(target, "", relative);
 	FREE(relative);
 
-	PUTS("Up to ");
+	PUTS(gettext("Up to "));
 	if (parent) {
 	    if ((0 == strcmp(current,".")) ||
 		(0 == strcmp(current,".."))) {
@@ -1528,15 +1496,14 @@ PUBLIC int HTLoadFile ARGS4(
     **	to the directories or files listed.
     */
     if (HTStat(filename, &stat_info) == -1) {
-	if (TRACE)
-	    fprintf(stderr, "HTLoadFile: Can't stat %s\n", filename);
+	CTRACE(tfp, "HTLoadFile: Can't stat %s\n", filename);
     } else {
-	if (((stat_info.st_mode) & S_IFMT) == S_IFDIR) {
+	if (S_ISDIR(stat_info.st_mode)) {
 	    if (HTDirAccess == HT_DIR_FORBID) {
 		FREE(filename);
 		FREE(nodename);
 		return HTLoadError(sink, 403,
-		"Directory browsing is not allowed.");
+				   gettext("Directory browsing is not allowed."));
 	    }
 
 	    if (HTDirAccess == HT_DIR_SELECTIVE) {
@@ -1552,7 +1519,7 @@ PUBLIC int HTLoadFile ARGS4(
 		    FREE(filename);
 		    FREE(nodename);
 		    return HTLoadError(sink, 403,
-		    "Selective access is not enabled for this directory");
+				       gettext("Selective access is not enabled for this directory"));
 		}
 	    }
 
@@ -1577,14 +1544,12 @@ PUBLIC int HTLoadFile ARGS4(
 	*/
 	if (!fp) {
 	    char ultrixname[INFINITY];
-	    if (TRACE)
-		fprintf(stderr, "HTLoadFile: Can't open as %s\n", vmsname);
+	    CTRACE(tfp, "HTLoadFile: Can't open as %s\n", vmsname);
 	    sprintf(ultrixname, "%s::\"%s\"", nodename, filename);
 	    fp = fopen(ultrixname, "r", "shr=put", "shr=upd");
 	    if (!fp) {
-		if (TRACE)
-		    fprintf(stderr, "HTLoadFile: Can't open as %s\n",
-				    ultrixname);
+		CTRACE(tfp, "HTLoadFile: Can't open as %s\n",
+			    ultrixname);
 	    }
 	}
 	if (fp) {
@@ -1624,9 +1589,7 @@ PUBLIC int HTLoadFile ARGS4(
 			*semicolon = ';';
 		    gzfp = gzopen(vmsname, "rb");
 
-		    if (TRACE)
-			fprintf(stderr,
-				"HTLoadFile: gzopen of `%s' gives %p\n",
+		    CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 				vmsname, (void*)gzfp);
 		    use_gzread = YES;
 		} else
@@ -1672,9 +1635,7 @@ PUBLIC int HTLoadFile ARGS4(
 				*semicolon = ';';
 			    gzfp = gzopen(vmsname, "rb");
 
-			    if (TRACE)
-				fprintf(stderr,
-				       "HTLoadFile: gzopen of `%s' gives %p\n",
+			    CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 					vmsname, (void*)gzfp);
 			    use_gzread = YES;
 			}
@@ -1717,7 +1678,7 @@ PUBLIC int HTLoadFile ARGS4(
 		} else {
 		    status = HTLoadError(NULL,
 					 -(HT_ERROR),
-					 "Could not open file for decompression!");
+					 gettext("Could not open file for decompression!"));
 		}
 	    } else
 #endif /* USE_ZLIB */
@@ -1757,7 +1718,7 @@ PUBLIC int HTLoadFile ARGS4(
 	if ((strlen(localname) > strlen(MULTI_SUFFIX)) &&
 	    (0 == strcmp(localname + strlen(localname) - strlen(MULTI_SUFFIX),
 			 MULTI_SUFFIX))) {
-	    DIR *dp;
+	    DIR *dp = 0;
 	    BOOL forget_multi = NO;
 
 	    STRUCT_DIRENT * dirbuf;
@@ -1782,7 +1743,7 @@ PUBLIC int HTLoadFile ARGS4(
 		FREE(localname);
 		FREE(nodename);
 		return HTLoadError(sink, 500,
-			"Multiformat: directory scan failed.");
+				   gettext("Multiformat: directory scan failed."));
 	    }
 
 	    while ((dirbuf = readdir(dp)) != NULL) {
@@ -1847,9 +1808,7 @@ PUBLIC int HTLoadFile ARGS4(
 			}
 		    }
 		    if (value != NO_VALUE_FOUND) {
-			if (TRACE)
-			    fprintf(stderr,
-				 "HTLoadFile: value of presenting %s is %f\n",
+			CTRACE(tfp, "HTLoadFile: value of presenting %s is %f\n",
 				    HTAtom_name(rep), value);
 			if  (value > best) {
 			    best_rep = rep;
@@ -1874,7 +1833,7 @@ PUBLIC int HTLoadFile ARGS4(
 		FREE(localname);
 		FREE(nodename);
 		return HTLoadError(sink, 403,	/* List formats? */
-		   "Could not find suitable representation for transmission.");
+				   gettext("Could not find suitable representation for transmission."));
 	    }
 	    /*NOTREACHED*/
 	} /* if multi suffix */
@@ -1895,8 +1854,7 @@ PUBLIC int HTLoadFile ARGS4(
 #endif
 	{
 				       /* if can't read file information */
-	    if (TRACE)
-		fprintf(stderr, "HTLoadFile: can't stat %s\n", localname);
+	    CTRACE(tfp, "HTLoadFile: can't stat %s\n", localname);
 
 	}  else {		/* Stat was OK */
 
@@ -1904,7 +1862,7 @@ PUBLIC int HTLoadFile ARGS4(
 	    if (stat(localname,&dir_info) == -1) dir_info.st_mode = S_IFDIR;
 #endif
 
-	    if (((dir_info.st_mode) & S_IFMT) == S_IFDIR) {
+	    if (S_ISDIR(dir_info.st_mode)) {
 		/*
 		**  If localname is a directory.
 		*/
@@ -1920,8 +1878,7 @@ PUBLIC int HTLoadFile ARGS4(
 		BOOL need_parent_link = FALSE;
 		struct stat file_info;
 
-		if (TRACE)
-		    fprintf(stderr, "%s is a directory\n", localname);
+		CTRACE(tfp, "%s is a directory\n", localname);
 
 		/*
 		**  Check directory access.
@@ -1932,7 +1889,7 @@ PUBLIC int HTLoadFile ARGS4(
 		    FREE(localname);
 		    FREE(nodename);
 		    return HTLoadError(sink, 403,
-		    "Directory browsing is not allowed.");
+				       gettext("Directory browsing is not allowed."));
 		}
 
 
@@ -1949,7 +1906,7 @@ PUBLIC int HTLoadFile ARGS4(
 			FREE(localname);
 			FREE(nodename);
 			return HTLoadError(sink, 403,
-			"Selective access is not enabled for this directory");
+					   gettext("Selective access is not enabled for this directory"));
 		    }
 		}
 
@@ -1958,7 +1915,7 @@ PUBLIC int HTLoadFile ARGS4(
 		    FREE(localname);
 		    FREE(nodename);
 		    return HTLoadError(sink, 403,
-				       "This directory is not readable.");
+				       gettext("This directory is not readable."));
 		}
 
 		/*
@@ -2067,13 +2024,14 @@ PUBLIC int HTLoadFile ARGS4(
 
 			StrAllocCat(tmpfilename, dirbuf->d_name);
 			stat(tmpfilename, &file_info);
-			if (((file_info.st_mode) & S_IFMT) == S_IFDIR)
+			if (S_ISDIR(file_info.st_mode))
 #ifndef DIRED_SUPPORT
 			    sprintf((char *)dirname, "D%s",dirbuf->d_name);
 			else
 			    sprintf((char *)dirname, "F%s",dirbuf->d_name);
 			    /* D & F to have first directories, then files */
 #else
+			{
 			    if (dir_list_style == MIXED_STYLE)
 				sprintf((char *)dirname,
 					" %s/", dirbuf->d_name);
@@ -2083,6 +2041,7 @@ PUBLIC int HTLoadFile ARGS4(
 			    else
 				sprintf((char *)dirname,
 					"D%s", dirbuf->d_name);
+			}
 			else if (dir_list_style == MIXED_STYLE)
 			    sprintf((char *)dirname, " %s", dirbuf->d_name);
 			else if (dir_list_style == FILES_FIRST)
@@ -2156,8 +2115,9 @@ PUBLIC int HTLoadFile ARGS4(
 				    START(HTML_H2);
 				    if (dir_list_style != MIXED_STYLE) {
 				       START(HTML_EM);
-				       PUTS(state == 'D' ?
-					  "Subdirectories:" : "Files:");
+				       PUTS(state == 'D'
+				          ? gettext("Subdirectories:")
+					  : gettext("Files:"));
 				       END(HTML_EM);
 				    }
 				    END(HTML_H2);
@@ -2177,8 +2137,9 @@ PUBLIC int HTLoadFile ARGS4(
 				       == 'D' ? 'D' : 'F');
 				    START(HTML_H2);
 				    START(HTML_EM);
-				    PUTS(state == 'D' ?
-				    "Subdirectories:" : "Files:");
+				    PUTS(state == 'D'
+				        ? gettext("Subdirectories:")
+					: gettext("Files:"));
 				    END(HTML_EM);
 				    END(HTML_H2);
 #ifndef LONG_LIST
@@ -2213,7 +2174,7 @@ PUBLIC int HTLoadFile ARGS4(
 			}
 			if (state == 'I') {
 			    START(HTML_P);
-			    PUTS("Empty Directory");
+			    PUTS(gettext("Empty Directory"));
 			}
 #ifndef LONG_LIST
 			else
@@ -2245,8 +2206,7 @@ PUBLIC int HTLoadFile ARGS4(
 	{
 	    FILE * fp = fopen(localname, "r");
 
-	    if (TRACE)
-		fprintf (stderr, "HTLoadFile: Opening `%s' gives %p\n",
+	    CTRACE (tfp, "HTLoadFile: Opening `%s' gives %p\n",
 				 localname, (void*)fp);
 	    if (fp) {		/* Good! */
 		int len;
@@ -2275,9 +2235,7 @@ PUBLIC int HTLoadFile ARGS4(
 			fclose(fp);
 			gzfp = gzopen(localname, "rb");
 
-			if (TRACE)
-			    fprintf(stderr,
-				    "HTLoadFile: gzopen of `%s' gives %p\n",
+			CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 				    localname, (void*)gzfp);
 			use_gzread = YES;
 		    } else
@@ -2316,9 +2274,7 @@ PUBLIC int HTLoadFile ARGS4(
 			    fclose(fp);
 			    gzfp = gzopen(localname, "rb");
 
-			    if (TRACE)
-				fprintf(stderr,
-				       "HTLoadFile: gzopen of `%s' gives %p\n",
+			    CTRACE(tfp, "HTLoadFile: gzopen of `%s' gives %p\n",
 					localname, (void*)gzfp);
 			    use_gzread = YES;
 			}
@@ -2358,7 +2314,7 @@ PUBLIC int HTLoadFile ARGS4(
 		    } else {
 			status = HTLoadError(NULL,
 					     -(HT_ERROR),
-				     "Could not open file for decompression!");
+					     gettext("Could not open file for decompression!"));
 		    }
 		} else
 #endif /* USE_ZLIB */
@@ -2405,10 +2361,9 @@ PUBLIC int HTLoadFile ARGS4(
     **	All attempts have failed.
     */
     {
-	if (TRACE)
-	    fprintf(stderr, "Can't open `%s', errno=%d\n", addr, SOCKET_ERRNO);
+	CTRACE(tfp, "Can't open `%s', errno=%d\n", addr, SOCKET_ERRNO);
 
-	return HTLoadError(sink, 403, "Can't access requested file.");
+	return HTLoadError(sink, 403, gettext("Can't access requested file."));
     }
 }
 
93 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 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
236
237
238
239