about summary refs log tree commit diff stats
path: root/WWW/Library
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library')
-rw-r--r--WWW/Library/Implementation/HTFile.c9
-rw-r--r--WWW/Library/Implementation/HTFormat.c51
-rw-r--r--WWW/Library/Implementation/HTMIME.c7
-rw-r--r--WWW/Library/Implementation/HTStyle.h2
-rw-r--r--WWW/Library/Implementation/HTTCP.c51
-rw-r--r--WWW/Library/Implementation/HTTP.c16
6 files changed, 104 insertions, 32 deletions
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 60c71e9a..99f0cc41 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -446,6 +446,8 @@ PRIVATE void do_readme ARGS2(HTStructured *, target, CONST char *, localname)
     FILE * fp;
     char * readme_file_name = 
 	malloc(strlen(localname)+ 1 + strlen(HT_DIR_README_FILE) + 1);
+    if (readme_file_name == NULL)
+        outofmem(__FILE__, "do_readme");
     strcpy(readme_file_name, localname);
     strcat(readme_file_name, "/");
     strcat(readme_file_name, HT_DIR_README_FILE);
@@ -1413,6 +1415,7 @@ PUBLIC int HTLoadFile ARGS4(
     char * nodename = NULL;
     char * newname = NULL;	/* Simplified name of file */
     HTAtom * encoding;		/* @@ not used yet */
+    int status;
 #ifdef VMS
     struct stat stat_info;
 #else
@@ -1489,6 +1492,8 @@ PUBLIC int HTLoadFile ARGS4(
 		char * enable_file_name = 
 		    malloc(strlen(filename)+ 1 +
 		    strlen(HT_DIR_ENABLE_FILE) + 1);
+		if (enable_file_name == NULL)
+		    outofmem(__FILE__, "HTLoadFile");
 		strcpy(enable_file_name, filename);
 		strcat(enable_file_name, "/");
 		strcat(enable_file_name, HT_DIR_ENABLE_FILE);
@@ -1593,7 +1598,7 @@ PUBLIC int HTLoadFile ARGS4(
 	    FREE(nodename);
 	    status = HTParseFile(format, format_out, anchor, fp, sink);
 	    fclose(fp);
-            return status;
+	    return status;
         }  /* If successfull open */
 	FREE(filename);
     }
@@ -1756,6 +1761,8 @@ forget_multi:
 		    char * enable_file_name = 
 			malloc(strlen(localname)+ 1 +
 				      strlen(HT_DIR_ENABLE_FILE) + 1);
+		    if (enable_file_name == NULL)
+			outofmem(__FILE__, "HTLoadFile");
 		    strcpy(enable_file_name, localname);
 		    strcat(enable_file_name, "/");
 		    strcat(enable_file_name, HT_DIR_ENABLE_FILE);
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index 527ae13c..c8bda5de 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -13,6 +13,7 @@
 
 #include "HTUtils.h"
 #include "tcp.h"
+#include "HTAccess.h"
 
 /* Implements:
 */
@@ -589,9 +590,9 @@ PUBLIC int HTFileCopy ARGS2(
 	FILE *,			fp,
 	HTStream*,		sink)
 {
-    HTStreamClass targetClass;
+    HTStreamClass targetClass;    
     char line[256];
-    int bytes = 0, nreads = 0, nprogr = 0;
+    int status, bytes = 0, nreads = 0, nprogr = 0;
     int rv = HT_OK;
     
     /*  Push the data down the stream
@@ -601,9 +602,8 @@ PUBLIC int HTFileCopy ARGS2(
     /*	Push binary from socket down sink
     */
     for (;;) {
-	int status = fread(input_buffer, 1, INPUT_BUFFER_SIZE, fp);
-	nreads ++;
-
+	status = fread(input_buffer, 1, INPUT_BUFFER_SIZE, fp);
+	nreads++;
 	if (status == 0) { /* EOF or error */
 	    if (ferror(fp) == 0) {
 		rv = HT_LOADED;
@@ -613,7 +613,11 @@ PUBLIC int HTFileCopy ARGS2(
 	        fprintf(stderr,
 			"HTFormat: Read error, read returns %d\n",
 			ferror(fp));
-	    rv = HT_PARTIAL_CONTENT;
+	    if (bytes) {
+		rv = HT_PARTIAL_CONTENT;
+	    } else {
+		rv = -1;
+	    }
 	    break;
 	}
 	(*targetClass.put_block)(sink, input_buffer, status);
@@ -621,27 +625,28 @@ PUBLIC int HTFileCopy ARGS2(
 	bytes += status;
 	if (nreads >= 100) {
 	    /*
-	     *  Show progres messages for local files, and check for
-	     *  user interruption.
-	     *  Start doing so only after a certain number of reads
-	     *  have been done, and don't update it on every read -
-	     *  normally reading in a local file should be speedy.
-	     */
+	    **  Show progress messages for local files, and check for
+	    **  user interruption.  Start doing so only after a certain
+	    **  number of reads have been done, and don't update it on
+	    **  every read (normally reading in a local file should be
+	    **  speedy). - KW
+	    */
 	    if (nprogr == 0) {
-	        if (bytes < 1024000) {
+		if (bytes < 1024000) {
 		    sprintf(line, "Read %d bytes of data.", bytes);
 		} else {
 		    sprintf(line, "Read %d KB of data. %s",
-			    bytes/1024,
+				  bytes/1024,
 		    "(Press 'z' if you want to abort loading.)");
 		}
 		HTProgress(line);
 		if (HTCheckForInterrupt()) {
 		    _HTProgress ("Data transfer interrupted.");
-		    if (bytes)
+		    if (bytes) {
 			rv = HT_INTERRUPTED;
-		    else
-			rv = HT_PARTIAL_CONTENT;
+		    } else {
+			rv = -1;
+		    }
 		    break;
 		}
 		nprogr++;
@@ -788,14 +793,18 @@ PUBLIC int HTParseFile ARGS5(
     */
     targetClass = *(stream->isa);	/* Copy pointers to procedures */
     rv = HTFileCopy(fp, stream);
-    if (rv == -1 || rv == HT_INTERRUPTED)
+    if (rv == -1 || rv == HT_INTERRUPTED) {
         (*targetClass._abort)(stream, NULL);
-    else
+    } else {
 	(*targetClass._free)(stream);
+    }
 
-    if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED))
+    if (rv == -1)
+	return HT_NO_DATA;
+    else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED))
 	return HT_PARTIAL_CONTENT;
-    return HT_LOADED;
+    else
+	return HT_LOADED;
 }
 
 /*	Converter stream: Network Telnet to internal character text
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 6e34c16b..2b9e31e4 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -86,7 +86,6 @@ typedef enum _MIME_state {
 	miPUBLIC,
 	miRETRY_AFTER,
 	miS,
-	miSA,
 	miSAFE,
 	miSE,
 	miSERVER,
@@ -977,9 +976,11 @@ PRIVATE void HTMIME_put_character ARGS2(
         switch (c) {
 	case 'a':
 	case 'A':
-	    me->state = miSAFE;
+	    me->check_pointer = "fe:";
+	    me->if_ok = miSAFE;
+	    me->state = miCHECK;
 	    if (TRACE)
-	        fprintf(stderr, "HTMIME: Was S, found A, state now SAFE'\n");
+	        fprintf(stderr, "HTMIME: Was S, found A, checking for 'fe:'\n");
 	    break;
 
 	case 'e':
diff --git a/WWW/Library/Implementation/HTStyle.h b/WWW/Library/Implementation/HTStyle.h
index 100162d2..837251aa 100644
--- a/WWW/Library/Implementation/HTStyle.h
+++ b/WWW/Library/Implementation/HTStyle.h
@@ -67,7 +67,7 @@ typedef struct _color {
 } HTColor;
 #else
 
-typedef float HTCoord;
+typedef int HTCoord;		/* changed from float to int - kw */
 
 typedef struct _HTParagraphStyle {
     HTCoord     left_indent;            /* @@@@ junk! etc etc*/
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 62c38095..98d21800 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -417,7 +417,8 @@ PUBLIC int HTParseInet ARGS2(
 	    /*
 	    **  Pipe, child pid, and status buffers.
 	    */
-	    int pfd[2], fpid, cstat, cst1;
+	    pid_t fpid, waitret = (pid_t)0;
+	    int pfd[2], cstat, cst1 = 0;
 
 	    pipe(pfd);
 
@@ -454,8 +455,9 @@ PUBLIC int HTParseInet ARGS2(
 		/*
 		**  Exit if child exited.
 		*/
-		if (waitpid(fpid, &cst1, WNOHANG) > 0)
+		if ((waitret = waitpid(fpid, &cst1, WNOHANG)) > 0) {
 		    break;
+		}
 		/*
 		**  Abort if interrupt key pressed.
 		*/
@@ -473,19 +475,56 @@ PUBLIC int HTParseInet ARGS2(
 		*/
 		sleep(1);
 	    }
-	    waitpid(fpid, &cst1, WNOHANG);
+	    if (waitret <= 0)
+		waitret = waitpid(fpid, &cst1, WNOHANG);
+	    if (TRACE) {
+		if (WIFEXITED(cst1)) {
+		    fprintf(stderr,
+			    "NSL_FORK: Child %d exited, status 0x%x.\n",
+			    (int)waitret, cst1);
+		} else if (WIFSIGNALED(cst1)) {
+		    fprintf(stderr,
+			    "NSL_FORK: Child %d got signal, status 0x%x!\n",
+			    (int)waitret, cst1);
+#ifdef WCOREDUMP
+		    if (WCOREDUMP(cst1)) {
+		    fprintf(stderr,
+			    "NSL_FORK: Child %d dumped core!\n",(int)waitret);
+		    }
+#endif
+		} else if (WIFSTOPPED(cst1)) {
+		    fprintf(stderr,
+			    "NSL_FORK: Child %d is stopped, status 0x%x!\n",
+			    (int)waitret, cst1);
+		}
+	    }
 	    /*
 	    **  Read as much as we can - should be the address.
 	    */
 	    IOCTL(pfd[0], FIONREAD, &cstat);
-	    if (cstat < 4)
+	    if (cstat < 4) {
+		if (TRACE)
+		    fprintf(stderr, 
+			    "NSL_FORK: Child returns only %d bytes, \
+trying again without forking...\n", cstat);
+		phost = gethostbyname(host);	/* See netdb.h */
+		if (!phost) {
+		    if (TRACE)
+			fprintf(stderr, 
+				"HTParseInet: Can't find internet node name `%s'.\n",host);
+		    memset((void *)&sin->sin_addr, 0, sizeof(sin->sin_addr));
+		} else {
+		    memcpy((void *)&sin->sin_addr, phost->h_addr, phost->h_length);
+		}
+#if 0		
 	        cstat = read(pfd[0], (void *)&sin->sin_addr , 4);
-	    else
+#endif
+	    } else {
 	        cstat = read(pfd[0], (void *)&sin->sin_addr , cstat);
+	    }
 	    close(pfd[0]);
 	    close(pfd[1]);
 	}
-
 	if (sin->sin_addr.s_addr == 0) {
 	    if (TRACE)
 	        fprintf(stderr, 
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 980b8f6e..0bcc2c62 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -485,7 +485,23 @@ try_again:
 	**  If we do have a cookie set, add it to the request buffer. - FM
 	*/
 	if (cookie != NULL) {
+	    if (*cookie != '$') {
+	        /*
+		**  It's a historical cookie, so signal to the
+		**  server that we support modern cookies. - FM
+		*/
+		StrAllocCat(command, "Cookie2: $Version=\"1\"");
+		StrAllocCat(command, crlf);
+	        if (TRACE)
+	            fprintf(stderr,
+			    "HTTP: Sending Cookie2: $Version =\"1\"\n");
+	    }
 	    if (*cookie != '\0') {
+	        /*
+		**  It's not a zero-length string, so add the header.
+		**  Note that any folding of long strings has been
+		**  done already in LYCookie.c. - FM
+		*/
 	        StrAllocCat(command, "Cookie: ");
 	        StrAllocCat(command, cookie);
 		StrAllocCat(command, crlf);