From 035a507db9abf0328e4ba8acb8106997cb4beab7 Mon Sep 17 00:00:00 2001 From: willamowius Date: Sun, 5 Nov 2023 21:56:10 +0100 Subject: [PATCH 1/5] clean up --- addpasswd_2022.vcxproj | 24 +++++++---- gk_2022.sln | 39 ++++++++--------- gk_2022.vcxproj | 96 +++++++++++++++++++++++++++--------------- 3 files changed, 99 insertions(+), 60 deletions(-) diff --git a/addpasswd_2022.vcxproj b/addpasswd_2022.vcxproj index 0369e0de..4ad8a421 100755 --- a/addpasswd_2022.vcxproj +++ b/addpasswd_2022.vcxproj @@ -70,12 +70,12 @@ <_ProjectFileVersion>10.0.21006.1 - $(Configuration)\ - $(Configuration)\ + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ true true - $(Configuration)\ - $(Configuration)\ + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ false false AllRules.ruleset @@ -99,6 +99,14 @@ $(ProjectDir)..\h323plus\lib;$(ProjectDir)..\ptlib\lib;$(LibraryPath) $(ProjectDir)..\h323plus\lib;$(ProjectDir)..\ptlib\lib;$(LibraryPath) + + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ + + + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/ + _DEBUG;%(PreprocessorDefinitions) @@ -129,7 +137,7 @@ ptlibsd.lib;%(AdditionalDependencies) - $(TargetDir)addpasswd.exe + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/addpasswd.exe true true $(TargetDir)addpasswd.pdb @@ -172,7 +180,7 @@ ptlibs_$(PlatformShortName)_d.lib;%(AdditionalDependencies) - $(TargetDir)addpasswd.exe + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/addpasswd.exe true true $(TargetDir)addpasswd_$(PlatformShortName).pdb @@ -220,7 +228,7 @@ ptlibs.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) - Release/addpasswd.exe + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/addpasswd.exe true Release/addpasswd.pdb Console @@ -268,7 +276,7 @@ ptlibs_$(PlatformShortName).lib;mpr.lib;winmm.lib;%(AdditionalDependencies) - Release_$(PlatformShortName)/addpasswd.exe + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/addpasswd.exe true Release_$(PlatformShortName)/addpasswd_$(PlatformShortName).pdb Console diff --git a/gk_2022.sln b/gk_2022.sln index db659773..ab15772b 100755 --- a/gk_2022.sln +++ b/gk_2022.sln @@ -1,11 +1,12 @@ + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.34221.43 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gnugk", "gk_2022.vcxproj", "{C5052DDD-FADC-4415-B235-92A9761BB21D}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "addpasswd", "addpasswd_2022.vcxproj", "{2C306BF0-7FBE-4136-B021-AFA258898341}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gnugk", "gk_2022.vcxproj", "{C5052DDD-FADC-4415-B235-92A9761BB21D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug as Service|Win32 = Debug as Service|Win32 @@ -18,6 +19,22 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|Win32.ActiveCfg = Debug|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|Win32.Build.0 = Debug|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|x64.ActiveCfg = Debug|x64 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|x64.Build.0 = Debug|x64 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|Win32.ActiveCfg = Debug|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|Win32.Build.0 = Debug|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|x64.ActiveCfg = Debug|x64 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|x64.Build.0 = Debug|x64 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|Win32.ActiveCfg = Release|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|Win32.Build.0 = Release|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|x64.ActiveCfg = Release|x64 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|x64.Build.0 = Release|x64 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|Win32.ActiveCfg = Release|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|Win32.Build.0 = Release|Win32 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|x64.ActiveCfg = Release|x64 + {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|x64.Build.0 = Release|x64 {C5052DDD-FADC-4415-B235-92A9761BB21D}.Debug as Service|Win32.ActiveCfg = Debug as Service|Win32 {C5052DDD-FADC-4415-B235-92A9761BB21D}.Debug as Service|Win32.Build.0 = Debug as Service|Win32 {C5052DDD-FADC-4415-B235-92A9761BB21D}.Debug as Service|x64.ActiveCfg = Debug as Service|x64 @@ -34,27 +51,11 @@ Global {C5052DDD-FADC-4415-B235-92A9761BB21D}.Release|Win32.Build.0 = Release|Win32 {C5052DDD-FADC-4415-B235-92A9761BB21D}.Release|x64.ActiveCfg = Release|x64 {C5052DDD-FADC-4415-B235-92A9761BB21D}.Release|x64.Build.0 = Release|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|Win32.ActiveCfg = Debug|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|Win32.Build.0 = Debug|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|x64.ActiveCfg = Debug|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug as Service|x64.Build.0 = Debug|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|Win32.ActiveCfg = Debug|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|Win32.Build.0 = Debug|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|x64.ActiveCfg = Release|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Debug|x64.Build.0 = Release|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|Win32.ActiveCfg = Release|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|Win32.Build.0 = Release|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|x64.ActiveCfg = Release|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release as Service|x64.Build.0 = Release|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|Win32.ActiveCfg = Release|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|Win32.Build.0 = Release|Win32 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|x64.ActiveCfg = Release|x64 - {2C306BF0-7FBE-4136-B021-AFA258898341}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9D30E884-FDEC-48A9-BA0D-CAE0029A0D76} + SolutionGuid = {A0B11BD0-B954-4E28-8503-C17B17D684BF} EndGlobalSection EndGlobal diff --git a/gk_2022.vcxproj b/gk_2022.vcxproj index 1b7d82d4..9e376592 100755 --- a/gk_2022.vcxproj +++ b/gk_2022.vcxproj @@ -2,35 +2,35 @@ - Debug (h323plus) + Debug Win32 - Debug (h323plus) + Debug x64 - Debug as Service (h323plus) + Debug as Service Win32 - Debug as Service (h323plus) + Debug as Service x64 - Release (h323plus) + Release Win32 - Release (h323plus) + Release x64 - Release as Service (h323plus) + Release as Service Win32 - Release as Service (h323plus) + Release as Service x64 @@ -80,6 +80,30 @@ false v143 + + v143 + + + v143 + + + v143 + + + v143 + + + v143 + + + v143 + + + v143 + + + v143 + @@ -124,8 +148,8 @@ false false false - $(Configuration)\ - $(Configuration)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ AllRules.ruleset @@ -172,26 +196,32 @@ $(ProjectDir)..\h323plus\lib;$(ProjectDir)..\ptlib\lib;$(LibraryPath) - $(Configuration)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ - $(Configuration)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ - $(SolutionDir)/$(Configuration)_$(PlatformShortName)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + + + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ @@ -368,7 +398,7 @@ MultiThreadedDebugDLL Default true - .\Debug/gk.pch + .\Debug/gnugk.pch .\Debug/ .\Debug/ .\Debug/ @@ -386,7 +416,7 @@ h323plusd.lib;ptlibsd.lib;snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) - Debug/gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true true .\Debug/gnugk.pdb @@ -427,7 +457,7 @@ h323plus_$(PlatformShortName)_d.lib;ptlibs_$(PlatformShortName)_d.lib;snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) - Debug_$(PlatformShortName)/gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true true .\Debug/gnugk.pdb @@ -456,7 +486,7 @@ false false true - $(TargetDir)gk.pch + $(TargetDir)gnugk.pch $(TargetDir) $(TargetDir) $(TargetDir) @@ -472,7 +502,7 @@ h323plus.lib;ptlibs.lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) - $(TargetDir)gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true $(TargetDir)gnugk.pdb Console @@ -518,7 +548,7 @@ h323plus_$(PlatformShortName).lib;ptlibs_$(PlatformShortName).lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) - $(TargetDir)gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true $(TargetDir)gnugk_$(PlatformShortName).pdb Console @@ -547,7 +577,7 @@ false false true - $(TargetDir)gk.pch + $(TargetDir)gnugk.pch $(TargetDir) $(TargetDir) $(TargetDir) @@ -563,7 +593,7 @@ h323plus.lib;ptlibs.lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) - $(TargetDir)gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true $(TargetDir)gnugk.pdb Windows @@ -609,7 +639,7 @@ h323plus_$(PlatformShortName).lib;ptlibs_$(PlatformShortName).lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) - $(TargetDir)gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true $(TargetDir)gnugk_$(PlatformShortName).pdb Windows @@ -631,7 +661,7 @@ MultiThreadedDebugDLL Default true - .\Debug/gk.pch + .\Debug/gnugk.pch .\Debug/ .\Debug/ .\Debug/ @@ -649,7 +679,7 @@ h323plusd.lib;ptlibsd.lib;snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) - Debug\gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true true .\Debug\gnugk.pdb @@ -690,7 +720,7 @@ h323plus_$(PlatformShortName)_d.lib;ptlibs_$(PlatformShortName)_d.lib;snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) - Debug_$(PlatformShortName)\gnugk.exe + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/gnugk.exe true true .\Debug\gnugk.pdb @@ -881,4 +911,4 @@ configure - + \ No newline at end of file From 9071e1df36de9b5c5a6fcfed136c829364f23402 Mon Sep 17 00:00:00 2001 From: willamowius Date: Sun, 5 Nov 2023 22:00:27 +0100 Subject: [PATCH 2/5] remove useless libs --- gk_2022.vcxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gk_2022.vcxproj b/gk_2022.vcxproj index 9e376592..8b118e45 100755 --- a/gk_2022.vcxproj +++ b/gk_2022.vcxproj @@ -253,7 +253,7 @@ 0x0409 - openh323d.lib;ptclibd.lib;ptlibd.lib;snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) + snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) Debug/gnugk.exe true true @@ -294,7 +294,7 @@ 0x0409 - openh323d.lib;ptclibd.lib;ptlibd.lib;snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) + snmpapi.lib;Winmm.lib;mpr.lib;wsock32.lib;%(AdditionalDependencies) Debug/gnugk.exe true true @@ -335,7 +335,7 @@ 0x0409 - h323plus.lib;ptclib.lib;ptlibs.lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) + h323plus.lib;ptlibs.lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) Release/gnugk.exe true .\Release/gnugk.pdb @@ -376,7 +376,7 @@ 0x0409 - h323plus.lib;ptclib.lib;ptlibs.lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) + h323plus.lib;ptlibs.lib;snmpapi.lib;odbc32.lib;odbccp32.lib;wsock32.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) Release/gnugk.exe true .\Release/gnugk.pdb From 0f97273430be16882c430e6db3bebe0c550ab2ef Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Tue, 21 Nov 2023 20:07:03 +0100 Subject: [PATCH 3/5] comment C++17 issue --- Routing.cxx | 1 + capctrl.cxx | 3 +++ clirw.cxx | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Routing.cxx b/Routing.cxx index b329e98f..6cb0a87a 100644 --- a/Routing.cxx +++ b/Routing.cxx @@ -1595,6 +1595,7 @@ bool VirtualQueuePolicy::OnRequest(SetupRequest & request) return false; } +// TODO the use of binary_function needs a patch for C++17 struct PrefixGreater : public binary_function { bool operator()(const NumberAnalysisPolicy::PrefixEntry &e1, const NumberAnalysisPolicy::PrefixEntry &e2) const diff --git a/capctrl.cxx b/capctrl.cxx index d9717760..32f187e1 100644 --- a/capctrl.cxx +++ b/capctrl.cxx @@ -31,6 +31,7 @@ namespace { // greater operators for sorting route lists +// TODO the use of binary_function needs a patch for C++17 struct IpRule_greater : public std::binary_function { bool operator()(const CapacityControl::IpCallVolume &e1, const CapacityControl::IpCallVolume &e2) const @@ -49,6 +50,7 @@ struct IpRule_greater : public std::binary_function { bool operator()(const CapacityControl::H323IdCallVolume & e1, const CapacityControl::H323IdCallVolume & e2) const @@ -57,6 +59,7 @@ struct H323IdRule_greater : public std::binary_function { bool operator()(const CapacityControl::CLICallVolume & e1, const CapacityControl::CLICallVolume & e2) const diff --git a/clirw.cxx b/clirw.cxx index 67511879..0dd4036a 100644 --- a/clirw.cxx +++ b/clirw.cxx @@ -102,6 +102,7 @@ PString CLIRewrite::RewriteRule::AsString() const } namespace { +// TODO the use of binary_function needs a patch for C++17 struct RewriteRule_greater : public std::binary_function { bool operator()(const CLIRewrite::RewriteRule &e1, const CLIRewrite::RewriteRule &e2) const @@ -116,6 +117,7 @@ struct RewriteRule_greater : public std::binary_function { bool operator()(const CLIRewrite::SingleIpRule &e1, const CLIRewrite::SingleIpRule &e2) const From 5695cd351039ca0195b10937f98c0d9523264d99 Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Tue, 21 Nov 2023 20:17:05 +0100 Subject: [PATCH 4/5] note C++17 issue --- Toolkit.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Toolkit.cxx b/Toolkit.cxx index 8ce3c94a..724dbde6 100644 --- a/Toolkit.cxx +++ b/Toolkit.cxx @@ -3660,6 +3660,7 @@ bool Toolkit::GetH46023STUN(const PIPSocket::Address & addr, H323TransportAddres std::map >::iterator inf = m_H46023STUN.find(intID); if (inf != m_H46023STUN.end()) { if (inf->second.size() > 1) + // TODO random_shuffle is removed in C++17 std::random_shuffle(inf->second.begin(), inf->second.end()); stun = inf->second.front(); return true; From 34a3cbe92c97af93ba794fec63fa978b7742d33a Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Wed, 22 Nov 2023 01:28:36 +0100 Subject: [PATCH 5/5] support C++17 --- GkClient.cxx | 10 ++++++ Neighbor.cxx | 41 +++++++++++++++++++++- ProxyChannel.cxx | 4 +++ RasSrv.cxx | 38 ++++++++++++++++++++- RasTbl.cxx | 88 +++++++++++++++++++++++++++++++++++++++++++++++- Routing.cxx | 12 +++++-- Toolkit.cxx | 21 ++++++++++-- Toolkit.h | 2 -- capctrl.cxx | 26 +++++++++++--- clirw.cxx | 25 ++++++++++++-- factory.h | 9 +++++ ipauth.cxx | 9 ++++- stl_supp.h | 49 ++++++++++++++++++++++++++- yasocket.cxx | 19 +++++++++++ 14 files changed, 335 insertions(+), 18 deletions(-) diff --git a/GkClient.cxx b/GkClient.cxx index d276f2e1..b2fe9475 100644 --- a/GkClient.cxx +++ b/GkClient.cxx @@ -44,8 +44,10 @@ using std::vector; using std::multimap; using std::make_pair; using std::for_each; +#if (__cplusplus < 201703L) // before C++17 using std::mem_fun; using std::bind1st; +#endif using Routing::Route; namespace { @@ -2503,7 +2505,11 @@ void GkClient::Unregister() m_natClient->Stop(); m_natClient = NULL; } +#if (__cplusplus >= 201703L) // C++17 + for_each(m_handlers, m_handlers + 4, bind(mem_fn(&RasServer::UnregisterHandler), m_rasSrv, std::placeholders::_1)); +#else for_each(m_handlers, m_handlers + 4, bind1st(mem_fun(&RasServer::UnregisterHandler), m_rasSrv)); +#endif m_registered = false; } @@ -2758,7 +2764,11 @@ void GkClient::OnRCF(RasMsg *ras) if (m_useAdditiveRegistration) RegistrationTable::Instance()->UpdateTable(); +#if (__cplusplus >= 201703L) // C++17 + for_each(m_handlers, m_handlers + 4, bind(mem_fn(&RasServer::RegisterHandler), m_rasSrv, std::placeholders::_1)); +#else for_each(m_handlers, m_handlers + 4, bind1st(mem_fun(&RasServer::RegisterHandler), m_rasSrv)); +#endif } // Not all RCF contain TTL, in that case keep old value diff --git a/Neighbor.cxx b/Neighbor.cxx index ae6a22e3..d912c66a 100644 --- a/Neighbor.cxx +++ b/Neighbor.cxx @@ -40,9 +40,11 @@ using std::multimap; using std::make_pair; using std::find_if; +#if (__cplusplus < 201703L) // before C++17 +using std::mem_fun; using std::bind2nd; +#endif using std::equal_to; -using std::mem_fun; using Routing::Route; namespace Neighbors { @@ -1719,8 +1721,13 @@ void NeighborList::OnReload() type = "ClarentGK"; if (PCaselessString(type) == "GlonetGK") type = "GlonetGK"; +#if (__cplusplus >= 201703L) // C++17 + iter = find_if(m_neighbors.begin(), m_neighbors.end(), + compose1(bind(equal_to(), std::placeholders::_1, nbid), mem_fn(&Neighbor::GetId))); +#else iter = find_if(m_neighbors.begin(), m_neighbors.end(), compose1(bind2nd(equal_to(), nbid), mem_fun(&Neighbor::GetId))); +#endif bool newnb = (iter == m_neighbors.end()); Neighbor *nb = newnb ? Factory::Create(type) : *iter; if (nb && nb->SetProfile(nbid, type, !newnb)) { @@ -1749,24 +1756,40 @@ bool NeighborList::CheckLRQ(RasMsg *ras) const bool NeighborList::CheckIP(const PIPSocket::Address & addr) const { +#if (__cplusplus >= 201703L) // C++17 + return find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsFrom), std::placeholders::_1, &addr)) != m_neighbors.end(); +#else return find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsFrom), &addr)) != m_neighbors.end(); +#endif } bool NeighborList::IsTraversalClient(const PIPSocket::Address & addr) const { +#if (__cplusplus >= 201703L) // C++17 + return find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsTraversalClient), std::placeholders::_1, &addr)) != m_neighbors.end(); +#else return find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsTraversalClient), &addr)) != m_neighbors.end(); +#endif } bool NeighborList::IsTraversalServer(const PIPSocket::Address & addr) const { +#if (__cplusplus >= 201703L) // C++17 + return find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsTraversalServer), std::placeholders::_1, &addr)) != m_neighbors.end(); +#else return find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsTraversalServer), &addr)) != m_neighbors.end(); +#endif } // is IP a neighbor and is it not disabled ? bool NeighborList::IsAvailable(const PIPSocket::Address & ip) { // Attempt to find the neighbor in the list +#if (__cplusplus >= 201703L) // C++17 + List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsFrom), std::placeholders::_1, &ip)); +#else List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsFrom), &ip)); +#endif if (findNeighbor == m_neighbors.end()) { return false; @@ -1790,7 +1813,11 @@ PString NeighborList::GetNeighborIdBySigAdr(const H225_TransportAddress & sigAd) PString NeighborList::GetNeighborIdBySigAdr(const PIPSocket::Address & sigAd) { // Attempt to find the neighbor in the list +#if (__cplusplus >= 201703L) // C++17 + List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsFrom), std::placeholders::_1, &sigAd)); +#else List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsFrom), &sigAd)); +#endif if (findNeighbor == m_neighbors.end()) { return PString::Empty(); @@ -1801,7 +1828,11 @@ PString NeighborList::GetNeighborIdBySigAdr(const PIPSocket::Address & sigAd) PString NeighborList::GetNeighborGkIdBySigAdr(const PIPSocket::Address & sigAd) { // Attempt to find the neighbor in the list +#if (__cplusplus >= 201703L) // C++17 + List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsFrom), std::placeholders::_1, &sigAd)); +#else List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsFrom), &sigAd)); +#endif if (findNeighbor == m_neighbors.end()) { @@ -1814,7 +1845,11 @@ PString NeighborList::GetNeighborGkIdBySigAdr(const PIPSocket::Address & sigAd) bool NeighborList::GetNeighborTLSBySigAdr(const PIPSocket::Address & sigAd) { // Attempt to find the neighbor in the list +#if (__cplusplus >= 201703L) // C++17 + List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsFrom), std::placeholders::_1, &sigAd)); +#else List::iterator findNeighbor = find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsFrom), &sigAd)); +#endif if (findNeighbor == m_neighbors.end()) { return false; @@ -2035,7 +2070,11 @@ bool NeighborPolicy::OnRequest(AdmissionRequest & arq_obj) bool NeighborPolicy::OnRequest(LocationRequest & lrq_obj) { RasMsg * ras = lrq_obj.GetWrapper(); +#if (__cplusplus >= 201703L) // C++17 + List::iterator iter = find_if(m_neighbors.begin(), m_neighbors.end(), bind(mem_fn(&Neighbor::IsAcceptable), std::placeholders::_1, ras)); +#else List::iterator iter = find_if(m_neighbors.begin(), m_neighbors.end(), bind2nd(mem_fun(&Neighbor::IsAcceptable), ras)); +#endif Neighbor * requester = (iter != m_neighbors.end()) ? *iter : NULL; int hopCount = 0; if (requester) { diff --git a/ProxyChannel.cxx b/ProxyChannel.cxx index ac11bbf1..f3063df4 100644 --- a/ProxyChannel.cxx +++ b/ProxyChannel.cxx @@ -17818,7 +17818,11 @@ bool H245ProxyHandler::RemoveLogicalChannel(WORD flcn) return false; } LogicalChannel * lc = iter->second; +#if (__cplusplus >= 201703L) // C++17 + siterator i = find_if(sessionIDs.begin(), sessionIDs.end(), bind(compare_lc, std::placeholders::_1, lc)); +#else siterator i = find_if(sessionIDs.begin(), sessionIDs.end(), bind2nd(std::ptr_fun(compare_lc), lc)); +#endif if (i != sessionIDs.end()) sessionIDs.erase(i); logicalChannels.erase(iter); diff --git a/RasSrv.cxx b/RasSrv.cxx index 17518a1d..baa52ed1 100644 --- a/RasSrv.cxx +++ b/RasSrv.cxx @@ -2,7 +2,7 @@ // // RAS Server for GNU Gatekeeper // -// Copyright (c) 2000-2021, Jan Willamowius +// Copyright (c) 2000-2023, Jan Willamowius // Copyright (c) Citron Network Inc. 2001-2003 // // This work is published under the GNU Public License version 2 (GPLv2) @@ -1009,7 +1009,11 @@ void RasServer::LoadConfig() for (int i = 0; i < hsize; ++i) { Address addr(GKHome[i]); +#if (__cplusplus >= 201703L) // C++17 + ifiterator iter = find_if(interfaces.begin(), interfaces.end(), bind(mem_fn(&GkInterface::IsBoundTo), std::placeholders::_1, &addr)); +#else ifiterator iter = find_if(interfaces.begin(), interfaces.end(), bind2nd(mem_fun(&GkInterface::IsBoundTo), &addr)); +#endif if (iter == interfaces.end()) { GkInterface *gkif = CreateInterface(addr); if (gkif->CreateListeners(this)) { @@ -1161,12 +1165,20 @@ GkInterface *RasServer::SelectInterface(const Address & addr) if (interfaces.empty()) return NULL; // prefer the interface that actually has the IP bound to it +#if (__cplusplus >= 201703L) // C++17 + ifiterator iter = find_if(interfaces.begin(), interfaces.end(), bind(mem_fn(&GkInterface::IsBoundTo), std::placeholders::_1, &addr)); +#else ifiterator iter = find_if(interfaces.begin(), interfaces.end(), bind2nd(mem_fun(&GkInterface::IsBoundTo), &addr)); +#endif if (iter != interfaces.end()) { return *iter; } // otherwise use an interface that can reach the IP +#if (__cplusplus >= 201703L) // C++17 + iter = find_if(interfaces.begin(), interfaces.end(), bind(mem_fn(&GkInterface::IsReachable), std::placeholders::_1, &addr)); +#else iter = find_if(interfaces.begin(), interfaces.end(), bind2nd(mem_fun(&GkInterface::IsReachable), &addr)); +#endif if (iter != interfaces.end()) { return *iter; } @@ -1718,9 +1730,17 @@ void RasServer::CreateRasJob(GatekeeperMessage * msg, bool syncronous) PWaitAndSignal rlock(requests_mutex); PWaitAndSignal hlock(handlers_mutex); if (RasMsg *ras = RasFactory::Create(tag, msg)) { +#if (__cplusplus >= 201703L) // C++17 + std::list::iterator iter = find_if(handlers.begin(), handlers.end(), bind(mem_fn(&RasHandler::IsExpected), std::placeholders::_1, ras)); +#else std::list::iterator iter = find_if(handlers.begin(), handlers.end(), bind2nd(mem_fun(&RasHandler::IsExpected), ras)); +#endif if (iter == handlers.end()) { +#if (__cplusplus >= 201703L) // C++17 + std::list::iterator i = find_if(requests.begin(), requests.end(), bind(mem_fn(&RasMsg::EqualTo), std::placeholders::_1, ras)); +#else std::list::iterator i = find_if(requests.begin(), requests.end(), bind2nd(mem_fun(&RasMsg::EqualTo), ras)); +#endif if (i != requests.end() && !(*i)->IsDone()) { PTRACE(2, "RAS\tDuplicate " << msg->GetTagName() << ", deleted"); delete ras; @@ -1753,7 +1773,11 @@ void RasServer::CleanUp() { PWaitAndSignal lock(requests_mutex); if (!requests.empty()) { +#if (__cplusplus >= 201703L) // C++17 + std::list::iterator iter = partition(requests.begin(), requests.end(), mem_fn(&RasMsg::IsDone)); +#else std::list::iterator iter = partition(requests.begin(), requests.end(), mem_fun(&RasMsg::IsDone)); +#endif DeleteObjects(requests.begin(), iter); requests.erase(requests.begin(), iter); } @@ -4844,7 +4868,11 @@ template<> bool RasPDU::Process() // find the neighbor this comes from NeighborList::List & neighbors = *RasServer::Instance()->GetNeighbors(); +#if (__cplusplus >= 201703L) // C++17 + NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), bind(mem_fn(&Neighbors::Neighbor::IsFrom), std::placeholders::_1, &m_msg->m_peerAddr)); +#else NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), bind2nd(mem_fun(&Neighbors::Neighbor::IsFrom), &m_msg->m_peerAddr)); +#endif Neighbors::Neighbor * from_neighbor = NULL; bool neighbor_authenticated = true; if (iter != neighbors.end()) @@ -4899,7 +4927,11 @@ template<> bool RasPDU::Process() && (request.m_cryptoTokens[0].GetTag() == H225_CryptoH323Token::e_cryptoGKPwdHash)) { H225_CryptoH323Token_cryptoGKPwdHash & token = request.m_cryptoTokens[0]; PString gkid = token.m_gatekeeperId; +#if (__cplusplus >= 201703L) // C++17 + NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), bind(mem_fn(&Neighbors::Neighbor::IsTraversalUser), std::placeholders::_1, &gkid)); +#else NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), bind2nd(mem_fun(&Neighbors::Neighbor::IsTraversalUser), &gkid)); +#endif if (iter != neighbors.end()) { from_neighbor = (*iter); neighbor_authenticated = from_neighbor->Authenticate(this); @@ -4967,7 +4999,11 @@ template<> bool RasPDU::Process() #ifdef HAS_H46018 // check if it belongs to a neighbor SCI and use the keepAliveInterval NeighborList::List & neighbors = *RasServer::Instance()->GetNeighbors(); +#if (__cplusplus >= 201703L) // C++17 + NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), bind(mem_fn(&Neighbors::Neighbor::IsFrom), std::placeholders::_1, &m_msg->m_peerAddr)); +#else NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), bind2nd(mem_fun(&Neighbors::Neighbor::IsFrom), &m_msg->m_peerAddr)); +#endif if (iter != neighbors.end()) { if (request.HasOptionalField(H225_ServiceControlResponse::e_result)) { if (request.m_result.GetTag() == H225_ServiceControlResponse_result::e_started) { diff --git a/RasTbl.cxx b/RasTbl.cxx index 67f4055d..4c640080 100644 --- a/RasTbl.cxx +++ b/RasTbl.cxx @@ -2,7 +2,7 @@ // // bookkeeping for RAS-Server in H.323 gatekeeper // -// Copyright (c) 2000-2022, Jan Willamowius +// Copyright (c) 2000-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -50,8 +50,10 @@ using std::copy; using std::partition; using std::back_inserter; using std::transform; +#if (__cplusplus < 201703L) // before C++17 using std::mem_fun; using std::bind2nd; +#endif using std::equal_to; using std::find; using std::find_if; @@ -320,7 +322,11 @@ void EndpointRec::SetEndpointRec(H225_LocationConfirm & lcf) PIPSocket::Address socketAddr; if (GetIPFromTransportAddr(m_rasAddress, socketAddr)) { NeighborList::List & neighbors = *RasServer::Instance()->GetNeighbors(); +#if (__cplusplus >= 201703L) // C++17 + NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), std::bind(&Neighbors::Neighbor::IsFrom, std::placeholders::_1, &socketAddr)); +#else NeighborList::List::iterator iter = find_if(neighbors.begin(), neighbors.end(), bind2nd(mem_fun(&Neighbors::Neighbor::IsFrom), &socketAddr)); +#endif if (iter != neighbors.end()) { if ((*iter)->IsH46018Server()) { m_traversalType = TraversalServer; @@ -1797,7 +1803,11 @@ RegistrationTable::~RegistrationTable() { ClearTable(); // since the socket has been deleted, just remove it +#if (__cplusplus >= 201703L) // C++17 + ForEachInContainer(RemovedList, mem_fn(&EndpointRec::GetAndRemoveSocket)); +#else ForEachInContainer(RemovedList, mem_fun(&EndpointRec::GetAndRemoveSocket)); +#endif DeleteObjectsInContainer(RemovedList); } @@ -1859,8 +1869,13 @@ endptr RegistrationTable::InternalInsertEP(H225_RasMessage & ras_msg) if (!rrq.HasOptionalField(H225_RegistrationRequest::e_endpointIdentifier) || !Toolkit::AsBool(GkConfig()->GetString(RRQFeaturesSection, "AcceptEndpointIdentifier", "1"))) { rrq.IncludeOptionalField(H225_RegistrationRequest::e_endpointIdentifier); +#if (__cplusplus >= 201703L) // C++17 + endptr e = InternalFind(compose1(std::bind(equal_to(), std::placeholders::_1, rrq.m_callSignalAddress[0]), + mem_fn(&EndpointRec::GetCallSignalAddress)), &RemovedList); +#else endptr e = InternalFind(compose1(bind2nd(equal_to(), rrq.m_callSignalAddress[0]), mem_fun(&EndpointRec::GetCallSignalAddress)), &RemovedList); +#endif if (e) // re-use the old endpoint identifier rrq.m_endpointIdentifier = e->GetEndpointIdentifier(); else @@ -2004,8 +2019,13 @@ endptr RegistrationTable::FindByEndpointId(const H225_EndpointIdentifier & epId) PString epIdStr; epIdStr = epId; +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(compose1(bind(equal_to(), std::placeholders::_1, epIdStr), + mem_fn(&EndpointRec::GetEndpointIdentifier))); +#else return InternalFind(compose1(bind2nd(equal_to(), epIdStr), mem_fun(&EndpointRec::GetEndpointIdentifier))); +#endif } namespace { // anonymous namespace @@ -2075,13 +2095,22 @@ endptr RegistrationTable::FindBySignalAdrIgnorePort(const H225_TransportAddress endptr RegistrationTable::FindOZEPBySignalAdr(const H225_TransportAddress & sigAd) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(compose1(std::bind(equal_to(), std::placeholders::_1, sigAd), + mem_fn(&EndpointRec::GetCallSignalAddress)), &OutOfZoneList); +#else return InternalFind(compose1(bind2nd(equal_to(), sigAd), mem_fun(&EndpointRec::GetCallSignalAddress)), &OutOfZoneList); +#endif } endptr RegistrationTable::FindByAliases(const H225_ArrayOf_AliasAddress & alias) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(std::bind(&EndpointRec::CompareAlias, std::placeholders::_1, &alias)); +#else return InternalFind(bind2nd(mem_fun(&EndpointRec::CompareAlias), &alias)); +#endif } endptr RegistrationTable::FindFirstEndpoint(const H225_ArrayOf_AliasAddress & alias) @@ -2114,7 +2143,11 @@ inline bool ComparePriority(const pair& x, const pair *List) { +#if (__cplusplus >= 201703L) // C++17 + endptr ep = InternalFind(std::bind(&EndpointRec::CompareAlias, std::placeholders::_1, &alias), List); +#else endptr ep = InternalFind(bind2nd(mem_fun(&EndpointRec::CompareAlias), &alias), List); +#endif if (ep) { PTRACE(4, "Alias match for EP " << AsDotString(ep->GetCallSignalAddress())); return ep; @@ -2160,7 +2193,11 @@ bool RegistrationTable::InternalFindEP( bool leastUsedRouting, list & routes) { +#if (__cplusplus >= 201703L) // C++17 + endptr ep = InternalFind(std::bind(&EndpointRec::CompareAlias, std::placeholders::_1, &aliases), endpoints); +#else endptr ep = InternalFind(bind2nd(mem_fun(&EndpointRec::CompareAlias), &aliases), endpoints); +#endif if (ep) { PTRACE(4, "Alias match for EP " << AsDotString(ep->GetCallSignalAddress())); if (ep->UsesH46017() && ep->GetActiveCalls() > 0) { @@ -2377,7 +2414,11 @@ void RegistrationTable::LoadConfig() // Load config for each endpoint if (regSize > 0) { ReadLock lock(listLock); +#if (__cplusplus >= 201703L) // C++17 + ForEachInContainer(EndpointList, mem_fn(&EndpointRec::LoadConfig)); +#else ForEachInContainer(EndpointList, mem_fun(&EndpointRec::LoadConfig)); +#endif } // Load permanent endpoints @@ -2512,8 +2553,13 @@ void RegistrationTable::ClearTable() WriteLock lock(listLock); if (Toolkit::AsBool(GkConfig()->GetString("Gatekeeper::Main", "DisconnectCallsOnShutdown", "1"))) { // Unregister all endpoints, and move the records into RemovedList +#if (__cplusplus >= 201703L) // C++17 + transform(EndpointList.begin(), EndpointList.end(), + back_inserter(RemovedList), mem_fn(&EndpointRec::Unregister)); +#else transform(EndpointList.begin(), EndpointList.end(), back_inserter(RemovedList), mem_fun(&EndpointRec::Unregister)); +#endif } EndpointList.clear(); regSize = 0; @@ -2525,7 +2571,11 @@ void RegistrationTable::UpdateTable() { WriteLock lock(listLock); +#if (__cplusplus >= 201703L) // C++17 + ForEachInContainer(EndpointList, mem_fn(&EndpointRec::Reregister)); +#else ForEachInContainer(EndpointList, mem_fun(&EndpointRec::Reregister)); +#endif EndpointList.clear(); } @@ -2601,7 +2651,11 @@ void RegistrationTable::CheckEndpoints() #endif // HAS_AVAYA_SUPPORT } +#if (__cplusplus >= 201703L) // C++17 + iterator OOZIter = partition(OutOfZoneList.begin(), OutOfZoneList.end(), std::bind(&EndpointRec::IsUpdated, std::placeholders::_1, &now)); +#else iterator OOZIter = partition(OutOfZoneList.begin(), OutOfZoneList.end(), bind2nd(mem_fun(&EndpointRec::IsUpdated), &now)); +#endif if (ptrdiff_t s = distance(OOZIter, OutOfZoneList.end())) { PTRACE(2, s << " out-of-zone endpoint(s) expired"); } @@ -2609,7 +2663,11 @@ void RegistrationTable::CheckEndpoints() OutOfZoneList.erase(OOZIter, OutOfZoneList.end()); // Cleanup unused EndpointRec in RemovedList +#if (__cplusplus >= 201703L) // C++17 + iterator RemIter = partition(RemovedList.begin(), RemovedList.end(), mem_fn(&EndpointRec::IsUsed)); +#else iterator RemIter = partition(RemovedList.begin(), RemovedList.end(), mem_fun(&EndpointRec::IsUsed)); +#endif DeleteObjects(RemIter, RemovedList.end()); RemovedList.erase(RemIter, RemovedList.end()); } @@ -5616,32 +5674,56 @@ unsigned CallTable::GetTotalAllocatedBandwidth() const // in kbps callptr CallTable::FindCallRec(const H225_CallIdentifier & CallId) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(std::bind(&CallRec::CompareCallId, std::placeholders::_1, &CallId)); +#else return InternalFind(bind2nd(mem_fun(&CallRec::CompareCallId), &CallId)); +#endif } callptr CallTable::FindCallRec(const H225_CallReferenceValue & CallRef) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(std::bind(&CallRec::CompareCRV, std::placeholders::_1, CallRef.GetValue())); +#else return InternalFind(bind2nd(mem_fun(&CallRec::CompareCRV), CallRef.GetValue())); +#endif } callptr CallTable::FindCallRec(PINDEX CallNumber) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(std::bind(&CallRec::CompareCallNumber, std::placeholders::_1, CallNumber)); +#else return InternalFind(bind2nd(mem_fun(&CallRec::CompareCallNumber), CallNumber)); +#endif } callptr CallTable::FindCallRec(const endptr & ep) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(std::bind(&CallRec::CompareEndpoint, std::placeholders::_1, &ep)); +#else return InternalFind(bind2nd(mem_fun(&CallRec::CompareEndpoint), &ep)); +#endif } callptr CallTable::FindBySignalAdr(const H225_TransportAddress & SignalAdr) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(std::bind(&CallRec::CompareSigAdr, std::placeholders::_1, &SignalAdr)); +#else return InternalFind(bind2nd(mem_fun(&CallRec::CompareSigAdr), &SignalAdr)); +#endif } callptr CallTable::FindBySignalAdrIgnorePort(const H225_TransportAddress & SignalAdr) const { +#if (__cplusplus >= 201703L) // C++17 + return InternalFind(std::bind(&CallRec::CompareSigAdrIgnorePort, std::placeholders::_1, &SignalAdr)); +#else return InternalFind(bind2nd(mem_fun(&CallRec::CompareSigAdrIgnorePort), &SignalAdr)); +#endif } void CallTable::ClearTable() @@ -5679,7 +5761,11 @@ void CallTable::CheckCalls(RasServer * rassrv) ++Iter; } +#if (__cplusplus >= 201703L) // C++7 + iterator RemIter = partition(RemovedList.begin(), RemovedList.end(), mem_fn(&CallRec::IsUsed)); +#else iterator RemIter = partition(RemovedList.begin(), RemovedList.end(), mem_fun(&CallRec::IsUsed)); +#endif DeleteObjects(RemIter, RemovedList.end()); RemovedList.erase(RemIter, RemovedList.end()); } diff --git a/Routing.cxx b/Routing.cxx index 6cb0a87a..5921f320 100644 --- a/Routing.cxx +++ b/Routing.cxx @@ -3,7 +3,7 @@ // Routing Mechanism for GNU Gatekeeper // // Copyright (c) Citron Network Inc. 2003 -// Copyright (c) 2004-2021, Jan Willamowius +// Copyright (c) 2004-2023, Jan Willamowius // // This work is published under the GNU Public License version 2 (GPLv2) // see file COPYING for details. @@ -42,7 +42,9 @@ using std::string; using std::vector; using std::list; using std::stable_sort; +#if (__cplusplus < 201703L) using std::binary_function; +#endif namespace Routing { @@ -1595,8 +1597,14 @@ bool VirtualQueuePolicy::OnRequest(SetupRequest & request) return false; } -// TODO the use of binary_function needs a patch for C++17 +#if (__cplusplus >= 201703L) // C++17 +struct PrefixGreater { + typedef NumberAnalysisPolicy::PrefixEntry first_argument_type; + typedef NumberAnalysisPolicy::PrefixEntry second_argument_type; + typedef bool result_type; +#else struct PrefixGreater : public binary_function { +#endif bool operator()(const NumberAnalysisPolicy::PrefixEntry &e1, const NumberAnalysisPolicy::PrefixEntry &e2) const { diff --git a/Toolkit.cxx b/Toolkit.cxx index 724dbde6..5778d52a 100644 --- a/Toolkit.cxx +++ b/Toolkit.cxx @@ -23,6 +23,9 @@ #if !defined(_WIN32) && !defined(_WIN64) #include #endif // _WIN32 +#if (__cplusplus >= 201703L) // C++17 +#include +#endif #include "stl_supp.h" #include "gktimer.h" #include "h323util.h" @@ -476,7 +479,11 @@ PIPSocket::Address Toolkit::RouteTable::GetLocalAddress(const Address & addr) co if (addr << m_internalnetworks[j]) { // check if internal network is in route table, but don't use the default route RouteEntry *entry = find_if(rtable_begin, rtable_end, +#if (__cplusplus >= 201703L) // C++17 + bind(mem_fn(&RouteEntry::CompareWithoutMask), std::placeholders::_1, &addr)); +#else bind2nd(mem_fun_ref(&RouteEntry::CompareWithoutMask), &addr)); +#endif if ((entry != rtable_end) && (entry->GetNetMask() != INADDR_ANY) #ifdef hasIPV6 && (entry->GetNetMask() != in6addr_any) @@ -517,7 +524,11 @@ PIPSocket::Address Toolkit::RouteTable::GetLocalAddress(const Address & addr) co } } RouteEntry *entry = find_if(rtable_begin, rtable_end, +#if (__cplusplus >= 201703L) // C++17 + bind(mem_fn(&RouteEntry::CompareWithMask), std::placeholders::_1, &addr)); +#else bind2nd(mem_fun_ref(&RouteEntry::CompareWithMask), &addr)); +#endif if (entry != rtable_end) { return entry->GetDestination(); } @@ -3659,9 +3670,15 @@ bool Toolkit::GetH46023STUN(const PIPSocket::Address & addr, H323TransportAddres int intID = m_ProxyCriterion.IsInternal(addr); std::map >::iterator inf = m_H46023STUN.find(intID); if (inf != m_H46023STUN.end()) { - if (inf->second.size() > 1) - // TODO random_shuffle is removed in C++17 + if (inf->second.size() > 1) { +#if (__cplusplus >= 201703L) // C++17 + std::random_device rd; + std::mt19937 g(rd()); + std::shuffle(inf->second.begin(), inf->second.end(), g); +#else std::random_shuffle(inf->second.begin(), inf->second.end()); +#endif + } stun = inf->second.front(); return true; } diff --git a/Toolkit.h b/Toolkit.h index a4d8ef37..6ce1c261 100644 --- a/Toolkit.h +++ b/Toolkit.h @@ -32,8 +32,6 @@ extern "C" { #include #include #include -// on Windows PTLib 2.10.x doesn't set an #pragma include_alias for this file, -// so the OpenSSL include dir must be added to IDE settings #include // needed for certificate check } #endif diff --git a/capctrl.cxx b/capctrl.cxx index 32f187e1..d6726471 100644 --- a/capctrl.cxx +++ b/capctrl.cxx @@ -6,7 +6,7 @@ * $Id$ * * Copyright (c) 2006, Michal Zygmuntowicz - * Copyright (c) 2008-2016, Jan Willamowius + * Copyright (c) 2008-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -31,8 +31,14 @@ namespace { // greater operators for sorting route lists -// TODO the use of binary_function needs a patch for C++17 +#if (__cplusplus >= 201703L) +struct IpRule_greater { + typedef CapacityControl::IpCallVolume first_argument_type; + typedef CapacityControl::IpCallVolume second_argument_type; + typedef bool result_type; +#else struct IpRule_greater : public std::binary_function { +#endif bool operator()(const CapacityControl::IpCallVolume &e1, const CapacityControl::IpCallVolume &e2) const { @@ -50,8 +56,14 @@ struct IpRule_greater : public std::binary_function= 201703L) +struct H323IdRule_greater { + typedef CapacityControl::H323IdCallVolume first_argument_type; + typedef CapacityControl::H323IdCallVolume second_argument_type; + typedef bool result_type; +#else struct H323IdRule_greater : public std::binary_function { +#endif bool operator()(const CapacityControl::H323IdCallVolume & e1, const CapacityControl::H323IdCallVolume & e2) const { @@ -59,8 +71,14 @@ struct H323IdRule_greater : public std::binary_function= 201703L) +struct CLIRule_greater { + typedef CapacityControl::CLICallVolume first_argument_type; + typedef CapacityControl::CLICallVolume second_argument_type; + typedef bool result_type; +#else struct CLIRule_greater : public std::binary_function { +#endif bool operator()(const CapacityControl::CLICallVolume & e1, const CapacityControl::CLICallVolume & e2) const { diff --git a/clirw.cxx b/clirw.cxx index 0dd4036a..4872d544 100644 --- a/clirw.cxx +++ b/clirw.cxx @@ -6,7 +6,7 @@ * $Id$ * * Copyright (c) 2005, Michal Zygmuntowicz - * Copyright (c) 2007-2013, Jan Willamowius + * Copyright (c) 2007-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -102,8 +102,14 @@ PString CLIRewrite::RewriteRule::AsString() const } namespace { -// TODO the use of binary_function needs a patch for C++17 +#if (__cplusplus >= 201703L) // C++17 +struct RewriteRule_greater { + typedef CLIRewrite::RewriteRule first_argument_type; + typedef CLIRewrite::RewriteRule second_argument_type; + typedef bool result_type; +#else struct RewriteRule_greater : public std::binary_function { +#endif bool operator()(const CLIRewrite::RewriteRule &e1, const CLIRewrite::RewriteRule &e2) const { @@ -117,8 +123,14 @@ struct RewriteRule_greater : public std::binary_function= 201703L) // C++17 +struct SingleIpRule_greater { + typedef CLIRewrite::SingleIpRule first_argument_type; + typedef CLIRewrite::SingleIpRule second_argument_type; + typedef bool result_type; +#else struct SingleIpRule_greater : public std::binary_function { +#endif bool operator()(const CLIRewrite::SingleIpRule &e1, const CLIRewrite::SingleIpRule &e2) const { @@ -136,7 +148,14 @@ struct SingleIpRule_greater : public std::binary_function= 201703L) // C++17 +struct DoubleIpRule_greater { + typedef CLIRewrite::DoubleIpRule first_argument_type; + typedef CLIRewrite::DoubleIpRule second_argument_type; + typedef bool result_type; +#else struct DoubleIpRule_greater : public std::binary_function { +#endif bool operator()(const CLIRewrite::DoubleIpRule &e1, const CLIRewrite::DoubleIpRule &e2) const { diff --git a/factory.h b/factory.h index 3c7110df..494234e6 100644 --- a/factory.h +++ b/factory.h @@ -99,10 +99,19 @@ factory.h(135) Init Can't create SampleC with 3 parameter(s) namespace std { +#if (__cplusplus >= 201703L) // C++17 +template<> struct less { + typedef const char * first_argument_type; + typedef const char * second_argument_type; + typedef bool result_type; + bool operator()(const char *s1, const char *s2) const { return (strcmp(s1, s2) < 0); } +}; +#else // gcc 3.x said specialization can't be put in different namespace template<> struct less : public binary_function { bool operator()(const char *s1, const char *s2) const { return (strcmp(s1, s2) < 0); } }; +#endif } diff --git a/ipauth.cxx b/ipauth.cxx index e12f6f9c..931211a8 100644 --- a/ipauth.cxx +++ b/ipauth.cxx @@ -6,7 +6,7 @@ * @(#) $Id$ * * Copyright (c) 2005, Michal Zygmuntowicz - * Copyright (c) 2006-2016, Jan Willamowius + * Copyright (c) 2006-2023, Jan Willamowius * * This work is published under the GNU Public License version 2 (GPLv2) * see file COPYING for details. @@ -194,7 +194,14 @@ int IPAuthBase::Check( namespace { const char *FileIPAuthSecName = "FileIPAuth"; +#if (__cplusplus >= 201703L) // C++17 +struct IPAuthEntry_greater { + typedef FileIPAuth::IPAuthEntry first_argument_type; + typedef FileIPAuth::IPAuthEntry second_argument_type; + typedef bool result_type; +#else struct IPAuthEntry_greater : public binary_function { +#endif bool operator()( const FileIPAuth::IPAuthEntry & a, diff --git a/stl_supp.h b/stl_supp.h index 81b061be..06401298 100644 --- a/stl_supp.h +++ b/stl_supp.h @@ -4,7 +4,7 @@ // // Supplementary of STL // -// Copyright (c) 2001-2018, Jan Willamowius +// Copyright (c) 2001-2023, Jan Willamowius // // Part of this code is adapted from the SGI implementation // @@ -23,12 +23,15 @@ #include #include + // Composition adapter is not part of C++ standard #if !defined(__GNUC__) || (defined(__GNUC__) && __GNUC__ >= 3) template class unary_compose +#if (__cplusplus < 201703L) : public std::unary_function +#endif { protected: _Operation1 __op1; @@ -55,7 +58,11 @@ using std::compose1; // since VC6 didn't support partial specialization, use different names template +#if (__cplusplus >= 201703L) // C++17 +class mem_vfun_t { +#else class mem_vfun_t : public std::unary_function<_Tp*,void> { +#endif public: explicit mem_vfun_t(void (_Tp::*__pf)()) : _M_f(__pf) {} void operator()(_Tp* __p) const { (__p->*_M_f)(); } @@ -64,7 +71,11 @@ class mem_vfun_t : public std::unary_function<_Tp*,void> { }; template +#if (__cplusplus >= 201703L) // C++17 +class const_mem_vfun_t { +#else class const_mem_vfun_t : public std::unary_function { +#endif public: explicit const_mem_vfun_t(void (_Tp::*__pf)() const) : _M_f(__pf) {} void operator()(const _Tp* __p) const { (__p->*_M_f)(); } @@ -73,7 +84,11 @@ class const_mem_vfun_t : public std::unary_function { }; template +#if (__cplusplus >= 201703L) // C++17 +class mem_vfun_ref_t { +#else class mem_vfun_ref_t : public std::unary_function<_Tp,void> { +#endif public: explicit mem_vfun_ref_t(void (_Tp::*__pf)()) : _M_f(__pf) {} void operator()(_Tp& __r) const { (__r.*_M_f)(); } @@ -82,7 +97,11 @@ class mem_vfun_ref_t : public std::unary_function<_Tp,void> { }; template +#if (__cplusplus >= 201703L) // C++17 +class const_mem_vfun_ref_t { +#else class const_mem_vfun_ref_t : public std::unary_function<_Tp,void> { +#endif public: explicit const_mem_vfun_ref_t(void (_Tp::*__pf)() const) : _M_f(__pf) {} void operator()(const _Tp& __r) const { (__r.*_M_f)(); } @@ -91,7 +110,11 @@ class const_mem_vfun_ref_t : public std::unary_function<_Tp,void> { }; template +#if (__cplusplus >= 201703L) // C++17 +class mem_vfun1_t { +#else class mem_vfun1_t : public std::binary_function<_Tp*,_Arg,void> { +#endif public: explicit mem_vfun1_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} void operator()(_Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } @@ -100,7 +123,11 @@ class mem_vfun1_t : public std::binary_function<_Tp*,_Arg,void> { }; template +#if (__cplusplus >= 201703L) // C++17 +class const_mem_vfun1_t { +#else class const_mem_vfun1_t : public std::binary_function { +#endif public: explicit const_mem_vfun1_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} void operator()(const _Tp* __p, _Arg __x) const { (__p->*_M_f)(__x); } @@ -109,7 +136,11 @@ class const_mem_vfun1_t : public std::binary_function { }; template +#if (__cplusplus >= 201703L) // C++17 +class mem_vfun1_ref_t { +#else class mem_vfun1_ref_t : public std::binary_function<_Tp,_Arg,void> { +#endif public: explicit mem_vfun1_ref_t(void (_Tp::*__pf)(_Arg)) : _M_f(__pf) {} void operator()(_Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } @@ -118,7 +149,11 @@ class mem_vfun1_ref_t : public std::binary_function<_Tp,_Arg,void> { }; template +#if (__cplusplus >= 201703L) // C++17 +class const_mem_vfun1_ref_t { +#else class const_mem_vfun1_ref_t : public std::binary_function<_Tp,_Arg,void> { +#endif public: explicit const_mem_vfun1_ref_t(void (_Tp::*__pf)(_Arg) const) : _M_f(__pf) {} void operator()(const _Tp& __r, _Arg __x) const { (__r.*_M_f)(__x); } @@ -157,7 +192,11 @@ inline const_mem_vfun1_ref_t<_Tp,_Arg> mem_vfun_ref(void (_Tp::*__f)(_Arg) const // end of partial specialization +#if (__cplusplus >= 201703L) // C++17 +struct str_prefix_greater { +#else struct str_prefix_greater : public std::binary_function { +#endif bool operator()(const std::string& s1, const std::string& s2) const { @@ -168,7 +207,11 @@ struct str_prefix_greater : public std::binary_function= 201703L) // C++17 +struct str_prefix_lesser { +#else struct str_prefix_lesser : public std::binary_function { +#endif bool operator()(const std::string& s1, const std::string& s2) const { @@ -179,7 +222,11 @@ struct str_prefix_lesser : public std::binary_function= 201703L) // C++17 +struct pstr_prefix_lesser { +#else struct pstr_prefix_lesser : public std::binary_function { +#endif bool operator()(const PString& s1, const PString& s2) const { diff --git a/yasocket.cxx b/yasocket.cxx index f5c48ebd..23496c2c 100644 --- a/yasocket.cxx +++ b/yasocket.cxx @@ -45,8 +45,10 @@ #endif // LARGE_FDSET +#if (__cplusplus < 201703L) // before C++17 using std::mem_fun; using std::bind1st; +#endif using std::partition; using std::distance; using std::copy; @@ -1043,7 +1045,11 @@ void SocketsReader::Stop() PWaitAndSignal lock(m_deletionPreventer); m_listmutex.StartWrite(); +#if (__cplusplus >= 201703L) // C++17 + ForEachInContainer(m_sockets, mem_fn(&IPSocket::Close)); +#else ForEachInContainer(m_sockets, mem_fun(&IPSocket::Close)); +#endif m_listmutex.EndWrite(); RegularJob::Stop(); @@ -1068,7 +1074,11 @@ void SocketsReader::AddSocket(IPSocket * socket) bool SocketsReader::BuildSelectList(SocketSelectList & slist) { ReadLock lock(m_listmutex); +#if (__cplusplus >= 201703L) // C++17 + ForEachInContainer(m_sockets, bind(&SocketSelectList::Append, &slist, std::placeholders::_1)); +#else ForEachInContainer(m_sockets, bind1st(mem_fun(&SocketSelectList::Append), &slist)); +#endif return !slist.IsEmpty(); } @@ -1099,7 +1109,11 @@ bool SocketsReader::SelectSockets(SocketSelectList & slist) void SocketsReader::RemoveClosed(bool bDeleteImmediately) { WriteLock listlock(m_listmutex); +#if (__cplusplus >= 201703L) // C++17 + iterator iter = partition(m_sockets.begin(), m_sockets.end(), mem_fn(&IPSocket::IsOpen)); +#else iterator iter = partition(m_sockets.begin(), m_sockets.end(), mem_fun(&IPSocket::IsOpen)); +#endif if (ptrdiff_t rmsize = distance(iter, m_sockets.end())) { if (bDeleteImmediately) DeleteObjects(iter, m_sockets.end()); @@ -1214,8 +1228,13 @@ void TCPServer::ReadSocket(IPSocket * socket) if (cps_limit > 0) { time_t now = time(NULL); // clear old values +#if (__cplusplus >= 201703L) // C++17 + one_sec.remove_if(bind(not_equal_to(), placeholders::_1, now)); + many_sec.remove_if(bind(less(), placeholders::_1, now - check_interval)); +#else one_sec.remove_if(bind2nd(not_equal_to(), now)); many_sec.remove_if(bind2nd(less(), now - check_interval)); +#endif PTRACE(4, GetName() << "\tcurrent cps=" << one_sec.size() << " calls in interval=" << many_sec.size()); if ((many_sec.size() > (cps_limit * check_interval)) && (one_sec.size() > cps_limit)) { // reject call