/*
* 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 <unistd.h>
#include <stdlib.h>
#include <libintl.h>
#include <ctype.h>
#include <termio.h>
#ifdef EUC
#include <sys/eucioctl.h>
#include <sys/csiioctl.h>
#include <getwidth.h>
#endif /* EUC */
#include "stty.h"
#include <locale.h>
#include <string.h>
static int match;
#ifdef EUC
#else
static int parse_encoded(struct termios *);
#endif /* EUC */
/* set terminal modes for supplied options */
char *
#ifdef EUC
#endif /* EUC */
/* */)
{
int i;
while (--argc > 0) {
match = 0;
else
else
if (match)
continue;
}
if (match)
continue;
if (eq("ek")) {
} else if (eq("line") &&
continue;
} else if (eq("raw")) {
} else if (eq("sane")) {
/* SWTCH purposely not set */
#ifdef EUC
} else if (eq("defeucw")) {
sizeof (ldterm_cs_data_user_t));
#endif /* EUC */
(void) cfsetospeed(cb,
break;
}
}
if (!match)
return (s_arg);
continue;
(void) cfsetispeed(cb,
break;
}
}
if (!match)
return (s_arg);
continue;
} else {
(void) cfsetospeed(cb,
(void) cfsetispeed(cb,
break;
}
}
}
}
continue;
}
#ifdef EUC
if (wp->_multibyte &&
#endif /* EUC */
}
}
}
}
continue;
}
#ifdef EUC
if (wp->_multibyte &&
eq("sane"))) {
}
#endif /* EUC */
}
}
}
}
}
}
}
if (!match) {
#ifdef EUC
#else
if (!parse_encoded(cb)) {
#endif /* EUC */
return (s_arg); /* parsing failed */
}
}
}
return ((char *)0);
}
static int
{
int i;
if (!s_arg)
return (0);
i = 0;
loop:
return (0);
if (s_arg[i++] != '\0')
goto loop;
match++;
return (1);
}
/* get pseudo control characters from terminal */
/* and convert to internal representation */
static int
{
int c;
c = *cp;
if (c == '^') {
c = *++cp;
if (c == '?')
c = 0177; /* map '^?' to 0177 */
else if (c == '-') {
/* map '^-' to undefined */
} else
c &= 037;
/* map "undef" to undefined */
}
return (c);
}
/* get modes of tty device and fill in applicable structures */
int
#ifdef EUC
#endif /* EUC */
/* */)
{
int i;
int term = 0;
#ifdef EUC
#endif /* EUC */
return (-1);
for (i = 0; i < NCC; i++)
} else
} else {
}
#ifdef EUC
else
#endif /* EUC */
return (term);
}
/* set tty modes */
int
#ifdef EUC
#endif /* EUC */
/* */)
{
int i;
#ifdef EUC
#endif /* EUC */
return (-1);
} else {
for (i = 0; i < NCC; i++)
return (-1);
}
} else {
return (-1);
}
return (-1);
}
return (-1);
#ifdef EUC
/*
* If the ldterm.dat file contains valid, non-EUC codeset info,
* send downstream CSDATA_SET. Otherwise, try EUC_WSET.
*/
if (invalid_ldterm_dat_file) {
"stty: can't set codeset width due to invalid ldterm.dat.\n"));
return (-1);
"stty: can't set codeset width.\n"));
return (-1);
}
"stty: can't set EUC codeset width.\n"));
return (-1);
}
}
#endif /* EUC */
return (0);
}
static int
#ifdef EUC
#endif /* EUC */
/* */)
{
int last, i;
#ifdef EUC
long l;
char s[3];
char *t;
char *r;
uchar_t *g;
#endif /* EUC */
/*
* Although there are only 16 control chars defined as of April 1995,
* parse_encoded() and prencode() will not have to be changed if up to
* MAX_CC control chars are defined in the future.
* Scan the fields of "stty -g" output into the grab array.
* Set a total of NUM_FIELDS fields (NUM_MODES modes + MAX_CC
* control chars).
*/
"%lx:%lx:%lx:%lx:%lx:%lx:%lx:%lx:%lx",
if (i < 12)
return (0);
for (i = 0; i < last; i++)
#ifdef EUC
/* This is to fulfill PSARC/1999/140 TCR2. */
if (r == (char *)NULL) {
"no more memory - try again later\n"));
return (0);
}
t = strtok(r, ":");
for (i = 0; t != NULL && i < 22; i++) {
}
if (t == NULL) {
free((void *)r);
return (0);
}
free((void *)r);
return (0);
}
free((void *)r);
return (0);
}
free((void *)r);
return (0);
}
free((void *)r);
return (0);
}
free((void *)r);
return (0);
}
free((void *)r);
return (0);
}
s[2] = '\0';
for (i = 0; *t != 0 && i < MAXNAMELEN; i++) {
if (*(t + 1) == (char)NULL) {
free((void *)r);
return (0);
}
s[0] = *t++;
s[1] = *t++;
16);
}
if (i >= MAXNAMELEN) {
free((void *)r);
return (0);
}
for (i = 0; i < (LDTERM_CS_MAX_CODESETS * 4); i++) {
free((void *)r);
return (0);
}
if (l < 0 || l > 255) {
free((void *)r);
return (0);
}
*g++ = (uchar_t)l;
}
/* We got the 'ecswp' all filled up now; let's copy. */
sizeof (ldterm_cs_data_user_t));
}
#endif /* EUC */
return (1);
}