$NetBSD: patch-ab,v 1.10 2015/07/04 16:11:53 bsiegert Exp $

Fix build.

--- ttcp.c.orig	1997-02-27 21:30:23.000000000 +0000
+++ ttcp.c
@@ -44,17 +44,19 @@ static char RCSid[] = "ttcp.c $Revision:
 /* #define BSD41a */
 /* #define SYSV */	/* required on SGI IRIX releases before 3.3 */
 
-#include <stdio.h>
-#include <signal.h>
-#include <ctype.h>
-#include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
+#include <stdio.h>
+#include <signal.h>
+#include <ctype.h>
+#include <errno.h>
 #include <netdb.h>
 #include <sys/time.h>		/* struct timeval */
+#include <stdlib.h>
+#include <string.h>
 
 #if defined(SYSV)
 #include <sys/times.h>
@@ -71,7 +73,8 @@ struct sockaddr_in sinme;
 struct sockaddr_in sinhim;
 struct sockaddr_in frominet;
 
-int domain, fromlen;
+int domain;
+socklen_t fromlen;
 int fd;				/* fd of network socket */
 
 int buflen = 8 * 1024;		/* length of buffer */
@@ -99,7 +102,6 @@ char fmt = 'K';			/* output format: k = 
 int touchdata = 0;		/* access data after reading */
 
 struct hostent *addr;
-extern int errno;
 extern int optind;
 extern char *optarg;
 
