aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-04-23 10:36:01 +0100
committerRon Yorston <rmy@pobox.com>2012-04-23 10:44:16 +0100
commit9e26feebb1f6752fa21f4680a744cdc688366be5 (patch)
tree579dac199ef3f83d56933df65e96f116f5f14cca /win32
parentece4cb7f6debdb741b8a43053aeea817b80f49e7 (diff)
downloadbusybox-w32-9e26feebb1f6752fa21f4680a744cdc688366be5.tar.gz
busybox-w32-9e26feebb1f6752fa21f4680a744cdc688366be5.tar.bz2
busybox-w32-9e26feebb1f6752fa21f4680a744cdc688366be5.zip
win32: implement ioctl
Diffstat (limited to 'win32')
-rw-r--r--win32/Kbuild1
-rw-r--r--win32/ioctl.c24
-rw-r--r--win32/winansi.c2
3 files changed, 26 insertions, 1 deletions
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
7lib-$(CONFIG_PLATFORM_MINGW32) += env.o 7lib-$(CONFIG_PLATFORM_MINGW32) += env.o
8lib-$(CONFIG_PLATFORM_MINGW32) += fnmatch.o 8lib-$(CONFIG_PLATFORM_MINGW32) += fnmatch.o
9lib-$(CONFIG_PLATFORM_MINGW32) += ioctl.o
9lib-$(CONFIG_PLATFORM_MINGW32) += mingw.o 10lib-$(CONFIG_PLATFORM_MINGW32) += mingw.o
10lib-$(CONFIG_PLATFORM_MINGW32) += process.o 11lib-$(CONFIG_PLATFORM_MINGW32) += process.o
11lib-$(CONFIG_PLATFORM_MINGW32) += regex.o 12lib-$(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
3int 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}