summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2014-01-16 11:25:52 +0100
committerMartin Herkt <lachs0r@srsfckn.biz>2014-01-16 11:25:52 +0100
commit26d6eb4a8ab4052d7f873ca0cc2c6b68f3d41a44 (patch)
tree8b677e5faa3a478b48ff5106a2c3f19c8c8552a4 /osdep
parentd5fce546a416539d101a33226c1d4a9ffcd737d5 (diff)
downloadmpv-26d6eb4a8ab4052d7f873ca0cc2c6b68f3d41a44.tar.bz2
mpv-26d6eb4a8ab4052d7f873ca0cc2c6b68f3d41a44.tar.xz
io/win32: move mp_attach_console to terminal-win.c
Why didn't I put it there from the start?
Diffstat (limited to 'osdep')
-rw-r--r--osdep/io.c22
-rw-r--r--osdep/io.h1
-rw-r--r--osdep/terminal-win.c17
3 files changed, 17 insertions, 23 deletions
diff --git a/osdep/io.c b/osdep/io.c
index b348890533..2e2603eb7f 100644
--- a/osdep/io.c
+++ b/osdep/io.c
@@ -327,26 +327,4 @@ char *mp_getenv(const char *name)
return NULL;
}
-void mp_attach_console(void)
-{
- if (AttachConsole(ATTACH_PARENT_PROCESS)) {
- // We have been started by something with a console window.
- // Redirect output streams to that console's low-level handles,
- // so we can actually use WriteConsole later on.
-
- int hConHandle;
- intptr_t hStdio;
-
- hStdio = (intptr_t)GetStdHandle(STD_OUTPUT_HANDLE);
- hConHandle = _open_osfhandle(hStdio, _O_TEXT);
- *stdout = *_fdopen(hConHandle, "w");
- setvbuf(stdout, NULL, _IONBF, 0);
-
- hStdio = (intptr_t)GetStdHandle(STD_ERROR_HANDLE);
- hConHandle = _open_osfhandle(hStdio, _O_TEXT);
- *stderr = *_fdopen(hConHandle, "w");
- setvbuf(stderr, NULL, _IONBF, 0);
- }
-}
-
#endif // __MINGW32__
diff --git a/osdep/io.h b/osdep/io.h
index 7c20d262b0..9f715d904e 100644
--- a/osdep/io.h
+++ b/osdep/io.h
@@ -77,7 +77,6 @@ struct dirent *mp_readdir(DIR *dir);
int mp_closedir(DIR *dir);
int mp_mkdir(const char *path, int mode);
char *mp_getenv(const char *name);
-void mp_attach_console(void);
// NOTE: stat is not overridden with mp_stat, because MinGW-w64 defines it as
// macro.
diff --git a/osdep/terminal-win.c b/osdep/terminal-win.c
index 1ecb520f94..9d49936d70 100644
--- a/osdep/terminal-win.c
+++ b/osdep/terminal-win.c
@@ -24,6 +24,7 @@
#include "config.h"
+#include <fcntl.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
@@ -238,6 +239,22 @@ void terminal_set_foreground_color(FILE *stream, int c)
int terminal_init(void)
{
+ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
+ // We have been started by something with a console window.
+ // Redirect output streams to that console's low-level handles,
+ // so we can actually use WriteConsole later on.
+
+ int hConHandle;
+
+ hConHandle = _open_osfhandle((intptr_t)hSTDOUT, _O_TEXT);
+ *stdout = *_fdopen(hConHandle, "w");
+ setvbuf(stdout, NULL, _IONBF, 0);
+
+ hConHandle = _open_osfhandle((intptr_t)hSTDERR, _O_TEXT);
+ *stderr = *_fdopen(hConHandle, "w");
+ setvbuf(stderr, NULL, _IONBF, 0);
+ }
+
CONSOLE_SCREEN_BUFFER_INFO cinfo;
DWORD cmode = 0;
GetConsoleMode(hSTDOUT, &cmode);