[Midnightbsd-cvs] src: usr.bin/tip: sync with freebsd7

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Mar 27 18:19:05 EDT 2009


Log Message:
-----------
sync with freebsd7

Modified Files:
--------------
    src/usr.bin/tip/libacu:
        biz22.c (r1.1.1.1 -> r1.2)
        biz31.c (r1.1.1.1 -> r1.2)
        courier.c (r1.1.1.1 -> r1.2)
        df.c (r1.1.1.1 -> r1.2)
        dn11.c (r1.1.1.1 -> r1.2)
        hayes.c (r1.1.1.1 -> r1.2)
        t3000.c (r1.1.1.1 -> r1.2)
        v3451.c (r1.1.1.1 -> r1.2)
        v831.c (r1.1.1.1 -> r1.2)
        ventel.c (r1.1.1.1 -> r1.2)
    src/usr.bin/tip/tip:
        Makefile (r1.1.1.1 -> r1.2)
        acu.c (r1.1.1.1 -> r1.2)
        acutab.c (r1.1.1.1 -> r1.2)
        cmds.c (r1.1.1.1 -> r1.2)
        cmdtab.c (r1.1.1.1 -> r1.2)
        cu.c (r1.1.1.1 -> r1.2)
        hunt.c (r1.1.1.1 -> r1.2)
        log.c (r1.1.1.1 -> r1.2)
        partab.c (r1.1.1.1 -> r1.2)
        pathnames.h (r1.1.1.1 -> r1.2)
        remote.c (r1.1.1.1 -> r1.2)
        tip.1 (r1.1.1.1 -> r1.2)
        tip.c (r1.1.1.1 -> r1.2)
        tip.h (r1.1.1.1 -> r1.2)
        tipout.c (r1.1.1.1 -> r1.2)
        uucplock.c (r1.1.1.1 -> r1.2)
        value.c (r1.1.1.1 -> r1.2)
        vars.c (r1.1.1.1 -> r1.2)

Removed Files:
-------------
    src/usr.bin/tip:
        NEWS

-------------- next part --------------
--- usr.bin/tip/NEWS
+++ /dev/null
@@ -1,65 +0,0 @@
-Sat Mar 25 16:06:31 PST 1995
-
-hw_flow_control (boolean) capability added to modem configuration
-data base (/etc/modems).
-
-Configurable unidialer driver compiled in by default. Builtin
-ACU drivers no longer compiled in by default.
-
-All configuration details isolated in tipconf.h (with exception of 
-pathnames.h).
-
-Made corrections to and updated manual page for tip.
-
-Conditional compilation of cu interface for systems that provide
-a separate cu implementation (e.g. FreeBSD).
-
-Sat Mar 25 00:35:08 PST 1995
-
-Corrected entry in man file to identify the lockfile dir as /var/spool/locks
-instead of /var/spool/uucp.
-
-xfer and transfer in cmds.c use standard C runtime buffered output.
-Eliminates a bug: buffer overruns when FRAMESIZE > BUFSIZ.
-
-Added xfer routine for doing cu style take commands.
-
-Thu Mar 16 08:17:57 PST 1995
-
-Added support for termios.
-
-Renamed acunap.* to acucommon.*. Moved common acu routines
-to it. Modified acu drivers to use common routines.
-
-Sat Mar 11 20:17:58 PST 1995
-
-Default nap function uses select call in preference to
-usleep or old, handrolled code.
-
-tip makefile does not create a link to cu by default.
-
-Wed Mar  8 00:11:04 PST 1995
-
-Reduced sleep time in finish () in cmds.c from 5 seconds to two.
-
-Sat Mar  4 19:00:34 PST 1995
-
-Added table-driven modem driver (unidialer) that fetches modem
-characteristics from a modem database ("/etc/modems").
-
-Removed common "nap" code from individual ACU drivers into a
-separate module.
-
-Added login script capability to remote database.
-
-Sun Feb 26 23:07:56 PST 1995
-
-Use HoneyDanber style locks by default (ASCII PIDs written to lock files).
-
-Changed default uucp file lock directory to "/var/spool/locks"
-to be consistent with default build of Taylor uucp.
-
-Reorganized build environment for tip into a master directory
-and two subdirectories. The master Makefile builds a library
-of ACU "drivers" in the directory libacu. Tip only links in
-drivers that it will actually use.
Index: ventel.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/ventel.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/ventel.c -L usr.bin/tip/libacu/ventel.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/ventel.c
+++ usr.bin/tip/libacu/ventel.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: ventel.c,v 1.7 2001/11/19 19:02:16 mpech Exp $	*/
+/*	$OpenBSD: ventel.c,v 1.12 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: ventel.c,v 1.6 1997/02/11 09:24:21 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/ventel.c,v 1.4 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/ventel.c,v 1.5 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)ventel.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: ventel.c,v 1.7 2001/11/19 19:02:16 mpech Exp $";
+static const char rcsid[] = "$OpenBSD: ventel.c,v 1.12 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -54,12 +50,13 @@
 
 #define	MAXRETRY	5
 
-static	void sigALRM();
-static	int timeout = 0;
+static	int dialtimeout = 0;
 static	jmp_buf timeoutbuf;
 
-static	int gobble(), vensync();
-static	void echo();
+static void	echo(char *);
+static void	sigALRM(int);
+static int	gobble(char, char *);
+static int	vensync(int);
 
 /*
  * some sleep calls have been replaced by this macro
@@ -72,9 +69,7 @@
 #define busyloop(n) do { DELAY(n); } while (0)
 
 int
-ven_dialer(num, acu)
-	char *num;
-	char *acu;
+ven_dialer(char *num, char *acu)
 {
 	char *cp;
 	int connected = 0;
@@ -109,21 +104,21 @@
 		connected = gobble('!', line);
 	tcflush(FD, TCIOFLUSH);
 #ifdef ACULOG
-	if (timeout) {
-		(void)sprintf(line, "%ld second dial timeout",
+	if (dialtimeout) {
+		(void)snprintf(line, sizeof line, "%ld second dial timeout",
 			number(value(DIALTIMEOUT)));
 		logent(value(HOST), num, "ventel", line);
 	}
 #endif
-	if (timeout)
+	if (dialtimeout)
 		ven_disconnect();	/* insurance */
-	if (connected || timeout || !boolean(value(VERBOSE)))
+	if (connected || dialtimeout || !boolean(value(VERBOSE)))
 		return (connected);
 	/* call failed, parse response for user */
 	cp = strchr(line, '\r');
 	if (cp)
 		*cp = '\0';
-	for (cp = line; cp = strchr(cp, ' '); cp++)
+	for (cp = line; (cp = strchr(cp, ' ')) != NULL; cp++)
 		if (cp[1] == ' ')
 			break;
 	if (cp) {
@@ -141,63 +136,59 @@
 }
 
 void
-ven_disconnect()
+ven_disconnect(void)
 {
-
 	close(FD);
 }
 
 void
-ven_abort()
+ven_abort(void)
 {
-
 	write(FD, "\03", 1);
 	close(FD);
 }
 
 static void
-echo(s)
-	char *s;
+echo(char *s)
 {
 	char c;
 
-	while (c = *s++) switch (c) {
+	while ((c = *s++) != '\0')
+		switch (c) {
+		case '$':
+			read(FD, &c, 1);
+			s++;
+			break;
 
-	case '$':
-		read(FD, &c, 1);
-		s++;
-		break;
-
-	case '#':
-		c = *s++;
-		write(FD, &c, 1);
-		break;
-
-	default:
-		write(FD, &c, 1);
-		read(FD, &c, 1);
-	}
+		case '#':
+			c = *s++;
+			write(FD, &c, 1);
+			break;
+
+		default:
+			write(FD, &c, 1);
+			read(FD, &c, 1);
+		}
 }
 
+/*ARGSUSED*/
 static void
-sigALRM()
+sigALRM(int signo)
 {
 	printf("\07timeout waiting for reply\n");
-	timeout = 1;
+	dialtimeout = 1;
 	longjmp(timeoutbuf, 1);
 }
 
 static int
