about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>1999-06-18 23:15:18 -0400
committerThomas E. Dickey <dickey@invisible-island.net>1999-06-18 23:15:18 -0400
commit5be99e2ee1a17028574fcbd90b9ba2c09555585e (patch)
tree1bfb6d74bcc359caef514b87d4fa3efef62dfe97 /WWW/Library/Implementation
parentc7bfda903760e4bd0d0d8327560f6dee5e1dc059 (diff)
downloadlynx-snapshots-5be99e2ee1a17028574fcbd90b9ba2c09555585e.tar.gz
snapshot of project "lynx", label v2-8-3dev_2
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTAccess.c4
-rw-r--r--WWW/Library/Implementation/HTAnchor.c21
-rw-r--r--WWW/Library/Implementation/HTAnchor.h7
-rw-r--r--WWW/Library/Implementation/HTFWriter.c2
-rw-r--r--WWW/Library/Implementation/HTFile.c2
-rw-r--r--WWW/Library/Implementation/HTFormat.c4
-rw-r--r--WWW/Library/Implementation/HTString.c62
-rw-r--r--WWW/Library/Implementation/HTString.h12
-rw-r--r--WWW/Library/Implementation/HTTCP.c4
-rw-r--r--WWW/Library/Implementation/HTTP.c9
-rw-r--r--WWW/Library/Implementation/HTTelnet.c2
-rw-r--r--WWW/Library/Implementation/tcp.h18
12 files changed, 127 insertions, 20 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index 11dfc5ae..c5f8ef06 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -1356,7 +1356,7 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS
 	    StrAllocCopy(my_home_document, REMOTE_ADDRESS);
     }
 
-#ifdef unix
+#ifdef UNIX
     if (my_home_document == NULL) {
 	FILE * fp = NULL;
 	CONST char * home =  (CONST char*)getenv("HOME");
@@ -1377,7 +1377,7 @@ PUBLIC HTParentAnchor * HTHomeAnchor NOARGS
 	    FREE(my_home_document);
 	}
     }
