stty.c revision cc6c5292fa8a241fe50604cf6a918edfbf7cd7d2
/*
* 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;
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);
#define ioctl_desc 1
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);
}
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);
}
return (0); /*NOTREACHED*/
}
void
/* print modes, no options, argc is 1 */
{
int 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();
}
void
/* print all modes, -a option */
{
int 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();
}
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
};
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++)
}