Make modperl support AddServerDependentCapability

This commit is contained in:
Alexey Sokolov
2024-01-14 12:02:07 +00:00
parent efd136c01c
commit 2b3b224bca
5 changed files with 75 additions and 3 deletions
+4
View File
@@ -189,6 +189,10 @@ class MCString : public std::map<CString, CString> {};
bool ExistsNV(const CString& sName) {
return $self->EndNV() != $self->FindNV(sName);
}
void AddServerDependentCapability(const CString& sName, SV* serverCb,
SV* clientCb) {
$self->AddServerDependentCapability(sName, std::make_unique<CPerlCapability>(serverCb, clientCb));
}
}
%extend CModules {
+14
View File
@@ -216,6 +216,20 @@ inline CPerlSocket* CreatePerlSocket(CPerlModule* pModule, SV* perlObj) {
return new CPerlSocket(pModule, perlObj);
}
class ZNC_EXPORT_LIB_EXPORT CPerlCapability : public CCapability {
public:
CPerlCapability(SV* serverCb, SV* clientCb)
: m_serverCb(newSVsv(serverCb)), m_clientCb(newSVsv(clientCb)) {}
~CPerlCapability();
void OnServerChangedSupport(CIRCNetwork* pNetwork, bool bState) override;
void OnClientChangedSupport(CClient* pClient, bool bState) override;
private:
SV* m_serverCb;
SV* m_clientCb;
};
inline bool HaveIPv6() {
#ifdef HAVE_IPV6
return true;