From: larrybr Date: Mon, 20 Sep 2021 20:15:28 +0000 (+0000) Subject: Allow fileio extension to be a stand-alone DLL for Win32 X-Git-Tag: version-3.37.0~215 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d9974342345fc159b0053e0a51adb48f6366e23;p=thirdparty%2Fsqlite.git Allow fileio extension to be a stand-alone DLL for Win32 FossilOrigin-Name: d1cc3105b2baceb9f426fd6bc8d8317de3af09a0f02517715bd292c68e282fa1 --- diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index d977d41ddc..deb714cee8 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -72,6 +72,11 @@ ** $path is a relative path, then $path is interpreted relative to $dir. ** And the paths returned in the "name" column of the table are also ** relative to directory $dir. +** +** Notes on building this extension for Windows: +** Unless linked statically with the SQLite library, a preprocessor +** symbol, FILEIO_WIN32_DLL, must be #define'd to create a stand-alone +** DLL form of this extension for WIN32. See its use below for details. */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 @@ -225,6 +230,22 @@ static sqlite3_uint64 fileTimeToUnixTime( return (fileIntervals.QuadPart - epochIntervals.QuadPart) / 10000000; } + +#if defined(FILEIO_WIN32_DLL) && (defined(_WIN32) || defined(WIN32)) +# /* To allow a standalone DLL, use this next replacement function: */ +# undef sqlite3_win32_utf8_to_unicode +# define sqlite3_win32_utf8_to_unicode utf8_to_utf16 +# +LPWSTR utf8_to_utf16(const char *z){ + int nAllot = MultiByteToWideChar(CP_UTF8, 0, z, -1, NULL, 0); + LPWSTR rv = malloc(nAllot * sizeof(WCHAR)); + if( rv!=0 && 0 < MultiByteToWideChar(CP_UTF8, 0, z, -1, rv, nAllot) ) + return rv; + free(rv); + return 0; +} +#endif + /* ** This function attempts to normalize the time values found in the stat() ** buffer to UTC. This is necessary on Win32, where the runtime library @@ -998,3 +1019,17 @@ int sqlite3_fileio_init( } return rc; } + +#if defined(FILEIO_WIN32_DLL) && (defined(_WIN32) || defined(WIN32)) + /* To allow a standalone DLL, make test_windirent.c take these next + * 3 functions from C runtime instead of from SQLite library: */ +# undef sqlite3_malloc +# define sqlite3_malloc malloc +# undef sqlite3_free +# define sqlite3_free free +# undef sqlite3_stricmp +# define sqlite3_stricmp stricmp + /* Just pull in this .c so above redefines take said effect. As a + * side-effect, this extension becomes a single translation unit. */ +# include "test_windirent.c" +#endif diff --git a/manifest b/manifest index d3509e1aa8..33f095e45c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Further\stests\sfor\slegacy\srtree\sgeom\scallbacks. -D 2021-09-18T16:15:54.996 +C Allow\sfileio\sextension\sto\sbe\sa\sstand-alone\sDLL\sfor\sWin32 +D 2021-09-20T20:15:28.135 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -301,7 +301,7 @@ F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f82 F ext/misc/decimal.c 09f967dcf4a1ee35a76309829308ec278d3648168733f4a1147820e11ebefd12 F ext/misc/eval.c 04bc9aada78c888394204b4ed996ab834b99726fb59603b0ee3ed6e049755dc1 F ext/misc/explain.c 0086fab288d4352ea638cf40ac382aad3b0dc5e845a1ea829a694c015fd970fe -F ext/misc/fileio.c 9b69e25da3b51d4a1d905a464ccb96709792ad627a742ba09215bc0d1447e7bd +F ext/misc/fileio.c 896dcad10a0c584647995b4aa2be7f5802b02fb237171f6a394ea89f264d7053 F ext/misc/fossildelta.c 1240b2d3e52eab1d50c160c7fe1902a9bd210e052dc209200a750bbf885402d5 F ext/misc/fuzzer.c eae560134f66333e9e1ca4c8ffea75df42056e2ce8456734565dbe1c2a92bf3d F ext/misc/ieee754.c cd6ab89f85fda8a020559b3f4d03001a8a62dd856beda5af3f558621d12be913 @@ -1925,7 +1925,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 929bcc4098549692c573779d65c4c28027b0a2f48ebbf5b3f038deee24374b67 -R b53a2568f9f1adf1f421cbce84f79cd1 -U dan -Z 0f8167edfa350ba64179ebda312bfead +P 99d6bb22e8735681443bfe67287aa15ce2c57d0d63e304abf8aa01fde50dd021 +R afb4d54eb24c4692fcc97528588cab39 +U larrybr +Z 5b9c18b20b82047bc497d18ca81df306 diff --git a/manifest.uuid b/manifest.uuid index bd0f76d7b3..9a59a58df5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -99d6bb22e8735681443bfe67287aa15ce2c57d0d63e304abf8aa01fde50dd021 \ No newline at end of file +d1cc3105b2baceb9f426fd6bc8d8317de3af09a0f02517715bd292c68e282fa1 \ No newline at end of file