summaryrefslogtreecommitdiff
path: root/usr.bin/tip/cmds.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/cmds.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/cmds.c')
-rw-r--r--usr.bin/tip/cmds.c57
1 files changed, 25 insertions, 32 deletions
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);
}
/*