Simplistic conversion of mail to use termios instead of sgtty.

This commit is contained in:
peter 1996-08-19 20:23:35 +00:00
parent 65b6e7181b
commit d093c7b48e
4 changed files with 23 additions and 21 deletions

View File

@ -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

View File

@ -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>

View File

@ -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;

View File

@ -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 @@ grabh(hp, gflags)
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);