Migrated away from CString::ToString() in favor of explicit constructors

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@669 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2006-02-25 09:43:35 +00:00
parent acb9012540
commit a9e60b43c5
24 changed files with 127 additions and 114 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ bool CChan::WriteConfig(CFile& File) {
File.Write("\t<Chan " + GetName() + ">\r\n");
File.Write("\t\tBuffer = " + CString::ToString(GetBufferCount()) + "\r\n");
File.Write("\t\tBuffer = " + CString(GetBufferCount()) + "\r\n");
File.Write("\t\tKeepBuffer = " + CString((KeepBuffer()) ? "true" : "false") + "\r\n");
File.Write("\t\tDetached = " + CString((IsDetached()) ? "true" : "false") + "\r\n");
File.Write("\t\tAutoCycle = " + CString((AutoCycle()) ? "true" : "false") + "\r\n");
@@ -76,7 +76,7 @@ void CChan::JoinUser(bool bForce, const CString& sKey, CClient* pClient) {
if (!GetTopic().empty()) {
m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 332 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " :" + GetTopic(), pClient);
m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 333 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " " + GetTopicOwner() + " " + CString::ToString(GetTopicDate()), pClient);
m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 333 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " " + GetTopicOwner() + " " + CString(GetTopicDate()), pClient);
}
CString sPre = ":" + m_pUser->GetIRCServer() + " 353 " + m_pUser->GetIRCNick().GetNick() + " = " + GetName() + " :";
+11 -11
View File
@@ -292,7 +292,7 @@ void CClient::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 " + CString::ToString(CUtils::GetLongIP(sIP)) + " " + CString::ToString(uBNCPort) + "\001");
PutIRC("PRIVMSG " + sTarget + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + "\001");
}
}
} else if (sType.CaseCmp("SEND") == 0) {
@@ -328,7 +328,7 @@ void CClient::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 + " " + CString::ToString(CUtils::GetLongIP(sIP)) + " " + CString::ToString(uBNCPort) + " " + CString::ToString(uFileSize) + "\001");
PutIRC("PRIVMSG " + sTarget + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(sIP)) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001");
}
}
} else if (sType.CaseCmp("RESUME") == 0) {
@@ -339,14 +339,14 @@ void CClient::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))) {
PutClient(":" + sTarget + "!znc@znc.com PRIVMSG " + GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString::ToString(uResumePort) + " " + CString::ToString(uResumeSize) + "\001");
PutClient(":" + sTarget + "!znc@znc.com PRIVMSG " + GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001");
} else {
PutStatus("DCC -> [" + GetNick() + "][" + sFile + "] Unable to find send to initiate resume.");
}
} else {
CDCCBounce* pSock = (CDCCBounce*) CZNC::Get().GetManager().FindSockByLocalPort(uResumePort);
if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) {
PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetUserPort()) + " " + sCTCP.Token(4) + "\001");
PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sCTCP.Token(4) + "\001");
}
}
} else if (sType.CaseCmp("ACCEPT") == 0) {
@@ -360,7 +360,7 @@ void CClient::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 + " " + CString::ToString(pSock->GetLocalPort()) + " " + sCTCP.Token(4) + "\001");
PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sCTCP.Token(4) + "\001");
}
}
}
@@ -653,7 +653,7 @@ void CClient::UserCommand(const CString& sLine) {
for (map<CString, CUser*>::const_iterator it = msUsers.begin(); it != msUsers.end(); it++) {
Table.AddRow();
Table.SetCell("Username", it->first);
Table.SetCell("Clients", CString::ToString(it->second->GetClients().size()));
Table.SetCell("Clients", CString(it->second->GetClients().size()));
if (!it->second->IsIRCConnected()) {
Table.SetCell("OnIRC", "No");
} else {
@@ -743,14 +743,14 @@ void CClient::UserCommand(const CString& sLine) {
Table.SetCell("Name", pChan->GetPermStr() + pChan->GetName());
Table.SetCell("Status", ((vChans[a]->IsOn()) ? ((vChans[a]->IsDetached()) ? "Detached" : "Joined") : "Trying"));
Table.SetCell("Conf", CString((pChan->InConfig()) ? "yes" : ""));
Table.SetCell("Buf", CString((pChan->KeepBuffer()) ? "*" : "") + CString::ToString(pChan->GetBufferCount()));
Table.SetCell("Buf", CString((pChan->KeepBuffer()) ? "*" : "") + CString(pChan->GetBufferCount()));
Table.SetCell("Modes", pChan->GetModeString());
Table.SetCell("Users", CString::ToString(pChan->GetNickCount()));
Table.SetCell("Users", CString(pChan->GetNickCount()));
for (unsigned int b = 0; b < sPerms.size(); b++) {
CString sPerm;
sPerm += sPerms[b];
Table.SetCell(sPerm, CString::ToString(pChan->GetPermCount(sPerms[b])));
Table.SetCell(sPerm, CString(pChan->GetPermCount(sPerms[b])));
}
}
@@ -814,7 +814,7 @@ void CClient::UserCommand(const CString& sLine) {
CServer* pServer = vServers[a];
Table.AddRow();
Table.SetCell("Host", pServer->GetName());
Table.SetCell("Port", CString::ToString(pServer->GetPort()));
Table.SetCell("Port", CString(pServer->GetPort()));
Table.SetCell("SSL", (pServer->IsSSL()) ? "SSL" : "");
Table.SetCell("Pass", pServer->GetPass());
}
@@ -1107,7 +1107,7 @@ void CClient::UserCommand(const CString& sLine) {
pChan->SetBufferCount(uLineCount);
PutStatus("BufferCount for [" + sChan + "] set to [" + CString::ToString(pChan->GetBufferCount()) + "]");
PutStatus("BufferCount for [" + sChan + "] set to [" + CString(pChan->GetBufferCount()) + "]");
} else {
PutStatus("Unknown command [" + sCommand + "] try 'Help'");
}
+5 -5
View File
@@ -25,14 +25,14 @@ void CDCCBounce::Timeout() {
if (IsRemote()) {
CString sHost = Csock::GetHostName();
if (!sHost.empty()) {
sHost = " to [" + sHost + ":" + CString::ToString(Csock::GetPort()) + "]";
sHost = " to [" + sHost + ":" + CString(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() + ":" + CString::ToString(Csock::GetLocalPort()) + "]");
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Timeout waiting for incoming connection [" + Csock::GetLocalIP() + ":" + CString(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 + ":" + CString::ToString(Csock::GetPort()) + "]";
sHost = " to [" + sHost + ":" + CString(Csock::GetPort()) + "]";
} else {
sHost = ".";
}
@@ -57,12 +57,12 @@ void CDCCBounce::SockError(int iErrno) {
if (IsRemote()) {
CString sHost = Csock::GetHostName();
if (!sHost.empty()) {
sHost = "[" + sHost + ":" + CString::ToString(Csock::GetPort()) + "]";
sHost = "[" + sHost + ":" + CString(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() + ":" + CString::ToString(Csock::GetLocalPort()) + "]");
m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + CString(strerror(iErrno)) + "] [" + Csock::GetLocalIP() + ":" + CString(Csock::GetLocalPort()) + "]");
}
}
+1 -1
View File
@@ -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 [" + CString::ToString(iErrno) + "]");
m_pUser->PutModule(m_sModuleName, ((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Socket Error [" + CString(iErrno) + "]");
}
void CDCCSock::Connected() {
+4 -4
View File
@@ -272,10 +272,10 @@ bool CHTTPSock::PrintErrorPage(unsigned int uStatusId, const CString& sStatusMsg
CString CHTTPSock::GetErrorPage(unsigned int uStatusId, const CString& sStatusMsg, const CString& sMessage) {
return "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
"<html><head>\r\n<title>" + CString::ToString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n"
"<html><head>\r\n<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n"
"</head><body>\r\n<h1>" + sStatusMsg.Escape_n(CString::EHTML) + "</h1>\r\n"
"<p>" + sMessage.Escape_n(CString::EHTML) + "</p>\r\n"
"<hr>\r\n<address>" + CZNC::GetTag().Escape_n(CString::EHTML) + " at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString::ToString(GetLocalPort()) + "</address>\r\n"
"<hr>\r\n<address>" + CZNC::GetTag().Escape_n(CString::EHTML) + " at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString(GetLocalPort()) + "</address>\r\n"
"</body></html>\r\n";
}
@@ -321,10 +321,10 @@ bool CHTTPSock::PrintHeader(unsigned long uContentLength, const CString& sConten
DEBUG_ONLY(cout << "- " << uStatusId << " (" << sStatusMsg << ") [" << m_sContentType << "]" << endl);
Write("HTTP/1.0 " + CString::ToString(uStatusId) + " " + sStatusMsg + "\r\n");
Write("HTTP/1.0 " + CString(uStatusId) + " " + sStatusMsg + "\r\n");
//Write("Date: Tue, 28 Jun 2005 20:45:36 GMT\r\n");
Write("Server: ZNC " + CZNC::GetTag() + "\r\n");
Write("Content-Length: " + CString::ToString(uContentLength) + "\r\n");
Write("Content-Length: " + CString(uContentLength) + "\r\n");
Write("Connection: Close\r\n");
Write("Content-Type: " + m_sContentType + "\r\n");
+4 -4
View File
@@ -636,21 +636,21 @@ bool CIRCSock::OnPrivCTCP(CNick& Nick, CString& sMessage) {
unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, "", true, m_pUser, GetLocalIP(), CUtils::GetIP(uLongIP));
if (uBNCPort) {
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC CHAT chat " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " " + CString::ToString(uBNCPort) + "\001");
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC CHAT chat " + CString(CUtils::GetLongIP(GetLocalIP())) + " " + CString(uBNCPort) + "\001");
}
}
} else if (sType.CaseCmp("SEND") == 0) {
// DCC SEND readme.txt 403120438 5550 1104
unsigned short uBNCPort = CDCCBounce::DCCRequest(Nick.GetNick(), uLongIP, uPort, sFile, false, m_pUser, GetLocalIP(), CUtils::GetIP(uLongIP));
if (uBNCPort) {
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC SEND " + sFile + " " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " " + CString::ToString(uBNCPort) + " " + CString::ToString(uFileSize) + "\001");
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC SEND " + sFile + " " + CString(CUtils::GetLongIP(GetLocalIP())) + " " + CString(uBNCPort) + " " + CString(uFileSize) + "\001");
}
} else if (sType.CaseCmp("RESUME") == 0) {
// Need to lookup the connection by port, filter the port, and forward to the user
CDCCBounce* pSock = (CDCCBounce*) CZNC::Get().GetManager().FindSockByLocalPort(atoi(sMessage.Token(3).c_str()));
if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) {
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001");
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001");
}
} else if (sType.CaseCmp("ACCEPT") == 0) {
// Need to lookup the connection by port, filter the port, and forward to the user
@@ -661,7 +661,7 @@ bool CIRCSock::OnPrivCTCP(CNick& Nick, CString& sMessage) {
if ((pSock) && (strncasecmp(pSock->GetSockName().c_str(), "DCC::", 5) == 0)) {
if (pSock->GetUserPort() == atoi(sMessage.Token(3).c_str())) {
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001");
m_pUser->PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetNick() + " :\001DCC " + sType + " " + sFile + " " + CString(pSock->GetLocalPort()) + " " + sMessage.Token(4) + "\001");
}
}
}
+4 -4
View File
@@ -316,8 +316,8 @@ void CModule::ListTimers() {
Table.AddRow();
Table.SetCell("Name", pTimer->GetName());
Table.SetCell("Secs", CString::ToString(pTimer->GetInterval()));
Table.SetCell("Cycles", ((uCycles) ? CString::ToString(uCycles) : "INF"));
Table.SetCell("Secs", CString(pTimer->GetInterval()));
Table.SetCell("Cycles", ((uCycles) ? CString(uCycles) : "INF"));
Table.SetCell("Description", pTimer->GetDescription());
}
@@ -414,10 +414,10 @@ void CModule::ListSockets() {
Table.SetCell("State", (pSocket->IsConnected() ? "Connected" : ""));
}
Table.SetCell("LocalPort", CString::ToString(pSocket->GetLocalPort()));
Table.SetCell("LocalPort", CString(pSocket->GetLocalPort()));
Table.SetCell("SSL", (pSocket->GetSSL() ? "yes" : "no"));
Table.SetCell("RemoteIP", pSocket->GetRemoteIP());
Table.SetCell("RemotePort", (pSocket->GetRemotePort()) ? CString::ToString(pSocket->GetRemotePort()) : CString(""));
Table.SetCell("RemotePort", (pSocket->GetRemotePort()) ? CString(pSocket->GetRemotePort()) : CString(""));
}
if (Table.size()) {
+1 -1
View File
@@ -34,5 +34,5 @@ bool CServer::IsSSL() const { return m_bSSL; }
bool CServer::IsIPV6() const { return m_bIPV6; }
CString CServer::GetString() const {
return m_sName + " " + CString(m_bSSL ? "+" : "") + CString::ToString(m_uPort) + CString(m_sPass.empty() ? CString("") : " " + m_sPass);
return m_sName + " " + CString(m_bSSL ? "+" : "") + CString(m_uPort) + CString(m_sPass.empty() ? CString("") : " " + m_sPass);
}
+13 -13
View File
@@ -119,6 +119,19 @@ const char* g_szHTMLescapes[256] = {
"&yuml;", // 255
};
CString::CString(char c) { stringstream s; s << c; *this = s.str(); }
CString::CString(unsigned char c) { stringstream s; s << c; *this = s.str(); }
CString::CString(short i) { stringstream s; s << i; *this = s.str(); }
CString::CString(unsigned short i) { stringstream s; s << i; *this = s.str(); }
CString::CString(int i) { stringstream s; s << i; *this = s.str(); }
CString::CString(unsigned int i) { stringstream s; s << i; *this = s.str(); }
CString::CString(long i) { stringstream s; s << i; *this = s.str(); }
CString::CString(unsigned long i) { stringstream s; s << i; *this = s.str(); }
CString::CString(long long i) { stringstream s; s << i; *this = s.str(); }
CString::CString(unsigned long long i) { stringstream s; s << i; *this = s.str(); }
CString::CString(double i) { stringstream s; s << i; *this = s.str(); }
CString::CString(float i) { stringstream s; s << i; *this = s.str(); }
inline unsigned char* CString::strnchr(const unsigned char* src, unsigned char c, unsigned int iMaxBytes, unsigned char* pFill, unsigned int* piCount) const {
for (unsigned int a = 0; a < iMaxBytes && *src; a++, src++) {
if (pFill) {
@@ -835,19 +848,6 @@ void CString::Crypt(const CString& sPass, bool bEncrypt, const CString& sIvec) {
}
#endif // HAVE_LIBSSL
CString CString::ToString(char c) { stringstream s; s << c; return s.str(); }
CString CString::ToString(unsigned char c) { stringstream s; s << c; return s.str(); }
CString CString::ToString(short i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(unsigned short i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(int i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(unsigned int i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(long i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(unsigned long i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(long long i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(unsigned long long i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(double i) { stringstream s; s << i; return s.str(); }
CString CString::ToString(float i) { stringstream s; s << i; return s.str(); }
CString CString::ToPercent(double d) {
char szRet[32];
snprintf(szRet, 32, "%.02f%%", d);
+13 -12
View File
@@ -65,6 +65,19 @@ public:
ESQL,
} EEscape;
explicit CString(char c);
explicit CString(unsigned char c);
explicit CString(short i);
explicit CString(unsigned short i);
explicit CString(int i);
explicit CString(unsigned int i);
explicit CString(long i);
explicit CString(unsigned long i);
explicit CString(long long i);
explicit CString(unsigned long long i);
explicit CString(double i);
explicit CString(float i);
CString() : string() {}
CString(const char* c) : string(c) {}
CString(const string& s) : string(s) {}
@@ -118,18 +131,6 @@ public:
void Crypt(const CString& sPass, bool bEncrypt, const CString& sIvec = "");
#endif
static CString ToString(char c);
static CString ToString(unsigned char c);
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(long 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);
+2 -2
View File
@@ -19,9 +19,9 @@ CString CTemplateLoopContext::GetValue(const CString& sName) {
}
if (sName.CaseCmp("__ID__") == 0) {
return CString::ToString(GetRowIndex() +1);
return CString(GetRowIndex() +1);
} else if (sName.CaseCmp("__COUNT__") == 0) {
return CString::ToString(GetRowCount());
return CString(GetRowCount());
} else if (sName.CaseCmp("__ODD__") == 0) {
return ((GetRowIndex() %2) ? "" : "1");
} else if (sName.CaseCmp("__EVEN__") == 0) {
+6 -6
View File
@@ -496,7 +496,7 @@ bool CUser::WriteConfig(CFile& File) {
PrintLine(File, "AwaySuffix", GetAwaySuffix());
PrintLine(File, "StatusPrefix", GetStatusPrefix());
PrintLine(File, "ChanModes", GetDefaultChanModes());
PrintLine(File, "Buffer", CString::ToString(GetBufferCount()));
PrintLine(File, "Buffer", CString(GetBufferCount()));
PrintLine(File, "KeepNick", CString((GetKeepNick()) ? "true" : "false"));
PrintLine(File, "KeepBuffer", CString((KeepBuffer()) ? "true" : "false"));
PrintLine(File, "MultiClients", CString((MultiClients()) ? "true" : "false"));
@@ -830,7 +830,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 [" + CString::ToString(uFileSize) + "]");
PutModule(pSock->GetModuleName(), "DCC -> [" + pSock->GetRemoteNick() + "][" + pSock->GetFileName() + "] - Attempting to resume from file position [" + CString(uFileSize) + "]");
return true;
} else {
return false;
@@ -856,11 +856,11 @@ bool CUser::SendFile(const CString& sRemoteNick, const CString& sFileName, const
unsigned short uPort = CZNC::Get().GetManager().ListenAllRand("DCC::LISTEN::" + sRemoteNick, false, SOMAXCONN, pSock, 120);
if (GetNick().CaseCmp(sRemoteNick) == 0) {
PutUser(":" + GetStatusPrefix() + "status!znc@znc.com PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " "
+ CString::ToString(uPort) + " " + CString::ToString(pFile->GetSize()) + "\001");
PutUser(":" + GetStatusPrefix() + "status!znc@znc.com PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalIP())) + " "
+ CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
} else {
PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " "
+ CString::ToString(uPort) + " " + CString::ToString(pFile->GetSize()) + "\001");
PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalIP())) + " "
+ CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
}
PutModule(sModuleName, "DCC -> [" + sRemoteNick + "][" + pFile->GetShortName() + "] - Attempting Send.");
+3 -3
View File
@@ -312,13 +312,13 @@ bool CUtils::GetNumInput(const CString& sPrompt, unsigned int& uRet, unsigned in
return false;
}
CString sDefault = (uDefault != (unsigned int) ~0) ? CString::ToString(uDefault) : "";
CString sDefault = (uDefault != (unsigned int) ~0) ? CString(uDefault) : "";
CString sNum, sHint;
if (uMax != (unsigned int) ~0) {
sHint = CString::ToString(uMin) + " to " + CString::ToString(uMax);
sHint = CString(uMin) + " to " + CString(uMax);
} else if (uMin > 0) {
sHint = CString::ToString(uMin) + " and up";
sHint = CString(uMin) + " and up";
}
while (true) {
+2 -2
View File
@@ -37,7 +37,7 @@ void die(int sig) {
signal(SIGPIPE, SIG_DFL);
#ifdef _DEBUG
CUtils::PrintMessage("Exiting on SIG [" + CString::ToString(sig) + "]");
CUtils::PrintMessage("Exiting on SIG [" + CString(sig) + "]");
if ((sig == SIGABRT) || (sig == SIGSEGV)) {
abort();
}
@@ -187,7 +187,7 @@ int main(int argc, char** argv, char** envp) {
}
if (iPid > 0) {
CUtils::PrintStatus(true, "[pid: " + CString::ToString(iPid) + "]");
CUtils::PrintStatus(true, "[pid: " + CString(iPid) + "]");
pZNC->WritePidFile(iPid);
CUtils::PrintMessage(CZNC::GetTag(false));
+8 -5
View File
@@ -18,6 +18,9 @@
*
*
* $Log$
* Revision 1.21 2006/02/25 09:43:35 prozacx
* Migrated away from CString::ToString() in favor of explicit constructors
*
* Revision 1.20 2006/02/11 11:55:55 imaginos
* fixed wrong type being used on 64bit
*
@@ -225,7 +228,7 @@ public:
CString sWhich = sCommand.Token(1);
if ( sWhich == "all" )
{
PutModNotice( "Deleted " + CString::ToString( m_vMessages.size() ) + " Messages.", "away" );
PutModNotice( "Deleted " + CString( m_vMessages.size() ) + " Messages.", "away" );
for( u_int a = 0; a < m_vMessages.size(); a++ )
m_vMessages.erase( m_vMessages.begin() + a-- );
@@ -293,7 +296,7 @@ public:
m_vMessages.erase( m_vMessages.begin() + a-- );
continue;
}
CString sTmp = " " + CString::ToString( a ) + ") [";
CString sTmp = " " + CString( a ) + ") [";
sTmp.append( szFormat, iCount );
sTmp += "] ";
sTmp += sMessage;
@@ -354,12 +357,12 @@ public:
if ( bUsePrivMessage )
{
PutModule( "Welcome Back!", "away" );
PutModule( "You have " + CString::ToString( m_vMessages.size() ) + " messages!", "away" );
PutModule( "You have " + CString( m_vMessages.size() ) + " messages!", "away" );
}
else
{
PutModNotice( "Welcome Back!", "away" );
PutModNotice( "You have " + CString::ToString( m_vMessages.size() ) + " messages!", "away" );
PutModNotice( "You have " + CString( m_vMessages.size() ) + " messages!", "away" );
}
}
m_sReason = "";
@@ -427,7 +430,7 @@ private:
void AddMessage( time_t iTime, const CNick & Nick, CString & sMessage )
{
AddMessage( CString::ToString( iTime ) + ":" + Nick.GetNickMask() + ":" + sMessage );
AddMessage( CString( iTime ) + ":" + Nick.GetNickMask() + ":" + sMessage );
}
void AddMessage( const CString & sText )
+4 -1
View File
@@ -16,6 +16,9 @@
* Author: imaginos <imaginos@imaginos.net>
*
* $Log$
* Revision 1.12 2006/02/25 09:43:35 prozacx
* Migrated away from CString::ToString() in favor of explicit constructors
*
* Revision 1.11 2006/02/12 21:00:59 prozacx
* Wrapped TSocketManager into CSockManager
*
@@ -151,7 +154,7 @@ public:
//PutModule( "------------------- New Email -------------------" );
Table.AddRow();
Table.SetCell( "From", vEmails[a].sFrom.Ellipsize( 32 ) );
Table.SetCell( "Size", CString::ToString( vEmails[a].iSize ) );
Table.SetCell( "Size", CString( vEmails[a].iSize ) );
Table.SetCell( "Subject", vEmails[a].sSubject.Ellipsize( 64 ) );
}
ssUidls.insert( vEmails[a].sUidl );
+7 -7
View File
@@ -36,13 +36,13 @@ public:
PString() : CString() { m_eType = STRING; }
PString( const char* c ) : CString(c) { m_eType = STRING; }
PString( const CString& s ) : CString(s) { m_eType = STRING; }
PString( int i ) : CString( PString::ToString( i ) ) { m_eType = INT; }
PString( u_int i ) : CString( PString::ToString( i ) ) { m_eType = UINT; }
PString( long i ) : CString( PString::ToString( i ) ) { m_eType = INT; }
PString( u_long i ) : CString( PString::ToString( i ) ) { m_eType = UINT; }
PString( long long i ) : CString( PString::ToString( (long long)i ) ) { m_eType = INT; }
PString( unsigned long long i ) : CString( PString::ToString( i ) ) { m_eType = UINT; }
PString( double i ) : CString( PString::ToString( i ) ) { m_eType = NUM; }
PString( int i ) : CString( i ) { m_eType = INT; }
PString( u_int i ) : CString( i ) { m_eType = UINT; }
PString( long i ) : CString( i ) { m_eType = INT; }
PString( u_long i ) : CString( i ) { m_eType = UINT; }
PString( long long i ) : CString( i ) { m_eType = INT; }
PString( unsigned long long i ) : CString( i ) { m_eType = UINT; }
PString( double i ) : CString( i ) { m_eType = NUM; }
PString( bool b ) : CString( ( b ? "1" : "0" ) ) { m_eType = BOOL; }
virtual ~PString() {}
+1 -1
View File
@@ -226,7 +226,7 @@ public:
Table.AddRow();
Table.SetCell("Channel", a->first);
Table.SetCell("Users", CString::ToString(a->second.size()));
Table.SetCell("Users", CString(a->second.size()));
}
unsigned int uTableIdx = 0;
+1 -1
View File
@@ -53,7 +53,7 @@ public:
}
virtual void OnChanPermission(const CNick& OpNick, const CNick& Nick, CChan& Channel, unsigned char uMode, bool bAdded, bool bNoChange) {
PutModule(((bNoChange) ? "[0] [" : "[1] [") + OpNick.GetNick() + "] set mode [" + Channel.GetName() + ((bAdded) ? "] +" : "] -") + CString::ToString(uMode) + " " + Nick.GetNick());
PutModule(((bNoChange) ? "[0] [" : "[1] [") + OpNick.GetNick() + "] set mode [" + Channel.GetName() + ((bAdded) ? "] +" : "] -") + CString(uMode) + " " + Nick.GetNick());
}
virtual void OnOp(const CNick& OpNick, const CNick& Nick, CChan& Channel, bool bNoChange) {
+4 -1
View File
@@ -24,6 +24,9 @@
* better solution then plain text.
*
* $Log$
* Revision 1.29 2006/02/25 09:43:35 prozacx
* Migrated away from CString::ToString() in favor of explicit constructors
*
* Revision 1.28 2006/02/11 11:55:55 imaginos
* fixed wrong type being used on 64bit
*
@@ -323,7 +326,7 @@ public:
CString SpoofChanMsg( const CString & sChannel, const CString & sMesg )
{
CString sReturn = ":*" + GetModName() + "!znc@znc.com PRIVMSG " + sChannel + " :" + CString::ToString( time( NULL ) ) + " " + sMesg;
CString sReturn = ":*" + GetModName() + "!znc@znc.com PRIVMSG " + sChannel + " :" + CString( time( NULL ) ) + " " + sMesg;
return( sReturn );
}
+8 -5
View File
@@ -21,6 +21,9 @@ using std::pair;
* Author: imaginos <imaginos@imaginos.net>
*
* $Log$
* Revision 1.23 2006/02/25 09:43:35 prozacx
* Migrated away from CString::ToString() in favor of explicit constructors
*
* Revision 1.22 2006/02/13 06:01:57 imaginos
* use u_short
*
@@ -340,7 +343,7 @@ public:
{
Table.SetCell( "Status", "Established" );
Table.SetCell( "Host", pSock->GetRemoteIP() );
Table.SetCell( "Port", CString::ToString( pSock->GetRemotePort() ) );
Table.SetCell( "Port", CString( pSock->GetRemotePort() ) );
SSL_SESSION *pSession = pSock->GetSSLSession();
if ( ( pSession ) && ( pSession->cipher ) && ( pSession->cipher->name ) )
Table.SetCell( "Cipher", pSession->cipher->name );
@@ -348,7 +351,7 @@ public:
} else
{
Table.SetCell( "Status", "Waiting" );
Table.SetCell( "Port", CString::ToString( pSock->GetLocalPort() ) );
Table.SetCell( "Port", CString( pSock->GetLocalPort() ) );
}
}
if ( Table.size() )
@@ -410,8 +413,8 @@ public:
Table.SetCell( "Type", "Outbound" );
else
Table.SetCell( "Type", "Inbound" );
Table.SetCell( "LocalIP:Port", pSock->GetLocalIP() + ":" + CString::ToString( pSock->GetLocalPort() ) );
Table.SetCell( "RemoteIP:Port", pSock->GetRemoteIP() + ":" + CString::ToString( pSock->GetRemotePort() ) );
Table.SetCell( "LocalIP:Port", pSock->GetLocalIP() + ":" + CString( pSock->GetLocalPort() ) );
Table.SetCell( "RemoteIP:Port", pSock->GetRemoteIP() + ":" + CString( pSock->GetRemotePort() ) );
SSL_SESSION *pSession = pSock->GetSSLSession();
if ( ( pSession ) && ( pSession->cipher ) && ( pSession->cipher->name ) )
Table.SetCell( "Cipher", pSession->cipher->name );
@@ -421,7 +424,7 @@ public:
} else
{
Table.SetCell( "Type", "Listener" );
Table.SetCell( "LocalIP:Port", pSock->GetLocalIP() + ":" + CString::ToString( pSock->GetLocalPort() ) );
Table.SetCell( "LocalIP:Port", pSock->GetLocalIP() + ":" + CString( pSock->GetLocalPort() ) );
Table.SetCell( "RemoteIP:Port", "0.0.0.0:0" );
}
}
+7 -7
View File
@@ -275,7 +275,7 @@ public:
m_Buffer.SetLineCount(atoi(sCount.c_str()));
}
PutModule("Buffer count is set to [" + CString::ToString(m_Buffer.GetLineCount()) + "]");
PutModule("Buffer count is set to [" + CString(m_Buffer.GetLineCount()) + "]");
} else if (strcasecmp(sCmdName.c_str(), "DEL") == 0) {
Remove(atoi(sCommand.Token(1).c_str()));
} else {
@@ -318,7 +318,7 @@ private:
for (unsigned int a = 0; a < uIdx; a++, it++);
(*it).SetDisabled(bDisabled);
PutModule("Id " + CString::ToString(uIdx +1) + ((bDisabled) ? " Disabled" : " Enabled"));
PutModule("Id " + CString(uIdx +1) + ((bDisabled) ? " Disabled" : " Enabled"));
}
void List() {
@@ -336,7 +336,7 @@ private:
CWatchEntry& WatchEntry = *it;
Table.AddRow();
Table.SetCell("Id", CString::ToString(uIdx));
Table.SetCell("Id", CString(uIdx));
Table.SetCell("HostMask", WatchEntry.GetHostMask());
Table.SetCell("Target", WatchEntry.GetTarget());
Table.SetCell("Pattern", WatchEntry.GetPattern());
@@ -373,11 +373,11 @@ private:
PutModule("/msg " + GetModNick() + " ADD " + WatchEntry.GetHostMask() + " " + WatchEntry.GetTarget() + " " + WatchEntry.GetPattern());
if (WatchEntry.GetSourcesStr().size()) {
PutModule("/msg " + GetModNick() + " SETSOURCES " + CString::ToString(uIdx) + " " + WatchEntry.GetSourcesStr());
PutModule("/msg " + GetModNick() + " SETSOURCES " + CString(uIdx) + " " + WatchEntry.GetSourcesStr());
}
if (WatchEntry.IsDisabled()) {
PutModule("/msg " + GetModNick() + " DISABLE " + CString::ToString(uIdx));
PutModule("/msg " + GetModNick() + " DISABLE " + CString(uIdx));
}
}
@@ -395,7 +395,7 @@ private:
for (unsigned int a = 0; a < uIdx; a++, it++);
(*it).SetSources(sSources);
PutModule("Sources set for Id " + CString::ToString(uIdx +1) + ".");
PutModule("Sources set for Id " + CString(uIdx +1) + ".");
}
void Remove(unsigned int uIdx) {
@@ -409,7 +409,7 @@ private:
for (unsigned int a = 0; a < uIdx; a++, it++);
m_lsWatchers.erase(it);
PutModule("Id " + CString::ToString(uIdx +1) + " Removed.");
PutModule("Id " + CString(uIdx +1) + " Removed.");
}
void Help() {
+6 -6
View File
@@ -242,7 +242,7 @@ void CWebAdminSock::ListUsersPage(CString& sPageRet) {
CUser& User = *it->second;
l["Username"] = User.GetUserName();
l["Clients"] = CString::ToString(User.GetClients().size());
l["Clients"] = CString(User.GetClients().size());
l["IRCNick"] = User.GetIRCNick().GetNick();
if (pServer) {
@@ -333,7 +333,7 @@ bool CWebAdminSock::OnPageRequest(const CString& sURI, CString& sPageRet) {
unsigned int uCounter = m_pModule->GetSwitchCounter(GetRemoteIP());
if (!uCurCnt) {
Redirect("/switchuser?cnt=" + CString::ToString(uCounter));
Redirect("/switchuser?cnt=" + CString(uCounter));
return false;
}
@@ -462,7 +462,7 @@ bool CWebAdminSock::SettingsPage(CString& sPageRet) {
CListener* pListener = vpListeners[c];
CTemplate& l = m_Template.AddRow("ListenLoop");
l["Port"] = CString::ToString(pListener->GetPort());
l["Port"] = CString(pListener->GetPort());
l["BindHost"] = pListener->GetBindHost();
#ifdef HAVE_LIBSSL
@@ -609,7 +609,7 @@ bool CWebAdminSock::ChanPage(CString& sPageRet, CChan* pChan) {
m_Template["Edit"] = "true";
m_Template["Title"] = "Edit Channel" + CString(" [" + pChan->GetName() + "]");
m_Template["ChanName"] = pChan->GetName();
m_Template["BufferCount"] = CString::ToString(pChan->GetBufferCount());
m_Template["BufferCount"] = CString(pChan->GetBufferCount());
m_Template["DefModes"] = pChan->GetDefaultModes();
if (pChan->InConfig()) {
@@ -728,7 +728,7 @@ bool CWebAdminSock::UserPage(CString& sPageRet, CUser* pUser) {
m_Template["RealName"] = pUser->GetRealName();
m_Template["QuitMsg"] = pUser->GetQuitMsg();
m_Template["DefaultChanModes"] = pUser->GetDefaultChanModes();
m_Template["BufferCount"] = CString::ToString(pUser->GetBufferCount());
m_Template["BufferCount"] = CString(pUser->GetBufferCount());
const set<CString>& ssAllowedHosts = pUser->GetAllowedHosts();
for (set<CString>::const_iterator it = ssAllowedHosts.begin(); it != ssAllowedHosts.end(); it++) {
@@ -778,7 +778,7 @@ bool CWebAdminSock::UserPage(CString& sPageRet, CUser* pUser) {
l["Perms"] = pChan->GetPermStr();
l["CurModes"] = pChan->GetModeString();
l["DefModes"] = pChan->GetDefaultModes();
l["BufferCount"] = CString::ToString(pChan->GetBufferCount());
l["BufferCount"] = CString(pChan->GetBufferCount());
l["Options"] = pChan->GetOptions();
if (pChan->InConfig()) {
+10 -10
View File
@@ -150,7 +150,7 @@ int CZNC::Loop() {
}
DEBUG_ONLY(cout << "User [" << pUser->GetUserName() << "] is connecting to [" << pServer->GetName() << ":" << pServer->GetPort() << "] ..." << endl);
pUser->PutStatus("Attempting to connect to [" + pServer->GetName() + ":" + CString::ToString(pServer->GetPort()) + "] ...");
pUser->PutStatus("Attempting to connect to [" + pServer->GetName() + ":" + CString(pServer->GetPort()) + "] ...");
pIRCSock = new CIRCSock(pUser);
pIRCSock->SetPass(pServer->GetPass());
@@ -194,7 +194,7 @@ bool CZNC::WritePidFile(int iPid) {
CUtils::PrintAction("Writing pid file [" + m_sPidFile + "]");
if (File.Open(O_WRONLY | O_TRUNC | O_CREAT)) {
File.Write(CString::ToString(iPid) + "\n");
File.Write(CString(iPid) + "\n");
File.Close();
CUtils::PrintStatus(true);
return true;
@@ -321,7 +321,7 @@ CString CZNC::ExpandConfigPath(const CString& sConfigFile) {
bool CZNC::WriteConfig() {
CFile File(m_sConfigFile);
if (!File.Copy(GetConfBackupPath() + "/" + File.GetShortName() + "-" + CString::ToString(time(NULL)))) {
if (!File.Copy(GetConfBackupPath() + "/" + File.GetShortName() + "-" + CString(time(NULL)))) {
return false;
}
@@ -339,7 +339,7 @@ bool CZNC::WriteConfig() {
CString s6 = (pListener->IsIPV6()) ? "6" : " ";
File.Write("Listen" + s6 + " = " + sHostPortion + CString((pListener->IsSSL()) ? "+" : "") + CString::ToString(pListener->GetPort()) + "\r\n");
File.Write("Listen" + s6 + " = " + sHostPortion + CString((pListener->IsSSL()) ? "+" : "") + CString(pListener->GetPort()) + "\r\n");
}
if (!m_sISpoofFile.empty()) {
@@ -440,7 +440,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
sListenHost += " ";
}
vsLines.push_back("Listen" + s6 + " = " + sListenHost + sSSL + CString::ToString(uPort));
vsLines.push_back("Listen" + s6 + " = " + sListenHost + sSSL + CString(uPort));
// !Listen
#ifdef _MODULES
@@ -526,7 +526,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 = " + CString::ToString(uBufferCount)); }
CUtils::GetNumInput("Number of lines to buffer per channel", uBufferCount, 0, ~0, 50); if (uBufferCount) { vsLines.push_back("\tBuffer = " + CString(uBufferCount)); }
if (CUtils::GetBoolInput("Would you like your buffer to be sticky?", true)) {
vsLines.push_back("\tKeepBuffer = true");
} else {
@@ -598,7 +598,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) ? " +" : " ") + CString::ToString(uPort) + " " + sPass);
vsLines.push_back("\tServer = " + sHost + ((bSSL) ? " +" : " ") + CString(uPort) + " " + sPass);
} while (CUtils::GetBoolInput("Would you like to add another server?", false));
vsLines.push_back("");
@@ -678,7 +678,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> " + CString::ToString(uPort) + " " + sUser + ":<pass>", true);
CUtils::PrintMessage("/server <znc_server_ip> " + CString(uPort) + " " + sUser + ":<pass>", true);
CUtils::PrintMessage("");
m_LockFile.UnLock();
@@ -998,7 +998,7 @@ bool CZNC::ParseConfig(const CString& sConfig) {
}
unsigned short uPort = strtol(sPort.c_str(), NULL, 10);
CUtils::PrintAction("Binding to port [" + CString((bSSL) ? "+" : "") + CString::ToString(uPort) + "]" + sHostComment + sIPV6Comment);
CUtils::PrintAction("Binding to port [" + CString((bSSL) ? "+" : "") + CString(uPort) + "]" + sHostComment + sIPV6Comment);
#ifndef HAVE_IPV6
if (bIPV6) {
@@ -1024,7 +1024,7 @@ bool CZNC::ParseConfig(const CString& sConfig) {
return false;
}
CUtils::PrintAction("Binding to port [+" + CString::ToString(uPort) + "]" + sHostComment + sIPV6Comment);
CUtils::PrintAction("Binding to port [+" + CString(uPort) + "]" + sHostComment + sIPV6Comment);
}
#endif
if (!uPort) {