summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Lhomme <robux4@ycbcr.xyz>2022-09-19 13:01:20 +0200
committerMartijn van Beurden <mvanb1@gmail.com>2022-09-20 11:51:05 +0200
commit020f5c3805bb95a7c77e7989d89da31eaa862d0e (patch)
tree73f5ee7893823dcf901d51ffe72e74d0718b3f33
parent71e23ab6b8b4cb353ce1259e88a25594d32b445b (diff)
downloadflac-020f5c3805bb95a7c77e7989d89da31eaa862d0e.tar.gz
disable console using on Universal Windows Platform builds
There's no support for the console. These functions cannot be used * GetStdHandle(): https://learn.microsoft.com/en-us/windows/console/getstdhandle * GetConsoleScreenBufferInfo(): https://learn.microsoft.com/en-us/windows/console/getconsolescreenbufferinfo * WriteConsoleW(): https://learn.microsoft.com/en-us/windows/console/writeconsole Instead send logs to the debug output
-rw-r--r--src/share/win_utf8_io/win_utf8_io.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/share/win_utf8_io/win_utf8_io.c b/src/share/win_utf8_io/win_utf8_io.c
index 41923c35..120d1ec7 100644
--- a/src/share/win_utf8_io/win_utf8_io.c
+++ b/src/share/win_utf8_io/win_utf8_io.c
@@ -177,16 +177,19 @@ size_t strlen_utf8(const char *str)
int win_get_console_width(void)
{
int width = 80;
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if(hOut != INVALID_HANDLE_VALUE && hOut != NULL)
if (GetConsoleScreenBufferInfo(hOut, &csbi) != 0)
width = csbi.dwSize.X;
+#endif // WINAPI_PARTITION_DESKTOP
return width;
}
/* print functions */
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
{
DWORD out;
@@ -216,6 +219,7 @@ static int wprint_console(FILE *stream, const wchar_t *text, size_t len)
return ret;
return len;
}
+#endif // WINAPI_PARTITION_DESKTOP
int printf_utf8(const char *format, ...)
{
@@ -256,7 +260,12 @@ int vfprintf_utf8(FILE *stream, const char *format, va_list argptr)
ret = -1;
break;
}
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
ret = wprint_console(stream, wout, wcslen(wout));
+#else // !WINAPI_PARTITION_DESKTOP
+ OutputDebugStringW(wout);
+ ret = 0;
+#endif // !WINAPI_PARTITION_DESKTOP
} while(0);
free(utmp);