增加立思辰定制websdk
This commit is contained in:
parent
a8bd4fee99
commit
2b976c6c2a
|
@ -58,6 +58,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HGScannerLib", "HGScannerLi
|
||||||
{4909ACEA-80FF-482E-9FA2-5E8534789A82} = {4909ACEA-80FF-482E-9FA2-5E8534789A82}
|
{4909ACEA-80FF-482E-9FA2-5E8534789A82} = {4909ACEA-80FF-482E-9FA2-5E8534789A82}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HGWebScan", "HGWebScan\HGWebScan.vcxproj", "{2A4A0C71-D333-4978-B7C4-08401230E0A5}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{F85F4457-1B42-46E7-BA86-F088D6D5994F} = {F85F4457-1B42-46E7-BA86-F088D6D5994F}
|
||||||
|
{5D85F2AC-FACD-436C-A67B-E13056DD0C03} = {5D85F2AC-FACD-436C-A67B-E13056DD0C03}
|
||||||
|
{4909ACEA-80FF-482E-9FA2-5E8534789A82} = {4909ACEA-80FF-482E-9FA2-5E8534789A82}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
|
@ -230,6 +237,22 @@ Global
|
||||||
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x64.Build.0 = Release|x64
|
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x64.Build.0 = Release|x64
|
||||||
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x86.ActiveCfg = Release|Win32
|
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x86.Build.0 = Release|Win32
|
{62CAD8E9-4461-49A1-8EB8-4CEBE113FE02}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.HWRelease|x64.ActiveCfg = HWRelease|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.HWRelease|x64.Build.0 = HWRelease|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.HWRelease|x86.ActiveCfg = HWRelease|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.HWRelease|x86.Build.0 = HWRelease|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.LSCRelease|x64.ActiveCfg = LSCRelease|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.LSCRelease|x64.Build.0 = LSCRelease|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.LSCRelease|x86.ActiveCfg = LSCRelease|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.LSCRelease|x86.Build.0 = LSCRelease|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Release|x64.Build.0 = Release|x64
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{2A4A0C71-D333-4978-B7C4-08401230E0A5}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -0,0 +1,353 @@
|
||||||
|
<?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="HWRelease|Win32">
|
||||||
|
<Configuration>HWRelease</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="HWRelease|x64">
|
||||||
|
<Configuration>HWRelease</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="LSCRelease|Win32">
|
||||||
|
<Configuration>LSCRelease</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="LSCRelease|x64">
|
||||||
|
<Configuration>LSCRelease</Configuration>
|
||||||
|
<Platform>x64</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>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\sdk\webscan\HttpHead.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\sdk\webscan\main.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\sdk\webscan\MsgPumpCallback.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\sdk\webscan\WebServer.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\sdk\webscan\WebUser.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\third_party\base64\base64.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\third_party\json\cJSON.c" />
|
||||||
|
<ClCompile Include="..\..\..\third_party\sha1\sha1.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\utility\HGString.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\..\sdk\webscan\HttpHead.h" />
|
||||||
|
<ClInclude Include="..\..\..\sdk\webscan\Msg.h" />
|
||||||
|
<ClInclude Include="..\..\..\sdk\webscan\MsgPumpCallback.h" />
|
||||||
|
<ClInclude Include="..\..\..\sdk\webscan\WebServer.h" />
|
||||||
|
<ClInclude Include="..\..\..\sdk\webscan\WebUser.h" />
|
||||||
|
<ClInclude Include="..\..\..\third_party\base64\base64.h" />
|
||||||
|
<ClInclude Include="..\..\..\third_party\json\cJSON.h" />
|
||||||
|
<ClInclude Include="..\..\..\third_party\sha1\sha1.h" />
|
||||||
|
<ClInclude Include="..\..\..\utility\HGString.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{2A4A0C71-D333-4978-B7C4-08401230E0A5}</ProjectGuid>
|
||||||
|
<RootNamespace>HGWebScan</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</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>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|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 Condition="'$(Configuration)|$(Platform)'=='HWRelease|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|Win32'" Label="PropertySheets">
|
||||||
|
<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>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|x64'" Label="PropertySheets">
|
||||||
|
<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>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>HWWebScan</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>LSCWebScan</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>HWWebScan</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<TargetName>LSCWebScan</TargetName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<DisableSpecificWarnings>28251;26812;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../Debug/HGBase.lib;../Debug/HGImgFmt.lib;../Debug/HGImgProc.lib;../../../../sdk/lib/win/x86/OEM/huagao/sane.lib;../../../third_party/zlib/windows/lib/x86/zlib.lib;../../../third_party/libzip/windows/lib/x86/zip.lib;../../../third_party/libcurl/windows/lib/x86/libcurld.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4098,4099,4075 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../Release/HGBase.lib;../Release/HGImgFmt.lib;../Release/HGImgProc.lib;../../../../sdk/lib/win/x86/OEM/huagao/sane.lib;../../../third_party/zlib/windows/lib/x86/zlib.lib;../../../third_party/libzip/windows/lib/x86/zip.lib;../../../third_party/libcurl/windows/lib/x86/libcurl.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy $(OutDir)HGWebScan.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_HANWANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../HWRelease/HWBase.lib;../HWRelease/HWImgFmt.lib;../HWRelease/HWImgProc.lib;../../../../sdk/lib/win/x86/OEM/hanvon/sane.lib;../../../third_party/zlib/windows/lib/x86/zlib.lib;../../../third_party/libzip/windows/lib/x86/zip.lib;../../../third_party/libcurl/windows/lib/x86/libcurl.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy $(OutDir)HWWebScan.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_LISICHENG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../LSCRelease/LSCBase.lib;../LSCRelease/LSCImgFmt.lib;../LSCRelease/LSCImgProc.lib;../../../../sdk/lib/win/x86/OEM/lanxum/sane.lib;../../../third_party/zlib/windows/lib/x86/zlib.lib;../../../third_party/libzip/windows/lib/x86/zip.lib;../../../third_party/libcurl/windows/lib/x86/libcurl.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy $(OutDir)LSCWebScan.exe $(SolutionDir)..\..\..\release\win\x86\Release\</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../x64/Debug/HGBase.lib;../x64/Debug/HGImgFmt.lib;../x64/Debug/HGImgProc.lib;../../../../sdk/lib/win/x64/OEM/huagao/sane.lib;../../../third_party/zlib/windows/lib/x64/zlib.lib;../../../third_party/libzip/windows/lib/x64/zip.lib;../../../third_party/libcurl/windows/lib/x64/libcurld.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4098,4099,4075 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_HUAGAO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../x64/Release/HGBase.lib;../x64/Release/HGImgFmt.lib;../x64/Release/HGImgProc.lib;../../../../sdk/lib/win/x64/OEM/huagao/sane.lib;../../../third_party/zlib/windows/lib/x64/zlib.lib;../../../third_party/libzip/windows/lib/x64/zip.lib;../../../third_party/libcurl/windows/lib/x64/libcurl.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy $(OutDir)HGWebScan.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='HWRelease|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_HANWANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../x64/HWRelease/HWBase.lib;../x64/HWRelease/HWImgFmt.lib;../x64/HWRelease/HWImgProc.lib;../../../../sdk/lib/win/x64/OEM/hanvon/sane.lib;../../../third_party/zlib/windows/lib/x64/zlib.lib;../../../third_party/libzip/windows/lib/x64/zip.lib;../../../third_party/libcurl/windows/lib/x64/libcurl.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy $(OutDir)HWWebScan.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='LSCRelease|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;ZIP_STATIC;CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS;OEM_LISICHENG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<AdditionalIncludeDirectories>../../../modules/;../../../third_party/sha1/;../../../third_party/base64/;../../../third_party/json/;../../../third_party/sqlite/;../../../utility/;../../../third_party/libzip/windows/include/;../../../third_party/libcurl/windows/include/;../../../../sdk/include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>../x64/LSCRelease/LSCBase.lib;../x64/LSCRelease/LSCImgFmt.lib;../x64/LSCRelease/LSCImgProc.lib;../../../../sdk/lib/win/x64/OEM/lanxum/sane.lib;../../../third_party/zlib/windows/lib/x64/zlib.lib;../../../third_party/libzip/windows/lib/x64/zip.lib;../../../third_party/libcurl/windows/lib/x64/libcurl.lib;wldap32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>copy $(OutDir)LSCWebScan.exe $(SolutionDir)..\..\..\release\win\x64\Release\</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,438 @@
|
||||||
|
#include "HttpHead.h"
|
||||||
|
|
||||||
|
const unsigned int asciiTableData[256] =
|
||||||
|
{
|
||||||
|
0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
|
||||||
|
0x004, 0x104, 0x104, 0x004, 0x104, 0x104, 0x004, 0x004,
|
||||||
|
0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
|
||||||
|
0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
|
||||||
|
0x140, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
|
||||||
|
0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
|
||||||
|
0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459,
|
||||||
|
0x459, 0x459, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
|
||||||
|
0x0d0, 0x653, 0x653, 0x653, 0x653, 0x653, 0x653, 0x253,
|
||||||
|
0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
|
||||||
|
0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
|
||||||
|
0x253, 0x253, 0x253, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
|
||||||
|
0x0d0, 0x473, 0x473, 0x473, 0x473, 0x473, 0x473, 0x073,
|
||||||
|
0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
|
||||||
|
0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
|
||||||
|
0x073, 0x073, 0x073, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x004
|
||||||
|
/* the upper 128 are all zeroes */
|
||||||
|
};
|
||||||
|
|
||||||
|
static void TrimString(std::string& str)
|
||||||
|
{
|
||||||
|
std::string str1;
|
||||||
|
bool add1 = false;
|
||||||
|
std::string::const_iterator iter1;
|
||||||
|
for (iter1 = str.begin(); iter1 != str.end(); ++iter1)
|
||||||
|
{
|
||||||
|
int c = (HGByte)(*iter1);
|
||||||
|
if (!add1)
|
||||||
|
{
|
||||||
|
if (!isspace(c))
|
||||||
|
{
|
||||||
|
str1.push_back(c);
|
||||||
|
add1 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str1.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str1.empty())
|
||||||
|
{
|
||||||
|
str.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string str2;
|
||||||
|
bool add2 = false;
|
||||||
|
std::string::const_reverse_iterator iter2;
|
||||||
|
for (iter2 = str1.rbegin(); iter2 != str1.rend(); ++iter2)
|
||||||
|
{
|
||||||
|
int c = (HGByte)(*iter2);
|
||||||
|
if (!add2)
|
||||||
|
{
|
||||||
|
if (!isspace(c))
|
||||||
|
{
|
||||||
|
str2.push_back(c);
|
||||||
|
add2 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str2.push_back(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str2.empty())
|
||||||
|
{
|
||||||
|
str.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
str = std::string(str2.rbegin(), str2.rend());
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpHead::HttpHead()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpHead::~HttpHead()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HttpHead::Parse(const std::string& head)
|
||||||
|
{
|
||||||
|
AnalysisHead(head, m_requestMethod, m_requestURIPath, m_requestURIQueryInfos,
|
||||||
|
m_requestURIFragment, m_requestHttpVersion, m_headInfos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpHead::Clear()
|
||||||
|
{
|
||||||
|
m_requestMethod.clear();
|
||||||
|
m_requestURIPath.clear();
|
||||||
|
m_requestURIQueryInfos.clear();
|
||||||
|
m_requestURIFragment.clear();
|
||||||
|
m_requestHttpVersion.clear();
|
||||||
|
m_headInfos.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string HttpHead::GetRequestMethod() const
|
||||||
|
{
|
||||||
|
return m_requestMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string HttpHead::GetRequestURIPath() const
|
||||||
|
{
|
||||||
|
return m_requestURIPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpPairs HttpHead::GetRequestURIQueryInfos() const
|
||||||
|
{
|
||||||
|
return m_requestURIQueryInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string HttpHead::GetRequestURIFragment() const
|
||||||
|
{
|
||||||
|
return m_requestURIFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string HttpHead::GetRequestHttpVersion() const
|
||||||
|
{
|
||||||
|
return m_requestHttpVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpPairs HttpHead::GetHeadInfos() const
|
||||||
|
{
|
||||||
|
return m_headInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HttpHead::GetContentLength() const
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
for (int i = 0; i < (int)m_headInfos.size(); ++i)
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
if (0 == _stricmp("Content-Length", m_headInfos[i].first.c_str()))
|
||||||
|
#else
|
||||||
|
if (0 == strcasecmp("Content-Length", m_headInfos[i].first.c_str()))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
len = atoi(m_headInfos[i].second.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string HttpHead::GetContentType() const
|
||||||
|
{
|
||||||
|
std::string type;
|
||||||
|
for (int i = 0; i < (int)m_headInfos.size(); ++i)
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
if (0 == _stricmp("Content-Type", m_headInfos[i].first.c_str()))
|
||||||
|
#else
|
||||||
|
if (0 == strcasecmp("Content-Type", m_headInfos[i].first.c_str()))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
type = m_headInfos[i].second.c_str();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string HttpHead::GetValue(const HttpPairs& infos, const std::string& key)
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
for (int i = 0; i < (int)infos.size(); ++i)
|
||||||
|
{
|
||||||
|
if (key == infos[i].first)
|
||||||
|
{
|
||||||
|
value = infos[i].second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpHead::AnalysisURIQuery(const std::string& query, HttpPairs& queryInfos)
|
||||||
|
{
|
||||||
|
std::vector<std::string> queryList;
|
||||||
|
|
||||||
|
char* p = new char[query.size() + 1];
|
||||||
|
strcpy(p, query.c_str());
|
||||||
|
char* pStr = strtok(p, "&");
|
||||||
|
if (NULL != pStr)
|
||||||
|
queryList.push_back(pStr);
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
pStr = strtok(NULL, "&");
|
||||||
|
if (NULL == pStr)
|
||||||
|
break;
|
||||||
|
queryList.push_back(pStr);
|
||||||
|
}
|
||||||
|
delete[] p;
|
||||||
|
|
||||||
|
queryInfos.clear();
|
||||||
|
for (int i = 0; i < (int)queryList.size(); ++i)
|
||||||
|
{
|
||||||
|
p = new char[queryList[i].size() + 1];
|
||||||
|
strcpy(p, queryList[i].c_str());
|
||||||
|
|
||||||
|
std::pair <std::string, std::string> pr;
|
||||||
|
pStr = strtok(p, "=");
|
||||||
|
if (NULL != pStr)
|
||||||
|
pr.first = AnalyURIString(pStr);
|
||||||
|
pStr = strtok(NULL, "=");
|
||||||
|
if (NULL != pStr)
|
||||||
|
pr.second = AnalyURIString(pStr);
|
||||||
|
|
||||||
|
queryInfos.push_back(pr);
|
||||||
|
delete[] p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpHead::AnalysisURI(const std::string& uri, std::string& path, HttpPairs& queryInfos, std::string& fragment)
|
||||||
|
{
|
||||||
|
size_t pathPos = uri.find('/');
|
||||||
|
size_t queryPos = uri.find('?');
|
||||||
|
size_t fragmentPos = uri.find('#');
|
||||||
|
|
||||||
|
path.clear();
|
||||||
|
if (std::string::npos != pathPos)
|
||||||
|
{
|
||||||
|
size_t count = std::string::npos;
|
||||||
|
if (queryPos != std::string::npos)
|
||||||
|
{
|
||||||
|
assert(queryPos > pathPos);
|
||||||
|
count = queryPos - pathPos;
|
||||||
|
}
|
||||||
|
else if (fragmentPos != std::string::npos)
|
||||||
|
{
|
||||||
|
assert(fragmentPos > pathPos);
|
||||||
|
count = fragmentPos - pathPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = AnalyURIString(uri.substr(pathPos, count));
|
||||||
|
}
|
||||||
|
|
||||||
|
queryInfos.clear();
|
||||||
|
if (std::string::npos != queryPos)
|
||||||
|
{
|
||||||
|
size_t count = std::string::npos;
|
||||||
|
if (fragmentPos != std::string::npos)
|
||||||
|
{
|
||||||
|
assert(fragmentPos > queryPos);
|
||||||
|
count = fragmentPos - queryPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string query = uri.substr(queryPos + 1, count - 1);
|
||||||
|
AnalysisURIQuery(query, queryInfos);
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment.clear();
|
||||||
|
if (std::string::npos != fragmentPos)
|
||||||
|
{
|
||||||
|
fragment = AnalyURIString(uri.substr(fragmentPos + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HttpHead::AnalysisHead(const std::string& head, std::string& requestMethod, std::string& requestURIPath,
|
||||||
|
HttpPairs& requestURIQueryInfos, std::string& requestURIFragment, std::string& httpVersion, HttpPairs& headInfos)
|
||||||
|
{
|
||||||
|
requestMethod.clear();
|
||||||
|
requestURIPath.clear();
|
||||||
|
requestURIQueryInfos.clear();
|
||||||
|
requestURIFragment.clear();
|
||||||
|
httpVersion.clear();
|
||||||
|
headInfos.clear();
|
||||||
|
|
||||||
|
std::vector<std::string> headList;
|
||||||
|
|
||||||
|
char* p = new char[head.size() + 1];
|
||||||
|
strcpy(p, head.c_str());
|
||||||
|
char* pStr = strtok(p, "\r\n");
|
||||||
|
if (NULL != pStr)
|
||||||
|
headList.push_back(pStr);
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
pStr = strtok(NULL, "\r\n");
|
||||||
|
if (NULL == pStr)
|
||||||
|
break;
|
||||||
|
headList.push_back(pStr);
|
||||||
|
}
|
||||||
|
delete[] p;
|
||||||
|
|
||||||
|
if (headList.size() < 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string requestURI;
|
||||||
|
|
||||||
|
// 解析请求行
|
||||||
|
p = new char[headList[0].size() + 1];
|
||||||
|
strcpy(p, headList[0].c_str());
|
||||||
|
pStr = strtok(p, " ");
|
||||||
|
if (NULL != pStr)
|
||||||
|
requestMethod = pStr;
|
||||||
|
pStr = strtok(NULL, " ");
|
||||||
|
if (NULL != pStr)
|
||||||
|
requestURI = pStr;
|
||||||
|
pStr = strtok(NULL, " ");
|
||||||
|
if (NULL != pStr)
|
||||||
|
httpVersion = pStr;
|
||||||
|
delete[] p;
|
||||||
|
|
||||||
|
// 解析URI
|
||||||
|
AnalysisURI(requestURI, requestURIPath, requestURIQueryInfos, requestURIFragment);
|
||||||
|
|
||||||
|
// 解析请求头
|
||||||
|
for (int i = 1; i < (int)headList.size(); ++i)
|
||||||
|
{
|
||||||
|
p = new char[headList[i].size() + 1];
|
||||||
|
strcpy(p, headList[i].c_str());
|
||||||
|
|
||||||
|
std::pair <std::string, std::string> pr;
|
||||||
|
pStr = strtok(p, ":");
|
||||||
|
if (NULL != pStr)
|
||||||
|
pr.first = pStr;
|
||||||
|
pStr = strtok(NULL, ":");
|
||||||
|
if (NULL != pStr)
|
||||||
|
pr.second = pStr;
|
||||||
|
|
||||||
|
TrimString(pr.first);
|
||||||
|
TrimString(pr.second);
|
||||||
|
headInfos.push_back(pr);
|
||||||
|
|
||||||
|
delete[] p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*判断ascii码是否是数字0-9*/
|
||||||
|
static bool asciiIsDigit(char c)
|
||||||
|
{
|
||||||
|
/*字符的ascii码&8 结果为0-127,则是数字*/
|
||||||
|
return asciiTableData[(unsigned char)c & (1 << 3)];
|
||||||
|
}
|
||||||
|
|
||||||
|
static int asciiDigitValue(char c)
|
||||||
|
{
|
||||||
|
if (asciiIsDigit(c))
|
||||||
|
return c - '0';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int asciiXdigitValue(char c)
|
||||||
|
{
|
||||||
|
//printf("-->%c\n",c);
|
||||||
|
if (c >= 'A' && c <= 'F')
|
||||||
|
return c - 'A' + 10;//(A B C D E F)->(10 11 12 13 14 15)
|
||||||
|
if (c >= 'a' && c <= 'f')
|
||||||
|
return c - 'a' + 10;
|
||||||
|
|
||||||
|
return asciiDigitValue(c);//('0'...'9')->(0...9)
|
||||||
|
}
|
||||||
|
|
||||||
|
static int unescapeCharacter(const char* scanner)
|
||||||
|
{
|
||||||
|
int first = asciiXdigitValue(scanner[0]);
|
||||||
|
if (first < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int second = asciiXdigitValue(scanner[1]);
|
||||||
|
if (second < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (first << 4) | second; //== (first*16 | second) == (first*16 + second)
|
||||||
|
}
|
||||||
|
|
||||||
|
static char* unescapeUriString(const char* uriString, bool asciiEscape)
|
||||||
|
{
|
||||||
|
if (NULL == uriString)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int strLen = (int)strlen(uriString);
|
||||||
|
char* result = (char*)malloc(strLen + 1);//可推测解码后的长度<=原长度
|
||||||
|
char* out = result;
|
||||||
|
|
||||||
|
const char* in, * end;
|
||||||
|
for (in = uriString, end = in + strLen; in < end; ++in)
|
||||||
|
{
|
||||||
|
int c = *in;
|
||||||
|
|
||||||
|
//遇到了'%'才去解析
|
||||||
|
if ('%' == c)
|
||||||
|
{
|
||||||
|
if (in + 3 > end)
|
||||||
|
break;
|
||||||
|
//获取%后2个字符的解码值
|
||||||
|
c = unescapeCharacter(in + 1);
|
||||||
|
if (c <= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (asciiEscape && c <= 0x7F)
|
||||||
|
break;
|
||||||
|
|
||||||
|
in += 2;//一般的格式为%后加两个ascii码字符
|
||||||
|
}
|
||||||
|
|
||||||
|
*out++ = c;//存储转义结果
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = '\0';
|
||||||
|
|
||||||
|
if (in != end)
|
||||||
|
{
|
||||||
|
free(result);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string HttpHead::AnalyURIString(const std::string& str)
|
||||||
|
{
|
||||||
|
std::string ret;
|
||||||
|
char* decodeStr = unescapeUriString(str.c_str(), false);
|
||||||
|
if (NULL != decodeStr)
|
||||||
|
{
|
||||||
|
ret = decodeStr;
|
||||||
|
free(decodeStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
typedef std::pair<std::string, std::string> HttpPair;
|
||||||
|
typedef std::vector<HttpPair> HttpPairs;
|
||||||
|
|
||||||
|
class HttpHead
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HttpHead();
|
||||||
|
~HttpHead();
|
||||||
|
|
||||||
|
bool Parse(const std::string& head);
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
std::string GetRequestMethod() const;
|
||||||
|
std::string GetRequestURIPath() const;
|
||||||
|
HttpPairs GetRequestURIQueryInfos() const;
|
||||||
|
std::string GetRequestURIFragment() const;
|
||||||
|
std::string GetRequestHttpVersion() const;
|
||||||
|
HttpPairs GetHeadInfos() const;
|
||||||
|
int GetContentLength() const;
|
||||||
|
std::string GetContentType() const;
|
||||||
|
|
||||||
|
static std::string GetValue(const HttpPairs& infos, const std::string& key);
|
||||||
|
static void AnalysisURIQuery(const std::string& query, HttpPairs& queryInfos);
|
||||||
|
static void AnalysisURI(const std::string& uri, std::string& path, HttpPairs& queryInfos, std::string& fragment);
|
||||||
|
static void AnalysisHead(const std::string& head, std::string& requestMethod, std::string& requestURIPath,
|
||||||
|
HttpPairs& requestURIQueryInfos, std::string& requestURIFragment, std::string& httpVersion, HttpPairs& headInfos);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::string AnalyURIString(const std::string& str);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_requestMethod;
|
||||||
|
std::string m_requestURIPath;
|
||||||
|
HttpPairs m_requestURIQueryInfos;
|
||||||
|
std::string m_requestURIFragment;
|
||||||
|
std::string m_requestHttpVersion;
|
||||||
|
HttpPairs m_headInfos;
|
||||||
|
};
|
|
@ -0,0 +1,65 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include <string>
|
||||||
|
#include "HttpHead.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MSGID_CONNECT = 1L,
|
||||||
|
MSGID_DISCONNECT,
|
||||||
|
MSGID_CLOSE_DEVICE,
|
||||||
|
MSGID_SCAN_FINISH,
|
||||||
|
MSGID_WS_COMMAND,
|
||||||
|
MSGID_WS_EVENT
|
||||||
|
};
|
||||||
|
|
||||||
|
class WebServer;
|
||||||
|
|
||||||
|
struct ConnectParam
|
||||||
|
{
|
||||||
|
WebServer* svr;
|
||||||
|
std::string ip;
|
||||||
|
HGUShort port;
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
SOCKET socket;
|
||||||
|
#else
|
||||||
|
int socket;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DisConnectParam
|
||||||
|
{
|
||||||
|
WebServer* svr;
|
||||||
|
HGUInt usrId;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CloseDevParam
|
||||||
|
{
|
||||||
|
WebServer* svr;
|
||||||
|
HGUInt usrId;
|
||||||
|
std::string devName;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ScanFinishParam
|
||||||
|
{
|
||||||
|
WebServer* svr;
|
||||||
|
HGUInt usrId;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WSCmdParam
|
||||||
|
{
|
||||||
|
WebServer* svr;
|
||||||
|
HGUInt usrId;
|
||||||
|
HGByte* data;
|
||||||
|
HGUInt size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WSEvtParam
|
||||||
|
{
|
||||||
|
WebServer* svr;
|
||||||
|
HGUInt usrId;
|
||||||
|
HGByte* data;
|
||||||
|
HGUInt size;
|
||||||
|
};
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include "MsgPumpCallback.h"
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include "WebServer.h"
|
||||||
|
|
||||||
|
void HGMsgPumpCallback(HGMsgPump msgPump, const HGMsg* msg, HGPointer param)
|
||||||
|
{
|
||||||
|
(void)msgPump;
|
||||||
|
(void)param;
|
||||||
|
assert(NULL != msg);
|
||||||
|
|
||||||
|
switch (msg->id)
|
||||||
|
{
|
||||||
|
case MSGID_CONNECT:
|
||||||
|
{
|
||||||
|
ConnectParam* param = (ConnectParam*)msg->data;
|
||||||
|
param->svr->Connect(param);
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSGID_DISCONNECT:
|
||||||
|
{
|
||||||
|
DisConnectParam* param = (DisConnectParam*)msg->data;
|
||||||
|
param->svr->DisConnect(param);
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSGID_CLOSE_DEVICE:
|
||||||
|
{
|
||||||
|
CloseDevParam* param = (CloseDevParam*)msg->data;
|
||||||
|
param->svr->CloseDev(param);
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSGID_SCAN_FINISH:
|
||||||
|
{
|
||||||
|
ScanFinishParam* param = (ScanFinishParam*)msg->data;
|
||||||
|
param->svr->ScanFinish(param);
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSGID_WS_COMMAND:
|
||||||
|
{
|
||||||
|
WSCmdParam* param = (WSCmdParam*)msg->data;
|
||||||
|
param->svr->Command(param);
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSGID_WS_EVENT:
|
||||||
|
{
|
||||||
|
WSEvtParam* param = (WSEvtParam*)msg->data;
|
||||||
|
param->svr->Event(param);
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/HGMsgPump.h"
|
||||||
|
|
||||||
|
void HGMsgPumpCallback(HGMsgPump msgPump, const HGMsg* msg, HGPointer param);
|
|
@ -0,0 +1,262 @@
|
||||||
|
#include "WebServer.h"
|
||||||
|
#include "WebUser.h"
|
||||||
|
#include "base/HGInfo.h"
|
||||||
|
|
||||||
|
WebServer::WebServer(HGMsgPump msgPump)
|
||||||
|
{
|
||||||
|
m_msgPump = msgPump;
|
||||||
|
|
||||||
|
m_currUserId = 1;
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
m_sockServer = INVALID_SOCKET;
|
||||||
|
#else
|
||||||
|
m_sockServer = -1;
|
||||||
|
#endif
|
||||||
|
m_listenThread = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebServer::~WebServer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebServer::Open(HGUShort port)
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
if (INVALID_SOCKET != m_sockServer)
|
||||||
|
#else
|
||||||
|
if (-1 != m_sockServer)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
SOCKET sockServer = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if (INVALID_SOCKET == sockServer)
|
||||||
|
#else
|
||||||
|
int sockServer = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if (-1 == sockServer)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "open webserver failed 1, port=%u", port);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bind
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
SOCKADDR_IN addrServer;
|
||||||
|
addrServer.sin_addr.S_un.S_addr = INADDR_ANY;
|
||||||
|
addrServer.sin_family = AF_INET;
|
||||||
|
addrServer.sin_port = htons(port);
|
||||||
|
if (0 != bind(sockServer, (SOCKADDR*)&addrServer, sizeof(SOCKADDR_IN)))
|
||||||
|
#else
|
||||||
|
struct sockaddr_in addrServer;
|
||||||
|
addrServer.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
addrServer.sin_family = AF_INET;
|
||||||
|
addrServer.sin_port = htons(port);
|
||||||
|
if (0 != bind(sockServer, (struct sockaddr*)&addrServer, sizeof(addrServer)))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
closesocket(sockServer);
|
||||||
|
#else
|
||||||
|
close(sockServer);
|
||||||
|
#endif
|
||||||
|
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "open webserver failed 2, port=%u", port);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// listen
|
||||||
|
if (0 != listen(sockServer, 5))
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
closesocket(sockServer);
|
||||||
|
#else
|
||||||
|
close(sockServer);
|
||||||
|
#endif
|
||||||
|
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "open webserver failed 3, port=%u", port);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_sockServer = sockServer;
|
||||||
|
HGBase_OpenThread(ThreadFunc, this, &m_listenThread);
|
||||||
|
assert(NULL != m_listenThread);
|
||||||
|
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, "open webserver success, port=%u", port);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebServer::Close()
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
if (INVALID_SOCKET == m_sockServer)
|
||||||
|
#else
|
||||||
|
if (-1 == m_sockServer)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!m_vectorUser.empty())
|
||||||
|
{
|
||||||
|
WebUser* pUser = m_vectorUser[0];
|
||||||
|
m_vectorUser.erase(m_vectorUser.begin());
|
||||||
|
delete pUser;
|
||||||
|
pUser = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
closesocket(m_sockServer);
|
||||||
|
m_sockServer = INVALID_SOCKET;
|
||||||
|
#else
|
||||||
|
close(m_sockServer);
|
||||||
|
m_sockServer = -1;
|
||||||
|
#endif
|
||||||
|
HGBase_CloseThread(m_listenThread);
|
||||||
|
m_listenThread = NULL;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer::Connect(const ConnectParam* param)
|
||||||
|
{
|
||||||
|
assert(NULL != param && this == param->svr);
|
||||||
|
|
||||||
|
if (!m_vectorUser.empty())
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
closesocket(param->socket);
|
||||||
|
#else
|
||||||
|
close(param->socket);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebUser* user = new WebUser(this, m_currUserId, m_msgPump, param->ip, param->port, param->socket);
|
||||||
|
++m_currUserId;
|
||||||
|
m_vectorUser.push_back(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer::DisConnect(const DisConnectParam* param)
|
||||||
|
{
|
||||||
|
assert(NULL != param && this == param->svr);
|
||||||
|
|
||||||
|
int nIndex = GetUserIndex(param->usrId);
|
||||||
|
if (-1 != nIndex)
|
||||||
|
{
|
||||||
|
WebUser* pUser = m_vectorUser[nIndex];
|
||||||
|
m_vectorUser.erase(m_vectorUser.begin() + nIndex);
|
||||||
|
delete pUser;
|
||||||
|
pUser = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer::CloseDev(const CloseDevParam* param)
|
||||||
|
{
|
||||||
|
assert(NULL != param && this == param->svr);
|
||||||
|
|
||||||
|
int nIndex = GetUserIndex(param->usrId);
|
||||||
|
if (-1 != nIndex)
|
||||||
|
{
|
||||||
|
((WebUser*)m_vectorUser[nIndex])->CloseDev(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer::ScanFinish(const ScanFinishParam* param)
|
||||||
|
{
|
||||||
|
assert(NULL != param && this == param->svr);
|
||||||
|
|
||||||
|
int nIndex = GetUserIndex(param->usrId);
|
||||||
|
if (-1 != nIndex)
|
||||||
|
{
|
||||||
|
((WebUser*)m_vectorUser[nIndex])->ScanFinish(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer::Command(const WSCmdParam* param)
|
||||||
|
{
|
||||||
|
assert(NULL != param && this == param->svr);
|
||||||
|
|
||||||
|
int nIndex = GetUserIndex(param->usrId);
|
||||||
|
if (-1 != nIndex)
|
||||||
|
{
|
||||||
|
((WebUser*)m_vectorUser[nIndex])->HandleCmd(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer::Event(const WSEvtParam* param)
|
||||||
|
{
|
||||||
|
assert(NULL != param && this == param->svr);
|
||||||
|
|
||||||
|
int nIndex = GetUserIndex(param->usrId);
|
||||||
|
if (-1 != nIndex)
|
||||||
|
{
|
||||||
|
((WebUser*)m_vectorUser[nIndex])->HandleEvent(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
void WebServer::PostConnectMsg(const std::string& ip, uint16_t port, SOCKET sockConn)
|
||||||
|
#else
|
||||||
|
void WebServer::PostConnectMsg(const std::string& ip, uint16_t port, int sockConn)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ConnectParam* param = new ConnectParam;
|
||||||
|
param->svr = this;
|
||||||
|
param->ip = ip;
|
||||||
|
param->port = port;
|
||||||
|
param->socket = sockConn;
|
||||||
|
|
||||||
|
HGMsg msg;
|
||||||
|
msg.id = MSGID_CONNECT;
|
||||||
|
msg.data = param;
|
||||||
|
if (HGBASE_ERR_OK != HGBase_PostPumpMessage(m_msgPump, &msg))
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
closesocket(param->socket);
|
||||||
|
#else
|
||||||
|
close(param->socket);
|
||||||
|
#endif
|
||||||
|
delete param;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int WebServer::GetUserIndex(HGUInt id)
|
||||||
|
{
|
||||||
|
int nIndex = -1;
|
||||||
|
for (int i = 0; i < (int)m_vectorUser.size(); ++i)
|
||||||
|
{
|
||||||
|
if (id == m_vectorUser[i]->GetId())
|
||||||
|
{
|
||||||
|
nIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServer::ThreadFunc(HGThread thread, HGPointer param)
|
||||||
|
{
|
||||||
|
WebServer* p = (WebServer*)param;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
SOCKADDR_IN addrClient;
|
||||||
|
int len = sizeof(SOCKADDR_IN);
|
||||||
|
SOCKET socketConn = accept(p->m_sockServer, (SOCKADDR*)&addrClient, &len);
|
||||||
|
if (INVALID_SOCKET == socketConn)
|
||||||
|
#else
|
||||||
|
struct sockaddr_in addrClient;
|
||||||
|
socklen_t len = sizeof(addrClient);
|
||||||
|
int socketConn = accept(p->m_sockServer, (struct sockaddr*)&addrClient, &len);
|
||||||
|
if (-1 == socketConn)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// 这里跳出,可能是服务器关闭了m_sockServer
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->PostConnectMsg(inet_ntoa(addrClient.sin_addr), ntohs(addrClient.sin_port), socketConn);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include "base/HGThread.h"
|
||||||
|
#include "base/HGMsgPump.h"
|
||||||
|
#include "Msg.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class WebServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebServer(HGMsgPump msgPump);
|
||||||
|
~WebServer();
|
||||||
|
|
||||||
|
bool Open(HGUShort port);
|
||||||
|
bool Close();
|
||||||
|
|
||||||
|
void Connect(const ConnectParam* param);
|
||||||
|
void DisConnect(const DisConnectParam* param);
|
||||||
|
void CloseDev(const CloseDevParam* param);
|
||||||
|
void ScanFinish(const ScanFinishParam* param);
|
||||||
|
void Command(const WSCmdParam* param);
|
||||||
|
void Event(const WSEvtParam* param);
|
||||||
|
|
||||||
|
private:
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
void PostConnectMsg(const std::string &ip, uint16_t port, SOCKET sockConn);
|
||||||
|
#else
|
||||||
|
void PostConnectMsg(const std::string &ip, uint16_t port, int sockConn);
|
||||||
|
#endif
|
||||||
|
int GetUserIndex(HGUInt id);
|
||||||
|
static void ThreadFunc(HGThread thread, HGPointer param);
|
||||||
|
|
||||||
|
private:
|
||||||
|
HGMsgPump m_msgPump;
|
||||||
|
|
||||||
|
HGUInt m_currUserId;
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
SOCKET m_sockServer;
|
||||||
|
#else
|
||||||
|
int m_sockServer;
|
||||||
|
#endif
|
||||||
|
HGThread m_listenThread;
|
||||||
|
std::vector<class WebUser*> m_vectorUser;
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,78 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include "base/HGLock.h"
|
||||||
|
#include "base/HGEvent.h"
|
||||||
|
#include "base/HGThread.h"
|
||||||
|
#include "base/HGImage.h"
|
||||||
|
#include "base/HGMsgPump.h"
|
||||||
|
#include "Msg.h"
|
||||||
|
#include "cJSON.h"
|
||||||
|
#include "sane/sane_ex.h"
|
||||||
|
#include "sane/sane_option_definitions.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class WebServer;
|
||||||
|
|
||||||
|
class WebUser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
WebUser(WebServer* server, HGUInt id, HGMsgPump msgPump, const std::string& ip, uint16_t port, SOCKET sockConn);
|
||||||
|
#else
|
||||||
|
WebUser(WebServer* server, HGUInt id, HGMsgPump msgPump, const std::string& ip, uint16_t port, int sockConn);
|
||||||
|
#endif
|
||||||
|
~WebUser();
|
||||||
|
|
||||||
|
HGUInt GetId();
|
||||||
|
void CloseDev(const CloseDevParam* param);
|
||||||
|
void ScanFinish(const ScanFinishParam* param);
|
||||||
|
void HandleCmd(const WSCmdParam* param);
|
||||||
|
void HandleEvent(const WSEvtParam* param);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GetDeviceList(cJSON *json);
|
||||||
|
void SelectDevice(cJSON* json);
|
||||||
|
void SetScanColorType(cJSON* json);
|
||||||
|
void SetDPI(cJSON* json);
|
||||||
|
void SetDuplex(cJSON* json);
|
||||||
|
void SetScanJPGQuality(cJSON* json);
|
||||||
|
void StartScan(cJSON* json);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void PostDisConnectMsg();
|
||||||
|
void PostCmdMsg(const HGByte* data, HGUInt dataSize);
|
||||||
|
void PostEventMsg(const HGByte* data, HGUInt dataSize);
|
||||||
|
static void ThreadFunc(HGThread thread, HGPointer param);
|
||||||
|
static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param);
|
||||||
|
std::string GetBase64(HGImage image);
|
||||||
|
HGBool SetParam(const char* optionName, const HGVoid* data);
|
||||||
|
HGInt GetDpi();
|
||||||
|
|
||||||
|
bool ShakeHand(const std::string& head);
|
||||||
|
void Pong();
|
||||||
|
bool SendResponse(const HGByte* data, HGUInt size, HGBool text);
|
||||||
|
|
||||||
|
private:
|
||||||
|
HGLock m_lock;
|
||||||
|
HGLock m_lockName;
|
||||||
|
WebServer* m_server;
|
||||||
|
HGUInt m_id;
|
||||||
|
HGMsgPump m_msgPump;
|
||||||
|
std::string m_ip;
|
||||||
|
uint16_t m_port;
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
SOCKET m_sockConn;
|
||||||
|
#else
|
||||||
|
int m_sockConn;
|
||||||
|
#endif
|
||||||
|
HGThread m_thread;
|
||||||
|
|
||||||
|
int m_jpgQuality;
|
||||||
|
std::vector<std::string> m_devNameList;
|
||||||
|
std::string m_devName;
|
||||||
|
SANE_Handle m_devHandle;
|
||||||
|
int m_dpi;
|
||||||
|
HGEvent m_scanEvent;
|
||||||
|
};
|
|
@ -0,0 +1,50 @@
|
||||||
|
#include "base/HGDef.h"
|
||||||
|
#include "base/HGInc.h"
|
||||||
|
#include "base/HGThread.h"
|
||||||
|
#include "base/HGMsgPump.h"
|
||||||
|
#include "WebServer.h"
|
||||||
|
#include "MsgPumpCallback.h"
|
||||||
|
|
||||||
|
static void ThreadFunc(HGThread thread, HGPointer param)
|
||||||
|
{
|
||||||
|
(void)thread;
|
||||||
|
HGMsgPump msgPump = (HGMsgPump)param;
|
||||||
|
|
||||||
|
WebServer wsServer(msgPump);
|
||||||
|
|
||||||
|
HGInt port = 9458;
|
||||||
|
if (wsServer.Open(port))
|
||||||
|
{
|
||||||
|
HGBase_RunMsgPump(msgPump, HGMsgPumpCallback, NULL);
|
||||||
|
wsServer.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE iPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
|
||||||
|
#else
|
||||||
|
int main()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
WSADATA ws = { 0 };
|
||||||
|
int ret = WSAStartup(MAKEWORD(2, 2), &ws);
|
||||||
|
assert(0 == ret);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HGMsgPump msgPump = NULL;
|
||||||
|
HGBase_CreateMsgPump(&msgPump);
|
||||||
|
|
||||||
|
HGThread thread = NULL;
|
||||||
|
HGBase_OpenThread(ThreadFunc, msgPump, &thread);
|
||||||
|
HGBase_CloseThread(thread);
|
||||||
|
thread = NULL;
|
||||||
|
|
||||||
|
HGBase_DestroyMsgPump(msgPump);
|
||||||
|
msgPump = NULL;
|
||||||
|
|
||||||
|
#if defined(HG_CMP_MSC)
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,190 @@
|
||||||
|
<html>
|
||||||
|
<title>Test</title>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<head>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var socket;
|
||||||
|
|
||||||
|
function connect()
|
||||||
|
{
|
||||||
|
var host = "ws://" + $("serverIP").value + ":" + $("serverPort").value + "/"
|
||||||
|
socket = new WebSocket(host);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
socket.onopen = function (msg)
|
||||||
|
{
|
||||||
|
$("serverIP").disabled = true;
|
||||||
|
$("serverPort").disabled = true;
|
||||||
|
$("btnConnect").disabled = true;
|
||||||
|
$("btnDisConnect").disabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onclose = function (msg)
|
||||||
|
{
|
||||||
|
var myimg = document.getElementById("myCanvas");
|
||||||
|
myimg.src = null;
|
||||||
|
|
||||||
|
$("serverIP").disabled = false;
|
||||||
|
$("serverPort").disabled = false;
|
||||||
|
$("btnConnect").disabled = false;
|
||||||
|
$("btnDisConnect").disabled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onmessage = function (msg)
|
||||||
|
{
|
||||||
|
if (typeof msg.data == "string")
|
||||||
|
{
|
||||||
|
var message = JSON.parse(msg.data);
|
||||||
|
if ("GetDeviceList" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
else if ("SelectDevice" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
else if ("SetScanColorType" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
else if ("SetDPI" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
else if ("SetDuplex" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
else if ("SetScanJPGQuality" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
else if ("StartScan" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
else if ("ImageSaveDone" == message['Func'])
|
||||||
|
{
|
||||||
|
myCanvas.src = "data:image/jpeg;base64," + message['result'];
|
||||||
|
}
|
||||||
|
else if ("ScanComplete" == message['Func'])
|
||||||
|
{
|
||||||
|
alert(msg.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ex)
|
||||||
|
{
|
||||||
|
log(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function disconnect()
|
||||||
|
{
|
||||||
|
socket.close();
|
||||||
|
socket = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetDeviceList()
|
||||||
|
{
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
'Func':'GetDeviceList',
|
||||||
|
'arg':0
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectDevice()
|
||||||
|
{
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
'Func':'SelectDevice',
|
||||||
|
'arg':0
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetScanColorType()
|
||||||
|
{
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
'Func':'SetScanColorType',
|
||||||
|
'arg':3
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetDPI()
|
||||||
|
{
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
'Func':'SetDPI',
|
||||||
|
'arg':200
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetDuplex()
|
||||||
|
{
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
'Func':'SetDuplex',
|
||||||
|
'arg':1
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetScanJPGQuality()
|
||||||
|
{
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
'Func':'SetScanJPGQuality',
|
||||||
|
'arg':60
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function StartScan()
|
||||||
|
{
|
||||||
|
socket.send(JSON.stringify({
|
||||||
|
'Func':'StartScan',
|
||||||
|
'arg':60
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onload = function()
|
||||||
|
{
|
||||||
|
var myimg = document.getElementById("myCanvas");
|
||||||
|
myimg.src = null;
|
||||||
|
|
||||||
|
$("serverIP").disabled = false;
|
||||||
|
$("serverPort").disabled = false;
|
||||||
|
$("btnConnect").disabled = false;
|
||||||
|
$("btnDisConnect").disabled = true;
|
||||||
|
|
||||||
|
connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onbeforeunload = function ()
|
||||||
|
{
|
||||||
|
disconnect();
|
||||||
|
};
|
||||||
|
|
||||||
|
function $(id)
|
||||||
|
{
|
||||||
|
return document.getElementById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<input id="serverIP" type="text" placeholder="服务器IP" value="127.0.0.1" autofocus="autofocus" />
|
||||||
|
<input id="serverPort" type="text" placeholder="服务器端口" value="9458" />
|
||||||
|
<input id="btnConnect" type="button" value="连接" onclick="connect()" />
|
||||||
|
<input id="btnDisConnect" type="button" value="断开" onclick="disconnect()" />
|
||||||
|
|
||||||
|
<input type="button" value="GetDeviceList" onclick="GetDeviceList()" />
|
||||||
|
<input type="button" value="SelectDevice" onclick="SelectDevice()" />
|
||||||
|
<input type="button" value="SetScanColorType" onclick="SetScanColorType()" />
|
||||||
|
<input type="button" value="SetDPI" onclick="SetDPI()" />
|
||||||
|
<input type="button" value="SetDuplex" onclick="SetDuplex()" />
|
||||||
|
<input type="button" value="SetScanJPGQuality" onclick="SetScanJPGQuality()" />
|
||||||
|
<input type="button" value="StartScan" onclick="StartScan()" />
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<img id="myCanvas" width='640' height='480' style="background-color: black; float: left;"/>
|
||||||
|
<input type="text" id="info" style="width:800px; height:80px;" />
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue