summaryrefslogtreecommitdiff
path: root/usr.bin/tip/aculib/t3000.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-14 03:12:29 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-12-14 03:12:29 +0000
commit95f41a9ae474619e43de33821c56a85f414715cf (patch)
treeeb3ce58ea6ccdaad669b142ab07eaa87a1e607f9 /usr.bin/tip/aculib/t3000.c
parenta3b7a686b1f0e746c512c93cd1f36367834d8f33 (diff)
from netbsd:
Convert to termios (from Scott Reynolds; PR#1621). 8-bit patches (from Matthieu Herrb; PR#1384).
Diffstat (limited to 'usr.bin/tip/aculib/t3000.c')
-rw-r--r--usr.bin/tip/aculib/t3000.c49
1 files changed, 18 insertions, 31 deletions
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();
}
}