Merge pull request #584 from ejohnstown/init-pty-size

Initial PTY Window Size
pull/585/head
David Garske 2023-09-18 15:37:18 -07:00 committed by GitHub
commit 5af49f2f9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -52,7 +52,7 @@ AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([off_t])
# Check headers/libs
AC_CHECK_HEADERS([sys/select.h sys/time.h pty.h util.h termios.h])
AC_CHECK_HEADERS([sys/select.h sys/time.h sys/ioctl.h pty.h util.h termios.h])
AC_CHECK_LIB([network],[socket])
AC_CHECK_LIB([util],[forkpty])

View File

@ -13069,20 +13069,21 @@ int SendChannelTerminalResize(WOLFSSH* ssh, word32 columns, word32 rows,
}
#ifdef __linux__
#ifdef HAVE_PTY_H
#include <pty.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
static void GetTerminalSize(word32* width, word32* height)
static void GetTerminalSize(word32* width, word32* height,
word32* pixWidth, word32* pixHeight)
{
#ifdef __linux__
#ifdef HAVE_SYS_IOCTL_H
struct winsize windowSize = { 0,0,0,0 };
ioctl(STDOUT_FILENO, TIOCGWINSZ, &windowSize);
*width = (word32)windowSize.ws_col;
*height = (word32)windowSize.ws_row;
*pixWidth = (word32)windowSize.ws_xpixel;
*pixHeight = (word32)windowSize.ws_ypixel;
#elif defined(_MSC_VER)
CONSOLE_SCREEN_BUFFER_INFO cs;
@ -13110,15 +13111,14 @@ int SendChannelTerminalRequest(WOLFSSH* ssh)
const char envVar[] = "xterm";
byte mode[4096];
word32 envSz, typeSz, modeSz;
word32 w, h;
word32 pxW = 0, pxH = 0;
word32 w = 0, h = 0, pxW = 0, pxH = 0;
WLOG(WS_LOG_DEBUG, "Entering SendChannelTerminalRequest()");
if (ssh == NULL)
ret = WS_BAD_ARGUMENT;
GetTerminalSize(&w, &h);
GetTerminalSize(&w, &h, &pxW, &pxH);
envSz = (word32)WSTRLEN(envVar);
typeSz = (word32)WSTRLEN(cType);
modeSz = CreateMode(ssh, mode);