drop <minix/termios.h>, use clean <sys/termios.h>
. also implement some netbsd-style tty ioctls . also implement SIGINFO . also import netbsd stty . rename keymap minix CMIN (for ctrl+minus on numeric keypad) to CNMIN; to keep unchanged control character default CMIN in new <sys/ttydefaults.h> . convert CS[5678] logic in rs232 driver to explicit setting of LC bits Change-Id: I9b7d2963fe9aec00fb6e7535ef565b3191fc1c1d
This commit is contained in:
parent
a06e2ab395
commit
7120f34ec1
69 changed files with 2734 additions and 2006 deletions
|
@ -2,6 +2,6 @@
|
||||||
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||||
|
|
||||||
SUBDIR= cat date df echo ed expr kill ksh ln ls \
|
SUBDIR= cat date df echo ed expr kill ksh ln ls \
|
||||||
mkdir pax pwd rm rmdir sync test
|
mkdir pax pwd rm rmdir sync test stty
|
||||||
|
|
||||||
.include <bsd.subdir.mk>
|
.include <bsd.subdir.mk>
|
||||||
|
|
9
bin/stty/Makefile
Normal file
9
bin/stty/Makefile
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# $NetBSD: Makefile,v 1.11 2012/04/04 10:59:44 joerg Exp $
|
||||||
|
# @(#)Makefile 8.1 (Berkeley) 5/31/93
|
||||||
|
|
||||||
|
PROG= stty
|
||||||
|
SRCS= cchar.c gfmt.c key.c modes.c print.c stty.c
|
||||||
|
|
||||||
|
CWARNFLAGS.clang+= -Wno-string-plus-int
|
||||||
|
|
||||||
|
.include <bsd.prog.mk>
|
148
bin/stty/cchar.c
Normal file
148
bin/stty/cchar.c
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
/* $NetBSD: cchar.c,v 1.16 2006/10/16 00:37:55 christos Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)cchar.c 8.5 (Berkeley) 4/2/94";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: cchar.c,v 1.16 2006/10/16 00:37:55 christos Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "stty.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
const struct cchar cchars1[] = {
|
||||||
|
{ "discard", VDISCARD, CDISCARD },
|
||||||
|
{ "dsusp", VDSUSP, CDSUSP },
|
||||||
|
{ "eof", VEOF, CEOF },
|
||||||
|
{ "eol", VEOL, CEOL },
|
||||||
|
{ "eol2", VEOL2, CEOL },
|
||||||
|
{ "erase", VERASE, CERASE },
|
||||||
|
{ "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 },
|
||||||
|
{ .name = NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct cchar cchars2[] = {
|
||||||
|
{ "brk", VEOL, CEOL },
|
||||||
|
{ "flush", VDISCARD, CDISCARD },
|
||||||
|
{ "rprnt", VREPRINT, CREPRINT },
|
||||||
|
{ .name = NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
static int c_cchar(const void *, const void *);
|
||||||
|
|
||||||
|
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(cchars1[0]) - 1, sizeof(cchars1[0]),
|
||||||
|
c_cchar)) &&
|
||||||
|
!(cp = (struct cchar *)bsearch(&tmp, cchars2,
|
||||||
|
sizeof(cchars2)/sizeof(cchars2[0]) - 1, sizeof(cchars2[0]),
|
||||||
|
c_cchar)))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
arg = *++*argvp;
|
||||||
|
if (!arg) {
|
||||||
|
warnx("option requires an argument -- %s", name);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CHK(s) (*arg == s[0] && !strcmp(arg, s))
|
||||||
|
if (CHK("undef") || CHK("<undef>"))
|
||||||
|
ip->t.c_cc[cp->sub] = _POSIX_VDISABLE;
|
||||||
|
else if (cp->sub == VMIN || cp->sub == VTIME) {
|
||||||
|
val = strtol(arg, &ep, 10);
|
||||||
|
if (val == _POSIX_VDISABLE) {
|
||||||
|
warnx("value of %ld would disable the option -- %s",
|
||||||
|
val, name);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
if (val > UCHAR_MAX) {
|
||||||
|
warnx("maximum option value is %d -- %s",
|
||||||
|
UCHAR_MAX, name);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
if (*ep != '\0') {
|
||||||
|
warnx("option requires a numeric argument -- %s", name);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
ip->t.c_cc[cp->sub] = (cc_t)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);
|
||||||
|
}
|
51
bin/stty/extern.h
Normal file
51
bin/stty/extern.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* $NetBSD: extern.h,v 1.12 2011/08/29 14:51:19 joerg Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _EXTERN_H_
|
||||||
|
#define _EXTERN_H_
|
||||||
|
|
||||||
|
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 *);
|
||||||
|
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);
|
||||||
|
__dead void usage(void);
|
||||||
|
|
||||||
|
extern const struct cchar cchars1[], cchars2[];
|
||||||
|
|
||||||
|
#endif /* !_EXTERN_H_ */
|
132
bin/stty/gfmt.c
Normal file
132
bin/stty/gfmt.c
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
/* $NetBSD: gfmt.c,v 1.17 2011/08/29 14:51:19 joerg Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)gfmt.c 8.6 (Berkeley) 4/2/94";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: gfmt.c,v 1.17 2011/08/29 14:51:19 joerg Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "stty.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
|
__dead static void gerr(char *);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gerr(char *s)
|
||||||
|
{
|
||||||
|
if (s)
|
||||||
|
errx(1, "illegal gfmt1 option -- %s", s);
|
||||||
|
else
|
||||||
|
errx(1, "illegal gfmt1 option");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gprint(struct termios *tp)
|
||||||
|
{
|
||||||
|
const struct cchar *cp;
|
||||||
|
|
||||||
|
(void)printf("gfmt1:cflag=%x:iflag=%x:lflag=%x:oflag=%x:",
|
||||||
|
tp->c_cflag, tp->c_iflag, tp->c_lflag, tp->c_oflag);
|
||||||
|
for (cp = cchars1; cp->name; ++cp)
|
||||||
|
(void)printf("%s=%x:", cp->name, tp->c_cc[cp->sub]);
|
||||||
|
(void)printf("ispeed=%d:ospeed=%d\n", cfgetispeed(tp), cfgetospeed(tp));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gread(struct termios *tp, char *s)
|
||||||
|
{
|
||||||
|
const 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';
|
||||||
|
(void)sscanf(ep, "%lx", &tmp);
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
#ifdef BSD4_4
|
||||||
|
if (CHK("ispeed")) {
|
||||||
|
(void)sscanf(ep, "%ld", &tmp);
|
||||||
|
tp->c_ispeed = tmp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (CHK("lflag")) {
|
||||||
|
tp->c_lflag = tmp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (CHK("oflag")) {
|
||||||
|
tp->c_oflag = tmp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#ifdef BSD4_4
|
||||||
|
if (CHK("ospeed")) {
|
||||||
|
(void)sscanf(ep, "%ld", &tmp);
|
||||||
|
tp->c_ospeed = tmp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (cp = cchars1; cp->name != NULL; ++cp)
|
||||||
|
if (CHK(cp->name)) {
|
||||||
|
if (cp->sub == VMIN || cp->sub == VTIME)
|
||||||
|
(void)sscanf(ep, "%ld", &tmp);
|
||||||
|
tp->c_cc[cp->sub] = tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (cp->name == NULL)
|
||||||
|
gerr(p);
|
||||||
|
}
|
||||||
|
}
|
339
bin/stty/key.c
Normal file
339
bin/stty/key.c
Normal file
|
@ -0,0 +1,339 @@
|
||||||
|
/* $NetBSD: key.c,v 1.20 2004/04/01 16:10:03 tsarna Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)key.c 8.4 (Berkeley) 2/20/95";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: key.c,v 1.20 2004/04/01 16:10:03 tsarna Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <paths.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "stty.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
void f_all(struct info *);
|
||||||
|
void f_cbreak(struct info *);
|
||||||
|
void f_columns(struct info *);
|
||||||
|
void f_dec(struct info *);
|
||||||
|
void f_everything(struct info *);
|
||||||
|
void f_extproc(struct info *);
|
||||||
|
void f_insane(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_ostart(struct info *);
|
||||||
|
void f_ostop(struct info *);
|
||||||
|
void f_tty(struct info *);
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
static const 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 },
|
||||||
|
{ "everything", f_everything, 0 },
|
||||||
|
{ "extproc", f_extproc, F_OFFOK },
|
||||||
|
{ "insane", f_insane, 0 },
|
||||||
|
{ "ispeed", f_ispeed, F_NEEDARG },
|
||||||
|
{ "new", f_tty, 0 },
|
||||||
|
{ "nl", f_nl, F_OFFOK },
|
||||||
|
{ "old", f_tty, 0 },
|
||||||
|
{ "ospeed", f_ospeed, F_NEEDARG },
|
||||||
|
{ "ostart", f_ostart, 0 },
|
||||||
|
{ "ostop", f_ostop, 0 },
|
||||||
|
{ "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 *, const void *);
|
||||||
|
|
||||||
|
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);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
if (kp->flags & F_NEEDARG && !(ip->arg = *++*argvp)) {
|
||||||
|
warnx("option requires an argument -- %s", name);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
kp->f(ip);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
f_all(struct info *ip)
|
||||||
|
{
|
||||||
|
print(&ip->t, &ip->win, ip->ldisc, STTY_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_everything(struct info *ip)
|
||||||
|
{
|
||||||
|
print(&ip->t, &ip->win, ip->ldisc, STTY_BSD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
f_extproc(struct info *ip)
|
||||||
|
{
|
||||||
|
#ifdef TIOCEXT
|
||||||
|
if (ip->off) {
|
||||||
|
int tmp = 0;
|
||||||
|
(void)ioctl(ip->fd, TIOCEXT, &tmp);
|
||||||
|
} else {
|
||||||
|
int tmp = 1;
|
||||||
|
(void)ioctl(ip->fd, TIOCEXT, &tmp);
|
||||||
|
}
|
||||||
|
ip->set = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
f_insane(struct info *ip)
|
||||||
|
{
|
||||||
|
int f, r;
|
||||||
|
|
||||||
|
r = f = open(_PATH_URANDOM, O_RDONLY, 0);
|
||||||
|
if (f >= 0) {
|
||||||
|
r = read(f, &(ip->t), sizeof(struct termios));
|
||||||
|
close(f);
|
||||||
|
}
|
||||||
|
if (r < 0) {
|
||||||
|
/* XXX not cryptographically secure! */
|
||||||
|
|
||||||
|
srandom(time(NULL));
|
||||||
|
ip->t.c_iflag = random();
|
||||||
|
ip->t.c_oflag = random();
|
||||||
|
ip->t.c_cflag = random();
|
||||||
|
ip->t.c_lflag = random();
|
||||||
|
for (f = 0; f < NCCS; f++) {
|
||||||
|
ip->t.c_cc[f] = random() & 0xFF;
|
||||||
|
}
|
||||||
|
ip->t.c_ispeed = random();
|
||||||
|
ip->t.c_ospeed = random();
|
||||||
|
}
|
||||||
|
|
||||||
|
ip->set = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
f_ispeed(struct info *ip)
|
||||||
|
{
|
||||||
|
cfsetispeed(&ip->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, 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)
|
||||||
|
{
|
||||||
|
ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & (CLOCAL|CRTSCTS|CDTRCTS));
|
||||||
|
ip->t.c_iflag = TTYDEF_IFLAG;
|
||||||
|
ip->t.c_iflag |= ICRNL;
|
||||||
|
/* preserve user-preference flags in lflag */
|
||||||
|
#define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH)
|
||||||
|
ip->t.c_lflag = TTYDEF_LFLAG | (ip->t.c_lflag & LKEEP);
|
||||||
|
ip->t.c_oflag = TTYDEF_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("%d\n", cfgetospeed(&ip->t));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ARGSUSED */
|
||||||
|
void
|
||||||
|
f_tty(struct info *ip)
|
||||||
|
{
|
||||||
|
#ifdef TTYDISC
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
tmp = TTYDISC;
|
||||||
|
if (ioctl(0, TIOCSETD, &tmp) < 0)
|
||||||
|
err(1, "TIOCSETD");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
f_ostart(struct info *ip)
|
||||||
|
{
|
||||||
|
#ifndef __minix
|
||||||
|
if (ioctl (0, TIOCSTART) < 0)
|
||||||
|
#else
|
||||||
|
if (ioctl (0, TIOCSTART, NULL) < 0)
|
||||||
|
#endif
|
||||||
|
err(1, "TIOCSTART");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
f_ostop(struct info *ip)
|
||||||
|
{
|
||||||
|
#ifndef __minix
|
||||||
|
if (ioctl (0, TIOCSTOP) < 0)
|
||||||
|
#else
|
||||||
|
if (ioctl (0, TIOCSTOP, NULL) < 0)
|
||||||
|
#endif
|
||||||
|
err(1, "TIOCSTOP");
|
||||||
|
}
|
242
bin/stty/modes.c
Normal file
242
bin/stty/modes.c
Normal file
|
@ -0,0 +1,242 @@
|
||||||
|
/* $NetBSD: modes.c,v 1.17 2006/10/16 00:37:55 christos Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: modes.c,v 1.17 2006/10/16 00:37:55 christos Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "stty.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
|
struct modes {
|
||||||
|
const char *name;
|
||||||
|
tcflag_t set;
|
||||||
|
tcflag_t unset;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The code in optlist() depends on minus options following regular
|
||||||
|
* options, i.e. "foo" must immediately precede "-foo".
|
||||||
|
*/
|
||||||
|
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 },
|
||||||
|
{ "mdmbuf", MDMBUF, 0 },
|
||||||
|
{ "-mdmbuf", 0, MDMBUF },
|
||||||
|
{ "cdtrcts", CDTRCTS, 0 },
|
||||||
|
{ "-cdtrcts", 0, CDTRCTS },
|
||||||
|
{ .name = NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
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 },
|
||||||
|
{ .name = NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
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 },
|
||||||
|
{ .name = NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct modes omodes[] = {
|
||||||
|
{ "opost", OPOST, 0 },
|
||||||
|
{ "-opost", 0, OPOST },
|
||||||
|
{ "litout", 0, OPOST },
|
||||||
|
{ "-litout", OPOST, 0 },
|
||||||
|
{ "onlcr", ONLCR, 0 },
|
||||||
|
{ "-onlcr", 0, ONLCR },
|
||||||
|
{ "ocrnl", OCRNL, 0 },
|
||||||
|
{ "-ocrnl", 0, OCRNL },
|
||||||
|
{ "tabs", 0, OXTABS }, /* "preserve" tabs */
|
||||||
|
{ "-tabs", OXTABS, 0 },
|
||||||
|
{ "oxtabs", OXTABS, 0 },
|
||||||
|
{ "-oxtabs", 0, OXTABS },
|
||||||
|
{ "onocr", ONOCR, 0 },
|
||||||
|
{ "-onocr", 0, ONOCR },
|
||||||
|
{ "onlret", ONLRET, 0 },
|
||||||
|
{ "-onlret", 0, ONLRET },
|
||||||
|
{ .name = NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CHK(s) (!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);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
273
bin/stty/print.c
Normal file
273
bin/stty/print.c
Normal file
|
@ -0,0 +1,273 @@
|
||||||
|
/* $NetBSD: print.c,v 1.22 2005/06/26 19:10:49 christos Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: print.c,v 1.22 2005/06/26 19:10:49 christos Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "stty.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
|
static void binit(const char *);
|
||||||
|
static void bput(const char *);
|
||||||
|
static const char *ccval(const struct cchar *, int);
|
||||||
|
|
||||||
|
void
|
||||||
|
print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt)
|
||||||
|
{
|
||||||
|
const struct cchar *p;
|
||||||
|
long tmp;
|
||||||
|
u_char *cc;
|
||||||
|
int cnt, ispeed, ospeed;
|
||||||
|
char buf1[100], buf2[100];
|
||||||
|
|
||||||
|
cnt = 0;
|
||||||
|
|
||||||
|
/* Line discipline. */
|
||||||
|
#ifdef TTYDISC
|
||||||
|
if (ldisc != TTYDISC) {
|
||||||
|
switch(ldisc) {
|
||||||
|
case TABLDISC:
|
||||||
|
cnt += printf("tablet disc; ");
|
||||||
|
break;
|
||||||
|
case SLIPDISC:
|
||||||
|
cnt += printf("slip disc; ");
|
||||||
|
break;
|
||||||
|
case PPPDISC:
|
||||||
|
cnt += printf("ppp disc; ");
|
||||||
|
break;
|
||||||
|
case STRIPDISC:
|
||||||
|
cnt += printf("strip disc; ");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cnt += printf("#%d disc; ", ldisc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 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 >= STTY_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 >= STTY_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);
|
||||||
|
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);
|
||||||
|
put("-ocrnl", OCRNL, 0);
|
||||||
|
put("-oxtabs", OXTABS, 1);
|
||||||
|
put("-onocr", OXTABS, 0);
|
||||||
|
put("-onlret", OXTABS, 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);
|
||||||
|
put("-crtscts", CRTSCTS, 0);
|
||||||
|
put("-mdmbuf", MDMBUF, 0);
|
||||||
|
put("-cdtrcts", CDTRCTS, 0);
|
||||||
|
|
||||||
|
/* special control characters */
|
||||||
|
cc = tp->c_cc;
|
||||||
|
if (fmt == STTY_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 != STTY_BSD && cc[p->sub] == p->def)
|
||||||
|
continue;
|
||||||
|
#define WD "%-8s"
|
||||||
|
(void)snprintf(buf1 + cnt * 8, 9, WD, p->name);
|
||||||
|
(void)snprintf(buf2 + cnt * 8, 9, 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(const struct cchar *p, int c)
|
||||||
|
{
|
||||||
|
static char buf[5];
|
||||||
|
char *bp;
|
||||||
|
|
||||||
|
if (c == _POSIX_VDISABLE)
|
||||||
|
return ("<undef>");
|
||||||
|
|
||||||
|
if (p->sub == VMIN || p->sub == VTIME) {
|
||||||
|
(void)snprintf(buf, sizeof(buf), "%d", c);
|
||||||
|
return (buf);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
635
bin/stty/stty.1
Normal file
635
bin/stty/stty.1
Normal file
|
@ -0,0 +1,635 @@
|
||||||
|
.\" $NetBSD: stty.1,v 1.41 2012/06/20 14:19:39 wiz Exp $
|
||||||
|
.\"
|
||||||
|
.\" 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.5 (Berkeley) 6/1/94
|
||||||
|
.\"
|
||||||
|
.Dd June 16, 2012
|
||||||
|
.Dt STTY 1
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm stty
|
||||||
|
.Nd set options for a terminal device interface
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Op Fl a | Fl e | Fl g
|
||||||
|
.Op Fl f Ar file
|
||||||
|
.Op operand ...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility sets or reports on terminal
|
||||||
|
characteristics for the device that is its standard input.
|
||||||
|
If no options or operands 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 XfXfileXX
|
||||||
|
.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
|
||||||
|
.Dq all
|
||||||
|
and
|
||||||
|
.Dq everything
|
||||||
|
formats.
|
||||||
|
.It Fl f Ar file
|
||||||
|
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
|
||||||
|
.Fa c_cflag
|
||||||
|
of the
|
||||||
|
.Xr termios 4
|
||||||
|
structure.
|
||||||
|
.Bl -tag -width Fl
|
||||||
|
.It Cm parenb Pq Fl parenb
|
||||||
|
Enable (disable) parity generation
|
||||||
|
and detection.
|
||||||
|
.It Cm parodd Pq Fl parodd
|
||||||
|
Select odd (even) parity.
|
||||||
|
.It Cm cs5 cs6 cs7 cs8
|
||||||
|
Select character size, if possible.
|
||||||
|
.It Ar number
|
||||||
|
Set terminal baud rate to
|
||||||
|
.Ar number ,
|
||||||
|
if possible.
|
||||||
|
If the
|
||||||
|
baud rate is set to zero, modem
|
||||||
|
control is no longer
|
||||||
|
asserted.
|
||||||
|
.It Cm ispeed Ar number
|
||||||
|
Set terminal input baud rate to
|
||||||
|
.Ar number ,
|
||||||
|
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
|
||||||
|
.Ar number ,
|
||||||
|
if possible.
|
||||||
|
If
|
||||||
|
the output baud rate is set to
|
||||||
|
zero, modem control is
|
||||||
|
no longer asserted.
|
||||||
|
.It Cm speed Ar number
|
||||||
|
This sets both
|
||||||
|
.Cm ispeed
|
||||||
|
and
|
||||||
|
.Cm ospeed
|
||||||
|
to
|
||||||
|
.Ar number .
|
||||||
|
.It Cm hupcl Pq Fl hupcl
|
||||||
|
Stop asserting modem control
|
||||||
|
(do not stop asserting modem control) on last close.
|
||||||
|
.It Cm hup Pq Fl hup
|
||||||
|
Same as hupcl
|
||||||
|
.Pq Fl hupcl .
|
||||||
|
.It Cm cstopb Pq Fl cstopb
|
||||||
|
Use two (one) stop bits per character.
|
||||||
|
.It Cm cread Pq Fl cread
|
||||||
|
Enable (disable) the receiver.
|
||||||
|
.It Cm clocal Pq Fl clocal
|
||||||
|
Assume a line without (with) modem
|
||||||
|
control.
|
||||||
|
.It Cm crtscts Pq Fl crtscts
|
||||||
|
Enable RTS/CTS flow control.
|
||||||
|
.It Cm cdtrcts Pq Fl cdtrcts
|
||||||
|
Enable DTR/CTS flow control (if supported).
|
||||||
|
.El
|
||||||
|
.Ss Input Modes
|
||||||
|
This corresponds to the
|
||||||
|
.Fa c_iflag
|
||||||
|
of the
|
||||||
|
.Xr termios 4
|
||||||
|
structure.
|
||||||
|
.Bl -tag -width Fl
|
||||||
|
.It Cm ignbrk Pq Fl ignbrk
|
||||||
|
Ignore (do not ignore) break on
|
||||||
|
input.
|
||||||
|
.It Cm brkint Pq Fl brkint
|
||||||
|
Signal (do not signal)
|
||||||
|
.Dv INTR
|
||||||
|
on
|
||||||
|
break.
|
||||||
|
.It Cm ignpar Pq Fl ignpar
|
||||||
|
Ignore (do not ignore) parity
|
||||||
|
errors.
|
||||||
|
.It Cm parmrk Pq Fl parmrk
|
||||||
|
Mark (do not mark) parity errors.
|
||||||
|
.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 inlcr Pq Fl inlcr
|
||||||
|
Map (do not map)
|
||||||
|
.Dv NL
|
||||||
|
to
|
||||||
|
.Dv CR
|
||||||
|
on input.
|
||||||
|
.It Cm igncr Pq Fl igncr
|
||||||
|
Ignore (do not ignore)
|
||||||
|
.Dv CR
|
||||||
|
on input.
|
||||||
|
.It Cm icrnl Pq Fl icrnl
|
||||||
|
Map (do not map)
|
||||||
|
.Dv CR
|
||||||
|
to
|
||||||
|
.Dv NL
|
||||||
|
on input.
|
||||||
|
.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 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 ixany Pq Fl ixany
|
||||||
|
Allow any character (allow only
|
||||||
|
.Dv START )
|
||||||
|
to restart output.
|
||||||
|
.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.
|
||||||
|
.El
|
||||||
|
.Ss Output Modes
|
||||||
|
This corresponds to the
|
||||||
|
.Fa c_oflag
|
||||||
|
of the
|
||||||
|
.Xr termios 4
|
||||||
|
structure.
|
||||||
|
.Bl -tag -width Fl
|
||||||
|
.It Cm opost Pq Fl opost
|
||||||
|
Post-process output (do not
|
||||||
|
post-process output; ignore all other
|
||||||
|
output modes).
|
||||||
|
.It Cm onlcr Pq Fl onlcr
|
||||||
|
Map (do not map)
|
||||||
|
.Dv NL
|
||||||
|
to
|
||||||
|
.Dv CR-NL
|
||||||
|
on output.
|
||||||
|
.It Cm ocrnl Pq Fl ocrnl
|
||||||
|
Map (do not map)
|
||||||
|
.Dv CR
|
||||||
|
to
|
||||||
|
.Dv NL
|
||||||
|
on output.
|
||||||
|
.It Cm oxtabs Pq Fl oxtabs
|
||||||
|
Expand (do not expand) tabs to spaces on output.
|
||||||
|
.It Cm onocr Pq Fl onocr
|
||||||
|
Do not (do) output CRs at column zero.
|
||||||
|
.It Cm onlret Pq Fl onlret
|
||||||
|
On the terminal NL performs (does not perform) the CR function.
|
||||||
|
.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 Ns -11/70
|
||||||
|
at
|
||||||
|
.Tn IIASA .
|
||||||
|
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 unchanged.
|
||||||
|
The second interpretation of the
|
||||||
|
.Sq l
|
||||||
|
in lflag
|
||||||
|
is
|
||||||
|
.Dq line discipline flag ,
|
||||||
|
which corresponds to the
|
||||||
|
.Fa c_lflag
|
||||||
|
of the
|
||||||
|
.Xr termios 4
|
||||||
|
structure.
|
||||||
|
.Bl -tag -width Fl
|
||||||
|
.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 icanon Pq Fl icanon
|
||||||
|
Enable (disable) canonical input
|
||||||
|
.Dv ( ERASE
|
||||||
|
and
|
||||||
|
.Dv KILL
|
||||||
|
processing).
|
||||||
|
.It Cm iexten Pq Fl iexten
|
||||||
|
Enable (disable) any implementation
|
||||||
|
defined special control characters
|
||||||
|
not currently controlled by icanon,
|
||||||
|
isig, or ixon.
|
||||||
|
.It Cm echo Pq Fl echo
|
||||||
|
Echo back (do not echo back) every
|
||||||
|
character typed.
|
||||||
|
.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 echoctl Pq Fl echoctl
|
||||||
|
If
|
||||||
|
.Cm echoctl
|
||||||
|
is set, echo control characters as ^X.
|
||||||
|
Otherwise control characters echo as themselves.
|
||||||
|
.It Cm echoprt Pq Fl echoprt
|
||||||
|
For printing terminals.
|
||||||
|
If set, echo erased characters backwards within
|
||||||
|
.Dq \e
|
||||||
|
and
|
||||||
|
.Dq / .
|
||||||
|
Otherwise, disable this feature.
|
||||||
|
.It Cm noflsh Pq Fl noflsh
|
||||||
|
Disable (enable) flush after
|
||||||
|
.Dv INTR , QUIT , SUSP .
|
||||||
|
.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.
|
||||||
|
.It Cm altwerase Pq Fl altwerase
|
||||||
|
Use (do not use) an alternative word erase algorithm when processing
|
||||||
|
.Dv WERASE
|
||||||
|
characters.
|
||||||
|
This alternative 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 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 flusho Pq Fl flusho
|
||||||
|
Indicates output is (is not) being discarded.
|
||||||
|
.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.
|
||||||
|
.El
|
||||||
|
.Ss Control Characters
|
||||||
|
.Bl -tag -width Fl
|
||||||
|
.It Ar control-character Ar string
|
||||||
|
Set
|
||||||
|
.Ar control-character
|
||||||
|
to string
|
||||||
|
.Ar string .
|
||||||
|
If the string is a single character,
|
||||||
|
then the control character is set to
|
||||||
|
that character.
|
||||||
|
If the string is the
|
||||||
|
two character sequence "^-" or the
|
||||||
|
string "undef", then the control character
|
||||||
|
is disabled (i.e., set to
|
||||||
|
.Bro Dv _POSIX_VDISABLE Brc ) .
|
||||||
|
.Pp
|
||||||
|
Recognized control characters:
|
||||||
|
.Bd -ragged -offset indent
|
||||||
|
.Bl -column character Subscript Description
|
||||||
|
.It control- Ta "" Ta ""
|
||||||
|
.It character Subscript Description
|
||||||
|
.It _________ _________ _______________
|
||||||
|
.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 werase Ta Tn VWERASE Ta WERASE No character
|
||||||
|
.It kill Ta Tn VKILL Ta KILL No character
|
||||||
|
.It reprint Ta Tn VREPRINT Ta REPRINT No character
|
||||||
|
.It intr Ta Tn VINTR Ta INTR No character
|
||||||
|
.It quit Ta Tn VQUIT Ta QUIT No character
|
||||||
|
.It susp Ta Tn VSUSP Ta SUSP No character
|
||||||
|
.It dsusp Ta Tn VDSUSP Ta DSUSP No character
|
||||||
|
.It start Ta Tn VSTART Ta START No character
|
||||||
|
.It stop Ta Tn VSTOP Ta STOP No character
|
||||||
|
.It lnext Ta Tn VLNEXT Ta LNEXT No character
|
||||||
|
.It status Ta Tn VSTATUS Ta STATUS No character
|
||||||
|
.It discard Ta Tn VDISCARD Ta DISCARD No character
|
||||||
|
.El
|
||||||
|
.Ed
|
||||||
|
.It Cm min Ar number
|
||||||
|
.It Cm time Ar number
|
||||||
|
Set the value of min or time to
|
||||||
|
.Ar 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 evenp No or Cm parity
|
||||||
|
Enable parenb and cs7; disable parodd.
|
||||||
|
.It Cm oddp
|
||||||
|
Enable parenb, cs7, and parodd.
|
||||||
|
.It Fl parity , evenp , oddp
|
||||||
|
Disable parenb, and set cs8.
|
||||||
|
.It Cm \&nl Pq Fl \&nl
|
||||||
|
Enable (disable) icrnl.
|
||||||
|
In addition
|
||||||
|
-nl unsets inlcr and igncr.
|
||||||
|
.It Cm ek
|
||||||
|
Reset
|
||||||
|
.Dv ERASE
|
||||||
|
and
|
||||||
|
.Dv KILL
|
||||||
|
characters back to system defaults.
|
||||||
|
.It Cm sane
|
||||||
|
Resets all modes to reasonable values for interactive terminal use.
|
||||||
|
.It Cm insane
|
||||||
|
Sets all modes to random values, which are very likely
|
||||||
|
.Pq but not guaranteed
|
||||||
|
to be unreasonable for interactive terminal use.
|
||||||
|
.It Cm tty
|
||||||
|
Set the line discipline to the standard terminal line discipline
|
||||||
|
.Dv TTYDISC .
|
||||||
|
.It Cm crt Pq Fl crt
|
||||||
|
Set (disable) all modes suitable for a CRT display device.
|
||||||
|
.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.
|
||||||
|
.It Cm columns Ar number
|
||||||
|
The terminal size is recorded as having
|
||||||
|
.Ar number
|
||||||
|
columns.
|
||||||
|
.It Cm cols Ar number
|
||||||
|
An alias for
|
||||||
|
.Cm columns .
|
||||||
|
.It Cm rows Ar number
|
||||||
|
The terminal size is recorded as having
|
||||||
|
.Ar number
|
||||||
|
rows.
|
||||||
|
.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 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 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 -offset indent
|
||||||
|
save_state=$(stty -g)
|
||||||
|
stty raw
|
||||||
|
\&...
|
||||||
|
stty "$save_state"
|
||||||
|
.Ed
|
||||||
|
.It Cm size
|
||||||
|
The size of the terminal is printed as two numbers on a single line,
|
||||||
|
first rows, then columns.
|
||||||
|
.El
|
||||||
|
.Ss Compatibility Modes
|
||||||
|
These modes remain for compatibility with the previous version of
|
||||||
|
the
|
||||||
|
.Nm
|
||||||
|
utility.
|
||||||
|
.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 everything
|
||||||
|
Same as
|
||||||
|
.Cm all .
|
||||||
|
.It Cm cooked
|
||||||
|
Same as
|
||||||
|
.Cm sane .
|
||||||
|
.It Cm cbreak
|
||||||
|
If set, enables
|
||||||
|
.Cm brkint , ixon , imaxbel , opost ,
|
||||||
|
.Cm isig , iexten ,
|
||||||
|
and
|
||||||
|
.Fl icanon .
|
||||||
|
If unset, same as
|
||||||
|
.Cm sane .
|
||||||
|
.It Cm new
|
||||||
|
Same as
|
||||||
|
.Cm tty .
|
||||||
|
.It Cm old
|
||||||
|
Same as
|
||||||
|
.Cm tty .
|
||||||
|
.It Cm newcrt Pq Fl newcrt
|
||||||
|
Same as
|
||||||
|
.Cm crt .
|
||||||
|
.It Cm pass8
|
||||||
|
The converse of
|
||||||
|
.Cm parity .
|
||||||
|
.It Cm tandem Pq Fl tandem
|
||||||
|
Same as
|
||||||
|
.Cm ixoff .
|
||||||
|
.It Cm decctlq Pq Fl decctlq
|
||||||
|
The converse of
|
||||||
|
.Cm ixany .
|
||||||
|
.It Cm crterase Pq Fl crterase
|
||||||
|
Same as
|
||||||
|
.Cm echoe .
|
||||||
|
.It Cm crtbs Pq Fl crtbs
|
||||||
|
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 prterase Pq Fl prterase
|
||||||
|
Same as
|
||||||
|
.Cm echoprt .
|
||||||
|
.It Cm litout Pq Fl litout
|
||||||
|
The converse of
|
||||||
|
.Cm opost .
|
||||||
|
.It Cm tabs Pq Fl tabs
|
||||||
|
The converse of
|
||||||
|
.Cm oxtabs .
|
||||||
|
.It Cm brk Ar value
|
||||||
|
Same as the control character
|
||||||
|
.Cm eol .
|
||||||
|
.It Cm flush Ar value
|
||||||
|
Same as the control character
|
||||||
|
.Cm discard .
|
||||||
|
.It Cm rprnt Ar value
|
||||||
|
Same as the control character
|
||||||
|
.Cm reprint .
|
||||||
|
.El
|
||||||
|
.Ss Control operations
|
||||||
|
These operations are not modes, but rather commands to be performed by
|
||||||
|
the tty layer.
|
||||||
|
.Bl -tag -width Fl
|
||||||
|
.It Cm ostart
|
||||||
|
Performs a "start output" operation, as normally done by an
|
||||||
|
incoming START character when
|
||||||
|
.Cm ixon
|
||||||
|
is set.
|
||||||
|
.It Cm ostop
|
||||||
|
Performs a "stop output" operation, as normally done by an
|
||||||
|
incoming STOP character when
|
||||||
|
.Cm ixon
|
||||||
|
is set.
|
||||||
|
.El
|
||||||
|
.Sh EXIT STATUS
|
||||||
|
.Ex -std
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr termios 4 ,
|
||||||
|
.Xr tty 4
|
||||||
|
.Sh STANDARDS
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility is expected to be
|
||||||
|
.St -p1003.2
|
||||||
|
compatible.
|
||||||
|
The
|
||||||
|
.Fl e
|
||||||
|
and
|
||||||
|
.Fl f
|
||||||
|
flags are
|
||||||
|
extensions to the standard, as are the operands mentioned in the control
|
||||||
|
operations section.
|
168
bin/stty/stty.c
Normal file
168
bin/stty/stty.c
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
/* $NetBSD: stty.c,v 1.22 2012/06/20 10:09:43 wiz Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
__COPYRIGHT("@(#) Copyright (c) 1989, 1991, 1993, 1994\
|
||||||
|
The Regents of the University of California. All rights reserved.");
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: stty.c,v 1.22 2012/06/20 10:09:43 wiz Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "stty.h"
|
||||||
|
#include "extern.h"
|
||||||
|
|
||||||
|
int main(int, char *[]);
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct info i;
|
||||||
|
enum FMT fmt;
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
setprogname(argv[0]);
|
||||||
|
(void)setlocale(LC_ALL, "");
|
||||||
|
|
||||||
|
fmt = STTY_NOTSET;
|
||||||
|
i.fd = STDIN_FILENO;
|
||||||
|
|
||||||
|
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 = STTY_POSIX;
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
fmt = STTY_BSD;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) < 0)
|
||||||
|
err(1, "%s", optarg);
|
||||||
|
break;
|
||||||
|
case 'g':
|
||||||
|
fmt = STTY_GFLAG;
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
default:
|
||||||
|
goto args;
|
||||||
|
}
|
||||||
|
|
||||||
|
args: argc -= optind;
|
||||||
|
argv += optind;
|
||||||
|
|
||||||
|
if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
|
||||||
|
err(1, "TIOCGETD");
|
||||||
|
if (tcgetattr(i.fd, &i.t) < 0)
|
||||||
|
err(1, "tcgetattr");
|
||||||
|
if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
|
||||||
|
warn("TIOCGWINSZ");
|
||||||
|
|
||||||
|
switch(fmt) {
|
||||||
|
case STTY_NOTSET:
|
||||||
|
if (*argv)
|
||||||
|
break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case STTY_BSD:
|
||||||
|
case STTY_POSIX:
|
||||||
|
print(&i.t, &i.win, i.ldisc, fmt);
|
||||||
|
break;
|
||||||
|
case STTY_GFLAG:
|
||||||
|
gprint(&i.t);
|
||||||
|
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((unsigned char)**argv)) {
|
||||||
|
int speed;
|
||||||
|
|
||||||
|
speed = atoi(*argv);
|
||||||
|
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);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
exit(0);
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
(void)fprintf(stderr, "usage: %s [-a|-e|-g] [-f file] [operand ...]\n", getprogname());
|
||||||
|
exit(1);
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
61
bin/stty/stty.h
Normal file
61
bin/stty/stty.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/* $NetBSD: stty.h,v 1.10 2003/08/07 09:05:42 agc Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STTY_H_
|
||||||
|
#define _STTY_H_
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
|
struct info {
|
||||||
|
int fd; /* file descriptor */
|
||||||
|
int ldisc; /* line discipline */
|
||||||
|
int off; /* turn off */
|
||||||
|
int set; /* need set */
|
||||||
|
int wset; /* need window set */
|
||||||
|
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 { STTY_NOTSET, STTY_GFLAG, STTY_BSD, STTY_POSIX };
|
||||||
|
|
||||||
|
#define LINELENGTH 72
|
||||||
|
|
||||||
|
#endif /* !_STTY_H_ */
|
|
@ -24,7 +24,7 @@ SUBDIR= add_route arp ash at backup btrace \
|
||||||
remsync rget rlogin \
|
remsync rget rlogin \
|
||||||
rotate rsh rshd service setup shar \
|
rotate rsh rshd service setup shar \
|
||||||
sleep slip spell sprofalyze sprofdiff srccrc \
|
sleep slip spell sprofalyze sprofdiff srccrc \
|
||||||
stty svclog svrctl swifi synctree sysenv \
|
svclog svrctl swifi synctree sysenv \
|
||||||
syslogd tail tcpd tcpdp tcpstat telnet \
|
syslogd tail tcpd tcpdp tcpstat telnet \
|
||||||
telnetd term termcap tget time touch \
|
telnetd term termcap tget time touch \
|
||||||
truncate udpstat umount \
|
truncate udpstat umount \
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
PROG= stty
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
1270
commands/stty/stty.c
1270
commands/stty/stty.c
File diff suppressed because it is too large
Load diff
|
@ -50,6 +50,7 @@
|
||||||
./bin/setup minix-sys
|
./bin/setup minix-sys
|
||||||
./bin/sh minix-sys
|
./bin/sh minix-sys
|
||||||
./bin/shutdown minix-sys obsolete
|
./bin/shutdown minix-sys obsolete
|
||||||
|
./bin/stty minix-sys
|
||||||
./bin/sync minix-sys
|
./bin/sync minix-sys
|
||||||
./bin/sysenv minix-sys
|
./bin/sysenv minix-sys
|
||||||
./bin/tar minix-sys
|
./bin/tar minix-sys
|
||||||
|
@ -501,7 +502,7 @@
|
||||||
./usr/bin/stat minix-sys
|
./usr/bin/stat minix-sys
|
||||||
./usr/bin/strings minix-sys binutils
|
./usr/bin/strings minix-sys binutils
|
||||||
./usr/bin/strip minix-sys binutils
|
./usr/bin/strip minix-sys binutils
|
||||||
./usr/bin/stty minix-sys
|
./usr/bin/stty minix-sys obsolete
|
||||||
./usr/bin/su minix-sys
|
./usr/bin/su minix-sys
|
||||||
./usr/bin/sum minix-sys
|
./usr/bin/sum minix-sys
|
||||||
./usr/bin/svclog minix-sys
|
./usr/bin/svclog minix-sys
|
||||||
|
@ -1455,7 +1456,7 @@
|
||||||
./usr/include/sys/ioc_tape.h minix-sys
|
./usr/include/sys/ioc_tape.h minix-sys
|
||||||
./usr/include/sys/ioctl_compat.h minix-sys
|
./usr/include/sys/ioctl_compat.h minix-sys
|
||||||
./usr/include/sys/ioctl.h minix-sys
|
./usr/include/sys/ioctl.h minix-sys
|
||||||
./usr/include/sys/ioc_tty.h minix-sys
|
./usr/include/sys/ioc_tty.h minix-sys obsolete
|
||||||
./usr/include/sys/iostat.h minix-sys
|
./usr/include/sys/iostat.h minix-sys
|
||||||
./usr/include/sys/ipc.h minix-sys
|
./usr/include/sys/ipc.h minix-sys
|
||||||
./usr/include/sys/jmp_buf.h minix-sys
|
./usr/include/sys/jmp_buf.h minix-sys
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Console unsupport for ARM. Just stubs. */
|
/* Console unsupport for ARM. Just stubs. */
|
||||||
#include <minix/ipc.h>
|
#include <minix/ipc.h>
|
||||||
#include <termios.h>
|
#include <sys/termios.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Keyboard unsupport for ARM. Just stubs. */
|
/* Keyboard unsupport for ARM. Just stubs. */
|
||||||
#include <minix/ipc.h>
|
#include <minix/ipc.h>
|
||||||
#include <termios.h>
|
#include <sys/termios.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -144,7 +144,8 @@ static int rs_read(tty_t *tp, int try);
|
||||||
static int rs_icancel(tty_t *tp, int try);
|
static int rs_icancel(tty_t *tp, int try);
|
||||||
static int rs_ocancel(tty_t *tp, int try);
|
static int rs_ocancel(tty_t *tp, int try);
|
||||||
static void rs_ostart(rs232_t *rs);
|
static void rs_ostart(rs232_t *rs);
|
||||||
static int rs_break(tty_t *tp, int try);
|
static int rs_break_on(tty_t *tp, int try);
|
||||||
|
static int rs_break_off(tty_t *tp, int try);
|
||||||
static int rs_close(tty_t *tp, int try);
|
static int rs_close(tty_t *tp, int try);
|
||||||
static int rs_open(tty_t *tp, int try);
|
static int rs_open(tty_t *tp, int try);
|
||||||
static void rs232_handler(rs232_t *rs);
|
static void rs232_handler(rs232_t *rs);
|
||||||
|
@ -330,8 +331,11 @@ omap_get_divisor(rs232_t *rs, unsigned int baud)
|
||||||
switch(baud) {
|
switch(baud) {
|
||||||
case B460800: /* Fall through */
|
case B460800: /* Fall through */
|
||||||
case B921600: /* Fall through */
|
case B921600: /* Fall through */
|
||||||
|
#if 0
|
||||||
case B1843200: /* Fall through */
|
case B1843200: /* Fall through */
|
||||||
case B3686400: oversampling = 13; break;
|
case B3686400:
|
||||||
|
#endif
|
||||||
|
oversampling = 13; break;
|
||||||
default: oversampling = 16;
|
default: oversampling = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +573,8 @@ rs_init(tty_t *tp)
|
||||||
tp->tty_icancel = rs_icancel;
|
tp->tty_icancel = rs_icancel;
|
||||||
tp->tty_ocancel = rs_ocancel;
|
tp->tty_ocancel = rs_ocancel;
|
||||||
tp->tty_ioctl = rs_ioctl;
|
tp->tty_ioctl = rs_ioctl;
|
||||||
tp->tty_break = rs_break;
|
tp->tty_break_on = rs_break_on;
|
||||||
|
tp->tty_break_off = rs_break_off;
|
||||||
tp->tty_open = rs_open;
|
tp->tty_open = rs_open;
|
||||||
tp->tty_close = rs_close;
|
tp->tty_close = rs_close;
|
||||||
|
|
||||||
|
@ -669,17 +674,26 @@ rs_ostart(rs232_t *rs)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rs_break(tty_t *tp, int UNUSED(dummy))
|
rs_break_on(tty_t *tp, int UNUSED(dummy))
|
||||||
{
|
{
|
||||||
/* Generate a break condition by setting the BREAK bit for 0.4 sec. */
|
/* Raise break condition */
|
||||||
rs232_t *rs = tp->tty_priv;
|
rs232_t *rs = tp->tty_priv;
|
||||||
unsigned int lsr;
|
unsigned int lsr;
|
||||||
|
|
||||||
lsr = serial_in(rs, OMAP3_LSR);
|
lsr = serial_in(rs, OMAP3_LSR);
|
||||||
serial_out(rs, OMAP3_LSR, lsr | UART_LSR_BI);
|
serial_out(rs, OMAP3_LSR, lsr | UART_LSR_BI);
|
||||||
/* XXX */
|
return 0; /* dummy */
|
||||||
/* milli_delay(400); */ /* ouch */
|
}
|
||||||
serial_out(rs, OMAP3_LSR, lsr);
|
|
||||||
|
static int
|
||||||
|
rs_break_off(tty_t *tp, int UNUSED(dummy))
|
||||||
|
{
|
||||||
|
/* Clear break condition */
|
||||||
|
rs232_t *rs = tp->tty_priv;
|
||||||
|
unsigned int lsr;
|
||||||
|
|
||||||
|
lsr = serial_in(rs, OMAP3_LSR);
|
||||||
|
serial_out(rs, OMAP3_LSR, lsr & ~UART_LSR_BI);
|
||||||
return 0; /* dummy */
|
return 0; /* dummy */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,16 @@
|
||||||
|
|
||||||
#include <minix/drivers.h>
|
#include <minix/drivers.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/vm.h>
|
#include <sys/vm.h>
|
||||||
#include <sys/video.h>
|
#include <sys/video.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
|
#include <minix/callnr.h>
|
||||||
|
#include <minix/com.h>
|
||||||
|
#include <minix/sys_config.h>
|
||||||
|
#include <minix/vm.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
|
||||||
/* Set this to 1 if you want console output duplicated on the first
|
/* Set this to 1 if you want console output duplicated on the first
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <termios.h>
|
#include <sys/termios.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <machine/archtypes.h>
|
#include <machine/archtypes.h>
|
||||||
#include <minix/callnr.h>
|
#include <minix/callnr.h>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <minix/drivers.h>
|
#include <minix/drivers.h>
|
||||||
#include <termios.h>
|
#include <sys/termios.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
|
||||||
|
@ -29,6 +29,10 @@
|
||||||
#define IS_IDBITS 6
|
#define IS_IDBITS 6
|
||||||
|
|
||||||
/* Line control bits. */
|
/* Line control bits. */
|
||||||
|
#define LC_CS5 0x00 /* LSB0 and LSB1 encoding for CS5 */
|
||||||
|
#define LC_CS6 0x01 /* LSB0 and LSB1 encoding for CS6 */
|
||||||
|
#define LC_CS7 0x02 /* LSB0 and LSB1 encoding for CS7 */
|
||||||
|
#define LC_CS8 0x03 /* LSB0 and LSB1 encoding for CS8 */
|
||||||
#define LC_2STOP_BITS 0x04
|
#define LC_2STOP_BITS 0x04
|
||||||
#define LC_PARITY 0x08
|
#define LC_PARITY 0x08
|
||||||
#define LC_PAREVEN 0x10
|
#define LC_PAREVEN 0x10
|
||||||
|
@ -191,7 +195,8 @@ static int rs_read(tty_t *tp, int try);
|
||||||
static int rs_icancel(tty_t *tp, int try);
|
static int rs_icancel(tty_t *tp, int try);
|
||||||
static int rs_ocancel(tty_t *tp, int try);
|
static int rs_ocancel(tty_t *tp, int try);
|
||||||
static void rs_ostart(rs232_t *rs);
|
static void rs_ostart(rs232_t *rs);
|
||||||
static int rs_break(tty_t *tp, int try);
|
static int rs_break_on(tty_t *tp, int try);
|
||||||
|
static int rs_break_off(tty_t *tp, int try);
|
||||||
static int rs_close(tty_t *tp, int try);
|
static int rs_close(tty_t *tp, int try);
|
||||||
static void out_int(rs232_t *rs);
|
static void out_int(rs232_t *rs);
|
||||||
static void rs232_handler(rs232_t *rs);
|
static void rs232_handler(rs232_t *rs);
|
||||||
|
@ -384,8 +389,19 @@ static void rs_config(rs232_t *rs)
|
||||||
line_controls |= LC_PARITY;
|
line_controls |= LC_PARITY;
|
||||||
if (!(tp->tty_termios.c_cflag & PARODD)) line_controls |= LC_PAREVEN;
|
if (!(tp->tty_termios.c_cflag & PARODD)) line_controls |= LC_PAREVEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (divisor >= (UART_FREQ / 110)) line_controls |= LC_2STOP_BITS;
|
if (divisor >= (UART_FREQ / 110)) line_controls |= LC_2STOP_BITS;
|
||||||
line_controls |= (tp->tty_termios.c_cflag & CSIZE) >> 2;
|
|
||||||
|
/* which word size is configured? set the bits explicitly. */
|
||||||
|
if((tp->tty_termios.c_cflag & CSIZE) == CS5)
|
||||||
|
line_controls |= LC_CS5;
|
||||||
|
else if((tp->tty_termios.c_cflag & CSIZE) == CS6)
|
||||||
|
line_controls |= LC_CS6;
|
||||||
|
else if((tp->tty_termios.c_cflag & CSIZE) == CS7)
|
||||||
|
line_controls |= LC_CS7;
|
||||||
|
else if((tp->tty_termios.c_cflag & CSIZE) == CS8)
|
||||||
|
line_controls |= LC_CS8;
|
||||||
|
else printf("rs232: warning: no known word size set\n");
|
||||||
|
|
||||||
/* Select the baud rate divisor registers and change the rate. */
|
/* Select the baud rate divisor registers and change the rate. */
|
||||||
sys_outb(rs->line_ctl_port, LC_ADDRESS_DIVISOR);
|
sys_outb(rs->line_ctl_port, LC_ADDRESS_DIVISOR);
|
||||||
|
@ -500,7 +516,8 @@ void rs_init(tty_t *tp)
|
||||||
tp->tty_icancel = rs_icancel;
|
tp->tty_icancel = rs_icancel;
|
||||||
tp->tty_ocancel = rs_ocancel;
|
tp->tty_ocancel = rs_ocancel;
|
||||||
tp->tty_ioctl = rs_ioctl;
|
tp->tty_ioctl = rs_ioctl;
|
||||||
tp->tty_break = rs_break;
|
tp->tty_break_on = rs_break_on;
|
||||||
|
tp->tty_break_off = rs_break_off;
|
||||||
tp->tty_close = rs_close;
|
tp->tty_close = rs_close;
|
||||||
|
|
||||||
/* Tell external device we are ready. */
|
/* Tell external device we are ready. */
|
||||||
|
@ -610,11 +627,11 @@ static void rs_ostart(rs232_t *rs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* rs_break *
|
* rs_break_on *
|
||||||
*===========================================================================*/
|
*===========================================================================*/
|
||||||
static int rs_break(tty_t *tp, int UNUSED(dummy))
|
static int rs_break_on(tty_t *tp, int UNUSED(dummy))
|
||||||
{
|
{
|
||||||
/* Generate a break condition by setting the BREAK bit for 0.4 sec. */
|
/* Raise break condition. */
|
||||||
rs232_t *rs = tp->tty_priv;
|
rs232_t *rs = tp->tty_priv;
|
||||||
u32_t line_controls;
|
u32_t line_controls;
|
||||||
int s;
|
int s;
|
||||||
|
@ -622,10 +639,22 @@ static int rs_break(tty_t *tp, int UNUSED(dummy))
|
||||||
if ((s = sys_inb(rs->line_ctl_port, &line_controls)) != OK)
|
if ((s = sys_inb(rs->line_ctl_port, &line_controls)) != OK)
|
||||||
printf("TTY: sys_inb() failed: %d", s);
|
printf("TTY: sys_inb() failed: %d", s);
|
||||||
sys_outb(rs->line_ctl_port, line_controls | LC_BREAK);
|
sys_outb(rs->line_ctl_port, line_controls | LC_BREAK);
|
||||||
/* XXX */
|
return 0; /* dummy */
|
||||||
/* milli_delay(400); */ /* ouch */
|
}
|
||||||
printf("RS232 break\n");
|
|
||||||
sys_outb(rs->line_ctl_port, line_controls);
|
/*===========================================================================*
|
||||||
|
* rs_break_off *
|
||||||
|
*===========================================================================*/
|
||||||
|
static int rs_break_off(tty_t *tp, int UNUSED(dummy))
|
||||||
|
{
|
||||||
|
/* Clear break condition. */
|
||||||
|
rs232_t *rs = tp->tty_priv;
|
||||||
|
u32_t line_controls;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
if ((s = sys_inb(rs->line_ctl_port, &line_controls)) != OK)
|
||||||
|
printf("TTY: sys_inb() failed: %d", s);
|
||||||
|
sys_outb(rs->line_ctl_port, line_controls & ~LC_BREAK);
|
||||||
return 0; /* dummy */
|
return 0; /* dummy */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('/') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('/') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
||||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
||||||
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', '/', A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', '/', A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
||||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
||||||
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, C('S') },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, C('S') },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
K(KP_STAR) = { '*', '*', A('*'), '*', '*', C('M') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),C('M'), CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, '1', CEND },
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', '/', A('/'), '/', C('@') },
|
K(KP_SLASH) = { '/', '/', '/', A('/'), '/', C('@') },
|
||||||
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
K(KP_STAR) = { '*', '*', '*', A('*'), '*', C('@') },
|
||||||
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CMIN },
|
K(KP_DASH) = { '-', '-', '-', AMIN, '-', CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
K(KP_PLUS) = { '+', '+', '+', APLUS, '+', CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), C('M'), CA('M'),C('M'), C('J') },
|
||||||
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
K(KP_1) = { NEND, '1', END, AEND, '1', CEND },
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
K(NUM_LOCK) = { NLOCK, NLOCK, NLOCK, NLOCK, NLOCK, NLOCK },
|
||||||
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
K(KP_SLASH) = { '/', '/', A('/'), A('/'), A('/'), C('@') },
|
||||||
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
K(KP_STAR) = { '*', '*', A('*'), A('*'), A('*'), C('@') },
|
||||||
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CMIN },
|
K(KP_DASH) = { '-', '-', AMIN, AMIN, A('-'), CNMIN },
|
||||||
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
K(KP_PLUS) = { '+', '+', APLUS, APLUS, A('+'), CPLUS },
|
||||||
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
K(KP_ENTER) = { C('M'), C('M'), CA('M'),CA('M'),CA('M'),C('J') },
|
||||||
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
K(KP_1) = { NEND, '1', AEND, AEND, A('1'), CEND },
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
#include <minix/drivers.h>
|
#include <minix/drivers.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <sys/termios.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,10 @@
|
||||||
#include <minix/drivers.h>
|
#include <minix/drivers.h>
|
||||||
#include <minix/driver.h>
|
#include <minix/driver.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/ioc_tty.h>
|
|
||||||
#include <sys/kbdio.h>
|
#include <sys/kbdio.h>
|
||||||
|
#include <sys/ttycom.h>
|
||||||
|
#include <sys/ttydefaults.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <minix/keymap.h>
|
#include <minix/keymap.h>
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
@ -103,12 +105,29 @@ static struct chardriver tty_tab = {
|
||||||
|
|
||||||
/* Default attributes. */
|
/* Default attributes. */
|
||||||
static struct termios termios_defaults = {
|
static struct termios termios_defaults = {
|
||||||
TINPUT_DEF, TOUTPUT_DEF, TCTRL_DEF, TLOCAL_DEF,
|
.c_iflag = TTYDEF_IFLAG,
|
||||||
{
|
.c_oflag = TTYDEF_OFLAG,
|
||||||
TEOF_DEF, TEOL_DEF, TERASE_DEF, TINTR_DEF, TKILL_DEF, TMIN_DEF,
|
.c_cflag = TTYDEF_CFLAG,
|
||||||
TQUIT_DEF, TTIME_DEF, TSUSP_DEF, TSTART_DEF, TSTOP_DEF,
|
.c_lflag = TTYDEF_LFLAG,
|
||||||
TREPRINT_DEF, TLNEXT_DEF, TDISCARD_DEF,
|
.c_ispeed = TTYDEF_SPEED,
|
||||||
}, TSPEED_DEF, TSPEED_DEF,
|
.c_ospeed = TTYDEF_SPEED,
|
||||||
|
.c_cc = {
|
||||||
|
[VEOF] = CEOF,
|
||||||
|
[VEOL] = CEOL,
|
||||||
|
[VERASE] = CERASE,
|
||||||
|
[VINTR] = CINTR,
|
||||||
|
[VKILL] = CKILL,
|
||||||
|
[VMIN] = CMIN,
|
||||||
|
[VQUIT] = CQUIT,
|
||||||
|
[VTIME] = CTIME,
|
||||||
|
[VSUSP] = CSUSP,
|
||||||
|
[VSTART] = CSTART,
|
||||||
|
[VSTOP] = CSTOP,
|
||||||
|
[VREPRINT] = CREPRINT,
|
||||||
|
[VLNEXT] = CLNEXT,
|
||||||
|
[VDISCARD] = CDISCARD,
|
||||||
|
[VSTATUS] = CSTATUS
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static struct winsize winsize_defaults; /* = all zeroes */
|
static struct winsize winsize_defaults; /* = all zeroes */
|
||||||
|
|
||||||
|
@ -600,15 +619,15 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||||
|
|
||||||
r = OK;
|
r = OK;
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case TCGETS:
|
case TIOCGETA:
|
||||||
/* Get the termios attributes. */
|
/* Get the termios attributes. */
|
||||||
r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &tp->tty_termios,
|
r = sys_safecopyto(endpt, grant, 0, (vir_bytes) &tp->tty_termios,
|
||||||
sizeof(struct termios));
|
sizeof(struct termios));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TCSETSW:
|
case TIOCSETAW:
|
||||||
case TCSETSF:
|
case TIOCSETAF:
|
||||||
case TCDRAIN:
|
case TIOCDRAIN:
|
||||||
if (tp->tty_outleft > 0) {
|
if (tp->tty_outleft > 0) {
|
||||||
if (flags & CDEV_NONBLOCK)
|
if (flags & CDEV_NONBLOCK)
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
|
@ -619,10 +638,10 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||||
tp->tty_iogrant = grant;
|
tp->tty_iogrant = grant;
|
||||||
return EDONTREPLY; /* suspend the caller */
|
return EDONTREPLY; /* suspend the caller */
|
||||||
}
|
}
|
||||||
if (request == TCDRAIN) break;
|
if (request == TIOCDRAIN) break;
|
||||||
if (request == TCSETSF) tty_icancel(tp);
|
if (request == TIOCSETAF) tty_icancel(tp);
|
||||||
/*FALL THROUGH*/
|
/*FALL THROUGH*/
|
||||||
case TCSETS:
|
case TIOCSETA:
|
||||||
/* Set the termios attributes. */
|
/* Set the termios attributes. */
|
||||||
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &tp->tty_termios,
|
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &tp->tty_termios,
|
||||||
sizeof(struct termios));
|
sizeof(struct termios));
|
||||||
|
@ -630,39 +649,25 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||||
setattr(tp);
|
setattr(tp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TCFLSH:
|
case TIOCFLUSH:
|
||||||
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &i, sizeof(i));
|
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &i, sizeof(i));
|
||||||
if (r != OK) break;
|
if (r != OK) break;
|
||||||
switch (i) {
|
if(i & FREAD) { tty_icancel(tp); }
|
||||||
case TCIFLUSH: tty_icancel(tp); break;
|
if(i & FWRITE) { (*tp->tty_ocancel)(tp, 0); }
|
||||||
case TCOFLUSH: (*tp->tty_ocancel)(tp, 0); break;
|
|
||||||
case TCIOFLUSH: tty_icancel(tp); (*tp->tty_ocancel)(tp, 0); break;
|
|
||||||
default: r = EINVAL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
case TIOCSTART:
|
||||||
case TCFLOW:
|
tp->tty_inhibited = 0;
|
||||||
r = sys_safecopyfrom(endpt, grant, 0, (vir_bytes) &i, sizeof(i));
|
|
||||||
if (r != OK) break;
|
|
||||||
switch (i) {
|
|
||||||
case TCOOFF:
|
|
||||||
case TCOON:
|
|
||||||
tp->tty_inhibited = (i == TCOOFF);
|
|
||||||
tp->tty_events = 1;
|
tp->tty_events = 1;
|
||||||
break;
|
break;
|
||||||
case TCIOFF:
|
case TIOCSTOP:
|
||||||
(*tp->tty_echo)(tp, tp->tty_termios.c_cc[VSTOP]);
|
tp->tty_inhibited = 1;
|
||||||
|
tp->tty_events = 1;
|
||||||
break;
|
break;
|
||||||
case TCION:
|
case TIOCSBRK: /* tcsendbreak - turn break on */
|
||||||
(*tp->tty_echo)(tp, tp->tty_termios.c_cc[VSTART]);
|
if (tp->tty_break_on != NULL) (*tp->tty_break_on)(tp,0);
|
||||||
break;
|
break;
|
||||||
default:
|
case TIOCCBRK: /* tcsendbreak - turn break off */
|
||||||
r = EINVAL;
|
if (tp->tty_break_off != NULL) (*tp->tty_break_off)(tp,0);
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TCSBRK:
|
|
||||||
if (tp->tty_break != NULL) (*tp->tty_break)(tp,0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIOCGWINSZ:
|
case TIOCGWINSZ:
|
||||||
|
@ -675,7 +680,6 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||||
sizeof(struct winsize));
|
sizeof(struct winsize));
|
||||||
sigchar(tp, SIGWINCH, 0);
|
sigchar(tp, SIGWINCH, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KIOCBELL:
|
case KIOCBELL:
|
||||||
/* Sound bell (only /dev/console). */
|
/* Sound bell (only /dev/console). */
|
||||||
if (!isconsole(tp))
|
if (!isconsole(tp))
|
||||||
|
@ -689,7 +693,17 @@ static int do_ioctl(devminor_t minor, unsigned long request, endpoint_t endpt,
|
||||||
ticks++;
|
ticks++;
|
||||||
beep_x(bell.kb_pitch, ticks);
|
beep_x(bell.kb_pitch, ticks);
|
||||||
break;
|
break;
|
||||||
|
case TIOCGETD: /* get line discipline */
|
||||||
|
{
|
||||||
|
int disc = TTYDISC;
|
||||||
|
r = sys_safecopyto(endpt, grant, 0,
|
||||||
|
(vir_bytes) &disc, (vir_bytes) sizeof(disc));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TIOCSETD: /* set line discipline */
|
||||||
|
printf("TTY: TIOCSETD: can't set any other line discipline.\n");
|
||||||
|
r = ENOTTY;
|
||||||
|
break;
|
||||||
case KIOCSMAP:
|
case KIOCSMAP:
|
||||||
/* Load a new keymap (only /dev/console). */
|
/* Load a new keymap (only /dev/console). */
|
||||||
if (isconsole(tp)) r = kbd_loadmap(endpt, grant);
|
if (isconsole(tp)) r = kbd_loadmap(endpt, grant);
|
||||||
|
@ -1125,11 +1139,16 @@ int count; /* number of input characters */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tp->tty_termios.c_lflag & ISIG) {
|
if (tp->tty_termios.c_lflag & ISIG) {
|
||||||
/* Check for INTR (^?) and QUIT (^\) characters. */
|
/* Check for INTR, QUIT and STATUS characters. */
|
||||||
if (ch == tp->tty_termios.c_cc[VINTR]
|
int sig = -1;
|
||||||
|| ch == tp->tty_termios.c_cc[VQUIT]) {
|
if (ch == tp->tty_termios.c_cc[VINTR])
|
||||||
sig = SIGINT;
|
sig = SIGINT;
|
||||||
if (ch == tp->tty_termios.c_cc[VQUIT]) sig = SIGQUIT;
|
else if(ch == tp->tty_termios.c_cc[VQUIT])
|
||||||
|
sig = SIGQUIT;
|
||||||
|
else if(ch == tp->tty_termios.c_cc[VSTATUS])
|
||||||
|
sig = SIGINFO;
|
||||||
|
|
||||||
|
if(sig >= 0) {
|
||||||
sigchar(tp, sig, 1);
|
sigchar(tp, sig, 1);
|
||||||
(void) tty_echo(tp, ch);
|
(void) tty_echo(tp, ch);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1366,8 +1385,8 @@ int *ocount; /* max output chars / output chars used */
|
||||||
/* Best guess for the tab length. */
|
/* Best guess for the tab length. */
|
||||||
tablen = TAB_SIZE - (pos & TAB_MASK);
|
tablen = TAB_SIZE - (pos & TAB_MASK);
|
||||||
|
|
||||||
if ((tp->tty_termios.c_oflag & (OPOST|XTABS))
|
if ((tp->tty_termios.c_oflag & (OPOST|OXTABS))
|
||||||
== (OPOST|XTABS)) {
|
== (OPOST|OXTABS)) {
|
||||||
/* Tabs must be expanded. */
|
/* Tabs must be expanded. */
|
||||||
if (oct >= tablen) {
|
if (oct >= tablen) {
|
||||||
pos += tablen;
|
pos += tablen;
|
||||||
|
@ -1404,7 +1423,7 @@ out_done:
|
||||||
static void dev_ioctl(tp)
|
static void dev_ioctl(tp)
|
||||||
tty_t *tp;
|
tty_t *tp;
|
||||||
{
|
{
|
||||||
/* The ioctl's TCSETSW, TCSETSF and TCDRAIN wait for output to finish to make
|
/* The ioctl's TCSETSW, TCSETSF and TIOCDRAIN wait for output to finish to make
|
||||||
* sure that an attribute change doesn't affect the processing of current
|
* sure that an attribute change doesn't affect the processing of current
|
||||||
* output. Once output finishes the ioctl is executed as in do_ioctl().
|
* output. Once output finishes the ioctl is executed as in do_ioctl().
|
||||||
*/
|
*/
|
||||||
|
@ -1412,8 +1431,8 @@ tty_t *tp;
|
||||||
|
|
||||||
if (tp->tty_outleft > 0) return; /* output not finished */
|
if (tp->tty_outleft > 0) return; /* output not finished */
|
||||||
|
|
||||||
if (tp->tty_ioreq != TCDRAIN) {
|
if (tp->tty_ioreq != TIOCDRAIN) {
|
||||||
if (tp->tty_ioreq == TCSETSF) tty_icancel(tp);
|
if (tp->tty_ioreq == TIOCSETAF) tty_icancel(tp);
|
||||||
result = sys_safecopyfrom(tp->tty_iocaller, tp->tty_iogrant, 0,
|
result = sys_safecopyfrom(tp->tty_iocaller, tp->tty_iogrant, 0,
|
||||||
(vir_bytes) &tp->tty_termios,
|
(vir_bytes) &tp->tty_termios,
|
||||||
(vir_bytes) sizeof(tp->tty_termios));
|
(vir_bytes) sizeof(tp->tty_termios));
|
||||||
|
|
|
@ -43,7 +43,8 @@ typedef struct tty {
|
||||||
devfun_t tty_devwrite; /* routine to start actual device output */
|
devfun_t tty_devwrite; /* routine to start actual device output */
|
||||||
devfunarg_t tty_echo; /* routine to echo characters input */
|
devfunarg_t tty_echo; /* routine to echo characters input */
|
||||||
devfun_t tty_ocancel; /* cancel any ongoing device output */
|
devfun_t tty_ocancel; /* cancel any ongoing device output */
|
||||||
devfun_t tty_break; /* let the device send a break */
|
devfun_t tty_break_on; /* let the device assert a break */
|
||||||
|
devfun_t tty_break_off; /* let the device de-assert a break */
|
||||||
|
|
||||||
/* Terminal parameters and status. */
|
/* Terminal parameters and status. */
|
||||||
int tty_position; /* current position on the screen for echoing */
|
int tty_position; /* current position on the screen for echoing */
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(__minix)
|
#if defined(__minix)
|
||||||
#include <minix/termios.h>
|
#include <sys/termios.h>
|
||||||
#endif /* defined(__minix) */
|
#endif /* defined(__minix) */
|
||||||
|
|
||||||
#include "utils/optional.hpp"
|
#include "utils/optional.hpp"
|
||||||
|
|
|
@ -18,7 +18,7 @@ INCS+= acpi.h audio_fw.h bitmap.h \
|
||||||
priv.h procfs.h profile.h queryparam.h \
|
priv.h procfs.h profile.h queryparam.h \
|
||||||
rs.h safecopies.h sched.h sef.h sffs.h \
|
rs.h safecopies.h sched.h sef.h sffs.h \
|
||||||
sound.h spin.h sys_config.h sysinfo.h \
|
sound.h spin.h sys_config.h sysinfo.h \
|
||||||
syslib.h sysutil.h termios.h timers.h type.h \
|
syslib.h sysutil.h timers.h type.h \
|
||||||
u64.h usb.h usb_ch9.h vbox.h \
|
u64.h usb.h usb_ch9.h vbox.h \
|
||||||
vboxfs.h vboxif.h vboxtype.h vm.h \
|
vboxfs.h vboxif.h vboxtype.h vm.h \
|
||||||
vfsif.h vtreefs.h libminixfs.h netsock.h \
|
vfsif.h vtreefs.h libminixfs.h netsock.h \
|
||||||
|
|
|
@ -12,15 +12,15 @@
|
||||||
#define L(c) ((c) | HASCAPS) /* Add "Caps Lock has effect" attribute */
|
#define L(c) ((c) | HASCAPS) /* Add "Caps Lock has effect" attribute */
|
||||||
|
|
||||||
#define EXT 0x0100 /* Normal function keys */
|
#define EXT 0x0100 /* Normal function keys */
|
||||||
#define CTRL 0x0200 /* Control key */
|
#define CTRLKEY 0x0200 /* Control key */
|
||||||
#define SHIFT 0x0400 /* Shift key */
|
#define SHIFT 0x0400 /* Shift key */
|
||||||
#define ALT 0x0800 /* Alternate key */
|
#define ALT 0x0800 /* Alternate key */
|
||||||
#define HASNUM 0x4000 /* Num Lock has effect */
|
#define HASNUM 0x4000 /* Num Lock has effect */
|
||||||
#define HASCAPS 0x8000 /* Caps Lock has effect */
|
#define HASCAPS 0x8000 /* Caps Lock has effect */
|
||||||
|
|
||||||
/* The left and right versions for the actual keys in the keymap. */
|
/* The left and right versions for the actual keys in the keymap. */
|
||||||
#define LCTRL CTRL
|
#define LCTRL CTRLKEY
|
||||||
#define RCTRL (CTRL | EXT)
|
#define RCTRL (CTRLKEY | EXT)
|
||||||
#define LSHIFT SHIFT
|
#define LSHIFT SHIFT
|
||||||
#define RSHIFT (SHIFT | EXT)
|
#define RSHIFT (SHIFT | EXT)
|
||||||
#define LALT ALT
|
#define LALT ALT
|
||||||
|
@ -71,18 +71,18 @@
|
||||||
#define AINSRT (0x0C + ALT)
|
#define AINSRT (0x0C + ALT)
|
||||||
|
|
||||||
/* Ctrl + Numeric keypad */
|
/* Ctrl + Numeric keypad */
|
||||||
#define CHOME (0x01 + CTRL)
|
#define CHOME (0x01 + CTRLKEY)
|
||||||
#define CEND (0x02 + CTRL)
|
#define CEND (0x02 + CTRLKEY)
|
||||||
#define CUP (0x03 + CTRL)
|
#define CUP (0x03 + CTRLKEY)
|
||||||
#define CDOWN (0x04 + CTRL)
|
#define CDOWN (0x04 + CTRLKEY)
|
||||||
#define CLEFT (0x05 + CTRL)
|
#define CLEFT (0x05 + CTRLKEY)
|
||||||
#define CRIGHT (0x06 + CTRL)
|
#define CRIGHT (0x06 + CTRLKEY)
|
||||||
#define CPGUP (0x07 + CTRL)
|
#define CPGUP (0x07 + CTRLKEY)
|
||||||
#define CPGDN (0x08 + CTRL)
|
#define CPGDN (0x08 + CTRLKEY)
|
||||||
#define CMID (0x09 + CTRL)
|
#define CMID (0x09 + CTRLKEY)
|
||||||
#define CMIN (0x0A + CTRL)
|
#define CNMIN (0x0A + CTRLKEY)
|
||||||
#define CPLUS (0x0B + CTRL)
|
#define CPLUS (0x0B + CTRLKEY)
|
||||||
#define CINSRT (0x0C + CTRL)
|
#define CINSRT (0x0C + CTRLKEY)
|
||||||
|
|
||||||
/* Lock keys */
|
/* Lock keys */
|
||||||
#define CALOCK (0x0D + EXT) /* caps lock */
|
#define CALOCK (0x0D + EXT) /* caps lock */
|
||||||
|
@ -118,18 +118,18 @@
|
||||||
#define AF12 (0x1B + ALT)
|
#define AF12 (0x1B + ALT)
|
||||||
|
|
||||||
/* Ctrl+Fn */
|
/* Ctrl+Fn */
|
||||||
#define CF1 (0x10 + CTRL)
|
#define CF1 (0x10 + CTRLKEY)
|
||||||
#define CF2 (0x11 + CTRL)
|
#define CF2 (0x11 + CTRLKEY)
|
||||||
#define CF3 (0x12 + CTRL)
|
#define CF3 (0x12 + CTRLKEY)
|
||||||
#define CF4 (0x13 + CTRL)
|
#define CF4 (0x13 + CTRLKEY)
|
||||||
#define CF5 (0x14 + CTRL)
|
#define CF5 (0x14 + CTRLKEY)
|
||||||
#define CF6 (0x15 + CTRL)
|
#define CF6 (0x15 + CTRLKEY)
|
||||||
#define CF7 (0x16 + CTRL)
|
#define CF7 (0x16 + CTRLKEY)
|
||||||
#define CF8 (0x17 + CTRL)
|
#define CF8 (0x17 + CTRLKEY)
|
||||||
#define CF9 (0x18 + CTRL)
|
#define CF9 (0x18 + CTRLKEY)
|
||||||
#define CF10 (0x19 + CTRL)
|
#define CF10 (0x19 + CTRLKEY)
|
||||||
#define CF11 (0x1A + CTRL)
|
#define CF11 (0x1A + CTRLKEY)
|
||||||
#define CF12 (0x1B + CTRL)
|
#define CF12 (0x1B + CTRLKEY)
|
||||||
|
|
||||||
/* Shift+Fn */
|
/* Shift+Fn */
|
||||||
#define SF1 (0x10 + SHIFT)
|
#define SF1 (0x10 + SHIFT)
|
||||||
|
|
|
@ -1,210 +0,0 @@
|
||||||
/* The <termios.h> header is used for controlling tty modes. */
|
|
||||||
|
|
||||||
#ifndef _TERMIOS_H
|
|
||||||
#define _TERMIOS_H
|
|
||||||
|
|
||||||
typedef unsigned int tcflag_t;
|
|
||||||
typedef unsigned char cc_t;
|
|
||||||
typedef unsigned int speed_t;
|
|
||||||
|
|
||||||
#define NCCS 20 /* size of cc_c array, some extra space
|
|
||||||
* for extensions. */
|
|
||||||
|
|
||||||
/* Primary terminal control structure. POSIX Table 7-1. */
|
|
||||||
struct termios {
|
|
||||||
tcflag_t c_iflag; /* input modes */
|
|
||||||
tcflag_t c_oflag; /* output modes */
|
|
||||||
tcflag_t c_cflag; /* control modes */
|
|
||||||
tcflag_t c_lflag; /* local modes */
|
|
||||||
cc_t c_cc[NCCS]; /* control characters */
|
|
||||||
speed_t c_ispeed; /* input speed */
|
|
||||||
speed_t c_ospeed; /* output speed */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Values for termios c_iflag bit map. POSIX Table 7-2. */
|
|
||||||
#define BRKINT 0x0001 /* signal interrupt on break */
|
|
||||||
#define ICRNL 0x0002 /* map CR to NL on input */
|
|
||||||
#define IGNBRK 0x0004 /* ignore break */
|
|
||||||
#define IGNCR 0x0008 /* ignore CR */
|
|
||||||
#define IGNPAR 0x0010 /* ignore characters with parity errors */
|
|
||||||
#define INLCR 0x0020 /* map NL to CR on input */
|
|
||||||
#define INPCK 0x0040 /* enable input parity check */
|
|
||||||
#define ISTRIP 0x0080 /* mask off 8th bit */
|
|
||||||
#define IXOFF 0x0100 /* enable start/stop input control */
|
|
||||||
#define IXON 0x0200 /* enable start/stop output control */
|
|
||||||
#define PARMRK 0x0400 /* mark parity errors in the input queue */
|
|
||||||
|
|
||||||
/* Values for termios c_oflag bit map. POSIX Sec. 7.1.2.3. */
|
|
||||||
#define OPOST 0x0001 /* perform output processing */
|
|
||||||
|
|
||||||
/* Values for termios c_cflag bit map. POSIX Table 7-3. */
|
|
||||||
#define CLOCAL 0x0001 /* ignore modem status lines */
|
|
||||||
#define CREAD 0x0002 /* enable receiver */
|
|
||||||
#define CSIZE 0x000C /* number of bits per character */
|
|
||||||
#define CS5 0x0000 /* if CSIZE is CS5, characters are 5 bits */
|
|
||||||
#define CS6 0x0004 /* if CSIZE is CS6, characters are 6 bits */
|
|
||||||
#define CS7 0x0008 /* if CSIZE is CS7, characters are 7 bits */
|
|
||||||
#define CS8 0x000C /* if CSIZE is CS8, characters are 8 bits */
|
|
||||||
#define CSTOPB 0x0010 /* send 2 stop bits if set, else 1 */
|
|
||||||
#define HUPCL 0x0020 /* hang up on last close */
|
|
||||||
#define PARENB 0x0040 /* enable parity on output */
|
|
||||||
#define PARODD 0x0080 /* use odd parity if set, else even */
|
|
||||||
|
|
||||||
/* Values for termios c_lflag bit map. POSIX Table 7-4. */
|
|
||||||
#define ECHO 0x0001 /* enable echoing of input characters */
|
|
||||||
#define ECHOE 0x0002 /* echo ERASE as backspace */
|
|
||||||
#define ECHOK 0x0004 /* echo KILL */
|
|
||||||
#define ECHONL 0x0008 /* echo NL */
|
|
||||||
#define ICANON 0x0010 /* canonical input (erase and kill enabled) */
|
|
||||||
#define IEXTEN 0x0020 /* enable extended functions */
|
|
||||||
#define ISIG 0x0040 /* enable signals */
|
|
||||||
#define NOFLSH 0x0080 /* disable flush after interrupt or quit */
|
|
||||||
#define TOSTOP 0x0100 /* send SIGTTOU (job control, not implemented*/
|
|
||||||
|
|
||||||
/* Indices into c_cc array. Default values in parentheses. POSIX Table 7-5. */
|
|
||||||
#define VEOF 0 /* cc_c[VEOF] = EOF char (^D) */
|
|
||||||
#define VEOL 1 /* cc_c[VEOL] = EOL char (undef) */
|
|
||||||
#define VERASE 2 /* cc_c[VERASE] = ERASE char (^H) */
|
|
||||||
#define VINTR 3 /* cc_c[VINTR] = INTR char (DEL) */
|
|
||||||
#define VKILL 4 /* cc_c[VKILL] = KILL char (^U) */
|
|
||||||
#define VMIN 5 /* cc_c[VMIN] = MIN value for timer */
|
|
||||||
#define VQUIT 6 /* cc_c[VQUIT] = QUIT char (^\) */
|
|
||||||
#define VTIME 7 /* cc_c[VTIME] = TIME value for timer */
|
|
||||||
#define VSUSP 8 /* cc_c[VSUSP] = SUSP (^Z, ignored) */
|
|
||||||
#define VSTART 9 /* cc_c[VSTART] = START char (^S) */
|
|
||||||
#define VSTOP 10 /* cc_c[VSTOP] = STOP char (^Q) */
|
|
||||||
|
|
||||||
/* Values for the baud rate settings. POSIX Table 7-6. */
|
|
||||||
#define B0 0x0000 /* hang up the line */
|
|
||||||
#define B50 0x1000 /* 50 baud */
|
|
||||||
#define B75 0x2000 /* 75 baud */
|
|
||||||
#define B110 0x3000 /* 110 baud */
|
|
||||||
#define B134 0x4000 /* 134.5 baud */
|
|
||||||
#define B150 0x5000 /* 150 baud */
|
|
||||||
#define B200 0x6000 /* 200 baud */
|
|
||||||
#define B300 0x7000 /* 300 baud */
|
|
||||||
#define B600 0x8000 /* 600 baud */
|
|
||||||
#define B1200 0x9000 /* 1200 baud */
|
|
||||||
#define B1800 0xA000 /* 1800 baud */
|
|
||||||
#define B2400 0xB000 /* 2400 baud */
|
|
||||||
#define B4800 0xC000 /* 4800 baud */
|
|
||||||
#define B9600 0xD000 /* 9600 baud */
|
|
||||||
#define B19200 0xE000 /* 19200 baud */
|
|
||||||
#define B38400 0xF000 /* 38400 baud */
|
|
||||||
|
|
||||||
/* Optional actions for tcsetattr(). POSIX Sec. 7.2.1.2. */
|
|
||||||
#define TCSANOW 1 /* changes take effect immediately */
|
|
||||||
#define TCSADRAIN 2 /* changes take effect after output is done */
|
|
||||||
#define TCSAFLUSH 3 /* wait for output to finish and flush input */
|
|
||||||
|
|
||||||
/* Queue_selector values for tcflush(). POSIX Sec. 7.2.2.2. */
|
|
||||||
#define TCIFLUSH 1 /* flush accumulated input data */
|
|
||||||
#define TCOFLUSH 2 /* flush accumulated output data */
|
|
||||||
#define TCIOFLUSH 3 /* flush accumulated input and output data */
|
|
||||||
|
|
||||||
/* Action values for tcflow(). POSIX Sec. 7.2.2.2. */
|
|
||||||
#define TCOOFF 1 /* suspend output */
|
|
||||||
#define TCOON 2 /* restart suspended output */
|
|
||||||
#define TCIOFF 3 /* transmit a STOP character on the line */
|
|
||||||
#define TCION 4 /* transmit a START character on the line */
|
|
||||||
|
|
||||||
int tcsendbreak(int _fildes, int _duration);
|
|
||||||
int tcdrain(int _filedes);
|
|
||||||
int tcflush(int _filedes, int _queue_selector);
|
|
||||||
int tcflow(int _filedes, int _action);
|
|
||||||
speed_t cfgetispeed(const struct termios *_termios_p);
|
|
||||||
speed_t cfgetospeed(const struct termios *_termios_p);
|
|
||||||
int cfsetispeed(struct termios *_termios_p, speed_t _speed);
|
|
||||||
int cfsetospeed(struct termios *_termios_p, speed_t _speed);
|
|
||||||
int tcgetattr(int _filedes, struct termios *_termios_p);
|
|
||||||
int tcsetattr(int _filedes, int _opt_actions, const struct termios
|
|
||||||
*_termios_p);
|
|
||||||
|
|
||||||
#ifndef cfgetispeed
|
|
||||||
#define cfgetispeed(termios_p) ((termios_p)->c_ispeed)
|
|
||||||
#endif
|
|
||||||
#ifndef cfgetospeed
|
|
||||||
#define cfgetospeed(termios_p) ((termios_p)->c_ospeed)
|
|
||||||
#endif
|
|
||||||
#ifndef cfsetispeed
|
|
||||||
#define cfsetispeed(termios_p, speed) ((termios_p)->c_ispeed = (speed), 0)
|
|
||||||
#endif
|
|
||||||
#ifndef cfsetospeed
|
|
||||||
#define cfsetospeed(termios_p, speed) ((termios_p)->c_ospeed = (speed), 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Here are the local extensions to the POSIX standard for Minix. */
|
|
||||||
|
|
||||||
/* Extensions to the termios c_iflag bit map. */
|
|
||||||
#define IXANY 0x0800 /* allow any key to continue ouptut */
|
|
||||||
|
|
||||||
/* Extensions to the termios c_oflag bit map. They are only active iff
|
|
||||||
* OPOST is enabled. */
|
|
||||||
#define ONLCR 0x0002 /* Map NL to CR-NL on output */
|
|
||||||
#define XTABS 0x0004 /* Expand tabs to spaces */
|
|
||||||
#define ONOEOT 0x0008 /* discard EOT's (^D) on output) */
|
|
||||||
|
|
||||||
/* Extensions to the termios c_lflag bit map. */
|
|
||||||
#define LFLUSHO 0x0200 /* Flush output. */
|
|
||||||
|
|
||||||
/* Extensions to the c_cc array. */
|
|
||||||
#define VREPRINT 11 /* cc_c[VREPRINT] (^R) */
|
|
||||||
#define VLNEXT 12 /* cc_c[VLNEXT] (^V) */
|
|
||||||
#define VDISCARD 13 /* cc_c[VDISCARD] (^O) */
|
|
||||||
|
|
||||||
/* Non-functional additions */
|
|
||||||
#define VDSUSP 14
|
|
||||||
#define VWERASE 15
|
|
||||||
#define VSTATUS 16
|
|
||||||
#define VEOL2 17
|
|
||||||
|
|
||||||
/* Extensions to baud rate settings. */
|
|
||||||
#if defined(__minix) && defined(_NETBSD_SOURCE)
|
|
||||||
#define B57600 0x0100 /* 57600 baud */
|
|
||||||
#define B115200 0x0200 /* 115200 baud */
|
|
||||||
#define B230400 0x0400 /* 230400 baud */
|
|
||||||
#define B460800 0x0800 /* 460800 baud */
|
|
||||||
#define B921600 0x1000 /* 921600 baud */
|
|
||||||
#define B1843200 0x2000 /* 1843200 baud */
|
|
||||||
#define B3000000 0x4000 /* 3000000 baud */
|
|
||||||
#define B3686400 0x8000 /* 3686400 baud */
|
|
||||||
#endif /* defined(__minix) && defined(_NETBSD_SOURCE) */
|
|
||||||
|
|
||||||
/* These are the default settings used by the kernel and by 'stty sane' */
|
|
||||||
|
|
||||||
#define TCTRL_DEF (CREAD | CS8 | HUPCL)
|
|
||||||
#define TINPUT_DEF (BRKINT | ICRNL | IXON | IXANY)
|
|
||||||
#define TOUTPUT_DEF (OPOST | ONLCR)
|
|
||||||
#define TLOCAL_DEF (ISIG | IEXTEN | ICANON | ECHO | ECHOE)
|
|
||||||
#define TSPEED_DEF B9600
|
|
||||||
|
|
||||||
#define TEOF_DEF '\4' /* ^D */
|
|
||||||
#define TEOL_DEF _POSIX_VDISABLE
|
|
||||||
#define TERASE_DEF '\10' /* ^H */
|
|
||||||
#define TINTR_DEF '\3' /* ^C */
|
|
||||||
#define TKILL_DEF '\25' /* ^U */
|
|
||||||
#define TMIN_DEF 1
|
|
||||||
#define TQUIT_DEF '\34' /* ^\ */
|
|
||||||
#define TSTART_DEF '\21' /* ^Q */
|
|
||||||
#define TSTOP_DEF '\23' /* ^S */
|
|
||||||
#define TSUSP_DEF '\32' /* ^Z */
|
|
||||||
#define TTIME_DEF 0
|
|
||||||
#define TREPRINT_DEF '\22' /* ^R */
|
|
||||||
#define TLNEXT_DEF '\26' /* ^V */
|
|
||||||
#define TDISCARD_DEF '\17' /* ^O */
|
|
||||||
|
|
||||||
/* Window size. This information is stored in the TTY driver but not used.
|
|
||||||
* This can be used for screen based applications in a window environment.
|
|
||||||
* The ioctls TIOCGWINSZ and TIOCSWINSZ can be used to get and set this
|
|
||||||
* information.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct winsize
|
|
||||||
{
|
|
||||||
unsigned short ws_row; /* rows, in characters */
|
|
||||||
unsigned short ws_col; /* columns, in characters */
|
|
||||||
unsigned short ws_xpixel; /* horizontal size, pixels */
|
|
||||||
unsigned short ws_ypixel; /* vertical size, pixels */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _TERMIOS_H */
|
|
|
@ -4,7 +4,7 @@ INCSDIR= /usr/include/sys
|
||||||
# Minix specific system headers
|
# Minix specific system headers
|
||||||
INCS= elf64.h elf_common.h elf_core.h elf_generic.h \
|
INCS= elf64.h elf_common.h elf_core.h elf_generic.h \
|
||||||
ioc_block.h ioc_disk.h ioc_fb.h ioc_fbd.h ioc_file.h ioc_memory.h \
|
ioc_block.h ioc_disk.h ioc_fb.h ioc_fbd.h ioc_file.h ioc_memory.h \
|
||||||
ioc_net.h ioc_sound.h ioc_tape.h ioc_tty.h \
|
ioc_net.h ioc_sound.h ioc_tape.h \
|
||||||
kbdio.h \
|
kbdio.h \
|
||||||
procfs.h statfs.h svrctl.h video.h vm.h
|
procfs.h statfs.h svrctl.h video.h vm.h
|
||||||
|
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* sys/ioc_tty.h - Terminal ioctl() command codes.
|
|
||||||
* Author: Kees J. Bot
|
|
||||||
* 23 Nov 2002
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _S_I_TTY_H
|
|
||||||
#define _S_I_TTY_H
|
|
||||||
|
|
||||||
#include <minix/ioctl.h>
|
|
||||||
|
|
||||||
/* Terminal ioctls. */
|
|
||||||
#define TCGETS _IOR('T', 8, struct termios) /* tcgetattr */
|
|
||||||
#define TCSETS _IOW('T', 9, struct termios) /* tcsetattr, TCSANOW */
|
|
||||||
#define TCSETSW _IOW('T', 10, struct termios) /* tcsetattr, TCSADRAIN */
|
|
||||||
#define TCSETSF _IOW('T', 11, struct termios) /* tcsetattr, TCSAFLUSH */
|
|
||||||
#define TCSBRK _IOW('T', 12, int) /* tcsendbreak */
|
|
||||||
#define TCDRAIN _IO ('T', 13) /* tcdrain */
|
|
||||||
#define TCFLOW _IOW('T', 14, int) /* tcflow */
|
|
||||||
#define TCFLSH _IOW('T', 15, int) /* tcflush */
|
|
||||||
#define TIOCGWINSZ _IOR('T', 16, struct winsize)
|
|
||||||
#define TIOCSWINSZ _IOW('T', 17, struct winsize)
|
|
||||||
#define TIOCGPGRP _IOW('T', 18, int)
|
|
||||||
#define TIOCSPGRP _IOW('T', 19, int)
|
|
||||||
#define TIOCSCTTY _IO ('T', 20) /* controlling tty */
|
|
||||||
#define TIOCSFON _IOW_BIG(1, u8_t [8192])
|
|
||||||
|
|
||||||
/* Keyboard ioctls. */
|
|
||||||
#define KIOCBELL _IOW('k', 1, struct kio_bell)
|
|
||||||
#define KIOCSLEDS _IOW('k', 2, struct kio_leds)
|
|
||||||
#define KIOCSMAP _IOW('k', 3, keymap_t)
|
|
||||||
|
|
||||||
/* /dev/video ioctls. */
|
|
||||||
#define TIOCMAPMEM _IORW('v', 1, struct mapreqvm)
|
|
||||||
#define TIOCUNMAPMEM _IORW('v', 2, struct mapreqvm)
|
|
||||||
|
|
||||||
#endif /* _S_I_TTY_H */
|
|
|
@ -53,10 +53,6 @@ __weak_alias(tcflow,_tcflow)
|
||||||
int
|
int
|
||||||
tcflow(int fd, int action)
|
tcflow(int fd, int action)
|
||||||
{
|
{
|
||||||
#ifdef __minix
|
|
||||||
_DIAGASSERT(fd != -1);
|
|
||||||
return ioctl(fd, TCFLOW, &action);
|
|
||||||
#else /* !__minix */
|
|
||||||
struct termios term;
|
struct termios term;
|
||||||
u_char c;
|
u_char c;
|
||||||
|
|
||||||
|
@ -80,5 +76,4 @@ tcflow(int fd, int action)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
#endif /* !__minix */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,6 @@ __weak_alias(tcflush,_tcflush)
|
||||||
int
|
int
|
||||||
tcflush(int fd, int which)
|
tcflush(int fd, int which)
|
||||||
{
|
{
|
||||||
#ifdef __minix
|
|
||||||
_DIAGASSERT(fd != -1);
|
|
||||||
return ioctl(fd, TCFLSH, &which);
|
|
||||||
#else /* !__minix */
|
|
||||||
int com;
|
int com;
|
||||||
|
|
||||||
_DIAGASSERT(fd != -1);
|
_DIAGASSERT(fd != -1);
|
||||||
|
@ -76,5 +72,4 @@ tcflush(int fd, int which)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
return (ioctl(fd, TIOCFLUSH, &com));
|
return (ioctl(fd, TIOCFLUSH, &com));
|
||||||
#endif /* !__minix */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,11 @@ __RCSID("$NetBSD: tcsendbreak.c,v 1.10 2012/06/25 22:32:46 abs Exp $");
|
||||||
|
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ioctl.h>
|
#ifdef __minix
|
||||||
#ifndef __minix
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif /* !__minix */
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -58,10 +59,6 @@ __weak_alias(tcsendbreak,_tcsendbreak)
|
||||||
int
|
int
|
||||||
tcsendbreak(int fd, int len)
|
tcsendbreak(int fd, int len)
|
||||||
{
|
{
|
||||||
#ifdef __minix
|
|
||||||
_DIAGASSERT(fd != -1);
|
|
||||||
return ioctl(fd, TCSBRK, &len);
|
|
||||||
#else /* !__minix */
|
|
||||||
static const struct timespec sleepytime = { 0, 400000000 };
|
static const struct timespec sleepytime = { 0, 400000000 };
|
||||||
|
|
||||||
_DIAGASSERT(fd != -1);
|
_DIAGASSERT(fd != -1);
|
||||||
|
@ -72,5 +69,4 @@ tcsendbreak(int fd, int len)
|
||||||
if (ioctl(fd, TIOCCBRK, 0) == -1)
|
if (ioctl(fd, TIOCCBRK, 0) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
#endif /* !__minix */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,22 +53,16 @@ __weak_alias(tcsetattr,_tcsetattr)
|
||||||
int
|
int
|
||||||
tcsetattr(int fd, int opt, const struct termios *t)
|
tcsetattr(int fd, int opt, const struct termios *t)
|
||||||
{
|
{
|
||||||
#ifndef __minix
|
|
||||||
struct termios localterm;
|
struct termios localterm;
|
||||||
#endif
|
|
||||||
|
|
||||||
_DIAGASSERT(fd != -1);
|
_DIAGASSERT(fd != -1);
|
||||||
_DIAGASSERT(t != NULL);
|
_DIAGASSERT(t != NULL);
|
||||||
|
|
||||||
#ifndef __minix
|
|
||||||
if (opt & TCSASOFT) {
|
if (opt & TCSASOFT) {
|
||||||
localterm = *t;
|
localterm = *t;
|
||||||
localterm.c_cflag |= CIGNORE;
|
localterm.c_cflag |= CIGNORE;
|
||||||
t = &localterm;
|
t = &localterm;
|
||||||
}
|
}
|
||||||
#else /* __minix */
|
|
||||||
#define TCSASOFT 0
|
|
||||||
#endif /* __minix */
|
|
||||||
switch (opt & ~TCSASOFT) {
|
switch (opt & ~TCSASOFT) {
|
||||||
case TCSANOW:
|
case TCSANOW:
|
||||||
return (ioctl(fd, TIOCSETA, __UNCONST(t)));
|
return (ioctl(fd, TIOCSETA, __UNCONST(t)));
|
||||||
|
|
|
@ -961,6 +961,7 @@ terminal_get_size(EditLine *el, int *lins, int *cols)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef __minix
|
||||||
#ifdef TIOCGSIZE
|
#ifdef TIOCGSIZE
|
||||||
{
|
{
|
||||||
struct ttysize ts;
|
struct ttysize ts;
|
||||||
|
@ -971,6 +972,7 @@ terminal_get_size(EditLine *el, int *lins, int *cols)
|
||||||
*lins = ts.ts_lines;
|
*lins = ts.ts_lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return Val(T_co) != *cols || Val(T_li) != *lins;
|
return Val(T_co) != *cols || Val(T_li) != *lins;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ MAN= ash.1 at.1 \
|
||||||
profile.1 ps.1 rcp.1 recwave.1 \
|
profile.1 ps.1 rcp.1 recwave.1 \
|
||||||
remsync.1 rget.1 rlogin.1 rsh.1 rz.1 \
|
remsync.1 rget.1 rlogin.1 rsh.1 rz.1 \
|
||||||
shar.1 sleep.1 spell.1 \
|
shar.1 sleep.1 spell.1 \
|
||||||
stty.1 svc.1 svrctl.1 \
|
svc.1 svrctl.1 \
|
||||||
synctree.1 sysenv.1 sz.1 tail.1 telnet.1 template.1 \
|
synctree.1 sysenv.1 sz.1 tail.1 telnet.1 template.1 \
|
||||||
term.1 termcap.1 tget.1 time.1 true.1 \
|
term.1 termcap.1 tget.1 time.1 true.1 \
|
||||||
truncate.1 umount.1 \
|
truncate.1 umount.1 \
|
||||||
|
|
250
man/man1/stty.1
250
man/man1/stty.1
|
@ -1,250 +0,0 @@
|
||||||
.TH STTY 1
|
|
||||||
.SH NAME
|
|
||||||
stty \- set terminal parameters
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.de SP
|
|
||||||
.if t .sp 0.4
|
|
||||||
.if n .sp
|
|
||||||
..
|
|
||||||
.in +4n
|
|
||||||
.ti -4n
|
|
||||||
.B stty
|
|
||||||
.RB [ \-ag]
|
|
||||||
.SP
|
|
||||||
.ti -4n
|
|
||||||
.B stty
|
|
||||||
.I encoded-form
|
|
||||||
.SP
|
|
||||||
.ti -4n
|
|
||||||
.B stty
|
|
||||||
.I speed
|
|
||||||
.B ispeed
|
|
||||||
.I speed
|
|
||||||
.B ospeed
|
|
||||||
.I speed
|
|
||||||
.B "cs5 cs6 cs7 cs8"
|
|
||||||
.RB [ \- ] parenb
|
|
||||||
.RB [ \- ] parodd
|
|
||||||
.RB [ \- ] hupcl
|
|
||||||
.RB [ \- ] cstopb
|
|
||||||
.RB [ \- ] cread
|
|
||||||
.RB [ \- ] clocal
|
|
||||||
.RB [ \- ] ignbrk
|
|
||||||
.RB [ \- ] brkint
|
|
||||||
.RB [ \- ] ignpar
|
|
||||||
.RB [ \- ] parmrk
|
|
||||||
.RB [ \- ] inpck
|
|
||||||
.RB [ \- ] istrip
|
|
||||||
.RB [ \- ] inlcr
|
|
||||||
.RB [ \- ] igncr
|
|
||||||
.RB [ \- ] icrnl
|
|
||||||
.RB [ \- ] ixon
|
|
||||||
.RB [ \- ] ixoff
|
|
||||||
.RB [ \- ] ixany
|
|
||||||
.RB [ \- ] opost
|
|
||||||
.RB [ \- ] onlcr
|
|
||||||
.RB [ \- ] xtabs
|
|
||||||
.RB [ \- ] onoeot
|
|
||||||
.RB [ \- ] isig
|
|
||||||
.RB [ \- ] icanon
|
|
||||||
.RB [ \- ] iexten
|
|
||||||
.RB [ \- ] echo
|
|
||||||
.RB [ \- ] echoe
|
|
||||||
.RB [ \- ] echok
|
|
||||||
.RB [ \- ] echonl
|
|
||||||
.RB [ \- ] noflsh
|
|
||||||
.RB [ \- ] tostop
|
|
||||||
.RB [ \- ] lflusho
|
|
||||||
.BR eof =\fIc
|
|
||||||
.BR eol =\fIc
|
|
||||||
.BR erase =\fIc
|
|
||||||
.BR erase =\fIc
|
|
||||||
.BR intr =\fIc
|
|
||||||
.BR kill =\fIc
|
|
||||||
.BR quit =\fIc
|
|
||||||
.BR susp =\fIc
|
|
||||||
.BR start =\fIc
|
|
||||||
.BR stop =\fIc
|
|
||||||
.BR rprnt =\fIc
|
|
||||||
.BR lnext =\fIc
|
|
||||||
.BR flush =\fIc
|
|
||||||
.BR min =\fIn
|
|
||||||
.BR time =\fIn
|
|
||||||
.B rows
|
|
||||||
.I n
|
|
||||||
.B cols
|
|
||||||
.I n
|
|
||||||
.B xpixels
|
|
||||||
.I n
|
|
||||||
.B ypixels
|
|
||||||
.I n
|
|
||||||
.B cooked
|
|
||||||
.B raw
|
|
||||||
.RB [ \- ] evenp
|
|
||||||
.RB [ \- ] parity
|
|
||||||
.RB [ \- ] oddp
|
|
||||||
.RB [ \- ] nl
|
|
||||||
.B ek
|
|
||||||
.B sane
|
|
||||||
.in -4n
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.B Stty
|
|
||||||
shows or changes the parameters of the terminal connected to standard input.
|
|
||||||
.B Stty
|
|
||||||
takes a myriad of arguments most of which are mapped directly to
|
|
||||||
the flags and special characters described in
|
|
||||||
.BR tty (4),
|
|
||||||
so we won't describe them here.
|
|
||||||
.PP
|
|
||||||
.B Stty
|
|
||||||
has three forms of operation. First, without any arguments
|
|
||||||
.B stty
|
|
||||||
shows all terminal attributes that are different from the default state.
|
|
||||||
Option
|
|
||||||
.B \-a
|
|
||||||
makes
|
|
||||||
.B stty
|
|
||||||
print all terminal attributes, and
|
|
||||||
.B \-g
|
|
||||||
lets
|
|
||||||
.B stty
|
|
||||||
print the attributes in a special encoded form, a simple row of colon separated
|
|
||||||
hexadecimal numbers.
|
|
||||||
.PP
|
|
||||||
In the second form of operation
|
|
||||||
.B stty
|
|
||||||
takes an encoded form as produced by the
|
|
||||||
.B \-g
|
|
||||||
option and sets the terminals attributes to its decoded value.
|
|
||||||
.PP
|
|
||||||
In the third form
|
|
||||||
.B stty
|
|
||||||
interprets a series of flags and parameters settings and modifies the
|
|
||||||
terminal attributes accordingly. Flags can be given as
|
|
||||||
.B icanon
|
|
||||||
or
|
|
||||||
.B \-icanon
|
|
||||||
for instance, either setting or clearing the
|
|
||||||
.B ICANON
|
|
||||||
flag.
|
|
||||||
Special character values can by set like
|
|
||||||
.B "intr=^C"
|
|
||||||
for example, which sets the interrupt character to CTRL-C. You can either
|
|
||||||
use a real CTRL-C, or the two characters `^' and `C'. In any case
|
|
||||||
it is probably necessary to use quotes to guard it from the shell:
|
|
||||||
.BR "intr='^C'" .
|
|
||||||
.PP
|
|
||||||
A number alone is interpreted as a baud rate setting for both the input and
|
|
||||||
output rate. The input or the output rate can be set separately with use
|
|
||||||
of the
|
|
||||||
.B ispeed
|
|
||||||
and
|
|
||||||
.B ospeed
|
|
||||||
prefixes to the number. The character size can be set with
|
|
||||||
.BR cs5 ,
|
|
||||||
.BR cs6 ,
|
|
||||||
.BR cs7
|
|
||||||
or
|
|
||||||
.BR cs8 .
|
|
||||||
.PP
|
|
||||||
The
|
|
||||||
.B MIN
|
|
||||||
and
|
|
||||||
.B TIME
|
|
||||||
value, the number of rows and columns, and the xpixels and ypixels of the
|
|
||||||
window can also be set using one of the keywords
|
|
||||||
.BR min ,
|
|
||||||
.BR time ,
|
|
||||||
.BR rows ,
|
|
||||||
.BR cols ,
|
|
||||||
.BR xpixels
|
|
||||||
or
|
|
||||||
.BR ypixels ,
|
|
||||||
followed by a decimal number that is the value of the setting.
|
|
||||||
.PP
|
|
||||||
.B Stty
|
|
||||||
accepts several keywords that are not named by corresponding flags or
|
|
||||||
parameters in
|
|
||||||
.BR tty (4).
|
|
||||||
They set several attributes at once:
|
|
||||||
.TP
|
|
||||||
.B cooked
|
|
||||||
Same as
|
|
||||||
.BR "icrnl ixon opost onlcr isig icanon iexten echo" ,
|
|
||||||
setting all the attributes that are needed for line oriented mode.
|
|
||||||
.TP
|
|
||||||
.B raw
|
|
||||||
Same as
|
|
||||||
.BR "\-icrnl \-ixon \-opost \-onlcr \-isig \-icanon \-iexten \-echo" ,
|
|
||||||
setting all the attributes for a raw data channel.
|
|
||||||
.TP
|
|
||||||
.B evenp parity
|
|
||||||
These synonyms are equal to
|
|
||||||
.BR "cs7 parenb \-parodd" ,
|
|
||||||
setting the line to 7 bits even parity.
|
|
||||||
.TP
|
|
||||||
.B oddp
|
|
||||||
Same as
|
|
||||||
.BR "cs7 parenb parodd" ,
|
|
||||||
setting the line to 7 bits odd parity.
|
|
||||||
.TP
|
|
||||||
.B "\-parity \-evenp \-oddp"
|
|
||||||
All synonyms for
|
|
||||||
.BR "cs8 \-parenb" ,
|
|
||||||
setting the line to 8 bits, no parity.
|
|
||||||
.TP
|
|
||||||
.B nl
|
|
||||||
Same as
|
|
||||||
.BR icrnl ,
|
|
||||||
setting carriage return to line feed input translation.
|
|
||||||
.TP
|
|
||||||
.B \-nl
|
|
||||||
Same as
|
|
||||||
.BR "\-icrnl \-inlcr \-igncr" ,
|
|
||||||
disabling any carriage return or line feed handling.
|
|
||||||
.TP
|
|
||||||
.B ek
|
|
||||||
Set the
|
|
||||||
.B ERASE
|
|
||||||
and
|
|
||||||
.B KILL
|
|
||||||
special characters back to the default.
|
|
||||||
.TP
|
|
||||||
.B sane
|
|
||||||
Set all attributes to the default except things like the line speed and
|
|
||||||
parity, because their "sane" value is probably what it is right now.
|
|
||||||
The default values are compiled into
|
|
||||||
.B stty
|
|
||||||
from the <termios.h> include file. Use
|
|
||||||
.B "stty sane; stty -a"
|
|
||||||
to know what they are.
|
|
||||||
.SH FILES
|
|
||||||
.TP 15n
|
|
||||||
.B /etc/ttytab
|
|
||||||
The
|
|
||||||
.B init
|
|
||||||
field of this file may contain an
|
|
||||||
.B stty
|
|
||||||
command to set the attributes to match an attached RS232 terminal or modem.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR tty (4),
|
|
||||||
.BR ttytab (5).
|
|
||||||
.SH NOTES
|
|
||||||
The
|
|
||||||
.BR cooked ,
|
|
||||||
.BR raw ,
|
|
||||||
.BR rows ,
|
|
||||||
.BR cols ,
|
|
||||||
.BR xpixels
|
|
||||||
and
|
|
||||||
.BR ypixels
|
|
||||||
keywords are MINIX 3 additions beyond the keywords defined by POSIX.
|
|
||||||
.B Rows
|
|
||||||
and
|
|
||||||
.B cols
|
|
||||||
are common UNIX extensions, however.
|
|
||||||
There are more MINIX 3 specific flags that match the MINIX 3 specific attributes
|
|
||||||
described in
|
|
||||||
.BR tty (4).
|
|
||||||
.SH AUTHOR
|
|
||||||
Kees J. Bot <kjb@cs.vu.nl>
|
|
|
@ -23,6 +23,7 @@
|
||||||
2012/10/17 12:00:00,bin/pwd
|
2012/10/17 12:00:00,bin/pwd
|
||||||
2011/08/29 14:48:46,bin/rm
|
2011/08/29 14:48:46,bin/rm
|
||||||
2011/08/29 14:49:38,bin/rmdir
|
2011/08/29 14:49:38,bin/rmdir
|
||||||
|
2012/10/17 12:00:00,bin/stty
|
||||||
2012/10/17 12:00:00,bin/sync
|
2012/10/17 12:00:00,bin/sync
|
||||||
2012/10/17 12:00:00,bin/test
|
2012/10/17 12:00:00,bin/test
|
||||||
2012/10/17 12:00:00,build.sh
|
2012/10/17 12:00:00,build.sh
|
||||||
|
|
|
@ -128,7 +128,7 @@ __RCSID("$NetBSD: mke2fs.c,v 1.14 2010/09/10 15:51:20 tsutsui Exp $");
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <uuid.h>
|
#include <uuid.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <minix/termios.h>
|
#include <sys/termios.h>
|
||||||
|
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
||||||
register struct boot_image *ip;
|
register struct boot_image *ip;
|
||||||
static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT,
|
static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT,
|
||||||
SIGEMT, SIGFPE, SIGBUS, SIGSEGV };
|
SIGEMT, SIGFPE, SIGBUS, SIGSEGV };
|
||||||
static char ign_sigs[] = { SIGCHLD, SIGWINCH, SIGCONT };
|
static char ign_sigs[] = { SIGCHLD, SIGWINCH, SIGCONT, SIGINFO };
|
||||||
static char noign_sigs[] = { SIGILL, SIGTRAP, SIGEMT, SIGFPE,
|
static char noign_sigs[] = { SIGILL, SIGTRAP, SIGEMT, SIGFPE,
|
||||||
SIGBUS, SIGSEGV };
|
SIGBUS, SIGSEGV };
|
||||||
register struct mproc *rmp;
|
register struct mproc *rmp;
|
||||||
|
|
|
@ -310,7 +310,7 @@ int process_ksig(endpoint_t proc_nr_e, int signo)
|
||||||
mp->mp_procgrp = rmp->mp_procgrp; /* get process group right */
|
mp->mp_procgrp = rmp->mp_procgrp; /* get process group right */
|
||||||
|
|
||||||
/* For SIGVTALRM and SIGPROF, see if we need to restart a
|
/* For SIGVTALRM and SIGPROF, see if we need to restart a
|
||||||
* virtual timer. For SIGINT, SIGWINCH and SIGQUIT, use proc_id 0
|
* virtual timer. For SIGINT, SIGINFO, SIGWINCH and SIGQUIT, use proc_id 0
|
||||||
* to indicate a broadcast to the recipient's process group. For
|
* to indicate a broadcast to the recipient's process group. For
|
||||||
* SIGKILL, use proc_id -1 to indicate a systemwide broadcast.
|
* SIGKILL, use proc_id -1 to indicate a systemwide broadcast.
|
||||||
*/
|
*/
|
||||||
|
@ -318,6 +318,7 @@ int process_ksig(endpoint_t proc_nr_e, int signo)
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
case SIGWINCH:
|
case SIGWINCH:
|
||||||
|
case SIGINFO:
|
||||||
id = 0; break; /* broadcast to process group */
|
id = 0; break; /* broadcast to process group */
|
||||||
case SIGVTALRM:
|
case SIGVTALRM:
|
||||||
case SIGPROF:
|
case SIGPROF:
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioc_tty.h>
|
#include <sys/ttycom.h>
|
||||||
#include <minix/callnr.h>
|
#include <minix/callnr.h>
|
||||||
#include <minix/com.h>
|
#include <minix/com.h>
|
||||||
#include <minix/endpoint.h>
|
#include <minix/endpoint.h>
|
||||||
|
|
201
sys/sys/fcntl.h
201
sys/sys/fcntl.h
|
@ -66,18 +66,20 @@
|
||||||
#define O_RDWR 0x00000002 /* open for reading and writing */
|
#define O_RDWR 0x00000002 /* open for reading and writing */
|
||||||
#define O_ACCMODE 0x00000003 /* mask for above modes */
|
#define O_ACCMODE 0x00000003 /* mask for above modes */
|
||||||
|
|
||||||
/* File status flags for open() and fcntl(). POSIX Table 6-5. */
|
/*
|
||||||
#define O_APPEND 02000 /* set append mode */
|
* Kernel encoding of open mode; separate read and write bits that are
|
||||||
#define O_NONBLOCK 04000 /* no delay */
|
* independently testable: 1 greater than the above.
|
||||||
#define O_REOPEN 010000 /* automatically re-open device after driver
|
*
|
||||||
* restart
|
* XXX
|
||||||
|
* FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH,
|
||||||
|
* which was documented to use FREAD/FWRITE, continues to work.
|
||||||
*/
|
*/
|
||||||
#define O_CLOEXEC 020000 /* close on exec */
|
|
||||||
#if defined(_NETBSD_SOURCE)
|
#if defined(_NETBSD_SOURCE)
|
||||||
#define O_NOSIGPIPE 040000 /* don't deliver sigpipe */
|
#define FREAD 0x00000001
|
||||||
|
#define FWRITE 0x00000002
|
||||||
#endif
|
#endif
|
||||||
|
#define O_NONBLOCK 0x00000004 /* no delay */
|
||||||
#ifndef __minix /* NOT SUPPORTED! */
|
#define O_APPEND 0x00000008 /* set append mode */
|
||||||
#if defined(_NETBSD_SOURCE)
|
#if defined(_NETBSD_SOURCE)
|
||||||
#define O_SHLOCK 0x00000010 /* open with shared file lock */
|
#define O_SHLOCK 0x00000010 /* open with shared file lock */
|
||||||
#define O_EXLOCK 0x00000020 /* open with exclusive file lock */
|
#define O_EXLOCK 0x00000020 /* open with exclusive file lock */
|
||||||
|
@ -92,15 +94,13 @@
|
||||||
#define O_NOFOLLOW 0x00000100 /* don't follow symlinks on the last */
|
#define O_NOFOLLOW 0x00000100 /* don't follow symlinks on the last */
|
||||||
/* path component */
|
/* path component */
|
||||||
#endif
|
#endif
|
||||||
#endif /* !__minix */
|
#define O_CREAT 0x00000200 /* create if nonexistent */
|
||||||
|
#define O_TRUNC 0x00000400 /* truncate to zero length */
|
||||||
|
#define O_EXCL 0x00000800 /* error if already exists */
|
||||||
|
|
||||||
/* Oflag values for open(). POSIX Table 6-4. */
|
/* defined by POSIX 1003.1; BSD default, but required to be bitwise distinct */
|
||||||
#define O_CREAT 00100 /* creat file if it doesn't exist */
|
#define O_NOCTTY 0x00008000 /* don't assign controlling terminal */
|
||||||
#define O_EXCL 00200 /* exclusive use flag */
|
|
||||||
#define O_NOCTTY 00400 /* do not assign a controlling terminal */
|
|
||||||
#define O_TRUNC 01000 /* truncate flag */
|
|
||||||
|
|
||||||
#ifndef __minix /* NOT SUPPORTED! */
|
|
||||||
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||||
defined(_NETBSD_SOURCE)
|
defined(_NETBSD_SOURCE)
|
||||||
#define O_DSYNC 0x00010000 /* write: I/O data completion */
|
#define O_DSYNC 0x00010000 /* write: I/O data completion */
|
||||||
|
@ -111,54 +111,165 @@
|
||||||
#define O_ALT_IO 0x00040000 /* use alternate i/o semantics */
|
#define O_ALT_IO 0x00040000 /* use alternate i/o semantics */
|
||||||
#define O_DIRECT 0x00080000 /* direct I/O hint */
|
#define O_DIRECT 0x00080000 /* direct I/O hint */
|
||||||
#endif
|
#endif
|
||||||
#endif /* !__minix */
|
|
||||||
|
#define O_DIRECTORY 0x00200000 /* fail if not a directory */
|
||||||
|
#define O_CLOEXEC 0x00400000 /* set close on exec */
|
||||||
|
#if defined(_INCOMPLETE_XOPEN_C063) || defined(_KERNEL)
|
||||||
|
#define O_SEARCH 0x00800000 /* skip search permission checks */
|
||||||
|
#endif
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define O_NOSIGPIPE 0x01000000 /* don't deliver sigpipe */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __minix
|
||||||
|
#define O_REOPEN 0x10000000 /* automatically re-open after driver crash */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _KERNEL
|
||||||
|
/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
|
||||||
|
#define FFLAGS(oflags) ((oflags) + 1)
|
||||||
|
#define OFLAGS(fflags) ((fflags) - 1)
|
||||||
|
|
||||||
|
/* all bits settable during open(2) */
|
||||||
|
#define O_MASK (O_ACCMODE|O_NONBLOCK|O_APPEND|O_SHLOCK|O_EXLOCK|\
|
||||||
|
O_ASYNC|O_SYNC|O_CREAT|O_TRUNC|O_EXCL|O_DSYNC|\
|
||||||
|
O_RSYNC|O_NOCTTY|O_ALT_IO|O_NOFOLLOW|O_DIRECT|\
|
||||||
|
O_DIRECTORY|O_CLOEXEC|O_NOSIGPIPE)
|
||||||
|
|
||||||
|
#define FMARK 0x00001000 /* mark during gc() */
|
||||||
|
#define FDEFER 0x00002000 /* defer for next gc pass */
|
||||||
|
#define FHASLOCK 0x00004000 /* descriptor holds advisory lock */
|
||||||
|
#define FSCAN 0x00100000 /* scan during gc passes */
|
||||||
|
#define FSILENT 0x40000000 /* suppress kernel error messages */
|
||||||
|
#define FKIOCTL 0x80000000 /* kernel originated ioctl */
|
||||||
|
/* bits settable by fcntl(F_SETFL, ...) */
|
||||||
|
#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FDSYNC|FRSYNC|FALTIO|\
|
||||||
|
FDIRECT|FNOSIGPIPE)
|
||||||
|
/* bits to save after open(2) */
|
||||||
|
#define FMASK (FREAD|FWRITE|FCNTLFLAGS)
|
||||||
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The O_* flags used to have only F* names, which were used in the kernel
|
||||||
|
* and by fcntl. We retain the F* names for the kernel f_flags field
|
||||||
|
* and for backward compatibility for fcntl.
|
||||||
|
*/
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define FAPPEND O_APPEND /* kernel/compat */
|
||||||
|
#define FASYNC O_ASYNC /* kernel/compat */
|
||||||
|
#define O_FSYNC O_SYNC /* compat */
|
||||||
|
#define FNDELAY O_NONBLOCK /* compat */
|
||||||
|
#define O_NDELAY O_NONBLOCK /* compat */
|
||||||
|
#endif
|
||||||
|
#if defined(_KERNEL)
|
||||||
|
#define FNOSIGPIPE O_NOSIGPIPE /* kernel */
|
||||||
|
#define FNONBLOCK O_NONBLOCK /* kernel */
|
||||||
|
#define FFSYNC O_SYNC /* kernel */
|
||||||
|
#define FDSYNC O_DSYNC /* kernel */
|
||||||
|
#define FRSYNC O_RSYNC /* kernel */
|
||||||
|
#define FALTIO O_ALT_IO /* kernel */
|
||||||
|
#define FDIRECT O_DIRECT /* kernel */
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constants used for fcntl(2)
|
* Constants used for fcntl(2)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* command values */
|
/* command values */
|
||||||
/* These values are used for cmd in fcntl(). POSIX Table 6-1. */
|
|
||||||
#define F_DUPFD 0 /* duplicate file descriptor */
|
#define F_DUPFD 0 /* duplicate file descriptor */
|
||||||
#define F_GETFD 1 /* get file descriptor flags */
|
#define F_GETFD 1 /* get file descriptor flags */
|
||||||
#define F_SETFD 2 /* set file descriptor flags */
|
#define F_SETFD 2 /* set file descriptor flags */
|
||||||
#define F_GETFL 3 /* get file status flags */
|
#define F_GETFL 3 /* get file status flags */
|
||||||
#define F_SETFL 4 /* set file status flags */
|
#define F_SETFL 4 /* set file status flags */
|
||||||
#define F_GETLK 5 /* get record locking information */
|
#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \
|
||||||
#define F_SETLK 6 /* set record locking information */
|
defined(_NETBSD_SOURCE)
|
||||||
#define F_SETLKW 7 /* set record locking info; wait if blocked */
|
#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
|
||||||
#define F_FREESP 8 /* free a section of a regular file */
|
#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
|
||||||
|
#endif
|
||||||
|
#define F_GETLK 7 /* get record locking information */
|
||||||
|
#define F_SETLK 8 /* set record locking information */
|
||||||
|
#define F_SETLKW 9 /* F_SETLK; wait if blocked */
|
||||||
#if defined(_NETBSD_SOURCE)
|
#if defined(_NETBSD_SOURCE)
|
||||||
#define F_GETNOSIGPIPE 9
|
#define F_CLOSEM 10 /* close all fds >= to the one given */
|
||||||
#define F_SETNOSIGPIPE 10
|
#define F_MAXFD 11 /* return the max open fd */
|
||||||
|
#define F_DUPFD_CLOEXEC 12 /* close on exec duplicated fd */
|
||||||
|
#define F_GETNOSIGPIPE 13 /* get SIGPIPE disposition */
|
||||||
|
#define F_SETNOSIGPIPE 14 /* set SIGPIPE disposition */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* File descriptor flags used for fcntl(). POSIX Table 6-2. */
|
#ifdef __minix
|
||||||
#define FD_CLOEXEC 1 /* close on exec flag for third arg of fcntl */
|
#define F_FREESP 100
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* file descriptor flags (F_GETFD, F_SETFD) */
|
||||||
|
#define FD_CLOEXEC 1 /* close-on-exec flag */
|
||||||
|
|
||||||
/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
|
/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
|
||||||
#define F_RDLCK 1 /* shared or read lock */
|
#define F_RDLCK 1 /* shared or read lock */
|
||||||
#define F_WRLCK 2 /* exclusive or write lock */
|
#define F_UNLCK 2 /* unlock */
|
||||||
#define F_UNLCK 3 /* unlock */
|
#define F_WRLCK 3 /* exclusive or write lock */
|
||||||
|
#ifdef _KERNEL
|
||||||
|
#define F_WAIT 0x010 /* Wait until lock is granted */
|
||||||
|
#define F_FLOCK 0x020 /* Use flock(2) semantics for lock */
|
||||||
|
#define F_POSIX 0x040 /* Use POSIX semantics for lock */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Constants for fcntl's passed to the underlying fs - like ioctl's. */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define F_PARAM_MASK 0xfff
|
||||||
|
#define F_PARAM_LEN(x) (((x) >> 16) & F_PARAM_MASK)
|
||||||
|
#define F_PARAM_MAX 4095
|
||||||
|
#define F_FSCTL (int)0x80000000 /* This fcntl goes to the fs */
|
||||||
|
#define F_FSVOID (int)0x40000000 /* no parameters */
|
||||||
|
#define F_FSOUT (int)0x20000000 /* copy out parameter */
|
||||||
|
#define F_FSIN (int)0x10000000 /* copy in parameter */
|
||||||
|
#define F_FSINOUT (F_FSIN | F_FSOUT)
|
||||||
|
#define F_FSDIRMASK (int)0x70000000 /* mask for IN/OUT/VOID */
|
||||||
|
#define F_FSPRIV (int)0x00008000 /* command is fs-specific */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define command macros for operations which, if implemented, must be
|
||||||
|
* the same for all fs's.
|
||||||
|
*/
|
||||||
|
#define _FCN(inout, num, len) \
|
||||||
|
(F_FSCTL | inout | ((len & F_PARAM_MASK) << 16) | (num))
|
||||||
|
#define _FCNO(c) _FCN(F_FSVOID, (c), 0)
|
||||||
|
#define _FCNR(c, t) _FCN(F_FSIN, (c), (int)sizeof(t))
|
||||||
|
#define _FCNW(c, t) _FCN(F_FSOUT, (c), (int)sizeof(t))
|
||||||
|
#define _FCNRW(c, t) _FCN(F_FSINOUT, (c), (int)sizeof(t))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define command macros for fs-specific commands.
|
||||||
|
*/
|
||||||
|
#define _FCN_FSPRIV(inout, fs, num, len) \
|
||||||
|
(F_FSCTL | F_FSPRIV | inout | ((len & F_PARAM_MASK) << 16) | \
|
||||||
|
(fs) << 8 | (num))
|
||||||
|
#define _FCNO_FSPRIV(f, c) _FCN_FSPRIV(F_FSVOID, (f), (c), 0)
|
||||||
|
#define _FCNR_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSIN, (f), (c), (int)sizeof(t))
|
||||||
|
#define _FCNW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSOUT, (f), (c), (int)sizeof(t))
|
||||||
|
#define _FCNRW_FSPRIV(f, c, t) _FCN_FSPRIV(F_FSINOUT, (f), (c), (int)sizeof(t))
|
||||||
|
|
||||||
|
#endif /* _NETBSD_SOURCE */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Advisory file segment locking data type -
|
* Advisory file segment locking data type -
|
||||||
* information passed to system by user
|
* information passed to system by user
|
||||||
*/
|
*/
|
||||||
struct flock {
|
struct flock {
|
||||||
short l_type; /* type: F_RDLCK, F_WRLCK, or F_UNLCK */
|
off_t l_start; /* starting offset */
|
||||||
short l_whence; /* flag for starting offset */
|
off_t l_len; /* len = 0 means until end of file */
|
||||||
off_t l_start; /* relative offset in bytes */
|
pid_t l_pid; /* lock owner */
|
||||||
off_t l_len; /* size; if 0, then until EOF */
|
short l_type; /* lock type: read/write, etc. */
|
||||||
pid_t l_pid; /* process id of the locks' owner */
|
short l_whence; /* type of l_start */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if defined(_NETBSD_SOURCE)
|
#if defined(_NETBSD_SOURCE)
|
||||||
/* lock operations for flock(2) */
|
/* lock operations for flock(2) */
|
||||||
#define LOCK_SH F_RDLCK /* Shared lock */
|
#define LOCK_SH 0x01 /* shared file lock */
|
||||||
#define LOCK_EX F_WRLCK /* Exclusive lock */
|
#define LOCK_EX 0x02 /* exclusive file lock */
|
||||||
#define LOCK_NB 0x0080 /* Do not block when locking */
|
#define LOCK_NB 0x04 /* don't block when locking */
|
||||||
#define LOCK_UN F_UNLCK /* Unlock */
|
#define LOCK_UN 0x08 /* unlock file */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Always ensure that these are consistent with <stdio.h> and <unistd.h>! */
|
/* Always ensure that these are consistent with <stdio.h> and <unistd.h>! */
|
||||||
|
@ -185,18 +296,14 @@ struct flock {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constants for X/Open Extended API set 2 (a.k.a. C063)
|
* Constants for X/Open Extended API set 2 (a.k.a. C063)
|
||||||
* linkat(2) - also part of Posix-2008/XPG7
|
|
||||||
*/
|
*/
|
||||||
#if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0) >= 700 || \
|
|
||||||
defined(_NETBSD_SOURCE)
|
|
||||||
#if defined(_INCOMPLETE_XOPEN_C063) || defined(_KERNEL) || defined(__minix)
|
#if defined(_INCOMPLETE_XOPEN_C063) || defined(_KERNEL) || defined(__minix)
|
||||||
#define AT_FDCWD -100 /* Use cwd for relative link target */
|
#define AT_FDCWD -100 /* Use cwd for relative link target */
|
||||||
#define AT_EACCESS 0x100 /* Use euid/egid for access checks */
|
#define AT_EACCESS 0x100 /* Use euig/egid for access checks */
|
||||||
#define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symlinks */
|
#define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symlinks */
|
||||||
#define AT_SYMLINK_FOLLOW 0x400 /* Follow symlinks */
|
#define AT_SYMLINK_FOLLOW 0x400 /* Follow symlinks */
|
||||||
#define AT_REMOVEDIR 0x800 /* Remove directory only */
|
#define AT_REMOVEDIR 0x800 /* Remove directory only */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _KERNEL
|
#ifndef _KERNEL
|
||||||
|
@ -209,7 +316,15 @@ int fcntl(int, int, ...);
|
||||||
#if defined(_NETBSD_SOURCE)
|
#if defined(_NETBSD_SOURCE)
|
||||||
int flock(int, int);
|
int flock(int, int);
|
||||||
#endif /* _NETBSD_SOURCE */
|
#endif /* _NETBSD_SOURCE */
|
||||||
|
int posix_fadvise(int, off_t, off_t, int);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* X/Open Extended API set 2 (a.k.a. C063)
|
||||||
|
*/
|
||||||
|
#if defined(_INCOMPLETE_XOPEN_C063)
|
||||||
|
int openat(int, const char *, int oflags, ...);
|
||||||
|
#endif
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
#endif /* _KERNEL */
|
#endif /* !_KERNEL */
|
||||||
|
|
||||||
#endif /* !_SYS_FCNTL_H_ */
|
#endif /* !_SYS_FCNTL_H_ */
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* used in each header file are shown in the comment following.
|
* used in each header file are shown in the comment following.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/ioc_tty.h> /* 'T' 't' 'k' */
|
#include <sys/ttycom.h> /* 't' */
|
||||||
#include <sys/ioc_net.h> /* 'n' */
|
#include <sys/ioc_net.h> /* 'n' */
|
||||||
#include <sys/ioc_disk.h> /* 'd' */
|
#include <sys/ioc_disk.h> /* 'd' */
|
||||||
#include <sys/ioc_file.h> /* 'f' */
|
#include <sys/ioc_file.h> /* 'f' */
|
||||||
|
@ -25,12 +25,7 @@
|
||||||
#include <sys/ioc_fb.h> /* 'V' */
|
#include <sys/ioc_fb.h> /* 'V' */
|
||||||
#include <dev/vndvar.h> /* 'F' */
|
#include <dev/vndvar.h> /* 'F' */
|
||||||
|
|
||||||
#if defined(_NETBSD_SOURCE)
|
#define TIOCGSIZE TIOCGWINSZ
|
||||||
#define TIOCDRAIN TCDRAIN
|
#define TIOCSSIZE TIOCSWINSZ
|
||||||
#define TIOCGETA TCGETS
|
|
||||||
#define TIOCSETA TCSETS
|
|
||||||
#define TIOCSETAW TCSETSW
|
|
||||||
#define TIOCSETAF TCSETSF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _S_IOCTL_H */
|
#endif /* _S_IOCTL_H */
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include <sys/featuretest.h>
|
#include <sys/featuretest.h>
|
||||||
#include <sys/sigtypes.h>
|
#include <sys/sigtypes.h>
|
||||||
|
|
||||||
#define _NSIG 26
|
#define _NSIG 27
|
||||||
#define NSIG _NSIG
|
#define NSIG _NSIG
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@
|
||||||
#define SIGWINCH 21 /* window size has changed */
|
#define SIGWINCH 21 /* window size has changed */
|
||||||
#define SIGVTALRM 24 /* virtual alarm */
|
#define SIGVTALRM 24 /* virtual alarm */
|
||||||
#define SIGPROF 25 /* profiler alarm */
|
#define SIGPROF 25 /* profiler alarm */
|
||||||
|
#define SIGINFO 26 /* information request */
|
||||||
|
|
||||||
/* POSIX requires the following signals to be defined, even if they are
|
/* POSIX requires the following signals to be defined, even if they are
|
||||||
* not supported. Here are the definitions, but they are not supported.
|
* not supported. Here are the definitions, but they are not supported.
|
||||||
|
@ -86,17 +87,17 @@
|
||||||
* processes in user-space. Higher-priority signals should be first.
|
* processes in user-space. Higher-priority signals should be first.
|
||||||
*/
|
*/
|
||||||
/* Signals delivered by a signal manager. */
|
/* Signals delivered by a signal manager. */
|
||||||
#define SIGSNDELAY 26 /* end of delay for signal delivery */
|
#define SIGSNDELAY 27 /* end of delay for signal delivery */
|
||||||
|
|
||||||
#define SIGS_FIRST SIGHUP /* first system signal */
|
#define SIGS_FIRST SIGHUP /* first system signal */
|
||||||
#define SIGS_LAST SIGSNDELAY /* last system signal */
|
#define SIGS_LAST SIGSNDELAY /* last system signal */
|
||||||
#define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST)
|
#define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST)
|
||||||
|
|
||||||
/* Signals delivered by the kernel. */
|
/* Signals delivered by the kernel. */
|
||||||
#define SIGKMEM 27 /* kernel memory request pending */
|
#define SIGKMEM 28 /* kernel memory request pending */
|
||||||
#define SIGKMESS 28 /* new kernel message */
|
#define SIGKMESS 29 /* new kernel message */
|
||||||
#define SIGKSIGSM 29 /* kernel signal pending for signal manager */
|
#define SIGKSIGSM 30 /* kernel signal pending for signal manager */
|
||||||
#define SIGKSIG 30 /* kernel signal pending */
|
#define SIGKSIG 31 /* kernel signal pending */
|
||||||
|
|
||||||
#define SIGK_FIRST SIGKMEM /* first kernel signal */
|
#define SIGK_FIRST SIGKMEM /* first kernel signal */
|
||||||
#define SIGK_LAST SIGKSIG /* last kernel signal */
|
#define SIGK_LAST SIGKSIG /* last kernel signal */
|
||||||
|
|
|
@ -34,17 +34,273 @@
|
||||||
#ifndef _SYS_TERMIOS_H_
|
#ifndef _SYS_TERMIOS_H_
|
||||||
#define _SYS_TERMIOS_H_
|
#define _SYS_TERMIOS_H_
|
||||||
|
|
||||||
|
#include <sys/ansi.h>
|
||||||
|
#include <sys/featuretest.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special Control Characters
|
||||||
|
*
|
||||||
|
* Index into c_cc[] character array.
|
||||||
|
*
|
||||||
|
* Name Subscript Enabled by
|
||||||
|
*/
|
||||||
|
#define VEOF 0 /* ICANON */
|
||||||
|
#define VEOL 1 /* ICANON */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define VEOL2 2 /* ICANON */
|
||||||
|
#endif
|
||||||
|
#define VERASE 3 /* ICANON */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define VWERASE 4 /* ICANON */
|
||||||
|
#endif
|
||||||
|
#define VKILL 5 /* ICANON */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define VREPRINT 6 /* ICANON */
|
||||||
|
#endif
|
||||||
|
/* 7 spare 1 */
|
||||||
|
#define VINTR 8 /* ISIG */
|
||||||
|
#define VQUIT 9 /* ISIG */
|
||||||
|
#define VSUSP 10 /* ISIG */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define VDSUSP 11 /* ISIG */
|
||||||
|
#endif
|
||||||
|
#define VSTART 12 /* IXON, IXOFF */
|
||||||
|
#define VSTOP 13 /* IXON, IXOFF */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define VLNEXT 14 /* IEXTEN */
|
||||||
|
#define VDISCARD 15 /* IEXTEN */
|
||||||
|
#endif
|
||||||
|
#define VMIN 16 /* !ICANON */
|
||||||
|
#define VTIME 17 /* !ICANON */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define VSTATUS 18 /* ICANON */
|
||||||
|
/* 19 spare 2 */
|
||||||
|
#endif
|
||||||
|
#define NCCS 20
|
||||||
|
|
||||||
|
#define _POSIX_VDISABLE __CAST(unsigned char, '\377')
|
||||||
|
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Input flags - software input processing
|
||||||
|
*/
|
||||||
|
#define IGNBRK 0x00000001 /* ignore BREAK condition */
|
||||||
|
#define BRKINT 0x00000002 /* map BREAK to SIGINT */
|
||||||
|
#define IGNPAR 0x00000004 /* ignore (discard) parity errors */
|
||||||
|
#define PARMRK 0x00000008 /* mark parity and framing errors */
|
||||||
|
#define INPCK 0x00000010 /* enable checking of parity errors */
|
||||||
|
#define ISTRIP 0x00000020 /* strip 8th bit off chars */
|
||||||
|
#define INLCR 0x00000040 /* map NL into CR */
|
||||||
|
#define IGNCR 0x00000080 /* ignore CR */
|
||||||
|
#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
|
||||||
|
#define IXON 0x00000200 /* enable output flow control */
|
||||||
|
#define IXOFF 0x00000400 /* enable input flow control */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define IXANY 0x00000800 /* any char will restart after stop */
|
||||||
|
#endif
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define IMAXBEL 0x00002000 /* ring bell on input queue full */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __minix
|
||||||
|
#define SCANCODES 0x00001000 /* send scancodes */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Output flags - software output processing
|
||||||
|
*/
|
||||||
|
#define OPOST 0x00000001 /* enable following output processing */
|
||||||
|
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||||
|
#define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
|
||||||
|
#endif
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define OXTABS 0x00000004 /* expand tabs to spaces */
|
||||||
|
#define ONOEOT 0x00000008 /* discard EOT's (^D) on output */
|
||||||
|
#endif
|
||||||
|
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||||
|
#define OCRNL 0x00000010 /* map CR to NL */
|
||||||
|
#define ONOCR 0x00000020 /* discard CR's when on column 0 */
|
||||||
|
#define ONLRET 0x00000040 /* move to column 0 on CR */
|
||||||
|
#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Control flags - hardware control of terminal
|
||||||
|
*/
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define CIGNORE 0x00000001 /* ignore control flags */
|
||||||
|
#endif
|
||||||
|
#define CSIZE 0x00000300 /* character size mask */
|
||||||
|
#define CS5 0x00000000 /* 5 bits (pseudo) */
|
||||||
|
#define CS6 0x00000100 /* 6 bits */
|
||||||
|
#define CS7 0x00000200 /* 7 bits */
|
||||||
|
#define CS8 0x00000300 /* 8 bits */
|
||||||
|
#define CSTOPB 0x00000400 /* send 2 stop bits */
|
||||||
|
#define CREAD 0x00000800 /* enable receiver */
|
||||||
|
#define PARENB 0x00001000 /* parity enable */
|
||||||
|
#define PARODD 0x00002000 /* odd parity, else even */
|
||||||
|
#define HUPCL 0x00004000 /* hang up on last close */
|
||||||
|
#define CLOCAL 0x00008000 /* ignore modem status lines */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define CRTSCTS 0x00010000 /* RTS/CTS full-duplex flow control */
|
||||||
|
#define CRTS_IFLOW CRTSCTS /* XXX compat */
|
||||||
|
#define CCTS_OFLOW CRTSCTS /* XXX compat */
|
||||||
|
#define CDTRCTS 0x00020000 /* DTR/CTS full-duplex flow control */
|
||||||
|
#define MDMBUF 0x00100000 /* DTR/DCD hardware flow control */
|
||||||
|
#define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "Local" flags - dumping ground for other state
|
||||||
|
*
|
||||||
|
* Warning: some flags in this structure begin with
|
||||||
|
* the letter "I" and look like they belong in the
|
||||||
|
* input flag.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define ECHOKE 0x00000001 /* visual erase for line kill */
|
||||||
|
#endif
|
||||||
|
#define ECHOE 0x00000002 /* visually erase chars */
|
||||||
|
#define ECHOK 0x00000004 /* echo NL after line kill */
|
||||||
|
#define ECHO 0x00000008 /* enable echoing */
|
||||||
|
#define ECHONL 0x00000010 /* echo NL even if ECHO is off */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */
|
||||||
|
#define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */
|
||||||
|
#endif /* defined(_NETBSD_SOURCE) */
|
||||||
|
#define ISIG 0x00000080 /* enable signals INT, QUIT, [D]SUSP */
|
||||||
|
#define ICANON 0x00000100 /* canonicalize input lines */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
|
||||||
|
#endif /* defined(_NETBSD_SOURCE) */
|
||||||
|
#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define EXTPROC 0x00000800 /* external processing */
|
||||||
|
#endif /* defined(_NETBSD_SOURCE) */
|
||||||
|
#define TOSTOP 0x00400000 /* stop background jobs on output */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define FLUSHO 0x00800000 /* output being flushed (state) */
|
||||||
|
#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
|
||||||
|
#define PENDIN 0x20000000 /* re-echo input buffer at next read */
|
||||||
|
#endif /* defined(_NETBSD_SOURCE) */
|
||||||
|
#define NOFLSH 0x80000000 /* don't flush output on signal */
|
||||||
|
|
||||||
|
typedef unsigned int tcflag_t;
|
||||||
|
typedef unsigned char cc_t;
|
||||||
|
typedef unsigned int speed_t;
|
||||||
|
|
||||||
|
struct termios {
|
||||||
|
tcflag_t c_iflag; /* input flags */
|
||||||
|
tcflag_t c_oflag; /* output flags */
|
||||||
|
tcflag_t c_cflag; /* control flags */
|
||||||
|
tcflag_t c_lflag; /* local flags */
|
||||||
|
cc_t c_cc[NCCS]; /* control chars */
|
||||||
|
int c_ispeed; /* input speed */
|
||||||
|
int c_ospeed; /* output speed */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Commands passed to tcsetattr() for setting the termios structure.
|
||||||
|
*/
|
||||||
|
#define TCSANOW 0 /* make change immediate */
|
||||||
|
#define TCSADRAIN 1 /* drain output, then change */
|
||||||
|
#define TCSAFLUSH 2 /* drain output, flush input */
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define TCSASOFT 0x10 /* flag - don't alter h.w. state */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Standard speeds
|
||||||
|
*/
|
||||||
|
#define B0 0
|
||||||
|
#define B50 50
|
||||||
|
#define B75 75
|
||||||
|
#define B110 110
|
||||||
|
#define B134 134
|
||||||
|
#define B150 150
|
||||||
|
#define B200 200
|
||||||
|
#define B300 300
|
||||||
|
#define B600 600
|
||||||
|
#define B1200 1200
|
||||||
|
#define B1800 1800
|
||||||
|
#define B2400 2400
|
||||||
|
#define B4800 4800
|
||||||
|
#define B9600 9600
|
||||||
|
#define B19200 19200
|
||||||
|
#define B38400 38400
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
#define B7200 7200
|
||||||
|
#define B14400 14400
|
||||||
|
#define B28800 28800
|
||||||
|
#define B57600 57600
|
||||||
|
#define B76800 76800
|
||||||
|
#define B115200 115200
|
||||||
|
#define B230400 230400
|
||||||
|
#define B460800 460800
|
||||||
|
#define B921600 921600
|
||||||
|
#define EXTA 19200
|
||||||
|
#define EXTB 38400
|
||||||
|
#endif /* defined(_NETBSD_SOURCE) */
|
||||||
|
|
||||||
|
#ifndef _KERNEL
|
||||||
|
|
||||||
|
#define TCIFLUSH 1
|
||||||
|
#define TCOFLUSH 2
|
||||||
|
#define TCIOFLUSH 3
|
||||||
|
#define TCOOFF 1
|
||||||
|
#define TCOON 2
|
||||||
|
#define TCIOFF 3
|
||||||
|
#define TCION 4
|
||||||
|
|
||||||
|
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||||
|
#ifndef pid_t
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#define pid_t __pid_t
|
||||||
|
#endif
|
||||||
|
#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
#include <minix/termios.h>
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
speed_t cfgetispeed(const struct termios *);
|
||||||
|
speed_t cfgetospeed(const struct termios *);
|
||||||
|
int cfsetispeed(struct termios *, speed_t);
|
||||||
|
int cfsetospeed(struct termios *, speed_t);
|
||||||
|
int tcgetattr(int, struct termios *);
|
||||||
|
int tcsetattr(int, int, const struct termios *);
|
||||||
|
int tcdrain(int);
|
||||||
|
int tcflow(int, int);
|
||||||
|
int tcflush(int, int);
|
||||||
|
int tcsendbreak(int, int);
|
||||||
|
#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
|
||||||
|
pid_t tcgetsid(int);
|
||||||
|
#endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */
|
||||||
|
|
||||||
|
|
||||||
#if defined(_NETBSD_SOURCE)
|
#if defined(_NETBSD_SOURCE)
|
||||||
void cfmakeraw(struct termios *);
|
void cfmakeraw(struct termios *);
|
||||||
int cfsetspeed(struct termios *, speed_t);
|
int cfsetspeed(struct termios *, speed_t);
|
||||||
#endif /* defined(_NETBSD_SOURCE) */
|
#endif /* defined(_NETBSD_SOURCE) */
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif /* !_KERNEL */
|
||||||
|
|
||||||
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include tty ioctl's that aren't just for backwards compatibility
|
||||||
|
* with the old tty driver. These ioctl definitions were previously
|
||||||
|
* in <sys/ioctl.h>.
|
||||||
|
*/
|
||||||
|
#include <sys/ttycom.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* END OF PROTECTED INCLUDE.
|
||||||
|
*/
|
||||||
#endif /* !_SYS_TERMIOS_H_ */
|
#endif /* !_SYS_TERMIOS_H_ */
|
||||||
|
|
||||||
#if defined(_NETBSD_SOURCE)
|
#if defined(_NETBSD_SOURCE)
|
||||||
|
|
|
@ -35,11 +35,6 @@
|
||||||
*
|
*
|
||||||
* @(#)ttycom.h 8.1 (Berkeley) 3/28/94
|
* @(#)ttycom.h 8.1 (Berkeley) 3/28/94
|
||||||
*/
|
*/
|
||||||
#include <minix/termios.h>
|
|
||||||
|
|
||||||
/* LSC FIXME: Wouldn't it be simpler to use that instead of including here
|
|
||||||
termios? for now disabled, pending investigation. */
|
|
||||||
#define _SYS_TTYCOM_H_
|
|
||||||
|
|
||||||
#ifndef _SYS_TTYCOM_H_
|
#ifndef _SYS_TTYCOM_H_
|
||||||
#define _SYS_TTYCOM_H_
|
#define _SYS_TTYCOM_H_
|
||||||
|
@ -168,4 +163,21 @@ typedef char linedn_t[TTLINEDNAMELEN];
|
||||||
#define STRIPDISC 6 /* metricom wireless IP discipline */
|
#define STRIPDISC 6 /* metricom wireless IP discipline */
|
||||||
#define HDLCDISC 9 /* HDLC discipline */
|
#define HDLCDISC 9 /* HDLC discipline */
|
||||||
|
|
||||||
|
#ifdef __minix
|
||||||
|
|
||||||
|
#include <minix/ioctl.h>
|
||||||
|
|
||||||
|
/* Terminal ioctls. Use big T. */
|
||||||
|
#define TIOCSFON _IOW_BIG(1, u8_t [8192]) /* new font */
|
||||||
|
|
||||||
|
/* Keyboard ioctls. */
|
||||||
|
#define KIOCBELL _IOW('k', 1, struct kio_bell)
|
||||||
|
#define KIOCSLEDS _IOW('k', 2, struct kio_leds)
|
||||||
|
#define KIOCSMAP _IOW('k', 3, keymap_t)
|
||||||
|
|
||||||
|
/* /dev/video ioctls. */
|
||||||
|
#define TIOCMAPMEM _IORW('v', 1, struct mapreqvm)
|
||||||
|
#define TIOCUNMAPMEM _IORW('v', 2, struct mapreqvm)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* !_SYS_TTYCOM_H_ */
|
#endif /* !_SYS_TTYCOM_H_ */
|
||||||
|
|
|
@ -49,7 +49,11 @@
|
||||||
#define TTYDEF_OFLAG (OPOST | ONLCR )
|
#define TTYDEF_OFLAG (OPOST | ONLCR )
|
||||||
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE)
|
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE)
|
||||||
#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
|
#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
|
||||||
|
#ifdef __minix
|
||||||
|
#define TTYDEF_SPEED (B115200)
|
||||||
|
#else
|
||||||
#define TTYDEF_SPEED (B9600)
|
#define TTYDEF_SPEED (B9600)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Control Character Defaults
|
* Control Character Defaults
|
||||||
|
|
|
@ -41,8 +41,9 @@ __RCSID("$NetBSD: infocmp.c,v 1.7 2010/02/22 23:05:39 roy Exp $");
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Specifically needed on MINIX, as struct winsize in not defined elsewhere */
|
#ifdef __minix
|
||||||
#include <minix/termios.h>
|
#include <sys/ttycom.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SW 8
|
#define SW 8
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,6 @@ __RCSID("$NetBSD: process.c,v 1.38 2009/04/13 07:29:55 lukem Exp $");
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#ifdef __minix
|
|
||||||
#include <minix/termios.h>
|
|
||||||
#endif
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -97,6 +94,10 @@ __RCSID("$NetBSD: process.c,v 1.38 2009/04/13 07:29:55 lukem Exp $");
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __minix
|
||||||
|
#include <sys/ttycom.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "extern.h"
|
#include "extern.h"
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <sys/ioc_tty.h>
|
#include <sys/ttycom.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
Loading…
Reference in a new issue