mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Renamed CZNC::New() to CZNC::Get() and return a static reference instead of a pointer
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@504 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
36
main.cpp
36
main.cpp
@@ -43,7 +43,6 @@ void die(int sig) {
|
||||
}
|
||||
#endif /* _DEBUG */
|
||||
|
||||
delete CZNC::New();
|
||||
exit(sig);
|
||||
}
|
||||
|
||||
@@ -104,9 +103,9 @@ int main(int argc, char** argv, char** envp) {
|
||||
sConfig = argv[optind];
|
||||
|
||||
if (bMakeConf) {
|
||||
CZNC* pZNC = CZNC::New();
|
||||
pZNC->InitDirs("");
|
||||
if (pZNC->WriteNewConfig(sConfig)) {
|
||||
CZNC& ZNC = CZNC::Get();
|
||||
ZNC.InitDirs("");
|
||||
if (ZNC.WriteNewConfig(sConfig)) {
|
||||
if (argc > 2) {
|
||||
char* args[3];
|
||||
args[0] = argv[0];
|
||||
@@ -128,15 +127,14 @@ int main(int argc, char** argv, char** envp) {
|
||||
|
||||
#ifdef HAVE_LIBSSL
|
||||
if (bMakePem) {
|
||||
CZNC* pZNC = CZNC::New();
|
||||
pZNC->InitDirs("");
|
||||
CString sPemFile = pZNC->GetPemLocation();
|
||||
CZNC& ZNC = CZNC::Get();
|
||||
ZNC.InitDirs("");
|
||||
CString sPemFile = ZNC.GetPemLocation();
|
||||
|
||||
CUtils::PrintAction("Writing Pem file [" + sPemFile + "]");
|
||||
|
||||
if (CFile::Exists(sPemFile)) {
|
||||
CUtils::PrintStatus(false, "File already exists");
|
||||
delete pZNC;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -144,7 +142,6 @@ int main(int argc, char** argv, char** envp) {
|
||||
|
||||
if (!f) {
|
||||
CUtils::PrintStatus(false, "Unable to open");
|
||||
delete pZNC;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
@@ -153,7 +150,6 @@ int main(int argc, char** argv, char** envp) {
|
||||
|
||||
CUtils::PrintStatus(true);
|
||||
|
||||
delete pZNC;
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_LIBSSL */
|
||||
@@ -165,24 +161,21 @@ int main(int argc, char** argv, char** envp) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CZNC* pZNC = CZNC::New();
|
||||
pZNC->InitDirs(((argc) ? argv[0] : ""));
|
||||
CZNC& ZNC = CZNC::Get();
|
||||
ZNC.InitDirs(((argc) ? argv[0] : ""));
|
||||
|
||||
if (!pZNC->ParseConfig(sConfig)) {
|
||||
if (!ZNC.ParseConfig(sConfig)) {
|
||||
CUtils::PrintError("Unrecoverable config error.");
|
||||
delete pZNC;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!pZNC->GetListenPort()) {
|
||||
if (!ZNC.GetListenPort()) {
|
||||
CUtils::PrintError("You must supply a ListenPort in your config.");
|
||||
delete pZNC;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!pZNC->OnBoot()) {
|
||||
if (!ZNC.OnBoot()) {
|
||||
CUtils::PrintError("Exiting due to module boot errors.");
|
||||
delete pZNC;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -195,14 +188,13 @@ int main(int argc, char** argv, char** envp) {
|
||||
|
||||
if (iPid == -1) {
|
||||
CUtils::PrintStatus(false, strerror(errno));
|
||||
delete pZNC;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (iPid > 0) {
|
||||
CUtils::PrintStatus(true, "[pid: " + CString::ToString(iPid) + "]");
|
||||
|
||||
pZNC->WritePidFile(iPid);
|
||||
ZNC.WritePidFile(iPid);
|
||||
CUtils::PrintMessage(CZNC::GetTag(false));
|
||||
exit(0);
|
||||
}
|
||||
@@ -231,7 +223,7 @@ int main(int argc, char** argv, char** envp) {
|
||||
int iRet = 0;
|
||||
|
||||
try {
|
||||
iRet = pZNC->Loop();
|
||||
iRet = ZNC.Loop();
|
||||
} catch (CException e) {
|
||||
// EX_Shutdown is thrown to exit
|
||||
switch (e.GetType()) {
|
||||
@@ -242,7 +234,5 @@ int main(int argc, char** argv, char** envp) {
|
||||
}
|
||||
}
|
||||
|
||||
delete pZNC;
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
return "";
|
||||
}
|
||||
|
||||
CModules& Modules = (bGlobal) ? CZNC::New()->GetModules() : m_pUser->GetModules();
|
||||
CModules& Modules = (bGlobal) ? CZNC::Get().GetModules() : m_pUser->GetModules();
|
||||
|
||||
for (unsigned int a = 0; a < Modules.size(); a++) {
|
||||
CModule* pModule = Modules[a];
|
||||
|
||||
Reference in New Issue
Block a user