@@ -151,7 +153,7 @@ main(argc,argv)
 int argc;
 char **argv;
 {
-	unsigned long addr_tmp;
+	in_addr_t addr_tmp;
 	int c;
 
 	if (argc < 2) goto usage;
@@ -263,29 +265,30 @@ char **argv;
 	if ( (buf = (char *)malloc(buflen+bufalign)) == (char *)NULL)
 		err("malloc");
 	if (bufalign != 0)
-		buf +=(bufalign - ((int)buf % bufalign) + bufoffset) % bufalign;
+		buf +=(bufalign - ((u_long)buf % bufalign) + bufoffset) % bufalign;
 
 	if (trans) {
-	    fprintf(stdout,
+	    fprintf(stderr,
 	    "ttcp-t: buflen=%d, nbuf=%d, align=%d/%d, port=%d",
 		buflen, nbuf, bufalign, bufoffset, port);
  	    if (sockbufsize)
- 		fprintf(stdout, ", sockbufsize=%d", sockbufsize);
+ 		fprintf(stderr, ", sockbufsize=%d", sockbufsize);
  	    fprintf(stdout, "  %s  -> %s\n", udp?"udp":"tcp", host);
 	} else {
-	    fprintf(stdout,
+	    fprintf(stderr,
  	    "ttcp-r: buflen=%d, nbuf=%d, align=%d/%d, port=%d",
  		buflen, nbuf, bufalign, bufoffset, port);
  	    if (sockbufsize)
- 		fprintf(stdout, ", sockbufsize=%d", sockbufsize);
- 	    fprintf(stdout, "  %s\n", udp?"udp":"tcp");
+ 		fprintf(stderr, ", sockbufsize=%d", sockbufsize);
+ 	    fprintf(stderr, "  %s\n", udp?"udp":"tcp");
 	}
 
 	if ((fd = socket(AF_INET, udp?SOCK_DGRAM:SOCK_STREAM, 0)) < 0)
 		err("socket");
 	mes("socket");
 
-	if (bind(fd, &sinme, sizeof(sinme)) < 0)
+	sinme.sin_family = AF_INET;
+	if (bind(fd, (struct sockaddr *)&sinme, sizeof(sinme)) < 0)
 		err("bind");
 
 #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
@@ -326,7 +329,7 @@ char **argv;
 			mes("nodelay");
 		}
 #endif
-		if(connect(fd, &sinhim, sizeof(sinhim) ) < 0)
+		if(connect(fd, (struct sockaddr *)&sinhim, sizeof(sinhim) ) < 0)
 			err("connect");
 		mes("connect");
 	    } else {
@@ -348,11 +351,11 @@ char **argv;
 		}
 		fromlen = sizeof(frominet);
 		domain = AF_INET;
-		if((fd=accept(fd, &frominet, &fromlen) ) < 0)
+		if((fd=accept(fd, (struct sockaddr *)&frominet, &fromlen) ) < 0)
 			err("accept");
 		{ struct sockaddr_in peer;
-		  int peerlen = sizeof(peer);
-		  if (getpeername(fd, (struct sockaddr_in *) &peer, 
+		  socklen_t peerlen = sizeof(peer);
+		  if (getpeername(fd, (struct sockaddr *) &peer, 
 				&peerlen) < 0) {
 			err("getpeername");
 		  }
@@ -412,25 +415,25 @@ char **argv;
 	}
 	if( cput <= 0.0 )  cput = 0.001;
 	if( realt <= 0.0 )  realt = 0.001;
-	fprintf(stdout,
+	fprintf(stderr,
 		"ttcp%s: %.0f bytes in %.2f real seconds = %s/sec +++\n",
 		trans?"-t":"-r",
 		nbytes, realt, outfmt(nbytes/realt));
 	if (verbose) {
-	    fprintf(stdout,
+	    fprintf(stderr,
 		"ttcp%s: %.0f bytes in %.2f CPU seconds = %s/cpu sec\n",
 		trans?"-t":"-r",
 		nbytes, cput, outfmt(nbytes/cput));
 	}
-	fprintf(stdout,
+	fprintf(stderr,
 		"ttcp%s: %d I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
 		trans?"-t":"-r",
 		numCalls,
 		1024.0 * realt/((double)numCalls),
 		((double)numCalls)/realt);
-	fprintf(stdout,"ttcp%s: %s\n", trans?"-t":"-r", stats);
+	fprintf(stderr,"ttcp%s: %s\n", trans?"-t":"-r", stats);
 	if (verbose) {
-	    fprintf(stdout,
+	    fprintf(stderr,
 		"ttcp%s: buffer address %#x\n",
 		trans?"-t":"-r",
 		buf);
@@ -488,13 +491,13 @@ double b;
 	    sprintf(obuf, "%.2f MB", b / 1024.0 / 1024.0);
 	    break;
 	case 'g':
-	    sprintf(obuf, "%.2f Gbit", b * 8.0 / 1024.0 / 1024.0 / 1024.0);
+	    sprintf(obuf, "%.2f Gbit", b * 8.0 / 1000.0 / 1000.0 / 1000.0);
 	    break;
 	case 'k':
-	    sprintf(obuf, "%.2f Kbit", b * 8.0 / 1024.0);
+	    sprintf(obuf, "%.2f Kbit", b * 8.0 / 1000.0);
 	    break;
 	case 'm':
-	    sprintf(obuf, "%.2f Mbit", b * 8.0 / 1024.0 / 1024.0);
+	    sprintf(obuf, "%.2f Mbit", b * 8.0 / 1000.0 / 1000.0);
 	    break;
     }
     return obuf;
@@ -749,10 +752,10 @@ void *buf;
 int count;
 {
 	struct sockaddr_in from;
-	int len = sizeof(from);
+	socklen_t len = sizeof(from);
 	register int cnt;
 	if( udp )  {
-		cnt = recvfrom( fd, buf, count, 0, &from, &len );
+		cnt = recvfrom( fd, buf, count, 0, (struct sockaddr *)&from, &len );
 		numCalls++;
 	} else {
 		if( b_flag )
@@ -782,7 +785,7 @@ int count;
 	register int cnt;
 	if( udp )  {
 again:
-		cnt = sendto( fd, buf, count, 0, &sinhim, sizeof(sinhim) );
+		cnt = sendto( fd, buf, count, 0, (struct sockaddr *)&sinhim, sizeof(sinhim) );
 		numCalls++;
 		if( cnt<0 && errno == ENOBUFS )  {
 			delay(18000);
@@ -803,7 +806,7 @@ delay(us)
 
 	tv.tv_sec = 0;
 	tv.tv_usec = us;
-	(void)select( 1, (char *)0, (char *)0, (char *)0, &tv );
+	(void)select( 1, (void *)0, (void *)0, (void *)0, &tv );
 }
 
 /*