mirror of
https://github.com/znc/znc.git
synced 2026-05-04 04:22:37 +02:00
Moved CUtils::ToString() into CString class
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@248 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
2
Chan.cpp
2
Chan.cpp
@@ -53,7 +53,7 @@ void CChan::JoinUser() {
|
||||
|
||||
if (!GetTopic().empty()) {
|
||||
m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 332 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " :" + GetTopic());
|
||||
m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 333 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " " + GetTopicOwner() + " " + CUtils::ToString(GetTopicDate()));
|
||||
m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 333 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " " + GetTopicOwner() + " " + CString::ToString(GetTopicDate()));
|
||||
}
|
||||
|
||||
CString sPre = ":" + m_pUser->GetIRCServer() + " 353 " + m_pUser->GetIRCNick().GetNick() + " = " + GetName() + " :";
|
||||
|
||||
@@ -25,14 +25,14 @@ void CDCCBounce::Timeout() {
|
||||
if (IsRemote()) {
|
||||
CString sHost = Csock::GetHostName();
|
||||
if (!sHost.empty()) {
|
||||
sHost = " to [" + sHost + ":" + CUtils::ToString(Csock::GetPort()) + "]";
|
||||
sHost = " to [" + sHost + ":" + CString::ToString(Csock::GetPort()) + "]";
|
||||
} else {
|
||||
sHost = ".";
|
||||
}
|
||||
|
||||
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Timeout while connecting" + sHost);
|
||||
} else {
|
||||
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Timeout waiting for incoming connection [" + Csock::GetLocalIP() + ":" + CUtils::ToString(Csock::GetLocalPort()) + "]");
|
||||
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Timeout waiting for incoming connection [" + Csock::GetLocalIP() + ":" + CString::ToString(Csock::GetLocalPort()) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void CDCCBounce::ConnectionRefused() {
|
||||
CString sType = (m_bIsChat) ? "Chat" : "Xfer";
|
||||
CString sHost = Csock::GetHostName();
|
||||
if (!sHost.empty()) {
|
||||
sHost = " to [" + sHost + ":" + CUtils::ToString(Csock::GetPort()) + "]";
|
||||
sHost = " to [" + sHost + ":" + CString::ToString(Csock::GetPort()) + "]";
|
||||
} else {
|
||||
sHost = ".";
|
||||
}
|
||||
@@ -57,12 +57,12 @@ void CDCCBounce::SockError(int iErrno) {
|
||||
if (IsRemote()) {
|
||||
CString sHost = Csock::GetHostName();
|
||||
if (!sHost.empty()) {
|
||||
sHost = "[" + sHost + ":" + CUtils::ToString(Csock::GetPort()) + "]";
|
||||
sHost = "[" + sHost + ":" + CString::ToString(Csock::GetPort()) + "]";
|
||||
}
|
||||
|
||||
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + CString(strerror(iErrno)) + "]" + sHost);
|
||||
} else {
|
||||
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + CString(strerror(iErrno)) + "] [" + Csock::GetLocalIP() + ":" + CUtils::ToString(Csock::GetLocalPort()) + "]");
|
||||
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + CString(strerror(iErrno)) + "] [" + Csock::GetLocalIP() + ":" + CString::ToString(Csock::GetLocalPort()) + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void CDCCSock::Timeout() {
|
||||
|
||||
void CDCCSock::SockError(int iErrno) {
|
||||
DEBUG_ONLY(cout << GetSockName() << " == SockError(" << iErrno << ")" << endl);
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Socket Error [" + CUtils::ToString(iErrno) + "]");
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Socket Error [" + CString::ToString(iErrno) + "]");
|
||||
}
|
||||
|
||||
void CDCCSock::Connected() {
|
||||
@@ -65,9 +65,9 @@ void CDCCSock::Disconnected() {
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - TooMuchData!");
|
||||
} else if (m_uBytesSoFar == m_uFileSize) {
|
||||
if (m_bSend) {
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Completed! - Sent [" + m_sLocalFile + "] at [" + CUtils::ToKBytes(GetAvgWrite() / 1000.0) + "]");
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Completed! - Sent [" + m_sLocalFile + "] at [" + CString::ToKBytes(GetAvgWrite() / 1000.0) + "]");
|
||||
} else {
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Completed! - Saved to [" + m_sLocalFile + "] at [" + CUtils::ToKBytes(GetAvgRead() / 1000.0) + "]");
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Completed! - Saved to [" + m_sLocalFile + "] at [" + CString::ToKBytes(GetAvgRead() / 1000.0) + "]");
|
||||
}
|
||||
} else {
|
||||
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Incomplete!");
|
||||
|
||||
@@ -633,7 +633,7 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) {
|
||||
unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, "", true, m_pUser, GetLocalIP(), CUtils::GetIP(uLongIP));
|
||||
|
||||
if (uBNCPort) {
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC CHAT chat " + CUtils::ToString(CUtils::GetLongIP(GetLocalIP())) + " " + CUtils::ToString(uBNCPort) + "\001");
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC CHAT chat " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " " + CString::ToString(uBNCPort) + "\001");
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(sType.c_str(), "SEND") == 0) {
|
||||
@@ -642,14 +642,14 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) {
|
||||
|
||||
unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, sFile, false, m_pUser, GetLocalIP(), CUtils::GetIP(uLongIP));
|
||||
if (uBNCPort) {
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC SEND " + sFile + " " + CUtils::ToString(CUtils::GetLongIP(GetLocalIP())) + " " + CUtils::ToString(uBNCPort) + " " + CUtils::ToString(uFileSize) + "\001");
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC SEND " + sFile + " " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " " + CString::ToString(uBNCPort) + " " + CString::ToString(uFileSize) + "\001");
|
||||
}
|
||||
} else if (strcasecmp(sType.c_str(), "RESUME") == 0) {
|
||||
// Need to lookup the connection by port, filter the port, and forward to the user
|
||||
CDCCBounce* pSock = (CDCCBounce*) m_pZNC->GetManager().FindSockByLocalPort(atoi(sMessage.Token(3).c_str()));
|
||||
|
||||
if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) {
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CUtils::ToString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001");
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001");
|
||||
}
|
||||
} else if (strcasecmp(sType.c_str(), "ACCEPT") == 0) {
|
||||
// Need to lookup the connection by port, filter the port, and forward to the user
|
||||
@@ -660,7 +660,7 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) {
|
||||
|
||||
if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) {
|
||||
if (pSock->GetUserPort() == atoi(sMessage.Token(3).c_str())) {
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CUtils::ToString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001");
|
||||
PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ void CModule::ListTimers() {
|
||||
|
||||
Table.AddRow();
|
||||
Table.SetCell("Name", pTimer->GetName());
|
||||
Table.SetCell("Secs", CUtils::ToString(pTimer->GetInterval()));
|
||||
Table.SetCell("Cycles", ((uCycles) ? CUtils::ToString(uCycles) : "INF"));
|
||||
Table.SetCell("Secs", CString::ToString(pTimer->GetInterval()));
|
||||
Table.SetCell("Cycles", ((uCycles) ? CString::ToString(uCycles) : "INF"));
|
||||
Table.SetCell("Description", pTimer->GetDescription());
|
||||
}
|
||||
|
||||
|
||||
10
User.cpp
10
User.cpp
@@ -359,7 +359,7 @@ bool CUser::ResumeFile(const CString& sRemoteNick, unsigned short uPort, unsigne
|
||||
|
||||
if (pSock->GetLocalPort() == uPort) {
|
||||
if (pSock->Seek(uFileSize)) {
|
||||
PutModule(pSock->GetModuleName(), "DCC -> [" + pSock->GetRemoteNick() + "][" + pSock->GetFileName() + "] - Attempting to resume from file position [" + CUtils::ToString(uFileSize) + "]");
|
||||
PutModule(pSock->GetModuleName(), "DCC -> [" + pSock->GetRemoteNick() + "][" + pSock->GetFileName() + "] - Attempting to resume from file position [" + CString::ToString(uFileSize) + "]");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -385,11 +385,11 @@ bool CUser::SendFile(const CString& sRemoteNick, const CString& sFileName, const
|
||||
int iPort = GetManager()->ListenAllRand("DCC::LISTEN::" + sRemoteNick, false, SOMAXCONN, pSock, 120);
|
||||
|
||||
if (strcasecmp(GetNick().c_str(), sRemoteNick.c_str()) == 0) {
|
||||
PutUser(":" + GetStatusPrefix() + "status!znc@znc.com PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CUtils::ToString(CUtils::GetLongIP(GetLocalIP())) + " "
|
||||
+ CUtils::ToString(iPort) + " " + CUtils::ToString(pFile->GetSize()) + "\001");
|
||||
PutUser(":" + GetStatusPrefix() + "status!znc@znc.com PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " "
|
||||
+ CString::ToString(iPort) + " " + CString::ToString(pFile->GetSize()) + "\001");
|
||||
} else {
|
||||
PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CUtils::ToString(CUtils::GetLongIP(GetLocalIP())) + " "
|
||||
+ CUtils::ToString(iPort) + " " + CUtils::ToString(pFile->GetSize()) + "\001");
|
||||
PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " "
|
||||
+ CString::ToString(iPort) + " " + CString::ToString(pFile->GetSize()) + "\001");
|
||||
}
|
||||
|
||||
PutModule(sModuleName, "DCC -> [" + sRemoteNick + "][" + pFile->GetShortName() + "] - Attempting Send.");
|
||||
|
||||
32
UserSock.cpp
32
UserSock.cpp
@@ -207,7 +207,7 @@ void CUserSock::ReadLine(const CString& sData) {
|
||||
} else {
|
||||
unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, "", true, m_pUser, (m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP(), "");
|
||||
if (uBNCPort) {
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC CHAT chat " + CUtils::ToString(CUtils::GetLongIP(sIP)) + " " + CUtils::ToString(uBNCPort) + "\001");
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC CHAT chat " + CString::ToString(CUtils::GetLongIP(sIP)) + " " + CString::ToString(uBNCPort) + "\001");
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(sType.c_str(), "SEND") == 0) {
|
||||
@@ -243,7 +243,7 @@ void CUserSock::ReadLine(const CString& sData) {
|
||||
} else {
|
||||
unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, sFile, false, m_pUser, (m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP(), "");
|
||||
if (uBNCPort) {
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC SEND " + sFile + " " + CUtils::ToString(CUtils::GetLongIP(sIP)) + " " + CUtils::ToString(uBNCPort) + " " + CUtils::ToString(uFileSize) + "\001");
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC SEND " + sFile + " " + CString::ToString(CUtils::GetLongIP(sIP)) + " " + CString::ToString(uBNCPort) + " " + CString::ToString(uFileSize) + "\001");
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(sType.c_str(), "RESUME") == 0) {
|
||||
@@ -254,14 +254,14 @@ void CUserSock::ReadLine(const CString& sData) {
|
||||
// Need to lookup the connection by port, filter the port, and forward to the user
|
||||
if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) {
|
||||
if ((m_pUser) && (m_pUser->ResumeFile(sTarget, uResumePort, uResumeSize))) {
|
||||
PutServ(":" + sTarget + "!znc@znc.com PRIVMSG " + GetNick() + " :\001DCC ACCEPT " + sFile + " " + CUtils::ToString(uResumePort) + " " + CUtils::ToString(uResumeSize) + "\001");
|
||||
PutServ(":" + sTarget + "!znc@znc.com PRIVMSG " + GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString::ToString(uResumePort) + " " + CString::ToString(uResumeSize) + "\001");
|
||||
} else {
|
||||
PutStatus("DCC -> [" + GetNick() + "][" + sFile + "] Unable to find send to initiate resume.");
|
||||
}
|
||||
} else {
|
||||
CDCCBounce* pSock = (CDCCBounce*) m_pZNC->GetManager().FindSockByLocalPort(uResumePort);
|
||||
if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) {
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CUtils::ToString(pSock->GetUserPort()) + " " + sCTCP.Token(4) + "\001");
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetUserPort()) + " " + sCTCP.Token(4) + "\001");
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(sType.c_str(), "ACCEPT") == 0) {
|
||||
@@ -275,7 +275,7 @@ void CUserSock::ReadLine(const CString& sData) {
|
||||
|
||||
if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) {
|
||||
if (pSock->GetUserPort() == atoi(sCTCP.Token(3).c_str())) {
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CUtils::ToString(pSock->GetLocalPort()) + " " + sCTCP.Token(4) + "\001");
|
||||
PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetLocalPort()) + " " + sCTCP.Token(4) + "\001");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -490,19 +490,19 @@ void CUserSock::UserCommand(const CString& sLine) {
|
||||
Table.AddRow();
|
||||
Table.SetCell("Name", CString((pChan->IsOp()) ? "@" : ((pChan->IsVoice()) ? "+" : "")) + pChan->GetName());
|
||||
Table.SetCell("Status", ((vChans[a]->IsOn()) ? ((vChans[a]->IsDetached()) ? "Detached" : "Joined") : "Trying"));
|
||||
Table.SetCell("Buf", CString((pChan->KeepBuffer()) ? "*" : "") + CUtils::ToString(pChan->GetBufferCount()));
|
||||
Table.SetCell("Buf", CString((pChan->KeepBuffer()) ? "*" : "") + CString::ToString(pChan->GetBufferCount()));
|
||||
|
||||
CString sModes = pChan->GetModeCString();
|
||||
unsigned int uLimit = pChan->GetLimit();
|
||||
const CString& sKey = pChan->GetKey();
|
||||
|
||||
if (uLimit) { sModes += " " + CUtils::ToString(uLimit); }
|
||||
if (uLimit) { sModes += " " + CString::ToString(uLimit); }
|
||||
if (!sKey.empty()) { sModes += " " + sKey; }
|
||||
|
||||
Table.SetCell("Modes", sModes);
|
||||
Table.SetCell("Users", CUtils::ToString(pChan->GetNickCount()));
|
||||
Table.SetCell("+o", CUtils::ToString(pChan->GetOpCount()));
|
||||
Table.SetCell("+v", CUtils::ToString(pChan->GetVoiceCount()));
|
||||
Table.SetCell("Users", CString::ToString(pChan->GetNickCount()));
|
||||
Table.SetCell("+o", CString::ToString(pChan->GetOpCount()));
|
||||
Table.SetCell("+v", CString::ToString(pChan->GetVoiceCount()));
|
||||
}
|
||||
|
||||
if (Table.size()) {
|
||||
@@ -565,7 +565,7 @@ void CUserSock::UserCommand(const CString& sLine) {
|
||||
CServer* pServer = vServers[a];
|
||||
Table.AddRow();
|
||||
Table.SetCell("Host", pServer->GetName());
|
||||
Table.SetCell("Port", CUtils::ToString(pServer->GetPort()));
|
||||
Table.SetCell("Port", CString::ToString(pServer->GetPort()));
|
||||
Table.SetCell("SSL", (pServer->IsSSL()) ? "SSL" : "");
|
||||
Table.SetCell("Pass", pServer->GetPass());
|
||||
}
|
||||
@@ -655,8 +655,8 @@ void CUserSock::UserCommand(const CString& sLine) {
|
||||
|
||||
Table.AddRow();
|
||||
Table.SetCell("Type", "Sending");
|
||||
Table.SetCell("State", CUtils::ToPercent(pSock->GetProgress()));
|
||||
Table.SetCell("Speed", CUtils::ToKBytes(pSock->GetAvgWrite() / 1000.0));
|
||||
Table.SetCell("State", CString::ToPercent(pSock->GetProgress()));
|
||||
Table.SetCell("Speed", CString::ToKBytes(pSock->GetAvgWrite() / 1000.0));
|
||||
Table.SetCell("Nick", pSock->GetRemoteNick());
|
||||
Table.SetCell("IP", pSock->GetRemoteIP());
|
||||
Table.SetCell("File", pSock->GetFileName());
|
||||
@@ -665,8 +665,8 @@ void CUserSock::UserCommand(const CString& sLine) {
|
||||
|
||||
Table.AddRow();
|
||||
Table.SetCell("Type", "Getting");
|
||||
Table.SetCell("State", CUtils::ToPercent(pSock->GetProgress()));
|
||||
Table.SetCell("Speed", CUtils::ToKBytes(pSock->GetAvgRead() / 1000.0));
|
||||
Table.SetCell("State", CString::ToPercent(pSock->GetProgress()));
|
||||
Table.SetCell("Speed", CString::ToKBytes(pSock->GetAvgRead() / 1000.0));
|
||||
Table.SetCell("Nick", pSock->GetRemoteNick());
|
||||
Table.SetCell("IP", pSock->GetRemoteIP());
|
||||
Table.SetCell("File", pSock->GetFileName());
|
||||
@@ -846,7 +846,7 @@ void CUserSock::UserCommand(const CString& sLine) {
|
||||
|
||||
pChan->SetBufferCount(uLineCount);
|
||||
|
||||
PutStatus("BufferCount for [" + sChan + "] set to [" + CUtils::ToString(pChan->GetBufferCount()) + "]");
|
||||
PutStatus("BufferCount for [" + sChan + "] set to [" + CString::ToString(pChan->GetBufferCount()) + "]");
|
||||
} else {
|
||||
PutStatus("I'm too stupid to help you with [" + sCommand + "]");
|
||||
}
|
||||
|
||||
28
Utils.cpp
28
Utils.cpp
@@ -282,13 +282,13 @@ bool CUtils::GetNumInput(const CString& sPrompt, unsigned int& uRet, unsigned in
|
||||
return false;
|
||||
}
|
||||
|
||||
CString sDefault = (uDefault != (unsigned int) ~0) ? CUtils::ToString(uDefault) : "";
|
||||
CString sDefault = (uDefault != (unsigned int) ~0) ? CString::ToString(uDefault) : "";
|
||||
CString sNum, sHint;
|
||||
|
||||
if (uMax != (unsigned int) ~0) {
|
||||
sHint = CUtils::ToString(uMin) + " to " + CUtils::ToString(uMax);
|
||||
sHint = CString::ToString(uMin) + " to " + CString::ToString(uMax);
|
||||
} else if (uMin > 0) {
|
||||
sHint = CUtils::ToString(uMin) + " and up";
|
||||
sHint = CString::ToString(uMin) + " and up";
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@@ -370,28 +370,6 @@ void CUtils::PrintStatus(bool bSuccess, const CString& sMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
CString CUtils::ToString(short i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(unsigned short i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(int i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(unsigned int i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(long i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(unsigned long i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(unsigned long long i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(double i) { stringstream s; s << i; return s.str(); }
|
||||
CString CUtils::ToString(float i) { stringstream s; s << i; return s.str(); }
|
||||
|
||||
CString CUtils::ToPercent(double d) {
|
||||
char szRet[32];
|
||||
snprintf(szRet, 32, "%.02f%%", d);
|
||||
return szRet;
|
||||
}
|
||||
|
||||
CString CUtils::ToKBytes(double d) {
|
||||
char szRet[32];
|
||||
snprintf(szRet, 32, "%.0f K/s", d);
|
||||
return szRet;
|
||||
}
|
||||
|
||||
bool CUtils::wildcmp(const CString& sWild, const CString& sString) {
|
||||
// Written by Jack Handy - jakkhandy@hotmail.com
|
||||
const char *wild = sWild.c_str(), *CString = sString.c_str();
|
||||
|
||||
12
Utils.h
12
Utils.h
@@ -42,18 +42,6 @@ public:
|
||||
static bool GetBoolInput(const CString& sPrompt, bool *pbDefault = NULL);
|
||||
static bool GetNumInput(const CString& sPrompt, unsigned int& uRet, unsigned int uMin = 0, unsigned int uMax = ~0, unsigned int uDefault = ~0);
|
||||
|
||||
static CString ToString(short i);
|
||||
static CString ToString(unsigned short i);
|
||||
static CString ToString(int i);
|
||||
static CString ToString(unsigned int i);
|
||||
static CString ToString(long i);
|
||||
static CString ToString(unsigned long i);
|
||||
static CString ToString(unsigned long long i);
|
||||
static CString ToString(double i);
|
||||
static CString ToString(float i);
|
||||
static CString ToPercent(double d);
|
||||
static CString ToKBytes(double d);
|
||||
|
||||
static bool wildcmp(const CString& sWild, const CString& sString);
|
||||
|
||||
static unsigned long long GetMillTime() {
|
||||
|
||||
4
main.cpp
4
main.cpp
@@ -35,7 +35,7 @@ void die(int sig) {
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
|
||||
#ifdef _DEBUG
|
||||
CUtils::PrintMessage("Exiting on SIG [" + CUtils::ToString(sig) + "]");
|
||||
CUtils::PrintMessage("Exiting on SIG [" + CString::ToString(sig) + "]");
|
||||
if ((sig == SIGABRT) || (sig == SIGSEGV)) {
|
||||
abort();
|
||||
}
|
||||
@@ -172,7 +172,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (iPid > 0) {
|
||||
CUtils::PrintStatus(true, "[pid: " + CUtils::ToString(iPid) + "]");
|
||||
CUtils::PrintStatus(true, "[pid: " + CString::ToString(iPid) + "]");
|
||||
|
||||
pZNC->WritePidFile(iPid);
|
||||
CUtils::PrintMessage(CZNC::GetTag(false));
|
||||
|
||||
16
znc.cpp
16
znc.cpp
@@ -97,7 +97,7 @@ int CZNC::Loop() {
|
||||
CUserSock* pUserSock = pUser->GetUserSock();
|
||||
|
||||
if (pUserSock) {
|
||||
pUserSock->PutStatus("Attempting to connect to [" + pServer->GetName() + ":" + CUtils::ToString(pServer->GetPort()) + "] ...");
|
||||
pUserSock->PutStatus("Attempting to connect to [" + pServer->GetName() + ":" + CString::ToString(pServer->GetPort()) + "] ...");
|
||||
}
|
||||
|
||||
pIRCSock = new CIRCSock(this, pUser);
|
||||
@@ -144,7 +144,7 @@ bool CZNC::WritePidFile(int iPid) {
|
||||
CUtils::PrintAction("Writing pid file [" + m_sPidFile + "]");
|
||||
|
||||
if (File.Open(O_WRONLY | O_TRUNC | O_CREAT)) {
|
||||
File.Write(CUtils::ToString(iPid) + "\n");
|
||||
File.Write(CString::ToString(iPid) + "\n");
|
||||
File.Close();
|
||||
CUtils::PrintStatus(true);
|
||||
return true;
|
||||
@@ -265,7 +265,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
|
||||
bAnswer = CUtils::GetBoolInput("Would you like ZNC to listen using SSL?", false);
|
||||
#endif
|
||||
|
||||
vsLines.push_back("ListenPort = " + CString((bAnswer) ? "+" : "") + CUtils::ToString(uPort));
|
||||
vsLines.push_back("ListenPort = " + CString((bAnswer) ? "+" : "") + CString::ToString(uPort));
|
||||
// !ListenPort
|
||||
|
||||
// User
|
||||
@@ -296,7 +296,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
|
||||
|
||||
unsigned int uBufferCount = 0;
|
||||
|
||||
CUtils::GetNumInput("Number of lines to buffer per channel", uBufferCount, 0, ~0, 50); if (uBufferCount) { vsLines.push_back("\tBuffer = " + CUtils::ToString(uBufferCount)); }
|
||||
CUtils::GetNumInput("Number of lines to buffer per channel", uBufferCount, 0, ~0, 50); if (uBufferCount) { vsLines.push_back("\tBuffer = " + CString::ToString(uBufferCount)); }
|
||||
if (CUtils::GetBoolInput("Would you like your buffer to be sticky?", true)) {
|
||||
vsLines.push_back("\tKeepBuffer = true");
|
||||
} else {
|
||||
@@ -351,7 +351,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
|
||||
bSSL = CUtils::GetBoolInput("Does this server use SSL? (probably no)", false);
|
||||
#endif
|
||||
|
||||
vsLines.push_back("\tServer = " + sHost + ((bSSL) ? " +" : " ") + CUtils::ToString(uPort) + " " + sPass);
|
||||
vsLines.push_back("\tServer = " + sHost + ((bSSL) ? " +" : " ") + CString::ToString(uPort) + " " + sPass);
|
||||
} while (CUtils::GetBoolInput("Would you like to add another server?", false));
|
||||
|
||||
vsLines.push_back("");
|
||||
@@ -400,7 +400,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
|
||||
CUtils::PrintMessage("as the irc server password like so.. user:pass.", true);
|
||||
CUtils::PrintMessage("");
|
||||
CUtils::PrintMessage("Try something like this in your IRC client...", true);
|
||||
CUtils::PrintMessage("/server <znc_server_ip> " + CUtils::ToString(uPort) + " " + sUser + ":<pass>", true);
|
||||
CUtils::PrintMessage("/server <znc_server_ip> " + CString::ToString(uPort) + " " + sUser + ":<pass>", true);
|
||||
CUtils::PrintMessage("");
|
||||
|
||||
return true;
|
||||
@@ -678,7 +678,7 @@ bool CZNC::ParseConfig(const CString& sConfig) {
|
||||
}
|
||||
|
||||
m_uListenPort = strtol(sPort.c_str(), NULL, 10);
|
||||
CUtils::PrintAction("Binding to port [" + CString((m_bSSL) ? "+" : "") + CUtils::ToString(m_uListenPort) + "]");
|
||||
CUtils::PrintAction("Binding to port [" + CString((m_bSSL) ? "+" : "") + CString::ToString(m_uListenPort) + "]");
|
||||
|
||||
#ifndef HAVE_LIBSSL
|
||||
if (m_bSSL) {
|
||||
@@ -714,7 +714,7 @@ bool CZNC::ParseConfig(const CString& sConfig) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CUtils::PrintAction("Binding to port [" + CString((m_bSSL) ? "+" : "") + CUtils::ToString(m_uListenPort) + "]");
|
||||
CUtils::PrintAction("Binding to port [" + CString((m_bSSL) ? "+" : "") + CString::ToString(m_uListenPort) + "]");
|
||||
}
|
||||
#endif
|
||||
if (!m_uListenPort) {
|
||||
|
||||
Reference in New Issue
Block a user