From 7d2c9f88a7d43db813c2becdd507f2940e341c0d Mon Sep 17 00:00:00 2001 From: HOLZSCHUCH Nicolas Date: Fri, 22 Mar 2024 19:32:23 +0100 Subject: [PATCH] Added stty --- adv_cmds-adv_cmds-199.0.1/stty/cchar.c | 148 ++++ adv_cmds-adv_cmds-199.0.1/stty/extern.h | 45 ++ adv_cmds-adv_cmds-199.0.1/stty/gfmt.c | 128 ++++ adv_cmds-adv_cmds-199.0.1/stty/key.c | 309 ++++++++ adv_cmds-adv_cmds-199.0.1/stty/modes.c | 318 +++++++++ adv_cmds-adv_cmds-199.0.1/stty/print.c | 317 +++++++++ adv_cmds-adv_cmds-199.0.1/stty/stty.1 | 667 ++++++++++++++++++ adv_cmds-adv_cmds-199.0.1/stty/stty.c | 186 +++++ adv_cmds-adv_cmds-199.0.1/stty/stty.h | 55 ++ .../stty/stty.plist.part | 20 + adv_cmds-adv_cmds-199.0.1/stty/util.c | 62 ++ 11 files changed, 2255 insertions(+) create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/cchar.c create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/extern.h create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/gfmt.c create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/key.c create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/modes.c create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/print.c create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/stty.1 create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/stty.c create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/stty.h create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/stty.plist.part create mode 100644 adv_cmds-adv_cmds-199.0.1/stty/util.c diff --git a/adv_cmds-adv_cmds-199.0.1/stty/cchar.c b/adv_cmds-adv_cmds-199.0.1/stty/cchar.c new file mode 100644 index 00000000..93c74a62 --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/cchar.c @@ -0,0 +1,148 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cchar.c 8.5 (Berkeley) 4/2/94"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include + +#include "stty.h" +#include "extern.h" + +static int c_cchar(const void *, const void *); + +/* + * Special control characters. + * + * Cchars1 are the standard names, cchars2 are the old aliases. + * The first are displayed, but both are recognized on the + * command line. + */ +struct cchar cchars1[] = { + { "discard", VDISCARD, CDISCARD }, + { "dsusp", VDSUSP, CDSUSP }, + { "eof", VEOF, CEOF }, + { "eol", VEOL, CEOL }, + { "eol2", VEOL2, CEOL }, + { "erase", VERASE, CERASE }, +#ifndef __APPLE__ + { "erase2", VERASE2, CERASE2 }, +#endif + { "intr", VINTR, CINTR }, + { "kill", VKILL, CKILL }, + { "lnext", VLNEXT, CLNEXT }, + { "min", VMIN, CMIN }, + { "quit", VQUIT, CQUIT }, + { "reprint", VREPRINT, CREPRINT }, + { "start", VSTART, CSTART }, + { "status", VSTATUS, CSTATUS }, + { "stop", VSTOP, CSTOP }, + { "susp", VSUSP, CSUSP }, + { "time", VTIME, CTIME }, + { "werase", VWERASE, CWERASE }, + { NULL, 0, 0}, +}; + +struct cchar cchars2[] = { + { "brk", VEOL, CEOL }, + { "flush", VDISCARD, CDISCARD }, + { "rprnt", VREPRINT, CREPRINT }, + { NULL, 0, 0 }, +}; + +static int +c_cchar(const void *a, const void *b) +{ + + return (strcmp(((const struct cchar *)a)->name, ((const struct cchar *)b)->name)); +} + +int +csearch(char ***argvp, struct info *ip) +{ + struct cchar *cp, tmp; + long val; + char *arg, *ep, *name; + + name = **argvp; + + tmp.name = name; + if (!(cp = (struct cchar *)bsearch(&tmp, cchars1, + sizeof(cchars1)/sizeof(struct cchar) - 1, sizeof(struct cchar), + c_cchar)) && !(cp = (struct cchar *)bsearch(&tmp, cchars2, + sizeof(cchars2)/sizeof(struct cchar) - 1, sizeof(struct cchar), + c_cchar))) + return (0); + + arg = *++*argvp; + if (!arg) { + warnx("option requires an argument -- %s", name); + stty_usage(); + } + +#define CHK(s) (*arg == s[0] && !strcmp(arg, s)) + if (CHK("undef") || CHK("")) + ip->t.c_cc[cp->sub] = _POSIX_VDISABLE; + else if (cp->sub == VMIN || cp->sub == VTIME) { + val = strtol(arg, &ep, 10); +#ifdef __APPLE__ + if (val == _POSIX_VDISABLE) { + warnx("value of %ld would disable the option -- %s", + val, name); + stty_usage(); + } +#endif + if (val > UCHAR_MAX) { + warnx("maximum option value is %d -- %s", + UCHAR_MAX, name); + stty_usage(); + } + if (*ep != '\0') { + warnx("option requires a numeric argument -- %s", name); + stty_usage(); + } + ip->t.c_cc[cp->sub] = val; + } else if (arg[0] == '^') + ip->t.c_cc[cp->sub] = (arg[1] == '?') ? 0177 : + (arg[1] == '-') ? _POSIX_VDISABLE : arg[1] & 037; + else + ip->t.c_cc[cp->sub] = arg[0]; + ip->set = 1; + return (1); +} diff --git a/adv_cmds-adv_cmds-199.0.1/stty/extern.h b/adv_cmds-adv_cmds-199.0.1/stty/extern.h new file mode 100644 index 00000000..82378d6d --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/extern.h @@ -0,0 +1,45 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)extern.h 8.1 (Berkeley) 5/31/93 + * $FreeBSD$ + */ + +int c_cchars(const void *, const void *); +int c_modes(const void *, const void *); +int csearch(char ***, struct info *); +void checkredirect(void); +void gprint(struct termios *, struct winsize *, int); +void gread(struct termios *, char *); +int ksearch(char ***, struct info *); +int msearch(char ***, struct info *); +void optlist(void); +void print(struct termios *, struct winsize *, int, enum FMT); +void stty_usage(void) __dead2; + +extern struct cchar cchars1[], cchars2[]; diff --git a/adv_cmds-adv_cmds-199.0.1/stty/gfmt.c b/adv_cmds-adv_cmds-199.0.1/stty/gfmt.c new file mode 100644 index 00000000..12ed2a2d --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/gfmt.c @@ -0,0 +1,128 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)gfmt.c 8.6 (Berkeley) 4/2/94"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include + +#include "stty.h" +#include "extern.h" + +static void gerr(const char *s) __dead2; + +static void +gerr(const char *s) +{ + if (s) + errx(1, "illegal gfmt1 option -- %s", s); + else + errx(1, "illegal gfmt1 option"); +} + +void +gprint(struct termios *tp, struct winsize *wp __unused, int ldisc __unused) +{ + struct cchar *cp; + + (void)printf("gfmt1:cflag=%lx:iflag=%lx:lflag=%lx:oflag=%lx:", + (u_long)tp->c_cflag, (u_long)tp->c_iflag, (u_long)tp->c_lflag, + (u_long)tp->c_oflag); + for (cp = cchars1; cp->name; ++cp) + (void)printf("%s=%x:", cp->name, tp->c_cc[cp->sub]); + (void)printf("ispeed=%lu:ospeed=%lu\n", + (u_long)cfgetispeed(tp), (u_long)cfgetospeed(tp)); +} + +void +gread(struct termios *tp, char *s) +{ + struct cchar *cp; + char *ep, *p; + long tmp; + + if ((s = strchr(s, ':')) == NULL) + gerr(NULL); + for (++s; s != NULL;) { + p = strsep(&s, ":\0"); + if (!p || !*p) + break; + if (!(ep = strchr(p, '='))) + gerr(p); + *ep++ = '\0'; + tmp = strtoul(ep, NULL, 0x10); + +#define CHK(s) (*p == s[0] && !strcmp(p, s)) + if (CHK("cflag")) { + tp->c_cflag = tmp; + continue; + } + if (CHK("iflag")) { + tp->c_iflag = tmp; + continue; + } + if (CHK("ispeed")) { + tmp = strtoul(ep, NULL, 10); + tp->c_ispeed = tmp; + continue; + } + if (CHK("lflag")) { + tp->c_lflag = tmp; + continue; + } + if (CHK("oflag")) { + tp->c_oflag = tmp; + continue; + } + if (CHK("ospeed")) { + tmp = strtoul(ep, NULL, 10); + tp->c_ospeed = tmp; + continue; + } + for (cp = cchars1; cp->name != NULL; ++cp) + if (CHK(cp->name)) { + if (cp->sub == VMIN || cp->sub == VTIME) + tmp = strtoul(ep, NULL, 10); + tp->c_cc[cp->sub] = tmp; + break; + } + if (cp->name == NULL) + gerr(p); + } +} diff --git a/adv_cmds-adv_cmds-199.0.1/stty/key.c b/adv_cmds-adv_cmds-199.0.1/stty/key.c new file mode 100644 index 00000000..4583bac8 --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/key.c @@ -0,0 +1,309 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)key.c 8.3 (Berkeley) 4/2/94"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include + +#include "stty.h" +#include "extern.h" + +// iOS: avoid multiply defined labels +#define f_size stty_f_size + +__BEGIN_DECLS +static int c_key(const void *, const void *); +void f_all(struct info *); +void f_cbreak(struct info *); +void f_columns(struct info *); +void f_dec(struct info *); +void f_ek(struct info *); +void f_everything(struct info *); +void f_extproc(struct info *); +void f_ispeed(struct info *); +void f_nl(struct info *); +void f_ospeed(struct info *); +void f_raw(struct info *); +void f_rows(struct info *); +void f_sane(struct info *); +void f_size(struct info *); +void f_speed(struct info *); +void f_tty(struct info *); +__END_DECLS + +#ifdef __APPLE__ +/* Upstream defines a different version in libc/gen/termios.c */ +static void +cfmakesane(struct termios *t) +{ + + t->c_cflag = TTYDEF_CFLAG; + t->c_iflag = TTYDEF_IFLAG; + t->c_lflag = TTYDEF_LFLAG; + t->c_oflag = TTYDEF_OFLAG; +} +#endif + +static struct key { + const char *name; /* name */ + void (*f)(struct info *); /* function */ +#define F_NEEDARG 0x01 /* needs an argument */ +#define F_OFFOK 0x02 /* can turn off */ + int flags; +} keys[] = { + { "all", f_all, 0 }, + { "cbreak", f_cbreak, F_OFFOK }, + { "cols", f_columns, F_NEEDARG }, + { "columns", f_columns, F_NEEDARG }, + { "cooked", f_sane, 0 }, + { "dec", f_dec, 0 }, + { "ek", f_ek, 0 }, + { "everything", f_everything, 0 }, + { "extproc", f_extproc, F_OFFOK }, + { "ispeed", f_ispeed, F_NEEDARG }, + { "new", f_tty, 0 }, + { "nl", f_nl, F_OFFOK }, + { "old", f_tty, 0 }, + { "ospeed", f_ospeed, F_NEEDARG }, + { "raw", f_raw, F_OFFOK }, + { "rows", f_rows, F_NEEDARG }, + { "sane", f_sane, 0 }, + { "size", f_size, 0 }, + { "speed", f_speed, 0 }, + { "tty", f_tty, 0 }, +}; + +static int +c_key(const void *a, const void *b) +{ + + return (strcmp(((const struct key *)a)->name, ((const struct key *)b)->name)); +} + +int +ksearch(char ***argvp, struct info *ip) +{ + char *name; + struct key *kp, tmp; + + name = **argvp; + if (*name == '-') { + ip->off = 1; + ++name; + } else + ip->off = 0; + + tmp.name = name; + if (!(kp = (struct key *)bsearch(&tmp, keys, + sizeof(keys)/sizeof(struct key), sizeof(struct key), c_key))) + return (0); + if (!(kp->flags & F_OFFOK) && ip->off) { + warnx("illegal option -- -%s", name); + stty_usage(); + } + if (kp->flags & F_NEEDARG && !(ip->arg = *++*argvp)) { + warnx("option requires an argument -- %s", name); + stty_usage(); + } + kp->f(ip); + return (1); +} + +void +f_all(struct info *ip) +{ + print(&ip->t, &ip->win, ip->ldisc, BSD); +} + +void +f_cbreak(struct info *ip) +{ + + if (ip->off) + f_sane(ip); + else { + ip->t.c_iflag |= BRKINT|IXON|IMAXBEL; + ip->t.c_oflag |= OPOST; + ip->t.c_lflag |= ISIG|IEXTEN; + ip->t.c_lflag &= ~ICANON; + ip->set = 1; + } +} + +void +f_columns(struct info *ip) +{ + + ip->win.ws_col = atoi(ip->arg); + ip->wset = 1; +} + +void +f_dec(struct info *ip) +{ + + ip->t.c_cc[VERASE] = (u_char)0177; + ip->t.c_cc[VKILL] = CTRL('u'); + ip->t.c_cc[VINTR] = CTRL('c'); + ip->t.c_lflag &= ~ECHOPRT; + ip->t.c_lflag |= ECHOE|ECHOKE|ECHOCTL; + ip->t.c_iflag &= ~IXANY; + ip->set = 1; +} + +void +f_ek(struct info *ip) +{ + + ip->t.c_cc[VERASE] = CERASE; + ip->t.c_cc[VKILL] = CKILL; + ip->set = 1; +} + +void +f_everything(struct info *ip) +{ + + print(&ip->t, &ip->win, ip->ldisc, BSD); +} + +void +f_extproc(struct info *ip) +{ + + if (ip->off) { + int tmp = 0; + (void)ioctl(ip->fd, TIOCEXT, &tmp); + } else { + int tmp = 1; + (void)ioctl(ip->fd, TIOCEXT, &tmp); + } +} + +void +f_ispeed(struct info *ip) +{ + + cfsetispeed(&ip->t, (speed_t)atoi(ip->arg)); + ip->set = 1; +} + +void +f_nl(struct info *ip) +{ + + if (ip->off) { + ip->t.c_iflag |= ICRNL; + ip->t.c_oflag |= ONLCR; + } else { + ip->t.c_iflag &= ~ICRNL; + ip->t.c_oflag &= ~ONLCR; + } + ip->set = 1; +} + +void +f_ospeed(struct info *ip) +{ + + cfsetospeed(&ip->t, (speed_t)atoi(ip->arg)); + ip->set = 1; +} + +void +f_raw(struct info *ip) +{ + + if (ip->off) + f_sane(ip); + else { + cfmakeraw(&ip->t); + ip->t.c_cflag &= ~(CSIZE|PARENB); + ip->t.c_cflag |= CS8; + ip->set = 1; + } +} + +void +f_rows(struct info *ip) +{ + + ip->win.ws_row = atoi(ip->arg); + ip->wset = 1; +} + +void +f_sane(struct info *ip) +{ + struct termios def; + + cfmakesane(&def); + ip->t.c_cflag = def.c_cflag | (ip->t.c_cflag & CLOCAL); + ip->t.c_iflag = def.c_iflag; + /* preserve user-preference flags in lflag */ +#define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH) + ip->t.c_lflag = def.c_lflag | (ip->t.c_lflag & LKEEP); + ip->t.c_oflag = def.c_oflag; + ip->set = 1; +} + +void +f_size(struct info *ip) +{ + + (void)printf("%d %d\n", ip->win.ws_row, ip->win.ws_col); +} + +void +f_speed(struct info *ip) +{ + + (void)printf("%lu\n", (u_long)cfgetospeed(&ip->t)); +} + +void +f_tty(struct info *ip) +{ + int tmp; + + tmp = TTYDISC; + if (ioctl(ip->fd, TIOCSETD, &tmp) < 0) + err(1, "TIOCSETD"); +} diff --git a/adv_cmds-adv_cmds-199.0.1/stty/modes.c b/adv_cmds-adv_cmds-199.0.1/stty/modes.c new file mode 100644 index 00000000..519489f5 --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/modes.c @@ -0,0 +1,318 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include "stty.h" + +#ifdef __APPLE__ +// #include +// #else +#define COMPAT_MODE(a,b) (1) +#endif /* __APPLE__ */ + +int msearch(char ***, struct info *); + +struct modes { + const char *name; + long set; + long unset; +}; + +/* + * The code in optlist() depends on minus options following regular + * options, i.e. "foo" must immediately precede "-foo". + */ +static const struct modes cmodes[] = { + { "cs5", CS5, CSIZE }, + { "cs6", CS6, CSIZE }, + { "cs7", CS7, CSIZE }, + { "cs8", CS8, CSIZE }, + { "cstopb", CSTOPB, 0 }, + { "-cstopb", 0, CSTOPB }, + { "cread", CREAD, 0 }, + { "-cread", 0, CREAD }, + { "parenb", PARENB, 0 }, + { "-parenb", 0, PARENB }, + { "parodd", PARODD, 0 }, + { "-parodd", 0, PARODD }, + { "parity", PARENB | CS7, PARODD | CSIZE }, + { "-parity", CS8, PARODD | PARENB | CSIZE }, + { "evenp", PARENB | CS7, PARODD | CSIZE }, + { "-evenp", CS8, PARODD | PARENB | CSIZE }, + { "oddp", PARENB | CS7 | PARODD, CSIZE }, + { "-oddp", CS8, PARODD | PARENB | CSIZE }, + { "pass8", CS8, PARODD | PARENB | CSIZE }, + { "-pass8", PARENB | CS7, PARODD | CSIZE }, + { "hupcl", HUPCL, 0 }, + { "-hupcl", 0, HUPCL }, + { "hup", HUPCL, 0 }, + { "-hup", 0, HUPCL }, + { "clocal", CLOCAL, 0 }, + { "-clocal", 0, CLOCAL }, + { "crtscts", CRTSCTS, 0 }, + { "-crtscts", 0, CRTSCTS }, + { "ctsflow", CCTS_OFLOW, 0 }, + { "-ctsflow", 0, CCTS_OFLOW }, + { "dsrflow", CDSR_OFLOW, 0 }, + { "-dsrflow", 0, CDSR_OFLOW }, + { "dtrflow", CDTR_IFLOW, 0 }, + { "-dtrflow", 0, CDTR_IFLOW }, + { "rtsflow", CRTS_IFLOW, 0 }, + { "-rtsflow", 0, CRTS_IFLOW }, + { "mdmbuf", MDMBUF, 0 }, + { "-mdmbuf", 0, MDMBUF }, +#ifndef __APPLE__ + { "rtsdtr", 0, CNO_RTSDTR }, + { "-rtsdtr", CNO_RTSDTR, 0 }, +#endif + { NULL, 0, 0 }, +}; + +static const struct modes imodes[] = { + { "ignbrk", IGNBRK, 0 }, + { "-ignbrk", 0, IGNBRK }, + { "brkint", BRKINT, 0 }, + { "-brkint", 0, BRKINT }, + { "ignpar", IGNPAR, 0 }, + { "-ignpar", 0, IGNPAR }, + { "parmrk", PARMRK, 0 }, + { "-parmrk", 0, PARMRK }, + { "inpck", INPCK, 0 }, + { "-inpck", 0, INPCK }, + { "istrip", ISTRIP, 0 }, + { "-istrip", 0, ISTRIP }, + { "inlcr", INLCR, 0 }, + { "-inlcr", 0, INLCR }, + { "igncr", IGNCR, 0 }, + { "-igncr", 0, IGNCR }, + { "icrnl", ICRNL, 0 }, + { "-icrnl", 0, ICRNL }, + { "ixon", IXON, 0 }, + { "-ixon", 0, IXON }, + { "flow", IXON, 0 }, + { "-flow", 0, IXON }, + { "ixoff", IXOFF, 0 }, + { "-ixoff", 0, IXOFF }, + { "tandem", IXOFF, 0 }, + { "-tandem", 0, IXOFF }, + { "ixany", IXANY, 0 }, + { "-ixany", 0, IXANY }, + { "decctlq", 0, IXANY }, + { "-decctlq", IXANY, 0 }, + { "imaxbel", IMAXBEL, 0 }, + { "-imaxbel", 0, IMAXBEL }, +#ifdef __APPLE__ + { "iutf8", IUTF8, 0 }, + { "-iutf8", 0, IUTF8 }, +#endif + { NULL, 0, 0 }, +}; + +static const struct modes lmodes[] = { + { "echo", ECHO, 0 }, + { "-echo", 0, ECHO }, + { "echoe", ECHOE, 0 }, + { "-echoe", 0, ECHOE }, + { "crterase", ECHOE, 0 }, + { "-crterase", 0, ECHOE }, + { "crtbs", ECHOE, 0 }, /* crtbs not supported, close enough */ + { "-crtbs", 0, ECHOE }, + { "echok", ECHOK, 0 }, + { "-echok", 0, ECHOK }, + { "echoke", ECHOKE, 0 }, + { "-echoke", 0, ECHOKE }, + { "crtkill", ECHOKE, 0 }, + { "-crtkill", 0, ECHOKE }, + { "altwerase", ALTWERASE, 0 }, + { "-altwerase", 0, ALTWERASE }, + { "iexten", IEXTEN, 0 }, + { "-iexten", 0, IEXTEN }, + { "echonl", ECHONL, 0 }, + { "-echonl", 0, ECHONL }, + { "echoctl", ECHOCTL, 0 }, + { "-echoctl", 0, ECHOCTL }, + { "ctlecho", ECHOCTL, 0 }, + { "-ctlecho", 0, ECHOCTL }, + { "echoprt", ECHOPRT, 0 }, + { "-echoprt", 0, ECHOPRT }, + { "prterase", ECHOPRT, 0 }, + { "-prterase", 0, ECHOPRT }, + { "isig", ISIG, 0 }, + { "-isig", 0, ISIG }, + { "icanon", ICANON, 0 }, + { "-icanon", 0, ICANON }, + { "noflsh", NOFLSH, 0 }, + { "-noflsh", 0, NOFLSH }, + { "tostop", TOSTOP, 0 }, + { "-tostop", 0, TOSTOP }, + { "flusho", FLUSHO, 0 }, + { "-flusho", 0, FLUSHO }, + { "pendin", PENDIN, 0 }, + { "-pendin", 0, PENDIN }, + { "crt", ECHOE|ECHOKE|ECHOCTL, ECHOK|ECHOPRT }, + { "-crt", ECHOK, ECHOE|ECHOKE|ECHOCTL }, + { "newcrt", ECHOE|ECHOKE|ECHOCTL, ECHOK|ECHOPRT }, + { "-newcrt", ECHOK, ECHOE|ECHOKE|ECHOCTL }, + { "nokerninfo", NOKERNINFO, 0 }, + { "-nokerninfo",0, NOKERNINFO }, + { "kerninfo", 0, NOKERNINFO }, + { "-kerninfo", NOKERNINFO, 0 }, + { NULL, 0, 0 }, +}; + +static const struct modes omodes[] = { + { "opost", OPOST, 0 }, + { "-opost", 0, OPOST }, + { "litout", 0, OPOST }, + { "-litout", OPOST, 0 }, + { "onlcr", ONLCR, 0 }, + { "-onlcr", 0, ONLCR }, +#ifdef __APPLE__ + { "tabs", 0, OXTABS }, /* "preserve" tabs */ + { "-tabs", OXTABS, 0 }, + { "oxtabs", OXTABS, 0 }, + { "-oxtabs", 0, OXTABS }, +#else + { "ocrnl", OCRNL, 0 }, + { "-ocrnl", 0, OCRNL }, + { "tabs", TAB0, TABDLY }, /* "preserve" tabs */ + { "-tabs", TAB3, TABDLY }, + { "oxtabs", TAB3, TABDLY }, + { "-oxtabs", TAB0, TABDLY }, + { "tab0", TAB0, TABDLY }, + { "tab3", TAB3, TABDLY }, + { "onocr", ONOCR, 0 }, + { "-onocr", 0, ONOCR }, + { "onlret", ONLRET, 0 }, + { "-onlret", 0, ONLRET }, +#endif + { NULL, 0, 0 }, +}; + +#ifdef __APPLE__ +struct modes umodes[] = { /* For Unix conformance only */ + { "ocrnl", OCRNL, 0 }, + { "-ocrnl", 0, OCRNL }, + { "onocr", ONOCR, 0 }, + { "-onocr", 0, ONOCR }, + { "onlret", ONLRET, 0 }, + { "-onlret", 0, ONLRET }, + + { "ofill", OFILL, 0 }, + { "-ofill", 0, OFILL }, + + { "ofdel", OFDEL, 0 }, + { "-ofdel", 0, OFDEL }, + + { "bs0", BS0, 0 }, + { "bs1", BS1, 0 }, + + { "cr0", CR0, 0 }, + { "cr1", CR1, 0 }, + { "cr2", CR2, 0 }, + { "cr3", CR3, 0 }, + + { "ff0", FF0, 0 }, + { "ff1", FF1, 0 }, + + { "nl0", NL0, 0 }, + { "nl1", NL1, 0 }, + + { "tab0", TAB0, 0 }, + { "tab1", TAB1, 0 }, + { "tab2", TAB2, 0 }, + { "tab3", TAB3, 0 }, + + { "vt0", VT0, 0 }, + { "vt1", VT1, 0 }, + + { NULL, 0, 0 }, +}; +#endif + +#define CHK(s) (*name == s[0] && !strcmp(name, s)) + +int +msearch(char ***argvp, struct info *ip) +{ + const struct modes *mp; + char *name; + + name = **argvp; + + for (mp = cmodes; mp->name; ++mp) + if (CHK(mp->name)) { + ip->t.c_cflag &= ~mp->unset; + ip->t.c_cflag |= mp->set; + ip->set = 1; + return (1); + } + for (mp = imodes; mp->name; ++mp) + if (CHK(mp->name)) { + ip->t.c_iflag &= ~mp->unset; + ip->t.c_iflag |= mp->set; + ip->set = 1; + return (1); + } + for (mp = lmodes; mp->name; ++mp) + if (CHK(mp->name)) { + ip->t.c_lflag &= ~mp->unset; + ip->t.c_lflag |= mp->set; + ip->set = 1; + return (1); + } + for (mp = omodes; mp->name; ++mp) + if (CHK(mp->name)) { + ip->t.c_oflag &= ~mp->unset; + ip->t.c_oflag |= mp->set; + ip->set = 1; + return (1); + } +#ifdef __APPLE__ + if (COMPAT_MODE("bin/stty", "Unix2003")) { + for (mp = umodes; mp->name; ++mp) + if (CHK(mp->name)) { + ip->t.c_oflag &= ~mp->unset; + ip->t.c_oflag |= mp->set; + ip->set = 1; + return (1); + } + } +#endif + return (0); +} diff --git a/adv_cmds-adv_cmds-199.0.1/stty/print.c b/adv_cmds-adv_cmds-199.0.1/stty/print.c new file mode 100644 index 00000000..ca28405c --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/print.c @@ -0,0 +1,317 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include + +#include "stty.h" +#include "extern.h" + + +#include +#if !TARGET_OS_IPHONE +#ifdef __APPLE__ +#include /* XXX NTTYDISC is too well hidden */ +#endif +#else +#include "ios_error.h" +#define printf(...) fprintf (thread_stdout, ##__VA_ARGS__) +#endif + +static void binit(const char *); +static void bput(const char *); +static const char *ccval(struct cchar *, int); + +void +print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt) +{ + struct cchar *p; + long tmp; + u_char *cc; + int cnt, ispeed, ospeed; + char buf1[100], buf2[100]; + + cnt = 0; + + /* Line discipline. */ + if (ldisc != TTYDISC) { + switch(ldisc) { +#if !TARGET_OS_IPHONE +#ifdef __APPLE__ + case NTTYDISC: + cnt += printf("new tty disc; "); + break; + case TABLDISC: + cnt += printf("tablet disc; "); + break; +#endif +#endif + case SLIPDISC: + cnt += printf("slip disc; "); + break; + case PPPDISC: + cnt += printf("ppp disc; "); + break; + default: + cnt += printf("#%d disc; ", ldisc); + break; + } + } + + /* Line speed. */ + ispeed = cfgetispeed(tp); + ospeed = cfgetospeed(tp); + if (ispeed != ospeed) + cnt += + printf("ispeed %d baud; ospeed %d baud;", ispeed, ospeed); + else + cnt += printf("speed %d baud;", ispeed); + if (fmt >= BSD) + cnt += printf(" %d rows; %d columns;", wp->ws_row, wp->ws_col); + if (cnt) + (void)printf("\n"); + +#define on(f) ((tmp & (f)) != 0) +#define put(n, f, d) \ + if (fmt >= BSD || on(f) != (d)) \ + bput((n) + on(f)); + + /* "local" flags */ + tmp = tp->c_lflag; + binit("lflags"); + put("-icanon", ICANON, 1); + put("-isig", ISIG, 1); + put("-iexten", IEXTEN, 1); + put("-echo", ECHO, 1); + put("-echoe", ECHOE, 0); + put("-echok", ECHOK, 0); + put("-echoke", ECHOKE, 0); + put("-echonl", ECHONL, 0); + put("-echoctl", ECHOCTL, 0); + put("-echoprt", ECHOPRT, 0); + put("-altwerase", ALTWERASE, 0); + put("-noflsh", NOFLSH, 0); + put("-tostop", TOSTOP, 0); + put("-flusho", FLUSHO, 0); + put("-pendin", PENDIN, 0); + put("-nokerninfo", NOKERNINFO, 0); + put("-extproc", EXTPROC, 0); + + /* input flags */ + tmp = tp->c_iflag; + binit("iflags"); + put("-istrip", ISTRIP, 0); + put("-icrnl", ICRNL, 1); + put("-inlcr", INLCR, 0); + put("-igncr", IGNCR, 0); + put("-ixon", IXON, 1); + put("-ixoff", IXOFF, 0); + put("-ixany", IXANY, 1); + put("-imaxbel", IMAXBEL, 1); +#ifdef __APPLE__ + put("-iutf8", IUTF8, 0); +#endif + put("-ignbrk", IGNBRK, 0); + put("-brkint", BRKINT, 1); + put("-inpck", INPCK, 0); + put("-ignpar", IGNPAR, 0); + put("-parmrk", PARMRK, 0); + + /* output flags */ + tmp = tp->c_oflag; + binit("oflags"); + put("-opost", OPOST, 1); + put("-onlcr", ONLCR, 1); +#ifdef __APPLE__ + put("-oxtabs", OXTABS, 1); +#else + put("-ocrnl", OCRNL, 0); + switch(tmp&TABDLY) { + case TAB0: + bput("tab0"); + break; + case TAB3: + bput("tab3"); + break; + } +#endif + put("-onocr", ONOCR, 0); + put("-onlret", ONLRET, 0); + + /* control flags (hardware state) */ + tmp = tp->c_cflag; + binit("cflags"); + put("-cread", CREAD, 1); + switch(tmp&CSIZE) { + case CS5: + bput("cs5"); + break; + case CS6: + bput("cs6"); + break; + case CS7: + bput("cs7"); + break; + case CS8: + bput("cs8"); + break; + } + bput("-parenb" + on(PARENB)); + put("-parodd", PARODD, 0); + put("-hupcl", HUPCL, 1); + put("-clocal", CLOCAL, 0); + put("-cstopb", CSTOPB, 0); + switch(tmp & (CCTS_OFLOW | CRTS_IFLOW)) { + case CCTS_OFLOW: + bput("ctsflow"); + break; + case CRTS_IFLOW: + bput("rtsflow"); + break; + default: + put("-crtscts", CCTS_OFLOW | CRTS_IFLOW, 0); + break; + } + put("-dsrflow", CDSR_OFLOW, 0); + put("-dtrflow", CDTR_IFLOW, 0); + put("-mdmbuf", MDMBUF, 0); /* XXX mdmbuf == dtrflow */ +#ifndef __APPLE__ + if (on(CNO_RTSDTR)) + bput("-rtsdtr"); + else { + if (fmt >= BSD) + bput("rtsdtr"); + } +#endif + + /* special control characters */ + cc = tp->c_cc; + if (fmt == POSIX) { + binit("cchars"); + for (p = cchars1; p->name; ++p) { + (void)snprintf(buf1, sizeof(buf1), "%s = %s;", + p->name, ccval(p, cc[p->sub])); + bput(buf1); + } + binit(NULL); + } else { + binit(NULL); + for (p = cchars1, cnt = 0; p->name; ++p) { + if (fmt != BSD && cc[p->sub] == p->def) + continue; +#define WD "%-8s" + (void)snprintf(buf1 + cnt * 8, sizeof(buf1) - cnt * 8, + WD, p->name); + (void)snprintf(buf2 + cnt * 8, sizeof(buf2) - cnt * 8, + WD, ccval(p, cc[p->sub])); + if (++cnt == LINELENGTH / 8) { + cnt = 0; + (void)printf("%s\n", buf1); + (void)printf("%s\n", buf2); + } + } + if (cnt) { + (void)printf("%s\n", buf1); + (void)printf("%s\n", buf2); + } + } +} + +static int col; +static const char *label; + +static void +binit(const char *lb) +{ + + if (col) { + (void)printf("\n"); + col = 0; + } + label = lb; +} + +static void +bput(const char *s) +{ + + if (col == 0) { + col = printf("%s: %s", label, s); + return; + } + if ((col + strlen(s)) > LINELENGTH) { + (void)printf("\n\t"); + col = printf("%s", s) + 8; + return; + } + col += printf(" %s", s); +} + +static const char * +ccval(struct cchar *p, int c) +{ + static char buf[5]; + char *bp; + + if (p->sub == VMIN || p->sub == VTIME) { + (void)snprintf(buf, sizeof(buf), "%d", c); + return (buf); + } + if (c == _POSIX_VDISABLE) + return (""); + bp = buf; + if (c & 0200) { + *bp++ = 'M'; + *bp++ = '-'; + c &= 0177; + } + if (c == 0177) { + *bp++ = '^'; + *bp++ = '?'; + } + else if (c < 040) { + *bp++ = '^'; + *bp++ = c + '@'; + } + else + *bp++ = c; + *bp = '\0'; + return (buf); +} diff --git a/adv_cmds-adv_cmds-199.0.1/stty/stty.1 b/adv_cmds-adv_cmds-199.0.1/stty/stty.1 new file mode 100644 index 00000000..4f292221 --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/stty.1 @@ -0,0 +1,667 @@ +.\"- +.\" Copyright (c) 1990, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the Institute of Electrical and Electronics Engineers, Inc. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)stty.1 8.4 (Berkeley) 4/18/94 +.\" $FreeBSD$ +.\" +.Dd October 20, 2018 +.Dt STTY 1 +.Os +.Sh NAME +.Nm stty +.Nd set the options for a terminal device interface +.Sh SYNOPSIS +.Nm +.Op Fl a | e | g +.Op Fl f Ar file +.Op Ar arguments +.Sh DESCRIPTION +The +.Nm +utility sets or reports on terminal +characteristics for the device that is its standard input. +If no options or arguments are specified, it reports the settings of a subset +of characteristics as well as additional ones if they differ from their +default values. +Otherwise it modifies +the terminal state according to the specified arguments. +Some combinations of arguments are mutually +exclusive on some terminal types. +.Pp +The following options are available: +.Bl -tag -width indent +.It Fl a +Display all the current settings for the terminal to standard output +as per +.St -p1003.2 . +.It Fl e +Display all the current settings for the terminal to standard output +in the traditional +.Bx +``all'' and ``everything'' formats. +.It Fl f +Open and use the terminal named by +.Ar file +rather than using standard input. +The file is opened +using the +.Dv O_NONBLOCK +flag of +.Fn open , +making it possible to +set or display settings on a terminal that might otherwise +block on the open. +.It Fl g +Display all the current settings for the terminal to standard output +in a form that may be used as an argument to a subsequent invocation of +.Nm +to restore the current terminal state as per +.St -p1003.2 . +.El +.Pp +The following arguments are available to set the terminal +characteristics: +.Ss Control Modes: +Control mode flags affect hardware characteristics associated with the +terminal. +This corresponds to the c_cflag in the termios structure. +.Bl -tag -width Fl +.It Ar number +Set terminal baud rate to the number given, if possible. +If the baud rate is set to zero, +modem control is no longer asserted. +.It Cm clocal Pq Fl clocal +Assume a line without (with) modem control. +.It Cm cread Pq Fl cread +Enable (disable) the receiver. +.It Cm crtscts Pq Fl crtscts +Enable (disable) RTS/CTS flow control. +.\" .It Cm rtsdtr Pq Fl -rtsdtr +.\" Enable (disable) asserting RTS/DTR on open. +.It Cm cs5 cs6 cs7 cs8 +Select character size, if possible. +.It Cm cstopb Pq Fl cstopb +Use two (one) stop bits per character. +.It Cm hup Pq Fl hup +Same as +.Cm hupcl +.Pq Fl hupcl . +.It Cm hupcl Pq Fl hupcl +Stop asserting modem control +(do not stop asserting modem control) on last close. +.It Cm ispeed Ar number +Set terminal input baud rate to the number given, if possible. +If the input baud rate is set to zero, +the input baud rate is set to the value of the output baud rate. +.It Cm ospeed Ar number +Set terminal output baud rate to the number given, if possible. +If the output baud rate is set to zero, +modem control is no longer asserted. +.It Cm parenb Pq Fl parenb +Enable (disable) parity generation and detection. +.It Cm parodd Pq Fl parodd +Select odd (even) parity. +.It Cm speed Ar number +This sets both +.Cm ispeed +and +.Cm ospeed +to +.Ar number . +.El +.Ss Input Modes: +This corresponds to the c_iflag in the termios structure. +.Bl -tag -width Fl +.It Cm brkint Pq Fl brkint +Signal (do not signal) +.Dv INTR +on +break. +.It Cm icrnl Pq Fl icrnl +Map (do not map) +.Dv CR +to +.Dv NL +on input. +.It Cm ignbrk Pq Fl ignbrk +Ignore (do not ignore) break on input. +.It Cm igncr Pq Fl igncr +Ignore (do not ignore) +.Dv CR +on input. +.It Cm ignpar Pq Fl ignpar +Ignore (do not ignore) characters with parity errors. +.It Cm imaxbel Pq Fl imaxbel +The system imposes a limit of +.Dv MAX_INPUT +(currently 255) characters in the input queue. +If +.Cm imaxbel +is set and the input queue limit has been reached, +subsequent input causes the system to send an ASCII BEL +character to the output queue (the terminal beeps at you). +Otherwise, +if +.Cm imaxbel +is unset and the input queue is full, the next input character causes +the entire input and output queues to be discarded. +.It Cm inlcr Pq Fl inlcr +Map (do not map) +.Dv NL +to +.Dv CR +on input. +.It Cm inpck Pq Fl inpck +Enable (disable) input parity checking. +.It Cm istrip Pq Fl istrip +Strip (do not strip) input characters to seven bits. +.It Cm iutf8 Pq Fl iutf8 +Assume input characters are UTF-8 encoded. +.It Cm ixany Pq Fl ixany +Allow any character (allow only +.Dv START ) +to restart output. +.It Cm ixoff Pq Fl ixoff +Request that the system send (not send) +.Dv START/STOP +characters when the input queue is nearly empty/full. +.It Cm ixon Pq Fl ixon +Enable (disable) +.Dv START/STOP +output control. +Output from the system is stopped when the system receives +.Dv STOP +and started when the system receives +.Dv START , +or if +.Cm ixany +is set, any character restarts output. +.It Cm parmrk Pq Fl parmrk +Mark (do not mark) characters with parity errors. +.El +.Ss Output Modes: +This corresponds to the c_oflag of the termios structure. +.Bl -tag -width Fl +.It Cm bs0 bs1 +Select the style of delay for backspaces (e.g., set BSDLY to BS0). +.It Cm cr0 cr1 cr2 cr3 +Select the style of delay for carriage returns (e.g., set CRDLY to CR0). +.It Cm ff0 ff1 +Select the style of delay for form feeds (e.g., set FFDLY to FF0). +.It Cm nl0 nl1 +Select the style of delay for newlines (e.g., set NLDLY to NL0). +.It Cm ocrnl Pq Fl ocrnl +Map (do not map) carriage return to newline on output. +.It Cm ofdel Pq Fl odell +Use DELs (NULs) as fill characters. +.It Cm ofill Pq Fl ofill +Use fill characters (use timing) for delays. +.It Cm onlcr Pq Fl onlcr +Map (do not map) +.Dv NL +to +.Dv CR-NL +on output. +.It Cm onlret Pq Fl onlret +On the terminal, NL performs (does not perform) the CR function. +.It Cm onocr Pq Fl onocr +Do not (do) output CRs at column zero. +.It Cm opost Pq Fl opost +Post-process output (do not post-process output; +ignore all other output modes). +.It Cm oxtabs Pq Fl oxtabs +Expand (do not expand) tabs to spaces on output. +.\" .It Cm tab0 tab3 +.\" Select tab epxansion policy. +.\" .Cm tab0 +.\" disables tab expansion, while +.\" .Cm tab3 +.\" enables it. +.It Cm tab0 tab1 tab2 tab3 +Select the style of delay for horizontal tabs (e.g., set TABDLY to TAB0). +.It Cm tabs Pq Fl tabs +Same as +.Cm tab0 +.Cm ( tab3 ) . +.It Cm vt0 vt1 +Select the style of delay for vertical tabs (e.g., set VTDLY to VT0). +.El +.Ss Local Modes: +Local mode flags (lflags) affect various and sundry characteristics of terminal +processing. +Historically the term "local" pertained to new job control features +implemented by Jim Kulp on a +.Tn Pdp 11/70 +at +.Tn IIASA . +.\" Later the driver ran on the first +Later, the driver ran on the first +.Tn VAX +at Evans Hall, UC Berkeley, where the job control details +.\" were greatly modified but the structure definitions and names +.\" remained essentially unchange. +were greatly modified, +but the structure definitions and names remained essentially unchanged. +The second interpretation of the 'l' in lflag +.\" is ``line discipline flag'' which corresponds to the +is ``line discipline flag'', which corresponds to the +.Ar c_lflag +of the +.Ar termios +structure. +.Bl -tag -width Fl +.It Cm altwerase Pq Fl altwerase +Use (do not use) an alternate word erase algorithm when processing +.Dv WERASE +characters. +This alternate algorithm considers sequences of +alphanumeric/underscores as words. +It also skips the first preceding character in its classification +(as a convenience, since the one preceding character could have been +erased with simply an +.Dv ERASE +character.) +.It Cm echo Pq Fl echo +Echo back (do not echo back) every +character typed. +.It Cm echoctl Pq Fl echoctl +If +.Cm echoctl +is set, echo control characters as ^X. +Otherwise, control characters +echo as themselves. +.It Cm echoe Pq Fl echoe +The +.Dv ERASE +character shall (shall not) visually erase the last character +in the current line from the display, if possible. +.It Cm echok Pq Fl echok +Echo (do not echo) +.Dv NL +after +.Dv KILL +character. +.It Cm echoke Pq Fl echoke +The +.Dv KILL +character shall (shall +not) visually erase the +current line from the +display, if possible. +.It Cm echonl Pq Fl echonl +Echo (do not echo) +.Dv NL , +even if echo is disabled. +.It Cm echoprt Pq Fl echoprt +For printing terminals. +If set, echo erased characters backwards within ``\\'' +and ``/''. +Otherwise, disable this feature. +.It Cm flusho Pq Fl flusho +Indicates output is (is not) being discarded. +.It Cm icanon Pq Fl icanon +Enable (disable) canonical input +.Pf ( Dv ERASE +and +.Dv KILL +processing). +.It Cm iexten Pq Fl iexten +Enable (disable) any implementation-defined special control characters +that are not currently controlled by +.Cm icanon , +.Cm isig , +.Cm ixoff , +or +.Cm ixon . +.It Cm isig Pq Fl isig +Enable (disable) the checking of characters +against the special control characters +.Dv INTR , QUIT , +and +.Dv SUSP . +.It Cm mdmbuf Pq Fl mdmbuf +If set, flow control output based on condition of Carrier Detect. +Otherwise, writes return an error if Carrier Detect is low +(and Carrier is not being ignored with the +.Dv CLOCAL +flag.) +.It Cm noflsh Pq Fl noflsh +Disable (enable) flush after +.Dv INTR , QUIT , +or +.Dv SUSP . +.It Cm pendin Pq Fl pendin +Indicates input is (is not) pending +after a switch from non-canonical to canonical mode +and will be re-input when a read becomes pending or more input arrives. +.It Cm tostop Pq Fl tostop +Send (do not send) +.Dv SIGTTOU +for background output. +This causes background jobs to stop if they attempt +terminal output. +.El +.Ss Control Characters: +.Bl -tag -width Fl +.It Ar control-character Ar string +Set +.Ar control-character +to +.Ar string . +If string is a single character, +the control character is set to +that character. +If string is the +two character sequence "^-" or the +string "undef" the control character +is disabled (i.e., set to +.Pf { Dv _POSIX_VDISABLE Ns } . ) +.Pp +Recognized control-characters: +.Bd -ragged -offset indent +.Bl -column character Subscript +.It control- Ta \& Ta \& +.It character Ta Subscript Ta Description +.It _________ Ta _________ Ta _______________ +.It eof Ta Tn VEOF Ta EOF No character +.It eol Ta Tn VEOL Ta EOL No character +.It eol2 Ta Tn VEOL2 Ta EOL2 No character +.It erase Ta Tn VERASE Ta ERASE No character +.It erase2 Ta Tn VERASE2 Ta ERASE2 No character +.It werase Ta Tn VWERASE Ta WERASE No character +.It intr Ta Tn VINTR Ta INTR No character +.It kill Ta Tn VKILL Ta KILL No character +.It quit Ta Tn VQUIT Ta QUIT No character +.It susp Ta Tn VSUSP Ta SUSP No character +.It start Ta Tn VSTART Ta START No character +.It stop Ta Tn VSTOP Ta STOP No character +.It dsusp Ta Tn VDSUSP Ta DSUSP No character +.It lnext Ta Tn VLNEXT Ta LNEXT No character +.It reprint Ta Tn VREPRINT Ta REPRINT No character +.It status Ta Tn VSTATUS Ta STATUS No character +.El +.Ed +.It Cm min Ar number +.It Cm time Ar number +Set the value of min or time to +number. +.Dv MIN +and +.Dv TIME +are used in Non-Canonical mode input processing (-icanon). +.El +.Ss Combination Modes: +.Bl -tag -width Fl +.It Ar saved settings +Set the current terminal +characteristics to the saved settings +produced by the +.Fl g +option. +.It Cm cols Ar number +Same as +.Cm columns . +.It Cm columns Ar number +The terminal size is recorded as having +.Ar number +columns. +.It Cm crt Pq Fl crt +Set (disable) all modes suitable for a CRT display device. +.It Cm dec +Set modes suitable for users of Digital Equipment Corporation systems +.Dv ( ERASE , +.Dv KILL , +and +.Dv INTR +characters are set to ^?, ^U, and ^C; +.Dv ixany +is disabled, and +.Dv crt +is enabled.) +.It Cm ek +Reset +.Dv ERASE , +.Dv ERASE2 , +and +.Dv KILL +characters +back to system defaults. +.It Fl evenp +Same as +.Fl oddp +and +.Fl parity . +.It Cm evenp +Enable +.Cm parenb +and +.Cm cs7 ; +disable +.Cm parodd . +.It Cm extproc Pq Fl extproc +If set, this flag indicates that some amount of terminal processing +is being performed by either the terminal hardware +or by the remote side connected to a pty. +.It Cm kerninfo Pq Fl kerninfo +Enable (disable) the system generated status line associated with +processing a +.Dv STATUS +character (usually set to ^T). +The status line consists of the +system load average, the current command name, its process ID, the +event the process is waiting on (or the status of the process), the user +and system times, percent cpu, and current memory usage. +.\" .Pp +.\" If the +.\" .Xr sysctl 8 +.\" variable +.\" .Va kern.tty_info_kstacks +.\" is set to a non-zero value, the status message also includes the kernel program +.\" stack of the foreground thread. +.It Cm \&nl Pq Fl \&nl +Enable (disable) +.Cm icrnl . +In addition, +.Fl nl +unsets +.Cm inlcr +and +.Cm igncr . +.It Fl oddp +Same as +.Fl evenp +and +.Fl parity . +.It Cm oddp +Enable +.Cm parenb , +.Cm cs7 , +and +.Cm parodd . +.It Fl parity +Disable +.Cm parenb ; +set +.Cm cs8 . +.It Cm parity +Same as +.Cm evenp . +.It Cm raw Pq Fl raw +If set, change the modes of the terminal so that no input or output processing +is performed. +If unset, change the modes of the terminal to some reasonable +state that performs input and output processing. +Note that since the +terminal driver no longer has a single +.Dv RAW +bit, it is not possible to intuit what flags were set prior to setting +.Cm raw . +This means that unsetting +.Cm raw +may not put back all the setting that were previously in effect. +To set the terminal into a raw state and then accurately restore it, +the following shell code is recommended: +.Bd -literal +save_state=$(stty -g) +stty raw +\&... +stty "$save_state" +.Ed +.It Cm rows Ar number +The terminal size is recorded as having +.Ar number +rows. +.It Cm sane +Resets all modes to reasonable values for interactive terminal use. +.It Cm size +The size of the terminal is printed as two numbers on a single line, +first rows, then columns. +.It Cm tty +Set the line discipline to the standard terminal line discipline +.Dv TTYDISC . +.El +.Ss Compatibility Modes: +These modes remain for compatibility with the previous version of +the +.Nm +command. +.Bl -tag -width Fl +.It Cm all +Reports all the terminal modes as with +.Cm stty Fl a +except that the control characters are printed in a columnar format. +.It Cm brk Ar value +Same as the control character +.Cm eol . +.It Cm cbreak +If set, enables +.Cm brkint , ixon , imaxbel , opost , isig , iexten , +and +.Fl icanon . +If unset, same as +.Cm sane . +.It Cm cooked +Same as +.Cm sane . +.It Cm crtbs Pq Fl crtbs +Same as +.Cm echoe . +.It Cm crterase Pq Fl crterase +Same as +.Cm echoe . +.It Cm crtkill Pq Fl crtkill +Same as +.Cm echoke . +.It Cm ctlecho Pq Fl ctlecho +Same as +.Cm echoctl . +.It Cm decctlq Pq Fl decctlq +The converse of +.Cm ixany . +.It Cm everything +Same as +.Cm all . +.It Cm flush Ar value +Same as the control character +.Cm discard . +.It Cm litout Pq Fl litout +The converse of +.Cm opost . +.It Cm new +Same as +.Cm tty . +.It Cm newcrt Pq Fl newcrt +Same as +.Cm crt . +.It Cm old +Same as +.Cm tty . +.It Cm oxtabs Pq Fl oxtabs +Expand(do not expand) tabs to spaces on output. +.It Cm pass8 +The converse of +.Cm parity . +.It Cm prterase Pq Fl prterase +Same as +.Cm echoprt . +.It Cm rprnt Ar value +Same as the control character +.Cm reprint . +.It Cm tabs Pq Fl tabs +The converse of +.Cm oxtabs . +.It Cm tandem Pq Fl tandem +Same as +.Cm ixoff . +.El +.Sh EXIT STATUS +.Ex -std +.Sh LEGACY DESCRIPTION +In legacy operation, the +.Cm bs[01] , +.Cm cr[0-3] , +.Cm ff[01] , +.Cm nl[01] , +.Cm tab[0-3] , +and +.Cm vt[01] +control modes are not accepted, nor are +.Cm ocrnl Pq Fl ocrnl , +.Cm ofdel Pq Fl ofdel , +.Cm ofill Pq Fl ofill , +.Cm onlret Pq Fl onlret , +and +.Cm onocr Pq Fl onocr . +.Pp +For more information about legacy mode, see +.Xr compat 5 . +.Sh SEE ALSO +.\" .Xr resizewin 1 , +.Xr termios 4 , +.Xr compat 5 +.\" .Xr pstat 8 +.Sh STANDARDS +The +.Nm +utility is expected to be +.St -p1003.2 +compatible. +The flags +.Fl e +and +.Fl f +are +extensions to the standard. +.Sh HISTORY +A +.Nm +command appeared in +.At v2 . diff --git a/adv_cmds-adv_cmds-199.0.1/stty/stty.c b/adv_cmds-adv_cmds-199.0.1/stty/stty.c new file mode 100644 index 00000000..d27ff93c --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/stty.c @@ -0,0 +1,186 @@ +/*- + * Copyright (c) 1989, 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +#ifndef lint +static char const copyright[] = +"@(#) Copyright (c) 1989, 1991, 1993, 1994\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94"; +#endif /* not lint */ +#endif +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "stty.h" +#include "extern.h" + +// stty is mostly useless inside a-Shell. But we keep it because other commands might need it. +#include +#if TARGET_OS_IPHONE +#include "ios_error.h" +#endif + +int +#if TARGET_OS_IPHONE +stty_main(int argc, char *argv[]) +#else +main(int argc, char *argv[]) +#endif +{ + struct info i; + enum FMT fmt; + int ch; + const char *file, *errstr = NULL; + + fmt = NOTSET; + i.fd = STDIN_FILENO; + file = "stdin"; + + opterr = 0; + while (optind < argc && + strspn(argv[optind], "-aefg") == strlen(argv[optind]) && + (ch = getopt(argc, argv, "aef:g")) != -1) + switch(ch) { + case 'a': /* undocumented: POSIX compatibility */ + fmt = POSIX; + break; + case 'e': + fmt = BSD; + break; + case 'f': + if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) < 0) + err(1, "%s", optarg); + file = optarg; + break; + case 'g': + fmt = GFLAG; + break; + case '?': + default: + goto args; + } + +args: argc -= optind; + argv += optind; + +#if !TARGET_OS_IPHONE + if (tcgetattr(i.fd, &i.t) < 0) + errx(1, "%s isn't a terminal", file); + if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0) + err(1, "TIOCGETD"); + if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) + warn("TIOCGWINSZ"); +#else + if (!ios_isatty(i.fd)) + errx(1, "%s isn't a terminal", file); + i.ldisc = TTYDISC; + i.win.ws_col = atoi(ios_getenv("COLUMNS")); + i.win.ws_row = atoi(ios_getenv("ROWS")); +#endif + + checkredirect(); /* conversion aid */ + + switch(fmt) { + case NOTSET: + if (*argv) + break; + /* FALLTHROUGH */ + case BSD: + case POSIX: + print(&i.t, &i.win, i.ldisc, fmt); + break; + case GFLAG: + gprint(&i.t, &i.win, i.ldisc); + break; + } + + for (i.set = i.wset = 0; *argv; ++argv) { + if (ksearch(&argv, &i)) + continue; + + if (csearch(&argv, &i)) + continue; + + if (msearch(&argv, &i)) + continue; + + if (isdigit(**argv)) { + speed_t speed; + + speed = strtonum(*argv, 0, UINT_MAX, &errstr); + if (errstr) + err(1, "speed"); + cfsetospeed(&i.t, speed); + cfsetispeed(&i.t, speed); + i.set = 1; + continue; + } + + if (!strncmp(*argv, "gfmt1", sizeof("gfmt1") - 1)) { + gread(&i.t, *argv + sizeof("gfmt1") - 1); + i.set = 1; + continue; + } + + warnx("illegal option -- %s", *argv); + stty_usage(); + } + +#if !TARGET_OS_IPHONE + if (i.set && tcsetattr(i.fd, 0, &i.t) < 0) + err(1, "tcsetattr"); + if (i.wset && ioctl(i.fd, TIOCSWINSZ, &i.win) < 0) + warn("TIOCSWINSZ"); +#endif + exit(0); +} + +void +stty_usage(void) +{ + + (void)fprintf(thread_stderr, + "usage: stty [-a | -e | -g] [-f file] [arguments]\n"); + exit (1); +} diff --git a/adv_cmds-adv_cmds-199.0.1/stty/stty.h b/adv_cmds-adv_cmds-199.0.1/stty/stty.h new file mode 100644 index 00000000..d48ccaa2 --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/stty.h @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stty.h 8.1 (Berkeley) 5/31/93 + * $FreeBSD$ + */ + +#include +#include + +struct info { + int fd; /* file descriptor */ + int ldisc; /* line discipline */ + int off; /* turn off */ + int set; /* need set */ + int wset; /* need window set */ + const char *arg; /* argument */ + struct termios t; /* terminal info */ + struct winsize win; /* window info */ +}; + +struct cchar { + const char *name; + int sub; + u_char def; +}; + +enum FMT { NOTSET, GFLAG, BSD, POSIX }; + +#define LINELENGTH 72 diff --git a/adv_cmds-adv_cmds-199.0.1/stty/stty.plist.part b/adv_cmds-adv_cmds-199.0.1/stty/stty.plist.part new file mode 100644 index 00000000..da74d42a --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/stty.plist.part @@ -0,0 +1,20 @@ + + OpenSourceProject + stty + OpenSourceVersion + 2020-12-26 + OpenSourceWebsiteURL + https://cgit.freebsd.org/src/tree/bin/stty?id=50fcb4ee771cabbae99bb3150b26484f3e573fab + OpenSourceImportDate + 2021-08-28 + OpenSourceModifications + + stty.c: remove unsupported modes (3159260, 84626054) + modes.c: Unix conformance (3701033) + modes.c, print.c, stty.1: add iutf8 flag (4252063) + stty.1: reorder lists alphabetically (4748039) + stty.1: discuss legacy mode (5589089) + + OpenSourceLicense + bsd + diff --git a/adv_cmds-adv_cmds-199.0.1/stty/util.c b/adv_cmds-adv_cmds-199.0.1/stty/util.c new file mode 100644 index 00000000..19898ba9 --- /dev/null +++ b/adv_cmds-adv_cmds-199.0.1/stty/util.c @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 1991, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94"; +#endif +#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include + +#include "stty.h" +#include "extern.h" + +/* + * Gross, but since we're changing the control descriptor from 1 to 0, most + * users will be probably be doing "stty > /dev/sometty" by accident. If 1 + * and 2 are both ttys, but not the same, assume that 1 was incorrectly + * redirected. + */ +void +checkredirect(void) +{ + struct stat sb1, sb2; + + if (isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) && + !fstat(STDOUT_FILENO, &sb1) && !fstat(STDERR_FILENO, &sb2) && + (sb1.st_rdev != sb2.st_rdev)) +warnx("stdout appears redirected, but stdin is the control descriptor"); +}