Add tcsetwinsize(2).

This commit is contained in:
Jonas 'Sortie' Termansen 2024-06-28 10:46:06 +02:00
parent 87bcf01967
commit c94f031be5
3 changed files with 34 additions and 2 deletions

View file

@ -661,6 +661,7 @@ termios/tcgetwinsize.o \
termios/tcsendbreak.o \
termios/tcsetattr.o \
termios/tcsetblob.o \
termios/tcsetwinsize.o \
time/clock_getres.o \
time/clock_gettime.o \
time/clock_gettimeres.o \

View file

@ -27,7 +27,7 @@
#include <sys/__/types.h>
#include <sortix/termios.h>
#if __USE_SORTIX
#if __USE_SORTIX || 202405L <= __USE_POSIX
#include <sortix/winsize.h>
#endif
@ -67,13 +67,17 @@ pid_t tcgetsid(int);
int tcsendbreak(int, int);
int tcsetattr(int, int, const struct termios*);
#if __USE_SORTIX || 202405L <= __USE_POSIX
int tcgetwinsize(int, struct winsize*);
int tcsetwinsize(int, const struct winsize*);
#endif
/* Functions that are Sortix extensions. */
#if __USE_SORTIX
int mkpty(int*, int*, int);
ssize_t tcgetblob(int, const char*, void*, size_t);
ssize_t tcsetblob(int, const char*, const void*, size_t);
int tcgetwincurpos(int, struct wincurpos*);
int tcgetwinsize(int, struct winsize*);
#endif
#ifdef __cplusplus

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2024 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* termios/tcsetwinsize.c
* Set the terminal resolution.
*/
#include <sys/ioctl.h>
#include <termios.h>
int tcsetwinsize(int fd, const struct winsize* ws)
{
return ioctl(fd, TIOCSWINSZ, ws);
}