-gobble(match, response)
-	char match;
-	char response[];
+gobble(char match, char response[])
 {
 	char *cp = response;
 	sig_t f;
 	char c;
 
 	f = signal(SIGALRM, sigALRM);
-	timeout = 0;
+	dialtimeout = 0;
 	do {
 		if (setjmp(timeoutbuf)) {
 			signal(SIGALRM, f);
@@ -225,7 +216,7 @@
  * there are gory ways to simulate this.
  */
 static int
-vensync(fd)
+vensync(int fd)
 {
 	int already = 0, nread;
 	char buf[60];
@@ -266,4 +257,3 @@
 	}
 	return (0);
 }
-
Index: dn11.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/dn11.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/dn11.c -L usr.bin/tip/libacu/dn11.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/dn11.c
+++ usr.bin/tip/libacu/dn11.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: dn11.c,v 1.5 2001/11/19 19:02:16 mpech Exp $	*/
+/*	$OpenBSD: dn11.c,v 1.9 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/dn11.c,v 1.3 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/dn11.c,v 1.4 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dn11.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: dn11.c,v 1.5 2001/11/19 19:02:16 mpech Exp $";
+static const char rcsid[] = "$OpenBSD: dn11.c,v 1.9 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -49,14 +45,13 @@
  */
 #include "tip.h"
 
-void dn_abort();
-void alarmtr();
 static jmp_buf jmpbuf;
-static int child = -1, dn;
+static pid_t child = -1, dn;
+
+static void alarmtr(int);
 
 int
-dn_dialer(num, acu)
-	char *num, *acu;
+dn_dialer(char *num, char *acu)
 {
 	int lt, nw;
 	int timelim;
@@ -119,8 +114,9 @@
 	return (1);
 }
 
-void
-alarmtr()
+/*ARGSUSED*/
+static void
+alarmtr(int signo)
 {
 	alarm(0);
 	longjmp(jmpbuf, 1);
@@ -131,9 +127,8 @@
  *  hanging up...
  */
 void
-dn_disconnect()
+dn_disconnect(void)
 {
-
 	sleep(2);
 	if (FD > 0)
 		ioctl(FD, TIOCCDTR, 0);
@@ -141,9 +136,8 @@
 }
 
 void
-dn_abort()
+dn_abort(void)
 {
-
 	sleep(2);
 	if (child > 0)
 		kill(child, SIGKILL);
Index: courier.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/courier.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/courier.c -L usr.bin/tip/libacu/courier.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/courier.c
+++ usr.bin/tip/libacu/courier.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: courier.c,v 1.9 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: courier.c,v 1.15 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: courier.c,v 1.7 1997/02/11 09:24:16 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/courier.c,v 1.6 2003/04/06 08:30:25 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/courier.c,v 1.7 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)courier.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: courier.c,v 1.9 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: courier.c,v 1.15 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -54,20 +50,22 @@
 
 #define	MAXRETRY	5
 
-static	void sigALRM();
-static	int timeout = 0;
+static	int dialtimeout = 0;
 static	int connected = 0;
-static	jmp_buf timeoutbuf, intbuf;
-static	int coursync(), cour_connect(), cour_swallow();
-void	cour_nap();
-static void cour_write(int fd, char *cp, int n);
+static	jmp_buf timeoutbuf;
 
-void cour_disconnect(void);
+static void	sigALRM(int);
+static int	cour_swallow(char *);
+static int	cour_connect(void);
+static int	coursync(void);
+static void	cour_write(int, char *, int);
+static void	cour_nap(void);
+#ifdef DEBUG
+static void	cour_verbose_read(void);
+#endif
 
 int
-cour_dialer(num, acu)
-	char *num;
-	char *acu;
+cour_dialer(char *num, char *acu)
 {
 	char *cp;
 #ifdef ACULOG
@@ -111,19 +109,19 @@
 	cour_write(FD, "\r", 1);
 	connected = cour_connect();
 #ifdef ACULOG
-	if (timeout) {
-		(void)sprintf(line, "%ld second dial timeout",
+	if (dialtimeout) {
+		(void)snprintf(line, sizeof line, "%ld second dial timeout",
 			number(value(DIALTIMEOUT)));
 		logent(value(HOST), num, "cour", line);
 	}
 #endif
-	if (timeout)
+	if (dialtimeout)
 		cour_disconnect();
 	return (connected);
 }
 
 void
-cour_disconnect()
+cour_disconnect(void)
 {
 	 /* first hang up the modem*/
 	ioctl(FD, TIOCCDTR, 0);
@@ -134,29 +132,29 @@
 }
 
 void
-cour_abort()
+cour_abort(void)
 {
 	cour_write(FD, "\r", 1);	/* send anything to abort the call */
 	cour_disconnect();
 }
 
+/*ARGSUSED*/
 static void
-sigALRM()
+sigALRM(int signo)
 {
 	printf("\07timeout waiting for reply\n");
-	timeout = 1;
+	dialtimeout = 1;
 	longjmp(timeoutbuf, 1);
 }
 
 static int
-cour_swallow(match)
-	char *match;
+cour_swallow(char *match)
 {
 	sig_t f;
 	char c;
 
 	f = signal(SIGALRM, sigALRM);
-	timeout = 0;
+	dialtimeout = 0;
 	do {
 		if (*match =='\0') {
 			signal(SIGALRM, f);
@@ -187,16 +185,16 @@
 	char *msg;
 	int baud;
 } baud_msg[] = {
-	"",		B300,
-	" 1200",	B1200,
-	" 2400",	B2400,
-	" 9600",	B9600,
-	" 9600/ARQ",	B9600,
-	0,		0,
+	{ "",		B300 },
+	{ " 1200",	B1200 },
+	{ " 2400",	B2400 },
+	{ " 9600",	B9600 },
+	{ " 9600/ARQ",	B9600 },
+	{ 0,		0 },
 };
 
 static int
-cour_connect()
+cour_connect(void)
 {
 	char c;
 	int nc, nl, n;
@@ -210,7 +208,7 @@
 again:
 	nc = 0; nl = sizeof(dialer_buf)-1;
 	bzero(dialer_buf, sizeof(dialer_buf));
-	timeout = 0;
+	dialtimeout = 0;
 	for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
 		if (setjmp(timeoutbuf))
 			break;
@@ -269,7 +267,7 @@
  * the courier in sync.
  */
 static int
-coursync()
+coursync(void)
 {
 	int already = 0;
 	int len;
@@ -311,10 +309,7 @@
 }
 
 static void
-cour_write(fd, cp, n)
-int fd;
-char *cp;
-int n;
+cour_write(int fd, char *cp, int n)
 {
 #ifdef notdef
 	if (boolean(value(VERBOSE)))
@@ -330,7 +325,8 @@
 }
 
 #ifdef DEBUG
-cour_verbose_read()
+static void
+cour_verbose_read(void)
 {
 	int n = 0;
 	char buf[BUFSIZ];
@@ -346,8 +342,8 @@
 #endif
 
 /* Give the courier 50 milliseconds between characters */
-void
-cour_nap()
+static void
+cour_nap(void)
 {
 	struct timespec ts;
 
Index: biz31.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/biz31.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/biz31.c -L usr.bin/tip/libacu/biz31.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/biz31.c
+++ usr.bin/tip/libacu/biz31.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: biz31.c,v 1.6 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: biz31.c,v 1.10 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: biz31.c,v 1.5 1997/02/11 09:24:14 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/biz31.c,v 1.2 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/biz31.c,v 1.3 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)biz31.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: biz31.c,v 1.6 2001/10/24 18:38:58 millert Exp $";
+static char rcsid[] = "$OpenBSD: biz31.c,v 1.10 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -49,7 +45,14 @@
 #define MAXRETRY	3		/* sync up retry count */
 #define DISCONNECT_CMD	"\21\25\11\24"	/* disconnection string */
 
-static	void sigALRM();
+static int	biz_dialer(char *, char *);
+static int	bizsync(int);
+static int	echo(char *);
+static void	sigALRM(int);
+static int	detect(char *);
+static int	flush(char *);
+static int	bizsync(int);
+
 static	int timeout = 0;
 static	jmp_buf timeoutbuf;
 
@@ -59,8 +62,7 @@
  *	pulse dialing (mod = "w")
  */
 static int
-biz_dialer(num, mod)
-	char *num, *mod;
+biz_dialer(char *num, char *mod)
 {
 	int connected = 0;
 
@@ -94,7 +96,7 @@
 	if (timeout) {
 		char line[80];
 
-		(void)sprintf(line, "%ld second dial timeout",
+		(void)snprintf(line, sizeof line, "%ld second dial timeout",
 			number(value(DIALTIMEOUT)));
 		logent(value(HOST), num, "biz", line);
 	}
@@ -108,37 +110,34 @@
 	return (connected);
 }
 
-biz31w_dialer(num, acu)
-	char *num, *acu;
+int
+biz31w_dialer(char *num, char *acu)
 {
-
 	return (biz_dialer(num, "w"));
 }
 
-biz31f_dialer(num, acu)
-	char *num, *acu;
+int
+biz31f_dialer(char *num, char *acu)
 {
-
 	return (biz_dialer(num, "f"));
 }
 
-biz31_disconnect()
+void
+biz31_disconnect(void)
 {
-
-	write(FD, DISCONNECT_CMD, 4);
+	write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1);
 	sleep(2);
 	tcflush(FD, TCIOFLUSH);
 }
 
-biz31_abort()
+void
+biz31_abort(void)
 {
-
 	write(FD, "\33", 1);
 }
 
 static int
-echo(s)
-	char *s;
+echo(char *s)
 {
 	char c;
 
@@ -160,17 +159,16 @@
 	}
 }
 
+/*ARGSUSED*/
 static void
-sigALRM()
+sigALRM(int signo)
 {
-
 	timeout = 1;
 	longjmp(timeoutbuf, 1);
 }
 
 static int
-detect(s)
-	char *s;
+detect(char *s)
 {
 	sig_t f;
 	char c;
@@ -194,8 +192,7 @@
 }
 
 static int
-flush(s)
-	char *s;
+flush(char *s)
 {
 	sig_t f;
 	char c;
@@ -218,7 +215,7 @@
  *  call there are gory ways to simulate this.
  */
 static int
-bizsync(fd)
+bizsync(int fd)
 {
 #ifdef FIOCAPACITY
 	struct capacity b;
Index: t3000.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/t3000.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/t3000.c -L usr.bin/tip/libacu/t3000.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/t3000.c
+++ usr.bin/tip/libacu/t3000.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: t3000.c,v 1.9 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: t3000.c,v 1.14 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: t3000.c,v 1.5 1997/02/11 09:24:18 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/t3000.c,v 1.5 2003/04/06 08:30:25 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/t3000.c,v 1.6 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)t3000.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: t3000.c,v 1.9 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: t3000.c,v 1.14 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -55,18 +51,22 @@
 
 #define	MAXRETRY	5
 
-static	void sigALRM();
-static	int timeout = 0;
+static	int dialtimeout = 0;
 static	int connected = 0;
-static	jmp_buf timeoutbuf, intbuf;
-static	int t3000_sync(), t3000_connect(), t3000_swallow();
-static	void t3000_nap();
-static	int t3000_write(int fd, char *cp, int n);
+static	jmp_buf timeoutbuf;
+
+static void	sigALRM(int);
+static int	t3000_swallow(char *);
+static int	t3000_connect(void);
+static int	t3000_sync(void);
+static void	t3000_write(int, char *, int);
+static void	t3000_nap(void);
+#ifdef DEBUG
+static void	t3000_verbose_read(void);
+#endif
 
 int
-t3000_dialer(num, acu)
-	char *num;
-	char *acu;
+t3000_dialer(char *num, char *acu)
 {
 	char *cp;
 	struct termios cntrl;
@@ -110,19 +110,19 @@
 	t3000_write(FD, "\r", 1);
 	connected = t3000_connect();
 #ifdef ACULOG
-	if (timeout) {
-		(void)sprintf(line, "%ld second dial timeout",
+	if (dialtimeout) {
+		(void)snprintf(line, sizeof line, "%ld second dial timeout",
 			number(value(DIALTIMEOUT)));
 		logent(value(HOST), num, "t3000", line);
 	}
 #endif
-	if (timeout)
+	if (dialtimeout)
 		t3000_disconnect();
 	return (connected);
 }
 
 void
-t3000_disconnect()
+t3000_disconnect(void)
 {
 	 /* first hang up the modem*/
 	ioctl(FD, TIOCCDTR, 0);
@@ -133,29 +133,29 @@
 }
 
 void
-t3000_abort()
+t3000_abort(void)
 {
 	t3000_write(FD, "\r", 1);	/* send anything to abort the call */
 	t3000_disconnect();
 }
 
+/*ARGSUSED*/
 static void
-sigALRM()
+sigALRM(int signo)
 {
 	printf("\07timeout waiting for reply\n");
-	timeout = 1;
+	dialtimeout = 1;
 	longjmp(timeoutbuf, 1);
 }
 
 static int
-t3000_swallow(match)
-	char *match;
+t3000_swallow(char *match)
 {
 	sig_t f;
 	char c;
 
 	f = signal(SIGALRM, sigALRM);
-	timeout = 0;
+	dialtimeout = 0;
 	do {
 		if (*match =='\0') {
 			signal(SIGALRM, f);
@@ -192,24 +192,24 @@
 	int baud;
 	int baud2;
 } tbaud_msg[] = {
-	"",		B300,	0,
-	" 1200",	B1200,	0,
-	" 2400",	B2400,	0,
-	" 4800",	B4800,	0,
-	" 9600",	B9600,	0,
-	" 14400",	B19200,	B9600,
-	" 19200",	B19200,	B9600,
-	" 38400",	B38400,	B9600,
-	" 57600",	B38400,	B9600,
-	" 7512",	B9600,	0,
-	" 1275",	B2400,	0,
-	" 7200",	B9600,	0,
-	" 12000",	B19200,	B9600,
-	0,		0,	0,
+	{ "",		B300,	0 },
+	{ " 1200",	B1200,	0 },
+	{ " 2400",	B2400,	0 },
+	{ " 4800",	B4800,	0 },
+	{ " 9600",	B9600,	0 },
+	{ " 14400",	B19200,	B9600 },
+	{ " 19200",	B19200,	B9600 },
+	{ " 38400",	B38400,	B9600 },
+	{ " 57600",	B38400,	B9600 },
+	{ " 7512",	B9600,	0 },
+	{ " 1275",	B2400,	0 },
+	{ " 7200",	B9600,	0 },
+	{ " 12000",	B19200,	B9600 },
+	{ 0,		0,	0 },
 };
 
 static int
-t3000_connect()
+t3000_connect(void)
 {
 	char c;
 	int nc, nl, n;
@@ -223,7 +223,7 @@
 again:
 	nc = 0; nl = sizeof(dialer_buf)-1;
 	bzero(dialer_buf, sizeof(dialer_buf));
-	timeout = 0;
+	dialtimeout = 0;
 	for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
 		if (setjmp(timeoutbuf))
 			break;
@@ -282,7 +282,7 @@
  * the t3000 in sync.
  */
 static int
-t3000_sync()
+t3000_sync(void)
 {
 	int already = 0;
 	int len;
@@ -326,11 +326,8 @@
 	return (0);
 }
 
-static int
-t3000_write(fd, cp, n)
-int fd;
-char *cp;
-int n;
+static void
+t3000_write(int fd, char *cp, int n)
 {
 #ifdef notdef
 	if (boolean(value(VERBOSE)))
@@ -346,7 +343,8 @@
 }
 
 #ifdef DEBUG
-t3000_verbose_read()
+static void
+t3000_verbose_read(void)
 {
 	int n = 0;
 	char buf[BUFSIZ];
@@ -362,8 +360,8 @@
 #endif
 
 /* Give the t3000 50 milliseconds between characters */
-void
-t3000_nap()
+static void
+t3000_nap(void)
 {
 	struct timespec ts;
 
Index: hayes.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/hayes.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/hayes.c -L usr.bin/tip/libacu/hayes.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/hayes.c
+++ usr.bin/tip/libacu/hayes.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: hayes.c,v 1.13 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: hayes.c,v 1.6 1997/02/11 09:24:17 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/hayes.c,v 1.4 2003/04/06 08:30:25 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/hayes.c,v 1.6 2006/08/31 19:19:44 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)hayes.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: hayes.c,v 1.13 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -74,12 +70,9 @@
 
 #define	min(a,b)	((a < b) ? a : b)
 
-static	void error_rep(char c);
-static	void goodbye(void);
-static	void sigALRM();
-static	int timeout = 0;
+static	int dialtimeout = 0;
 static	jmp_buf timeoutbuf;
-static 	char gobble();
+
 #define DUMBUFLEN	40
 static char dumbuf[DUMBUFLEN];
 
@@ -89,10 +82,14 @@
 #define	FAILED		4
 static	int state = IDLE;
 
+static void	sigALRM(int);
+static char	gobble(char *);
+static void	error_rep(char);
+static void	goodbye(void);
+static int	hay_sync(void);
+
 int
-hay_dialer(num, acu)
-	char *num;
-	char *acu;
+hay_dialer(char *num, char *acu)
 {
 	char *cp;
 	int connected = 0;
@@ -135,20 +132,19 @@
 	}
 	tcflush(FD, TCIOFLUSH);
 #ifdef ACULOG
-	if (timeout) {
-		(void)sprintf(line, "%ld second dial timeout",
+	if (dialtimeout) {
+		(void)snprintf(line, sizeof line, "%ld second dial timeout",
 			number(value(DIALTIMEOUT)));
 		logent(value(HOST), num, "hayes", line);
 	}
 #endif
-	if (timeout)
+	if (dialtimeout)
 		hay_disconnect();	/* insurance */
 	return (connected);
 }
 
-
 void
-hay_disconnect()
+hay_disconnect(void)
 {
 	/* first hang up the modem*/
 #ifdef DEBUG
@@ -161,32 +157,31 @@
 }
 
 void
-hay_abort()
+hay_abort(void)
 {
-
 	write(FD, "\r", 1);	/* send anything to abort the call */
 	hay_disconnect();
 }
 
+/*ARGSUSED*/
 static void
-sigALRM()
+sigALRM(int signo)
 {
-
 	printf("\07timeout waiting for reply\n\r");
-	timeout = 1;
+	dialtimeout = 1;
 	longjmp(timeoutbuf, 1);
 }
 
 static char
-gobble(match)
-	char *match;
+gobble(char *match)
 {
 	char c;
 	sig_t f;
-	int i, status = 0;
+	size_t i;
+	int status = 0;
 
 	f = signal(SIGALRM, sigALRM);
-	timeout = 0;
+	dialtimeout = 0;
 #ifdef DEBUG
 	printf("\ngobble: waiting for %s\n", match);
 #endif
@@ -214,8 +209,7 @@
 }
 
 static void
-error_rep(c)
-	char c;
+error_rep(char c)
 {
 	printf("\n\r");
 	switch (c) {
@@ -227,23 +221,23 @@
 	case '1':
 		printf("CONNECT");
 		break;
-	
+
 	case '2':
 		printf("RING");
 		break;
-	
+
 	case '3':
 		printf("NO CARRIER");
 		break;
-	
+
 	case '4':
 		printf("ERROR in input");
 		break;
-	
+
 	case '5':
 		printf("CONNECT 1200");
 		break;
-	
+
 	default:
 		printf("Unknown Modem error: %c (0x%x)", c, c);
 	}
@@ -299,8 +293,8 @@
 
 #define MAXRETRY	5
 
-int
-hay_sync()
+static int
+hay_sync(void)
 {
 	int len, retry = 0;
 
Index: v831.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/v831.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/v831.c -L usr.bin/tip/libacu/v831.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/v831.c
+++ usr.bin/tip/libacu/v831.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: v831.c,v 1.6 2001/11/19 19:02:16 mpech Exp $	*/
+/*	$OpenBSD: v831.c,v 1.11 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: v831.c,v 1.5 1996/12/29 10:42:01 cgd Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/v831.c,v 1.3 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/v831.c,v 1.5 2006/08/31 19:19:44 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)v831.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: v831.c,v 1.6 2001/11/19 19:02:16 mpech Exp $";
+static const char rcsid[] = "$OpenBSD: v831.c,v 1.11 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -50,20 +46,19 @@
 #include "tip.h"
 #include <termios.h>
 
-void	v831_abort();
-static	void alarmtr();
-static	int dialit();
-static	char *sanitize();
-
 static jmp_buf jmpbuf;
-static int child = -1;
+static pid_t child = -1;
+
+static void	alarmtr(int);
+static int	dialit(char *, char *);
+static char *	sanitize(char *);
 
 int
-v831_dialer(num, acu)
-        char *num, *acu;
+v831_dialer(char *num, char *acu)
 {
-        int status, pid;
+        int status;
         int timelim;
+	pid_t pid;
 
         if (boolean(value(VERBOSE)))
                 printf("\nstarting call...");
@@ -122,8 +117,9 @@
         return (1);
 }
 
+/*ARGSUSED*/
 static void
-alarmtr()
+alarmtr(int signo)
 {
         alarm(0);
         longjmp(jmpbuf, 1);
@@ -134,7 +130,7 @@
  *  hanging up...
  */
 void
-v831_disconnect()
+v831_disconnect(void)
 {
 	struct termios	cntrl;
 
@@ -154,18 +150,17 @@
 }
 
 void
-v831_abort()
+v831_abort(void)
 {
-
 #ifdef DEBUG
         printf("[abort: AC=%d]\n", AC);
 #endif
         sleep(2);
         if (child > 0)
                 kill(child, SIGKILL);
-        if (AC > 0)
+        if (FD > 0)
                 ioctl(FD, TIOCNXCL, NULL);
-                close(AC);
+        close(AC);
         if (FD > 0)
                 ioctl(FD, TIOCCDTR, 0);
         close(FD);
@@ -181,7 +176,7 @@
 } vaconfig[] = {
 	{ "/dev/cua0",'4','0' },
 	{ "/dev/cua1",'4','1' },
-	{ 0 }
+	{ NULL, '\0', '\0' }
 };
 
 #define pc(x)	(c = x, write(AC,&c,1))
@@ -191,9 +186,7 @@
 #define ETX	03
 
 static int
-dialit(phonenum, acu)
-	char *phonenum;
-	char *acu;
+dialit(char *phonenum, char *acu)
 {
         struct vaconfig *vp;
 	struct termios cntrl;
@@ -253,8 +246,7 @@
 }
 
 static char *
-sanitize(s)
-	char *s;
+sanitize(char *s)
 {
         static char buf[128];
         char *cp;
Index: biz22.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/biz22.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/biz22.c -L usr.bin/tip/libacu/biz22.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/biz22.c
+++ usr.bin/tip/libacu/biz22.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: biz22.c,v 1.7 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: biz22.c,v 1.13 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: biz22.c,v 1.6 1997/02/11 09:24:11 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/biz22.c,v 1.2 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/biz22.c,v 1.3 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)biz22.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: biz22.c,v 1.7 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: biz22.c,v 1.13 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -48,12 +44,13 @@
 
 #define DISCONNECT_CMD	"\20\04"	/* disconnection string */
 
-static	void sigALRM();
-static	int timeout = 0;
+static	int dialtimeout = 0;
 static	jmp_buf timeoutbuf;
 
-static	int cmd(), detect();
-void	biz22_disconnect();
+static int	biz_dialer(char *, char *);
+static void	sigALRM(int);
+static int	cmd(char *);
+static int	detect(char *);
 
 /*
  * Dial up on a BIZCOMP Model 1022 with either
@@ -61,8 +58,7 @@
  *	pulse dialing (mod = "W")
  */
 static int
-biz_dialer(num, mod)
-	char *num, *mod;
+biz_dialer(char *num, char *mod)
 {
 	int connected = 0;
 	char cbuf[40];
@@ -77,7 +73,7 @@
 		printf("can't initialize bizcomp...");
 		return (0);
 	}
-	(void)strcpy(cbuf, "\02.\r");
+	(void)strlcpy(cbuf, "\02.\r", sizeof cbuf);
 	cbuf[1] = *mod;
 	if (cmd(cbuf)) {
 		printf("can't set dialing mode...");
@@ -98,61 +94,55 @@
 	 */
 	connected = detect("1\r");
 #ifdef ACULOG
-	if (timeout) {
+	if (dialtimeout) {
 		char line[80];
 
-		(void)sprintf(line, "%ld second dial timeout",
+		(void)snprintf(line, sizeof line, "%ld second dial timeout",
 			number(value(DIALTIMEOUT)));
 		logent(value(HOST), num, "biz1022", line);
 	}
 #endif
-	if (timeout)
+	if (dialtimeout)
 		biz22_disconnect();	/* insurance */
 	return (connected);
 }
 
 int
-biz22w_dialer(num, acu)
-	char *num, *acu;
+biz22w_dialer(char *num, char *acu)
 {
-
 	return (biz_dialer(num, "W"));
 }
 
 int
-biz22f_dialer(num, acu)
-	char *num, *acu;
+biz22f_dialer(char *num, char *acu)
 {
-
 	return (biz_dialer(num, "V"));
 }
 
 void
-biz22_disconnect()
+biz22_disconnect(void)
 {
-	write(FD, DISCONNECT_CMD, 4);
+	write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1);
 	sleep(2);
 	tcflush(FD, TCIOFLUSH);
 }
 
 void
-biz22_abort()
+biz22_abort(void)
 {
-
 	write(FD, "\02", 1);
 }
 
+/*ARGSUSED*/
 static void
-sigALRM()
+sigALRM(int signo)
 {
-
-	timeout = 1;
+	dialtimeout = 1;
 	longjmp(timeoutbuf, 1);
 }
 
 static int
-cmd(s)
-	char *s;
+cmd(char *s)
 {
 	sig_t f;
 	char c;
@@ -173,14 +163,13 @@
 }
 
 static int
-detect(s)
-	char *s;
+detect(char *s)
 {
 	sig_t f;
 	char c;
 
 	f = signal(SIGALRM, sigALRM);
-	timeout = 0;
+	dialtimeout = 0;
 	while (*s) {
 		if (setjmp(timeoutbuf)) {
 			biz22_abort();
@@ -194,5 +183,5 @@
 			return (0);
 	}
 	signal(SIGALRM, f);
-	return (timeout == 0);
+	return (dialtimeout == 0);
 }
Index: df.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/df.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/df.c -L usr.bin/tip/libacu/df.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/df.c
+++ usr.bin/tip/libacu/df.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: df.c,v 1.5 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: df.c,v 1.9 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/df.c,v 1.3 2003/04/06 08:30:25 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/df.c,v 1.4 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)df.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: df.c,v 1.5 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: df.c,v 1.9 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -51,29 +47,24 @@
 #include "tip.h"
 
 static jmp_buf Sjbuf;
-static void timeout();
-static void df_disconnect(void);
+
+static int	df_dialer(char *, char *, int);
+static void	alrm_timeout(int);
 
 int
-df02_dialer(num, acu)
-	char *num, *acu;
+df02_dialer(char *num, char *acu)
 {
-
 	return (df_dialer(num, acu, 0));
 }
 
 int
-df03_dialer(num, acu)
-	char *num, *acu;
+df03_dialer(char *num, char *acu)
 {
-
 	return (df_dialer(num, acu, 1));
 }
 
-int
-df_dialer(num, acu, df03)
-	char *num, *acu;
-	int df03;
+static int
+df_dialer(char *num, char *acu, int df03)
 {
 	int f = FD;
 	struct termios cntrl;
@@ -106,7 +97,7 @@
 			ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
 	}
 #endif
-	signal(SIGALRM, timeout);
+	signal(SIGALRM, alrm_timeout);
 	alarm(5 * strlen(num) + 10);
 	tcflush(f, TCIOFLUSH);
 	write(f, "\001", 1);
@@ -124,7 +115,7 @@
 	return (c == 'A');
 }
 
-static void
+void
 df_disconnect(void)
 {
 	write(FD, "\001", 1);
@@ -132,18 +123,15 @@
 	tcflush(FD, TCIOFLUSH);
 }
 
-
 void
-df_abort()
+df_abort(void)
 {
-
 	df_disconnect();
 }
 
-
+/*ARGSUSED*/
 static void
-timeout()
+alrm_timeout(int signo)
 {
-
 	longjmp(Sjbuf, 1);
 }
Index: v3451.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/libacu/v3451.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/libacu/v3451.c -L usr.bin/tip/libacu/v3451.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/libacu/v3451.c
+++ usr.bin/tip/libacu/v3451.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: v3451.c,v 1.6 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: v3451.c,v 1.9 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: v3451.c,v 1.6 1997/02/11 09:24:20 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/v3451.c,v 1.2 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/libacu/v3451.c,v 1.3 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)v3451.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: v3451.c,v 1.6 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: v3451.c,v 1.9 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -51,13 +47,14 @@
 
 static	jmp_buf Sjbuf;
 
-static	int expect(), notin(), prefix();
-static	void vawrite(), alarmtr();
+static void	vawrite(char *, int);
+static int	expect(char *);
+static void	alarmtr(int);
+static int	notin(char *, char *);
+static int	prefix(char *, char *);
 
 int
-v3451_dialer(num, acu)
-	char *num;
-	char *acu;
+v3451_dialer(char *num, char *acu)
 {
 	sig_t func;
 	int ok;
@@ -131,32 +128,26 @@
 }
 
 void
-v3451_disconnect()
+v3451_disconnect(void)
 {
-
 	close(FD);
 }
 
 void
-v3451_abort()
+v3451_abort(void)
 {
-
 	close(FD);
 }
 
 static void
-vawrite(cp, delay)
-	char *cp;
-	int delay;
+vawrite(char *cp, int delay)
 {
-
 	for (; *cp; sleep(delay), cp++)
 		write(FD, cp, 1);
 }
 
 static int
-expect(cp)
-	char *cp;
+expect(char *cp)
 {
 	char buf[300];
 	char *rp = buf;
@@ -193,17 +184,16 @@
 	return (1);
 }
 
+/*ARGSUSED*/
 static void
-alarmtr()
+alarmtr(int signo)
 {
 	longjmp(Sjbuf, 1);
 }
 
 static int
-notin(sh, lg)
-	char *sh, *lg;
+notin(char *sh, char *lg)
 {
-
 	for (; *lg; lg++)
 		if (prefix(sh, lg))
 			return (0);
@@ -211,8 +201,7 @@
 }
 
 static int
-prefix(s1, s2)
-	char *s1, *s2;
+prefix(char *s1, char *s2)
 {
 	char c;
 
Index: tip.h
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/tip.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/tip.h -L usr.bin/tip/tip/tip.h -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/tip.h
+++ usr.bin/tip/tip/tip.h
@@ -1,6 +1,6 @@
-/*	$OpenBSD: tip.h,v 1.11 2001/09/09 19:30:49 millert Exp $	*/
+/*	$OpenBSD: tip.h,v 1.27 2006/08/18 03:06:18 jason Exp $	*/
 /*	$NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $	*/
-/*	$FreeBSD: src/usr.bin/tip/tip/tip.h,v 1.10 2004/05/06 13:25:09 stefanf Exp $	*/
+/*	$FreeBSD: src/usr.bin/tip/tip/tip.h,v 1.11 2006/08/31 14:14:30 ru Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -15,11 +15,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -92,8 +88,8 @@
 long	DL;			/* line delay for file transfers to remote */
 long	CL;			/* char delay for file transfers to remote */
 long	ET;			/* echocheck timeout */
+long	LD;			/* line disc */
 short	HD;			/* this host is half duplex - do local echo */
-short	DC;			/* this host is directly connected. */
 
 /*
  * String value table
@@ -134,10 +130,10 @@
  */
 typedef
 	struct {
-		const char	*acu_name;
-		int		(*acu_dialer)(char *, char *);
-		void		(*acu_disconnect)(void);
-		void		(*acu_abort)(void);
+		char	*acu_name;
+		int	(*acu_dialer)(char *, char *);
+		void	(*acu_disconnect)(void);
+		void	(*acu_abort)(void);
 	}
 	acu_t;
 
@@ -151,6 +147,7 @@
  */
 
 #define value(v)	vtable[v].v_value
+#define lvalue(v)	(long)vtable[v].v_value
 
 #define	number(v)	((long)(v))
 #define	boolean(v)      ((short)(long)(v))
@@ -170,16 +167,16 @@
 
 typedef
 	struct {
-		char	e_char;		/* char to match on */
-		char	e_flags;	/* experimental, priviledged */
-		const char *e_help;	/* help string */
-		void 	(*e_func)(char);	/* command */
+		char	e_char;			/* char to match on */
+		char	e_flags;		/* experimental, privileged */
+		char	*e_help;		/* help string */
+		void	(*e_func)(int);		/* command */
 	}
 	esctable_t;
 
 #define NORM	00		/* normal protection, execute anyone */
 #define EXP	01		/* experimental, mark it with a `*' on help */
-#define PRIV	02		/* priviledged, root execute only */
+#define PRIV	02		/* privileged, root execute only */
 
 extern int	vflag;		/* verbose during reading of .tiprc file */
 extern int	noesc;		/* no escape `~' char */
@@ -228,6 +225,9 @@
 #define HALFDUPLEX	30
 #define	LECHO		31
 #define	PARITY		32
+#define	HARDWAREFLOW	33
+#define	LINEDISC	34
+#define	DC		35
 
 #define NOVAL	((value_t *)NULL)
 #define NOACU	((acu_t *)NULL)
@@ -238,6 +238,7 @@
 struct termios	term;		/* current mode of terminal */
 struct termios	defterm;	/* initial mode of terminal */
 struct termios	defchars;	/* current mode with initial chars */
+int	gotdefterm;
 
 FILE	*fscript;		/* FILE for scripting */
 
@@ -248,7 +249,8 @@
 int	vflag;			/* print .tiprc initialization sequence */
 int	noesc;			/* no `~' escape char */
 int	sfd;			/* for ~< operation */
-int	pid;			/* pid of tipout */
+pid_t	tipin_pid;		/* pid of tipin */
+pid_t	tipout_pid;		/* pid of tipout */
 uid_t	uid, euid;		/* real and effective user id's */
 gid_t	gid, egid;		/* real and effective group id's */
 int	stop;			/* stop transfer session flag */
@@ -263,7 +265,6 @@
 char	fname[PATH_MAX];	/* file name buffer for ~< */
 char	copyname[PATH_MAX];	/* file name buffer for ~> */
 char	ccc;			/* synchronization character */
-char	ch;			/* for tipout */
 char	*uucplock;		/* name of lock file for uucp's */
 
 int	odisc;			/* initial tty line discipline */
@@ -271,68 +272,82 @@
 
 extern	char *__progname;	/* program name */
 
-extern	char *ctrl(char);
-extern	char *vinterp(char *, char);
-extern	const char *connect(void);
-
-char	*sname(char *s);
-int	any(int cc, char *p);
-int	anyof(char *s1, char *s2);
-int	args(char *buf, char *a[], int num);
-int	escape(void);
-int	prompt(char *s, char *p, size_t sz);
-int	size(char *s);
-int	speed(int n);
-int	uu_lock(char *_ttyname);
-int	uu_unlock(char *_ttyname);
-int	vstring(char *s, char *v);
-long	hunt(char *name);
-void	cumain(int argc, char *argv[]);
+char	*con(void);
+char	*ctrl(char);
+char	*expand(char *);
+char	*getremote(char *);
+char	*interp(char *);
+int	any(int, char *);
+int	biz22w_dialer(char *, char *);
+int	biz22f_dialer(char *, char *);
+int	biz31w_dialer(char *, char *);
+int	biz31f_dialer(char *, char *);
+int	cour_dialer(char *, char *);
+int	df02_dialer(char *, char *);
+int	df03_dialer(char *, char *);
+int	dn_dialer(char *, char *);
+int	hay_dialer(char *, char *);
+int	prompt(char *, char *, size_t);
+size_t	size(char *);
+int	t3000_dialer(char *, char *);
+int	ttysetup(int);
+int	uu_lock(char *);
+int	uu_unlock(char *);
+int	v3451_dialer(char *, char *);
+int	v831_dialer(char *, char *);
+int	ven_dialer(char *, char *);
+int	vstring(char *, char *);
+long	hunt(char *);
+void	biz22_disconnect(void);
+void	biz22_abort(void);
+void	biz31_disconnect(void);
+void	biz31_abort(void);
+void	chdirectory(int);
+void	cleanup(int);
+void	consh(int);
+void	cour_abort(void);
+void	cour_disconnect(void);
+void	cu_put(int);
+void	cu_take(int);
+void	cumain(int, char **);
 void	daemon_uid(void);
-void	disconnect(char *reason);
-void	execute(char *s);
-char	*interp(char *s);
-void	logent(char *group, const char *num, const char *acu, const char *message);
+void	df_abort(void);
+void	df_disconnect(void);
+void	disconnect(char *);
+void	dn_abort(void);
+void	dn_disconnect(void);
+void	finish(int);
+void	genbrk(int);
+void	getfl(int);
+void	hay_abort(void);
+void	hay_disconnect(void);
+void	help(int);
+void	listvariables(int);
+void	logent(char *, char *, char *, char *);
 void	loginit(void);
-void	prtime(char *s, time_t a);
-void	parwrite(int fd, char *buf, int n);
+void	parwrite(int, char *, size_t);
+void	pipefile(int);
+void	pipeout(int);
 void	raw(void);
-void	send(int c);
-void	setparity(char *defparity);
+void	sendfile(int);
+void	setparity(char *);
 void	setscript(void);
+void	shell(int);
 void	shell_uid(void);
-void	tandem(char *option);
-void	tipabort(char *msg);
-void	tipin(void);
-void	tipout(void);
-void	transfer(char *buf, int fd, char *eofchars);
-void	transmit(FILE *fd, char *eofchars, char *command);
-void	ttysetup(int _speed);
-void	unraw(void);
-void	user_uid(void);
-void	vinit(void);
-void	vlex(char *s);
-
-int	biz31f_dialer(char *, char *);
-void	biz31f_disconnect(void);
-void	biz31f_abort(void);
-int	ven_dialer(char *, char *);
-void	ven_disconnect(void);
-void	ven_abort(void);
-int	hay_dialer(char *, char *);
-void	hay_disconnect(void);
-void	hay_abort(void);
-int	cour_dialer(char *, char *);
-void	cour_disconnect(void);
-void	cour_abort(void);
-int	t3000_dialer(char *, char *);
+void	suspend(int);
 void	t3000_disconnect(void);
 void	t3000_abort(void);
-int	v831_dialer(char *, char *);
+void	timeout(int);
+void	tipabort(char *);
+void	tipout(void);
+void	user_uid(void);
+void	unraw(void);
+void	v3451_abort(void);
+void	v3451_disconnect(void);
 void	v831_disconnect(void);
 void	v831_abort(void);
-
-void shell(char c), getfl(char c), sendfile(char c), chdirectory(char c);
-void finish(char c), help(char c), pipefile(char c), pipeout(char c);
-void consh(char c), variable(char c), cu_take(char c), cu_put(char c);
-void dollar(char c), genbrk(char c), suspend(char c), listvariables(char c);
+void	variable(int);
+void	ven_disconnect(void);
+void	ven_abort(void);
+void	vinit(void);
+void	vlex(char *);
Index: value.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/value.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/value.c -L usr.bin/tip/tip/value.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/value.c
+++ usr.bin/tip/tip/value.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: value.c,v 1.7 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: value.c,v 1.14 2006/03/17 22:02:58 moritz Exp $	*/
 /*	$NetBSD: value.c,v 1.6 1997/02/11 09:24:09 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/value.c,v 1.9 2004/05/06 13:25:09 stefanf Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/value.c,v 1.12 2007/02/23 18:41:12 jls Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)value.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: value.c,v 1.7 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: value.c,v 1.14 2006/03/17 22:02:58 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -48,19 +44,24 @@
 
 #define MIDDLE	35
 
-static value_t *vlookup();
-static int col = 0;
+static value_t *vlookup(char *);
+static void vassign(value_t *, char *);
+static void vtoken(char *);
+static void vprint(value_t *);
+static int vaccess(unsigned int, unsigned int);
+static char *vinterp(char *, int);
+
+static size_t col = 0;
 
 /*
  * Variable manipulation
  */
 void
-vinit()
+vinit(void)
 {
+	char file[FILENAME_MAX], *cp;
 	value_t *p;
-	char *cp;
-	FILE *f;
-	char file[FILENAME_MAX];
+	FILE *fp;
 
 	for (p = vtable; p->v_name != NULL; p++) {
 		if (p->v_type&ENVIRON)
@@ -73,22 +74,26 @@
 	 * Read the .tiprc file in the HOME directory
 	 *  for sets
 	 */
-	if (strlen(value(HOME)) + sizeof("/.tiprc") > sizeof(file)) {
+	cp = value(HOME);
+	if (cp == NULL) {
+		(void)fprintf(stderr, 
+		    "$HOME not set. Skipping check for ~/.tiprc\n");
+	} else if (strlen(cp) + sizeof("/.tiprc") > sizeof(file)) {
 		(void)fprintf(stderr, "Home directory path too long: %s\n",
-			value(HOME));
+		    value(HOME));
 	} else {
 		snprintf(file, sizeof file, "%s/.tiprc", value(HOME));
-		if ((f = fopen(file, "r")) != NULL) {
+		if ((fp = fopen(file, "r")) != NULL) {
 			char *tp;
 
-			while (fgets(file, sizeof(file)-1, f) != NULL) {
+			while (fgets(file, sizeof(file)-1, fp) != NULL) {
 				if (vflag)
 					printf("set %s", file);
 				if ((tp = strrchr(file, '\n')))
 					*tp = '\0';
 				vlex(file);
 			}
-			fclose(f);
+			fclose(fp);
 		}
 	}
 	/*
@@ -97,21 +102,16 @@
 	vtable[EXCEPTIONS].v_access &= ~(WRITE<<PUBLIC);
 }
 
-static int vaccess();
-
 /*VARARGS1*/
-void
-vassign(p, v)
-	value_t *p;
-	char *v;
+static void
+vassign(value_t *p, char *v)
 {
-
 	if (!vaccess(p->v_access, WRITE)) {
 		printf("access denied\r\n");
 		return;
 	}
-	switch (p->v_type&TMASK) {
 
+	switch (p->v_type&TMASK) {
 	case STRING:
 		if (p->v_value && equal(p->v_value, v))
 			return;
@@ -123,19 +123,16 @@
 		}
 		p->v_type &= ~(ENVIRON|INIT);
 		break;
-
 	case NUMBER:
 		if (number(p->v_value) == number(v))
 			return;
 		setnumber(p->v_value, number(v));
 		break;
-
 	case BOOL:
 		if (boolean(p->v_value) == (*v != '!'))
 			return;
 		setboolean(p->v_value, (*v != '!'));
 		break;
-
 	case CHAR:
 		if (character(p->v_value) == *v)
 			return;
@@ -144,22 +141,17 @@
 	p->v_access |= CHANGED;
 }
 
-static void vprint();
-static void vtoken();
-
 void
-vlex(s)
-	char *s;
+vlex(char *s)
 {
 	value_t *p;
+	char *cp;
 
 	if (equal(s, "all")) {
 		for (p = vtable; p->v_name; p++)
 			if (vaccess(p->v_access, READ))
 				vprint(p);
 	} else {
-		char *cp;
-
 		do {
 			if ((cp = vinterp(s, ' ')))
 				cp++;
@@ -174,19 +166,17 @@
 }
 
 static void
-vtoken(s)
-	char *s;
+vtoken(char *s)
 {
 	value_t *p;
 	char *cp;
-	char *expand();
 
 	if ((cp = strchr(s, '='))) {
 		*cp = '\0';
 		if ((p = vlookup(s))) {
 			cp++;
 			if (p->v_type&NUMBER)
-				vassign(p, atoi(cp));
+				vassign(p, (char *)(intptr_t)atoi(cp));
 			else {
 				if (strcmp(s, "record") == 0)
 					cp = expand(cp);
@@ -214,8 +204,7 @@
 }
 
 static void
-vprint(p)
-	value_t *p;
+vprint(value_t *p)
 {
 	char *cp;
 
@@ -265,10 +254,8 @@
 	}
 }
 
-
 static int
-vaccess(mode, rw)
-	unsigned mode, rw;
+vaccess(unsigned int mode, unsigned int rw)
 {
 	if (mode & (rw<<PUBLIC))
 		return (1);
@@ -278,8 +265,7 @@
 }
 
 static value_t *
-vlookup(s)
-	char *s;
+vlookup(char *s)
 {
 	value_t *p;
 
@@ -289,15 +275,13 @@
 	return (NULL);
 }
 
-char *
-vinterp(s, stop)
-	char *s;
-	char stop;
+static char *
+vinterp(char *s, int stop)
 {
 	char *p = s, c;
 	int num;
 
-	while ((c = *s++) && c != stop)
+	while ((c = *s++) && c != stop) {
 		switch (c) {
 
 		case '^':
@@ -338,6 +322,7 @@
 		default:
 			*p++ = c;
 		}
+	}
 	*p = '\0';
 	return (c == stop ? s-1 : NULL);
 }
@@ -346,18 +331,15 @@
  * assign variable s with value v (for NUMBER or STRING or CHAR types)
  */
 int
-vstring(s,v)
-	char *s;
-	char *v;
+vstring(char *s, char *v)
 {
 	value_t *p;
-	char *expand();
 
-	p = vlookup(s); 
+	p = vlookup(s);
 	if (p == 0)
 		return (1);
 	if (p->v_type&NUMBER)
-		vassign(p, atoi(v));
+		vassign(p, (char *)(intptr_t)atoi(v));
 	else {
 		if (strcmp(s, "record") == 0)
 			v = expand(v);
Index: tip.1
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/tip.1,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/tip.1 -L usr.bin/tip/tip/tip.1 -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/tip.1
+++ usr.bin/tip/tip/tip.1
@@ -1,4 +1,4 @@
-.\"	$OpenBSD: tip.1,v 1.19 2001/09/23 06:15:30 pvalchev Exp $
+.\"	$OpenBSD: tip.1,v 1.37 2006/06/07 06:35:59 mbalmer Exp $
 .\"	$NetBSD: tip.1,v 1.7 1994/12/08 09:31:05 jtc Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1993
@@ -12,11 +12,7 @@
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"	This product includes software developed by the University of
-.\"	California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
@@ -33,76 +29,39 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)tip.1	8.4 (Berkeley) 4/18/94
-.\" $FreeBSD: src/usr.bin/tip/tip/tip.1,v 1.22.10.2 2005/11/04 17:27:24 jdp Exp $
+.\" $FreeBSD: src/usr.bin/tip/tip/tip.1,v 1.27 2006/08/31 16:40:30 ru Exp $
 .\"
-.Dd September 9, 2001
+.Dd August 31, 2006
 .Dt TIP 1
 .Os
 .Sh NAME
-.Nm tip ,
-.Nm cu
+.Nm tip
 .Nd connect to a remote system
 .Sh SYNOPSIS
 .Nm
 .Op Fl nv
 .Op Fl Ar speed
 .Op Ar system-name
-.Nm cu
-.Op Fl ehot
-.Op Fl a Ar acu
-.Op Fl l Ar line
-.Op Fl s Ar speed
-.Op Fl Ar #
-.Op Ar phone-number
 .Sh DESCRIPTION
 The
 .Nm
-and
-.Nm cu
-utilities
-establish a full-duplex connection to another machine, giving the
+utility
+establishes a full-duplex connection to another machine, giving the
 appearance of being logged in directly on the remote CPU.
 It goes without saying that you must have a login on the machine (or
 equivalent) to which you wish to connect.
-The preferred interface is
-.Nm .
-The
-.Nm cu
-interface is included for those people attached to the
-.Dq call Ux
-command of
-.At v7 .
-This manual page
-describes only
-.Nm .
 .Pp
 The options are as follows:
-.Bl -tag -width ".Fl s Ar speed"
-.It Fl a Ar acu
-Set the acu.
-.It Fl l Ar line
-For
-.Nm cu ,
-specify the line to use.
-Either of the forms like
-.Pa tty00
-or
-.Pa /dev/tty00
-are permitted.
+.Bl -tag -width indent
 .It Fl n
 No escape (disable tilde).
-.It Fl s Ar speed
-For
-.Nm cu ,
-set the speed of the connection.
-Defaults to 9600.
 .It Fl v
 Set verbose mode.
 .El
 .Pp
 If
 .Ar speed
-is specified it will override any baudrate specified in the system
+is specified, it will override any baudrate specified in the system
 description being used.
 .Pp
 If neither
@@ -126,7 +85,7 @@
 with
 .Ar speed
 appended.
-E.g.,
+For example,
 .Nm Fl 1200
 will set
 .Ar system-name
@@ -140,19 +99,15 @@
 appearing as the first character of a line is an escape signal; the
 following are recognized:
 .Bl -tag -width indent
-.It Xo
-.Ic ~^D
-or
-.Ic ~.
-.Xc
-Drop the connection and exit (you may still be logged in on the remote
-machine).
+.It Ic ~^D No or Ic ~.
+Drop the connection and exit.
+Only the connection is dropped \(en the login session is not terminated.
 .It Ic ~c Op Ar name
 Change directory to
 .Ar name
-(no argument implies change to your home directory).
+(no argument implies change to home directory).
 .It Ic ~!
-Escape to a shell (exiting the shell will return you to
+Escape to a shell (exiting the shell will return to
 .Nm ) .
 .It Ic ~>
 Copy file from local to remote.
@@ -171,21 +126,21 @@
 Send a file to a remote
 .Ux
 host.
-The put command causes the remote
+This command causes the remote
 .Ux
-system to run the command string
-.Dq Nm cat Li \&> Ar to ,
-while
-.Nm
-sends it the
+system to run the following command string,
+sending it the
 .Ar from
-file.
+file:
+.Pp
+.Dl "stty -echo; cat > 'to'; stty echo"
+.Pp
 If the
 .Ar to
 file is not specified, the
 .Ar from
 file name is used.
-this command is actually a
+This command is actually a
 .Ux
 specific version of the
 .Ic ~>
@@ -194,15 +149,18 @@
 Take a file from a remote
 .Ux
 host.
-As in the put command, the
+As in the
+.Ic ~p
+command, the
 .Ar to
 file defaults to the
 .Ar from
 file name if it is not specified.
-The remote host executes the command string
-.Dq Nm cat Ar from ; Nm echo Li ^A
+The remote host executes the following command string
 to send the file to
-.Nm .
+.Nm :
+.Pp
+.Dl "cat 'from'; echo '' | tr '\e012' '\e01'"
 .It Ic ~|
 Pipe the output from a remote command to a local
 .Ux
@@ -221,12 +179,12 @@
 Fork a child process on the local system to perform special protocols
 such as
 .Tn XMODEM .
-The child program will be run with the following
-arrangement of file descriptors:
+The child program will be run with the following arrangement of
+file descriptors:
 .Bd -literal -offset indent
 0 <-> remote tty in
 1 <-> remote tty out
-2 <-> local tty out
+2 <-> local tty stderr
 .Ed
 .It Ic ~#
 Send a
@@ -234,7 +192,7 @@
 to the remote system.
 For systems which do not support the necessary
 .Fn ioctl
-call the break is simulated by a sequence of line speed changes and
+call, the break is simulated by a sequence of line speed changes and
 .Dv DEL
 characters.
 .It Ic ~s
@@ -259,7 +217,7 @@
 Get a summary of the tilde escapes.
 .El
 .Pp
-To find the system description and thus the operating characteristics
+To find the system description, and thus the operating characteristics
 of
 .Ar system-name ,
 .Nm
@@ -271,13 +229,13 @@
 If the environment variable
 .Ev REMOTE
 does not start with a
-.Ql \&/
+.Ql /
 it is assumed to be a system description, and is considered first.
 .It
 If the environment variable
 .Ev REMOTE
 begins with a
-.Ql \&/
+.Ql /
 it is assumed to be a path to a
 .Xr remote 5
 database, and the specified database is searched.
@@ -298,7 +256,7 @@
 capability is used in system descriptions to specify the baud rate
 with which to establish a connection.
 If the value specified is not suitable, the baud rate to be used may
-be given on the command line, e.g.,
+be given on the command line, e.g.\&
 .Dq Li "tip -300 mds" .
 .Pp
 When
@@ -310,10 +268,10 @@
 .Pp
 When
 .Nm
-prompts for an argument (e.g., during setup of a file transfer), the
+prompts for an argument, for example during setup of a file transfer, the
 line typed may be edited with the standard erase and kill characters.
 A null line in response to a prompt, or an interrupt, will abort the
-dialogue and return you to the remote machine.
+dialogue and return the user to the remote machine.
 .Pp
 The
 .Nm
@@ -323,7 +281,7 @@
 locking protocol used by
 .Xr uucico 8 Pq Pa ports/net/freebsd-uucp .
 .Pp
-During file transfers,
+During file transfers
 .Nm
 provides a running count of the number of lines transferred.
 When using the
@@ -336,8 +294,8 @@
 .Va eofwrite
 variables are used to recognize end-of-file when reading, and specify
 end-of-file when writing (see below).
-File transfers normally depend on tandem mode for flow control.
-If the remote system does not support tandem mode,
+File transfers normally depend on hardwareflow or tandem mode for flow control.
+If the remote system does not support hardwareflow or tandem mode,
 .Va echocheck
 may be set to indicate that
 .Nm
@@ -408,28 +366,27 @@
 Variables may be initialized at run time by placing set commands
 (without the
 .Ic ~s
-prefix in a file
-.Pa .tiprc
-in one's home directory).
-The
+prefix) in the initialization file
+.Pa ~/.tiprc ;
+the
 .Fl v
-option causes
+option additionally causes
 .Nm
 to display the sets as they are made.
 Certain common variables have abbreviations.
 The following is a list of common variables, their abbreviations, and
 their default values:
 .Bl -tag -width indent
-.It Va beautify
-.Pq Vt bool
-Discard unprintable characters when a session is being
-scripted; abbreviated
-.Va be .
 .It Va baudrate
 .Pq Vt num
 The baud rate at which the connection was established;
 abbreviated
 .Va ba .
+.It Va beautify
+.Pq Vt bool
+Discard unprintable characters when a session is being
+scripted; abbreviated
+.Va be .
 .It Va dialtimeout
 .Pq Vt num
 When dialing a phone number, the time (in seconds) to wait for a
@@ -485,10 +442,21 @@
 The amount of data (in bytes) to buffer between file system
 writes when receiving files; abbreviated
 .Va fr .
+.It Va hardwareflow
+.Pq Vt bool
+Whether hardware flow control (CRTSCTS) is enabled for the
+connection; abbreviated
+.Va hf ;
+default value is
+.Cm off .
 .It Va host
 .Pq Vt str
 The name of the host to which you are connected; abbreviated
 .Va ho .
+.It Va linedisc
+.Pq Vt num
+The line discipline to use; abbreviated
+.Va ld .
 .It Va prompt
 .Pq Vt char
 The character which indicates an end-of-line on the remote
@@ -514,8 +482,7 @@
 The input character used to toggle uppercase mapping mode;
 abbreviated
 .Va rc ;
-default value is
-.Ql ^A .
+not set by default.
 .It Va record
 .Pq Vt str
 The name of the file in which a session script is recorded;
@@ -554,6 +521,19 @@
 default value is
 .Cm false .
 Each tab is expanded to 8 spaces.
+.It Va tandem
+.Pq Vt bool
+Use XON/XOFF flow control to throttle data from the remote host;
+abbreviated
+.Va ta .
+The default value is
+.Cm true
+unless the
+.Va nt
+capability has been specified in
+.Pa /etc/remote ,
+in which case the default value is
+.Cm false .
 .It Va verbose
 .Pq Vt bool
 Verbose mode; abbreviated
@@ -567,11 +547,6 @@
 .El
 .Sh ENVIRONMENT
 .Bl -tag -width indent
-.It Ev SHELL
-The name of the shell to use for the
-.Ic ~!
-command; default value is
-.Pa /bin/sh .
 .It Ev HOME
 The home directory to use for the
 .Ic ~c
@@ -580,29 +555,34 @@
 The default value for
 .Ar system-name
 if none is specified via the command line.
-.It Ev REMOTE
-A system description, or an absolute path to a
-.Xr remote 5
-system description database.
 .It Ev PHONES
 A path to a
 .Xr phones 5
 database.
+.It Ev REMOTE
+A system description, or an absolute path to a
+.Xr remote 5
+system description database.
+.It Ev SHELL
+The name of the shell to use for the
+.Ic ~!
+command; default value is
+.Dq Li /bin/sh .
 .El
 .Sh FILES
 .Bl -tag -width ".Pa /var/spool/lock/LCK..*" -compact
-.It Pa /etc/remote
-global
-.Xr remote 5
-database
-.It Pa /etc/phones
-default
-.Xr phones 5
-file
 .It Pa ~/.tiprc
 initialization file
 .It Pa tip.record
 record file
+.It Pa /etc/phones
+default
+.Xr phones 5
+file
+.It Pa /etc/remote
+global
+.Xr remote 5
+database
 .It Pa /var/log/aculog
 line access log
 .It Pa /var/spool/lock/LCK..*
@@ -610,6 +590,7 @@
 .Xr uucp 1 Pq Pa ports/net/freebsd-uucp
 .El
 .Sh SEE ALSO
+.Xr cu 1 ,
 .Xr phones 5 ,
 .Xr remote 5
 .Sh HISTORY
Index: log.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/log.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/log.c -L usr.bin/tip/tip/log.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/log.c
+++ usr.bin/tip/tip/log.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: log.c,v 1.5 2001/09/09 19:30:49 millert Exp $	*/
+/*	$OpenBSD: log.c,v 1.8 2006/03/16 19:32:46 deraadt Exp $	*/
 /*	$NetBSD: log.c,v 1.4 1994/12/24 17:56:28 cgd Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/log.c,v 1.5 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/log.c,v 1.6 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)log.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: log.c,v 1.5 2001/09/09 19:30:49 millert Exp $";
+static const char rcsid[] = "$OpenBSD: log.c,v 1.8 2006/03/16 19:32:46 deraadt Exp $";
 #endif
 #endif /* not lint */
 
@@ -53,9 +49,7 @@
  * Log file maintenance routines
  */
 void
-logent(group, num, acu, message)
-	char *group;
-	const char *num, *acu, *message;
+logent(char *group, char *num, char *acu, char *message)
 {
 	char *user, *timestamp;
 	struct passwd *pwd;
@@ -89,7 +83,7 @@
 }
 
 void
-loginit()
+loginit(void)
 {
 	flog = fopen(value(LOG), "a");
 	if (flog == NULL)
Index: cu.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/cu.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/cu.c -L usr.bin/tip/tip/cu.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/cu.c
+++ usr.bin/tip/tip/cu.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: cu.c,v 1.10 2001/09/26 06:07:28 pvalchev Exp $	*/
+/*	$OpenBSD: cu.c,v 1.19 2006/05/25 08:41:52 jmc Exp $	*/
 /*	$NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,29 +31,26 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/cu.c,v 1.5 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/cu.c,v 1.7 2006/09/07 19:48:52 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cu.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: cu.c,v 1.10 2001/09/26 06:07:28 pvalchev Exp $";
+static const char rcsid[] = "$OpenBSD: cu.c,v 1.19 2006/05/25 08:41:52 jmc Exp $";
 #endif
 #endif /* not lint */
 
 #include "tip.h"
 
-void	cleanup();
-void	cuusage();
+static void	cuusage(void);
 
 /*
  * Botch the interface to look like cu's
  */
 void
-cumain(argc, argv)
-	int argc;
-	char *argv[];
+cumain(int argc, char *argv[])
 {
-	int ch, i;
+	int ch, i, parity;
 	long l;
 	char *cp;
 	static char sbuf[12];
@@ -66,8 +59,28 @@
 		cuusage();
 	CU = DV = NOSTR;
 	BR = DEFBR;
-	while ((ch = getopt(argc, argv, "a:l:s:htoe0123456789")) != -1) {
-		switch(ch) {
+	parity = 0;	/* none */
+
+	/*
+	 * We want to accept -# as a speed.  It's easiest to look through
+	 * the arguments, replace -# with -s#, and let getopt() handle it.
+	 */
+	for (i = 1; i < argc; i++) {
+		if (argv[i][0] == '-' &&
+		    argv[i][1] >= '0' && argv[i][1] <= '9') {
+			asprintf(&cp, "-s%s", argv[i] + 1);
+			if (cp == NULL) {
+				fprintf(stderr,
+				    "%s: cannot convert -# to -s#\n",
+				    __progname);
+				exit(3);
+			}
+			argv[i] = cp;
+		}
+	}
+
+	while ((ch = getopt(argc, argv, "a:l:s:htoe")) != -1) {
+		switch (ch) {
 		case 'a':
 			CU = optarg;
 			break;
@@ -85,8 +98,7 @@
 			break;
 		case 's':
 			l = strtol(optarg, &cp, 10);
-			if (*cp != '\0' || l < 0 || l >= INT_MAX ||
-			    speed((int)l) == 0) {
+			if (*cp != '\0' || l < 0 || l >= INT_MAX) {
 				fprintf(stderr, "%s: unsupported speed %s\n",
 				    __progname, optarg);
 				exit(3);
@@ -101,17 +113,16 @@
 			HW = 1, DU = -1;
 			break;
 		case 'o':
-			setparity("odd");
+			if (parity != 0)
+				parity = 0;	/* -e -o */
+			else
+				parity = 1;	/* odd */
 			break;
 		case 'e':
-			setparity("even");
-			break;
-		case '0': case '1': case '2': case '3': case '4':
-		case '5': case '6': case '7': case '8': case '9':
-			if (CU)
-				CU[strlen(CU)-1] = ch;
-			if (DV)
-				DV[strlen(DV)-1] = ch;
+			if (parity != 0)
+				parity = 0;	/* -o -e */
+			else
+				parity = -1;	/* even */
 			break;
 		default:
 			cuusage();
@@ -136,6 +147,7 @@
 	signal(SIGQUIT, cleanup);
 	signal(SIGHUP, cleanup);
 	signal(SIGTERM, cleanup);
+	signal(SIGCHLD, SIG_DFL);
 
 	/*
 	 * The "cu" host name is used to define the
@@ -155,24 +167,44 @@
 	loginit();
 	user_uid();
 	vinit();
-	setparity("none");
+	switch (parity) {
+	case -1:
+		setparity("even");
+		break;
+	case 1:
+		setparity("odd");
+		break;
+	default:
+		setparity("none");
+		break;
+	}
 	setboolean(value(VERBOSE), FALSE);
-	if (HW)
-		ttysetup(speed(BR));
-	if (connect()) {
+	if (HW && ttysetup(BR)) {
+		fprintf(stderr, "%s: unsupported speed %ld\n",
+		    __progname, BR);
+		daemon_uid();
+		(void)uu_unlock(uucplock);
+		exit(3);
+	}
+	if (con()) {
 		printf("Connect failed\n");
 		daemon_uid();
 		(void)uu_unlock(uucplock);
 		exit(1);
 	}
-	if (!HW)
-		ttysetup(speed(BR));
+	if (!HW && ttysetup(BR)) {
+		fprintf(stderr, "%s: unsupported speed %ld\n",
+		    __progname, BR);
+		daemon_uid();
+		(void)uu_unlock(uucplock);
+		exit(3);
+	}
 }
 
-void
-cuusage()
+static void
+cuusage(void)
 {
-	fprintf(stderr, "usage: cu [-ehot] [-a acu] [-l line] [-s speed] [-#] "
-	    "[phone-number]\n");
+	fprintf(stderr, "usage: cu [-ehot] [-a acu] [-l line] "
+	    "[-s speed | -speed] [phone-number]\n");
 	exit(8);
 }
Index: tip.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/tip.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/tip.c -L usr.bin/tip/tip/tip.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/tip.c
+++ usr.bin/tip/tip/tip.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: tip.c,v 1.15 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: tip.c,v 1.30 2006/08/18 03:06:18 jason Exp $	*/
 /*	$NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,10 +31,10 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/tip.c,v 1.16 2003/04/06 08:30:25 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/tip.c,v 1.18 2006/08/31 19:19:44 ru Exp $");
 
 #ifndef lint
-static char copyright[] =
+static const char copyright[] =
 "@(#) Copyright (c) 1983, 1993\n\
 	The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
@@ -46,7 +42,7 @@
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)tip.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: tip.c,v 1.15 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: tip.c,v 1.30 2006/08/18 03:06:18 jason Exp $";
 #endif
 #endif /* not lint */
 
@@ -59,30 +55,21 @@
 #include "tip.h"
 #include "pathnames.h"
 
-/*
- * Baud rate mapping table
- */
-int rates[] = {
-	0, 50, 75, 110, 134, 150, 200, 300, 600,
-	1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1
-};
-
 int	disc = TTYDISC;		/* tip normally runs this way */
-void	intprompt();
-void	timeout();
-void	cleanup();
 char	PNbuf[256];			/* This limits the size of a number */
 
+static void	intprompt(int);
+static void	tipin(void);
+static int	escape(void);
+
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char *argv[])
 {
-	char *system = NOSTR;
+	char *sys = NOSTR, sbuf[12], *p;
 	int i;
-	char *p;
-	const char *p2;
-	char sbuf[12];
+
+	/* XXX preserve previous braindamaged behavior */
+	setboolean(value(DC), TRUE);
 
 	gid = getgid();
 	egid = getegid();
@@ -105,7 +92,7 @@
 
 	for (; argc > 1; argv++, argc--) {
 		if (argv[1][0] != '-')
-			system = argv[1];
+			sys = argv[1];
 		else switch (argv[1][1]) {
 
 		case 'v':
@@ -128,34 +115,35 @@
 		}
 	}
 
-	if (system == NOSTR)
+	if (sys == NOSTR)
 		goto notnumber;
-	if (isalpha(*system))
+	if (isalpha(*sys))
 		goto notnumber;
 	/*
 	 * System name is really a phone number...
 	 * Copy the number then stomp on the original (in case the number
 	 *	is private, we don't want 'ps' or 'w' to find it).
 	 */
-	if (strlen(system) > sizeof PNbuf - 1) {
+	if (strlen(sys) > sizeof PNbuf - 1) {
 		fprintf(stderr, "%s: phone number too long (max = %d bytes)\n",
 			__progname, (int)sizeof(PNbuf) - 1);
 		exit(1);
 	}
-	strncpy( PNbuf, system, sizeof PNbuf - 1 );
-	for (p = system; *p; p++)
+	strlcpy(PNbuf, sys, sizeof PNbuf - 1);
+	for (p = sys; *p; p++)
 		*p = '\0';
 	PN = PNbuf;
 	(void)snprintf(sbuf, sizeof(sbuf), "tip%ld", BR);
-	system = sbuf;
+	sys = sbuf;
 
 notnumber:
 	(void)signal(SIGINT, cleanup);
 	(void)signal(SIGQUIT, cleanup);
 	(void)signal(SIGHUP, cleanup);
 	(void)signal(SIGTERM, cleanup);
+	(void)signal(SIGCHLD, SIG_DFL);
 
-	if ((i = hunt(system)) == 0) {
+	if ((i = hunt(sys)) == 0) {
 		printf("all ports busy\n");
 		exit(3);
 	}
@@ -184,29 +172,32 @@
 		PH = _PATH_PHONES;
 	vinit();				/* init variables */
 	setparity("none");			/* set the parity table */
-	if ((i = speed(number(value(BAUDRATE)))) == 0) {
-		printf("%s: bad baud rate %ld\n", __progname,
-		    number(value(BAUDRATE)));
-		daemon_uid();
-		(void)uu_unlock(uucplock);
-		exit(3);
-	}
 
 	/*
 	 * Hardwired connections require the
 	 *  line speed set before they make any transmissions
 	 *  (this is particularly true of things like a DF03-AC)
 	 */
-	if (HW)
-		ttysetup(i);
-	if ((p2 = connect())) {
-		printf("\07%s\n[EOT]\n", p2);
+	if (HW && ttysetup(number(value(BAUDRATE)))) {
+		fprintf(stderr, "%s: bad baud rate %ld\n", __progname,
+		    number(value(BAUDRATE)));
+		daemon_uid();
+		(void)uu_unlock(uucplock);
+		exit(3);
+	}
+	if ((p = con())) {
+		printf("\07%s\n[EOT]\n", p);
 		daemon_uid();
 		(void)uu_unlock(uucplock);
 		exit(1);
 	}
-	if (!HW)
-		ttysetup(i);
+	if (!HW && ttysetup(number(value(BAUDRATE)))) {
+		fprintf(stderr, "%s: bad baud rate %ld\n", __progname,
+		    number(value(BAUDRATE)));
+		daemon_uid();
+		(void)uu_unlock(uucplock);
+		exit(3);
+	}
 cucommon:
 	/*
 	 * From here down the code is shared with
@@ -216,15 +207,16 @@
 	i = fcntl(FD, F_GETFL);
 	if (i == -1) {
 		perror("fcntl");
-		cleanup();
+		cleanup(0);
 	}
 	i = fcntl(FD, F_SETFL, i & ~O_NONBLOCK);
 	if (i == -1) {
 		perror("fcntl");
-		cleanup();
+		cleanup(0);
 	}
 
 	tcgetattr(0, &defterm);
+	gotdefterm = 1;
 	term = defterm;
 	term.c_lflag &= ~(ICANON|IEXTEN|ECHO);
 	term.c_iflag &= ~(INPCK|ICRNL);
@@ -233,13 +225,18 @@
 	term.c_cc[VTIME] = 0;
 	defchars = term;
 	term.c_cc[VINTR] = term.c_cc[VQUIT] = term.c_cc[VSUSP] =
-		term.c_cc[VDSUSP] = term.c_cc[VDISCARD] = 
-	 	term.c_cc[VLNEXT] = _POSIX_VDISABLE;
+	    term.c_cc[VDSUSP] = term.c_cc[VDISCARD] =
+	    term.c_cc[VLNEXT] = _POSIX_VDISABLE;
 	raw();
 
 	pipe(fildes); pipe(repdes);
 	(void)signal(SIGALRM, timeout);
 
+	if (value(LINEDISC) != TTYDISC) {
+		int ld = (int)(intptr_t)value(LINEDISC);
+		ioctl(FD, TIOCSETD, &ld);
+	}		
+
 	/*
 	 * Everything's set up now:
 	 *	connection established (hardwired or dialup)
@@ -248,7 +245,8 @@
 	 * so, fork one process for local side and one for remote.
 	 */
 	printf(cumode ? "Connected\r\n" : "\07connected\r\n");
-	if ((pid = fork()))
+	tipin_pid = getpid();
+	if ((tipout_pid = fork()))
 		tipin();
 	else
 		tipout();
@@ -257,13 +255,17 @@
 }
 
 void
-cleanup()
+cleanup(int signo)
 {
-
 	daemon_uid();
 	(void)uu_unlock(uucplock);
 	if (odisc)
-		ioctl(0, TIOCSETD, (char *)&odisc);
+		ioctl(0, TIOCSETD, &odisc);
+	unraw();
+	if (signo && tipout_pid) {
+		kill(tipout_pid, signo);
+		wait(NULL);
+	}
 	exit(0);
 }
 
@@ -278,7 +280,7 @@
 static int uidswapped;
 
 void
-user_uid()
+user_uid(void)
 {
 	if (uidswapped == 0) {
 		seteuid(uid);
@@ -287,7 +289,7 @@
 }
 
 void
-daemon_uid()
+daemon_uid(void)
 {
 
 	if (uidswapped) {
@@ -297,7 +299,7 @@
 }
 
 void
-shell_uid()
+shell_uid(void)
 {
 	setegid(gid);
 	seteuid(uid);
@@ -307,7 +309,7 @@
  * put the controlling keyboard into raw mode
  */
 void
-raw()
+raw(void)
 {
 	tcsetattr(0, TCSADRAIN, &term);
 }
@@ -317,9 +319,10 @@
  * return keyboard to normal mode
  */
 void
-unraw()
+unraw(void)
 {
-	tcsetattr(0, TCSADRAIN, &defterm);
+	if (gotdefterm)
+		tcsetattr(0, TCSADRAIN, &defterm);
 }
 
 static	jmp_buf promptbuf;
@@ -330,10 +333,7 @@
  *  normal erase and kill characters.
  */
 int
-prompt(s, p, sz)
-	char *s;
-	char *p;
-	size_t sz;
+prompt(char *s, char *p, size_t sz)
 {
 	int c;
 	char *b = p;
@@ -358,10 +358,10 @@
 /*
  * Interrupt service routine during prompting
  */
-void
-intprompt()
+/*ARGSUSED*/
+static void
+intprompt(int signo)
 {
-
 	(void)signal(SIGINT, SIG_IGN);
 	stoprompt = 1;
 	printf("\r\n");
@@ -371,10 +371,12 @@
 /*
  * ****TIPIN   TIPIN****
  */
-void
-tipin()
+static void
+tipin(void)
 {
-	char gch, bol = 1;
+	int bol = 1;
+	int gch;
+	char ch;
 
 	/*
 	 * Kinda klugey here...
@@ -390,6 +392,7 @@
 
 	while (1) {
 		gch = getchar()&STRIP_PAR;
+		/* XXX does not check for EOF */
 		if ((gch == character(value(ESCAPE))) && bol) {
 			if (!noesc) {
 				if (!(gch = escape()))
@@ -400,7 +403,8 @@
 			continue;
 		} else if (gch == '\r') {
 			bol = 1;
-			parwrite(FD, &gch, 1);
+			ch = gch;
+			parwrite(FD, &ch, 1);
 			if (boolean(value(HALFDUPLEX)))
 				printf("\r\n");
 			continue;
@@ -409,9 +413,10 @@
 		bol = any(gch, value(EOL));
 		if (boolean(value(RAISE)) && islower(gch))
 			gch = toupper(gch);
-		parwrite(FD, &gch, 1);
+		ch = gch;
+		parwrite(FD, &ch, 1);
 		if (boolean(value(HALFDUPLEX)))
-			printf("%c", gch);
+			printf("%c", ch);
 	}
 }
 
@@ -421,14 +426,15 @@
  * Escape handler --
  *  called on recognition of ``escapec'' at the beginning of a line
  */
-int
-escape()
+static int
+escape(void)
 {
-	char gch;
+	int gch;
 	esctable_t *p;
 	char c = character(value(ESCAPE));
 
 	gch = (getchar()&STRIP_PAR);
+	/* XXX does not check for EOF */
 	for (p = etable; p->e_char; p++)
 		if (p->e_char == gch) {
 			if ((p->e_flags&PRIV) && uid)
@@ -444,21 +450,7 @@
 }
 
 int
-speed(n)
-	int n;
-{
-	int *p;
-
-	for (p = rates; *p != -1;  p++)
-		if (*p == n)
-			return n;
-	return 0;
-}
-
-int
-any(cc, p)
-	int cc;
-	char *p;
+any(int cc, char *p)
 {
 	char c = cc;
 	while (p && *p)
@@ -467,11 +459,10 @@
 	return (0);
 }
 
-int
-size(s)
-	char *s;
+size_t
+size(char *s)
 {
-	int i = 0;
+	size_t i = 0;
 
 	while (s && *s++)
 		i++;
@@ -479,8 +470,7 @@
 }
 
 char *
-interp(s)
-	char *s;
+interp(char *s)
 {
 	static char buf[256];
 	char *p = buf, c, *q;
@@ -505,8 +495,7 @@
 }
 
 char *
-ctrl(c)
-	char c;
+ctrl(char c)
 {
 	static char s[3];
 
@@ -525,8 +514,7 @@
  * Help command
  */
 void
-help(c)
-	char c;
+help(int c)
 {
 	esctable_t *p;
 
@@ -543,19 +531,20 @@
 /*
  * Set up the "remote" tty's state
  */
-void
-ttysetup(speed)
-	int speed;
+int
+ttysetup(int speed)
 {
 	struct termios	cntrl;
 
-	tcgetattr(FD, &cntrl);
-	cfsetospeed(&cntrl, speed);
-	cfsetispeed(&cntrl, speed);
+	if (tcgetattr(FD, &cntrl))
+		return (-1);
+	cfsetspeed(&cntrl, speed);
 	cntrl.c_cflag &= ~(CSIZE|PARENB);
 	cntrl.c_cflag |= CS8;
 	if (boolean(value(DC)))
 		cntrl.c_cflag |= CLOCAL;
+	if (boolean(value(HARDWAREFLOW)))
+		cntrl.c_cflag |= CRTSCTS;
 	cntrl.c_iflag &= ~(ISTRIP|ICRNL);
 	cntrl.c_oflag &= ~OPOST;
 	cntrl.c_lflag &= ~(ICANON|ISIG|IEXTEN|ECHO);
@@ -563,7 +552,7 @@
 	cntrl.c_cc[VTIME] = 0;
 	if (boolean(value(TAND)))
 		cntrl.c_iflag |= IXOFF;
-	tcsetattr(FD, TCSAFLUSH, &cntrl);
+	return (tcsetattr(FD, TCSAFLUSH, &cntrl));
 }
 
 static char partab[0200];
@@ -574,12 +563,9 @@
  * with the right parity and output it.
  */
 void
-parwrite(fd, buf, n)
-	int fd;
-	char *buf;
-	int n;
+parwrite(int fd, char *buf, size_t n)
 {
-	int i;
+	size_t i;
 	char *bp;
 
 	bp = buf;
@@ -600,8 +586,7 @@
  * Build a parity table with appropriate high-order bit.
  */
 void
-setparity(defparity)
-	char *defparity;
+setparity(char *defparity)
 {
 	int i, flip, clr, set;
 	char *parity;
@@ -629,5 +614,5 @@
 		(void) fflush(stderr);
 	}
 	for (i = 0; i < 0200; i++)
-		partab[i] = (evenpartab[i] ^ flip | set) & clr;
+		partab[i] = ((evenpartab[i] ^ flip) | set) & clr;
 }
Index: Makefile
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/Makefile -L usr.bin/tip/tip/Makefile -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/Makefile
+++ usr.bin/tip/tip/Makefile
@@ -1,5 +1,5 @@
-#	$OpenBSD: Makefile,v 1.9 2001/09/23 06:15:30 pvalchev Exp $
-# $FreeBSD: src/usr.bin/tip/tip/Makefile,v 1.18 2002/07/12 14:49:25 ru Exp $
+#	$OpenBSD: Makefile,v 1.11 2006/05/25 08:41:52 jmc Exp $
+# $FreeBSD: src/usr.bin/tip/tip/Makefile,v 1.20 2006/09/01 17:09:09 ru Exp $
 #
 # Files are:
 #	/etc/remote		remote host description file
@@ -33,11 +33,10 @@
 
 PROG=	tip
 LINKS=	${BINDIR}/tip ${BINDIR}/cu
-MLINKS=	tip.1 cu.1
-CFLAGS+=-I${.CURDIR} \
-	-DDEFBR=9600 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE -DCONNECT \
-	-DV831 -DVENTEL -DHAYES -DCOURIER -DT3000
-WARNS?=	0
+MAN=	tip.1 cu.1
+CFLAGS+=-I${.CURDIR} -DDEFBR=9600 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE \
+	-DCONNECT -DV831 -DVENTEL -DHAYES -DCOURIER -DT3000
+WARNS?=	3
 .PATH:	${.CURDIR}/../libacu
 SRCS=	acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c \
 	remote.c tip.c tipout.c uucplock.c value.c vars.c \
Index: hunt.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/hunt.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/hunt.c -L usr.bin/tip/tip/hunt.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/hunt.c
+++ usr.bin/tip/tip/hunt.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: hunt.c,v 1.8 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: hunt.c,v 1.13 2006/03/17 19:39:46 deraadt Exp $	*/
 /*	$NetBSD: hunt.c,v 1.6 1997/04/20 00:02:10 mellon Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,32 +31,32 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/hunt.c,v 1.6 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/hunt.c,v 1.7 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)hunt.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: hunt.c,v 1.8 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: hunt.c,v 1.13 2006/03/17 19:39:46 deraadt Exp $";
 #endif
 #endif /* not lint */
 
 #include "tip.h"
 
-extern char *getremote();
-
 static	jmp_buf deadline;
 static	int deadfl;
 
-void
-dead()
+static void	dead(int);
+
+/*ARGSUSED*/
+static void
+dead(int signo)
 {
 	deadfl = 1;
 	longjmp(deadline, 1);
 }
 
 long
-hunt(name)
-	char *name;
+hunt(char *name)
 {
 	char *cp;
 	sig_t f;
@@ -88,7 +84,7 @@
 		if (setjmp(deadline) == 0) {
 			alarm(10);
 			FD = open(cp, (O_RDWR |
-				       (boolean(value(DC)) ? O_NONBLOCK : 0)));
+			    (boolean(value(DC)) ? O_NONBLOCK : 0)));
 		}
 		alarm(0);
 		if (FD < 0) {
Index: remote.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/remote.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/remote.c -L usr.bin/tip/tip/remote.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/remote.c
+++ usr.bin/tip/tip/remote.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: remote.c,v 1.10 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: remote.c,v 1.16 2006/06/06 23:24:52 deraadt Exp $	*/
 /*	$NetBSD: remote.c,v 1.5 1997/04/20 00:02:45 mellon Exp $	*/
 
 /*
@@ -14,11 +14,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -36,10 +32,10 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/remote.c,v 1.5 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/remote.c,v 1.6 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
-static char copyright[] =
+static const char copyright[] =
 "@(#) Copyright (c) 1992, 1993\n\
 	The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
@@ -47,7 +43,7 @@
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)remote.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: remote.c,v 1.10 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: remote.c,v 1.16 2006/06/06 23:24:52 deraadt Exp $";
 #endif
 #endif /* not lint */
 
@@ -75,13 +71,12 @@
 
 #define cgetflag(f)	(cgetcap(bp, f, ':') != NULL)
 
+static void	getremcap(char *);
+
 static void
-getremcap(host)
-	char *host;
+getremcap(char *host)
 {
-	char **p, ***q;
-	char *bp;
-	char *rempath;
+	char **p, ***q, *bp, *rempath;
 	int   stat;
 
 	rempath = getenv("REMOTE");
@@ -96,8 +91,8 @@
 	}
 
 	if ((stat = cgetent(&bp, db_array, host)) < 0) {
-		if (DV ||
-		    host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) {
+		if ((DV != NULL) ||
+		    (host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) {
 			CU = DV;
 			HO = host;
 			HW = 1;
@@ -107,18 +102,18 @@
 			FS = DEFFS;
 			return;
 		}
-		switch(stat) {
+		switch (stat) {
 		case -1:
 			fprintf(stderr, "%s: unknown host %s\n", __progname,
 			    host);
 			break;
 		case -2:
-			fprintf(stderr, 
+			fprintf(stderr,
 			    "%s: can't open host description file\n",
 			    __progname);
 			break;
 		case -3:
-			fprintf(stderr, 
+			fprintf(stderr,
 			    "%s: possible reference loop in host description file\n", __progname);
 			break;
 		}
@@ -130,6 +125,8 @@
 			cgetstr(bp, *p, *q);
 	if (!BR && (cgetnum(bp, "br", &BR) == -1))
 		BR = DEFBR;
+	if (!LD && (cgetnum(bp, "ld", &LD) == -1))
+		LD = TTYDISC;
 	if (cgetnum(bp, "fs", &FS) == -1)
 		FS = DEFFS;
 	if (DU < 0)
@@ -189,6 +186,8 @@
 		setboolean(value(HALFDUPLEX), 1);
 	if (cgetflag("dc"))
 		setboolean(value(DC), 1);
+	if (cgetflag("hf"))
+		setboolean(value(HARDWAREFLOW), 1);
 	if (RE == NOSTR)
 		RE = (char *)"tip.record";
 	if (EX == NOSTR)
@@ -210,8 +209,7 @@
 }
 
 char *
-getremote(host)
-	char *host;
+getremote(char *host)
 {
 	char *cp;
 	static char *next;
Index: acu.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/acu.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/acu.c -L usr.bin/tip/tip/acu.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/acu.c
+++ usr.bin/tip/tip/acu.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: acu.c,v 1.7 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: acu.c,v 1.12 2006/03/17 14:43:06 moritz Exp $	*/
 /*	$NetBSD: acu.c,v 1.4 1996/12/29 10:34:03 cgd Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/acu.c,v 1.7 2002/03/22 01:42:35 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/acu.c,v 1.10 2007/05/12 23:29:33 pav Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)acu.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: acu.c,v 1.7 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: acu.c,v 1.12 2006/03/17 14:43:06 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -67,8 +63,8 @@
  *   for a single host acting as a rotary (in the order
  *   found in the file).
  */
-const char *
-connect()
+char *
+con(void)
 {
 	char *cp = PN;
 	char *phnum, string[256];
@@ -106,7 +102,7 @@
 	if (*cp != '@') {
 		while (*cp) {
 			phnum = cp;
-			cp = strpbrk(cp, ",");
+			cp += strcspn(cp, ",");
 			if (*cp != '\0')
 				*cp++ = '\0';
 
@@ -143,7 +139,7 @@
 			conflag = (*acu->acu_dialer)(phnum, CU);
 			if (conflag)
 				break;
-			
+
 			logent(value(HOST), phnum, acu->acu_name, "call failed");
 			tried++;
 		}
@@ -164,8 +160,7 @@
 }
 
 void
-disconnect(reason)
-	char *reason;
+disconnect(char *reason)
 {
 	if (!conflag) {
 		logent(value(HOST), "", DV, "call terminated");
@@ -175,22 +170,20 @@
 		logent(value(HOST), "", acu->acu_name, "call terminated");
 		if (boolean(value(VERBOSE)))
 			printf("\r\ndisconnecting...");
-	} else 
+	} else
 		logent(value(HOST), "", acu->acu_name, reason);
 	(*acu->acu_disconnect)();
 }
 
 static void
-acuabort(s)
-	int s;
+acuabort(int s)
 {
 	signal(s, SIG_IGN);
 	longjmp(jmpbuf, 1);
 }
 
 static acu_t *
-acutype(s)
-	char *s;
+acutype(char *s)
 {
 	acu_t *p;
 	extern acu_t acutable[];
Index: acutab.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/acutab.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/acutab.c -L usr.bin/tip/tip/acutab.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/acutab.c
+++ usr.bin/tip/tip/acutab.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: acutab.c,v 1.2 1996/06/26 05:40:41 deraadt Exp $	*/
+/*	$OpenBSD: acutab.c,v 1.5 2006/03/17 19:17:13 moritz Exp $	*/
 /*	$NetBSD: acutab.c,v 1.3 1994/12/08 09:30:41 jtc Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/acutab.c,v 1.5 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/acutab.c,v 1.6 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)acutab.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: acutab.c,v 1.2 1996/06/26 05:40:41 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: acutab.c,v 1.5 2006/03/17 19:17:13 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -48,46 +44,46 @@
 
 acu_t acutable[] = {
 #if BIZ1031
-	"biz31f", biz31f_dialer, biz31_disconnect,	biz31_abort,
-	"biz31w", biz31w_dialer, biz31_disconnect,	biz31_abort,
+	{ "biz31f",	biz31f_dialer,	biz31_disconnect,	biz31_abort },
+	{ "biz31w",	biz31w_dialer,	biz31_disconnect,	biz31_abort },
 #endif
 #if BIZ1022
-	"biz22f", biz22f_dialer, biz22_disconnect,	biz22_abort,
-	"biz22w", biz22w_dialer, biz22_disconnect,	biz22_abort,
+	{ "biz22f",	biz22f_dialer,	biz22_disconnect,	biz22_abort },
+	{ "biz22w",	biz22w_dialer,	biz22_disconnect,	biz22_abort },
 #endif
 #if DF02
-	"df02",	df02_dialer,	df_disconnect,		df_abort,
+	{ "df02",	df02_dialer,	df_disconnect,		df_abort },
 #endif
 #if DF03
-	"df03",	df03_dialer,	df_disconnect,		df_abort,
+	{ "df03",	df03_dialer,	df_disconnect,		df_abort },
 #endif
 #if DN11
-	"dn11",	dn_dialer,	dn_disconnect,		dn_abort,
+	{ "dn11",	dn_dialer,	dn_disconnect,		dn_abort },
 #endif
 #ifdef VENTEL
-	"ventel",ven_dialer,	ven_disconnect,		ven_abort,
+	{ "ventel",	ven_dialer,	ven_disconnect,		ven_abort },
 #endif
 #ifdef HAYES
-	"hayes",hay_dialer,	hay_disconnect,		hay_abort,
+	{ "hayes",	hay_dialer,	hay_disconnect,		hay_abort },
 #endif
 #ifdef COURIER
-	"courier",cour_dialer,	cour_disconnect,	cour_abort,
+	{ "courier",	cour_dialer,	cour_disconnect,	cour_abort },
 #endif
 #ifdef T3000
-	"t3000",t3000_dialer,	t3000_disconnect,	t3000_abort,
+	{ "t3000",	t3000_dialer,	t3000_disconnect,	t3000_abort },
 #endif
 #ifdef V3451
 #ifndef V831
-	"vadic",v3451_dialer,	v3451_disconnect,	v3451_abort,
+	{ "vadic",	v3451_dialer,	v3451_disconnect,	v3451_abort },
 #endif
-	"v3451",v3451_dialer,	v3451_disconnect,	v3451_abort,
+	{ "v3451",	v3451_dialer,	v3451_disconnect,	v3451_abort },
 #endif
 #ifdef V831
 #ifndef V3451
-	"vadic",v831_dialer,	v831_disconnect,	v831_abort,
+	{ "vadic",	v831_dialer,	v831_disconnect,	v831_abort },
 #endif
-	"v831",v831_dialer,	v831_disconnect,	v831_abort,
+	{ "v831",	v831_dialer,	v831_disconnect,	v831_abort },
 #endif
-	0,	0,		0,			0
+	{ 0,		0,		0,			0 }
 };
 
Index: cmds.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/cmds.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/cmds.c -L usr.bin/tip/tip/cmds.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/cmds.c
+++ usr.bin/tip/tip/cmds.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: cmds.c,v 1.13 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: cmds.c,v 1.26 2006/06/06 23:24:52 deraadt Exp $	*/
 /*	$NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/cmds.c,v 1.16 2003/04/06 08:30:25 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/cmds.c,v 1.18 2006/08/31 19:19:44 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cmds.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: cmds.c,v 1.13 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: cmds.c,v 1.26 2006/06/06 23:24:52 deraadt Exp $";
 #endif
 #endif /* not lint */
 
@@ -61,20 +57,28 @@
 char	*sep[] = { "second", "minute", "hour" };
 static char *argv[10];		/* argument vector for take and put */
 
-void	timeout();		/* timeout function called on alarm */
-void	stopsnd();		/* SIGINT handler during file transfers */
-void	intcopy();		/* interrupt routine for file transfers */
+static void	transfer(char *, int, char *);
+static void	stopsnd(int);	/* SIGINT handler during file transfers */
+static void	intcopy(int);	/* interrupt routine for file transfers */
+static void	transmit(FILE *, char *, char *);
+static void	send(int);
+static void	execute(char *);
+static int	args(char *, char **, int);
+static void	prtime(char *, time_t);
+static void	tandem(char *);
+static void	hardwareflow(char *);
+void		linedisc(char *);
+static int	anyof(char *, char *);
 
 /*
  * FTP - remote ==> local
  *  get a file from the remote host
  */
 void
-getfl(c)
-	char c;
+getfl(int c)
 {
-	char buf[256], *cp, *expand();
-	
+	char buf[256], *cp;
+
 	putchar(c);
 	/*
 	 * get the UNIX receiving file's name
@@ -86,7 +90,7 @@
 		printf("\r\n%s: cannot creat\r\n", copyname);
 		return;
 	}
-	
+
 	/*
 	 * collect parameters
 	 */
@@ -95,18 +99,16 @@
 		return;
 	}
 	transfer(buf, sfd, value(EOFREAD));
-	return;
 }
 
 /*
  * Cu-like take command
  */
 void
-cu_take(cc)
-	char cc;
+cu_take(int c)
 {
 	int fd, argc;
-	char line[BUFSIZ], *expand(), *cp;
+	char line[BUFSIZ], *cp;
 
 	if (prompt("[take] ", copyname, sizeof(copyname)))
 		return;
@@ -122,7 +124,7 @@
 		printf("\r\n%s: cannot create\r\n", argv[1]);
 		return;
 	}
-	(void)snprintf(line, sizeof(line), "cat %s;echo \01", argv[0]);
+	(void)snprintf(line, sizeof(line), "cat %s;echo ''|tr '\\012' '\\01'", argv[0]);
 	transfer(line, fd, "\01");
 }
 
@@ -132,34 +134,38 @@
  * Bulk transfer routine --
  *  used by getfl(), cu_take(), and pipefile()
  */
-void
-transfer(buf, fd, eofchars)
-	char *buf, *eofchars;
-	int fd;
+static void
+transfer(char *buf, int fd, char *eofchars)
 {
-	int ct;
+	int ct, eof;
 	char c, buffer[BUFSIZ];
 	char *p = buffer;
-	int cnt, eof;
+	size_t cnt;
 	time_t start;
 	sig_t f;
 	char r;
 
+	if (number(value(FRAMESIZE)) > BUFSIZ || number(value(FRAMESIZE)) < 1) {
+		printf("framesize must be >= 1 and <= %d\r\n", BUFSIZ);
+		close(fd);
+		return;
+	}
+
 	parwrite(FD, buf, size(buf));
 	quit = 0;
-	kill(pid, SIGIOT);
+	kill(tipout_pid, SIGIOT);
 	read(repdes[0], (char *)&ccc, 1);  /* Wait until read process stops */
-	
+
 	/*
 	 * finish command
 	 */
 	r = '\r';
 	parwrite(FD, &r, 1);
 	do
-		read(FD, &c, 1); 
+		read(FD, &c, 1);
 	while ((c&STRIP_PAR) != '\n');
 	tcsetattr(0, TCSAFLUSH, &defchars);
-	
+
 	(void) setjmp(intbuf);
 	f = signal(SIGINT, intcopy);
 	start = time(0);
@@ -178,8 +184,8 @@
 
 		if (c == '\n' && boolean(value(VERBOSE)))
 			printf("\r%d", ++ct);
-		if ((cnt = (p-buffer)) == number(value(FRAMESIZE))) {
-			if (write(fd, buffer, cnt) != cnt) {
+		if ((cnt = (p-buffer)) == (size_t)number(value(FRAMESIZE))) {
+			if ((size_t)write(fd, buffer, cnt) != cnt) {
 				printf("\r\nwrite error\r\n");
 				quit = 1;
 			}
@@ -187,7 +193,7 @@
 		}
 	}
 	if ((cnt = (p-buffer)))
-		if (write(fd, buffer, cnt) != cnt)
+		if ((size_t)write(fd, buffer, cnt) != cnt)
 			printf("\r\nwrite error\r\n");
 
 	if (boolean(value(VERBOSE)))
@@ -202,12 +208,14 @@
  * FTP - remote ==> local process
  *   send remote input to local process via pipe
  */
+/*ARGSUSED*/
 void
-pipefile(char c)
+pipefile(int c)
 {
-	int cpid, pdes[2];
+	int pdes[2];
 	char buf[256];
 	int status, p;
+	pid_t cpid;
 
 	if (prompt("Local command? ", buf, sizeof(buf)))
 		return;
@@ -248,10 +256,10 @@
 /*
  * Interrupt service routine for FTP
  */
-void
-stopsnd()
+/*ARGSUSED*/
+static void
+stopsnd(int signo)
 {
-
 	stop = 1;
 	signal(SIGINT, SIG_IGN);
 }
@@ -262,14 +270,12 @@
  *  terminate transmission with pseudo EOF sequence
  */
 void
-sendfile(cc)
-	char cc;
+sendfile(int c)
 {
-	FILE *fd;
+	FILE *fp;
 	char *fnamex;
-	char *expand();
 
-	putchar(cc);
+	putchar(c);
 	/*
 	 * get file name
 	 */
@@ -280,11 +286,11 @@
 	 * look up file
 	 */
 	fnamex = expand(fname);
-	if ((fd = fopen(fnamex, "r")) == NULL) {
+	if ((fp = fopen(fnamex, "r")) == NULL) {
 		printf("%s: cannot open\r\n", fname);
 		return;
 	}
-	transmit(fd, value(EOFWRITE), NULL);
+	transmit(fp, value(EOFWRITE), NULL);
 	if (!boolean(value(ECHOCHECK)))
 		tcdrain(FD);
 }
@@ -293,17 +299,15 @@
  * Bulk transfer routine to remote host --
  *   used by sendfile() and cu_put()
  */
-void
-transmit(fd, eofchars, command)
-	FILE *fd;
-	char *eofchars, *command;
+static void
+transmit(FILE *fp, char *eofchars, char *command)
 {
 	char *pc, lastc;
 	int c, ccount, lcount;
 	time_t start_t, stop_t;
 	sig_t f;
 
-	kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
+	kill(tipout_pid, SIGIOT);	/* put TIPOUT into a wait state */
 	stop = 0;
 	f = signal(SIGINT, stopsnd);
 	tcsetattr(0, TCSAFLUSH, &defchars);
@@ -324,7 +328,7 @@
 	while (1) {
 		ccount = 0;
 		do {
-			c = getc(fd);
+			c = getc(fp);
 			if (stop)
 				goto out;
 			if (c == EOF)
@@ -336,8 +340,7 @@
 				if (c == '\n') {
 					if (!boolean(value(RAWFTP)))
 						c = '\r';
-				}
-				else if (c == '\t') {
+				} else if (c == '\t') {
 					if (!boolean(value(RAWFTP))) {
 						if (boolean(value(TABEXPAND))) {
 							send(' ');
@@ -356,7 +359,7 @@
 			printf("\r%d", ++lcount);
 		if (boolean(value(ECHOCHECK))) {
 			timedout = 0;
-			alarm((long)value(ETIMEOUT));
+			alarm((unsigned int)lvalue(ETIMEOUT));
 			do {	/* wait for prompt */
 				read(FD, (char *)&c, 1);
 				if (timedout || stop) {
@@ -377,7 +380,7 @@
 			send(*pc);
 	}
 	stop_t = time(0);
-	fclose(fd);
+	fclose(fp);
 	signal(SIGINT, f);
 	if (boolean(value(VERBOSE))) {
 		if (boolean(value(RAWFTP)))
@@ -392,14 +395,13 @@
 /*
  * Cu-like put command
  */
+/*ARGSUSED*/
 void
-cu_put(cc)
-	char cc;
+cu_put(int c)
 {
-	FILE *fd;
+	FILE *fp;
 	char line[BUFSIZ];
 	int argc;
-	char *expand();
 	char *copynamex;
 
 	if (prompt("[put] ", copyname, sizeof(copyname)))
@@ -412,7 +414,7 @@
 	if (argc == 1)
 		argv[1] = argv[0];
 	copynamex = expand(argv[0]);
-	if ((fd = fopen(copynamex, "r")) == NULL) {
+	if ((fp = fopen(copynamex, "r")) == NULL) {
 		printf("%s: cannot open\r\n", copynamex);
 		return;
 	}
@@ -421,36 +423,31 @@
 	else
 		(void)snprintf(line, sizeof(line),
 		    "stty -echo;cat>%s;stty echo\r", argv[1]);
-	transmit(fd, "\04", line);
+	transmit(fp, "\04", line);
 }
 
 /*
  * FTP - send single character
  *  wait for echo & handle timeout
  */
-void
-send(c)
-	int c;
+static void
+send(int c)
 {
 	char cc;
 	int retry = 0;
 
 	cc = c;
 	parwrite(FD, &cc, 1);
-#ifdef notdef
 	if (number(value(CDELAY)) > 0 && c != '\r')
-		nap(number(value(CDELAY)));
-#endif
+		usleep(number(value(CDELAY)));
 	if (!boolean(value(ECHOCHECK))) {
-#ifdef notdef
 		if (number(value(LDELAY)) > 0 && c == '\r')
-			nap(number(value(LDELAY)));
-#endif
+			usleep(number(value(LDELAY)));
 		return;
 	}
 tryagain:
 	timedout = 0;
-	alarm((long)value(ETIMEOUT));
+	alarm((unsigned int)lvalue(ETIMEOUT));
 	read(FD, &cc, 1);
 	alarm(0);
 	if (timedout) {
@@ -462,8 +459,9 @@
 	}
 }
 
+/*ARGSUSED*/
 void
-timeout()
+timeout(int signo)
 {
 	signal(SIGALRM, timeout);
 	timedout = 1;
@@ -474,16 +472,17 @@
  *	Identical to consh() except for where stdout goes.
  */
 void
-pipeout(char c)
+pipeout(int c)
 {
 	char buf[256];
-	int cpid, status, p;
+	int status, p;
+	pid_t cpid;
 	time_t start = time(NULL);
 
 	putchar(c);
 	if (prompt("Local command? ", buf, sizeof(buf)))
 		return;
-	kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
+	kill(tipout_pid, SIGIOT);	/* put TIPOUT into a wait state */
 	signal(SIGINT, SIG_IGN);
 	signal(SIGQUIT, SIG_IGN);
 	tcsetattr(0, TCSAFLUSH, &defchars);
@@ -523,19 +522,20 @@
  * Fork a program with:
  *  0 <-> remote tty in
  *  1 <-> remote tty out
- *  2 <-> local tty out
+ *  2 <-> local tty stderr
  */
 void
-consh(char c)
+consh(int c)
 {
 	char buf[256];
-	int cpid, status, p;
+	int status, p;
+	pid_t cpid;
 	time_t start = time(NULL);
 
 	putchar(c);
 	if (prompt("Local command? ", buf, sizeof(buf)))
 		return;
-	kill(pid, SIGIOT);	/* put TIPOUT into a wait state */
+	kill(tipout_pid, SIGIOT);	/* put TIPOUT into a wait state */
 	signal(SIGINT, SIG_IGN);
 	signal(SIGQUIT, SIG_IGN);
 	tcsetattr(0, TCSAFLUSH, &defchars);
@@ -575,11 +575,13 @@
 /*
  * Escape to local shell
  */
+/*ARGSUSED*/
 void
-shell(char c)
+shell(int c)
 {
-	int shpid, status;
+	int status;
 	char *cp;
+	pid_t shpid;
 
 	printf("[sh]\r\n");
 	signal(SIGINT, SIG_IGN);
@@ -611,13 +613,14 @@
  *   initiate the conversation with TIPOUT
  */
 void
-setscript()
+setscript(void)
 {
 	char c;
+
 	/*
 	 * enable TIPOUT side for dialogue
 	 */
-	kill(pid, SIGEMT);
+	kill(tipout_pid, SIGEMT);
 	if (boolean(value(SCRIPT)))
 		write(fildes[1], value(RECORD), size(value(RECORD)));
 	write(fildes[1], "\n", 1);
@@ -633,8 +636,9 @@
  * Change current working directory of
  *   local portion of tip
  */
+/*ARGSUSED*/
 void
-chdirectory(char c)
+chdirectory(int c)
 {
 	char dirname[PATH_MAX];
 	char *cp = dirname;
@@ -650,11 +654,11 @@
 }
 
 void
-tipabort(msg)
-	char *msg;
+tipabort(char *msg)
 {
 
-	kill(pid, SIGTERM);
+	signal(SIGTERM, SIG_IGN);
+	kill(tipout_pid, SIGTERM);
 	disconnect(msg);
 	if (msg != NOSTR)
 		printf("\r\n%s", msg);
@@ -665,8 +669,9 @@
 	exit(0);
 }
 
+/*ARGSUSED*/
 void
-finish(char c)
+finish(int c)
 {
 	char *dismsg;
 
@@ -677,17 +682,17 @@
 	tipabort(NOSTR);
 }
 
-void
-intcopy()
+/*ARGSUSED*/
+static void
+intcopy(int signo)
 {
 	raw();
 	quit = 1;
 	longjmp(intbuf, 1);
 }
 
-void
-execute(s)
-	char *s;
+static void
+execute(char *s)
 {
 	char *cp;
 
@@ -699,10 +704,8 @@
 	execl(value(SHELL), cp, "-c", s, (char *)NULL);
 }
 
-int
-args(buf, a, num)
-	char *buf, *a[];
-	int num;
+static int
+args(char *buf, char *a[], int num)
 {
 	char *p = buf, *start;
 	char **parg = a;
@@ -725,10 +728,8 @@
 	return(n);
 }
 
-void
-prtime(s, a)
-	char *s;
-	time_t a;
+static void
+prtime(char *s, time_t a)
 {
 	int i;
 	int nums[3];
@@ -739,14 +740,15 @@
 	}
 	printf("%s", s);
 	while (--i >= 0)
-		if (nums[i] || i == 0 && nums[1] == 0 && nums[2] == 0)
+		if (nums[i] || (i == 0 && nums[1] == 0 && nums[2] == 0))
 			printf("%d %s%c ", nums[i], sep[i],
 				nums[i] == 1 ? '\0' : 's');
 	printf("\r\n!\r\n");
 }
 
+/*ARGSUSED*/
 void
-variable(char c)
+variable(int c)
 {
 	char	buf[256];
 
@@ -755,7 +757,7 @@
 	vlex(buf);
 	if (vtable[BEAUTIFY].v_access&CHANGED) {
 		vtable[BEAUTIFY].v_access &= ~CHANGED;
-		kill(pid, SIGSYS);
+		kill(tipout_pid, SIGSYS);
 	}
 	if (vtable[SCRIPT].v_access&CHANGED) {
 		vtable[SCRIPT].v_access &= ~CHANGED;
@@ -779,18 +781,30 @@
 		else
 			tandem("off");
 	}
- 	if (vtable[LECHO].v_access&CHANGED) {
- 		vtable[LECHO].v_access &= ~CHANGED;
- 		HD = boolean(value(LECHO));
- 	}
+	if (vtable[LECHO].v_access&CHANGED) {
+		vtable[LECHO].v_access &= ~CHANGED;
+		HD = boolean(value(LECHO));
+	}
 	if (vtable[PARITY].v_access&CHANGED) {
 		vtable[PARITY].v_access &= ~CHANGED;
 		setparity(NOSTR);
 	}
+	if (vtable[HARDWAREFLOW].v_access&CHANGED) {
+		vtable[HARDWAREFLOW].v_access &= ~CHANGED;
+		if (boolean(value(HARDWAREFLOW)))
+			hardwareflow("on");
+		else
+			hardwareflow("off");
+	}
+	if (vtable[LINEDISC].v_access&CHANGED) {
+		vtable[LINEDISC].v_access &= ~CHANGED;
+		linedisc(NOSTR);
+	}
 }
 
+/*ARGSUSED*/
 void
-listvariables(char c)
+listvariables(int c)
 {
 	value_t *p;
 	char *buf;
@@ -819,22 +833,21 @@
 			break;
 		case BOOL:
 			printf(" %s\r\n",
-			    boolean(p->v_value) == '!' ? "false" : "true");
+			    !boolean(p->v_value) ? "false" : "true");
 			break;
 		case CHAR:
 			vis(charbuf, character(p->v_value), VIS_WHITE, 0);
 			printf(" %s\r\n", charbuf);
 			break;
 		}
-        }
+	}
 }
 
 /*
  * Turn tandem mode on or off for remote tty.
  */
-void
-tandem(option)
-	char *option;
+static void
+tandem(char *option)
 {
 	struct termios	rmtty;
 
@@ -851,12 +864,39 @@
 }
 
 /*
- * Send a break.
+ * Turn hardware flow control on or off for remote tty.
+ */
+static void
+hardwareflow(char *option)
+{
+	struct termios	rmtty;
+
+	tcgetattr(FD, &rmtty);
+	if (strcmp(option, "on") == 0)
+		rmtty.c_iflag |= CRTSCTS;
+	else
+		rmtty.c_iflag &= ~CRTSCTS;
+	tcsetattr(FD, TCSADRAIN, &rmtty);
+}
+
+/*
+ * Change line discipline to the specified one.
  */
 void
-genbrk(char c)
+linedisc(char *option)
 {
+	int ld = (int)(intptr_t)value(LINEDISC);
 
+	ioctl(FD, TIOCSETD, &ld);
+}
+
+/*
+ * Send a break.
+ */
+/*ARGSUSED*/
+void
+genbrk(int c)
+{
 	ioctl(FD, TIOCSBRK, NULL);
 	sleep(1);
 	ioctl(FD, TIOCCBRK, NULL);
@@ -866,10 +906,8 @@
  * Suspend tip
  */
 void
-suspend(c)
-	char c;
+suspend(int c)
 {
-
 	unraw();
 	kill(c == CTRL('y') ? getpid() : 0, SIGTSTP);
 	raw();
@@ -878,16 +916,15 @@
 /*
  *	expand a file name if it includes shell meta characters
  */
-
 char *
-expand(name)
-	char name[];
+expand(char name[])
 {
 	static char xname[BUFSIZ];
 	char cmdbuf[BUFSIZ];
-	int pid, l;
+	int l;
 	char *cp, *Shell;
 	int s, pivec[2];
+	pid_t pid;
 
 	if (!anyof(name, "~{[*?$`'\"\\"))
 		return(name);
@@ -949,9 +986,8 @@
 /*
  * Are any of the characters in the two strings the same?
  */
-int
-anyof(s1, s2)
-	char *s1, *s2;
+static int
+anyof(char *s1, char *s2)
 {
 	int c;
 
Index: tipout.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/tipout.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/tipout.c -L usr.bin/tip/tip/tipout.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/tipout.c
+++ usr.bin/tip/tip/tipout.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: tipout.c,v 1.8 2001/10/24 18:38:58 millert Exp $	*/
+/*	$OpenBSD: tipout.c,v 1.18 2006/05/31 07:03:08 jason Exp $	*/
 /*	$NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,16 +31,17 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/tipout.c,v 1.10 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/tipout.c,v 1.12 2006/08/31 19:19:44 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)tipout.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: tipout.c,v 1.8 2001/10/24 18:38:58 millert Exp $";
+static const char rcsid[] = "$OpenBSD: tipout.c,v 1.18 2006/05/31 07:03:08 jason Exp $";
 #endif
 #endif /* not lint */
 
 #include "tip.h"
+
 /*
  * tip
  *
@@ -54,14 +51,19 @@
 
 static	jmp_buf sigbuf;
 
+static void	intIOT(int);
+static void	intEMT(int);
+static void	intTERM(int);
+static void	intSYS(int);
+
 /*
  * TIPOUT wait state routine --
  *   sent by TIPIN when it wants to posses the remote host
  */
-void
-intIOT()
+/*ARGSUSED*/
+static void
+intIOT(int signo)
 {
-
 	write(repdes[1],&ccc,1);
 	read(fildes[0], &ccc,1);
 	longjmp(sigbuf, 1);
@@ -71,15 +73,16 @@
  * Scripting command interpreter --
  *  accepts script file name over the pipe and acts accordingly
  */
-void
-intEMT()
+/*ARGSUSED*/
+static void
+intEMT(int signo)
 {
 	char c, line[256];
 	char *pline = line;
 	char reply;
 
 	read(fildes[0], &c, 1);
-	while (c != '\n' && pline - line < sizeof(line)) {
+	while (c != '\n' && (size_t)(pline - line) < sizeof(line)) {
 		*pline++ = c;
 		read(fildes[0], &c, 1);
 	}
@@ -101,19 +104,20 @@
 	longjmp(sigbuf, 1);
 }
 
-void
-intTERM()
+static void
+intTERM(int signo)
 {
-
 	if (boolean(value(SCRIPT)) && fscript != NULL)
 		fclose(fscript);
+	if (signo && tipin_pid)
+		kill(tipin_pid, signo);
 	exit(0);
 }
 
-void
-intSYS()
+/*ARGSUSED*/
+static void
+intSYS(int signo)
 {
-
 	setboolean(value(BEAUTIFY), !boolean(value(BEAUTIFY)));
 	longjmp(sigbuf, 1);
 }
@@ -122,11 +126,12 @@
  * ****TIPOUT   TIPOUT****
  */
 void
-tipout()
+tipout(void)
 {
 	char buf[BUFSIZ];
 	char *cp;
-	int cnt;
+	ssize_t scnt;
+	size_t cnt;
 	sigset_t mask, omask;
 
 	signal(SIGINT, SIG_IGN);
@@ -140,18 +145,19 @@
 	sigprocmask(SIG_BLOCK, NULL, &omask);
 	for (;;) {
 		sigprocmask(SIG_SETMASK, &omask, NULL);
-		cnt = read(FD, buf, BUFSIZ);
-		if (cnt <= 0) {
+		scnt = read(FD, buf, BUFSIZ);
+		if (scnt <= 0) {
 			/* lost carrier */
-			if (cnt < 0 && errno == EIO) {
+			if (scnt == 0 || (scnt < 0 && errno == EIO)) {
 				sigemptyset(&mask);
 				sigaddset(&mask, SIGTERM);
 				sigprocmask(SIG_BLOCK, &mask, NULL);
-				intTERM();
+				intTERM(0);
 				/*NOTREACHED*/
 			}
 			continue;
 		}
+		cnt = scnt;
 		sigemptyset(&mask);
 		sigaddset(&mask, SIGEMT);
 		sigaddset(&mask, SIGTERM);
@@ -160,7 +166,7 @@
 		sigprocmask(SIG_BLOCK, &mask, NULL);
 		for (cp = buf; cp < buf + cnt; cp++)
 			*cp &= STRIP_PAR;
-		write(1, buf, cnt);
+		write(STDOUT_FILENO, buf, cnt);
 		if (boolean(value(SCRIPT)) && fscript != NULL) {
 			if (!boolean(value(BEAUTIFY))) {
 				fwrite(buf, 1, cnt, fscript);
Index: vars.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/vars.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/vars.c -L usr.bin/tip/tip/vars.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/vars.c
+++ usr.bin/tip/tip/vars.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: vars.c,v 1.2 1996/06/26 05:40:50 deraadt Exp $	*/
+/*	$OpenBSD: vars.c,v 1.8 2006/08/18 03:06:18 jason Exp $	*/
 /*	$NetBSD: vars.c,v 1.3 1994/12/08 09:31:19 jtc Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/vars.c,v 1.6 2004/03/14 05:55:16 bde Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/vars.c,v 1.7 2006/08/31 14:14:30 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)vars.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: vars.c,v 1.2 1996/06/26 05:40:50 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: vars.c,v 1.8 2006/08/18 03:06:18 jason Exp $";
 #endif
 #endif /* not lint */
 
@@ -82,7 +78,7 @@
 	{ "raise",	BOOL,			(READ|WRITE)<<PUBLIC,
 	  "ra",		(char *)FALSE },
 	{ "raisechar",	CHAR,			(READ|WRITE)<<PUBLIC,
-	  "rc",		(char *)CTRL('a') },
+	  "rc",		NOSTR },
 	{ "record",	STRING|INIT|IREMOTE,	(READ|WRITE)<<PUBLIC,
 	  "rec",	(char *)&RE },
 	{ "remote",	STRING|INIT|IREMOTE,	READ<<PUBLIC,
@@ -117,6 +113,12 @@
 	  "le",		(char *)FALSE },
 	{ "parity",	STRING|INIT|IREMOTE,	(READ|WRITE)<<PUBLIC,
 	  "par",	(char *)&PA },
+	{ "hardwareflow", BOOL,			(READ|WRITE)<<PUBLIC,
+	  "hf",		(char *)FALSE },
+	{ "linedisc",	NUMBER|IREMOTE|INIT,	(READ|WRITE)<<PUBLIC,
+	  "ld",		(char *)&LD },
+	{ "direct",	BOOL,			(READ<<PUBLIC)|(WRITE<<ROOT),
+	  "dc",		(char *)FALSE },
 	{ NOSTR,	0,			0,
 	  NOSTR,	NOSTR }
 };
Index: cmdtab.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/cmdtab.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/cmdtab.c -L usr.bin/tip/tip/cmdtab.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/cmdtab.c
+++ usr.bin/tip/tip/cmdtab.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: cmdtab.c,v 1.3 2001/09/09 17:58:41 millert Exp $	*/
+/*	$OpenBSD: cmdtab.c,v 1.7 2006/03/17 14:43:06 moritz Exp $	*/
 /*	$NetBSD: cmdtab.c,v 1.3 1994/12/08 09:30:46 jtc Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/cmdtab.c,v 1.5 2003/04/06 08:30:25 imp Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/cmdtab.c,v 1.7 2006/08/31 19:19:44 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cmdtab.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.3 2001/09/09 17:58:41 millert Exp $";
+static const char rcsid[] = "$OpenBSD: cmdtab.c,v 1.7 2006/03/17 14:43:06 moritz Exp $";
 #endif
 #endif /* not lint */
 
@@ -66,5 +62,5 @@
 	{ 'v',	NORM,	"list variables",		 listvariables },
 	{ '?',	NORM,	"get this summary",		 help },
 	{ '#',	NORM,	"send break",			 genbrk },
-	{ 0, 0, 0 }
+	{ '\0',	0,	NULL,				 NULL }
 };
Index: partab.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/partab.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/partab.c -L usr.bin/tip/tip/partab.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/partab.c
+++ usr.bin/tip/tip/partab.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: partab.c,v 1.3 1997/04/02 01:47:02 millert Exp $	*/
+/*	$OpenBSD: partab.c,v 1.5 2003/06/03 02:56:18 millert Exp $	*/
 /*	$NetBSD: partab.c,v 1.4 1996/12/29 10:38:21 cgd Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/partab.c,v 1.4 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/partab.c,v 1.5 2006/08/31 14:14:29 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)partab.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: partab.c,v 1.3 1997/04/02 01:47:02 millert Exp $";
+static const char rcsid[] = "$OpenBSD: partab.c,v 1.5 2003/06/03 02:56:18 millert Exp $";
 #endif
 #endif /* not lint */
 
Index: uucplock.c
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/uucplock.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/uucplock.c -L usr.bin/tip/tip/uucplock.c -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/uucplock.c
+++ usr.bin/tip/tip/uucplock.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: uucplock.c,v 1.6 1998/07/13 02:11:44 millert Exp $	*/
+/*	$OpenBSD: uucplock.c,v 1.11 2006/03/16 19:32:46 deraadt Exp $	*/
 /*	$NetBSD: uucplock.c,v 1.7 1997/02/11 09:24:08 mrg Exp $	*/
 
 /*
@@ -13,11 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/tip/tip/uucplock.c,v 1.6 2001/12/20 14:25:46 markm Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/tip/tip/uucplock.c,v 1.8 2006/08/31 19:19:44 ru Exp $");
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)uucplock.c	8.1 (Berkeley) 6/6/93";
-static char rcsid[] = "$OpenBSD: uucplock.c,v 1.6 1998/07/13 02:11:44 millert Exp $";
+static const char rcsid[] = "$OpenBSD: uucplock.c,v 1.11 2006/03/16 19:32:46 deraadt Exp $";
 #endif
 #endif /* not lint */
 
@@ -53,22 +49,22 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
+#include "tip.h"
 #include "pathnames.h"
 
-/* 
+/*
  * uucp style locking routines
  * return: 0 - success
- * 	  -1 - failure
+ *	  -1 - failure
  */
 
 int
-uu_lock(ttyname)
-	char *ttyname;
+uu_lock(char *ttyname)
 {
-	int fd, pid;
+	int fd, len;
 	char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
 	char text_pid[81];
-	int len;
+	pid_t pid;
 
 	(void)snprintf(tbuf, sizeof tbuf, _PATH_LOCKDIRNAME, ttyname);
 	fd = open(tbuf, O_RDWR|O_CREAT|O_EXCL, 0660);
@@ -84,7 +80,7 @@
 			return(-1);
 		}
 		len = read(fd, text_pid, sizeof(text_pid)-1);
-		if(len<=0) {
+		if (len<=0) {
 			perror(tbuf);
 			(void)close(fd);
 			fprintf(stderr, "Can't read lock file.\n");
@@ -101,8 +97,8 @@
 		 * The process that locked the file isn't running, so
 		 * we'll lock it ourselves
 		 */
-		fprintf(stderr, "Stale lock on %s PID=%d... overriding.\n",
-			ttyname, pid);
+		fprintf(stderr, "Stale lock on %s PID=%ld... overriding.\n",
+			ttyname, (long)pid);
 		if (lseek(fd, (off_t)0, SEEK_SET) < 0) {
 			perror(tbuf);
 			(void)close(fd);
@@ -112,7 +108,7 @@
 		/* fall out and finish the locking process */
 	}
 	pid = getpid();
-	(void)sprintf(text_pid, "%10d\n", pid);
+	(void)snprintf(text_pid, sizeof text_pid, "%10ld\n", (long)pid);
 	len = strlen(text_pid);
 	if (write(fd, text_pid, len) != len) {
 		(void)close(fd);
@@ -125,8 +121,7 @@
 }
 
 int
-uu_unlock(ttyname)
-	char *ttyname;
+uu_unlock(char *ttyname)
 {
 	char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
 
Index: pathnames.h
===================================================================
RCS file: /home/cvs/src/usr.bin/tip/tip/pathnames.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -L usr.bin/tip/tip/pathnames.h -L usr.bin/tip/tip/pathnames.h -u -r1.1.1.1 -r1.2
--- usr.bin/tip/tip/pathnames.h
+++ usr.bin/tip/tip/pathnames.h
@@ -1,6 +1,6 @@
-/*	$OpenBSD: pathnames.h,v 1.2 1996/06/26 05:40:45 deraadt Exp $	*/
+/*	$OpenBSD: pathnames.h,v 1.3 2003/06/03 02:56:18 millert Exp $	*/
 /*	$NetBSD: pathnames.h,v 1.3 1994/12/08 09:30:59 jtc Exp $	*/
-/*	$FreeBSD: src/usr.bin/tip/tip/pathnames.h,v 1.5 2001/12/20 14:25:46 markm Exp $	*/
+/*	$FreeBSD: src/usr.bin/tip/tip/pathnames.h,v 1.6 2006/08/31 14:14:29 ru Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -14,11 +14,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *


More information about the Midnightbsd-cvs mailing list