/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdio.h>
#include <ctype.h>
#include <termio.h>
#include "stty.h"
extern char *getenv();
extern void exit();
extern void perror();
static int pitt = 0;
static int term;
void prmodes(int);
void pramodes(int);
void prachars(void);
void pcol(int, int);
void pit(unsigned char, char *, char *);
void delay(int, char *s);
void prspeed(char *, int);
void prencode(void);
int
{
int i;
if (argc == 2) {
/*
* "stty size", "stty speed" and "stty -g" are intended for
* use within backquotes; thus, they do the "fetch" "ioctl"
* standard output.
* Since their standard output is likely to be a pipe, they
* should not try to read the modes from the standard output.
*/
exit(2);
}
perror("stty: TIOCGWINSZ");
exit(2);
}
(void) printf("%d %d\n",
exit(0);
exit(2);
}
if ((term = get_ttymode(i,
exit(2);
}
if (cfgetospeed(&cb) ==
(void) printf("%s\n",
exit(0);
}
} else {
(void) printf("%s\n",
exit(0);
}
}
(void) printf("unknown\n");
exit(1);
exit(2);
}
if ((term = get_ttymode(i,
exit(2);
}
prencode();
exit(0);
}
}
exit(2);
}
if (argc == 1) {
prmodes(0);
exit(0);
}
prmodes(1);
exit(0);
}
pramodes(1);
exit(0);
}
case 'a':
pramodes(0);
exit(0);
case 'h':
pramodes(1);
exit(0);
default:
exit(2);
}
exit(2);
}
if (set_ttymode(ioctl_desc,
exit(2);
}
return (0); /*NOTREACHED*/
}
void
/* print modes, no options, argc is 1 */
{
int m;
if (m & IUCLC)
else
if (m & OLCUC)
else
if (m & TAB3)
if (m & XCASE)
else
if (m & STFLUSH)
else
if (m & STWRAP)
else
if (m & STAPPL)
else
}
} else
if (m & PARENB) {
if (m & PARODD)
else
} else {
if (m & PARODD)
else
}
} else
if (m & CSTOPB)
if (m & HUPCL)
if (!(m & CREAD))
if (m & CLOCAL)
if (m & LOBLK)
}
if (!moremodes) {
}
}
if (pitt)
if (m & IGNBRK)
else if (!(m & BRKINT))
if (!(m & INPCK))
else if (!(m & IGNPAR))
if (m & PARMRK)
if (!(m & ISTRIP))
if (m & INLCR)
if (m & IGNCR)
if (!(m & ICRNL))
if (m & IUCLC)
if (!(m & IXON))
else if (m & IXANY)
if (m & IXOFF)
if (!(m & OPOST))
else {
if (m & OLCUC)
if (!(m & ONLCR))
if (m & OCRNL)
if (m & ONOCR)
if (m & ONLRET)
if (m & OFILL)
if (m & OFDEL)
else
else
}
if (!(m & ISIG))
if (!(m & ICANON))
if (m & XCASE)
if (!(m & ECHO))
if (m & ECHOE) {
if (m & ECHOKE)
else
} else {
if (!(m & ECHOPRT))
}
if (!(m & ECHOK))
if (m & ECHONL)
if (m & NOFLSH)
if (m & TOSTOP)
if (!(m & ECHOCTL))
if (m & DEFECHO)
if (m & FLUSHO)
if (m & PENDIN)
if (m & IEXTEN)
}
if (m & RTSXOFF)
if (m & CTSXON)
if (m & DTRXOFF)
if (m & CDXON)
if (m & ISXOFF)
switch (m & XMTCLK) {
case XCIBRG:
break;
case XCTSET:
break;
case XCRSET:
break;
}
switch (m & RCVCLK) {
case RCIBRG:
break;
case RCTSET:
break;
case RCRSET:
break;
}
switch (m & TSETCLK) {
case TSETCOFF:
break;
case TSETCRBRG:
break;
case TSETCTBRG:
break;
}
switch (m & RSETCLK) {
case RSETCOFF:
break;
case RSETCRBRG:
break;
case RSETCTBRG:
}
}
if (moremodes)
prachars();
}
void
/* print all modes, -a option */
{
int m;
} else
}
if (!tabform) {
}
}
} else
}
}
else
switch (m & XMTCLK) {
case XCIBRG:
break;
case XCTSET:
break;
case XCRSET:
break;
}
switch (m & RCVCLK) {
case RCIBRG:
break;
case RCTSET:
break;
case RCRSET:
break;
}
switch (m & TSETCLK) {
case TSETCOFF:
break;
case TSETCRBRG:
break;
case TSETCTBRG:
break;
}
switch (m & RSETCLK) {
case RSETCOFF:
break;
case RSETCRBRG:
break;
case RSETCTBRG:
break;
}
}
if (tabform)
prachars();
}
void
prachars(void)
{
erase kill werase rprnt flush lnext susp intr quit stop eof\
\n");
eol2 swtch\
\n");
}
}
void
{
int nout = 0;
ch1 &= 0377;
ch2 &= 0377;
ch2 = 0;
if (ch1 == 0)
continue;
nout += 2;
ch1 &= ~ 0200;
}
if (ch1 == 0177) {
nout++;
ch1 = '?';
} else if (ch1 < ' ') {
nout++;
ch1 += '@';
}
nout++;
if (ch2 != 0) {
nout++;
}
}
while (nout < 7) {
nout++;
}
}
void
/* print function for prmodes() and pramodes() */
{
pitt++;
return;
}
what &= ~ 0200;
}
if (what == 0177) {
return;
} else if (what < ' ') {
what += '`';
}
}
void
delay(int m, char *s)
{
if (m)
}
long speed[] = {
0, 50, 75, 110, 134, 150, 200, 300,
600, 1200, 1800, 2400, 4800, 9600, 19200, 38400,
57600, 76800, 115200, 153600, 230400, 307200, 460800, 921600
};
void
prspeed(char *c, int s)
{
}
/*
* print current settings for use with
* another stty cmd, used for -g option
*/
void
prencode(void)
{
int i, last;
/* Since the -g option is mostly used for redirecting to a file */
/* We must print to stdout here, not stderr */
/* last control slot is unused */
else
for (i = 0; i < last; i++)
}