mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
Patch ZNC core for more control over singleton...
This commit is contained in:
+3
-1
@@ -56,7 +56,7 @@ public:
|
||||
CString ExpandConfigPath(const CString& sConfigFile, bool bAllowMkDir = true);
|
||||
bool WriteNewConfig(const CString& sConfigFile);
|
||||
bool WriteConfig();
|
||||
bool ParseConfig(const CString& sConfig);
|
||||
bool ParseConfig(const CString& sConfig, CString& sError);
|
||||
bool RehashConfig(CString& sError);
|
||||
void BackupConfigOnce(const CString& sSuffix);
|
||||
static CString GetVersion();
|
||||
@@ -131,7 +131,9 @@ public:
|
||||
// !Getters
|
||||
|
||||
// Static allocator
|
||||
static void CreateInstance();
|
||||
static CZNC& Get();
|
||||
static void DestroyInstance();
|
||||
CUser* FindUser(const CString& sUsername);
|
||||
CModule* FindModule(const CString& sModName, const CString& sUsername);
|
||||
CModule* FindModule(const CString& sModName, CUser* pUser);
|
||||
|
||||
+4
-1
@@ -193,6 +193,8 @@ int main(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
CZNC::CreateInstance();
|
||||
|
||||
CZNC* pZNC = &CZNC::Get();
|
||||
pZNC->InitDirs(((argc) ? argv[0] : ""), sDataDir);
|
||||
|
||||
@@ -264,7 +266,8 @@ int main(int argc, char** argv) {
|
||||
/* Fall through to normal bootup */
|
||||
}
|
||||
|
||||
if (!pZNC->ParseConfig(sConfig)) {
|
||||
CString sConfigError;
|
||||
if (!pZNC->ParseConfig(sConfig, sConfigError)) {
|
||||
CUtils::PrintError("Unrecoverable config error.");
|
||||
delete pZNC;
|
||||
return 1;
|
||||
|
||||
+17
-6
@@ -1022,13 +1022,11 @@ void CZNC::BackupConfigOnce(const CString& sSuffix) {
|
||||
CUtils::PrintStatus(false, strerror(errno));
|
||||
}
|
||||
|
||||
bool CZNC::ParseConfig(const CString& sConfig)
|
||||
bool CZNC::ParseConfig(const CString& sConfig, CString& sError)
|
||||
{
|
||||
CString s;
|
||||
|
||||
m_sConfigFile = ExpandConfigPath(sConfig, false);
|
||||
|
||||
return DoRehash(s);
|
||||
return DoRehash(sError);
|
||||
}
|
||||
|
||||
bool CZNC::RehashConfig(CString& sError)
|
||||
@@ -1853,9 +1851,22 @@ bool CZNC::DelListener(CListener* pListener) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static CZNC* s_pZNC = NULL;
|
||||
|
||||
void CZNC::CreateInstance() {
|
||||
if (s_pZNC)
|
||||
abort();
|
||||
|
||||
s_pZNC = new CZNC();
|
||||
}
|
||||
|
||||
CZNC& CZNC::Get() {
|
||||
static CZNC* pZNC = new CZNC;
|
||||
return *pZNC;
|
||||
return *s_pZNC;
|
||||
}
|
||||
|
||||
void CZNC::DestroyInstance() {
|
||||
delete s_pZNC;
|
||||
s_pZNC = NULL;
|
||||
}
|
||||
|
||||
CZNC::TrafficStatsMap CZNC::GetTrafficStats(TrafficStatsPair &Users,
|
||||
|
||||
Reference in New Issue
Block a user