aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-03-05 12:32:15 +0000
committerRon Yorston <rmy@pobox.com>2023-03-05 12:32:15 +0000
commit4020c7689c3f640e8a56edd1a1491403112857ec (patch)
treee1f68655eb34994557b51af970afae5c14cb05c6 /libbb
parentf52c2004b818ac739ec886d5ff0a87734b55d293 (diff)
downloadbusybox-w32-4020c7689c3f640e8a56edd1a1491403112857ec.tar.gz
busybox-w32-4020c7689c3f640e8a56edd1a1491403112857ec.tar.bz2
busybox-w32-4020c7689c3f640e8a56edd1a1491403112857ec.zip
win32: add virtual terminal support to termios(3)
Modify `struct termios` to support Windows virtual terminals. Native console mode flags replace the Unix `c_?flag` structure members. Remove unsupported flags from termios.h. Add implementations of tcgetattr(3)/tcsetattr(3) to get/set console flags when virtual terminal input mode is enabled. Add support for emulating raw mode to get_termios_and_make_raw(). This (and related functions) are exposed but not yet used.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/xfuncs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 388b246ca..bf15f4c75 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -311,13 +311,12 @@ int FAST_FUNC is_TERM_dumb(void)
311 return term && strcmp(term, "dumb") == 0; 311 return term && strcmp(term, "dumb") == 0;
312} 312}
313 313
314#if !ENABLE_PLATFORM_MINGW32
315int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp) 314int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp)
316{ 315{
317 return tcsetattr(STDIN_FILENO, TCSANOW, tp); 316 return tcsetattr(STDIN_FILENO, TCSANOW, tp);
318} 317}
319 318
320int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) 319int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags IF_PLATFORM_MINGW32(UNUSED_PARAM))
321{ 320{
322//TODO: slattach, shell read might be adapted to use this too: grep for "tcsetattr", "[VTIME] = 0" 321//TODO: slattach, shell read might be adapted to use this too: grep for "tcsetattr", "[VTIME] = 0"
323 int r; 322 int r;
@@ -326,6 +325,9 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t
326 r = tcgetattr(fd, oldterm); 325 r = tcgetattr(fd, oldterm);
327 *newterm = *oldterm; 326 *newterm = *oldterm;
328 327
328#if ENABLE_PLATFORM_MINGW32
329 newterm->imode &= ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT);
330#else
329 /* Turn off buffered input (ICANON) 331 /* Turn off buffered input (ICANON)
330 * Turn off echoing (ECHO) 332 * Turn off echoing (ECHO)
331 * and separate echoing of newline (ECHONL, normally off anyway) 333 * and separate echoing of newline (ECHONL, normally off anyway)
@@ -382,6 +384,7 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t
382 */ 384 */
383 newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL); 385 newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL);
384 } 386 }
387#endif
385 return r; 388 return r;
386} 389}
387 390
@@ -392,7 +395,6 @@ int FAST_FUNC set_termios_to_raw(int fd, struct termios *oldterm, int flags)
392 get_termios_and_make_raw(fd, &newterm, oldterm, flags); 395 get_termios_and_make_raw(fd, &newterm, oldterm, flags);
393 return tcsetattr(fd, TCSANOW, &newterm); 396 return tcsetattr(fd, TCSANOW, &newterm);
394} 397}
395#endif
396 398
397pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options) 399pid_t FAST_FUNC safe_waitpid(pid_t pid, int *wstat, int options)
398{ 400{