/*
* 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 1999-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
*/
/*
* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
* All Rights Reserved
*
*/
#include <stdio.h>
#include <ctype.h>
#include <locale.h>
#include <termio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#ifdef EUC
#include <fcntl.h>
#include <unistd.h>
#include <sys/eucioctl.h>
#include <sys/csiioctl.h>
#include <getwidth.h>
#endif /* EUC */
#include "stty.h"
extern const char *not_supported[];
extern char *getenv();
extern void exit();
extern void perror();
extern int get_ttymode();
extern int set_ttymode();
static int pitt = 0;
static int term;
#ifdef EUC
static int invalid_ldterm_dat_file;
#endif /* EUC */
static void prmodes();
static void pramodes();
static void delay(int m, char *s);
static void prspeed(char *c, int s);
static void prencode();
int
{
int i;
int fd;
#ifdef EUC
char *lc;
#endif /* EUC */
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
#ifdef EUC
if (lc) {
if (fd != -1) {
sizeof (cswp)) {
"cannot read entire %s file\n"), tmps);
exit(2);
}
/*
* If the ldterm.dat contains invalid data or
* the current locale name is too long, we clear
* the 'cswp' and flag the invalid ldterm.dat since
* we are not going to use the data.
*/
} else {
}
}
}
#endif /* EUC */
#ifdef EUC
#endif /* EUC */
/* */)) < 0) {
exit(2);
}
if (argc == 1) {
prmodes();
exit(0);
}
case 'a':
pramodes();
return (0);
case 'g':
prencode();
return (0);
case '-':
prmodes(); /* stty -- */
return (0);
default:
"usage: stty [-a| -g]\n"));
" stty [modes]\n"));
return (2);
}
case 'a':
pramodes();
return (0);
case 'g':
prencode();
return (0);
default:
"usage: stty [-a| -g]\n"));
" stty [modes]\n"));
return (2);
}
/* ignore -- */
--argc;
++argv;
}
#ifdef EUC
#endif /* EUC */
/* */)) {
char *s = s_arg;
if (*s == '-') s++;
for (i = 0; not_supported[i]; i++) {
if (strcmp(not_supported[i], s) == 0) {
"mode not supported on this device: %s\n"),
s_arg);
exit(2);
}
}
return (2);
}
#ifdef EUC
#endif /* EUC */
/* */) == -1) {
return (2);
}
return (0);
}
void
{
int m;
if (m & IUCLC)
(void) printf("iuclc ");
else
(void) printf("-iuclc ");
if (m & OLCUC)
(void) printf("olcuc ");
else
(void) printf("-olcuc ");
if (m & TAB3)
(void) printf("tab3 ");
if (m & XCASE)
(void) printf("xcase ");
else
(void) printf("-xcase ");
if (m & STFLUSH)
(void) printf("stflush ");
else
(void) printf("-stflush ");
if (m & STWRAP)
(void) printf("stwrap ");
else
(void) printf("-stwrap ");
if (m & STAPPL)
(void) printf("stappl ");
else
(void) printf("-stappl ");
(void) printf("\n");
}
} else
if (m&PARENB) {
if (m&PARODD)
(void) printf("markp ");
else
(void) printf("spacep ");
} else {
if (m&PARODD)
(void) printf("oddp ");
else
(void) printf("evenp ");
}
} else
(void) printf("-parity ");
if (m&CSTOPB)
(void) printf("cstopb ");
if (m&HUPCL)
(void) printf("hupcl ");
if (!(m&CREAD))
(void) printf("-cread ");
if (m&CLOCAL)
(void) printf("clocal ");
if (m&LOBLK)
(void) printf("loblk ");
(void) printf("\n");
" ypixels = %d; xpixels = %d;\n"),
}
}
if (m&IGNBRK)
(void) printf("ignbrk ");
else if (m&BRKINT)
(void) printf("brkint ");
if (!(m&INPCK))
(void) printf("-inpck ");
else if (m&IGNPAR)
(void) printf("ignpar ");
if (m&PARMRK)
(void) printf("parmrk ");
if (!(m&ISTRIP))
(void) printf("-istrip ");
if (m&INLCR)
(void) printf("inlcr ");
if (m&IGNCR)
(void) printf("igncr ");
if (m&ICRNL)
(void) printf("icrnl ");
if (m&IUCLC)
(void) printf("iuclc ");
if (!(m&IXON))
(void) printf("-ixon ");
else if (!(m&IXANY))
(void) printf("-ixany ");
if (m&IXOFF)
(void) printf("ixoff ");
(void) printf("imaxbel ");
if (!(m&OPOST))
(void) printf("-opost ");
else {
if (m&OLCUC)
(void) printf("olcuc ");
if (m&ONLCR)
(void) printf("onlcr ");
if (m&OCRNL)
(void) printf("ocrnl ");
if (m&ONOCR)
(void) printf("onocr ");
if (m&ONLRET)
(void) printf("onlret ");
if (m&OFILL)
if (m&OFDEL)
(void) printf("del-fill ");
else
(void) printf("nul-fill ");
}
(void) printf("\n");
if (!(m&ISIG))
(void) printf("-isig ");
if (!(m&ICANON))
(void) printf("-icanon ");
if (m&XCASE)
(void) printf("xcase ");
if (m&ECHONL)
(void) printf("echonl ");
if (m&NOFLSH)
(void) printf("noflsh ");
if (m&TOSTOP)
(void) printf("tostop ");
if (m&ECHOCTL)
(void) printf("echoctl ");
if (m&ECHOPRT)
(void) printf("echoprt ");
if (m&ECHOKE)
(void) printf("echoke ");
if (m&DEFECHO)
(void) printf("defecho ");
if (m&FLUSHO)
(void) printf("flusho ");
if (m&PENDIN)
(void) printf("pendin ");
if (m&IEXTEN)
(void) printf("iexten ");
(void) printf("\n");
}
if (m & RTSXOFF)
(void) printf("rtsxoff ");
if (m & CTSXON)
(void) printf("ctsxon ");
if (m & DTRXOFF)
(void) printf("dtrxoff ");
if (m & CDXON)
(void) printf("cdxon ");
if (m & ISXOFF)
(void) printf("isxoff ");
switch (m & XMTCLK) {
break;
break;
}
switch (m & RCVCLK) {
break;
break;
}
switch (m & TSETCLK) {
break;
break;
break;
break;
}
switch (m & RSETCLK) {
break;
break;
break;
break;
}
(void) printf("\n");
}
}
void
{
int m;
} else
(void) printf("\n");
" ypixels = %d; xpixels = %d;\n"),
}
#ifdef EUC
} else {
(void) printf("csdata ?\n");
}
/*
* If kwp.eucw[0] is zero, it means the current codeset type
* in the ldterm is not EUC.
*/
} else
(void) printf("eucw ?, scrw ?\n");
#endif /* EUC */
}
} else
(void) printf("\n");
(void) printf("\n");
(void) printf("\n");
(void) printf("\n");
}
}
(void) printf("\n");
(void) printf("\n");
switch (m & XMTCLK) {
break;
break;
}
switch (m & RCVCLK) {
break;
break;
}
switch (m & TSETCLK) {
break;
break;
break;
break;
}
switch (m & RSETCLK) {
break;
break;
break;
break;
}
(void) printf("\n");
}
}
/* print function for prmodes() and pramodes() */
void
{
pitt++;
return;
}
(void) printf(" = ");
(void) printf("-");
what &= ~ 0200;
}
if (what == 0177) {
return;
} else if (what < ' ') {
(void) printf("^");
what += '`';
if (what > 'z')
}
}
void
delay(int m, char *s)
{
if (m)
(void) printf("%s%d ", s, m);
}
void
{
int i;
break;
}
}
}
/* print current settings for use with */
void
{
int i, last;
/*
* Although there are only 16 control chars defined as of April 1995,
* prencode() and encode() will not have to be changed if up to MAX_CC
* control chars are defined in the future. A maximum of MAX_CC rather
* than NCCS control chars are printed because the last control slot
* is unused. "stty -g" prints out a total of NUM_FIELDS fields
* (NUM_MODES modes + MAX_CC control chars). First print the input,
* output, control, and line discipline modes.
*/
/* Print the control character fields. */
else
#ifdef EUC
for (i = 0; i < MAX_CC; i++)
/*
* Print out ldterm_cs_data_user_t data fields for
* PSARC/1999/140 TCR2. This change introduces additional
* 44 fields that come from the ldterm_cs_data_user_t data
* structure.
*/
(void) printf("00");
} else {
}
for (i = 0; i < LDTERM_CS_MAX_CODESETS; i++)
(void) printf(":%x:%x:%x:%x",
} else {
#endif /* EUC */
for (i = 0; i < last; i++)
#ifdef EUC
}
#endif /* EUC */
(void) printf("\n");
}