diff options
author | Ron Yorston <rmy@pobox.com> | 2012-04-23 10:36:01 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-04-23 10:44:16 +0100 |
commit | 9e26feebb1f6752fa21f4680a744cdc688366be5 (patch) | |
tree | 579dac199ef3f83d56933df65e96f116f5f14cca | |
parent | ece4cb7f6debdb741b8a43053aeea817b80f49e7 (diff) | |
download | busybox-w32-9e26feebb1f6752fa21f4680a744cdc688366be5.tar.gz busybox-w32-9e26feebb1f6752fa21f4680a744cdc688366be5.tar.bz2 busybox-w32-9e26feebb1f6752fa21f4680a744cdc688366be5.zip |
win32: implement ioctl
-rw-r--r-- | include/mingw.h | 2 | ||||
-rw-r--r-- | libbb/xfuncs.c | 4 | ||||
-rw-r--r-- | win32/Kbuild | 1 | ||||
-rw-r--r-- | win32/ioctl.c | 24 | ||||
-rw-r--r-- | win32/winansi.c | 2 |
5 files changed, 27 insertions, 6 deletions
diff --git a/include/mingw.h b/include/mingw.h index b81a6e180..66296cfc8 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -183,7 +183,7 @@ void unsetenv(const char *env); | |||
183 | 183 | ||
184 | #define TIOCGWINSZ 0x5413 | 184 | #define TIOCGWINSZ 0x5413 |
185 | 185 | ||
186 | NOIMPL(ioctl,int fd UNUSED_PARAM, int code UNUSED_PARAM,...); | 186 | int ioctl(int fd, int code, ...); |
187 | 187 | ||
188 | /* | 188 | /* |
189 | * sys/socket.h | 189 | * sys/socket.h |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index e657820f3..23f27516f 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -262,11 +262,7 @@ int FAST_FUNC get_terminal_width_height(int fd, unsigned *width, unsigned *heigh | |||
262 | win.ws_col = 0; | 262 | win.ws_col = 0; |
263 | /* I've seen ioctl returning 0, but row/col is (still?) 0. | 263 | /* I've seen ioctl returning 0, but row/col is (still?) 0. |
264 | * We treat that as an error too. */ | 264 | * We treat that as an error too. */ |
265 | #if !ENABLE_PLATFORM_MINGW32 | ||
266 | err = ioctl(fd, TIOCGWINSZ, &win) != 0 || win.ws_row == 0; | 265 | err = ioctl(fd, TIOCGWINSZ, &win) != 0 || win.ws_row == 0; |
267 | #else | ||
268 | err = winansi_get_terminal_width_height(&win) == 0; | ||
269 | #endif | ||
270 | if (height) | 266 | if (height) |
271 | *height = wh_helper(win.ws_row, 24, "LINES", &err); | 267 | *height = wh_helper(win.ws_row, 24, "LINES", &err); |
272 | if (width) | 268 | if (width) |
diff --git a/win32/Kbuild b/win32/Kbuild index 42df86692..ceede0c67 100644 --- a/win32/Kbuild +++ b/win32/Kbuild | |||
@@ -6,6 +6,7 @@ lib-y:= | |||
6 | 6 | ||
7 | lib-$(CONFIG_PLATFORM_MINGW32) += env.o | 7 | lib-$(CONFIG_PLATFORM_MINGW32) += env.o |
8 | lib-$(CONFIG_PLATFORM_MINGW32) += fnmatch.o | 8 | lib-$(CONFIG_PLATFORM_MINGW32) += fnmatch.o |
9 | lib-$(CONFIG_PLATFORM_MINGW32) += ioctl.o | ||
9 | lib-$(CONFIG_PLATFORM_MINGW32) += mingw.o | 10 | lib-$(CONFIG_PLATFORM_MINGW32) += mingw.o |
10 | lib-$(CONFIG_PLATFORM_MINGW32) += process.o | 11 | lib-$(CONFIG_PLATFORM_MINGW32) += process.o |
11 | lib-$(CONFIG_PLATFORM_MINGW32) += regex.o | 12 | lib-$(CONFIG_PLATFORM_MINGW32) += regex.o |
diff --git a/win32/ioctl.c b/win32/ioctl.c new file mode 100644 index 000000000..73ceeedec --- /dev/null +++ b/win32/ioctl.c | |||
@@ -0,0 +1,24 @@ | |||
1 | #include "libbb.h" | ||
2 | |||
3 | int ioctl(int fd UNUSED_PARAM, int code, ...) | ||
4 | { | ||
5 | va_list ap; | ||
6 | void *arg; | ||
7 | int ret = -1; | ||
8 | |||
9 | va_start(ap, code); | ||
10 | |||
11 | switch (code) { | ||
12 | case TIOCGWINSZ: | ||
13 | arg = va_arg(ap, void *); | ||
14 | ret = winansi_get_terminal_width_height((struct winsize *)arg); | ||
15 | break; | ||
16 | default: | ||
17 | ret = -1; | ||
18 | errno = EINVAL; | ||
19 | break; | ||
20 | } | ||
21 | |||
22 | va_end(ap); | ||
23 | return ret; | ||
24 | } | ||
diff --git a/win32/winansi.c b/win32/winansi.c index 7730fd006..c923bde56 100644 --- a/win32/winansi.c +++ b/win32/winansi.c | |||
@@ -432,5 +432,5 @@ int winansi_get_terminal_width_height(struct winsize *win) | |||
432 | win->ws_col = sbi.srWindow.Right - sbi.srWindow.Left + 1; | 432 | win->ws_col = sbi.srWindow.Right - sbi.srWindow.Left + 1; |
433 | } | 433 | } |
434 | 434 | ||
435 | return ret; | 435 | return ret ? 0 : -1; |
436 | } | 436 | } |