* Copyright (c) 1982, 1986, 1991 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 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
* @(#)tty_compat.c 7.10 (Berkeley) 5/9/91
* PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
* -------------------- ----- ----------------------
* CURRENT PATCH LEVEL: 2 00163
* -------------------- ----- ----------------------
* 22 Apr 93 David Greenman support for 57600 and 115200 baud
* 27 May 93 Andrew A. Chernov Make more compatible with POSIX
* 27 May 93 Bruce Evans The work David did above was replaced
* by Bruces work plus some more stuff.
* (Chernov's fixes from the net edited
* Guido van Rooij Fix a bug caused by Bruces patches.
* mapping routines for old line discipline (yuck)
static struct speedtab compatspeeds
[] = {
static int compatspcodes
[] = {
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
ttcompat(tp
, com
, data
, flag
)
register struct sgttyb
*sg
= (struct sgttyb
*)data
;
register u_char
*cc
= tp
->t_cc
;
speed
= ttspeedtab(tp
->t_ospeed
, compatspeeds
);
sg
->sg_ospeed
= (speed
== -1) ? MAX_SPEED
: speed
;
sg
->sg_ispeed
= sg
->sg_ospeed
;
speed
= ttspeedtab(tp
->t_ispeed
, compatspeeds
);
sg
->sg_ispeed
= (speed
== -1) ? MAX_SPEED
: speed
;
sg
->sg_erase
= cc
[VERASE
];
sg
->sg_flags
= tp
->t_flags
= ttcompatgetflags(tp
);
register struct sgttyb
*sg
= (struct sgttyb
*)data
;
if ((speed
= sg
->sg_ispeed
) > MAX_SPEED
|| speed
< 0)
term
.c_ispeed
= compatspcodes
[speed
];
if ((speed
= sg
->sg_ospeed
) > MAX_SPEED
|| speed
< 0)
term
.c_ospeed
= compatspcodes
[speed
];
term
.c_cc
[VERASE
] = sg
->sg_erase
;
term
.c_cc
[VKILL
] = sg
->sg_kill
;
tp
->t_flags
= tp
->t_flags
&0xffff0000 | sg
->sg_flags
&0xffff;
ttcompatsetflags(tp
, &term
);
return (ttioctl(tp
, com
== TIOCSETP
? TIOCSETAF
: TIOCSETA
,
struct tchars
*tc
= (struct tchars
*)data
;
register u_char
*cc
= tp
->t_cc
;
tc
->t_startc
= cc
[VSTART
];
struct tchars
*tc
= (struct tchars
*)data
;
register u_char
*cc
= tp
->t_cc
;
cc
[VSTART
] = tc
->t_startc
;
cc
[VEOL2
] = _POSIX_VDISABLE
;
struct ltchars
*ltc
= (struct ltchars
*)data
;
register u_char
*cc
= tp
->t_cc
;
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
;
struct ltchars
*ltc
= (struct ltchars
*)data
;
register u_char
*cc
= tp
->t_cc
;
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
];
tp
->t_flags
= (tp
->t_flags
&0xffff) | *(int *)data
<<16;
(ttcompatgetflags(tp
)&0xffff0000)|(tp
->t_flags
&0xffff);
tp
->t_flags
|= *(int *)data
<<16;
tp
->t_flags
&= ~(*(int *)data
<<16);
ttcompatsetlflags(tp
, &term
);
return (ttioctl(tp
, TIOCSETA
, (caddr_t
)&term
, flag
));
(ttcompatgetflags(tp
)&0xffff0000)|(tp
->t_flags
&0xffff);
*(int *)data
= tp
->t_flags
>>16;
printf("CLGET: returning %x\n", *(int *)data
);
*(int *)data
= tp
->t_line
? tp
->t_line
: 2;
return (ttioctl(tp
, TIOCSETD
,
*(int *)data
== 2 ? (caddr_t
)&ldisczero
: data
, flag
));
return (ttioctl(tp
, TIOCCONS
, data
, flag
));
register long iflag
= tp
->t_iflag
;
register long lflag
= tp
->t_lflag
;
register long oflag
= tp
->t_oflag
;
register long cflag
= tp
->t_cflag
;
if (iflag
&ICRNL
|| oflag
&ONLCR
)
if ((cflag
&CSIZE
) == CS8
) {
if ((lflag
&ICANON
) == 0) {
if (iflag
&(INPCK
|ISTRIP
|IXON
) || lflag
&(IEXTEN
|ISIG
)
|| cflag
&(CSIZE
|PARENB
) != CS8
)
if (!(flags
&RAW
) && !(oflag
&OPOST
) && cflag
&(CSIZE
|PARENB
) == CS8
)
flags
|= lflag
&(ECHO
|MDMBUF
|TOSTOP
|FLUSHO
|NOHANG
|PENDIN
|NOFLSH
);
printf("getflags: %x\n", flags
);
register struct termios
*t
;
register flags
= tp
->t_flags
;
register long iflag
= t
->c_iflag
;
register long oflag
= t
->c_oflag
;
register long lflag
= t
->c_lflag
;
register long cflag
= t
->c_cflag
;
lflag
&= ~(ECHOCTL
|ISIG
|ICANON
|IEXTEN
);
iflag
|= BRKINT
|IXON
|IMAXBEL
;
lflag
|= ISIG
|IEXTEN
|ECHOCTL
; /* XXX was echoctl on ? */
cflag
&= ~(CSIZE
|PARENB
);
if (flags
&(RAW
|LITOUT
|PASS8
)) {
|| (flags
&(RAW
|PASS8
|ANYP
)) == (PASS8
|ANYP
))
if ((flags
&(EVENP
|ODDP
)) == EVENP
) {
} else if ((flags
&(EVENP
|ODDP
)) == ODDP
) {
register struct termios
*t
;
register flags
= tp
->t_flags
;
register long iflag
= t
->c_iflag
;
register long oflag
= t
->c_oflag
;
register long lflag
= t
->c_lflag
;
register long cflag
= t
->c_cflag
;
lflag
&= ~(MDMBUF
|TOSTOP
|FLUSHO
|NOHANG
|PENDIN
|NOFLSH
);
lflag
|= flags
&(MDMBUF
|TOSTOP
|FLUSHO
|NOHANG
|PENDIN
|NOFLSH
);
cflag
&= ~(CSIZE
|PARENB
);
* The next if-else statement is copied from above so don't bother
* checking it separately. We could avoid fiddlling with the
* character size if the mode is already RAW or if neither the
* LITOUT bit or the PASS8 bit is being changed, but the delta of
* the change is not available here and skipping the RAW case would
* make the code different from above.
if (flags
&(RAW
|LITOUT
|PASS8
)) {
|| (flags
&(RAW
|PASS8
|ANYP
)) == (PASS8
|ANYP
))