From 3291d04cecdbc2762b23b53423378d0e9fe939e4 Mon Sep 17 00:00:00 2001 From: caixiangyue <caixiangyue007@gmail.com> Date: Fri, 1 Nov 2019 14:58:00 +0800 Subject: [PATCH] libsearpc portable visual studio --- lib/searpc-named-pipe-transport.c | 16 ++-- lib/searpc-utils.c | 1 - libsearpc.sln | 31 ++++++++ libsearpc.vcxproj | 118 ++++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 9 deletions(-) create mode 100644 libsearpc.sln create mode 100644 libsearpc.vcxproj diff --git a/lib/searpc-named-pipe-transport.c b/lib/searpc-named-pipe-transport.c index b3b0cd5..ccb85fc 100644 --- a/lib/searpc-named-pipe-transport.c +++ b/lib/searpc-named-pipe-transport.c @@ -43,8 +43,8 @@ static int request_from_json (const char *content, size_t len, char **service, c static void json_object_set_string_member (json_t *object, const char *key, const char *value); static const char * json_object_get_string_member (json_t *object, const char *key); -static ssize_t pipe_write_n(SearpcNamedPipe fd, const void *vptr, size_t n); -static ssize_t pipe_read_n(SearpcNamedPipe fd, void *vptr, size_t n); +static gssize pipe_write_n(SearpcNamedPipe fd, const void *vptr, size_t n); +static gssize pipe_read_n(SearpcNamedPipe fd, void *vptr, size_t n); typedef struct { SearpcNamedPipeClient* client; @@ -481,11 +481,11 @@ json_object_get_string_member (json_t *object, const char *key) #if !defined(WIN32) // Write "n" bytes to a descriptor. -ssize_t +gssize pipe_write_n(int fd, const void *vptr, size_t n) { size_t nleft; - ssize_t nwritten; + gssize nwritten; const char *ptr; ptr = vptr; @@ -506,11 +506,11 @@ pipe_write_n(int fd, const void *vptr, size_t n) } // Read "n" bytes from a descriptor. -ssize_t +gssize pipe_read_n(int fd, void *vptr, size_t n) { size_t nleft; - ssize_t nread; + gssize nread; char *ptr; ptr = vptr; @@ -532,7 +532,7 @@ pipe_read_n(int fd, void *vptr, size_t n) #else // !defined(WIN32) -ssize_t pipe_read_n (SearpcNamedPipe fd, void *vptr, size_t n) +gssize pipe_read_n (SearpcNamedPipe fd, void *vptr, size_t n) { DWORD bytes_read; BOOL success = ReadFile( @@ -553,7 +553,7 @@ ssize_t pipe_read_n (SearpcNamedPipe fd, void *vptr, size_t n) return n; } -ssize_t pipe_write_n(SearpcNamedPipe fd, const void *vptr, size_t n) +gssize pipe_write_n(SearpcNamedPipe fd, const void *vptr, size_t n) { DWORD bytes_written; BOOL success = WriteFile( diff --git a/lib/searpc-utils.c b/lib/searpc-utils.c index c7345e7..a00417d 100644 --- a/lib/searpc-utils.c +++ b/lib/searpc-utils.c @@ -1,5 +1,4 @@ #include <errno.h> -#include <unistd.h> #include <glib.h> #include <glib-object.h> #include <jansson.h> diff --git a/libsearpc.sln b/libsearpc.sln new file mode 100644 index 0000000..d277e98 --- /dev/null +++ b/libsearpc.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29215.179 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsearpc", "libsearpc.vcxproj", "{7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Debug|x64.ActiveCfg = Debug|x64 + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Debug|x64.Build.0 = Debug|x64 + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Debug|x86.ActiveCfg = Debug|Win32 + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Debug|x86.Build.0 = Debug|Win32 + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Release|x64.ActiveCfg = Release|x64 + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Release|x64.Build.0 = Release|x64 + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Release|x86.ActiveCfg = Release|Win32 + {7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {393C05AB-0CCA-4180-93EF-57D9CB079042} + EndGlobalSection +EndGlobal diff --git a/libsearpc.vcxproj b/libsearpc.vcxproj new file mode 100644 index 0000000..883a341 --- /dev/null +++ b/libsearpc.vcxproj @@ -0,0 +1,118 @@ +<?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>{7E7BDAA2-D61E-466D-B138-CC2454CAB1D3}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </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> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v142</PlatformToolset> + </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> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <Optimization>Disabled</Optimization> + </ClCompile> + <Link> + <TargetMachine>MachineX86</TargetMachine> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <WarningLevel>Level3</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + </ClCompile> + <Link> + <TargetMachine>MachineX86</TargetMachine> + <GenerateDebugInformation>true</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="lib\searpc-client.c" /> + <ClCompile Include="lib\searpc-named-pipe-transport.c" /> + <ClCompile Include="lib\searpc-server.c" /> + <ClCompile Include="lib\searpc-utils.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="config.h" /> + <ClInclude Include="lib\searpc-client.h" /> + <ClInclude Include="lib\searpc-named-pipe-transport.h" /> + <ClInclude Include="lib\searpc-server.h" /> + <ClInclude Include="lib\searpc-utils.h" /> + <ClInclude Include="lib\searpc.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file