From ce188d4d7f3b9ad04867c49b424e8497c2ade92b Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 14 May 2019 08:58:52 +0100 Subject: add CHD support. --- .../flac-1.3.2/src/share/win_utf8_io/Makefile.lite | 21 ++ .../flac-1.3.2/src/share/win_utf8_io/win_utf8_io.c | 253 +++++++++++++++++++++ .../share/win_utf8_io/win_utf8_io_static.vcproj | 174 ++++++++++++++ .../share/win_utf8_io/win_utf8_io_static.vcxproj | 140 ++++++++++++ .../win_utf8_io/win_utf8_io_static.vcxproj.filters | 22 ++ 5 files changed, 610 insertions(+) create mode 100644 deps/flac-1.3.2/src/share/win_utf8_io/Makefile.lite create mode 100644 deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io.c create mode 100644 deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcproj create mode 100644 deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj create mode 100644 deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj.filters (limited to 'deps/flac-1.3.2/src/share/win_utf8_io') diff --git a/deps/flac-1.3.2/src/share/win_utf8_io/Makefile.lite b/deps/flac-1.3.2/src/share/win_utf8_io/Makefile.lite new file mode 100644 index 0000000..1549266 --- /dev/null +++ b/deps/flac-1.3.2/src/share/win_utf8_io/Makefile.lite @@ -0,0 +1,21 @@ +# +# GNU makefile +# + +topdir = ../../.. + +ifeq ($(OS),Darwin) + EXPLICIT_LIBS = $(libdir)/libFLAC.a $(OGG_EXPLICIT_LIBS) -lm +else + LIBS = -lFLAC $(OGG_LIBS) -lm +endif + +LIB_NAME = libwin_utf8_io +INCLUDES = -I$(topdir)/include + +SRCS_C = \ + win_utf8_io.c + +include $(topdir)/build/lib.mk + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io.c b/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io.c new file mode 100644 index 0000000..c61d27f --- /dev/null +++ b/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io.c @@ -0,0 +1,253 @@ +/* libFLAC - Free Lossless Audio Codec library + * Copyright (C) 2013-2016 Xiph.Org Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include "share/win_utf8_io.h" +#include "share/windows_unicode_filenames.h" + +#define UTF8_BUFFER_SIZE 32768 + +static int local_vsnprintf(char *str, size_t size, const char *fmt, va_list va) +{ + int rc; + +#if defined _MSC_VER + if (size == 0) + return 1024; + rc = vsnprintf_s(str, size, _TRUNCATE, fmt, va); + if (rc < 0) + rc = size - 1; +#elif defined __MINGW32__ + rc = __mingw_vsnprintf(str, size, fmt, va); +#else + rc = vsnprintf(str, size, fmt, va); +#endif + + return rc; +} + +/* convert WCHAR stored Unicode string to UTF-8. Caller is responsible for freeing memory */ +static char *utf8_from_wchar(const wchar_t *wstr) +{ + char *utf8str; + int len; + + if (!wstr) + return NULL; + if ((len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL)) == 0) + return NULL; + if ((utf8str = (char *)malloc(len)) == NULL) + return NULL; + if (WideCharToMultiByte(CP_UTF8, 0, wstr, -1, utf8str, len, NULL, NULL) == 0) { + free(utf8str); + utf8str = NULL; + } + + return utf8str; +} + +/* convert UTF-8 back to WCHAR. Caller is responsible for freeing memory */ +static wchar_t *wchar_from_utf8(const char *str) +{ + wchar_t *widestr; + int len; + + if (!str) + return NULL; + if ((len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0)) == 0) + return NULL; + if ((widestr = (wchar_t *)malloc(len*sizeof(wchar_t))) == NULL) + return NULL; + if (MultiByteToWideChar(CP_UTF8, 0, str, -1, widestr, len) == 0) { + free(widestr); + widestr = NULL; + } + + return widestr; +} + +/* retrieve WCHAR commandline, expand wildcards and convert everything to UTF-8 */ +int get_utf8_argv(int *argc, char ***argv) +{ + typedef int (__cdecl *wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*); + wgetmainargs_t wgetmainargs; + HMODULE handle; + int wargc; + wchar_t **wargv; + wchar_t **wenv; + char **utf8argv; + int ret, i; + + if ((handle = LoadLibrary("msvcrt.dll")) == NULL) return 1; + if ((wgetmainargs = (wgetmainargs_t)GetProcAddress(handle, "__wgetmainargs")) == NULL) { + FreeLibrary(handle); + return 1; + } + i = 0; + /* when the 4th argument is 1, __wgetmainargs expands wildcards but also erroneously converts \\?\c:\path\to\file.flac to \\file.flac */ + if (wgetmainargs(&wargc, &wargv, &wenv, 1, &i) != 0) { + FreeLibrary(handle); + return 1; + } + if ((utf8argv = (char **)calloc(wargc, sizeof(char*))) == NULL) { + FreeLibrary(handle); + return 1; + } + + ret = 0; + for (i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj b/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj new file mode 100644 index 0000000..aa9a3ee --- /dev/null +++ b/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {4cefbe02-c215-11db-8314-0800200c9a66} + win_utf8_io_static + Win32Proj + + + + StaticLibrary + true + + + StaticLibrary + true + + + StaticLibrary + + + StaticLibrary + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>12.0.30501.0 + + + $(SolutionDir)objs\$(Configuration)\lib\ + + + $(SolutionDir)objs\$(Platform)\$(Configuration)\lib\ + + + $(SolutionDir)objs\$(Configuration)\lib\ + + + $(SolutionDir)objs\$(Platform)\$(Configuration)\lib\ + + + + Disabled + .\include;..\..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Level3 + ProgramDatabase + Default + 4267;4996;%(DisableSpecificWarnings) + + + + + Disabled + .\include;..\..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;FLAC__NO_DLL;DEBUG;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Level3 + ProgramDatabase + Default + 4267;4996;%(DisableSpecificWarnings) + + + + + true + Speed + true + true + .\include;..\..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;FLAC__NO_DLL;%(PreprocessorDefinitions) + MultiThreaded + false + Level3 + ProgramDatabase + Default + 4267;4996;%(DisableSpecificWarnings) + + + + + true + Speed + true + true + .\include;..\..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;FLAC__NO_DLL;%(PreprocessorDefinitions) + MultiThreaded + false + Level3 + ProgramDatabase + Default + 4267;4996;%(DisableSpecificWarnings) + + + + + + + + + + + + \ No newline at end of file diff --git a/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj.filters b/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj.filters new file mode 100644 index 0000000..e44a0c7 --- /dev/null +++ b/deps/flac-1.3.2/src/share/win_utf8_io/win_utf8_io_static.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {6469e7f2-0837-4004-9f36-27d45ed62336} + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + Public Header Files + + + + + Source Files + + + \ No newline at end of file -- cgit v1.2.3