mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibCore: Add wrappers for tc{get,set}winsize
On Serenity, this uses the equivalent LibC function, otherwise it defaults to the pretty standard ioctl equivalent. At the time of writing, it seems that only musl, BSDs and Serenity have the standardized POSIX function.
This commit is contained in:
1 parent
8e34c970b5
commit
76175e09ba
2 files changed
+27
No files matched your search
@@ -826,6 +826,31 @@ ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const& ios)
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<winsize> tcgetwinsize(int fd)
|
||||
{
|
||||
winsize ws {};
|
||||
#ifdef AK_OS_SERENITY
|
||||
if (::tcgetwinsize(fd, &ws) < 0)
|
||||
return Error::from_syscall("tcgetwinsize"sv, -errno);
|
||||
#else
|
||||
if (::ioctl(fd, TIOCGWINSZ, &ws) < 0)
|
||||
return Error::from_syscall("ioctl"sv, -errno);
|
||||
#endif
|
||||
return ws;
|
||||
}
|
||||
|
||||
ErrorOr<void> tcsetwinsize(int fd, winsize const& ws)
|
||||
{
|
||||
#ifdef AK_OS_SERENITY
|
||||
if (::tcsetwinsize(fd, &ws) < 0)
|
||||
return Error::from_syscall("tcsetwinsize"sv, -errno);
|
||||
#else
|
||||
if (::ioctl(fd, TIOCSWINSZ, &ws) < 0)
|
||||
return Error::from_syscall("ioctl"sv, -errno);
|
||||
#endif
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<int> tcsetpgrp(int fd, pid_t pgrp)
|
||||
{
|
||||
int rc = ::tcsetpgrp(fd, pgrp);
|
||||
|
||||
@@ -149,6 +149,8 @@ ErrorOr<ByteString> getcwd();
|
||||
ErrorOr<void> ioctl(int fd, unsigned request, ...);
|
||||
ErrorOr<struct termios> tcgetattr(int fd);
|
||||
ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const&);
|
||||
ErrorOr<winsize> tcgetwinsize(int fd);
|
||||
ErrorOr<void> tcsetwinsize(int fd, winsize const&);
|
||||
ErrorOr<int> tcsetpgrp(int fd, pid_t pgrp);
|
||||
ErrorOr<void> chmod(StringView pathname, mode_t mode);
|
||||
ErrorOr<void> lchown(StringView pathname, uid_t uid, gid_t gid);
|
||||
|
||||
Reference in new issue
Block a user