Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@15570 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
5ce01812fa
commit
0669678204
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="Authoriz"
|
||||
ProjectGUID="{75D3E647-7693-43E7-8634-43CDCC27A5B7}"
|
||||
>
|
||||
@ -47,10 +47,10 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
InlineFunctionExpansion="2"
|
||||
AdditionalIncludeDirectories="c:/wx233/include"
|
||||
AdditionalIncludeDirectories="\u\guy\wx283\lib\vc_lib\msw;\u\guy\wx283\include"
|
||||
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;__WINDOWS__;__WXMSW__;__WIN95__;__WIN32__;WINVER=0x0400;STRICT"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
PrecompiledHeaderFile=".\../server/release/Authoriz.pch"
|
||||
AssemblerListingLocation=".\../server/release/"
|
||||
@ -66,19 +66,18 @@
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="2057"
|
||||
AdditionalIncludeDirectories="\U\Luca\r020200\server;..\..\wx283\include"
|
||||
AdditionalIncludeDirectories="\u\guy\wx283\include"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxmsw233.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib"
|
||||
OutputFile="../exe/servers/Authoriz.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="../../lib,../../contrib/lib"
|
||||
IgnoreDefaultLibraryNames="libc.lib,libci.lib,msvcrtd.lib"
|
||||
AdditionalLibraryDirectories=""
|
||||
IgnoreDefaultLibraryNames=""
|
||||
ProgramDatabaseFile=".\../server/release/Authoriz.pdb"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
@ -241,7 +240,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="\wx283\include"
|
||||
AdditionalIncludeDirectories="..\..\wx283\lib\vc_lib\mswd,..\..\wx283\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;__WINDOWS__;__WXMSW__;DEBUG=1;__WXDEBUG__;__WIN95__;__WIN32__;WINVER=0x0400;STRICT"
|
||||
MinimalRebuild="true"
|
||||
RuntimeLibrary="1"
|
||||
@ -250,7 +249,7 @@
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
BrowseInformation="1"
|
||||
WarningLevel="3"
|
||||
WarningLevel="4"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
@ -261,7 +260,7 @@
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="2057"
|
||||
AdditionalIncludeDirectories="\U\Luca\r020200\server;..\..\wx283\include"
|
||||
AdditionalIncludeDirectories="..\..\wx283\include"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
@ -269,11 +268,10 @@
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/libpath:"/wx283/lib""
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib"
|
||||
OutputFile="../exed/servers/Authoriz.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
IgnoreDefaultLibraryNames="libcd.lib,libcid.lib,msvcrt.lib"
|
||||
IgnoreDefaultLibraryNames=""
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/Authoriz.pdb"
|
||||
SubSystem="2"
|
||||
@ -448,46 +446,6 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\server\BaseServ.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\server\Dongle.cpp"
|
||||
>
|
||||
@ -528,55 +486,11 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\server\xml.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Headers"
|
||||
Filter="h"
|
||||
>
|
||||
<File
|
||||
RelativePath="BaseServ.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="dongle.h"
|
||||
>
|
||||
@ -585,16 +499,16 @@
|
||||
RelativePath="hlapi_c.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="html.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="skeylink.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="xml.h"
|
||||
RelativePath="..\server\server.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
@ -602,172 +516,10 @@
|
||||
RelativePath="..\Lib\hlw32_mc.lib"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\server\server.rc"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
AdditionalIncludeDirectories="\U\Luca\R_04_00\server"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
Culture="1040"
|
||||
AdditionalIncludeDirectories="\U\Luca\R_04_00\server;\U\Release\A_04_00\server;\U\Release\A_02_02\server;\U\Luca\A_02_02\server;\U\Luca\R_02_01\server;\U\Luca\r030200\server;\U\Luca\r020200.aga\server;\U\Luca\wx283\include;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
AdditionalIncludeDirectories="\U\Luca\R_04_00\server"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions=""
|
||||
Culture="1040"
|
||||
AdditionalIncludeDirectories="\U\Luca\R_04_00\server;\U\Release\A_04_00\server;\U\Release\A_02_02\server;\U\Luca\A_02_02\server;\U\Luca\R_02_01\server;\U\Luca\r030200\server;\U\Luca\r020200.aga\server;\U\Luca\wx283\include;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\Lib\skeylink.obj"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxbase28.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxbase28_net.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxbase28_odbc.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxbase28d.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxbase28d_net.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxbase28d_odbc.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxmsw28_adv.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxmsw28_core.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxmsw28d_adv.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\wx283\lib\vc_dll\wxmsw28d_core.lib"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release DLL|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
@ -2,16 +2,37 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual C++ Express 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Authoriz", "Authoriz.vcproj", "{75D3E647-7693-43E7-8634-43CDCC27A5B7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770} = {1991F7F5-2E5A-4985-A328-744D5E8AB770}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseServ", "BaseServ.vcproj", "{317A257E-922D-4266-90A1-FA842756B082}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770} = {1991F7F5-2E5A-4985-A328-744D5E8AB770}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Coffee", "coffee.vcproj", "{AB5A5765-F83F-48B7-B825-364F965AC756}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DataBase", "Database.vcproj", "{70F00347-C9F1-4D91-8D6E-E57B39923B72}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Diction", "Diction.vcproj", "{6A51F3A2-B65B-4007-8619-BA668F241FD2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770} = {1991F7F5-2E5A-4985-A328-744D5E8AB770}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lerch", "Lerch.vcproj", "{7F343AFA-5310-4D90-BA49-AE9B022BC692}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770} = {1991F7F5-2E5A-4985-A328-744D5E8AB770}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Setup", "Setup.vcproj", "{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerLib", "ServerLib\ServerLib.vcproj", "{1991F7F5-2E5A-4985-A328-744D5E8AB770}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Licenser", "Licenser.vcproj", "{96C419F4-5419-4C6C-B5CD-786ED6C1101A}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770} = {1991F7F5-2E5A-4985-A328-744D5E8AB770}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -69,6 +90,30 @@ Global
|
||||
{7F343AFA-5310-4D90-BA49-AE9B022BC692}.Release DLL|Win32.Build.0 = Release DLL|Win32
|
||||
{7F343AFA-5310-4D90-BA49-AE9B022BC692}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{7F343AFA-5310-4D90-BA49-AE9B022BC692}.Release|Win32.Build.0 = Release|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Debug DLL|Win32.ActiveCfg = Debug|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Debug DLL|Win32.Build.0 = Debug|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Release DLL|Win32.ActiveCfg = Release|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Release DLL|Win32.Build.0 = Release|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{59D7EE36-6D12-4A17-AB39-0CDDFDE6DE14}.Release|Win32.Build.0 = Release|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Debug DLL|Win32.ActiveCfg = Debug|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Debug DLL|Win32.Build.0 = Debug|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Release DLL|Win32.ActiveCfg = Release|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Release DLL|Win32.Build.0 = Release|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{1991F7F5-2E5A-4985-A328-744D5E8AB770}.Release|Win32.Build.0 = Release|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Debug DLL|Win32.ActiveCfg = Debug DLL|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Debug DLL|Win32.Build.0 = Debug DLL|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Release DLL|Win32.ActiveCfg = Release DLL|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Release DLL|Win32.Build.0 = Release DLL|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{96C419F4-5419-4C6C-B5CD-786ED6C1101A}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -67,8 +67,7 @@ TUserInfo* TUserTable::AddConnection(wxSocketBase& sock, const wxChar* user, int
|
||||
{
|
||||
wxIPV4address peer; sock.GetPeer(peer);
|
||||
wxString host;
|
||||
|
||||
host = wxString::Format("%s:%d", (const char *) peer.Hostname(), session);
|
||||
host.Printf("%s:%d", (const char *) peer.Hostname(), session);
|
||||
ui = new TUserInfo(user, host);
|
||||
m_Hash.Put(wxString::Format("%s@%s", (const char *) user, host.c_str()), ui);
|
||||
}
|
||||
@ -256,10 +255,7 @@ bool TAuthorizationServer::IsMagicName(wxString& strFilename) const
|
||||
|
||||
wxString TAuthorizationServer::GetModulesFilename() const
|
||||
{
|
||||
wxString strAut = "../campo.aut";
|
||||
if (!wxFileExists(strAut))
|
||||
strAut = "../prassi.aut";
|
||||
return strAut;
|
||||
return "../campo.aut";
|
||||
}
|
||||
|
||||
wxString TAuthorizationServer::DescribeModule(int m) const
|
||||
@ -271,7 +267,7 @@ wxString TAuthorizationServer::DescribeModule(int m) const
|
||||
{
|
||||
aut >> line;
|
||||
if (nModule == m)
|
||||
return line.Mid(3);
|
||||
return line.Mid(3).Trim();
|
||||
}
|
||||
return line; // Should never happen!
|
||||
}
|
||||
@ -341,11 +337,17 @@ void TAuthorizationServer::GenerateIndex(wxString& strFilename)
|
||||
AddNumber(tr4, m_nModules);
|
||||
|
||||
TXmlItem& tr5 = body.AddChild("tr");
|
||||
TXmlItem& al = tr5.AddChild("td").AddChild("a");
|
||||
al.SetAttr("href", "Log"); al << "Log File";
|
||||
tr5.AddChild("td") << "Host name:port";
|
||||
wxIPV4address addr; addr.AnyAddress(); addr.Service(GetDefaultPort());
|
||||
wxString strHP; strHP << addr.Hostname() << ":" << addr.Service();
|
||||
tr5.AddChild("td").SetAttr("align", "right") << strHP;
|
||||
|
||||
TXmlItem& tr6 = body.AddChild("tr");
|
||||
TXmlItem& as = tr6.AddChild("td").AddChild("a");
|
||||
TXmlItem& al = tr6.AddChild("td").AddChild("a");
|
||||
al.SetAttr("href", "Log"); al << "Log File";
|
||||
|
||||
TXmlItem& tr7 = body.AddChild("tr");
|
||||
TXmlItem& as = tr7.AddChild("td").AddChild("a");
|
||||
as.SetAttr("href", "stop.cgi"); as << "Stop the Server";
|
||||
|
||||
strFilename = GetTempFilename();
|
||||
@ -785,9 +787,9 @@ unsigned int TAuthorizationServer::DecodePassword(const wxChar* strPassword, con
|
||||
|
||||
void TAuthorizationServer::ProcessUserLogin(wxString cmd, wxSocketBase& sock)
|
||||
{
|
||||
wxChar strUser[16];
|
||||
wxChar strPassword[16];
|
||||
wxChar strProgram[16];
|
||||
wxChar strUser[32];
|
||||
wxChar strPassword[32];
|
||||
wxChar strProgram[32];
|
||||
int session;
|
||||
|
||||
cmd.Replace(",", " "); cmd.Replace(")", " ");
|
||||
@ -832,8 +834,8 @@ void TAuthorizationServer::ProcessUserLogin(wxString cmd, wxSocketBase& sock)
|
||||
|
||||
bool TAuthorizationServer::ProcessUserLogout(wxString cmd, wxSocketBase& sock)
|
||||
{
|
||||
wxChar strUser[16];
|
||||
wxChar strProgram[16];
|
||||
wxChar strUser[32];
|
||||
wxChar strProgram[32];
|
||||
int session;
|
||||
|
||||
cmd.Replace(",", " "); cmd.Replace(")", " ");
|
||||
@ -915,14 +917,13 @@ bool TAuthorizationServer::Initialization()
|
||||
if (::GlobalFindAtom(ATOMIC_SEMAPHORE) == NULL)
|
||||
::GlobalAddAtom(ATOMIC_SEMAPHORE); // Same as old Frontend.exe
|
||||
#endif
|
||||
int delay = GetConfigInt("Delay", 10);
|
||||
const int delay = GetConfigInt("Delay", 10);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
wxSleep(delay);
|
||||
if (m_Dongle.Login())
|
||||
break;
|
||||
wxSleep(delay);
|
||||
}
|
||||
InitModules();
|
||||
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include <wx/filename.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/sckstrm.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <wx/fileconf.h>
|
||||
#endif
|
||||
@ -54,14 +56,14 @@ wxDateTime String2Date(const wxString& str)
|
||||
wxSocketBase& operator<<(wxSocketBase& outf, const wxChar* str)
|
||||
{
|
||||
if (str && *str)
|
||||
outf.Write(str, wxStrlen(str));
|
||||
outf.Write(str, (wxUint32)wxStrlen(str));
|
||||
return outf;
|
||||
}
|
||||
|
||||
wxSocketBase& operator<<(wxSocketBase& outf, wxString str)
|
||||
{
|
||||
if (!str.IsEmpty())
|
||||
outf.Write(str, str.Length());
|
||||
outf.Write(str, (wxUint32)str.Length());
|
||||
return outf;
|
||||
}
|
||||
|
||||
@ -108,10 +110,14 @@ BEGIN_EVENT_TABLE(TTaskBarIcon, wxTaskBarIcon)
|
||||
EVT_TASKBAR_LEFT_DOWN(TTaskBarIcon::OnTaskBarClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TTaskBarIcon::OnTaskBarClick(wxTaskBarIconEvent& e)
|
||||
void TTaskBarIcon::OnTaskBarClick(wxTaskBarIconEvent& WXUNUSED(e))
|
||||
{
|
||||
wxString url;
|
||||
// wxIPV4address addr; addr.AnyAddress();
|
||||
// addr.Service(GetServerApp().GetDefaultPort());
|
||||
// url << addr.Hostname() << ":" << addr.Service();
|
||||
url << "http://127.0.0.1:" << GetServerApp().GetDefaultPort();
|
||||
|
||||
::ShellExecute(0, "open", url, NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
@ -284,22 +290,22 @@ bool TBaseServerApp::CanProcessCommand(wxString& cmd, wxSocketBase& outs)
|
||||
void TBaseServerApp::SendContent(wxFileInputStream& inf, wxSocketBase& sock)
|
||||
{
|
||||
const size_t nSize = inf.GetSize();
|
||||
WriteLog(wxString::Format("Sending %u bytes", nSize));
|
||||
WriteLog(wxString::Format("Sending %lu bytes", nSize));
|
||||
|
||||
const size_t BUF_TEMP_SIZE = nSize; // was 1024*16
|
||||
const size_t BUF_TEMP_SIZE = 1024*1024; // was 1024*16
|
||||
char* buf = new char[BUF_TEMP_SIZE];
|
||||
size_t bytes = BUF_TEMP_SIZE;
|
||||
size_t nTotalWritten = 0;
|
||||
while (bytes == BUF_TEMP_SIZE)
|
||||
{
|
||||
bytes = inf.Read(buf, bytes).LastRead();
|
||||
size_t nWritten = sock.Write(buf, bytes).LastCount();
|
||||
size_t nWritten = sock.Write(buf, wxUint32(bytes)).LastCount();
|
||||
nTotalWritten += nWritten;
|
||||
}
|
||||
delete buf;
|
||||
|
||||
if (nTotalWritten < nSize)
|
||||
WriteLog(wxString::Format("I sent %u on %u bytes only.", nTotalWritten, nSize));
|
||||
WriteLog(wxString::Format("I sent %lu of %lu bytes only.", nTotalWritten, nSize));
|
||||
}
|
||||
|
||||
void TBaseServerApp::SendFile(wxString strFilename, wxSocketBase& sock)
|
||||
@ -356,6 +362,68 @@ void TBaseServerApp::SendFile(wxString strFilename, wxSocketBase& sock)
|
||||
SendContent(inf, sock);
|
||||
}
|
||||
|
||||
void TBaseServerApp::SoapProcessMethod(const TXmlItem& WXUNUSED(xmlMethod), TXmlItem& WXUNUSED(xmlAnswer))
|
||||
{
|
||||
}
|
||||
|
||||
void TBaseServerApp::ProcessSoapCommand(wxString cmd, wxSocketBase& sock)
|
||||
{
|
||||
TXmlItem xmlEnvelope;
|
||||
xmlEnvelope.SetTag("SOAP-ENV:Envelope");
|
||||
TXmlItem& xmlBody = xmlEnvelope.AddChild("SOAP-ENV:Body");
|
||||
|
||||
const int soapstart = cmd.Find("<SOAP-ENV:");
|
||||
if (soapstart > 0)
|
||||
{
|
||||
const size_t soaplen = cmd.length() - soapstart;
|
||||
const char* buff = (const char*)cmd;
|
||||
buff += soapstart;
|
||||
wxMemoryInputStream input(buff, soaplen);
|
||||
TXmlItem query;
|
||||
if (query.Read(input))
|
||||
{
|
||||
const TXmlItem* pxmlBody = query.FindFirst("SOAP-ENV:Body");
|
||||
if (pxmlBody != NULL) for (int m = 0; ; m++)
|
||||
{
|
||||
const TXmlItem* pxmlMethod = pxmlBody->GetChild(m);
|
||||
if (pxmlMethod == NULL)
|
||||
break;
|
||||
if (pxmlMethod->GetTag().StartsWith("m:"))
|
||||
{
|
||||
wxString str = pxmlMethod->GetTag(); str += "Result";
|
||||
TXmlItem& xmlAnswer = xmlBody.AddChild(str);
|
||||
SoapProcessMethod(*pxmlMethod, xmlAnswer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const wxString strResult = xmlEnvelope.AsString();
|
||||
|
||||
sock << "HTTP/1.1 200 OK" << endl;
|
||||
sock << "Connection: keep-alive" << endl;
|
||||
sock << "Content-Length: " << strResult.Length() << endl;
|
||||
sock << "Content-Type: text/xml; charset=utf-8" << endl;
|
||||
sock << "Date: " << wxDateTime::Now().Format("%#c") << endl;
|
||||
sock << "Server: " << GetAppName() << endl;
|
||||
sock << "Host: " << wxGetFullHostName() << endl;
|
||||
sock << endl;
|
||||
sock << strResult;
|
||||
}
|
||||
|
||||
void TBaseServerApp::ProcessHttpGet(wxString cmd, wxSocketBase& sock)
|
||||
{
|
||||
const int stop = cmd.Find(" HTTP");
|
||||
wxString str = cmd.Mid(4, stop-4).Trim();
|
||||
if (str == "/")
|
||||
str += "index.htm";
|
||||
wxString strFilename = GetDocumentRoot() + str;
|
||||
SendFile(strFilename, sock);
|
||||
}
|
||||
|
||||
void TBaseServerApp::ProcessFormCommand(wxString WXUNUSED(cmd),
|
||||
wxSocketBase& WXUNUSED(sock))
|
||||
{ }
|
||||
|
||||
void TBaseServerApp::SendNotModifiedFile(wxSocketBase& sock)
|
||||
{
|
||||
sock << "HTTP/1.1 304 Not Modified\n";
|
||||
@ -372,9 +440,15 @@ const wxChar* TBaseServerApp::GetAppName() const
|
||||
|
||||
void TBaseServerApp::ProcessCommand(wxString cmd, wxSocketBase& outs)
|
||||
{
|
||||
// Pure virtual function
|
||||
WriteLog("Processing...");
|
||||
SendFile("index.htm", outs);
|
||||
if (cmd.StartsWith("POST "))
|
||||
{
|
||||
if (cmd.Find("SOAPAction") > 0)
|
||||
ProcessSoapCommand(cmd, outs);
|
||||
else
|
||||
ProcessFormCommand(cmd, outs);
|
||||
} else
|
||||
if (cmd.StartsWith("GET "))
|
||||
ProcessHttpGet(cmd, outs);
|
||||
}
|
||||
|
||||
void TBaseServerApp::OnServerEvent(wxSocketEvent& event)
|
||||
@ -411,58 +485,57 @@ void TBaseServerApp::OnServerEvent(wxSocketEvent& event)
|
||||
sock->Notify(TRUE);
|
||||
}
|
||||
|
||||
void TBaseServerApp::OnSocketEvent(wxSocketEvent& event)
|
||||
void TBaseServerApp::OnSocketEvent(wxSocketEvent& e)
|
||||
{
|
||||
wxSocketBase& sock = *event.GetSocket();
|
||||
switch(event.GetSocketEvent())
|
||||
wxSocketBase& sock = *e.GetSocket();
|
||||
switch(e.GetSocketEvent())
|
||||
{
|
||||
case wxSOCKET_INPUT:
|
||||
case wxSOCKET_INPUT:
|
||||
{
|
||||
// We disable input events, so that the test doesn't trigger
|
||||
// wxSocketEvent again.
|
||||
sock.SetNotify(wxSOCKET_LOST_FLAG);
|
||||
|
||||
// Read the data
|
||||
const size_t BUFSIZE = 2048;
|
||||
wxString str;
|
||||
wxChar* bufStart = str.GetWriteBuf(BUFSIZE);
|
||||
memset(bufStart, 0, BUFSIZE);
|
||||
wxChar* buf = bufStart;
|
||||
// Read the data
|
||||
const size_t BUFSIZE = 2048;
|
||||
wxString str;
|
||||
wxChar* bufStart = str.GetWriteBuf(BUFSIZE);
|
||||
memset(bufStart, 0, BUFSIZE);
|
||||
wxChar* buf = bufStart;
|
||||
|
||||
const size_t len = sock.Read(buf, BUFSIZE).LastCount();
|
||||
buf += len;
|
||||
// Attendi la fine del comando HTTP!
|
||||
const size_t len = sock.Read(buf, BUFSIZE).LastCount();
|
||||
buf += len;
|
||||
// Attendi la fine del comando HTTP!
|
||||
if (strncmp(bufStart, "GET ", 4) == 0 || strncmp(bufStart, "POST ", 5) == 0)
|
||||
{
|
||||
while (strstr(bufStart, "\r\n\r\n") == NULL)
|
||||
{
|
||||
const size_t len = sock.Read(buf, BUFSIZE).LastCount();
|
||||
buf += len;
|
||||
}
|
||||
}
|
||||
{
|
||||
while (strstr(bufStart, "\r\n\r\n") == NULL)
|
||||
{
|
||||
const size_t len = sock.Read(buf, BUFSIZE).LastCount();
|
||||
buf += len;
|
||||
}
|
||||
}
|
||||
str.UngetWriteBuf();
|
||||
|
||||
WriteLog(str);
|
||||
|
||||
if (CanProcessCommand(str, sock))
|
||||
{
|
||||
const wxSocketFlags flags = sock.GetFlags();
|
||||
sock.SetFlags(wxSOCKET_WAITALL);
|
||||
ProcessCommand(str, sock);
|
||||
sock.SetFlags(flags);
|
||||
}
|
||||
if (CanProcessCommand(str, sock))
|
||||
{
|
||||
const wxSocketFlags flags = sock.GetFlags();
|
||||
sock.SetFlags(wxSOCKET_WAITALL);
|
||||
ProcessCommand(str, sock);
|
||||
sock.SetFlags(flags);
|
||||
}
|
||||
|
||||
// Enable input events again.
|
||||
sock.SetNotify(wxSOCKET_LOST_FLAG | wxSOCKET_INPUT_FLAG);
|
||||
break;
|
||||
}
|
||||
case wxSOCKET_LOST:
|
||||
{
|
||||
WriteLog("--- Deleting socket.");
|
||||
sock.Destroy();
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
break;
|
||||
case wxSOCKET_LOST:
|
||||
WriteLog("--- Deleting socket.");
|
||||
sock.Destroy();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,9 +543,9 @@ const wxString& TBaseServerApp::GetConfigName() const
|
||||
{
|
||||
if (m_strIni.IsEmpty())
|
||||
{
|
||||
wxFileName name(argv[0]);
|
||||
name.SetName("servers");
|
||||
name.SetExt("ini");
|
||||
wxFileName name(argv[0]); // Prendo il persorso completo del server in esecuzione
|
||||
name.SetName("servers"); // Trasformo il nome in servers ...
|
||||
name.SetExt("ini"); // ... e l'esetensione in .ini
|
||||
(wxString&)m_strIni = name.GetFullPath();
|
||||
}
|
||||
return m_strIni;
|
||||
@ -491,7 +564,7 @@ void TBaseServerApp::SetConfigString(const wxChar* key, const wxChar* val, const
|
||||
|
||||
void TBaseServerApp::SetConfigInt(const wxChar* key, int val, const wxChar* app) const
|
||||
{
|
||||
wxString str = wxString::Format("%d", val);
|
||||
wxString str; str.Printf("%d", val);
|
||||
SetConfigString(key, str, app);
|
||||
}
|
||||
|
||||
@ -562,6 +635,7 @@ bool TBaseServerApp::OnInit()
|
||||
|
||||
// Create the address - defaults to localhost:0 initially
|
||||
wxIPV4address addr;
|
||||
addr.AnyAddress(); // I docs affermano che AnyAddress sia meglio di LocalHost
|
||||
addr.Service(GetDefaultPort());
|
||||
// Create the socket
|
||||
m_server = new wxSocketServer(addr);
|
||||
@ -586,7 +660,7 @@ bool TBaseServerApp::OnInit()
|
||||
m_server->SetNotify(wxSOCKET_CONNECTION_FLAG);
|
||||
m_server->Notify(TRUE);
|
||||
|
||||
str << GetAppName() << " listening on port " << addr.Service();
|
||||
str << GetAppName() << " listening at " << addr.Hostname() << ":" << addr.Service();
|
||||
m_bRunning = true;
|
||||
}
|
||||
else
|
||||
@ -661,7 +735,7 @@ wxString TBaseServerApp::UnformatString(const wxString& strFormString) const
|
||||
return strResult;
|
||||
}
|
||||
|
||||
int TBaseServerApp::ParseArguments(wxString args, THashTable& hashArgs) const
|
||||
size_t TBaseServerApp::ParseArguments(wxString args, THashTable& hashArgs) const
|
||||
{
|
||||
int uguale = args.Find('=');
|
||||
while (uguale > 0)
|
||||
|
@ -93,9 +93,7 @@ private:
|
||||
protected:
|
||||
wxSingleInstanceChecker* m_SingleInstance;
|
||||
|
||||
// Pure virtual functions!
|
||||
virtual void ProcessCommand(wxString cmd, wxSocketBase& outs) = 0;
|
||||
|
||||
virtual void ProcessCommand(wxString cmd, wxSocketBase& outs);
|
||||
virtual bool CanProcessCommand(wxString& cmd, wxSocketBase& outs);
|
||||
|
||||
virtual wxString GetDocumentRoot() const;
|
||||
@ -106,6 +104,11 @@ protected:
|
||||
void SendContent(wxFileInputStream& inf, wxSocketBase& sock);
|
||||
void SendNotModifiedFile(wxSocketBase& sock);
|
||||
|
||||
virtual void SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer);
|
||||
virtual void ProcessSoapCommand(wxString cmd, wxSocketBase& sock);
|
||||
virtual void ProcessFormCommand(wxString cmd, wxSocketBase& outs);
|
||||
virtual void ProcessHttpGet(wxString cmd, wxSocketBase& outs);
|
||||
|
||||
public:
|
||||
// Utilities
|
||||
virtual const wxChar* GetAppName() const = 0;
|
||||
@ -127,7 +130,7 @@ public:
|
||||
void MessageBox(const wxChar* caption, const wxChar* msg, wxSocketBase& sock);
|
||||
|
||||
wxString UnformatString(const wxString& strFormString) const;
|
||||
int ParseArguments(wxString args, THashTable& hashArgs) const;
|
||||
size_t ParseArguments(wxString args, THashTable& hashArgs) const;
|
||||
|
||||
virtual void WriteLog(const wxChar* str) const; // Writes on log file if present
|
||||
virtual bool Ok() const { return m_server->Ok(); }
|
||||
|
@ -332,13 +332,12 @@ class TDictionaryServer : public TBaseServerApp
|
||||
protected:
|
||||
virtual const wxChar* GetAppName() const;
|
||||
virtual void ProcessCommand(wxString cmd, wxSocketBase& outs);
|
||||
virtual void SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer);
|
||||
|
||||
size_t FindIndex(const wxString& strKey);
|
||||
|
||||
public:
|
||||
bool DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer);
|
||||
bool SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer);
|
||||
void ProcessSoapCommand(wxString cmd, wxSocketBase& outs);
|
||||
void ProcessHttpGet(wxString cmd, wxSocketBase& outs);
|
||||
void ProcessFormCommand(wxString cmd, wxSocketBase& outs);
|
||||
|
||||
@ -360,13 +359,11 @@ public:
|
||||
TDictionaryServer();
|
||||
};
|
||||
|
||||
bool TDictionaryServer::SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer)
|
||||
void TDictionaryServer::SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer)
|
||||
{
|
||||
const wxString& strMethod = xmlMethod.GetTag();
|
||||
if (strMethod == "m:Translate")
|
||||
return DoTranslate(xmlMethod, xmlAnswer);
|
||||
|
||||
return false;
|
||||
DoTranslate(xmlMethod, xmlAnswer);
|
||||
}
|
||||
|
||||
bool TDictionaryServer::DoTranslate(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer)
|
||||
@ -641,50 +638,6 @@ const wxChar* TDictionaryServer::GetAppName() const
|
||||
return "Dictionary";
|
||||
}
|
||||
|
||||
void TDictionaryServer::ProcessSoapCommand(wxString cmd, wxSocketBase& sock)
|
||||
{
|
||||
TXmlItem xmlEnvelope;
|
||||
xmlEnvelope.SetTag("SOAP-ENV:Envelope");
|
||||
TXmlItem& xmlBody = xmlEnvelope.AddChild("SOAP-ENV:Body");
|
||||
|
||||
const int soapstart = cmd.Find("<SOAP-ENV:");
|
||||
if (soapstart > 0)
|
||||
{
|
||||
const size_t soaplen = cmd.length() - soapstart;
|
||||
const char* buff = (const char*)cmd;
|
||||
buff += soapstart;
|
||||
wxMemoryInputStream input(buff, soaplen);
|
||||
TXmlItem query;
|
||||
if (query.Read(input))
|
||||
{
|
||||
const TXmlItem* pxmlBody = query.FindFirst("SOAP-ENV:Body");
|
||||
if (pxmlBody != NULL) for (int m = 0; ; m++)
|
||||
{
|
||||
const TXmlItem* pxmlMethod = pxmlBody->GetChild(m);
|
||||
if (pxmlMethod == NULL)
|
||||
break;
|
||||
if (pxmlMethod->GetTag().StartsWith("m:"))
|
||||
{
|
||||
wxString str = pxmlMethod->GetTag(); str += "Result";
|
||||
TXmlItem& xmlAnswer = xmlBody.AddChild(str);
|
||||
SoapProcessMethod(*pxmlMethod, xmlAnswer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const wxString strResult = xmlEnvelope.AsString();
|
||||
|
||||
sock << "HTTP/1.1 200 OK" << endl;
|
||||
sock << "Connection: keep-alive" << endl;
|
||||
sock << "Content-Length: " << strResult.Length() << endl;
|
||||
sock << "Content-Type: text/xml; charset=utf-8" << endl;
|
||||
sock << "Date: " << wxDateTime::Now().Format("%#c") << endl;
|
||||
sock << "Server: " << GetAppName() << endl;
|
||||
sock << "Host: " << wxGetFullHostName() << endl;
|
||||
sock << endl;
|
||||
sock << strResult;
|
||||
}
|
||||
|
||||
void TDictionaryServer::ProcessHttpGet(wxString cmd, wxSocketBase& outs)
|
||||
{
|
||||
const int stop = cmd.Find(" HTTP");
|
||||
@ -794,19 +747,6 @@ void TDictionaryServer::ProcessFormCommand(wxString cmd, wxSocketBase& outs)
|
||||
SendFile(strFileName, outs);
|
||||
}
|
||||
|
||||
void TDictionaryServer::ProcessCommand(wxString cmd, wxSocketBase& outs)
|
||||
{
|
||||
if (cmd.StartsWith("POST "))
|
||||
{
|
||||
if (cmd.Find("SOAPAction") > 0)
|
||||
ProcessSoapCommand(cmd, outs);
|
||||
else
|
||||
ProcessFormCommand(cmd, outs);
|
||||
} else
|
||||
if (cmd.StartsWith("GET "))
|
||||
ProcessHttpGet(cmd, outs);
|
||||
}
|
||||
|
||||
bool TDictionaryServer::Initialization()
|
||||
{
|
||||
return m_DevotoOli.LoadIfEmpty();
|
||||
|
275
server/licenser.cpp
Executable file
275
server/licenser.cpp
Executable file
@ -0,0 +1,275 @@
|
||||
#include "baseserv.h"
|
||||
|
||||
#include "dongle.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TLicenseServer
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TLicenseServer : public TBaseServerApp
|
||||
{
|
||||
private:
|
||||
TDongle m_Dongle;
|
||||
|
||||
protected:
|
||||
virtual const wxChar* GetAppName() const;
|
||||
void AddNumber(TXmlItem& tr, int n) const;
|
||||
wxString Garble(unsigned short n, const wxDateTime& date) const;
|
||||
|
||||
virtual bool Initialization();
|
||||
virtual bool Deinitialization();
|
||||
virtual void SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer);
|
||||
virtual void ProcessFormCommand(wxString cmd, wxSocketBase& outs);
|
||||
|
||||
public:
|
||||
bool IsMagicName(wxString& strFilename) const;
|
||||
void GenerateIndex(wxString& strFilename);
|
||||
void GenerateFile(wxString& strFile);
|
||||
|
||||
wxString Garble(unsigned short nDongle, unsigned short nNumber) const;
|
||||
|
||||
};
|
||||
|
||||
wxString TLicenseServer::Garble(unsigned short nMaster, unsigned short nDongle,
|
||||
long nNumber) const
|
||||
{
|
||||
unsigned short data[4];
|
||||
data[0] = nMaster;
|
||||
data[1] = nDongle;
|
||||
data[2] = (unsigned short)(nNumber >> 16);
|
||||
data[3] = (unsigned short)(nNumber & 0xFFFF);
|
||||
m_Dongle.garble(data);
|
||||
return wxString::Format("%04X%04X%04X%04X", data[0], data[1], data[2], data[3]);
|
||||
}
|
||||
|
||||
// Implementare almeno queste due funzioni pure virtuali
|
||||
|
||||
const wxChar* TLicenseServer::GetAppName() const
|
||||
{ return "Licenser"; }
|
||||
|
||||
bool TLicenseServer::IsMagicName(wxString& strFilename) const
|
||||
{
|
||||
wxString strName;
|
||||
wxSplitPath(strFilename, NULL, &strName, NULL);
|
||||
strName.MakeLower();
|
||||
const int q = strName.Find('?');
|
||||
if (q > 0)
|
||||
strName.Truncate(q);
|
||||
|
||||
if (strName == "index" || strName == "modules")
|
||||
{
|
||||
strFilename = strName;
|
||||
return true;
|
||||
} else
|
||||
if (strName == "log")
|
||||
{
|
||||
strFilename = GetLogFileName();
|
||||
} else
|
||||
if (strName == "activate" || strName == "deactivate" ||
|
||||
strName == "year" || strName == "maxusers" || strName == "kill")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TLicenseServer::AddNumber(TXmlItem& tr, int n) const
|
||||
{
|
||||
TXmlItem& td = tr.AddChild("td");
|
||||
td.SetAttr("align", "right");
|
||||
td << wxString::Format("%d", n);
|
||||
}
|
||||
|
||||
void TLicenseServer::GenerateIndex(wxString& strFilename)
|
||||
{
|
||||
TXmlItem html;
|
||||
TXmlItem& body = CreatePageBody(html);
|
||||
|
||||
TXmlItem& title = body.AddChild("h1").AddChild("center");
|
||||
if (m_Dongle.Ok())
|
||||
{
|
||||
TXmlItem& tr = title.AddChild("table").SetAttr("width", "40%").AddChild("tr");
|
||||
|
||||
TXmlItem& td = tr.AddChild("td").SetAttr("width", "30%");
|
||||
const bool hard = m_Dongle.hardware() == _dongle_hardlock;
|
||||
TXmlItem& img = td.AddChild("img");
|
||||
img.SetAttr("src", hard ? "hardlock.gif" : "eutron.gif");
|
||||
|
||||
tr.AddChild("td").SetAttr("align", "center").AddChild("h1") << (hard ? "Hardlock EYE" : "Eutron Smartkey");
|
||||
}
|
||||
else
|
||||
{
|
||||
title << "No Dongle Connected!";
|
||||
}
|
||||
body.AddChild("br");
|
||||
|
||||
TXmlItem& table = body.AddChild("center").AddChild("table");
|
||||
table.SetAttr("border", "1");
|
||||
table.SetAttr("width", "70%");
|
||||
|
||||
TXmlItem& tr0 = body.AddChild("tr");
|
||||
tr0.AddChild("td") << "Serial Number";
|
||||
AddNumber(tr0, m_Dongle.Number());
|
||||
|
||||
TXmlItem& tr1 = body.AddChild("tr");
|
||||
TXmlItem& ay = tr1.AddChild("td").AddChild("a");
|
||||
ay.SetAttr("href", "year.htm") << "Assistance Year";
|
||||
AddNumber(tr1, m_Dongle.YearAssist());
|
||||
|
||||
TXmlItem& tr2 = body.AddChild("tr");
|
||||
TXmlItem& mu = tr2.AddChild("td").AddChild("a");
|
||||
mu.SetAttr("href", "maxusers.htm") << "Maximum Users";
|
||||
AddNumber(tr2, m_Dongle.MaxUsers());
|
||||
|
||||
TXmlItem& tr5 = body.AddChild("tr");
|
||||
tr5.AddChild("td") << "Host name:port";
|
||||
wxIPV4address addr; addr.AnyAddress(); addr.Service(GetDefaultPort());
|
||||
wxString strHP; strHP << addr.Hostname() << ":" << addr.Service();
|
||||
tr5.AddChild("td").SetAttr("align", "right") << strHP;
|
||||
|
||||
TXmlItem& tr6 = body.AddChild("tr");
|
||||
TXmlItem& al = tr6.AddChild("td").AddChild("a");
|
||||
al.SetAttr("href", "Log"); al << "Log File";
|
||||
|
||||
TXmlItem& tr7 = body.AddChild("tr");
|
||||
TXmlItem& as = tr7.AddChild("td").AddChild("a");
|
||||
as.SetAttr("href", "stop.cgi"); as << "Stop the Server";
|
||||
|
||||
strFilename = GetTempFilename();
|
||||
html.Save(strFilename);
|
||||
}
|
||||
|
||||
void TLicenseServer::GenerateFile(wxString& strFilename)
|
||||
{
|
||||
const int q = strFilename.Find('?');
|
||||
wxString strArgs;
|
||||
if (q > 0)
|
||||
{
|
||||
strArgs = strFilename.Mid(q+1);
|
||||
strFilename.Truncate(q);
|
||||
}
|
||||
|
||||
wxString strName;
|
||||
wxSplitPath(strFilename, NULL, &strName, NULL);
|
||||
strName.MakeLower();
|
||||
|
||||
if (strName == "index")
|
||||
{
|
||||
GenerateIndex(strFilename);
|
||||
} else
|
||||
if (strName == "modules")
|
||||
{
|
||||
} else
|
||||
if (strName == "users")
|
||||
{
|
||||
} else
|
||||
if (strName == "log")
|
||||
{
|
||||
strFilename = GetLogFileName();
|
||||
} else
|
||||
if (strName == "activate")
|
||||
{
|
||||
} else
|
||||
if (strName == "deactivate")
|
||||
{
|
||||
} else
|
||||
if (strName == "year")
|
||||
{
|
||||
} else
|
||||
if (strName == "maxusers")
|
||||
{
|
||||
} else
|
||||
if (strName == "kill")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void TLicenseServer::ProcessFormCommand(wxString cmd, wxSocketBase& outs)
|
||||
{
|
||||
const int stop = cmd.Find(" HTTP");
|
||||
wxString strFileName = cmd.Mid(5, stop-5).Trim();
|
||||
|
||||
wxString strName, args;
|
||||
wxSplitPath(strFileName, NULL, &strName, NULL);
|
||||
strName.MakeLower();
|
||||
|
||||
const int pos = cmd.Find("\r\n\r\n");
|
||||
if (pos > 0)
|
||||
args = cmd.Mid(pos+4);
|
||||
|
||||
THashTable hashArgs(13);
|
||||
ParseArguments(args, hashArgs);
|
||||
|
||||
if (strName == "activate")
|
||||
{
|
||||
} else
|
||||
if (strName == "deactivate")
|
||||
{
|
||||
} else
|
||||
if (strName == "year")
|
||||
{
|
||||
} else
|
||||
if (strName == "maxusers")
|
||||
{
|
||||
} else
|
||||
MessageBox("ERROR!", "You supplied the wrong activation code", outs);
|
||||
}
|
||||
|
||||
bool TLicenseServer::Initialization()
|
||||
{
|
||||
const int delay = GetConfigInt("Delay", 10);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (m_Dongle.Login())
|
||||
break;
|
||||
wxSleep(delay);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TLicenseServer::Deinitialization()
|
||||
{
|
||||
m_Dongle.Logout();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TLicenseServer::SoapProcessMethod(const TXmlItem& xmlMethod, TXmlItem& xmlAnswer)
|
||||
{
|
||||
const wxString& strMethod = xmlMethod.GetTag();
|
||||
|
||||
if (strMethod == "m:ActivateYear") // ActivateYear(int master, int dongle, int year, string pwd)
|
||||
{
|
||||
const int nMaster = xmlMethod.GetSoapInt("master");
|
||||
if (nMaster <= 0 || nMaster >= 1000)
|
||||
{
|
||||
xmlAnswer.AddSoapInt("error", 1);
|
||||
xmlAnswer.AddSoapString("description", "Invalid Master Dongle number");
|
||||
return;
|
||||
}
|
||||
|
||||
const int nDongle = xmlMethod.GetSoapInt("dongle");
|
||||
if (nDongle < 1000 || nDongle >= 10000)
|
||||
{
|
||||
xmlAnswer.AddSoapInt("error", 1);
|
||||
xmlAnswer.AddSoapString("description", "Invalid Dongle number");
|
||||
return;
|
||||
}
|
||||
|
||||
const int nYear = xmlMethod.GetSoapInt("year");
|
||||
if (nYear < 2000 || nYear > 3000)
|
||||
{
|
||||
xmlAnswer.AddSoapInt("error", 2);
|
||||
xmlAnswer.AddSoapString("description", "Invalid Year");
|
||||
return;
|
||||
}
|
||||
|
||||
const wxString strPwd = xmlMethod.GetSoapInt("password");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Istanziare l'applicazione principale
|
||||
|
||||
IMPLEMENT_APP(TLicenseServer)
|
443
server/lurch.cpp
Executable file
443
server/lurch.cpp
Executable file
@ -0,0 +1,443 @@
|
||||
#include "baseserv.h"
|
||||
|
||||
#include <wx/config.h>
|
||||
#ifdef WIN32
|
||||
#include <wx/fileconf.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
class TLurchServer : public TBaseServerApp
|
||||
{
|
||||
protected:
|
||||
virtual const wxChar* GetAppName() const;
|
||||
virtual bool Initialization();
|
||||
|
||||
void AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const;
|
||||
void EnumerateVariables(const wxString& strApp, wxArrayString& arr) const;
|
||||
|
||||
void CreateServersList(wxArrayString& arr) const;
|
||||
void KillProcess(const wxString& strApp);
|
||||
|
||||
public:
|
||||
void GenerateFile(wxString& strFilename);
|
||||
bool IsMagicName(wxString& strFilename) const;
|
||||
bool IsCgiName(wxString strFilename) const;
|
||||
|
||||
void ProcessHttpGet(wxString cmd, wxSocketBase& outs);
|
||||
void ProcessHttpPost(wxString cmd, wxSocketBase& outs);
|
||||
|
||||
void ProcessFormStart(const THashTable& args, wxSocketBase& sock);
|
||||
void ProcessFormKill(const THashTable& args, wxSocketBase& sock);
|
||||
void ProcessFormConfig(const THashTable& args, wxSocketBase& sock);
|
||||
void ProcessFormUpdate(THashTable& args, wxSocketBase& sock);
|
||||
void CallCgi(wxString& strFileName, wxSocketBase& sock);
|
||||
};
|
||||
|
||||
const wxChar* TLurchServer::GetAppName() const
|
||||
{
|
||||
return "Lurch";
|
||||
}
|
||||
|
||||
void TLurchServer::CreateServersList(wxArrayString& arr) const
|
||||
{
|
||||
wxFileInputStream ini(GetConfigName());
|
||||
const size_t size = ini.GetSize();
|
||||
wxChar* buff = new wxChar[size];
|
||||
ini.Read(buff, size);
|
||||
|
||||
const char* aperta = strchr(buff, '[');
|
||||
while (aperta != NULL)
|
||||
{
|
||||
char* chiusa = (char*)strchr(aperta+1, ']');
|
||||
if (chiusa != NULL)
|
||||
{
|
||||
*chiusa = '\0';
|
||||
wxString str = aperta+1;
|
||||
arr.Add(str);
|
||||
aperta = strchr(chiusa+1, '[');
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
delete buff;
|
||||
}
|
||||
|
||||
void TLurchServer::AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const
|
||||
{
|
||||
TXmlItem& td = tr.AddChild("td").SetAttr("width", "15%");
|
||||
TXmlItem& form = td.AddChild("center").AddChild("form");
|
||||
form.SetAttr("action", action);
|
||||
|
||||
TXmlItem& name = form.AddChild("input");
|
||||
name.SetAttr("type", "hidden"); name.SetAttr("name", "App");
|
||||
name.SetAttr("value", app);
|
||||
|
||||
TXmlItem& submit = form.AddChild("input");
|
||||
submit.SetAttr("type", "submit");
|
||||
submit.SetAttr("value", prompt);
|
||||
}
|
||||
|
||||
void TLurchServer::GenerateFile(wxString& strFilename)
|
||||
{
|
||||
TXmlItem html;
|
||||
TXmlItem& body = CreatePageBody(html);
|
||||
|
||||
if (strFilename == "index")
|
||||
{
|
||||
TXmlItem& table = body.AddChild("table");
|
||||
table.SetAttr("border", "1"); table.SetAttr("width", "100%");
|
||||
strFilename = GetTempFilename();
|
||||
const wxString strLurchName = GetAppName();
|
||||
|
||||
wxArrayString arr; CreateServersList(arr);
|
||||
for (size_t i = 0; i < arr.GetCount(); i++)
|
||||
{
|
||||
const bool bLurch = arr[i] == strLurchName;
|
||||
wxFileConfig ini("", "", GetConfigName(), "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
|
||||
wxString str;
|
||||
str << '/' << arr[i];
|
||||
ini.SetPath(str);
|
||||
|
||||
wxString strHost;
|
||||
ini.Read("Host", &strHost, wxGetFullHostName());
|
||||
|
||||
int nPort;
|
||||
ini.Read("Port", &nPort, 3883);
|
||||
|
||||
wxString strIcon;
|
||||
ini.Read("Icon", &strIcon, "euro.gif");
|
||||
|
||||
const wxSingleInstanceChecker sic(arr[i]);
|
||||
const bool bRunning = sic.IsAnotherRunning();
|
||||
|
||||
TXmlItem& tr = table.AddChild("tr");
|
||||
TXmlItem& td0 = tr.AddChild("td");
|
||||
td0.SetAttr("width", "15%"); td0.SetAttr("align", "center");
|
||||
TXmlItem& a = td0.AddChild("a");
|
||||
if (!bLurch && bRunning)
|
||||
{
|
||||
a.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost.c_str(), nPort));
|
||||
a.SetAttr("target", "_blank");
|
||||
}
|
||||
TXmlItem& img = a.AddChild("img");
|
||||
img.SetAttr("src", strIcon); img.SetAttr("border", 0L); img.SetAttr("alt", arr[i]);
|
||||
|
||||
AddMiniForm(tr, (bRunning || bLurch) ? "kill.cgi" : "start.cgi", arr[i], (bRunning || bLurch) ? "Stop" : "Start");
|
||||
AddMiniForm(tr, "config.cgi", arr[i], "Configure");
|
||||
|
||||
TXmlItem& a3 = tr.AddChild("td").AddChild("a");
|
||||
if (!bLurch && bRunning)
|
||||
{
|
||||
a3.SetAttr("href", wxString::Format("http://%s:%d/index.htm", strHost.c_str(), nPort));
|
||||
a3.SetAttr("target", "_blank");
|
||||
}
|
||||
a3 << arr[i] << " Server";
|
||||
}
|
||||
|
||||
html.Save(strFilename);
|
||||
}
|
||||
}
|
||||
|
||||
bool TLurchServer::IsMagicName(wxString& strFilename) const
|
||||
{
|
||||
wxString strName;
|
||||
wxSplitPath(strFilename, NULL, &strName, NULL);
|
||||
strName.MakeLower();
|
||||
if (strName == "index")
|
||||
{
|
||||
strFilename = strName;
|
||||
return true;
|
||||
}
|
||||
if (strName == "log")
|
||||
{
|
||||
strFilename = GetLogFileName();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TLurchServer::IsCgiName(wxString strFilename) const
|
||||
{
|
||||
const int q = strFilename.Find('?');
|
||||
if (q > 0)
|
||||
strFilename.Truncate(q);
|
||||
|
||||
wxString strExt;
|
||||
wxSplitPath(strFilename, NULL, NULL, &strExt);
|
||||
strExt.MakeLower();
|
||||
return strExt == "cgi" || strExt == "exe";
|
||||
}
|
||||
|
||||
void TLurchServer::ProcessFormStart(const THashTable& args, wxSocketBase& sock)
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
const wxString strApp = args.Get("App");
|
||||
if (!strApp.IsEmpty()) // Dummy test
|
||||
{
|
||||
const wxSingleInstanceChecker sic(strApp);
|
||||
ok = !sic.IsAnotherRunning();
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
wxString strRun = GetConfigString("Run", "", strApp);
|
||||
if (wxFileExists(strRun))
|
||||
{
|
||||
#ifdef LINUX
|
||||
if (strRun[ 0u] != '/' && strRun[ 0u] != '.')
|
||||
strRun = "./" + strRun;
|
||||
#endif
|
||||
const long nProc = wxExecute(strRun);
|
||||
if (nProc == 0 || nProc == -1)
|
||||
MessageBox("ERROR", wxString::Format("Can't run %s executable (%s)", strApp.c_str(),
|
||||
strRun.c_str()), sock);
|
||||
else
|
||||
MessageBox("Server Started", strApp, sock);
|
||||
}
|
||||
else
|
||||
MessageBox("ERROR", wxString::Format("Can't find %s executable (%s)", strApp.c_str(),
|
||||
strRun.c_str()), sock);
|
||||
}
|
||||
else
|
||||
MessageBox("ERROR", wxString::Format("%s il already running", strApp.c_str()), sock);
|
||||
}
|
||||
|
||||
void TLurchServer::KillProcess(const wxString& strApp)
|
||||
{
|
||||
const wxString strHost = GetConfigString("Host", "localhost", strApp);
|
||||
const int nPort = GetConfigInt("Port", 0, strApp);
|
||||
if (nPort > 0)
|
||||
{
|
||||
wxIPV4address addr;
|
||||
addr.Hostname(strHost);
|
||||
addr.Service(nPort);
|
||||
|
||||
wxSocketClient sock;
|
||||
if (sock.Connect(addr))
|
||||
{
|
||||
const wxString str = "GET /stop.cgi HTTP/1.1\r\n\r\n";
|
||||
sock.Write(str, str.Length());
|
||||
if (strHost == "localhost")
|
||||
{
|
||||
const wxSingleInstanceChecker sic(strApp);
|
||||
for (int i = 0; i < 5 && sic.IsAnotherRunning(); i++)
|
||||
wxSleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TLurchServer::ProcessFormKill(const THashTable& args, wxSocketBase& sock)
|
||||
{
|
||||
const wxString strApp = args.Get("App");
|
||||
if (strApp == GetAppName()) // Stop myself!
|
||||
{
|
||||
wxArrayString app; CreateServersList(app);
|
||||
for (size_t i = 0; i < app.GetCount(); i++)
|
||||
{
|
||||
if (app[i] != GetAppName()) // Stop Children only!
|
||||
{
|
||||
const wxSingleInstanceChecker sic(app[i]);
|
||||
if (sic.IsAnotherRunning())
|
||||
KillProcess(app[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
KillProcess(strApp);
|
||||
MessageBox("Server stopped", strApp, sock);
|
||||
}
|
||||
|
||||
void TLurchServer::EnumerateVariables(const wxString& strApp, wxArrayString& arr) const
|
||||
{
|
||||
wxFileInputStream inf(GetConfigName());
|
||||
wxString strParagraph = wxString::Format("[%s]", strApp.c_str());
|
||||
wxString str;
|
||||
|
||||
bool bFound = false;
|
||||
while (inf.Ok())
|
||||
{
|
||||
inf >> str;
|
||||
if (str == strParagraph)
|
||||
{
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFound)
|
||||
{
|
||||
while (inf.Ok())
|
||||
{
|
||||
inf >> str;
|
||||
if (str.IsEmpty() || str[0u] == '[')
|
||||
break;
|
||||
const int nEqual = str.Find('=');
|
||||
if (nEqual > 0)
|
||||
{
|
||||
str.Truncate(nEqual);
|
||||
str.Trim(false);
|
||||
str.Trim(true);
|
||||
arr.Add(str);
|
||||
}
|
||||
}
|
||||
arr.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
void TLurchServer::ProcessFormConfig(const THashTable& args, wxSocketBase& sock)
|
||||
{
|
||||
const wxString strApp = args.Get("App");
|
||||
wxArrayString arr;
|
||||
EnumerateVariables(strApp, arr);
|
||||
|
||||
TXmlItem html;
|
||||
TXmlItem& body = CreatePageBody(html);
|
||||
|
||||
TXmlItem& form = body.AddChild("form");
|
||||
form.SetAttr("action", "update.cgi").SetAttr("method", "post");
|
||||
|
||||
TXmlItem& table = form.AddChild("table").SetAttr("width", "100%").SetAttr("border", "1");
|
||||
table.AddChild("caption").AddChild("h2") << strApp;
|
||||
TXmlItem& thead = table.AddChild("thead");
|
||||
thead.AddChild("th").SetAttr("width", "15%") << "Property";
|
||||
thead.AddChild("th").SetAttr("width", "85%") << "Value";
|
||||
|
||||
for (size_t v = 0; v < arr.GetCount(); v++)
|
||||
{
|
||||
TXmlItem& tr = table.AddChild("tr");
|
||||
tr.AddChild("td") << arr[v];
|
||||
TXmlItem& input = tr.AddChild("td").AddChild("input");
|
||||
input.SetAttr("type", "text"); input.SetAttr("name", arr[v]);
|
||||
input.SetAttr("size", "80"); input.SetAttr("maxlength", "256");
|
||||
input.SetAttr("value", GetConfigString(arr[v], "", strApp));
|
||||
}
|
||||
|
||||
TXmlItem& app = form.AddChild("input").SetAttr("type", "hidden");
|
||||
app.SetAttr("name", "App"); app.SetAttr("value", strApp);
|
||||
|
||||
TXmlItem& submit = form.AddChild("br").AddChild("center").AddChild("input");
|
||||
submit.SetAttr("type", "submit"); submit.SetAttr("value", "Update Parameters");
|
||||
|
||||
body.AddChild("br");
|
||||
AddLinkButton(body.AddChild("center"), "Return to main page", "/");
|
||||
|
||||
const wxString strFilename = GetTempFilename();
|
||||
html.Save(strFilename);
|
||||
SendFile(strFilename, sock);
|
||||
}
|
||||
|
||||
void TLurchServer::ProcessFormUpdate(THashTable& args, wxSocketBase& sock)
|
||||
{
|
||||
const wxString strApp = args.Get("App");
|
||||
args.BeginFind();
|
||||
for (wxHashTable::Node* pNode = args.Next(); pNode; pNode = args.Next())
|
||||
{
|
||||
const wxString strKey = pNode->GetKeyString();
|
||||
if (strKey != "App")
|
||||
{
|
||||
const wxString strVal = args.Get(strKey);
|
||||
SetConfigString(strKey, strVal, strApp);
|
||||
}
|
||||
}
|
||||
const wxString msg = wxString::Format("%s parameters updated", strApp.c_str());
|
||||
MessageBox("Success!", msg, sock);
|
||||
}
|
||||
|
||||
void TLurchServer::CallCgi(wxString& strFileName, wxSocketBase& sock)
|
||||
{
|
||||
wxString strName, strExt, strArgs;
|
||||
const int q = strFileName.Find('?');
|
||||
if (q > 0)
|
||||
{
|
||||
strArgs = strFileName.Mid(q+1);
|
||||
strFileName.Truncate(q);
|
||||
}
|
||||
wxSplitPath(strFileName, NULL, &strName, &strExt);
|
||||
|
||||
THashTable hashArgs(13);
|
||||
ParseArguments(strArgs, hashArgs);
|
||||
|
||||
if (strExt == "cgi")
|
||||
{
|
||||
if (strName == "start")
|
||||
ProcessFormStart(hashArgs, sock); else
|
||||
if (strName == "kill")
|
||||
ProcessFormKill(hashArgs, sock); else
|
||||
if (strName == "config")
|
||||
ProcessFormConfig(hashArgs, sock); else
|
||||
if (strName == "update")
|
||||
ProcessFormUpdate(hashArgs, sock);
|
||||
}
|
||||
}
|
||||
|
||||
void TLurchServer::ProcessHttpGet(wxString cmd, wxSocketBase& outs)
|
||||
{
|
||||
const int stop = cmd.Find(" HTTP");
|
||||
wxString str = cmd.Mid(4, stop-4).Trim();
|
||||
|
||||
if (str == "/")
|
||||
str += "index.htm";
|
||||
wxString strFilename = GetDocumentRoot() + str;
|
||||
|
||||
if (IsCgiName(strFilename))
|
||||
CallCgi(strFilename, outs);
|
||||
else
|
||||
{
|
||||
if (IsMagicName(strFilename))
|
||||
GenerateFile(strFilename);
|
||||
SendFile(strFilename, outs);
|
||||
}
|
||||
}
|
||||
|
||||
void TLurchServer::ProcessHttpPost(wxString cmd, wxSocketBase& outs)
|
||||
{
|
||||
const int stop = cmd.Find(" HTTP");
|
||||
wxString strFileName = cmd.Mid(5, stop-5).Trim();
|
||||
|
||||
wxString strName, args;
|
||||
wxSplitPath(strFileName, NULL, &strName, NULL);
|
||||
|
||||
const int pos = cmd.Find("\r\n\r\n");
|
||||
if (pos > 0)
|
||||
args = cmd.Mid(pos+4);
|
||||
|
||||
THashTable hashArgs(17);
|
||||
ParseArguments(args, hashArgs);
|
||||
|
||||
if (strName == "update")
|
||||
ProcessFormUpdate(hashArgs, outs);
|
||||
}
|
||||
|
||||
bool TLurchServer::Initialization()
|
||||
{
|
||||
wxArrayString arr; CreateServersList(arr);
|
||||
for (size_t i = 0; i < arr.GetCount(); i++)
|
||||
{
|
||||
const wxString& strApp = arr[i];
|
||||
const bool bAutorun = GetConfigBool("Autorun", false, strApp);
|
||||
if (bAutorun)
|
||||
{
|
||||
const wxSingleInstanceChecker sic(strApp);
|
||||
if (!sic.IsAnotherRunning())
|
||||
{
|
||||
wxString strRun = GetConfigString("Run", "", strApp);
|
||||
if (wxFileExists(strRun))
|
||||
{
|
||||
#ifdef LINUX
|
||||
if (strRun[ 0u] != '/' && strRun[ 0u] != '.')
|
||||
strRun = "./" + strRun;
|
||||
#endif
|
||||
wxExecute(strRun);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Istanziare l'applicazione principale
|
||||
|
||||
IMPLEMENT_APP(TLurchServer)
|
@ -1,2 +1,4 @@
|
||||
soap ICON "soap.ico"
|
||||
#include "wx/msw/wx.rc"
|
||||
|
||||
|
||||
|
@ -180,7 +180,7 @@ int TXmlItem::GetChildren() const
|
||||
{
|
||||
int n = 0;
|
||||
if (m_Children != NULL)
|
||||
n = m_Children->GetCount();
|
||||
n = (int)m_Children->GetCount();
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -355,6 +355,21 @@ TXmlItem& TXmlItem::AddSoapInt(const wxChar* name, int value, bool typized)
|
||||
return xmlVar;
|
||||
}
|
||||
|
||||
wxString TXmlItem::GetSoapString(const wxChar* tag, const wxChar* def) const
|
||||
{
|
||||
const TXmlItem* i = FindFirst(tag);
|
||||
return i != NULL ? i->GetEnclosedText().Trim() : def;
|
||||
}
|
||||
|
||||
long TXmlItem::GetSoapInt(const wxChar* tag, long def) const
|
||||
{
|
||||
const wxString str = GetSoapString(tag);
|
||||
long n;
|
||||
if (str.ToLong(&n))
|
||||
def = n;
|
||||
return def;
|
||||
}
|
||||
|
||||
void TXmlItem::RemoveLastChild()
|
||||
{
|
||||
if (m_Children != NULL)
|
||||
@ -386,7 +401,7 @@ bool TXmlItem::Read(wxInputStream& inf)
|
||||
return res >= 0;
|
||||
}
|
||||
|
||||
TXmlItem* TXmlItem::ForEach(XmlItemCallback cb, long jolly)
|
||||
TXmlItem* TXmlItem::ForEach(XmlItemCallback cb, void* jolly)
|
||||
{
|
||||
if (cb(*this, jolly))
|
||||
return this;
|
||||
@ -404,7 +419,7 @@ TXmlItem* TXmlItem::ForEach(XmlItemCallback cb, long jolly)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool GetEnclosedTextCallback(TXmlItem& item, long jolly)
|
||||
static bool GetEnclosedTextCallback(TXmlItem& item, void* jolly)
|
||||
{
|
||||
wxString* strText = (wxString*)jolly;
|
||||
const wxString& str = item.GetText();
|
||||
@ -420,7 +435,7 @@ static bool GetEnclosedTextCallback(TXmlItem& item, long jolly)
|
||||
wxString TXmlItem::GetEnclosedText() const
|
||||
{
|
||||
wxString text;
|
||||
((TXmlItem*)this)->ForEach(GetEnclosedTextCallback, (long)&text);
|
||||
((TXmlItem*)this)->ForEach(GetEnclosedTextCallback, &text);
|
||||
return text;
|
||||
}
|
||||
|
||||
@ -483,7 +498,7 @@ wxString TXmlItem::AsString() const
|
||||
wxString str;
|
||||
for (size_t nSize = 8192; ; nSize *= 2)
|
||||
{
|
||||
char* buf = str.GetWriteBuf(nSize);
|
||||
wxChar* buf = str.GetWriteBuf(nSize);
|
||||
memset(buf, 0, nSize);
|
||||
wxMemoryOutputStream outf(buf, nSize);
|
||||
Write(outf, 0);
|
||||
@ -501,7 +516,7 @@ void TXmlItem::Save(const wxChar* strFilename) const
|
||||
Write(outf, 0);
|
||||
}
|
||||
|
||||
static bool FindFirstCallback(TXmlItem& item, long jolly)
|
||||
static bool FindFirstCallback(TXmlItem& item, void* jolly)
|
||||
{
|
||||
const wxChar* strTag = (const wxChar*)jolly;
|
||||
return item.GetTag() == strTag;
|
||||
@ -509,7 +524,7 @@ static bool FindFirstCallback(TXmlItem& item, long jolly)
|
||||
|
||||
TXmlItem* TXmlItem::FindFirst(const wxChar* strTag) const
|
||||
{
|
||||
return ((TXmlItem*)this)->ForEach(FindFirstCallback, (long)strTag);
|
||||
return ((TXmlItem*)this)->ForEach(FindFirstCallback, (void*)strTag);
|
||||
}
|
||||
|
||||
TXmlItem::TXmlItem()
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
class TXmlItem;
|
||||
|
||||
typedef bool (*XmlItemCallback)(TXmlItem& item, long jolly);
|
||||
typedef bool (*XmlItemCallback)(TXmlItem& item, void* jolly);
|
||||
|
||||
class TXmlItem : public wxObject
|
||||
{
|
||||
@ -36,6 +36,8 @@ public:
|
||||
TXmlItem& AddChild(const wxChar* strTag);
|
||||
TXmlItem& AddSoapString(const wxChar* name, const wxChar* value, bool typized = false);
|
||||
TXmlItem& AddSoapInt(const wxChar* name, int value, bool typized = false);
|
||||
wxString GetSoapString(const wxChar* name, const wxChar* def = "") const;
|
||||
long GetSoapInt(const wxChar* name, long def = 0) const;
|
||||
|
||||
int GetChildren() const;
|
||||
TXmlItem* GetChild(size_t n) const;
|
||||
@ -47,7 +49,7 @@ public:
|
||||
|
||||
void Save(const wxChar* strFilename) const;
|
||||
|
||||
TXmlItem* ForEach(XmlItemCallback cb, long jolly = 0);
|
||||
TXmlItem* ForEach(XmlItemCallback cb, void* jolly = NULL);
|
||||
TXmlItem* FindFirst(const wxChar* strTag) const;
|
||||
|
||||
TXmlItem();
|
||||
|
Loading…
x
Reference in New Issue
Block a user