-#endif /* unix */
+#endif /* UNIX */
     ref = HTParse((my_home_document ?
 		   my_home_document : (HTClientHost ?
 				     REMOTE_ADDRESS : LAST_RESORT)),
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 22af2bfb..ba131155 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -21,6 +21,7 @@
 #include <UCAux.h>
 #include <UCMap.h>
 
+#include <LYUtils.h>
 #include <LYCharSets.h>
 #include <LYLeaks.h>
 
@@ -75,6 +76,10 @@ PRIVATE HTParentAnchor * HTParentAnchor_new NOARGS
     newAnchor->isISMAPScript = FALSE;	/* Lynx appends ?0,0 if TRUE. - FM */
     newAnchor->isHEAD = FALSE;		/* HEAD request if TRUE. - FM */
     newAnchor->safe = FALSE;		/* Safe. - FM */
+#ifdef SOURCE_CACHE
+    newAnchor->source_cache_file = NULL;
+    newAnchor->source_cache_chunk = NULL;
+#endif
     newAnchor->FileCache = NULL;	/* Path to a disk-cached copy. - FM */
     newAnchor->SugFname = NULL; 	/* Suggested filename. - FM */
     newAnchor->RevTitle = NULL; 	/* TITLE for a LINK with REV. - FM */
@@ -689,6 +694,22 @@ PUBLIC BOOL HTAnchor_delete ARGS1(
     FREE(me->bookmark);
     FREE(me->owner);
     FREE(me->RevTitle);
+#ifdef SOURCE_CACHE
+    /*
+     * Clean up the source cache, if any.
+     */
+    if (me->source_cache_file) {
+	CTRACE(tfp, "Removing source cache file %s\n",
+	       me->source_cache_file);
+	LYRemoveTemp(me->source_cache_file);
+	FREE(me->source_cache_file);
+    }
+    if (me->source_cache_chunk) {
+	CTRACE(tfp, "Removing memory source cache %p\n",
+	       (void *)me->source_cache_chunk);
+	HTChunkFree(me->source_cache_chunk);
+    }
+#endif
     if (me->FileCache) {
 	FILE *fd;
 	if ((fd = fopen(me->FileCache, "r")) != NULL) {
diff --git a/WWW/Library/Implementation/HTAnchor.h b/WWW/Library/Implementation/HTAnchor.h
index cb47e52e..ee0dcfef 100644
--- a/WWW/Library/Implementation/HTAnchor.h
+++ b/WWW/Library/Implementation/HTAnchor.h
@@ -15,6 +15,7 @@
 /* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independent */
 
 #include <HTList.h>
+#include <HTChunk.h>
 #include <HTAtom.h>
 #include <UCDefs.h>
 
@@ -77,7 +78,11 @@ struct _HTParentAnchor {
   BOOL		isISMAPScript;	/* Script for clickable image map */
   BOOL		isHEAD;		/* Document is headers from a HEAD request */
   BOOL		safe;			/* Safe */
-  char *	FileCache;	/* Path to a disk-cached copy */
+#ifdef SOURCE_CACHE
+  char *	source_cache_file;
+  HTChunk *	source_cache_chunk;
+#endif
+  char *	FileCache;	/* Path to a disk-cached copy (see src/HTFWriter.c) */
   char *	SugFname;	/* Suggested filename */
   char *	cache_control;	/* Cache-Control */
   BOOL		no_cache;	/* Cache-Control, Pragma or META "no-cache"? */
diff --git a/WWW/Library/Implementation/HTFWriter.c b/WWW/Library/Implementation/HTFWriter.c
index 943e1a22..b101e95c 100644
--- a/WWW/Library/Implementation/HTFWriter.c
+++ b/WWW/Library/Implementation/HTFWriter.c
@@ -223,7 +223,7 @@ PUBLIC HTStream* HTSaveAndExecute ARGS3(
 	HTParentAnchor *,	anchor,	/* Not used */
 	HTStream *,		sink)	/* Not used */
 
-#ifdef unix
+#ifdef UNIX
 #define REMOVE_COMMAND "/bin/rm -f %s\n"
 #endif
 #ifdef VMS
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index f0b294e7..f8280243 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1643,7 +1643,7 @@ PRIVATE int print_local_dir ARGS5(
 	if (status != HT_PARTIAL_CONTENT)
 	    _HTProgress (gettext("OK"));
 	else
-	    CTRACE(tfp, "Reading the directory interrupred by user\n");
+	    CTRACE(tfp, "Reading the directory interrupted by user\n");
 
 
 	/*
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index f214b536..a45d7d0c 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -20,14 +20,14 @@ PUBLIC float HTMaxSecs = 1e10;		/* No effective limit */
 PUBLIC float HTMaxLength = 1e10;	/* No effective limit */
 PUBLIC long int HTMaxBytes  = 0;	/* No effective limit */
 
-#ifdef unix
+#ifdef UNIX
 #ifdef NeXT
 #define PRESENT_POSTSCRIPT "open %s; /bin/rm -f %s\n"
 #else
 #define PRESENT_POSTSCRIPT "(ghostview %s ; /bin/rm -f %s)&\n"
 			   /* Full pathname would be better! */
 #endif /* NeXT */
-#endif /* unix */
+#endif /* UNIX */
 
 #include <HTML.h>
 #include <HTMLDTD.h>
diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c
index 90b6665b..039c0e64 100644
--- a/WWW/Library/Implementation/HTString.c
+++ b/WWW/Library/Implementation/HTString.c
@@ -890,3 +890,65 @@ PUBLIC void HTEndParam ARGS3(
     }
     CTRACE(tfp, "PARAM-END:%s\n", *result);
 }
+
+
+#ifdef EXP_FILE_UPLOAD
+/*	bstring Allocate and Concatenate
+*/
+
+/*	Allocate a new copy of a bstring, and returns it
+*/
+PUBLIC void HTSABCopy ARGS3(
+	bstring**,	dest,
+	CONST char *,	src,
+	int,		len)
+{
+    bstring *t;
+    CTRACE(tfp, "HTSABCopy(%p, %p, %d)\n", dest, src, len);
+    /* if we already have a bstring ** ... */
+    if (dest) {
+    	/* ... with a valid bstring *, free it ... */
+    	if (*dest) {
+	    FREE((*dest)->str);
+	    FREE(*dest);
+    	}
+	*dest = malloc(sizeof(bstring));
+	if (src) {
+	    CTRACE(tfp, "%% [%s]\n", src);
+	    t = (bstring*) malloc(sizeof(bstring));
+	    if (t == NULL)
+		outofmem(__FILE__, "HTSABCopy");
+	    t->str = (char *) malloc (len);
+	    if (t->str == NULL)
+		outofmem(__FILE__, "HTSABCopy");
+	    memcpy (t->str, src, len);
+	    t->len = len;
+	    *dest = t;
+	}
+    }
+}
+
+PUBLIC void HTSABCat ARGS3(
+	bstring **,	dest,
+	CONST char *,	src,
+	int,		len)
+{
+    bstring *t = *dest;
+    if (src) {
+	if (t) {
+	    int length = t->len;
+	    t->str = (char *)realloc(t->str, length + len);
+	} else {
+	    t = (bstring *)calloc(1, sizeof(*t));
+	    if (t == NULL)
+		outofmem(__FILE__, "HTSACat");
+	    t->str = (char *)malloc(len);
+	}
+	if (t->str == NULL)
+	    outofmem(__FILE__, "HTSACat");
+	memcpy (t->str + t->len, src, len);
+	t->len += len;
+	*dest = t;
+    }
+}
+#endif /* EXP_FILE_UPLOAD */
diff --git a/WWW/Library/Implementation/HTString.h b/WWW/Library/Implementation/HTString.h
index 2891b295..3190b88a 100644
--- a/WWW/Library/Implementation/HTString.h
+++ b/WWW/Library/Implementation/HTString.h
@@ -102,4 +102,16 @@ extern void HTEndParam PARAMS((char ** result, CONST char * command, int number)
 /* Force an option, with leading blanks, to be appended without quoting them */
 #define HTOptParam(result, command, number, parameter) HTSACat(result, parameter)
 
+/* Binary copy and concat */
+#ifdef EXP_FILE_UPLOAD
+
+typedef struct {
+	char *str;
+	int len;
+} bstring;
+
+extern void HTSABCopy PARAMS((bstring** dest, CONST char * src, int len));
+extern void HTSABCat PARAMS((bstring ** dest, CONST char * src, int len));
+#endif
+
 #endif /* HTSTRING_H */
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index fdc6b66a..a0f6948a 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -576,8 +576,10 @@ PRIVATE size_t fill_rehostent ARGS3(
 #define h_errno my_errno
 static int my_errno;
 #else /* we do HAVE_H_ERRNO: */
+#ifndef h_errno		/* there may be a macro as well as the extern data */
 extern int h_errno;
 #endif
+#endif
 
 /*	Resolve an internet hostname, like gethostbyname
 **	------------------------------------------------
@@ -1173,7 +1175,7 @@ PUBLIC int HTParseInet ARGS2(
     if ((port = strchr(host, ':')) != NULL) {
 	*port++ = 0;		/* Chop off port */
 	if (port[0] >= '0' && port[0] <= '9') {
-#ifdef unix
+#ifdef UNIX
 	    soc_in->sin_port = htons(atol(port));
 #else /* VMS: */
 #ifdef DECNET
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 05b3e89c..ab5b3bc7 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -185,6 +185,11 @@ try_again:
       goto done;
   }
 
+/* *sob*  All this needs to be converted to handle binary strings
+ * if we're going to be able to handle binary form uploads...
+ * This is a nice long function as well.  *sigh*  -RJP
+ */
+
   /*	Ask that node for the document,
   **	omitting the host name & anchor
   */
@@ -583,6 +588,10 @@ try_again:
 	if (!anAnchor->post_data)
 	  content_length = 0;
 	else
+/* 
+ * Ack!  This assumes non-binary data!  Icky!  
+ * 
+ */
 	  content_length = strlen (anAnchor->post_data);
 	sprintf (line, "Content-length: %d%c%c",
 		 content_length, CR, LF);
diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c
index 2d7f162b..43f148d3 100644
--- a/WWW/Library/Implementation/HTTelnet.c
+++ b/WWW/Library/Implementation/HTTelnet.c
@@ -166,7 +166,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
 #endif
 
 /* Most unix machines suppport username only with rlogin */
-#if defined(unix) || defined(DOSPATH)
+#if defined(UNIX) || defined(DOSPATH)
 #ifndef TELNET_DONE
 
 #define FMT_RLOGIN "%s %s%s%s"
diff --git a/WWW/Library/Implementation/tcp.h b/WWW/Library/Implementation/tcp.h
index c9d05dfa..fe977bca 100644
--- a/WWW/Library/Implementation/tcp.h
+++ b/WWW/Library/Implementation/tcp.h
@@ -49,9 +49,9 @@ Default values
 #define SELECT                  /* Can handle >1 channel.               */
 #define GOT_SYSTEM              /* Can call shell with string           */
 
-#ifdef unix
+#ifdef UNIX
 #define GOT_PIPE
-#endif /* unix */
+#endif /* UNIX */
 
 #define INVSOC (-1)             /* Unix invalid socket */
 		/* NB: newer libwww has something different for Windows */
@@ -101,10 +101,6 @@ typedef struct sockaddr_in SockA;  /* See netinet/in.h */
 #define AIX
 #endif /* _AIX */
 
-#if defined(AIX) && !defined(unix)
-#define unix
-#endif /* AIX */
-
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #else
@@ -513,7 +509,11 @@ struct timeval {
 #include <sys/filio.h>
 #endif /* HAVE_SYS_FILIO_H */
 
-#ifdef DECL_ERRNO
+#if !defined(HAVE_LSTAT) && !defined(lstat)
+#define lstat(path,block) stat(path,block)
+#endif
+
+#if defined(DECL_ERRNO) && !defined(errno)
 extern int errno;
 #endif /* DECL_ERRNO */
 
@@ -598,10 +598,6 @@ typedef int pid_t;
 
 /*	Directory reading stuff - BSD or SYS V
 */
-#if defined(UNIX) && !defined(unix)
-#define unix
-#endif /* UNIX && !unix */
-
 #ifdef HAVE_CONFIG_H
 
 # ifdef HAVE_LIMITS_H