diff --git a/GkClient.cxx b/GkClient.cxx index d276f2e1..237ed19a 100644 --- a/GkClient.cxx +++ b/GkClient.cxx @@ -40,12 +40,16 @@ #include #endif +#include + 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 +2507,11 @@ void GkClient::Unregister() m_natClient->Stop(); m_natClient = NULL; } +#if (__cplusplus >= 201703L) // C++17 + for_each(m_handlers, m_handlers + 4, std::bind(std::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 +2766,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(std::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/RasTbl.cxx b/RasTbl.cxx index 67f4055d..961c1854 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()); } @@ -3131,7 +3189,7 @@ int EndpointRec::GetTimeToLive() const if (enableTTLRestrictions && (m_nat || IsTraversalClient() || UsesH46017())) { // force timeToLive to 5 - 30 sec, 19 sec if not set - return m_timeToLive == 0 ? m_defaultKeepAliveInterval : max(5, min(30, m_defaultKeepAliveInterval)); + return m_timeToLive == 0 ? m_defaultKeepAliveInterval : std::max(5, min(30, m_defaultKeepAliveInterval)); } return m_timeToLive; } @@ -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 b329e98f..60b012a9 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. @@ -38,11 +38,15 @@ #include #endif // HAS_LIBCURL +#include + using std::string; using std::vector; using std::list; using std::stable_sort; +#if (__cplusplus < 201703L) using std::binary_function; +#endif namespace Routing { @@ -1595,7 +1599,14 @@ bool VirtualQueuePolicy::OnRequest(SetupRequest & request) return false; } +#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/addpasswd_2022.vcxproj b/addpasswd_2022.vcxproj index 0369e0de..bc7b1e6e 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) @@ -122,6 +130,8 @@ Level2 true EditAndContinue + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) _DEBUG;_AFXDLL;%(PreprocessorDefinitions) @@ -129,7 +139,7 @@ ptlibsd.lib;%(AdditionalDependencies) - $(TargetDir)addpasswd.exe + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/addpasswd.exe true true $(TargetDir)addpasswd.pdb @@ -165,6 +175,8 @@ Level2 true ProgramDatabase + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) _DEBUG;_AFXDLL;%(PreprocessorDefinitions) @@ -172,7 +184,7 @@ ptlibs_$(PlatformShortName)_d.lib;%(AdditionalDependencies) - $(TargetDir)addpasswd.exe + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/addpasswd.exe true true $(TargetDir)addpasswd_$(PlatformShortName).pdb @@ -213,6 +225,8 @@ true ProgramDatabase true + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) NDEBUG;_AFXDLL;%(PreprocessorDefinitions) @@ -220,7 +234,7 @@ ptlibs.lib;mpr.lib;winmm.lib;%(AdditionalDependencies) - Release/addpasswd.exe + $(SolutionDir)/$(ProjectName)/$(Configuration)_$(PlatformShortName)/addpasswd.exe true Release/addpasswd.pdb Console @@ -261,6 +275,8 @@ true ProgramDatabase true + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) NDEBUG;_AFXDLL;%(PreprocessorDefinitions) @@ -268,7 +284,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 b12afbf0..3c41db30 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,28 +80,28 @@ false v143 - + v143 - + v143 - + v143 - + v143 - + v143 - + v143 - + v143 - + v143 @@ -148,8 +148,8 @@ false false false - $(Configuration)\ - $(Configuration)\ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ + $(SolutionDir)/$(Configuration)_$(PlatformShortName)/ AllRules.ruleset @@ -196,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)/ @@ -247,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 @@ -288,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 @@ -329,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 @@ -370,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 @@ -392,7 +398,7 @@ MultiThreadedDebugDLL Default true - .\Debug/gk.pch + .\Debug/gnugk.pch .\Debug/ .\Debug/ .\Debug/ @@ -401,8 +407,8 @@ true ProgramDatabase Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) _DEBUG;%(PreprocessorDefinitions) @@ -410,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 @@ -442,8 +448,8 @@ true ProgramDatabase Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) _DEBUG;%(PreprocessorDefinitions) @@ -451,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 @@ -480,15 +486,15 @@ false false true - $(TargetDir)gk.pch + $(TargetDir)gnugk.pch $(TargetDir) $(TargetDir) $(TargetDir) Level2 true Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) NDEBUG;%(PreprocessorDefinitions) @@ -496,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 @@ -533,8 +539,8 @@ Level3 true Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) NDEBUG;%(PreprocessorDefinitions) @@ -542,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 @@ -571,15 +577,15 @@ false false true - $(TargetDir)gk.pch + $(TargetDir)gnugk.pch $(TargetDir) $(TargetDir) $(TargetDir) Level2 true Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) NDEBUG;%(PreprocessorDefinitions) @@ -587,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 @@ -624,8 +630,8 @@ Level3 true Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) NDEBUG;%(PreprocessorDefinitions) @@ -633,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 @@ -655,7 +661,7 @@ MultiThreadedDebugDLL Default true - .\Debug/gk.pch + .\Debug/gnugk.pch .\Debug/ .\Debug/ .\Debug/ @@ -664,8 +670,8 @@ true ProgramDatabase Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) _DEBUG;%(PreprocessorDefinitions) @@ -673,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 @@ -705,8 +711,8 @@ true ProgramDatabase Default - - + stdcpp17 + /Zc:__cplusplus %(AdditionalOptions) _DEBUG;%(PreprocessorDefinitions) @@ -714,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 diff --git a/yasocket.cxx b/yasocket.cxx index f5c48ebd..b0502a22 100644 --- a/yasocket.cxx +++ b/yasocket.cxx @@ -20,6 +20,7 @@ #include "yasocket.h" #include "Toolkit.h" #include "snmp.h" +#include "factory.h" #include "gk.h" #include "gnugkbuildopts.h" #include "ptbuildopts.h" // sets WINVER needed for WSAPoll @@ -45,8 +46,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 +1046,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 +1075,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 +1110,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 +1229,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(std::not_equal_to(), std::placeholders::_1, now)); + many_sec.remove_if(bind(std::less(), std::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