about summary refs log tree commit diff stats
path: root/WWW
diff options
context:
space:
mode:
Diffstat (limited to 'WWW')
-rw-r--r--WWW/Library/Implementation/HTAccess.c2
-rw-r--r--WWW/Library/Implementation/HTBTree.c3
-rw-r--r--WWW/Library/Implementation/HTFile.c57
-rw-r--r--WWW/Library/Implementation/HTFile.h7
-rw-r--r--WWW/Library/Implementation/HTUtils.h37
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.c2
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.h4
7 files changed, 65 insertions, 47 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 786c9619..962407da 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -1057,7 +1057,7 @@ PRIVATE BOOL HTLoadDocument ARGS4(
 	fprintf(stderr,
  gettext("**** HTAccess: Internal software error.  Please mail lynx-dev@sig.net!\n"));
 	fprintf(stderr, gettext("**** HTAccess: Status returned was: %d\n"),status);
-	exit(-1);
+	exit(EXIT_FAILURE);
     }
 
     /* Failure in accessing a document */
diff --git a/WWW/Library/Implementation/HTBTree.c b/WWW/Library/Implementation/HTBTree.c
index c545eb0e..db3b50db 100644
--- a/WWW/Library/Implementation/HTBTree.c
+++ b/WWW/Library/Implementation/HTBTree.c
@@ -9,9 +9,6 @@
 
 #include <HTUtils.h>
 #include <HTBTree.h>
-#ifndef __STRICT_BSD__
-#include <stdlib.h>
-#endif
 
 #define MAXIMUM(a,b) ((a)>(b)?(a):(b))
 
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 41627cdb..3e990097 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -138,11 +138,6 @@ PRIVATE HTSuffix no_suffix = { "*", NULL, NULL, NULL, 1.0 };
 PRIVATE HTSuffix unknown_suffix = { "*.*", NULL, NULL, NULL, 1.0};
 
 
-#ifdef _WINDOWS
-#define exists(p)	(access(p,0)==0)
-#endif
-
-
 /*	To free up the suffixes at program exit.
 **	----------------------------------------
 */
@@ -233,13 +228,8 @@ PRIVATE void LYListFmtParse ARGS5(
 #define PTBIT(a, s)  PBIT(a, 0, 0)
 #endif
 
-#ifdef _WINDOWS
-	if (stat(file, &st) < 0)
-		fmtstr = "    %a";	/* can't stat so just do anchor */
-#else
 	if (lstat(file, &st) < 0)
 		fmtstr = "    %a";	/* can't stat so just do anchor */
-#endif
 
 	StrAllocCopy(str, fmtstr);
 	s = str;
@@ -1995,7 +1985,6 @@ PRIVATE int print_local_dir ARGS5(
 	    }
 	} /* end printing out the tree in order */
 
-	closedir(dp);
 	FREE(logical);
 	FREE(tmpfilename);
 	FREE(tail);
