From 1de3af8e0303b8f09885e2e01be3baae62cf9d01 Mon Sep 17 00:00:00 2001 From: millert Date: Sun, 20 Apr 1997 23:29:32 +0000 Subject: [PATCH] Incorporate some NetBSD changes: tip.c getchar() returns an int [important since EOF == -1] (thorpej) Set CLOCAL if dc flag is set (mellon) tip.h Change booleans from char to short so that comparisons against negative values work as expected on systems with unsigned chars. (thorpej) Add boolean for dc flag (mellon) hunt.c Set O_NONBLOCK if dc flag set. Don't set HUPCL if dc flag is set. (mellon) remote.c Add boolean for dc flag (mellon) --- usr.bin/tip/hunt.c | 12 +++++++----- usr.bin/tip/remote.c | 8 +++++--- usr.bin/tip/tip.c | 11 +++++++---- usr.bin/tip/tip.h | 11 ++++++----- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/usr.bin/tip/hunt.c b/usr.bin/tip/hunt.c index bcf92ac794b..fd2d22d87da 100644 --- a/usr.bin/tip/hunt.c +++ b/usr.bin/tip/hunt.c @@ -1,5 +1,5 @@ -/* $OpenBSD: hunt.c,v 1.4 1996/10/15 23:47:21 millert Exp $ */ -/* $NetBSD: hunt.c,v 1.5 1995/10/29 00:49:40 pk Exp $ */ +/* $OpenBSD: hunt.c,v 1.5 1997/04/20 23:29:32 millert Exp $ */ +/* $NetBSD: hunt.c,v 1.6 1997/04/20 00:02:10 mellon Exp $ */ /* * Copyright (c) 1983, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: hunt.c,v 1.4 1996/10/15 23:47:21 millert Exp $"; +static char rcsid[] = "$OpenBSD: hunt.c,v 1.5 1997/04/20 23:29:32 millert Exp $"; #endif /* not lint */ #include "tip.h" @@ -79,7 +79,8 @@ hunt(name) break; if (setjmp(deadline) == 0) { alarm(10); - FD = open(cp, O_RDWR); + FD = open(cp, (O_RDWR | + (boolean(value(DC)) ? O_NONBLOCK : 0))); } alarm(0); if (FD < 0) { @@ -90,7 +91,8 @@ hunt(name) struct termios cntrl; tcgetattr(FD, &cntrl); - cntrl.c_cflag |= HUPCL; + if (!boolean(value(DC))) + cntrl.c_cflag |= HUPCL; tcsetattr(FD, TCSAFLUSH, &cntrl); ioctl(FD, TIOCEXCL, 0); signal(SIGALRM, SIG_DFL); diff --git a/usr.bin/tip/remote.c b/usr.bin/tip/remote.c index 52b7aa08e43..ac6bc48230e 100644 --- a/usr.bin/tip/remote.c +++ b/usr.bin/tip/remote.c @@ -1,5 +1,5 @@ -/* $OpenBSD: remote.c,v 1.4 1997/04/02 01:47:02 millert Exp $ */ -/* $NetBSD: remote.c,v 1.4 1996/12/29 10:34:08 cgd Exp $ */ +/* $OpenBSD: remote.c,v 1.5 1997/04/20 23:29:33 millert Exp $ */ +/* $NetBSD: remote.c,v 1.5 1997/04/20 00:02:45 mellon Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: remote.c,v 1.4 1997/04/02 01:47:02 millert Exp $"; +static char rcsid[] = "$OpenBSD: remote.c,v 1.5 1997/04/20 23:29:33 millert Exp $"; #endif /* not lint */ #include @@ -177,6 +177,8 @@ getremcap(host) setboolean(value(RAWFTP), 1); if (cgetflag("hd")) setboolean(value(HALFDUPLEX), 1); + if (cgetflag("dc")) + setboolean(value(DC), 1); if (RE == NOSTR) RE = (char *)"tip.record"; if (EX == NOSTR) diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c index f208c15c662..f022c8919f0 100644 --- a/usr.bin/tip/tip.c +++ b/usr.bin/tip/tip.c @@ -1,5 +1,5 @@ -/* $OpenBSD: tip.c,v 1.4 1997/04/02 01:47:03 millert Exp $ */ -/* $NetBSD: tip.c,v 1.11 1997/02/11 09:24:06 mrg Exp $ */ +/* $OpenBSD: tip.c,v 1.5 1997/04/20 23:29:33 millert Exp $ */ +/* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */ /* * Copyright (c) 1983, 1993 @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: tip.c,v 1.4 1997/04/02 01:47:03 millert Exp $"; +static char rcsid[] = "$OpenBSD: tip.c,v 1.5 1997/04/20 23:29:33 millert Exp $"; #endif /* not lint */ /* @@ -304,6 +304,7 @@ prompt(s, p) char *s; register char *p; { + register int c; register char *b = p; sig_t oint, oquit; @@ -313,7 +314,7 @@ prompt(s, p) unraw(); printf("%s", s); if (setjmp(promptbuf) == 0) - while ((*p = getchar()) != EOF && *p != '\n') + while ((c = getchar()) != EOF && (*p = c) != '\n') p++; *p = '\0'; @@ -511,6 +512,8 @@ ttysetup(speed) cfsetispeed(&cntrl, speed); cntrl.c_cflag &= ~(CSIZE|PARENB); cntrl.c_cflag |= CS8; + if (boolean(value(DC))) + cntrl.c_cflag |= CLOCAL; cntrl.c_iflag &= ~(ISTRIP|ICRNL); cntrl.c_oflag &= ~OPOST; cntrl.c_lflag &= ~(ICANON|ISIG|IEXTEN|ECHO); diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h index 86d0e4a913c..2b5a8bda9fe 100644 --- a/usr.bin/tip/tip.h +++ b/usr.bin/tip/tip.h @@ -1,5 +1,5 @@ -/* $OpenBSD: tip.h,v 1.5 1997/04/02 01:47:03 millert Exp $ */ -/* $NetBSD: tip.h,v 1.5 1996/12/29 10:34:11 cgd Exp $ */ +/* $OpenBSD: tip.h,v 1.6 1997/04/20 23:29:33 millert Exp $ */ +/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */ /* * Copyright (c) 1989, 1993 @@ -77,8 +77,8 @@ char *HO; /* host name */ long BR; /* line speed for conversation */ long FS; /* frame size for transfers */ -char DU; /* this host is dialed up */ -char HW; /* this device is hardwired, see hunt.c */ +short DU; /* this host is dialed up */ +short HW; /* this device is hardwired, see hunt.c */ char *ES; /* escape character */ char *EX; /* exceptions */ char *FO; /* force (literal next) char*/ @@ -88,7 +88,8 @@ char *PR; /* remote prompt */ long DL; /* line delay for file transfers to remote */ long CL; /* char delay for file transfers to remote */ long ET; /* echocheck timeout */ -char HD; /* this host is half duplex - do local echo */ +short HD; /* this host is half duplex - do local echo */ +short DC; /* this host is directly connected. */ /* * String value table -- 2.20.1