2007-12-08 21:35:53 +03:00
|
|
|
/* $NetBSD: tty_43.c,v 1.24 2007/12/08 18:35:55 dsl Exp $ */
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1982, 1986, 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1995-06-25 00:15:55 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1998-03-01 05:20:01 +03:00
|
|
|
* @(#)tty_compat.c 8.2 (Berkeley) 1/9/95
|
1995-06-25 00:15:55 +04:00
|
|
|
*/
|
|
|
|
|
1996-02-02 21:47:50 +03:00
|
|
|
/*
|
1995-06-25 00:15:55 +04:00
|
|
|
* mapping routines for old line discipline (yuck)
|
|
|
|
*/
|
2001-11-13 05:07:52 +03:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2007-12-08 21:35:53 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tty_43.c,v 1.24 2007/12/08 18:35:55 dsl Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1995-06-25 00:15:55 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/proc.h>
|
2000-11-02 14:00:53 +03:00
|
|
|
#include <sys/conf.h>
|
1995-06-25 00:15:55 +04:00
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/termios.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syslog.h>
|
1996-02-10 03:12:44 +03:00
|
|
|
#include <sys/ioctl_compat.h>
|
1995-06-25 00:15:55 +04:00
|
|
|
|
1996-05-19 02:17:49 +04:00
|
|
|
/*
|
|
|
|
* XXX libcompat files should be included with config attributes
|
|
|
|
*/
|
|
|
|
#ifdef COMPAT_OLDTTY
|
|
|
|
|
1995-06-25 00:15:55 +04:00
|
|
|
int ttydebug = 0;
|
|
|
|
|
2004-04-25 10:23:40 +04:00
|
|
|
static const struct speedtab compatspeeds[] = {
|
1995-06-25 00:15:55 +04:00
|
|
|
#define MAX_SPEED 17
|
|
|
|
{ 115200, 17 },
|
|
|
|
{ 57600, 16 },
|
|
|
|
{ 38400, 15 },
|
|
|
|
{ 19200, 14 },
|
|
|
|
{ 9600, 13 },
|
|
|
|
{ 4800, 12 },
|
|
|
|
{ 2400, 11 },
|
|
|
|
{ 1800, 10 },
|
|
|
|
{ 1200, 9 },
|
|
|
|
{ 600, 8 },
|
|
|
|
{ 300, 7 },
|
|
|
|
{ 200, 6 },
|
|
|
|
{ 150, 5 },
|
|
|
|
{ 134, 4 },
|
|
|
|
{ 110, 3 },
|
|
|
|
{ 75, 2 },
|
|
|
|
{ 50, 1 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ -1, -1 },
|
|
|
|
};
|
2004-04-25 10:23:40 +04:00
|
|
|
static const int compatspcodes[] = {
|
1995-06-25 00:15:55 +04:00
|
|
|
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
|
|
|
|
1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200
|
|
|
|
};
|
|
|
|
|
2007-12-04 21:40:07 +03:00
|
|
|
int ttcompatgetflags(struct tty *);
|
|
|
|
void ttcompatsetflags(struct tty *, struct termios *);
|
|
|
|
void ttcompatsetlflags(struct tty *, struct termios *);
|
1996-03-14 22:31:45 +03:00
|
|
|
|
1995-06-25 00:15:55 +04:00
|
|
|
/*ARGSUSED*/
|
1996-03-14 22:31:45 +03:00
|
|
|
int
|
2007-12-08 21:35:53 +03:00
|
|
|
ttcompat(struct tty *tp, u_long com, void *data, int flag, struct lwp *l)
|
1995-06-25 00:15:55 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
switch (com) {
|
|
|
|
case TIOCGETP: {
|
2000-03-30 15:24:16 +04:00
|
|
|
struct sgttyb *sg = (struct sgttyb *)data;
|
|
|
|
u_char *cc = tp->t_cc;
|
|
|
|
int speed;
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
speed = ttspeedtab(tp->t_ospeed, compatspeeds);
|
|
|
|
sg->sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
|
|
|
|
if (tp->t_ispeed == 0)
|
|
|
|
sg->sg_ispeed = sg->sg_ospeed;
|
|
|
|
else {
|
|
|
|
speed = ttspeedtab(tp->t_ispeed, compatspeeds);
|
|
|
|
sg->sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
|
|
|
|
}
|
|
|
|
sg->sg_erase = cc[VERASE];
|
|
|
|
sg->sg_kill = cc[VKILL];
|
|
|
|
sg->sg_flags = ttcompatgetflags(tp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case TIOCSETP:
|
|
|
|
case TIOCSETN: {
|
2000-03-30 15:24:16 +04:00
|
|
|
struct sgttyb *sg = (struct sgttyb *)data;
|
1995-06-25 00:15:55 +04:00
|
|
|
struct termios term;
|
|
|
|
int speed;
|
|
|
|
|
|
|
|
term = tp->t_termios;
|
|
|
|
if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0)
|
|
|
|
term.c_ispeed = speed;
|
|
|
|
else
|
|
|
|
term.c_ispeed = compatspcodes[speed];
|
|
|
|
if ((speed = sg->sg_ospeed) > MAX_SPEED || speed < 0)
|
|
|
|
term.c_ospeed = speed;
|
|
|
|
else
|
|
|
|
term.c_ospeed = compatspcodes[speed];
|
|
|
|
term.c_cc[VERASE] = sg->sg_erase;
|
|
|
|
term.c_cc[VKILL] = sg->sg_kill;
|
|
|
|
tp->t_flags = (ttcompatgetflags(tp)&0xffff0000) | (sg->sg_flags&0xffff);
|
|
|
|
ttcompatsetflags(tp, &term);
|
1996-02-02 21:47:50 +03:00
|
|
|
return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA,
|
2007-03-04 08:59:00 +03:00
|
|
|
(void *)&term, flag, l));
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case TIOCGETC: {
|
|
|
|
struct tchars *tc = (struct tchars *)data;
|
2000-03-30 15:24:16 +04:00
|
|
|
u_char *cc = tp->t_cc;
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
tc->t_intrc = cc[VINTR];
|
|
|
|
tc->t_quitc = cc[VQUIT];
|
|
|
|
tc->t_startc = cc[VSTART];
|
|
|
|
tc->t_stopc = cc[VSTOP];
|
|
|
|
tc->t_eofc = cc[VEOF];
|
|
|
|
tc->t_brkc = cc[VEOL];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCSETC: {
|
|
|
|
struct tchars *tc = (struct tchars *)data;
|
2000-03-30 15:24:16 +04:00
|
|
|
u_char *cc = tp->t_cc;
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
cc[VINTR] = tc->t_intrc;
|
|
|
|
cc[VQUIT] = tc->t_quitc;
|
|
|
|
cc[VSTART] = tc->t_startc;
|
|
|
|
cc[VSTOP] = tc->t_stopc;
|
|
|
|
cc[VEOF] = tc->t_eofc;
|
|
|
|
cc[VEOL] = tc->t_brkc;
|
1996-05-20 18:29:17 +04:00
|
|
|
if (tc->t_brkc == (char)-1)
|
1995-06-25 00:15:55 +04:00
|
|
|
cc[VEOL2] = _POSIX_VDISABLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCSLTC: {
|
|
|
|
struct ltchars *ltc = (struct ltchars *)data;
|
2000-03-30 15:24:16 +04:00
|
|
|
u_char *cc = tp->t_cc;
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
cc[VSUSP] = ltc->t_suspc;
|
|
|
|
cc[VDSUSP] = ltc->t_dsuspc;
|
|
|
|
cc[VREPRINT] = ltc->t_rprntc;
|
|
|
|
cc[VDISCARD] = ltc->t_flushc;
|
|
|
|
cc[VWERASE] = ltc->t_werasc;
|
|
|
|
cc[VLNEXT] = ltc->t_lnextc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCGLTC: {
|
|
|
|
struct ltchars *ltc = (struct ltchars *)data;
|
2000-03-30 15:24:16 +04:00
|
|
|
u_char *cc = tp->t_cc;
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
ltc->t_suspc = cc[VSUSP];
|
|
|
|
ltc->t_dsuspc = cc[VDSUSP];
|
|
|
|
ltc->t_rprntc = cc[VREPRINT];
|
|
|
|
ltc->t_flushc = cc[VDISCARD];
|
|
|
|
ltc->t_werasc = cc[VWERASE];
|
|
|
|
ltc->t_lnextc = cc[VLNEXT];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TIOCLBIS:
|
|
|
|
case TIOCLBIC:
|
|
|
|
case TIOCLSET: {
|
|
|
|
struct termios term;
|
1996-02-02 21:47:50 +03:00
|
|
|
int flags;
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
term = tp->t_termios;
|
|
|
|
flags = ttcompatgetflags(tp);
|
|
|
|
switch (com) {
|
|
|
|
case TIOCLSET:
|
|
|
|
tp->t_flags = (flags&0xffff) | (*(int *)data<<16);
|
|
|
|
break;
|
|
|
|
case TIOCLBIS:
|
|
|
|
tp->t_flags = flags | (*(int *)data<<16);
|
|
|
|
break;
|
|
|
|
case TIOCLBIC:
|
|
|
|
tp->t_flags = flags & ~(*(int *)data<<16);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ttcompatsetlflags(tp, &term);
|
2007-03-04 08:59:00 +03:00
|
|
|
return (ttioctl(tp, TIOCSETA, (void *)&term, flag, l));
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
|
|
|
case TIOCLGET:
|
|
|
|
*(int *)data = ttcompatgetflags(tp)>>16;
|
|
|
|
if (ttydebug)
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("CLGET: returning %x\n", *(int *)data);
|
1995-06-25 00:15:55 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OTIOCGETD:
|
2005-11-27 08:35:52 +03:00
|
|
|
*(int *)data = (tp->t_linesw == NULL) ?
|
|
|
|
2 /* XXX old NTTYDISC */ : tp->t_linesw->l_no;
|
1995-06-25 00:15:55 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OTIOCSETD: {
|
|
|
|
int ldisczero = 0;
|
|
|
|
|
1996-02-02 21:47:50 +03:00
|
|
|
return (ttioctl(tp, TIOCSETD,
|
2007-03-04 08:59:00 +03:00
|
|
|
*(int *)data == 2 ? (void *)&ldisczero : data, flag,
|
2005-12-11 15:16:03 +03:00
|
|
|
l));
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
case OTIOCCONS:
|
|
|
|
*(int *)data = 1;
|
2005-12-11 15:16:03 +03:00
|
|
|
return (ttioctl(tp, TIOCCONS, data, flag, l));
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
case TIOCHPCL:
|
1996-02-02 21:47:50 +03:00
|
|
|
SET(tp->t_cflag, HUPCL);
|
1995-06-25 00:15:55 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TIOCGSID:
|
|
|
|
if (tp->t_session == NULL)
|
|
|
|
return ENOTTY;
|
|
|
|
|
|
|
|
if (tp->t_session->s_leader == NULL)
|
|
|
|
return ENOTTY;
|
|
|
|
|
|
|
|
*(int *) data = tp->t_session->s_leader->p_pid;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2002-03-17 22:40:26 +03:00
|
|
|
return (EPASSTHROUGH);
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-02-02 21:47:50 +03:00
|
|
|
int
|
2007-12-08 21:35:53 +03:00
|
|
|
ttcompatgetflags(struct tty *tp)
|
1995-06-25 00:15:55 +04:00
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
tcflag_t iflag = tp->t_iflag;
|
|
|
|
tcflag_t lflag = tp->t_lflag;
|
|
|
|
tcflag_t oflag = tp->t_oflag;
|
|
|
|
tcflag_t cflag = tp->t_cflag;
|
|
|
|
int flags = 0;
|
1996-02-02 21:47:50 +03:00
|
|
|
|
|
|
|
if (ISSET(iflag, IXOFF))
|
|
|
|
SET(flags, TANDEM);
|
|
|
|
if (ISSET(iflag, ICRNL) || ISSET(oflag, ONLCR))
|
|
|
|
SET(flags, CRMOD);
|
|
|
|
if (ISSET(cflag, PARENB)) {
|
|
|
|
if (ISSET(iflag, INPCK)) {
|
|
|
|
if (ISSET(cflag, PARODD))
|
|
|
|
SET(flags, ODDP);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
SET(flags, EVENP);
|
1995-06-25 00:15:55 +04:00
|
|
|
} else
|
1996-02-02 21:47:50 +03:00
|
|
|
SET(flags, ANYP);
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
1996-02-02 21:47:50 +03:00
|
|
|
|
|
|
|
if (!ISSET(lflag, ICANON)) {
|
1995-06-25 00:15:55 +04:00
|
|
|
/* fudge */
|
1996-02-02 21:47:50 +03:00
|
|
|
if (ISSET(iflag, IXON) || ISSET(lflag, ISIG|IEXTEN) ||
|
|
|
|
ISSET(cflag, PARENB))
|
|
|
|
SET(flags, CBREAK);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
SET(flags, RAW);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ISSET(flags, RAW))
|
|
|
|
SET(flags, ISSET(tp->t_flags, LITOUT|PASS8));
|
|
|
|
else if (ISSET(cflag, CSIZE) == CS8) {
|
|
|
|
if (!ISSET(oflag, OPOST))
|
|
|
|
SET(flags, LITOUT);
|
|
|
|
if (!ISSET(iflag, ISTRIP))
|
|
|
|
SET(flags, PASS8);
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
1996-02-02 21:47:50 +03:00
|
|
|
|
|
|
|
if (ISSET(cflag, MDMBUF))
|
|
|
|
SET(flags, MDMBUF);
|
|
|
|
if (!ISSET(cflag, HUPCL))
|
|
|
|
SET(flags, NOHANG);
|
|
|
|
if (ISSET(oflag, OXTABS))
|
|
|
|
SET(flags, XTABS);
|
|
|
|
if (ISSET(lflag, ECHOE))
|
|
|
|
SET(flags, CRTERA|CRTBS);
|
|
|
|
if (ISSET(lflag, ECHOKE))
|
|
|
|
SET(flags, CRTKIL|CRTBS);
|
|
|
|
if (ISSET(lflag, ECHOPRT))
|
|
|
|
SET(flags, PRTERA);
|
|
|
|
if (ISSET(lflag, ECHOCTL))
|
|
|
|
SET(flags, CTLECH);
|
|
|
|
if (!ISSET(iflag, IXANY))
|
|
|
|
SET(flags, DECCTQ);
|
|
|
|
SET(flags, ISSET(lflag, ECHO|TOSTOP|FLUSHO|PENDIN|NOFLSH));
|
1995-06-25 00:15:55 +04:00
|
|
|
if (ttydebug)
|
1996-10-13 04:46:49 +04:00
|
|
|
printf("getflags: %x\n", flags);
|
1995-06-25 00:15:55 +04:00
|
|
|
return (flags);
|
|
|
|
}
|
|
|
|
|
1996-03-14 22:31:45 +03:00
|
|
|
void
|
2007-12-08 21:35:53 +03:00
|
|
|
ttcompatsetflags(struct tty *tp, struct termios *t)
|
1995-06-25 00:15:55 +04:00
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
int flags = tp->t_flags;
|
|
|
|
tcflag_t iflag = t->c_iflag;
|
|
|
|
tcflag_t oflag = t->c_oflag;
|
|
|
|
tcflag_t lflag = t->c_lflag;
|
|
|
|
tcflag_t cflag = t->c_cflag;
|
1996-02-02 21:47:50 +03:00
|
|
|
|
|
|
|
if (ISSET(flags, TANDEM))
|
|
|
|
SET(iflag, IXOFF);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(iflag, IXOFF);
|
|
|
|
if (ISSET(flags, ECHO))
|
|
|
|
SET(lflag, ECHO);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(lflag, ECHO);
|
|
|
|
if (ISSET(flags, CRMOD)) {
|
|
|
|
SET(iflag, ICRNL);
|
|
|
|
SET(oflag, ONLCR);
|
1995-06-25 00:15:55 +04:00
|
|
|
} else {
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(iflag, ICRNL);
|
|
|
|
CLR(oflag, ONLCR);
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
1996-02-02 21:47:50 +03:00
|
|
|
if (ISSET(flags, XTABS))
|
|
|
|
SET(oflag, OXTABS);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(oflag, OXTABS);
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
|
1996-02-02 21:47:50 +03:00
|
|
|
if (ISSET(flags, RAW)) {
|
1995-06-25 00:15:55 +04:00
|
|
|
iflag &= IXOFF;
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(lflag, ISIG|ICANON|IEXTEN);
|
|
|
|
CLR(cflag, PARENB);
|
1995-06-25 00:15:55 +04:00
|
|
|
} else {
|
1996-02-02 21:47:50 +03:00
|
|
|
SET(iflag, BRKINT|IXON|IMAXBEL);
|
|
|
|
SET(lflag, ISIG|IEXTEN);
|
|
|
|
if (ISSET(flags, CBREAK))
|
|
|
|
CLR(lflag, ICANON);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
SET(lflag, ICANON);
|
|
|
|
switch (ISSET(flags, ANYP)) {
|
|
|
|
case 0:
|
|
|
|
CLR(cflag, PARENB);
|
|
|
|
break;
|
|
|
|
case ANYP:
|
|
|
|
SET(cflag, PARENB);
|
|
|
|
CLR(iflag, INPCK);
|
|
|
|
break;
|
|
|
|
case EVENP:
|
|
|
|
SET(cflag, PARENB);
|
|
|
|
SET(iflag, INPCK);
|
|
|
|
CLR(cflag, PARODD);
|
|
|
|
break;
|
|
|
|
case ODDP:
|
|
|
|
SET(cflag, PARENB);
|
|
|
|
SET(iflag, INPCK);
|
|
|
|
SET(cflag, PARODD);
|
|
|
|
break;
|
|
|
|
}
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
|
|
|
|
1996-02-02 21:47:50 +03:00
|
|
|
if (ISSET(flags, RAW|LITOUT|PASS8)) {
|
|
|
|
CLR(cflag, CSIZE);
|
|
|
|
SET(cflag, CS8);
|
|
|
|
if (!ISSET(flags, RAW|PASS8))
|
|
|
|
SET(iflag, ISTRIP);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(iflag, ISTRIP);
|
|
|
|
if (!ISSET(flags, RAW|LITOUT))
|
|
|
|
SET(oflag, OPOST);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(oflag, OPOST);
|
1995-06-25 00:15:55 +04:00
|
|
|
} else {
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(cflag, CSIZE);
|
|
|
|
SET(cflag, CS7);
|
|
|
|
SET(iflag, ISTRIP);
|
|
|
|
SET(oflag, OPOST);
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
t->c_iflag = iflag;
|
|
|
|
t->c_oflag = oflag;
|
|
|
|
t->c_lflag = lflag;
|
|
|
|
t->c_cflag = cflag;
|
|
|
|
}
|
|
|
|
|
1996-03-14 22:31:45 +03:00
|
|
|
void
|
2007-12-08 21:35:53 +03:00
|
|
|
ttcompatsetlflags(struct tty *tp, struct termios *t)
|
1995-06-25 00:15:55 +04:00
|
|
|
{
|
2000-03-30 15:24:16 +04:00
|
|
|
int flags = tp->t_flags;
|
|
|
|
tcflag_t iflag = t->c_iflag;
|
|
|
|
tcflag_t oflag = t->c_oflag;
|
|
|
|
tcflag_t lflag = t->c_lflag;
|
|
|
|
tcflag_t cflag = t->c_cflag;
|
1995-06-25 00:15:55 +04:00
|
|
|
|
|
|
|
/* Nothing we can do with CRTBS. */
|
1996-02-02 21:47:50 +03:00
|
|
|
if (ISSET(flags, PRTERA))
|
|
|
|
SET(lflag, ECHOPRT);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(lflag, ECHOPRT);
|
|
|
|
if (ISSET(flags, CRTERA))
|
|
|
|
SET(lflag, ECHOE);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(lflag, ECHOE);
|
1995-06-25 00:15:55 +04:00
|
|
|
/* Nothing we can do with TILDE. */
|
1996-02-02 21:47:50 +03:00
|
|
|
if (ISSET(flags, MDMBUF))
|
|
|
|
SET(cflag, MDMBUF);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(cflag, MDMBUF);
|
|
|
|
if (ISSET(flags, NOHANG))
|
|
|
|
CLR(cflag, HUPCL);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
SET(cflag, HUPCL);
|
|
|
|
if (ISSET(flags, CRTKIL))
|
|
|
|
SET(lflag, ECHOKE);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(lflag, ECHOKE);
|
|
|
|
if (ISSET(flags, CTLECH))
|
|
|
|
SET(lflag, ECHOCTL);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(lflag, ECHOCTL);
|
|
|
|
if (!ISSET(flags, DECCTQ))
|
|
|
|
SET(iflag, IXANY);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(iflag, IXANY);
|
|
|
|
CLR(lflag, TOSTOP|FLUSHO|PENDIN|NOFLSH);
|
|
|
|
SET(lflag, ISSET(flags, TOSTOP|FLUSHO|PENDIN|NOFLSH));
|
|
|
|
|
|
|
|
if (ISSET(flags, RAW|LITOUT|PASS8)) {
|
|
|
|
CLR(cflag, CSIZE);
|
|
|
|
SET(cflag, CS8);
|
|
|
|
if (!ISSET(flags, RAW|PASS8))
|
|
|
|
SET(iflag, ISTRIP);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(iflag, ISTRIP);
|
|
|
|
if (!ISSET(flags, RAW|LITOUT))
|
|
|
|
SET(oflag, OPOST);
|
1995-06-25 00:15:55 +04:00
|
|
|
else
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(oflag, OPOST);
|
1995-06-25 00:15:55 +04:00
|
|
|
} else {
|
1996-02-02 21:47:50 +03:00
|
|
|
CLR(cflag, CSIZE);
|
|
|
|
SET(cflag, CS7);
|
|
|
|
SET(iflag, ISTRIP);
|
|
|
|
SET(oflag, OPOST);
|
1995-06-25 00:15:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
t->c_iflag = iflag;
|
|
|
|
t->c_oflag = oflag;
|
|
|
|
t->c_lflag = lflag;
|
|
|
|
t->c_cflag = cflag;
|
|
|
|
}
|
1996-05-19 02:17:49 +04:00
|
|
|
|
|
|
|
#endif /* COMPAT_OLDTTY */
|