diff options
-rw-r--r-- | usr.bin/tip/aculib/biz22.c | 6 | ||||
-rw-r--r-- | usr.bin/tip/aculib/biz31.c | 8 | ||||
-rw-r--r-- | usr.bin/tip/aculib/courier.c | 37 | ||||
-rw-r--r-- | usr.bin/tip/aculib/df.c | 32 | ||||
-rw-r--r-- | usr.bin/tip/aculib/dn11.c | 9 | ||||
-rw-r--r-- | usr.bin/tip/aculib/hayes.c | 22 | ||||
-rw-r--r-- | usr.bin/tip/aculib/t3000.c | 49 | ||||
-rw-r--r-- | usr.bin/tip/aculib/v3451.c | 11 | ||||
-rw-r--r-- | usr.bin/tip/aculib/v831.c | 35 | ||||
-rw-r--r-- | usr.bin/tip/aculib/ventel.c | 13 | ||||
-rw-r--r-- | usr.bin/tip/cmds.c | 57 | ||||
-rw-r--r-- | usr.bin/tip/hunt.c | 10 | ||||
-rw-r--r-- | usr.bin/tip/tip.c | 78 | ||||
-rw-r--r-- | usr.bin/tip/tip.h | 15 | ||||
-rw-r--r-- | usr.bin/tip/tipout.c | 6 |
15 files changed, 194 insertions, 194 deletions
diff --git a/usr.bin/tip/aculib/biz22.c b/usr.bin/tip/aculib/biz22.c index db9e8da3ca8..165ce59dd69 100644 --- a/usr.bin/tip/aculib/biz22.c +++ b/usr.bin/tip/aculib/biz22.c @@ -1,4 +1,4 @@ -/* $NetBSD: biz22.c,v 1.3 1994/12/08 09:31:31 jtc Exp $ */ +/* $NetBSD: biz22.c,v 1.4 1995/10/29 00:49:47 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: biz22.c,v 1.3 1994/12/08 09:31:31 jtc Exp $"; +static char rcsid[] = "$NetBSD: biz22.c,v 1.4 1995/10/29 00:49:47 pk Exp $"; #endif /* not lint */ #include "tip.h" @@ -127,7 +127,7 @@ biz22_disconnect() write(FD, DISCONNECT_CMD, 4); sleep(2); - ioctl(FD, TIOCFLUSH, &rw); + tcflush(FD, TCIOFLUSH); } biz22_abort() diff --git a/usr.bin/tip/aculib/biz31.c b/usr.bin/tip/aculib/biz31.c index 15185cd58a4..a82c6282ee8 100644 --- a/usr.bin/tip/aculib/biz31.c +++ b/usr.bin/tip/aculib/biz31.c @@ -1,4 +1,4 @@ -/* $NetBSD: biz31.c,v 1.3 1994/12/08 09:31:33 jtc Exp $ */ +/* $NetBSD: biz31.c,v 1.4 1995/10/29 00:49:48 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: biz31.c,v 1.3 1994/12/08 09:31:33 jtc Exp $"; +static char rcsid[] = "$NetBSD: biz31.c,v 1.4 1995/10/29 00:49:48 pk Exp $"; #endif /* not lint */ #include "tip.h" @@ -123,7 +123,7 @@ biz31_disconnect() write(FD, DISCONNECT_CMD, 4); sleep(2); - ioctl(FD, TIOCFLUSH); + tcflush(FD, TCIOFLUSH); } biz31_abort() @@ -231,7 +231,7 @@ bizsync(fd) retry: if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0 && chars(b) > 0) - ioctl(fd, TIOCFLUSH); + tcflush(FD, TCIOFLUSH); write(fd, "\rp>\r", 4); sleep(1); if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0) { diff --git a/usr.bin/tip/aculib/courier.c b/usr.bin/tip/aculib/courier.c index fbf56b99a55..57f14f149e8 100644 --- a/usr.bin/tip/aculib/courier.c +++ b/usr.bin/tip/aculib/courier.c @@ -1,4 +1,4 @@ -/* $NetBSD: courier.c,v 1.4 1994/12/08 09:31:35 jtc Exp $ */ +/* $NetBSD: courier.c,v 1.5 1995/10/29 00:49:50 pk Exp $ */ /* * Copyright (c) 1986, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: courier.c,v 1.4 1994/12/08 09:31:35 jtc Exp $"; +static char rcsid[] = "$NetBSD: courier.c,v 1.5 1995/10/29 00:49:50 pk Exp $"; #endif /* not lint */ /* @@ -45,6 +45,7 @@ static char rcsid[] = "$NetBSD: courier.c,v 1.4 1994/12/08 09:31:35 jtc Exp $"; * Derived from Hayes driver. */ #include "tip.h" +#include <sys/ioctl.h> #include <stdio.h> #define MAXRETRY 5 @@ -63,12 +64,15 @@ cour_dialer(num, acu) #ifdef ACULOG char line[80]; #endif + struct termios cntrl; static int cour_connect(), cour_swallow(); if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); - ioctl(FD, TIOCHPCL, 0); + tcgetattr(FD, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(FD, TCSAFLUSH, &cntrl); /* * Get in synch. */ @@ -86,7 +90,7 @@ badsynch: if (boolean(value(VERBOSE))) cour_verbose_read(); #endif - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ + tcflush(FD, TCIOFLUSH); cour_write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21); if (!cour_swallow("\r\nOK\r\n")) goto badsynch; @@ -186,7 +190,6 @@ cour_connect() { char c; int nc, nl, n; - struct sgttyb sb; char dialer_buf[64]; struct baud_msg *bm; sig_t f; @@ -225,15 +228,12 @@ again: for (bm = baud_msg ; bm->msg ; bm++) if (strcmp(bm->msg, dialer_buf+sizeof("CONNECT")-1) == 0) { - if (ioctl(FD, TIOCGETP, &sb) < 0) { - perror("TIOCGETP"); - goto error; - } - sb.sg_ispeed = sb.sg_ospeed = bm->baud; - if (ioctl(FD, TIOCSETP, &sb) < 0) { - perror("TIOCSETP"); - goto error; - } + struct termios cntrl; + + tcgetattr(FD, &cntrl); + cfsetospeed(&cntrl, bm->baud); + cfsetispeed(&cntrl, bm->baud); + tcsetattr(FD, TCSAFLUSH, &cntrl); signal(SIGALRM, f); #ifdef DEBUG if (boolean(value(VERBOSE))) @@ -268,7 +268,7 @@ coursync() char buf[40]; while (already++ < MAXRETRY) { - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ + tcflush(FD, TCIOFLUSH); cour_write(FD, "\rAT Z\r", 6); /* reset modem */ bzero(buf, sizeof(buf)); sleep(1); @@ -307,18 +307,15 @@ int fd; char *cp; int n; { - struct sgttyb sb; #ifdef notdef if (boolean(value(VERBOSE))) write(1, cp, n); #endif - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); + tcdrain(fd); cour_nap(); for ( ; n-- ; cp++) { write(fd, cp, 1); - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); + tcdrain(fd); cour_nap(); } } diff --git a/usr.bin/tip/aculib/df.c b/usr.bin/tip/aculib/df.c index bc843d7291d..f0581e63c7a 100644 --- a/usr.bin/tip/aculib/df.c +++ b/usr.bin/tip/aculib/df.c @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.3 1994/12/08 09:31:38 jtc Exp $ */ +/* $NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: df.c,v 1.3 1994/12/08 09:31:38 jtc Exp $"; +static char rcsid[] = "$NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $"; #endif /* not lint */ /* @@ -68,11 +68,13 @@ df_dialer(num, acu, df03) int df03; { register int f = FD; - struct sgttyb buf; + struct termios cntrl; int speed = 0, rw = 2; char c = '\0'; - ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ + tcgetattr(f, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(f, TCSANOW, &cntrl); if (setjmp(Sjbuf)) { printf("connection timed out\r\n"); df_disconnect(); @@ -85,11 +87,12 @@ df_dialer(num, acu, df03) if (df03) { int st = TIOCM_ST; /* secondary Transmit flag */ - ioctl(f, TIOCGETP, &buf); - if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ - speed = buf.sg_ospeed; - buf.sg_ospeed = buf.sg_ispeed = B1200; - ioctl(f, TIOCSETP, &buf); + tcgetattr(f, &cntrl); + speed = cfgetospeed(&cntrl); + if (speed != B1200) { /* must dial at 1200 baud */ + cfsetospeed(&cntrl, B1200); + cfsetispeed(&cntrl, B1200); + tcsetattr(f, TCSAFLUSH, &cntrl); ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ } else ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ @@ -97,16 +100,17 @@ df_dialer(num, acu, df03) #endif signal(SIGALRM, timeout); alarm(5 * strlen(num) + 10); - ioctl(f, TIOCFLUSH, &rw); + tcflush(f, TCIOFLUSH); write(f, "\001", 1); sleep(1); write(f, "\002", 1); write(f, num, strlen(num)); read(f, &c, 1); #ifdef TIOCMSET - if (df03 && speed) { - buf.sg_ispeed = buf.sg_ospeed = speed; - ioctl(f, TIOCSETP, &buf); + if (df03 && speed != B1200) { + cfsetospeed(&cntrl, speed); + cfsetispeed(&cntrl, speed); + tcsetattr(f, TCSAFLUSH, &cntrl); } #endif return (c == 'A'); @@ -118,7 +122,7 @@ df_disconnect() write(FD, "\001", 1); sleep(1); - ioctl(FD, TIOCFLUSH, &rw); + tcflush(FD, TCIOFLUSH); } diff --git a/usr.bin/tip/aculib/dn11.c b/usr.bin/tip/aculib/dn11.c index d310deb723b..37d97618d64 100644 --- a/usr.bin/tip/aculib/dn11.c +++ b/usr.bin/tip/aculib/dn11.c @@ -1,4 +1,4 @@ -/* $NetBSD: dn11.c,v 1.3 1994/12/08 09:31:40 jtc Exp $ */ +/* $NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: dn11.c,v 1.3 1994/12/08 09:31:40 jtc Exp $"; +static char rcsid[] = "$NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $"; #endif /* not lint */ /* @@ -57,6 +57,7 @@ dn_dialer(num, acu) char *p, *q, phone[40]; int lt, nw, connected = 1; register int timelim; + struct termios cntrl; if (boolean(value(VERBOSE))) printf("\nstarting call..."); @@ -100,7 +101,9 @@ dn_dialer(num, acu) return (0); } alarm(0); - ioctl(dn, TIOCHPCL, 0); + tcgetattr(dn, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(dn, TCSANOW, &cntrl); signal(SIGALRM, SIG_DFL); while ((nw = wait(<)) != child && nw != -1) ; diff --git a/usr.bin/tip/aculib/hayes.c b/usr.bin/tip/aculib/hayes.c index a35256fe318..d8ff831e587 100644 --- a/usr.bin/tip/aculib/hayes.c +++ b/usr.bin/tip/aculib/hayes.c @@ -1,4 +1,4 @@ -/* $NetBSD: hayes.c,v 1.3 1994/12/08 09:31:42 jtc Exp $ */ +/* $NetBSD: hayes.c,v 1.4 1995/10/29 00:49:54 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: hayes.c,v 1.3 1994/12/08 09:31:42 jtc Exp $"; +static char rcsid[] = "$NetBSD: hayes.c,v 1.4 1995/10/29 00:49:54 pk Exp $"; #endif /* not lint */ /* @@ -65,6 +65,9 @@ static char rcsid[] = "$NetBSD: hayes.c,v 1.3 1994/12/08 09:31:42 jtc Exp $"; */ #include "tip.h" +#include <termios.h> +#include <sys/ioctl.h> + #define min(a,b) ((a < b) ? a : b) static void sigALRM(); @@ -87,6 +90,7 @@ hay_dialer(num, acu) register char *cp; register int connected = 0; char dummy; + struct termios cntrl; #ifdef ACULOG char line[80]; #endif @@ -95,8 +99,10 @@ hay_dialer(num, acu) if (boolean(value(VERBOSE))) printf("\ndialing..."); fflush(stdout); - ioctl(FD, TIOCHPCL, 0); - ioctl(FD, TIOCFLUSH, 0); /* get rid of garbage */ + tcgetattr(FD, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(FD, TCSANOW, &cntrl); + tcflush(FD, TCIOFLUSH); write(FD, "ATv0\r", 5); /* tell modem to use short status codes */ gobble("\r"); gobble("\r"); @@ -117,7 +123,7 @@ hay_dialer(num, acu) state = FAILED; return (connected); /* lets get out of here.. */ } - ioctl(FD, TIOCFLUSH, 0); + tcflush(FD, TCIOFLUSH); #ifdef ACULOG if (timeout) { sprintf(line, "%d second dial timeout", @@ -245,11 +251,11 @@ goodbye() int len, rlen; char c; - ioctl(FD, TIOCFLUSH, &len); /* get rid of trash */ + tcflush(FD, TCIOFLUSH); if (hay_sync()) { sleep(1); #ifndef DEBUG - ioctl(FD, TIOCFLUSH, 0); + tcflush(FD, TCIOFLUSH); #endif write(FD, "ATH0\r", 5); /* insurance */ #ifndef DEBUG @@ -277,7 +283,7 @@ goodbye() printf("read (%d): %s\r\n", rlen, dumbuf); #endif } - ioctl(FD, TIOCFLUSH, 0); /* clear the input buffer */ + tcflush(FD, TCIOFLUSH); ioctl(FD, TIOCCDTR, 0); /* clear DTR (insurance) */ close(FD); } diff --git a/usr.bin/tip/aculib/t3000.c b/usr.bin/tip/aculib/t3000.c index e6e1813a879..94bbf9a6f0a 100644 --- a/usr.bin/tip/aculib/t3000.c +++ b/usr.bin/tip/aculib/t3000.c @@ -1,4 +1,4 @@ -/* $NetBSD: t3000.c,v 1.2 1994/12/08 09:31:45 jtc Exp $ */ +/* $NetBSD: t3000.c,v 1.3 1995/10/29 00:49:57 pk Exp $ */ /* * Copyright (c) 1992, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: t3000.c,v 1.2 1994/12/08 09:31:45 jtc Exp $"; +static char rcsid[] = "$NetBSD: t3000.c,v 1.3 1995/10/29 00:49:57 pk Exp $"; #endif /* not lint */ /* @@ -45,6 +45,8 @@ static char rcsid[] = "$NetBSD: t3000.c,v 1.2 1994/12/08 09:31:45 jtc Exp $"; * Derived from Courier driver. */ #include "tip.h" + +#include <sys/ioctl.h> #include <stdio.h> #define MAXRETRY 5 @@ -60,6 +62,7 @@ t3000_dialer(num, acu) char *acu; { register char *cp; + struct termios cntrl; #ifdef ACULOG char line[80]; #endif @@ -68,7 +71,9 @@ t3000_dialer(num, acu) if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); - ioctl(FD, TIOCHPCL, 0); + tcgetattr(FD, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(FD, TCSANOW, &cntrl); /* * Get in synch. */ @@ -86,7 +91,7 @@ badsynch: if (boolean(value(VERBOSE))) t3000_verbose_read(); #endif - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ + tcflush(FD, TCIOFLUSH); t3000_write(FD, "AT E0 H0 Q0 X4 V1\r", 18); if (!t3000_swallow("\r\nOK\r\n")) goto badsynch; @@ -200,7 +205,6 @@ t3000_connect() { char c; int nc, nl, n; - struct sgttyb sb; char dialer_buf[64]; struct tbaud_msg *bm; sig_t f; @@ -239,25 +243,12 @@ again: for (bm = tbaud_msg ; bm->msg ; bm++) if (strcmp(bm->msg, dialer_buf+sizeof("CONNECT")-1) == 0) { - if (ioctl(FD, TIOCGETP, &sb) < 0) { - perror("TIOCGETP"); - goto error; - } - sb.sg_ispeed = sb.sg_ospeed = bm->baud; - if (ioctl(FD, TIOCSETP, &sb) < 0) { - if (bm->baud2) { - sb.sg_ispeed = - sb.sg_ospeed = - bm->baud2; - if (ioctl(FD, - TIOCSETP, - &sb) >= 0) - goto isok; - } - perror("TIOCSETP"); - goto error; - } -isok: + struct termios cntrl; + + tcgetattr(FD, &cntrl); + cfsetospeed(&cntrl, bm->baud); + cfsetispeed(&cntrl, bm->baud); + tcsetattr(FD, TCSAFLUSH, &cntrl); signal(SIGALRM, f); #ifdef DEBUG if (boolean(value(VERBOSE))) @@ -292,7 +283,7 @@ t3000_sync() char buf[40]; while (already++ < MAXRETRY) { - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ + tcflush(FD, TCIOFLUSH); t3000_write(FD, "\rAT Z\r", 6); /* reset modem */ bzero(buf, sizeof(buf)); sleep(2); @@ -334,19 +325,15 @@ int fd; char *cp; int n; { - struct sgttyb sb; - #ifdef notdef if (boolean(value(VERBOSE))) write(1, cp, n); #endif - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); + tcdrain(fd); t3000_nap(); for ( ; n-- ; cp++) { write(fd, cp, 1); - ioctl(fd, TIOCGETP, &sb); - ioctl(fd, TIOCSETP, &sb); + tcdrain(fd); t3000_nap(); } } diff --git a/usr.bin/tip/aculib/v3451.c b/usr.bin/tip/aculib/v3451.c index cd4077277c1..da7f23c405e 100644 --- a/usr.bin/tip/aculib/v3451.c +++ b/usr.bin/tip/aculib/v3451.c @@ -1,4 +1,4 @@ -/* $NetBSD: v3451.c,v 1.3 1994/12/08 09:31:48 jtc Exp $ */ +/* $NetBSD: v3451.c,v 1.4 1995/10/29 00:49:59 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: v3451.c,v 1.3 1994/12/08 09:31:48 jtc Exp $"; +static char rcsid[] = "$NetBSD: v3451.c,v 1.4 1995/10/29 00:49:59 pk Exp $"; #endif /* not lint */ /* @@ -55,6 +55,7 @@ v3451_dialer(num, acu) int ok; int slow = number(value(BAUDRATE)) < 1200, rw = 2; char phone[50]; + struct termios cntrl; #ifdef ACULOG char line[80]; #endif @@ -75,7 +76,9 @@ v3451_dialer(num, acu) #endif return (0); } - ioctl(FD, TIOCHPCL, 0); + tcgetattr(FD, &cntrl); + term.c_cflag |= HUPCL; + tcsetattr(FD, TCSANOW, &cntrl); sleep(1); vawrite("D\r", 2 + slow); if (!expect("NUMBER?")) { @@ -121,7 +124,7 @@ v3451_dialer(num, acu) #endif return (0); } - ioctl(FD, TIOCFLUSH, &rw); + tcflush(FD, TCIOFLUSH); return (1); } diff --git a/usr.bin/tip/aculib/v831.c b/usr.bin/tip/aculib/v831.c index 5a7d92fea45..42994e540a8 100644 --- a/usr.bin/tip/aculib/v831.c +++ b/usr.bin/tip/aculib/v831.c @@ -1,4 +1,4 @@ -/* $NetBSD: v831.c,v 1.3 1994/12/08 09:31:50 jtc Exp $ */ +/* $NetBSD: v831.c,v 1.4 1995/10/29 00:50:02 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,13 +37,14 @@ #if 0 static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: v831.c,v 1.3 1994/12/08 09:31:50 jtc Exp $"; +static char rcsid[] = "$NetBSD: v831.c,v 1.4 1995/10/29 00:50:02 pk Exp $"; #endif /* not lint */ /* * Routines for dialing up on Vadic 831 */ #include "tip.h" +#include <termios.h> int v831_abort(); static void alarmtr(); @@ -106,9 +107,6 @@ v831_dialer(num, acu) return (0); } alarm(0); -#ifdef notdef - ioctl(AC, TIOCHPCL, 0); -#endif signal(SIGALRM, SIG_DFL); while ((pid = wait(&status)) != child && pid != -1) ; @@ -132,7 +130,7 @@ alarmtr() */ v831_disconnect() { - struct sgttyb cntrl; + struct termios cntrl; sleep(2); #ifdef DEBUG @@ -140,10 +138,11 @@ v831_disconnect() #endif if (FD > 0) { ioctl(FD, TIOCCDTR, 0); - ioctl(FD, TIOCGETP, &cntrl); - cntrl.sg_ispeed = cntrl.sg_ospeed = 0; - ioctl(FD, TIOCSETP, &cntrl); - ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); + tcgetattr(FD, &cntrl); + cfsetospeed(&cntrl, 0); + cfsetispeed(&cntrl, 0); + tcsetattr(FD, TCSAFLUSH, &cntrl); + ioctl(FD, TIOCNXCL, NULL); } close(FD); } @@ -158,7 +157,7 @@ v831_abort() if (child > 0) kill(child, SIGKILL); if (AC > 0) - ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); + ioctl(FD, TIOCNXCL, NULL); close(AC); if (FD > 0) ioctl(FD, TIOCCDTR, 0); @@ -190,7 +189,7 @@ dialit(phonenum, acu) char *acu; { register struct vaconfig *vp; - struct sgttyb cntrl; + struct termios cntrl; char c; int i, two = 2; static char *sanitize(); @@ -208,11 +207,13 @@ dialit(phonenum, acu) printf("Unable to locate dialer (%s)\n", acu); return ('K'); } - ioctl(AC, TIOCGETP, &cntrl); - cntrl.sg_ispeed = cntrl.sg_ospeed = B2400; - cntrl.sg_flags = RAW | EVENP | ODDP; - ioctl(AC, TIOCSETP, &cntrl); - ioctl(AC, TIOCFLUSH, &two); + tcgetattr(AC, &cntrl); + cfsetospeed(&cntrl, B2400); + cfsetispeed(&cntrl, B2400); + cntrl.c_cflag |= PARODD | PARENB; + cntrl.c_lflag &= ~(ISIG | ICANON); + tcsetattr(AC, TCSANOW, &cntrl); + tcflush(AC, TCIOFLUSH); pc(STX); pc(vp->vc_rack); pc(vp->vc_modem); diff --git a/usr.bin/tip/aculib/ventel.c b/usr.bin/tip/aculib/ventel.c index 9ebb4188ce1..0ce43ed7aad 100644 --- a/usr.bin/tip/aculib/ventel.c +++ b/usr.bin/tip/aculib/ventel.c @@ -1,4 +1,4 @@ -/* $NetBSD: ventel.c,v 1.3 1994/12/08 09:31:52 jtc Exp $ */ +/* $NetBSD: ventel.c,v 1.4 1995/10/29 00:50:04 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: ventel.c,v 1.3 1994/12/08 09:31:52 jtc Exp $"; +static char rcsid[] = "$NetBSD: ventel.c,v 1.4 1995/10/29 00:50:04 pk Exp $"; #endif /* not lint */ /* @@ -45,6 +45,8 @@ static char rcsid[] = "$NetBSD: ventel.c,v 1.3 1994/12/08 09:31:52 jtc Exp $"; * The Ventel is expected to be strapped for local echo (just like uucp) */ #include "tip.h" +#include <termios.h> +#include <sys/ioctl.h> #define MAXRETRY 5 @@ -71,6 +73,7 @@ ven_dialer(num, acu) char *msg, *index(), line[80]; static int gobble(), vensync(); static void echo(); + struct termios cntrl; /* * Get in synch with a couple of carriage returns @@ -85,7 +88,9 @@ ven_dialer(num, acu) if (boolean(value(VERBOSE))) printf("\ndialing..."); fflush(stdout); - ioctl(FD, TIOCHPCL, 0); + tcgetattr(FD, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(FD, TCSANOW, &cntrl); echo("#k$\r$\n$D$I$A$L$:$ "); for (cp = num; *cp; cp++) { delay(1, 10); @@ -96,7 +101,7 @@ ven_dialer(num, acu) gobble('\n', line); if (gobble('\n', line)) connected = gobble('!', line); - ioctl(FD, TIOCFLUSH); + tcflush(FD, TCIOFLUSH); #ifdef ACULOG if (timeout) { sprintf(line, "%d second dial timeout", diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c index 40022029965..8d2409b0b9d 100644 --- a/usr.bin/tip/cmds.c +++ b/usr.bin/tip/cmds.c @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.5 1995/09/26 06:02:08 jtc Exp $ */ +/* $NetBSD: cmds.c,v 1.6 1995/10/29 00:49:38 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: cmds.c,v 1.5 1995/09/26 06:02:08 jtc Exp $"; +static char rcsid[] = "$NetBSD: cmds.c,v 1.6 1995/10/29 00:49:38 pk Exp $"; #endif /* not lint */ #include "tip.h" @@ -144,15 +144,15 @@ transfer(buf, fd, eofchars) pwrite(FD, &r, 1); do read(FD, &c, 1); - while ((c&0177) != '\n'); - ioctl(0, TIOCSETC, &defchars); + while ((c&STRIP_PAR) != '\n'); + tcsetattr(0, TCSAFLUSH, &defchars); (void) setjmp(intbuf); f = signal(SIGINT, intcopy); start = time(0); for (ct = 0; !quit;) { eof = read(FD, &c, 1) <= 0; - c &= 0177; + c &= STRIP_PAR; if (quit) continue; if (eof || any(c, eofchars)) @@ -179,7 +179,7 @@ transfer(buf, fd, eofchars) if (boolean(value(VERBOSE))) prtime(" lines transferred in ", time(0)-start); - ioctl(0, TIOCSETC, &tchars); + tcsetattr(0, TCSAFLUSH, &term); write(fildes[1], (char *)&ccc, 1); signal(SIGINT, f); close(fd); @@ -271,12 +271,8 @@ sendfile(cc) return; } transmit(fd, value(EOFWRITE), NULL); - if (!boolean(value(ECHOCHECK))) { - struct sgttyb buf; - - ioctl(FD, TIOCGETP, &buf); /* this does a */ - ioctl(FD, TIOCSETP, &buf); /* wflushtty */ - } + if (!boolean(value(ECHOCHECK))) + tcdrain(FD); } /* @@ -295,7 +291,7 @@ transmit(fd, eofchars, command) kill(pid, SIGIOT); /* put TIPOUT into a wait state */ stop = 0; f = signal(SIGINT, stopsnd); - ioctl(0, TIOCSETC, &defchars); + tcsetattr(0, TCSAFLUSH, &defchars); read(repdes[0], (char *)&ccc, 1); if (command != NULL) { for (pc = command; *pc; pc++) @@ -303,10 +299,7 @@ transmit(fd, eofchars, command) if (boolean(value(ECHOCHECK))) read(FD, (char *)&c, 1); /* trailing \n */ else { - struct sgttyb buf; - - ioctl(FD, TIOCGETP, &buf); /* this does a */ - ioctl(FD, TIOCSETP, &buf); /* wflushtty */ + tcdrain(FD); sleep(5); /* wait for remote stty to take effect */ } } @@ -357,7 +350,7 @@ transmit(fd, eofchars, command) alarm(0); goto out; } - } while ((c&0177) != character(value(PROMPT))); + } while ((c&STRIP_PAR) != character(value(PROMPT))); alarm(0); } } @@ -377,7 +370,7 @@ out: else prtime(" lines transferred in ", stop_t-start_t); write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); + tcsetattr(0, TCSAFLUSH, &term); } /* @@ -472,7 +465,7 @@ pipeout(c) kill(pid, SIGIOT); /* put TIPOUT into a wait state */ signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); - ioctl(0, TIOCSETC, &defchars); + tcsetattr(0, TCSAFLUSH, &defchars); read(repdes[0], (char *)&ccc, 1); /* * Set up file descriptors in the child and @@ -499,7 +492,7 @@ pipeout(c) if (boolean(value(VERBOSE))) prtime("away for ", time(0)-start); write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); + tcsetattr(0, TCSAFLUSH, &term); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); } @@ -523,7 +516,7 @@ consh(c) kill(pid, SIGIOT); /* put TIPOUT into a wait state */ signal(SIGINT, SIG_IGN); signal(SIGQUIT, SIG_IGN); - ioctl(0, TIOCSETC, &defchars); + tcsetattr(0, TCSAFLUSH, &defchars); read(repdes[0], (char *)&ccc, 1); /* * Set up file descriptors in the child and @@ -551,7 +544,7 @@ consh(c) if (boolean(value(VERBOSE))) prtime("away for ", time(0)-start); write(fildes[1], (char *)&ccc, 1); - ioctl(0, TIOCSETC, &tchars); + tcsetattr(0, TCSAFLUSH, &term); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); } @@ -771,18 +764,18 @@ variable() tandem(option) char *option; { - struct sgttyb rmtty; + struct termios rmtty; - ioctl(FD, TIOCGETP, &rmtty); - if (strcmp(option,"on") == 0) { - rmtty.sg_flags |= TANDEM; - arg.sg_flags |= TANDEM; + tcgetattr(FD, &rmtty); + if (strcmp(option, "on") == 0) { + rmtty.c_iflag |= IXOFF; + term.c_iflag |= IXOFF; } else { - rmtty.sg_flags &= ~TANDEM; - arg.sg_flags &= ~TANDEM; + rmtty.c_iflag &= ~IXOFF; + term.c_iflag &= ~IXOFF; } - ioctl(FD, TIOCSETP, &rmtty); - ioctl(0, TIOCSETP, &arg); + tcsetattr(FD, TCSADRAIN, &rmtty); + tcsetattr(0, TCSADRAIN, &term); } /* diff --git a/usr.bin/tip/hunt.c b/usr.bin/tip/hunt.c index 970b6a5d491..b490a7f7de2 100644 --- a/usr.bin/tip/hunt.c +++ b/usr.bin/tip/hunt.c @@ -1,4 +1,4 @@ -/* $NetBSD: hunt.c,v 1.4 1994/12/24 17:56:27 cgd Exp $ */ +/* $NetBSD: hunt.c,v 1.5 1995/10/29 00:49:40 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: hunt.c,v 1.4 1994/12/24 17:56:27 cgd Exp $"; +static char rcsid[] = "$NetBSD: hunt.c,v 1.5 1995/10/29 00:49:40 pk Exp $"; #endif /* not lint */ #include "tip.h" @@ -87,8 +87,12 @@ hunt(name) deadfl = 1; } if (!deadfl) { + struct termios cntrl; + + tcgetattr(FD, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(FD, TCSAFLUSH, &cntrl); ioctl(FD, TIOCEXCL, 0); - ioctl(FD, TIOCHPCL, 0); signal(SIGALRM, SIG_DFL); return ((long)cp); } diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c index ae08425d696..860f2456765 100644 --- a/usr.bin/tip/tip.c +++ b/usr.bin/tip/tip.c @@ -1,4 +1,4 @@ -/* $NetBSD: tip.c,v 1.7 1995/08/11 00:10:40 jtc Exp $ */ +/* $NetBSD: tip.c,v 1.8 1995/10/29 00:49:42 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: tip.c,v 1.7 1995/08/11 00:10:40 jtc Exp $"; +static char rcsid[] = "$NetBSD: tip.c,v 1.8 1995/10/29 00:49:42 pk Exp $"; #endif /* not lint */ /* @@ -58,12 +58,12 @@ static char rcsid[] = "$NetBSD: tip.c,v 1.7 1995/08/11 00:10:40 jtc Exp $"; /* * Baud rate mapping table */ -int bauds[] = { +int rates[] = { 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1 }; -int disc = OTTYDISC; /* tip normally runs this way */ +int disc = TTYDISC; /* tip normally runs this way */ void intprompt(); void timeout(); void cleanup(); @@ -173,7 +173,7 @@ notnumber: PH = _PATH_PHONES; vinit(); /* init variables */ setparity("even"); /* set the parity table */ - if ((i = speed(number(value(BAUDRATE)))) == NULL) { + if ((i = speed(number(value(BAUDRATE)))) == 0) { printf("tip: bad baud rate %d\n", number(value(BAUDRATE))); daemon_uid(); (void)uu_unlock(uucplock); @@ -201,17 +201,17 @@ cucommon: * the "cu" version of tip. */ - ioctl(0, TIOCGETP, (char *)&defarg); - ioctl(0, TIOCGETC, (char *)&defchars); - ioctl(0, TIOCGLTC, (char *)&deflchars); - ioctl(0, TIOCGETD, (char *)&odisc); - arg = defarg; - arg.sg_flags = ANYP | CBREAK; - tchars = defchars; - tchars.t_intrc = tchars.t_quitc = -1; - ltchars = deflchars; - ltchars.t_suspc = ltchars.t_dsuspc = ltchars.t_flushc - = ltchars.t_lnextc = -1; + tcgetattr(0, &defterm); + term = defterm; + term.c_lflag &= ~(ICANON|IEXTEN|ECHO); + term.c_iflag &= ~(INPCK|ICRNL); + term.c_oflag &= ~OPOST; + term.c_cc[VMIN] = 1; + 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; raw(); pipe(fildes); pipe(repdes); @@ -280,11 +280,7 @@ shell_uid() */ raw() { - - ioctl(0, TIOCSETP, &arg); - ioctl(0, TIOCSETC, &tchars); - ioctl(0, TIOCSLTC, <chars); - ioctl(0, TIOCSETD, (char *)&disc); + tcsetattr(0, TCSADRAIN, &term); } @@ -293,11 +289,7 @@ raw() */ unraw() { - - ioctl(0, TIOCSETD, (char *)&odisc); - ioctl(0, TIOCSETP, (char *)&defarg); - ioctl(0, TIOCSETC, (char *)&defchars); - ioctl(0, TIOCSLTC, (char *)&deflchars); + tcsetattr(0, TCSADRAIN, &defterm); } static jmp_buf promptbuf; @@ -363,7 +355,7 @@ tipin() } while (1) { - gch = getchar()&0177; + gch = getchar()&STRIP_PAR; if ((gch == character(value(ESCAPE))) && bol) { if (!(gch = escape())) continue; @@ -377,7 +369,7 @@ tipin() printf("\r\n"); continue; } else if (!cumode && gch == character(value(FORCE))) - gch = getchar()&0177; + gch = getchar()&STRIP_PAR; bol = any(gch, value(EOL)); if (boolean(value(RAISE)) && islower(gch)) gch = toupper(gch); @@ -399,7 +391,7 @@ escape() register esctable_t *p; char c = character(value(ESCAPE)); - gch = (getchar()&0177); + gch = (getchar()&STRIP_PAR); for (p = etable; p->e_char; p++) if (p->e_char == gch) { if ((p->e_flags&PRIV) && uid) @@ -419,10 +411,10 @@ speed(n) { register int *p; - for (p = bauds; *p != -1; p++) + for (p = rates; *p != -1; p++) if (*p == n) - return (p - bauds); - return (NULL); + return n; + return 0; } any(c, p) @@ -511,14 +503,21 @@ help(c) ttysetup(speed) int speed; { - unsigned bits = LDECCTQ; - - arg.sg_ispeed = arg.sg_ospeed = speed; - arg.sg_flags = RAW; + struct termios cntrl; + + tcgetattr(FD, &cntrl); + cfsetospeed(&cntrl, speed); + cfsetispeed(&cntrl, speed); + cntrl.c_cflag &= ~(CSIZE|PARENB); + cntrl.c_cflag |= CS8; + cntrl.c_iflag &= ~(ISTRIP|ICRNL); + cntrl.c_oflag &= ~OPOST; + cntrl.c_lflag &= ~(ICANON|ISIG|IEXTEN|ECHO); + cntrl.c_cc[VMIN] = 1; + cntrl.c_cc[VTIME] = 0; if (boolean(value(TAND))) - arg.sg_flags |= TANDEM; - ioctl(FD, TIOCSETP, (char *)&arg); - ioctl(FD, TIOCLBIS, (char *)&bits); + cntrl.c_iflag |= IXOFF; + tcsetattr(FD, TCSAFLUSH, &cntrl); } /* @@ -538,7 +537,6 @@ sname(s) } static char partab[0200]; -static int bits8; /* * Do a write to the remote machine with the correct parity. diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h index e96946656cb..7591ebf1877 100644 --- a/usr.bin/tip/tip.h +++ b/usr.bin/tip/tip.h @@ -1,4 +1,4 @@ -/* $NetBSD: tip.h,v 1.3 1994/12/08 09:31:10 jtc Exp $ */ +/* $NetBSD: tip.h,v 1.4 1995/10/29 00:49:43 pk Exp $ */ /* * Copyright (c) 1989, 1993 @@ -45,7 +45,7 @@ #include <sys/file.h> #include <sys/time.h> -#include <sgtty.h> +#include <termios.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -241,12 +241,9 @@ extern value_t vtable[]; /* variable table */ #define NOFILE ((FILE *)NULL) #define NOPWD ((struct passwd *)0) -struct sgttyb arg; /* current mode of local terminal */ -struct sgttyb defarg; /* initial mode of local terminal */ -struct tchars tchars; /* current state of terminal */ -struct tchars defchars; /* initial state of terminal */ -struct ltchars ltchars; /* current local characters of terminal */ -struct ltchars deflchars; /* initial local characters of terminal */ +struct termios term; /* current mode of terminal */ +struct termios defterm; /* initial mode of terminal */ +struct termios defchars; /* current mode with initial chars */ FILE *fscript; /* FILE for scripting */ @@ -265,6 +262,8 @@ int intflag; /* recognized interrupt */ int stoprompt; /* for interrupting a prompt session */ int timedout; /* ~> transfer timedout */ int cumode; /* simulating the "cu" program */ +int bits8; /* terminal is is 8-bit mode */ +#define STRIP_PAR (bits8 ? 0377 : 0177) char fname[80]; /* file name buffer for ~< */ char copyname[80]; /* file name buffer for ~> */ diff --git a/usr.bin/tip/tipout.c b/usr.bin/tip/tipout.c index 9ee5a02b0b6..08571567020 100644 --- a/usr.bin/tip/tipout.c +++ b/usr.bin/tip/tipout.c @@ -1,4 +1,4 @@ -/* $NetBSD: tipout.c,v 1.3 1994/12/08 09:31:12 jtc Exp $ */ +/* $NetBSD: tipout.c,v 1.4 1995/10/29 00:49:45 pk Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$NetBSD: tipout.c,v 1.3 1994/12/08 09:31:12 jtc Exp $"; +static char rcsid[] = "$NetBSD: tipout.c,v 1.4 1995/10/29 00:49:45 pk Exp $"; #endif /* not lint */ #include "tip.h" @@ -147,7 +147,7 @@ tipout() #define ALLSIGS sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS) omask = sigblock(ALLSIGS); for (cp = buf; cp < buf + cnt; cp++) - *cp &= 0177; + *cp &= STRIP_PAR; write(1, buf, cnt); if (boolean(value(SCRIPT)) && fscript != NULL) { if (!boolean(value(BEAUTIFY))) { |