diff options
author | Ron Yorston <rmy@pobox.com> | 2016-08-02 15:53:24 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-08-02 15:53:24 +0100 |
commit | 759188eae5651f1fbca45be310b0b9b46d876080 (patch) | |
tree | 7e2cda8242feb743f49a55e30f521b0c8d0c22c5 | |
parent | 31277ab7e6e0a8385a35138d9d2d5168ecadec87 (diff) | |
download | busybox-w32-759188eae5651f1fbca45be310b0b9b46d876080.tar.gz busybox-w32-759188eae5651f1fbca45be310b0b9b46d876080.tar.bz2 busybox-w32-759188eae5651f1fbca45be310b0b9b46d876080.zip |
stty: changes required to build for WIN32
-rw-r--r-- | configs/mingw32_defconfig | 6 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 6 | ||||
-rw-r--r-- | include/mingw.h | 2 | ||||
-rw-r--r-- | win32/ioctl.c | 4 | ||||
-rw-r--r-- | win32/termios.c | 43 | ||||
-rw-r--r-- | win32/termios.h | 17 | ||||
-rw-r--r-- | win32/winansi.c | 17 |
7 files changed, 85 insertions, 10 deletions
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index 34ce09e78..b81dce789 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.26.0.git | 3 | # Busybox version: 1.26.0.git |
4 | # Thu Jul 7 14:45:07 2016 | 4 | # Tue Aug 2 15:42:24 2016 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -294,7 +294,7 @@ CONFIG_SORT=y | |||
294 | CONFIG_FEATURE_SORT_BIG=y | 294 | CONFIG_FEATURE_SORT_BIG=y |
295 | CONFIG_SPLIT=y | 295 | CONFIG_SPLIT=y |
296 | CONFIG_FEATURE_SPLIT_FANCY=y | 296 | CONFIG_FEATURE_SPLIT_FANCY=y |
297 | # CONFIG_STTY is not set | 297 | CONFIG_STTY=y |
298 | CONFIG_SUM=y | 298 | CONFIG_SUM=y |
299 | CONFIG_TAC=y | 299 | CONFIG_TAC=y |
300 | CONFIG_TAIL=y | 300 | CONFIG_TAIL=y |
@@ -760,7 +760,7 @@ CONFIG_MAN=y | |||
760 | CONFIG_STRINGS=y | 760 | CONFIG_STRINGS=y |
761 | # CONFIG_TIME is not set | 761 | # CONFIG_TIME is not set |
762 | # CONFIG_TIMEOUT is not set | 762 | # CONFIG_TIMEOUT is not set |
763 | # CONFIG_TTYSIZE is not set | 763 | CONFIG_TTYSIZE=y |
764 | # CONFIG_VOLNAME is not set | 764 | # CONFIG_VOLNAME is not set |
765 | # CONFIG_WATCHDOG is not set | 765 | # CONFIG_WATCHDOG is not set |
766 | 766 | ||
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index b0fb0c0d4..8434cd2b7 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.26.0.git | 3 | # Busybox version: 1.26.0.git |
4 | # Thu Jul 7 14:45:07 2016 | 4 | # Tue Aug 2 15:42:24 2016 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -294,7 +294,7 @@ CONFIG_SORT=y | |||
294 | CONFIG_FEATURE_SORT_BIG=y | 294 | CONFIG_FEATURE_SORT_BIG=y |
295 | CONFIG_SPLIT=y | 295 | CONFIG_SPLIT=y |
296 | CONFIG_FEATURE_SPLIT_FANCY=y | 296 | CONFIG_FEATURE_SPLIT_FANCY=y |
297 | # CONFIG_STTY is not set | 297 | CONFIG_STTY=y |
298 | CONFIG_SUM=y | 298 | CONFIG_SUM=y |
299 | CONFIG_TAC=y | 299 | CONFIG_TAC=y |
300 | CONFIG_TAIL=y | 300 | CONFIG_TAIL=y |
@@ -760,7 +760,7 @@ CONFIG_MAN=y | |||
760 | CONFIG_STRINGS=y | 760 | CONFIG_STRINGS=y |
761 | # CONFIG_TIME is not set | 761 | # CONFIG_TIME is not set |
762 | # CONFIG_TIMEOUT is not set | 762 | # CONFIG_TIMEOUT is not set |
763 | # CONFIG_TTYSIZE is not set | 763 | CONFIG_TTYSIZE=y |
764 | # CONFIG_VOLNAME is not set | 764 | # CONFIG_VOLNAME is not set |
765 | # CONFIG_WATCHDOG is not set | 765 | # CONFIG_WATCHDOG is not set |
766 | 766 | ||
diff --git a/include/mingw.h b/include/mingw.h index 04700963c..729a08db0 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -178,6 +178,7 @@ int winansi_getc(FILE *stream); | |||
178 | #define getc winansi_getc | 178 | #define getc winansi_getc |
179 | 179 | ||
180 | int winansi_get_terminal_width_height(struct winsize *win); | 180 | int winansi_get_terminal_width_height(struct winsize *win); |
181 | int winansi_set_terminal_width_height(struct winsize *win); | ||
181 | 182 | ||
182 | /* | 183 | /* |
183 | * stdlib.h | 184 | * stdlib.h |
@@ -225,6 +226,7 @@ int ffs(int i); | |||
225 | */ | 226 | */ |
226 | 227 | ||
227 | #define TIOCGWINSZ 0x5413 | 228 | #define TIOCGWINSZ 0x5413 |
229 | #define TIOCSWINSZ 0x5414 | ||
228 | 230 | ||
229 | int ioctl(int fd, int code, ...); | 231 | int ioctl(int fd, int code, ...); |
230 | 232 | ||
diff --git a/win32/ioctl.c b/win32/ioctl.c index 73ceeedec..f3657966d 100644 --- a/win32/ioctl.c +++ b/win32/ioctl.c | |||
@@ -13,6 +13,10 @@ int ioctl(int fd UNUSED_PARAM, int code, ...) | |||
13 | arg = va_arg(ap, void *); | 13 | arg = va_arg(ap, void *); |
14 | ret = winansi_get_terminal_width_height((struct winsize *)arg); | 14 | ret = winansi_get_terminal_width_height((struct winsize *)arg); |
15 | break; | 15 | break; |
16 | case TIOCSWINSZ: | ||
17 | arg = va_arg(ap, void *); | ||
18 | ret = winansi_set_terminal_width_height((struct winsize *)arg); | ||
19 | break; | ||
16 | default: | 20 | default: |
17 | ret = -1; | 21 | ret = -1; |
18 | errno = EINVAL; | 22 | errno = EINVAL; |
diff --git a/win32/termios.c b/win32/termios.c index 658af4a26..108a746ef 100644 --- a/win32/termios.c +++ b/win32/termios.c | |||
@@ -1,13 +1,26 @@ | |||
1 | #include "libbb.h" | 1 | #include "libbb.h" |
2 | 2 | ||
3 | int tcsetattr(int fd UNUSED_PARAM, int mode UNUSED_PARAM, const struct termios *t UNUSED_PARAM) | 3 | static struct termios dummy = { |
4 | 0, /* c_iflag */ | ||
5 | 0, /* c_oflag */ | ||
6 | 0, /* c_cflag */ | ||
7 | 0, /* c_lflag */ | ||
8 | '\0', /* c_line */ | ||
9 | "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", /* c_cc[NCCS] */ | ||
10 | B9600, /* c_ispeed */ | ||
11 | B9600 /* c_ospeed */ | ||
12 | }; | ||
13 | |||
14 | int tcsetattr(int fd UNUSED_PARAM, int mode UNUSED_PARAM, const struct termios *t) | ||
4 | { | 15 | { |
5 | return -1; | 16 | dummy = *t; |
17 | return 0; | ||
6 | } | 18 | } |
7 | 19 | ||
8 | int tcgetattr(int fd UNUSED_PARAM, struct termios *t UNUSED_PARAM) | 20 | int tcgetattr(int fd UNUSED_PARAM, struct termios *t) |
9 | { | 21 | { |
10 | return -1; | 22 | *t = dummy; |
23 | return 0; | ||
11 | } | 24 | } |
12 | 25 | ||
13 | int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) | 26 | int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) |
@@ -81,3 +94,25 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) | |||
81 | SetConsoleMode(cin, mode); | 94 | SetConsoleMode(cin, mode); |
82 | return ret; | 95 | return ret; |
83 | } | 96 | } |
97 | |||
98 | speed_t cfgetispeed(const struct termios *termios_p) | ||
99 | { | ||
100 | return termios_p->c_ispeed; | ||
101 | } | ||
102 | |||
103 | speed_t cfgetospeed(const struct termios *termios_p) | ||
104 | { | ||
105 | return termios_p->c_ospeed; | ||
106 | } | ||
107 | |||
108 | int cfsetispeed(struct termios *termios_p, speed_t speed) | ||
109 | { | ||
110 | termios_p->c_ispeed = speed; | ||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | int cfsetospeed(struct termios *termios_p, speed_t speed) | ||
115 | { | ||
116 | termios_p->c_ospeed = speed; | ||
117 | return 0; | ||
118 | } | ||
diff --git a/win32/termios.h b/win32/termios.h index 011a37eb9..9255e0141 100644 --- a/win32/termios.h +++ b/win32/termios.h | |||
@@ -100,6 +100,18 @@ | |||
100 | #define B2400 0000013 | 100 | #define B2400 0000013 |
101 | #define B4800 0000014 | 101 | #define B4800 0000014 |
102 | #define B9600 0000015 | 102 | #define B9600 0000015 |
103 | #define CSIZE 0000060 | ||
104 | #define CS5 0000000 | ||
105 | #define CS6 0000020 | ||
106 | #define CS7 0000040 | ||
107 | #define CS8 0000060 | ||
108 | #define CSTOPB 0000100 | ||
109 | #define CREAD 0000200 | ||
110 | #define PARENB 0000400 | ||
111 | #define PARODD 0001000 | ||
112 | #define HUPCL 0002000 | ||
113 | #define CLOCAL 0004000 | ||
114 | |||
103 | 115 | ||
104 | typedef unsigned char cc_t; | 116 | typedef unsigned char cc_t; |
105 | typedef unsigned int tcflag_t; | 117 | typedef unsigned int tcflag_t; |
@@ -127,3 +139,8 @@ struct winsize { | |||
127 | int tcflush(int fd, int queue_selector); | 139 | int tcflush(int fd, int queue_selector); |
128 | int tcgetattr(int fd, struct termios *t); | 140 | int tcgetattr(int fd, struct termios *t); |
129 | int tcsetattr(int fd, int mode, const struct termios *t); | 141 | int tcsetattr(int fd, int mode, const struct termios *t); |
142 | |||
143 | speed_t cfgetispeed(const struct termios *termios_p); | ||
144 | speed_t cfgetospeed(const struct termios *termios_p); | ||
145 | int cfsetispeed(struct termios *termios_p, speed_t speed); | ||
146 | int cfsetospeed(struct termios *termios_p, speed_t speed); | ||
diff --git a/win32/winansi.c b/win32/winansi.c index c0493c77e..757a3509d 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -596,6 +596,23 @@ int winansi_get_terminal_width_height(struct winsize *win) | |||
596 | return ret ? 0 : -1; | 596 | return ret ? 0 : -1; |
597 | } | 597 | } |
598 | 598 | ||
599 | int winansi_set_terminal_width_height(struct winsize *win) | ||
600 | { | ||
601 | BOOL ret; | ||
602 | CONSOLE_SCREEN_BUFFER_INFOEX sbi; | ||
603 | |||
604 | init(); | ||
605 | |||
606 | sbi.cbSize = sizeof(sbi); | ||
607 | if ((ret=GetConsoleScreenBufferInfoEx(console, &sbi)) != 0) { | ||
608 | sbi.srWindow.Bottom = sbi.srWindow.Top + win->ws_row; | ||
609 | sbi.srWindow.Right = sbi.srWindow.Left + win->ws_col; | ||
610 | ret = SetConsoleScreenBufferInfoEx(console, &sbi); | ||
611 | } | ||
612 | |||
613 | return ret ? 0 : -1; | ||
614 | } | ||
615 | |||
599 | static int ansi_emulate_write(int fd, const void *buf, size_t count) | 616 | static int ansi_emulate_write(int fd, const void *buf, size_t count) |
600 | { | 617 | { |
601 | int rv = 0, i; | 618 | int rv = 0, i; |