Implement tcgetwinsize() and tcsetwinsize() in libc, with access
via <termios.h> (and document them.) Bump libc minor number for them. Arrange for "struct winsize" to become visible in <termios.h> Fix stty(1) so that "cols" is reported as the arg to set number of columns, and "columns" is the alias, rather than the other way around, as "cols" is what has been added to POSIX. This is to conform with updates to be included in 1003.1 issue 8 (whenever that gets published) currently available at: http://austingroupbugs.net/view.php?id=1053 (see note 3863) http://austingroupbugs.net/view.php?id=1151 (see note 3856)
This commit is contained in:
parent
2a7a645aaa
commit
673e27def2
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: stty.1,v 1.43 2016/08/14 23:29:43 sevan Exp $
|
||||
.\" $NetBSD: stty.1,v 1.44 2017/10/25 06:32:59 kre Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1990, 1993, 1994
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -477,13 +477,13 @@ 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
|
||||
.It Cm cols Ar number
|
||||
The terminal size is recorded as having
|
||||
.Ar number
|
||||
columns.
|
||||
.It Cm cols Ar number
|
||||
.It Cm columns Ar number
|
||||
An alias for
|
||||
.Cm columns .
|
||||
.Cm cols .
|
||||
.It Cm rows Ar number
|
||||
The terminal size is recorded as having
|
||||
.Ar number
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: shl.mi,v 1.823 2017/10/10 19:31:56 christos Exp $
|
||||
# $NetBSD: shl.mi,v 1.824 2017/10/25 06:32:59 kre Exp $
|
||||
#
|
||||
# Note: Don't delete entries from here - mark them as "obsolete" instead,
|
||||
# unless otherwise stated below.
|
||||
|
@ -18,7 +18,7 @@
|
|||
./lib/libblacklist.so.0.0 base-sys-shlib dynamicroot
|
||||
./lib/libc.so base-sys-shlib dynamicroot
|
||||
./lib/libc.so.12 base-sys-shlib dynamicroot
|
||||
./lib/libc.so.12.208 base-sys-shlib dynamicroot
|
||||
./lib/libc.so.12.209 base-sys-shlib dynamicroot
|
||||
./lib/libcrypt.so base-sys-shlib dynamicroot
|
||||
./lib/libcrypt.so.1 base-sys-shlib dynamicroot
|
||||
./lib/libcrypt.so.1.0 base-sys-shlib dynamicroot
|
||||
|
@ -217,7 +217,7 @@
|
|||
./usr/lib/libc++.so.1.0 base-sys-shlib compatfile,libcxx
|
||||
./usr/lib/libc.so base-sys-shlib compatfile
|
||||
./usr/lib/libc.so.12 base-sys-shlib compatfile
|
||||
./usr/lib/libc.so.12.208 base-sys-shlib compatfile
|
||||
./usr/lib/libc.so.12.209 base-sys-shlib compatfile
|
||||
./usr/lib/libcdk.so base-obsolete compatfile,obsolete
|
||||
./usr/lib/libcom_err.so base-krb5-shlib compatfile,kerberos
|
||||
./usr/lib/libcom_err.so.8 base-krb5-shlib compatfile,kerberos
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.2152 2017/10/16 11:38:25 maya Exp $
|
||||
# $NetBSD: mi,v 1.2153 2017/10/25 06:32:59 kre Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
./etc/mtree/set.comp comp-sys-root
|
||||
|
@ -9570,9 +9570,11 @@
|
|||
./usr/share/man/cat3/tcgetattr.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/tcgetpgrp.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/tcgetsid.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/tcgetwinsize.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/tcsendbreak.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/tcsetattr.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/tcsetpgrp.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/tcsetwinsize.0 comp-c-catman .cat
|
||||
./usr/share/man/cat3/td_close.0 comp-obsolete obsolete
|
||||
./usr/share/man/cat3/td_map_pth2thr.0 comp-obsolete obsolete
|
||||
./usr/share/man/cat3/td_open.0 comp-obsolete obsolete
|
||||
|
@ -17081,9 +17083,11 @@
|
|||
./usr/share/man/html3/tcgetattr.html comp-c-htmlman html
|
||||
./usr/share/man/html3/tcgetpgrp.html comp-c-htmlman html
|
||||
./usr/share/man/html3/tcgetsid.html comp-c-htmlman html
|
||||
./usr/share/man/html3/tcgetwinsize.html comp-c-htmlman html
|
||||
./usr/share/man/html3/tcsendbreak.html comp-c-htmlman html
|
||||
./usr/share/man/html3/tcsetattr.html comp-c-htmlman html
|
||||
./usr/share/man/html3/tcsetpgrp.html comp-c-htmlman html
|
||||
./usr/share/man/html3/tcsetwinsize.html comp-c-htmlman html
|
||||
./usr/share/man/html3/td_close.html comp-obsolete obsolete
|
||||
./usr/share/man/html3/td_map_pth2thr.html comp-obsolete obsolete
|
||||
./usr/share/man/html3/td_open.html comp-obsolete obsolete
|
||||
|
@ -24653,9 +24657,11 @@
|
|||
./usr/share/man/man3/tcgetattr.3 comp-c-man .man
|
||||
./usr/share/man/man3/tcgetpgrp.3 comp-c-man .man
|
||||
./usr/share/man/man3/tcgetsid.3 comp-c-man .man
|
||||
./usr/share/man/man3/tcgetwinsize.3 comp-c-man .man
|
||||
./usr/share/man/man3/tcsendbreak.3 comp-c-man .man
|
||||
./usr/share/man/man3/tcsetattr.3 comp-c-man .man
|
||||
./usr/share/man/man3/tcsetpgrp.3 comp-c-man .man
|
||||
./usr/share/man/man3/tcsetwinsize.3 comp-c-man .man
|
||||
./usr/share/man/man3/td_close.3 comp-obsolete obsolete
|
||||
./usr/share/man/man3/td_map_pth2thr.3 comp-obsolete obsolete
|
||||
./usr/share/man/man3/td_open.3 comp-obsolete obsolete
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# $NetBSD: shl.mi,v 1.185 2017/10/10 19:31:57 christos Exp $
|
||||
# $NetBSD: shl.mi,v 1.186 2017/10/25 06:32:59 kre Exp $
|
||||
./usr/lib/libbfd_g.a comp-c-debuglib debuglib,compatfile,binutils
|
||||
./usr/libdata/debug/lib base-sys-usr debug,dynamicroot,compatdir
|
||||
./usr/libdata/debug/lib/libblacklist.so.0.0.debug comp-sys-debug debug,dynamicroot
|
||||
./usr/libdata/debug/lib/libc.so.12.208.debug comp-sys-debug debug,dynamicroot
|
||||
./usr/libdata/debug/lib/libc.so.12.209.debug comp-sys-debug debug,dynamicroot
|
||||
./usr/libdata/debug/lib/libcrypt.so.1.0.debug comp-sys-debug debug,dynamicroot
|
||||
./usr/libdata/debug/lib/libcrypto.so.12.0.debug comp-sys-debug debug,dynamicroot
|
||||
./usr/libdata/debug/lib/libdevmapper.so.1.0.debug comp-sys-debug debug,dynamicroot,lvm
|
||||
|
@ -70,7 +70,7 @@
|
|||
./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug comp-sys-debug debug,compatfile
|
||||
./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug comp-sys-debug debug,compatfile
|
||||
./usr/libdata/debug/usr/lib/libc++.so.1.0.debug comp-sys-debug debug,compatfile,libcxx
|
||||
./usr/libdata/debug/usr/lib/libc.so.12.208.debug comp-sys-debug debug,compatfile
|
||||
./usr/libdata/debug/usr/lib/libc.so.12.209.debug comp-sys-debug debug,compatfile
|
||||
./usr/libdata/debug/usr/lib/libcom_err.so.8.0.debug comp-krb5-debug debug,compatfile,kerberos
|
||||
./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug comp-sys-debug debug,compatfile
|
||||
./usr/libdata/debug/usr/lib/libcrypto.so.12.0.debug comp-crypto-debug debug,compatfile
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: shlib_version,v 1.277 2017/10/05 04:38:08 dholland Exp $
|
||||
# $NetBSD: shlib_version,v 1.278 2017/10/25 06:32:59 kre Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
# things we wish to do on next major version bump:
|
||||
|
@ -52,4 +52,4 @@
|
|||
# - clean-up initialisation order between crt0.o, rtld and libc.
|
||||
# - move environ and __ps_strings from crt0.o into libc.
|
||||
major=12
|
||||
minor=208
|
||||
minor=209
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
# $NetBSD: Makefile.inc,v 1.4 1998/02/14 20:20:44 kleink Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.5 2017/10/25 06:32:59 kre Exp $
|
||||
|
||||
.PATH: ${.CURDIR}/termios
|
||||
|
||||
SRCS+= cfgetispeed.c cfgetospeed.c cfmakeraw.c cfsetispeed.c cfsetospeed.c \
|
||||
cfsetspeed.c tcdrain.c tcflow.c tcflush.c tcgetattr.c tcgetpgrp.c \
|
||||
tcgetsid.c tcsendbreak.c tcsetattr.c tcsetpgrp.c
|
||||
tcgetwinsize.c tcgetsid.c tcsendbreak.c tcsetattr.c tcsetpgrp.c \
|
||||
tcsetwinsize.c
|
||||
|
||||
MAN+= tcgetpgrp.3 tcgetsid.3 tcsendbreak.3 tcsetattr.3 tcsetpgrp.3
|
||||
MAN+= tcgetpgrp.3 tcgetsid.3 tcgetwinsize.3 tcsendbreak.3 tcsetattr.3 \
|
||||
tcsetpgrp.3
|
||||
|
||||
MLINKS+=tcgetwinsize.3 tcsetwinsize.3
|
||||
MLINKS+=tcsendbreak.3 tcdrain.3 tcsendbreak.3 tcflow.3 \
|
||||
tcsendbreak.3 tcflush.3
|
||||
MLINKS+=tcsetattr.3 tcgetattr.3 tcsetattr.3 cfgetispeed.3 \
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
.\" $NetBSD: tcgetwinsize.3,v 1.1 2017/10/25 06:32:59 kre Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2017 The NetBSD Foundation, Inc.
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
.\"
|
||||
.Dd October 25, 2017
|
||||
.Dt TCGETWINSIZE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm tcgetwinsize ,
|
||||
.Nm tcsetwinsize
|
||||
.Nd manipulate terminal window size
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In termios.h
|
||||
.Fd
|
||||
.Ft int
|
||||
.Fn tcgetwinsize "int fd" "struct winsize *gws"
|
||||
.Fd
|
||||
.Ft int
|
||||
.Fn tcsetwinsize "int fd" "const struct winsize *sws"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm tcgetwinsize
|
||||
function fills in the
|
||||
.Ic winsize
|
||||
structure pointed to by
|
||||
.Fa gws
|
||||
with values that represent the size of the
|
||||
terminal window for which
|
||||
.Fa fd
|
||||
provides an open file descriptor.
|
||||
If no error occurs
|
||||
.Fn tcgetwinsize
|
||||
returns zero (0).
|
||||
.Pp
|
||||
The
|
||||
.Nm tcsetwinsize
|
||||
function sets the terminal window size,
|
||||
for the terminal referenced by
|
||||
.Fa fd ,
|
||||
to the sizes from the
|
||||
.Ic winsize
|
||||
structure pointed to by
|
||||
.Fa sws .
|
||||
If no error occurs
|
||||
.Fn tcsetwinsize
|
||||
returns zero (0).
|
||||
.Pp
|
||||
The
|
||||
.Ic winsize
|
||||
structure, defined in
|
||||
.In termios.h ,
|
||||
contains (at least) the following four fields
|
||||
.Bd -literal
|
||||
unsigned short ws_row; /* Number of rows, in characters */
|
||||
unsigned short ws_col; /* Number of columns, in characters */
|
||||
unsigned short ws_xpixel; /* Width, in pixels */
|
||||
unsigned short ws_ypixel; /* Height, in pixels */
|
||||
.Ed
|
||||
.Pp
|
||||
If the actual window size of the controlling terminal
|
||||
of a process changes, the process is sent a
|
||||
.Dv SIGWINCH
|
||||
signal.
|
||||
See
|
||||
.Xr signal 7 .
|
||||
Note simply changing the sizes using
|
||||
.Fn tcsetwinsize
|
||||
does not necessarily change the actual window size,
|
||||
and if not, will not generate a
|
||||
.Dv SIGWINCH .
|
||||
.Sh ERRORS
|
||||
If an error occurs,
|
||||
.Fn tcgetwinsize
|
||||
and
|
||||
.Fn tcsetwinsize
|
||||
return -1 and cause the global variable
|
||||
.Va errno
|
||||
to be set to indicate the error.
|
||||
Common errors are as follows:
|
||||
.Bl -tag -width Er
|
||||
.It Bq Er EBADF
|
||||
The
|
||||
.Fa fd
|
||||
argument to
|
||||
.Fn tcgetwinsize
|
||||
or
|
||||
.Fn tcsetwinsize
|
||||
is not a valid file descriptor.
|
||||
.It Bq Er EFAULT
|
||||
The
|
||||
.Fa gws
|
||||
argument to
|
||||
.Fn tcgetwinsize
|
||||
does not point to a suitable location
|
||||
into which to store the resulting
|
||||
.Ic winsize
|
||||
structure,
|
||||
or the
|
||||
.Fa sws
|
||||
argument to
|
||||
.Fn tcsetwinsize
|
||||
does not refer to a suitable location
|
||||
from which the
|
||||
.Ic winsize
|
||||
structure can be obtained.
|
||||
.It Bq Er EINVAL
|
||||
The values passed in the
|
||||
.Ar sws
|
||||
.Ic winsize
|
||||
structure to
|
||||
.Fn tcsetwinsize
|
||||
represent an attempt to set the window size to an invalid state.
|
||||
.It Bq Er ENOTTY
|
||||
The
|
||||
.Fa fd
|
||||
argument to
|
||||
.Fn tcgetwinsize
|
||||
or
|
||||
.Fn tcsetwinsize
|
||||
does not represent a terminal device capable
|
||||
of remembering a window size.
|
||||
.Sh SEE ALSO
|
||||
.Xr stty 1 ,
|
||||
.Xr termios 4 ,
|
||||
.Xr pty 4 ,
|
||||
.Xr tty 4 ,
|
||||
.Xr signal 7
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Nm tcgetwinsize
|
||||
and
|
||||
.Nm tcsetwinsize
|
||||
functions will conform to
|
||||
.St -p1003.1
|
||||
issue 8, when it is published.
|
||||
.Pp
|
||||
The
|
||||
.Ic ws_xpixel
|
||||
and
|
||||
.Ic ws_ypixel
|
||||
fields are extensions to the standard.
|
||||
.Pp
|
||||
The standard only requires pseudo-terminals
|
||||
.Pq Xr pty 4
|
||||
to support these operations.
|
||||
In
|
||||
.Nx
|
||||
all terminal devices can set and recall a window size,
|
||||
regardless of whether any actual window exists.
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn tcgetwinsize
|
||||
and
|
||||
.Fn tcsetwinsize
|
||||
functions were added in
|
||||
.Nx 8.0
|
||||
after specification by POSIX
|
||||
as more portable alternatives to ancient
|
||||
.Ic ioctl
|
||||
operations from
|
||||
.Bx 4.3 .
|
||||
.Sh CAVEATS
|
||||
It is unspecified whether calling the
|
||||
.Nm tcsetwinsize
|
||||
function causes the underlying terminal window to be resized.
|
||||
Nor is it specified whether altering the relationship between
|
||||
the character fields (ws_row and ws_col) and the pixel fields
|
||||
(ws_xpixel and ws_ypixel) causes the font size to change, or
|
||||
whether the application is required to maintain any specific
|
||||
relationship between these fields.
|
||||
In general, the
|
||||
.Nm tcsetwinsize
|
||||
function is best avoided except by applications responsible
|
||||
for actually implementing terminal windows.
|
||||
.Pp
|
||||
As the
|
||||
.Ic winsize
|
||||
structure may have more fields than documented, applications
|
||||
planning to call
|
||||
.Fn tcsetwinsize
|
||||
should call
|
||||
.Fn tcgetwinsize
|
||||
first with the same
|
||||
.Ar fd
|
||||
parameter, and use the result obtained in
|
||||
.Ar *gws
|
||||
to initialize the
|
||||
.Ic winsize
|
||||
structure to be used (after altering fields that are to be changed)
|
||||
as the
|
||||
.Ar sws
|
||||
operand of
|
||||
.Nm tcsetwinsize .
|
|
@ -0,0 +1,48 @@
|
|||
/* $NetBSD: tcgetwinsize.c,v 1.1 2017/10/25 06:32:59 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2017 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: tcgetwinsize.c,v 1.1 2017/10/25 06:32:59 kre Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifndef _NETBSD_SOURCE
|
||||
#define _NETBSD_SOURCE /* need the ioctl values to be in <termios.h> */
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
|
||||
int
|
||||
tcgetwinsize(int fd, struct winsize *ws)
|
||||
{
|
||||
return ioctl(fd, TIOCGWINSZ, ws);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/* $NetBSD: tcsetwinsize.c,v 1.1 2017/10/25 06:32:59 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2017 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: tcsetwinsize.c,v 1.1 2017/10/25 06:32:59 kre Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifndef _NETBSD_SOURCE
|
||||
#define _NETBSD_SOURCE /* need the ioctl values to be in <termios.h> */
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
|
||||
int
|
||||
tcsetwinsize(int fd, const struct winsize *ws)
|
||||
{
|
||||
return ioctl(fd, TIOCSWINSZ, ws);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: termios.h,v 1.33 2016/07/31 21:34:53 dholland Exp $ */
|
||||
/* $NetBSD: termios.h,v 1.34 2017/10/25 06:32:59 kre Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1993, 1994
|
||||
|
@ -284,15 +284,17 @@ __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>.
|
||||
* in <sys/ioctl.h>. Most of this appears only when _NETBSD_SOURCE
|
||||
* is defined, but (at least) struct winsize has been made standard,
|
||||
* and needs to be visible here (as well as via the old <sys/ioctl.h>.)
|
||||
*/
|
||||
#include <sys/ttycom.h>
|
||||
#endif
|
||||
|
||||
int tcgetwinsize(int, struct winsize *);
|
||||
int tcsetwinsize(int, const struct winsize *);
|
||||
|
||||
/*
|
||||
* END OF PROTECTED INCLUDE.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ttycom.h,v 1.20 2012/10/19 16:49:21 apb Exp $ */
|
||||
/* $NetBSD: ttycom.h,v 1.21 2017/10/25 06:32:59 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993, 1994
|
||||
|
@ -36,8 +36,8 @@
|
|||
* @(#)ttycom.h 8.1 (Berkeley) 3/28/94
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TTYCOM_H_
|
||||
#define _SYS_TTYCOM_H_
|
||||
#ifndef _POSIX_SYS_TTYCOM_H_
|
||||
#define _POSIX_SYS_TTYCOM_H_
|
||||
|
||||
#include <sys/syslimits.h>
|
||||
#include <sys/ioccom.h>
|
||||
|
@ -57,6 +57,18 @@ struct winsize {
|
|||
unsigned short ws_xpixel; /* horizontal size, pixels */
|
||||
unsigned short ws_ypixel; /* vertical size, pixels */
|
||||
};
|
||||
#endif /* !_POSIX_SYS_TTYCOM_H_ */
|
||||
|
||||
#if defined(_NETBSD_SOURCE) || defined(_SYS_IOCTL_H_)
|
||||
|
||||
#ifndef _NETBSD_SYS_TTYCOM_H_
|
||||
#define _NETBSD_SYS_TTYCOM_H_
|
||||
|
||||
/*
|
||||
* The following are not exposed when imported via <termios.h>
|
||||
* when _POSIX_SOURCE (et.al.) is defined (and hence _NETBSD_SOURCE
|
||||
* is not, unless that is added manually.)
|
||||
*/
|
||||
|
||||
/* ptmget, for /dev/ptm pty getting ioctl TIOCPTMGET, and for TIOCPTSNAME */
|
||||
struct ptmget {
|
||||
|
@ -164,4 +176,5 @@ typedef char linedn_t[TTLINEDNAMELEN];
|
|||
#define STRIPDISC 6 /* metricom wireless IP discipline */
|
||||
#define HDLCDISC 9 /* HDLC discipline */
|
||||
|
||||
#endif /* !_SYS_TTYCOM_H_ */
|
||||
#endif /* !_NETBSD_SYS_TTYCOM_H_ */
|
||||
#endif /* _NETBSD_SOURCE || _IOCTL_H */
|
||||
|
|
Loading…
Reference in New Issue