From a2495bd1ac9e5e54074d65616de0efa822a6309e Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 1 Apr 2020 00:13:11 +0200 Subject: Add preliminary VisualStudio support - Mostly workarounds/clutches in compat.h - Change getline return type to int - Replace C99 style flexible array with alloca - Add all the MSVC solution/project crap Signed-off-by: David Oberhollenzer --- lib/compat/getline.c | 2 +- lib/sqfs/Makemodule.am | 2 + lib/sqfs/comp/compressor.c | 4 +- lib/sqfs/libsqfs.vcxproj | 230 +++++++++++++++++++++++++++++++++++++++++++++ lib/sqfs/write_inode.c | 9 -- 5 files changed, 235 insertions(+), 12 deletions(-) create mode 100644 lib/sqfs/libsqfs.vcxproj (limited to 'lib') diff --git a/lib/compat/getline.c b/lib/compat/getline.c index e63c50e..d7e456b 100644 --- a/lib/compat/getline.c +++ b/lib/compat/getline.c @@ -11,7 +11,7 @@ #include #ifndef HAVE_GETLINE -ssize_t getline(char **line, size_t *n, FILE *fp) +int getline(char **line, size_t *n, FILE *fp) { size_t new_cap, len = 0, cap = 0; char *buffer = NULL, *new; diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am index 942c37c..6786ee2 100644 --- a/lib/sqfs/Makemodule.am +++ b/lib/sqfs/Makemodule.am @@ -113,3 +113,5 @@ lib_LTLIBRARIES += libsquashfs.la pkgconfig_DATA += lib/sqfs/libsquashfs0.pc EXTRA_DIST += lib/sqfs/comp/lz4/README lib/sqfs/comp/zlib/README +EXTRA_DIST += lib/sqfs/libsqfs.vcxproj +EXTRA_DIST += include/win32/config.h diff --git a/lib/sqfs/comp/compressor.c b/lib/sqfs/comp/compressor.c index 946ee25..2294b98 100644 --- a/lib/sqfs/comp/compressor.c +++ b/lib/sqfs/comp/compressor.c @@ -42,7 +42,7 @@ static const char *names[] = { int sqfs_generic_write_options(sqfs_file_t *file, const void *data, size_t size) { - sqfs_u8 buffer[size + 2]; + sqfs_u8 *buffer = alloca(size + 2); int ret; *((sqfs_u16 *)buffer) = htole16(0x8000 | size); @@ -58,7 +58,7 @@ int sqfs_generic_write_options(sqfs_file_t *file, const void *data, size_t size) int sqfs_generic_read_options(sqfs_file_t *file, void *data, size_t size) { - sqfs_u8 buffer[size + 2]; + sqfs_u8 *buffer = alloca(size + 2); int ret; ret = file->read_at(file, sizeof(sqfs_super_t), diff --git a/lib/sqfs/libsqfs.vcxproj b/lib/sqfs/libsqfs.vcxproj new file mode 100644 index 0000000..176ba20 --- /dev/null +++ b/lib/sqfs/libsqfs.vcxproj @@ -0,0 +1,230 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {7F732A8E-22A5-4DC1-B8DB-7091D37BE502} + libsqfs + 10.0 + squashfs + + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(Configuration)\ + + + true + + + false + $(SolutionDir)$(Configuration)\ + + + false + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;WITH_GZIP;WITH_LZ4;NO_GZIP;%(PreprocessorDefinitions) + true + $(SolutionDir)\include;$(SolutionDir)\include\win32;$(SolutionDir)\lib\sqfs\comp\zlib;$(SolutionDir)\lib\sqfs\comp\lz4;%(AdditionalIncludeDirectories) + CompileAsC + $(IntDir)%(RelativeDir) + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;WITH_GZIP;WITH_LZ4;NO_GZIP;%(PreprocessorDefinitions) + true + $(SolutionDir)\include;$(SolutionDir)\include\win32;$(SolutionDir)\lib\sqfs\comp\zlib;$(SolutionDir)\lib\sqfs\comp\lz4;%(AdditionalIncludeDirectories) + CompileAsC + $(IntDir)%(RelativeDir) + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c index 787c4b5..d27d1b4 100644 --- a/lib/sqfs/write_inode.c +++ b/lib/sqfs/write_inode.c @@ -15,15 +15,6 @@ #include -#if defined(_WIN32) || defined(__WINDOWS__) -# include -# ifdef _MSC_VER -# define alloca _alloca -# endif -#else -# include -#endif - static int write_block_sizes(sqfs_meta_writer_t *ir, const sqfs_inode_generic_t *n) { -- cgit v1.2.3