about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTFTP.c64
-rw-r--r--WWW/Library/Implementation/HTFormat.h8
-rw-r--r--WWW/Library/Implementation/HTTCP.c42
-rw-r--r--WWW/Library/Implementation/www_tcp.h27
-rw-r--r--WWW/Library/Implementation/www_wait.h26
5 files changed, 64 insertions, 103 deletions
diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c
index e725080a..5c3df4f0 100644
--- a/WWW/Library/Implementation/HTFTP.c
+++ b/WWW/Library/Implementation/HTFTP.c
@@ -1166,21 +1166,9 @@ PRIVATE int get_listen_socket NOARGS
 		if ((status=Rbind(new_socket,
 			(struct sockaddr*)&soc_address,
 			    /* Cast to generic sockaddr */
-#ifdef INET6
-#ifdef SIN6_LEN
-			((struct sockaddr *)&soc_address)->sa_len,
-#else
-			SA_LEN((struct sockaddr *)&soc_address),
-#endif /* SIN6_LEN */
-#else
-			sizeof(soc_address)
-#endif /* INET6 */
+			SOCKADDR_LEN(soc_address)
 #ifndef SHORTENED_RBIND
-#ifdef INET6
-			socks_bind_remoteAddr
-#else
 			,socks_bind_remoteAddr
-#endif /* INET6 */
 #endif /* !SHORTENED_RBIND */
 						)) == 0) {
 		    break;
@@ -1189,16 +1177,8 @@ PRIVATE int get_listen_socket NOARGS
 	    if ((status=bind(new_socket,
 		    (struct sockaddr*)&soc_address,
 			    /* Cast to generic sockaddr */
-#ifdef INET6
-#ifdef SIN6_LEN
-		    ((struct sockaddr *)&soc_address)->sa_len
-#else
-		    SA_LEN((struct sockaddr *)&soc_address)
-#endif /* SIN6_LEN */
+		    SOCKADDR_LEN(soc_address)
 		    )) == 0) {
-#else
-		    sizeof(soc_address))) == 0) {
-#endif /* INET6 */
 		break;
 	    }
 	    CTRACE((tfp, "TCP bind attempt to port %d yields %d, errno=%d\n",
@@ -1250,16 +1230,8 @@ PRIVATE int get_listen_socket NOARGS
 	status=bind(new_socket,
 		    (struct sockaddr*)&soc_address,
 		    /* Cast to generic sockaddr */
-#ifdef INET6
-#ifdef SIN6_LEN
-		    ((struct sockaddr *)&soc_address)->sa_len
-#else
-		    SA_LEN((struct sockaddr *)&soc_address)
-#endif /* SIN6_LEN */
+		    SOCKADDR_LEN(soc_address)
 		    );
-#else
-		    sizeof(soc_address));
-#endif /* INET6 */
 	if (status<0) return HTInetStatus("bind");
 
 	address_length = sizeof(soc_address);
@@ -1300,10 +1272,8 @@ PRIVATE int get_listen_socket NOARGS
 #ifdef INET6
     switch (((struct sockaddr *)&soc_address)->sa_family) {
     case AF_INET:
-	sprintf(port_command, "PORT %d,%d,%d,%d,%d,%d%c%c",
-#else
-    sprintf(port_command, "PORT %d,%d,%d,%d,%d,%d%c%c",
 #endif /* INET6 */
+	sprintf(port_command, "PORT %d,%d,%d,%d,%d,%d%c%c",
 		    (int)*((unsigned char *)(&soc_in->sin_addr)+0),
 		    (int)*((unsigned char *)(&soc_in->sin_addr)+1),
 		    (int)*((unsigned char *)(&soc_in->sin_addr)+2),
@@ -1320,11 +1290,7 @@ PRIVATE int get_listen_socket NOARGS
 	char hostbuf[MAXHOSTNAMELEN];
 	char portbuf[MAXHOSTNAMELEN];
 	getnameinfo((struct sockaddr *)&soc_address,
-#ifdef SIN6_LEN
-	    ((struct sockaddr *)&soc_address)->sa_len,
-#else
-	    SA_LEN((struct sockaddr *)&soc_address),
-#endif /* SIN6_LEN */
+	    SOCKADDR_LEN(soc_address),
 	    hostbuf, sizeof(hostbuf), portbuf, sizeof(portbuf),
 	    NI_NUMERICHOST | NI_NUMERICSERV);
 	sprintf(port_command, "EPRT |%d|%s|%s|%c%c", 2, hostbuf, portbuf,
@@ -3049,15 +3015,15 @@ PUBLIC int HTFTPLoad ARGS4(
 
 		while (--p > response_text && '0' <= *p && *p <= '9')
 		    ; /* null body */
-	       status = sscanf(p+1, "%d,%d,%d,%d,%d,%d",
+		status = sscanf(p+1, "%d,%d,%d,%d,%d,%d",
 		       &h0, &h1, &h2, &h3, &p0, &p1);
-	       if (status < 4) {
-		   fprintf(tfp, "HTFTP: PASV reply has no inet address!\n");
-		   return -99;
-	       }
-	       passive_port = (p0<<8) + p1;
+		if (status < 4) {
+		    fprintf(tfp, "HTFTP: PASV reply has no inet address!\n");
+		    return -99;
+		}
+		passive_port = (p0<<8) + p1;
 	    } else if (strncmp(command, "EPSV", 4) == 0) {
-		char ch;
+		unsigned char c0, c1, c2, c3;
 		/*
 		 * EPSV |||port|
 		 */
@@ -3066,11 +3032,15 @@ PUBLIC int HTFTPLoad ARGS4(
 		for (p = response_text; *p && isspace(*p); p++)
 		    ; /* null body */
 		status = sscanf(p+1, "%c%c%c%d%c",
-		       &h0, &h1, &h2, &p0, &h3);
+		       &c0, &c1, &c2, &p0, &c3);
 		if (status != 5) {
 		    fprintf(tfp, "HTFTP: EPSV reply has invalid format!\n");
 		    return -99;
 		}
+		h0 = c0;
+		h1 = c1;
+		h2 = c2;
+		h3 = c3;
 		passive_port = p0;
  	    }
 #else
diff --git a/WWW/Library/Implementation/HTFormat.h b/WWW/Library/Implementation/HTFormat.h
index b1fbf8b4..8cba2c05 100644
--- a/WWW/Library/Implementation/HTFormat.h
+++ b/WWW/Library/Implementation/HTFormat.h
@@ -150,7 +150,7 @@ typedef HTAtom* HTEncoding;
 The HTPresentation and HTConverter types
 
    This HTPresentation structure represents a possible conversion algorithm from one
-   format to annother.  It includes a pointer to a conversion routine.  The conversion
+   format to another.  It includes a pointer to a conversion routine.  The conversion
    routine returns a stream to which data should be fed. See also HTStreamStack which
    scans the list of registered converters and calls one.  See the initialisation module
    for a list of conversion routines.
@@ -164,9 +164,9 @@ typedef HTStream * HTConverter PARAMS((
         HTStream *              sink));
 
 struct _HTPresentation {
-        HTAtom	*	rep;            /* representation name atmoized */
+        HTAtom	*	rep;            /* representation name atomized */
         HTAtom	*	rep_out;        /* resulting representation */
-        HTConverter *	converter;  /* The routine to gen the stream stack */
+        HTConverter *	converter;	/* routine to gen the stream stack */
         char *		command;        /* MIME-format string */
         float		quality;        /* Between 0 (bad) and 1 (good) */
         float		secs;
@@ -184,7 +184,7 @@ extern HTList * HTPresentations;
 
 /*
 
-   The default presentation is used when no other is appriporate
+   The default presentation is used when no other is appropriate
 
  */
 extern  HTPresentation* default_presentation;
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 859a6734..5b528bc2 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -25,7 +25,7 @@
 
 #ifdef NSL_FORK
 #include <signal.h>
-#include <sys/wait.h>
+#include <www_wait.h>
 #endif /* NSL_FORK */
 
 #ifdef HAVE_RESOLV_H
@@ -302,11 +302,7 @@ PUBLIC CONST char * HTInetString ARGS1(
 #ifdef INET6
     static char hostbuf[MAXHOSTNAMELEN];
     getnameinfo((struct sockaddr *)soc_in,
-#ifdef SIN6_LEN
-	    ((struct sockaddr *)soc_in)->sa_len,
-#else
-	    SA_LEN((struct sockaddr *)soc_in),
-#endif /* SIN6_LEN */
+	    SOCKADDR_LEN(soc_in),
 	    hostbuf, sizeof(hostbuf), NULL, 0, NI_NUMERICHOST);
     return hostbuf;
 #else
@@ -1016,18 +1012,10 @@ PUBLIC struct hostent * LYGetHostByName ARGS1(
 		**  Make sure child is cleaned up.  -BL
 		*/
 		if (!child_exited)
-#ifdef HAVE_TYPE_UNIONWAIT
-		    waitret = waitpid(fpid, &waitstat.w_status, WNOHANG);
-#else
 		    waitret = waitpid(fpid, &waitstat, WNOHANG);
-#endif
 		if (!WIFEXITED(waitstat) && !WIFSIGNALED(waitstat)) {
 		    kill(fpid, SIGTERM);
-#ifdef HAVE_TYPE_UNIONWAIT
-		    waitret = waitpid(fpid, &waitstat.w_status, WNOHANG);
-#else
 		    waitret = waitpid(fpid, &waitstat, WNOHANG);
-#endif
 		}
 		break;
 	    }
@@ -1036,21 +1024,13 @@ PUBLIC struct hostent * LYGetHostByName ARGS1(
 	    **  Clean up if child exited before & no data received.  -BL
 	    */
 	    if (child_exited) {
-#ifdef HAVE_TYPE_UNIONWAIT
-		waitret = waitpid(fpid, &waitstat.w_status, WNOHANG);
-#else
 		waitret = waitpid(fpid, &waitstat, WNOHANG);
-#endif
 		break;
 	    }
 	    /*
 	    **  If child exited, loop once more looking for data.  -BL
 	    */
-#ifdef HAVE_TYPE_UNIONWAIT
-	    if ((waitret = waitpid(fpid, &waitstat.w_status, WNOHANG)) > 0) {
-#else
 	    if ((waitret = waitpid(fpid, &waitstat, WNOHANG)) > 0) {
-#endif
 		/*
 		**	Data will be arriving right now, so make sure we
 		**	don't short-circuit out for too many loops, and
@@ -1079,16 +1059,11 @@ PUBLIC struct hostent * LYGetHostByName ARGS1(
 	}
 	if (waitret > 0) {
 	    if (WIFEXITED(waitstat)) {
-#ifdef HAVE_TYPE_UNIONWAIT
-		CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d exited, status 0x%x.\n",
-			(int)waitret, waitstat.w_status));
-#else
 		CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d exited, status 0x%x.\n",
-			(int)waitret, waitstat));
-#endif
+			(int)waitret, WEXITSTATUS(waitstat)));
 	    } else if (WIFSIGNALED(waitstat)) {
 		CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d got signal, status 0x%x!\n",
-		       (int)waitret, waitstat));
+		       (int)waitret, WTERMSIG(waitstat)));
 #ifdef WCOREDUMP
 		if (WCOREDUMP(waitstat)) {
 		    CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d dumped core!\n",
@@ -1096,13 +1071,8 @@ PUBLIC struct hostent * LYGetHostByName ARGS1(
 		}
 #endif /* WCOREDUMP */
 	    } else if (WIFSTOPPED(waitstat)) {
-#ifdef HAVE_TYPE_UNIONWAIT
-	      CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d is stopped, status 0x%x!\n",
-		      (int)waitret, waitstat.w_status));
-#else
-	      CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d is stopped, status 0x%x!\n",
-		      (int)waitret, waitstat));
-#endif
+		CTRACE((tfp, "LYGetHostByName: NSL_FORK child %d is stopped, status 0x%x!\n",
+			(int)waitret, WEXITSTATUS(waitstat)));
 	    }
 	}
 	if (!got_rehostent) {
diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h
index 16bca6e2..d0ed557f 100644
--- a/WWW/Library/Implementation/www_tcp.h
+++ b/WWW/Library/Implementation/www_tcp.h
@@ -69,7 +69,18 @@ typedef struct sockaddr_in SockA;  /* See netinet/in.h */
 #endif /* INET6 */
 #endif
 
+#ifdef INET6
+#ifdef SIN6_LEN
+#define SOCKADDR_LEN(soc_address) ((struct sockaddr *)&soc_address)->sa_len
+#else
+#define SOCKADDR_LEN(soc_address) SA_LEN((struct sockaddr *)&soc_address)
+#endif /* SIN6_LEN */
+#else
+#define SOCKADDR_LEN(soc_address) sizeof(soc_address)
+#endif /* INET6 */
+
 #ifndef VMS
+
 #include <sys/types.h>
 
 #if defined(__BORLANDC__)
@@ -615,22 +626,6 @@ typedef unsigned short mode_t;
 typedef int pid_t;
 #endif /* !pid_t */
 
-#ifndef WEXITSTATUS
-#ifdef sony_news
-#define WEXITSTATUS(s) WIFEXITED(s)
-#else
-#define WEXITSTATUS(s) (((s).w_status >> 8) & 0377)
-#endif /* sony_news */
-#endif /* !WEXITSTATUS */
-
-#ifndef WTERMSIG
-#ifdef sony_news
-#define WTERMSIG(s) (s).w_termsig
-#else
-#define WTERMSIG(s) (((s).w_status >> 8) & 0177)
-#endif /* sony_news */
-#endif /* !WTERMSIG */
-
 #endif /* NeXT || sony_news */
 
 #define INCLUDES_DONE
diff --git a/WWW/Library/Implementation/www_wait.h b/WWW/Library/Implementation/www_wait.h
new file mode 100644
index 00000000..730b3ec5
--- /dev/null
+++ b/WWW/Library/Implementation/www_wait.h
@@ -0,0 +1,26 @@
+#ifndef WWW_WAIT_H
+#define WWW_WAIT_H 1
+
+#include <HTUtils.h>
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifndef WEXITSTATUS
+# ifdef HAVE_TYPE_UNIONWAIT
+#  define	WEXITSTATUS(status)	(status.w_retcode)
+# else
+#  define	WEXITSTATUS(status)	(((status) & 0xff00) >> 8)
+# endif
+#endif
+
+#ifndef WTERMSIG
+# ifdef HAVE_TYPE_UNIONWAIT
+#  define	WTERMSIG(status)	(status.w_termsig)
+# else
+#  define	WTERMSIG(status)	((status) & 0x7f)
+# endif
+#endif
+
+#endif /* WWW_WAIT_H */