stty.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 1995 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <ctype.h>
#include <termio.h>
#include "stty.h"
extern char *getenv();
extern void exit();
extern void perror();
static char *STTY="stty: ";
static char *USAGE="usage: stty [-agh] [modes]\n";
static int pitt = 0;
static int term;
#define ioctl_desc 1
char *argv[];
{
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);
}
exit(0);
}
exit(2);
}
&winsize)) < 0) {
exit(2);
}
exit(0);
}
} else {
exit(0);
}
}
(void) printf("unknown\n");
exit(1);
}
exit(2);
}
&winsize)) < 0) {
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);
}
exit(2);
}
exit(0); /*NOTREACHED*/
}
int moremodes;
{
register m;
}
} 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 (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)
{
break;
break;
}
switch(m & RCVCLK)
{
break;
break;
}
switch(m & TSETCLK)
{
break;
break;
}
switch(m & RSETCLK)
{
break;
break;
}
}
if(moremodes)
prachars();
}
int tabform;
{
register m;
} else
}
if (!tabform) {
}
}
} else
}
}
else
switch(m & XMTCLK)
{
break;
break;
}
switch(m & RCVCLK)
{
break;
break;
}
switch(m & TSETCLK)
{
break;
break;
}
switch(m & RSETCLK)
{
break;
break;
}
}
if (tabform)
prachars();
}
prachars()
{
erase kill werase rprnt flush lnext susp intr quit stop eof\
\n");
eol2 swtch\
\n");
}
}
{
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++;
}
}
unsigned char what;
{
pitt++;
return;
}
what &= ~ 0200;
}
if (what == 0177) {
return;
} else if (what < ' ') {
what += '`';
}
}
delay(m, s)
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
};
prspeed(c, s)
char *c;
int s;
{
}
/* print current settings for use with */
prencode() /* another stty cmd, used for -g option */
{
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++)
}