summaryrefslogtreecommitdiffstats
path: root/usr.bin/mail
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-08-19 20:23:35 +0000
committerpeter <peter@FreeBSD.org>1996-08-19 20:23:35 +0000
commitd093c7b48e95c00d2fcbc70970b1e99c1a5712b7 (patch)
tree2f7a1aed406bea4049bb1f4e000e564c5c306112 /usr.bin/mail
parent65b6e7181bc8bde1918c94186c38543764663453 (diff)
downloadFreeBSD-src-d093c7b48e95c00d2fcbc70970b1e99c1a5712b7.zip
FreeBSD-src-d093c7b48e95c00d2fcbc70970b1e99c1a5712b7.tar.gz
Simplistic conversion of mail to use termios instead of sgtty.
Diffstat (limited to 'usr.bin/mail')
-rw-r--r--usr.bin/mail/Makefile1
-rw-r--r--usr.bin/mail/def.h2
-rw-r--r--usr.bin/mail/main.c13
-rw-r--r--usr.bin/mail/tty.c28
4 files changed, 23 insertions, 21 deletions
diff --git a/usr.bin/mail/Makefile b/usr.bin/mail/Makefile
index ac2f642..8724206 100644
--- a/usr.bin/mail/Makefile
+++ b/usr.bin/mail/Makefile
@@ -1,7 +1,6 @@
# @(#)Makefile 8.2 (Berkeley) 1/25/94
PROG= mail
-CFLAGS+=-DUSE_OLD_TTY
SRCS= version.c aux.c cmd1.c cmd2.c cmd3.c cmdtab.c collect.c edit.c fio.c \
getname.c head.c v7.local.c lex.c list.c main.c names.c popen.c \
quit.c send.c strings.c temp.c tty.c vars.c
diff --git a/usr.bin/mail/def.h b/usr.bin/mail/def.h
index 1faca76..6ed65a4 100644
--- a/usr.bin/mail/def.h
+++ b/usr.bin/mail/def.h
@@ -44,7 +44,7 @@
#include <sys/time.h>
#include <signal.h>
-#include <sgtty.h>
+#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c
index 1e1579b..e912ccb 100644
--- a/usr.bin/mail/main.c
+++ b/usr.bin/mail/main.c
@@ -274,16 +274,19 @@ hdrstop(signo)
void
setscreensize()
{
- struct sgttyb tbuf;
struct winsize ws;
+ struct termios tio;
+ speed_t speed = 0;
if (ioctl(1, TIOCGWINSZ, (char *) &ws) < 0)
ws.ws_col = ws.ws_row = 0;
- if (ioctl(1, TIOCGETP, &tbuf) < 0)
- tbuf.sg_ospeed = B9600;
- if (tbuf.sg_ospeed < B1200)
+ if (tcgetattr(1, &tio) != -1)
+ speed = cfgetospeed(&tio);
+ if (speed <= 0)
+ speed = B9600;
+ if (speed < B1200)
screenheight = 9;
- else if (tbuf.sg_ospeed == B1200)
+ else if (speed == B1200)
screenheight = 14;
else if (ws.ws_row != 0)
screenheight = ws.ws_row;
diff --git a/usr.bin/mail/tty.c b/usr.bin/mail/tty.c
index b39eba5..53cb456 100644
--- a/usr.bin/mail/tty.c
+++ b/usr.bin/mail/tty.c
@@ -61,7 +61,7 @@ grabh(hp, gflags)
struct header *hp;
int gflags;
{
- struct sgttyb ttybuf;
+ struct termios tio;
sig_t saveint;
#ifndef TIOCSTI
sig_t savequit;
@@ -79,15 +79,15 @@ grabh(hp, gflags)
#ifndef TIOCSTI
ttyset = 0;
#endif
- if (ioctl(fileno(stdin), TIOCGETP, &ttybuf) < 0) {
- perror("gtty");
+ if (tcgetattr(fileno(stdin), &tio) < 0) {
+ perror("tcgetattr(stdin)");
return(-1);
}
- c_erase = ttybuf.sg_erase;
- c_kill = ttybuf.sg_kill;
+ c_erase = tio.c_cc[VERASE];
+ c_kill = tio.c_cc[VKILL];
#ifndef TIOCSTI
- ttybuf.sg_erase = 0;
- ttybuf.sg_kill = 0;
+ tio.c_cc[VERASE] = 0;
+ tio.c_cc[VKILL] = 0;
if ((saveint = signal(SIGINT, SIG_IGN)) == SIG_DFL)
signal(SIGINT, SIG_DFL);
if ((savequit = signal(SIGQUIT, SIG_IGN)) == SIG_DFL)
@@ -100,7 +100,7 @@ grabh(hp, gflags)
if (gflags & GTO) {
#ifndef TIOCSTI
if (!ttyset && hp->h_to != NIL)
- ttyset++, stty(fileno(stdin), &ttybuf);
+ ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
#endif
hp->h_to =
extract(readtty("To: ", detract(hp->h_to, 0)), GTO);
@@ -108,14 +108,14 @@ grabh(hp, gflags)
if (gflags & GSUBJECT) {
#ifndef TIOCSTI
if (!ttyset && hp->h_subject != NOSTR)
- ttyset++, stty(fileno(stdin), &ttybuf);
+ ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
#endif
hp->h_subject = readtty("Subject: ", hp->h_subject);
}
if (gflags & GCC) {
#ifndef TIOCSTI
if (!ttyset && hp->h_cc != NIL)
- ttyset++, stty(fileno(stdin), &ttybuf);
+ ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
#endif
hp->h_cc =
extract(readtty("Cc: ", detract(hp->h_cc, 0)), GCC);
@@ -123,7 +123,7 @@ grabh(hp, gflags)
if (gflags & GBCC) {
#ifndef TIOCSTI
if (!ttyset && hp->h_bcc != NIL)
- ttyset++, stty(fileno(stdin), &ttybuf);
+ ttyset++, tcsetattr(fileno(stdin), TCSADRAIN, &tio);
#endif
hp->h_bcc =
extract(readtty("Bcc: ", detract(hp->h_bcc, 0)), GBCC);
@@ -133,10 +133,10 @@ out:
signal(SIGTTOU, savettou);
signal(SIGTTIN, savettin);
#ifndef TIOCSTI
- ttybuf.sg_erase = c_erase;
- ttybuf.sg_kill = c_kill;
+ tio.c_cc[VERASE] = c_erase;
+ tio.c_cc[VKILL] = c_kill;
if (ttyset)
- stty(fileno(stdin), &ttybuf);
+ tcsetattr(fileno(stdin), TCSADRAIN, &tio);
signal(SIGQUIT, savequit);
#endif
signal(SIGINT, saveint);
OpenPOWER on IntegriCloud