@@ -2015,6 +2004,40 @@ PRIVATE int print_local_dir ARGS5(
 #endif /* HAVE_READDIR */
 
 
+#ifndef VMS
+PUBLIC int HTStat ARGS2(
+	CONST char *,	filename,
+	struct stat *,	data)
+{
+    int result = -1;
+    char *temp_name = NULL;
+    size_t len = strlen(filename);
+
+    if (len != 0 && LYIsPathSep(filename[len-1])) {
+	HTSprintf0(&temp_name, "%s.", filename);
+    } else {
+	temp_name = (char *)filename;
+    }
+#ifdef _WINDOWS
+    /*
+     * Someone claims that stat() doesn't give the proper result for a
+     * directory on Windows.
+     */
+    if (access(temp_name, 0) == 0) {
+	if (stat(temp_name, data) == -1) data->st_mode = S_IFDIR;
+	return 0;
+    }
+    return -1;
+#else
+    return stat(temp_name, data);
+#endif
+
+    if (temp_name != filename) {
+	FREE(temp_name);
+    }
+    return result;
+}
+#endif
 
 /*	Load a document.
 **	----------------
@@ -2465,21 +2488,13 @@ PUBLIC int HTLoadFile ARGS4(
 	**  will hold the directory entry, and a type 'DIR' which is used
 	**  to point to the current directory being read.
 	*/
-#ifdef _WINDOWS
-	if (!exists(localname))
-#else
-	if (stat(localname,&dir_info) == -1)	   /* get file information */
-#endif
+	if (HTStat(localname,&dir_info) == -1)	   /* get file information */
 	{
 				/* if can't read file information */
 	    CTRACE((tfp, "HTLoadFile: can't stat %s\n", localname));
 
 	}  else {		/* Stat was OK */
 
-#ifdef _WINDOWS
-	    if (stat(localname,&dir_info) == -1) dir_info.st_mode = S_IFDIR;
-#endif
-
 	    if (S_ISDIR(dir_info.st_mode)) {
 		/*
 		**  If localname is a directory.
@@ -2500,7 +2515,6 @@ PUBLIC int HTLoadFile ARGS4(
 		    return HTLoadError(sink, 403, DISALLOWED_DIR_SCAN);
 		}
 
-
 		if (HTDirAccess == HT_DIR_SELECTIVE) {
 		    char * enable_file_name = NULL;
 
@@ -2527,6 +2541,7 @@ PUBLIC int HTLoadFile ARGS4(
 
 		status = print_local_dir(dp, localname,
 					anchor, format_out, sink);
+		closedir(dp);
 		FREE(localname);
 		FREE(nodename);
 		return status;	/* document loaded, maybe partial */
diff --git a/WWW/Library/Implementation/HTFile.h b/WWW/Library/Implementation/HTFile.h
index f0a3178a..edee6ded 100644
--- a/WWW/Library/Implementation/HTFile.h
+++ b/WWW/Library/Implementation/HTFile.h
@@ -72,6 +72,13 @@ extern BOOL HTDirTitles PARAMS((
         HTAnchor *      anchor,
 	BOOL		tildeIsTop));
 
+/*
+**	Check existence.
+*/
+extern int HTStat PARAMS((
+	CONST char *	filename,
+	struct stat *	data));
+
 /*	Load a document.
 **	----------------
 */
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index aaef1923..036ed2fd 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -48,6 +48,10 @@
 #define HAVE_STDARG_H 1
 #endif
 
+#if defined(VMS) || defined(_WINDOWS)
+#define HAVE_STDLIB_H 1
+#endif
+
 /* Accommodate non-autoconf'd Makefile's (VMS, DJGPP, etc) */
 
 #ifndef NO_ARPA_INET_H
@@ -142,14 +146,6 @@ typedef unsigned short mode_t;
 
 #endif /* _WINDOWS */
 
-#ifdef __EMX__
-#include <unistd.h> /* should be re-include protected under EMX */
-#include <stdlib.h> /* should be re-include protected under EMX */
-#define getcwd _getcwd2
-#define chdir _chdir2
-
-#endif
-
 #ifndef USE_COLOR_STYLE
     /* it's useless for such setup */
 #  define NO_EMPTY_HREFLESS_A
@@ -186,9 +182,23 @@ typedef void * HTError;                 /* Unused at present -- best definition?
 Standard C library for malloc() etc
 
  */
-#ifdef DGUX
+#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif /* DGUX */
+#endif
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+#ifdef __EMX__
+#include <unistd.h> /* should be re-include protected under EMX */
+#define getcwd _getcwd2
+#define chdir _chdir2
+#endif
 
 #ifdef vax
 #ifdef unix
@@ -202,22 +212,15 @@ Standard C library for malloc() etc
 #ifdef NeXT
 #include <libc.h>       /* NeXT */
 #endif /* NeXT */
-#ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */
-#ifndef __STRICT_BSD__
-#include <stdlib.h>
-#endif /* !__STRICT_BSD__ */
-#endif /* !MACH */
 
 #else /* ultrix: */
 
 #include <malloc.h>
 #include <memory.h>
-#include <stdlib.h>   /* ANSI */   /* BSN */
 
 #endif /* !ultrix */
 #else   /* VMS: */
 
-#include <stdlib.h>
 #include <unixlib.h>
 #if defined(VAXC) && !defined(__DECC)
 #define malloc	VAXC$MALLOC_OPT
diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c
index f4209ce2..a83bdce3 100644
--- a/WWW/Library/Implementation/HTVMSUtils.c
+++ b/WWW/Library/Implementation/HTVMSUtils.c
@@ -364,7 +364,7 @@ static char *Name;
       }
    }
 
-   /* try in case a file on toplevel directory or .DIR was alreadyt specified */
+   /* try in case a file on toplevel directory or .DIR was already specified */
    Result = stat(Name,info);
    if (Result == 0)
       return(Result);
diff --git a/WWW/Library/Implementation/HTVMSUtils.h b/WWW/Library/Implementation/HTVMSUtils.h
index 6eb55ca6..2720125e 100644
--- a/WWW/Library/Implementation/HTVMSUtils.h
+++ b/WWW/Library/Implementation/HTVMSUtils.h
@@ -89,10 +89,6 @@ PUBLIC BOOL HTVMS_checkAccess PARAMS((
 PUBLIC char * HTVMS_wwwName PARAMS((
 	CONST char *	vmsname));
 
-PUBLIC int HTStat PARAMS((
-	CONST char * filename,
-        struct stat * info));
-
 PUBLIC int HTVMSBrowseDir PARAMS((
 	CONST char * address,
 	HTParentAnchor * anchor,