aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-04-01 00:13:11 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-04-01 18:31:04 +0200
commita2495bd1ac9e5e54074d65616de0efa822a6309e (patch)
treee8a186b06bb4a94faafd7826b1ddc7c65112e824 /lib
parentb3f2636f44eea1a8b6fbf892d2daa611cff9d4af (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/compat/getline.c2
-rw-r--r--lib/sqfs/Makemodule.am2
-rw-r--r--lib/sqfs/comp/compressor.c4
-rw-r--r--lib/sqfs/libsqfs.vcxproj230
-rw-r--r--lib/sqfs/write_inode.c9
5 files changed, 235 insertions, 12 deletions
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 <stdlib.h>
#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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>16.0</VCProjectVersion>
+ <ProjectGuid>{7F732A8E-22A5-4DC1-B8DB-7091D37BE502}</ProjectGuid>
+ <RootNamespace>libsqfs</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+ <ProjectName>squashfs</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v142</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;WITH_GZIP;WITH_LZ4;NO_GZIP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <AdditionalIncludeDirectories>$(SolutionDir)\include;$(SolutionDir)\include\win32;$(SolutionDir)\lib\sqfs\comp\zlib;$(SolutionDir)\lib\sqfs\comp\lz4;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <CompileAs>CompileAsC</CompileAs>
+ <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;WITH_GZIP;WITH_LZ4;NO_GZIP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ <AdditionalIncludeDirectories>$(SolutionDir)\include;$(SolutionDir)\include\win32;$(SolutionDir)\lib\sqfs\comp\zlib;$(SolutionDir)\lib\sqfs\comp\lz4;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <CompileAs>CompileAsC</CompileAs>
+ <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\sqfs\block.h" />
+ <ClInclude Include="..\..\include\sqfs\block_processor.h" />
+ <ClInclude Include="..\..\include\sqfs\block_writer.h" />
+ <ClInclude Include="..\..\include\sqfs\compressor.h" />
+ <ClInclude Include="..\..\include\sqfs\data_reader.h" />
+ <ClInclude Include="..\..\include\sqfs\dir.h" />
+ <ClInclude Include="..\..\include\sqfs\dir_reader.h" />
+ <ClInclude Include="..\..\include\sqfs\dir_writer.h" />
+ <ClInclude Include="..\..\include\sqfs\error.h" />
+ <ClInclude Include="..\..\include\sqfs\frag_table.h" />
+ <ClInclude Include="..\..\include\sqfs\id_table.h" />
+ <ClInclude Include="..\..\include\sqfs\inode.h" />
+ <ClInclude Include="..\..\include\sqfs\io.h" />
+ <ClInclude Include="..\..\include\sqfs\meta_reader.h" />
+ <ClInclude Include="..\..\include\sqfs\meta_writer.h" />
+ <ClInclude Include="..\..\include\sqfs\predef.h" />
+ <ClInclude Include="..\..\include\sqfs\super.h" />
+ <ClInclude Include="..\..\include\sqfs\table.h" />
+ <ClInclude Include="..\..\include\sqfs\xattr.h" />
+ <ClInclude Include="..\..\include\sqfs\xattr_reader.h" />
+ <ClInclude Include="..\..\include\sqfs\xattr_writer.h" />
+ <ClInclude Include="..\..\include\win32\config.h" />
+ <ClInclude Include="block_processor\internal.h" />
+ <ClInclude Include="comp\internal.h" />
+ <ClInclude Include="comp\lz4\lz4.h" />
+ <ClInclude Include="comp\lz4\lz4hc.h" />
+ <ClInclude Include="comp\zlib\deflate.h" />
+ <ClInclude Include="comp\zlib\inffast.h" />
+ <ClInclude Include="comp\zlib\inffixed.h" />
+ <ClInclude Include="comp\zlib\inflate.h" />
+ <ClInclude Include="comp\zlib\inftrees.h" />
+ <ClInclude Include="comp\zlib\trees.h" />
+ <ClInclude Include="comp\zlib\zconf.h" />
+ <ClInclude Include="comp\zlib\zlib.h" />
+ <ClInclude Include="comp\zlib\zutil.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\util\alloc.c" />
+ <ClCompile Include="..\util\str_table.c" />
+ <ClCompile Include="..\util\xxhash.c" />
+ <ClCompile Include="block_processor\common.c" />
+ <ClCompile Include="block_processor\winpthread.c" />
+ <ClCompile Include="block_writer.c" />
+ <ClCompile Include="comp\compressor.c" />
+ <ClCompile Include="comp\gzip.c" />
+ <ClCompile Include="comp\lz4.c" />
+ <ClCompile Include="comp\lz4\lz4.c" />
+ <ClCompile Include="comp\lz4\lz4hc.c" />
+ <ClCompile Include="comp\zlib\adler32.c" />
+ <ClCompile Include="comp\zlib\deflate.c" />
+ <ClCompile Include="comp\zlib\inffast.c" />
+ <ClCompile Include="comp\zlib\inflate.c" />
+ <ClCompile Include="comp\zlib\inftrees.c" />
+ <ClCompile Include="comp\zlib\trees.c" />
+ <ClCompile Include="comp\zlib\zutil.c" />
+ <ClCompile Include="data_reader.c" />
+ <ClCompile Include="dir_reader.c" />
+ <ClCompile Include="dir_writer.c" />
+ <ClCompile Include="frag_table.c" />
+ <ClCompile Include="id_table.c" />
+ <ClCompile Include="inode.c" />
+ <ClCompile Include="meta_reader.c" />
+ <ClCompile Include="meta_writer.c" />
+ <ClCompile Include="readdir.c" />
+ <ClCompile Include="read_inode.c" />
+ <ClCompile Include="read_super.c" />
+ <ClCompile Include="read_table.c" />
+ <ClCompile Include="read_tree.c" />
+ <ClCompile Include="super.c" />
+ <ClCompile Include="win32\io_file.c" />
+ <ClCompile Include="write_inode.c" />
+ <ClCompile Include="write_super.c" />
+ <ClCompile Include="write_table.c" />
+ <ClCompile Include="xattr.c" />
+ <ClCompile Include="xattr_reader.c" />
+ <ClCompile Include="xattr_writer.c" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ 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 <string.h>
-#if defined(_WIN32) || defined(__WINDOWS__)
-# include <malloc.h>
-# ifdef _MSC_VER
-# define alloca _alloca
-# endif
-#else
-# include <alloca.h>
-#endif
-
static int write_block_sizes(sqfs_meta_writer_t *ir,
const sqfs_inode_generic_t *n)
{