diff --git a/Chan.cpp b/Chan.cpp index 1a917aba..a7faec5e 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -267,14 +267,14 @@ bool CChan::AddNick(const CString& sNick) { IncOpCount(); pNick->SetOp(true); - if (strcasecmp(pNick->GetNick().c_str(), m_pUser->GetCurNick().c_str()) == 0) { + if (pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0) { SetOpped(true); } } else if ((bIsVoice) && (!pNick->IsVoice())) { IncVoiceCount(); pNick->SetVoice(true); - if (strcasecmp(pNick->GetNick().c_str(), m_pUser->GetCurNick().c_str()) == 0) { + if (pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0) { SetVoiced(true); } } @@ -302,7 +302,7 @@ bool CChan::RemNick(const CString& sNick) { m_msNicks.erase(it); CNick* pNick = m_msNicks.begin()->second; - if ((m_msNicks.size() == 1) && (!pNick->IsOp()) && (strcasecmp(pNick->GetNick().c_str(), m_pUser->GetCurNick().c_str()) == 0)) { + if ((m_msNicks.size() == 1) && (!pNick->IsOp()) && (pNick->GetNick().CaseCmp(m_pUser->GetCurNick()) == 0)) { if (AutoCycle()) { Cycle(); } @@ -345,7 +345,7 @@ void CChan::OnOp(const CString& sOpNick, const CString& sNick, bool bOpped) { } #endif - if (strcasecmp(sNick.c_str(), m_pUser->GetCurNick().c_str()) == 0) { + if (sNick.CaseCmp(m_pUser->GetCurNick()) == 0) { SetOpped(bOpped); } @@ -377,7 +377,7 @@ void CChan::OnVoice(const CString& sOpNick, const CString& sNick, bool bVoiced) } #endif - if (strcasecmp(sNick.c_str(), m_pUser->GetCurNick().c_str()) == 0) { + if (sNick.CaseCmp(m_pUser->GetCurNick()) == 0) { SetVoiced(bVoiced); } diff --git a/IRCSock.cpp b/IRCSock.cpp index 6c7b1ccb..696fd9b9 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -80,7 +80,7 @@ void CIRCSock::ReadLine(const CString& sData) { if (m_pUserSock) { CString sClientNick = m_pUserSock->GetNick(); - if (strcasecmp(sClientNick.c_str(), sNick.c_str()) != 0) { + if (sClientNick.CaseCmp(sNick) != 0) { // If they connected with a nick that doesn't match the one we got on irc, then we need to update them PutUser(":" + sClientNick + "!" + m_Nick.GetIdent() + "@" + m_Nick.GetHost() + " NICK :" + sNick); } @@ -143,17 +143,17 @@ void CIRCSock::ReadLine(const CString& sData) { if (sNick == "*") { CString sAltNick = m_pUser->GetAltNick(); - if (strcasecmp(sBadNick.c_str(), sConfNick.c_str()) == 0) { - if ((!sAltNick.empty()) && (strcasecmp(sConfNick.c_str(), sAltNick.c_str()) != 0)) { + if (sBadNick.CaseCmp(sConfNick) == 0) { + if ((!sAltNick.empty()) && (sConfNick.CaseCmp(sAltNick) != 0)) { PutServ("NICK " + sAltNick); } else { PutServ("NICK " + sConfNick.Left(8) + "-"); } - } else if (strcasecmp(sBadNick.c_str(), sAltNick.c_str()) == 0) { + } else if (sBadNick.CaseCmp(sAltNick) == 0) { PutServ("NICK " + sConfNick.Left(8) + "-"); - } else if (strcasecmp(sBadNick.c_str(), CString(sConfNick.Left(8) + "-").c_str()) == 0) { + } else if (sBadNick.CaseCmp(CString(sConfNick.Left(8) + "-")) == 0) { PutServ("NICK " + sConfNick.Left(8) + "|"); - } else if (strcasecmp(sBadNick.c_str(), CString(sConfNick.Left(8) + "|").c_str()) == 0) { + } else if (sBadNick.CaseCmp(CString(sConfNick.Left(8) + "|")) == 0) { PutServ("NICK " + sConfNick.Left(8) + "^"); } else { char cLetter = 0; @@ -177,7 +177,7 @@ void CIRCSock::ReadLine(const CString& sData) { } else { // :irc.server.net 433 mynick badnick :Nickname is already in use. if ((m_bKeepNick) && (m_pUser->KeepNick())) { - if (strcasecmp(sBadNick.c_str(), sConfNick.c_str()) == 0) { + if (sBadNick.CaseCmp(sConfNick) == 0) { if ((!m_pUserSock) || (!m_pUserSock->DecKeepNickCounter())) { return; } @@ -241,7 +241,7 @@ void CIRCSock::ReadLine(const CString& sData) { sServer.LeftChomp(); - if (strcasecmp(sNick.c_str(), GetNick().c_str()) == 0) { + if (sNick.CaseCmp(GetNick()) == 0) { m_Nick.SetIdent(sIdent); m_Nick.SetHost(sHost); } @@ -335,7 +335,7 @@ void CIRCSock::ReadLine(const CString& sData) { CString sCmd = sLine.Token(1); CString sRest = sLine.Token(2, true); - if (strcasecmp(sCmd.c_str(), "NICK") == 0) { + if (sCmd.CaseCmp("NICK") == 0) { CString sNewNick = sRest; bool bIsVisible = false; @@ -358,13 +358,13 @@ void CIRCSock::ReadLine(const CString& sData) { } } - if (strcasecmp(sNick.c_str(), GetNick().c_str()) == 0) { + if (sNick.CaseCmp(GetNick()) == 0) { SetNick(sNewNick); - if (strcasecmp(sNick.c_str(), m_pUser->GetNick().c_str()) == 0) { + if (sNick.CaseCmp(m_pUser->GetNick()) == 0) { // If the user changes his nick away from the config nick, we shut off keepnick for this session m_bKeepNick = false; } - } else if (strcasecmp(sNick.c_str(), m_pUser->GetNick().c_str()) == 0) { + } else if (sNick.CaseCmp(m_pUser->GetNick()) == 0) { KeepNick(); } #ifdef _MODULES @@ -374,7 +374,7 @@ void CIRCSock::ReadLine(const CString& sData) { if (!bIsVisible) { return; } - } else if (strcasecmp(sCmd.c_str(), "QUIT") == 0) { + } else if (sCmd.CaseCmp("QUIT") == 0) { CString sMessage = sRest; bool bIsVisible = false; @@ -400,7 +400,7 @@ void CIRCSock::ReadLine(const CString& sData) { } } - if (strcasecmp(Nick.GetNick().c_str(), m_pUser->GetNick().c_str()) == 0) { + if (Nick.GetNick().CaseCmp(m_pUser->GetNick()) == 0) { KeepNick(); } @@ -411,13 +411,13 @@ void CIRCSock::ReadLine(const CString& sData) { if (!bIsVisible) { return; } - } else if (strcasecmp(sCmd.c_str(), "JOIN") == 0) { + } else if (sCmd.CaseCmp("JOIN") == 0) { CString sChan = sRest.Token(0); if (sChan.Left(1) == ":") { sChan.LeftChomp(); } - if (strcasecmp(sNick.c_str(), GetNick().c_str()) == 0) { + if (sNick.CaseCmp(GetNick()) == 0) { m_pUser->AddChan(sChan); } @@ -431,7 +431,7 @@ void CIRCSock::ReadLine(const CString& sData) { return; } } - } else if (strcasecmp(sCmd.c_str(), "PART") == 0) { + } else if (sCmd.CaseCmp("PART") == 0) { CString sChan = sRest.Token(0); if (sChan.Left(1) == ":") { sChan.LeftChomp(); @@ -445,14 +445,14 @@ void CIRCSock::ReadLine(const CString& sData) { #endif } - if (strcasecmp(sNick.c_str(), GetNick().c_str()) == 0) { + if (sNick.CaseCmp(GetNick()) == 0) { m_pUser->DelChan(sChan); } if ((pChan) && (pChan->IsDetached())) { return; } - } else if (strcasecmp(sCmd.c_str(), "MODE") == 0) { + } else if (sCmd.CaseCmp("MODE") == 0) { CString sChan = sRest.Token(0); CString sModes = sRest.Token(1, true); @@ -464,7 +464,7 @@ void CIRCSock::ReadLine(const CString& sData) { return; } } - } else if (strcasecmp(sCmd.c_str(), "KICK") == 0) { + } else if (sCmd.CaseCmp("KICK") == 0) { // :opnick!ident@host.com KICK #chan nick :msg CString sChan = sRest.Token(0); CString sKickedNick = sRest.Token(1); @@ -480,7 +480,7 @@ void CIRCSock::ReadLine(const CString& sData) { #endif } - if (strcasecmp(GetNick().c_str(), sKickedNick.c_str()) == 0) { + if (GetNick().CaseCmp(sKickedNick) == 0) { CString sKey; if (pChan) { @@ -494,7 +494,7 @@ void CIRCSock::ReadLine(const CString& sData) { if ((pChan) && (pChan->IsDetached())) { return; } - } else if (strcasecmp(sCmd.c_str(), "NOTICE") == 0) { + } else if (sCmd.CaseCmp("NOTICE") == 0) { // :nick!ident@host.com NOTICE #chan :Message CNick Nick(sNickMask); @@ -507,7 +507,7 @@ void CIRCSock::ReadLine(const CString& sData) { sMsg.LeftChomp(); sMsg.RightChomp(); - if (strcasecmp(sTarget.c_str(), GetNick().c_str()) == 0) { + if (sTarget.CaseCmp(GetNick()) == 0) { if (OnCTCPReply(sNickMask, sMsg)) { return; } @@ -516,7 +516,7 @@ void CIRCSock::ReadLine(const CString& sData) { PutUser(":" + sNickMask + " NOTICE " + sTarget + " :\001" + sMsg + "\001"); return; } else { - if (strcasecmp(sTarget.c_str(), GetNick().c_str()) == 0) { + if (sTarget.CaseCmp(GetNick()) == 0) { if (OnPrivNotice(sNickMask, sMsg)) { return; } @@ -529,7 +529,7 @@ void CIRCSock::ReadLine(const CString& sData) { PutUser(":" + sNickMask + " NOTICE " + sTarget + " :" + sMsg); return; - } else if (strcasecmp(sCmd.c_str(), "TOPIC") == 0) { + } else if (sCmd.CaseCmp("TOPIC") == 0) { // :nick!ident@host.com TOPIC #chan :This is a topic CChan* pChan = m_pUser->FindChan(sLine.Token(2)); @@ -541,7 +541,7 @@ void CIRCSock::ReadLine(const CString& sData) { pChan->SetTopicDate((unsigned long) time(NULL)); // @todo use local time pChan->SetTopic(sTopic); } - } else if (strcasecmp(sCmd.c_str(), "PRIVMSG") == 0) { + } else if (sCmd.CaseCmp("PRIVMSG") == 0) { // :nick!ident@host.com PRIVMSG #chan :Message CNick Nick(sNickMask); @@ -556,7 +556,7 @@ void CIRCSock::ReadLine(const CString& sData) { sMsg.LeftChomp(); sMsg.RightChomp(); - if (strcasecmp(sTarget.c_str(), GetNick().c_str()) == 0) { + if (sTarget.CaseCmp(GetNick()) == 0) { if (OnPrivCTCP(sNickMask, sMsg)) { return; } @@ -569,7 +569,7 @@ void CIRCSock::ReadLine(const CString& sData) { PutUser(":" + sNickMask + " PRIVMSG " + sTarget + " :\001" + sMsg + "\001"); return; } else { - if (strcasecmp(sTarget.c_str(), GetNick().c_str()) == 0) { + if (sTarget.CaseCmp(GetNick()) == 0) { if (OnPrivMsg(sNickMask, sMsg)) { return; } @@ -592,7 +592,7 @@ void CIRCSock::ReadLine(const CString& sData) { void CIRCSock::KeepNick() { const CString& sConfNick = m_pUser->GetNick(); - if ((m_bAuthed) && (m_bKeepNick) && (m_pUser->KeepNick()) && (strcasecmp(GetNick().c_str(), sConfNick.c_str()) != 0)) { + if ((m_bAuthed) && (m_bKeepNick) && (m_pUser->KeepNick()) && (GetNick().CaseCmp(sConfNick) != 0)) { PutServ("NICK " + sConfNick); } } @@ -614,7 +614,7 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) { } #endif - if (strcasecmp(sMessage.c_str(), "VERSION") == 0) { + if (sMessage.CaseCmp("VERSION") == 0) { if (!IsUserAttached()) { CString sVersionReply = m_pUser->GetVersionReply(); PutServ("NOTICE " + CNick(sNickMask).GetNick() + " :\001VERSION " + sVersionReply + "\001"); @@ -627,7 +627,7 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) { unsigned short uPort = strtoul(sMessage.Token(4).c_str(), NULL, 10); unsigned long uFileSize = strtoul(sMessage.Token(5).c_str(), NULL, 10); - if (strcasecmp(sType.c_str(), "CHAT") == 0) { + if (sType.CaseCmp("CHAT") == 0) { if (m_pUserSock) { CNick FromNick(sNickMask); unsigned short uBNCPort = CDCCBounce::DCCRequest(FromNick.GetNick(), uLongIP, uPort, "", true, m_pUser, GetLocalIP(), CUtils::GetIP(uLongIP)); @@ -636,7 +636,7 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) { PutUser(":" + sNickMask + " PRIVMSG " + GetNick() + " :\001DCC CHAT chat " + CString::ToString(CUtils::GetLongIP(GetLocalIP())) + " " + CString::ToString(uBNCPort) + "\001"); } } - } else if (strcasecmp(sType.c_str(), "SEND") == 0) { + } else if (sType.CaseCmp("SEND") == 0) { // DCC SEND readme.txt 403120438 5550 1104 CNick FromNick(sNickMask); @@ -644,14 +644,14 @@ bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) { if (uBNCPort) { 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) { + } else if (sType.CaseCmp("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 + " " + CString::ToString(pSock->GetUserPort()) + " " + sMessage.Token(4) + "\001"); } - } else if (strcasecmp(sType.c_str(), "ACCEPT") == 0) { + } else if (sType.CaseCmp("ACCEPT") == 0) { // Need to lookup the connection by port, filter the port, and forward to the user TSocketManager& Manager = m_pZNC->GetManager(); diff --git a/Modules.cpp b/Modules.cpp index a8d0375b..b4baaad2 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -57,7 +57,7 @@ bool CModule::RemTimer(const CString& sLabel) { for (unsigned int a = 0; a < m_vTimers.size(); a++) { CTimer* pTimer = m_vTimers[a]; - if (strcasecmp(pTimer->GetName().c_str(), sLabel.c_str()) == 0) { + if (pTimer->GetName().CaseCmp(sLabel) == 0) { m_vTimers.erase(m_vTimers.begin() +a); m_pManager->DelCronByAddr(pTimer); return true; @@ -81,7 +81,7 @@ bool CModule::UnlinkTimer(CTimer* pTimer) { CTimer* CModule::FindTimer(const CString& sLabel) { for (unsigned int a = 0; a < m_vTimers.size(); a++) { CTimer* pTimer = m_vTimers[a]; - if (strcasecmp(pTimer->GetName().c_str(), sLabel.c_str()) == 0) { + if (pTimer->GetName().CaseCmp(sLabel) == 0) { return pTimer; } } @@ -470,7 +470,7 @@ void CModules::OnModCTCP(const CString& sMessage) { CModule* CModules::FindModule(const CString& sModule) { for (unsigned int a = 0; a < size(); a++) { - if (strcasecmp(sModule.c_str(), (*this)[a]->GetModName().c_str()) == 0) { + if (sModule.CaseCmp((*this)[a]->GetModName()) == 0) { return (*this)[a]; } } diff --git a/Nick.cpp b/Nick.cpp index 5d429ff8..c04bcfda 100644 --- a/Nick.cpp +++ b/Nick.cpp @@ -46,7 +46,7 @@ unsigned int CNick::GetCommonChans(vector& vRetChans, CUser* pUser) cons const map& msNicks = pChan->GetNicks(); for (map::const_iterator it = msNicks.begin(); it != msNicks.end(); it++) { - if (strcasecmp(it->first.c_str(), m_sNick.c_str()) == 0) { + if (it->first.CaseCmp(m_sNick) == 0) { vRetChans.push_back(pChan); continue; } diff --git a/User.cpp b/User.cpp index 22c5839b..08e040a4 100644 --- a/User.cpp +++ b/User.cpp @@ -113,7 +113,7 @@ bool CUser::AddChan(CChan* pChan) { } for (unsigned int a = 0; a < m_vChans.size(); a++) { - if (strcasecmp(m_vChans[a]->GetName().c_str(), pChan->GetName().c_str()) == 0) { + if (m_vChans[a]->GetName().CaseCmp(pChan->GetName()) == 0) { delete pChan; return false; } @@ -129,7 +129,7 @@ bool CUser::AddChan(const CString& sName) { } for (unsigned int a = 0; a < m_vChans.size(); a++) { - if (strcasecmp(sName.c_str(), m_vChans[a]->GetName().c_str()) == 0) { + if (sName.CaseCmp(m_vChans[a]->GetName()) == 0) { return false; } } @@ -141,7 +141,7 @@ bool CUser::AddChan(const CString& sName) { bool CUser::DelChan(const CString& sName) { for (vector::iterator a = m_vChans.begin(); a != m_vChans.end(); a++) { - if (strcasecmp(sName.c_str(), (*a)->GetName().c_str()) == 0) { + if (sName.CaseCmp((*a)->GetName()) == 0) { m_vChans.erase(a); return true; } @@ -153,7 +153,7 @@ bool CUser::DelChan(const CString& sName) { CChan* CUser::FindChan(const CString& sName) { for (unsigned int a = 0; a < m_vChans.size(); a++) { CChan* pChan = m_vChans[a]; - if (strcasecmp(sName.c_str(), pChan->GetName().c_str()) == 0) { + if (sName.CaseCmp(pChan->GetName()) == 0) { return pChan; } } @@ -164,7 +164,7 @@ CChan* CUser::FindChan(const CString& sName) { CServer* CUser::FindServer(const CString& sName) { for (unsigned int a = 0; a < m_vServers.size(); a++) { CServer* pServer = m_vServers[a]; - if (strcasecmp(sName.c_str(), pServer->GetName().c_str()) == 0) { + if (sName.CaseCmp(pServer->GetName()) == 0) { return pServer; } } @@ -178,7 +178,7 @@ bool CUser::DelServer(const CString& sName) { } for (vector::iterator it = m_vServers.begin(); it != m_vServers.end(); it++) { - if (strcasecmp((*it)->GetName().c_str(), sName.c_str()) == 0) { + if ((*it)->GetName().CaseCmp(sName) == 0) { m_vServers.erase(it); return true; } @@ -247,7 +247,7 @@ bool CUser::CheckPass(const CString& sPass) { return (sPass == m_sPass); } - return (strcasecmp(m_sPass.c_str(), CMD5(sPass)) == 0); + return (m_sPass.CaseCmp((char*) CMD5(sPass)) == 0); } TSocketManager* CUser::GetManager() { @@ -265,7 +265,7 @@ CUserSock* CUser::GetUserSock() { for (unsigned int a = 0; a < Manager.size(); a++) { Csock* pSock = Manager[a]; - if (strcasecmp(pSock->GetSockName().c_str(), sSockName.c_str()) == 0) { + if (pSock->GetSockName().CaseCmp(sSockName) == 0) { if (!pSock->isClosed()) { return (CUserSock*) pSock; } @@ -384,7 +384,7 @@ 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) { + if (GetNick().CaseCmp(sRemoteNick) == 0) { 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 { diff --git a/UserSock.cpp b/UserSock.cpp index 2fa9b360..15144cd1 100644 --- a/UserSock.cpp +++ b/UserSock.cpp @@ -26,10 +26,10 @@ void CUserSock::ReadLine(const CString& sData) { CString sCommand = sLine.Token(0); - if (strcasecmp(sCommand.c_str(), "ZNC") == 0) { + if (sCommand.CaseCmp("ZNC") == 0) { PutStatus("Hello. How may I help you?"); return; - } else if (strcasecmp(sCommand.c_str(), "DETACH") == 0) { + } else if (sCommand.CaseCmp("DETACH") == 0) { if (m_pUser) { CString sChan = sLine.Token(1); @@ -48,9 +48,9 @@ void CUserSock::ReadLine(const CString& sData) { PutStatusNotice("Detached from [" + sChan + "]"); return; } - } else if (strcasecmp(sCommand.c_str(), "PONG") == 0) { + } else if (sCommand.CaseCmp("PONG") == 0) { return; // Block pong replies, we already responded to the pings - } else if (strcasecmp(sCommand.c_str(), "PASS") == 0) { + } else if (sCommand.CaseCmp("PASS") == 0) { if (!m_bAuthed) { m_bGotPass = true; m_sPass = sLine.Token(1); @@ -66,7 +66,7 @@ void CUserSock::ReadLine(const CString& sData) { } return; // Don't forward this msg. ZNC has already registered us. - } else if (strcasecmp(sCommand.c_str(), "NICK") == 0) { + } else if (sCommand.CaseCmp("NICK") == 0) { CString sNick = sLine.Token(1); if (sNick.Left(1) == ":") { sNick.LeftChomp(); @@ -82,10 +82,10 @@ void CUserSock::ReadLine(const CString& sData) { return; // Don't forward this msg. ZNC will handle nick changes until auth is complete } - if ((m_pUser) && (strcasecmp(sNick.c_str(), m_pUser->GetNick().c_str()) == 0)) { + if ((m_pUser) && (sNick.CaseCmp(m_pUser->GetNick()) == 0)) { m_uKeepNickCounter++; } - } else if (strcasecmp(sCommand.c_str(), "USER") == 0) { + } else if (sCommand.CaseCmp("USER") == 0) { if ((!m_bAuthed) && (m_sUser.empty())) { m_sUser = sLine.Token(1); } @@ -97,7 +97,7 @@ void CUserSock::ReadLine(const CString& sData) { } return; // Don't forward this msg. ZNC has already registered us. - } else if (strcasecmp(sCommand.c_str(), "JOIN") == 0) { + } else if (sCommand.CaseCmp("JOIN") == 0) { CString sChan = sLine.Token(1); if (sChan.Left(1) == ":") { sChan.LeftChomp(); @@ -111,14 +111,14 @@ void CUserSock::ReadLine(const CString& sData) { return; } } - } else if (strcasecmp(sCommand.c_str(), "QUIT") == 0) { + } else if (sCommand.CaseCmp("QUIT") == 0) { if (m_pIRCSock) { m_pIRCSock->UserDisconnected(); } Close(); // Treat a client quit as a detach return; // Don't forward this msg. We don't want the client getting us disconnected. - } else if (strcasecmp(sCommand.c_str(), "NOTICE") == 0) { + } else if (sCommand.CaseCmp("NOTICE") == 0) { CString sTarget = sLine.Token(1); CString sMsg = sLine.Token(2, true); @@ -126,7 +126,7 @@ void CUserSock::ReadLine(const CString& sData) { sMsg.LeftChomp(); } - if ((!m_pUser) || (strcasecmp(sTarget.c_str(), CString(m_pUser->GetStatusPrefix() + "status").c_str())) == 0) { + if ((!m_pUser) || (sTarget.CaseCmp(CString(m_pUser->GetStatusPrefix() + "status"))) == 0) { return; } @@ -177,7 +177,7 @@ void CUserSock::ReadLine(const CString& sData) { PutIRC("NOTICE " + sTarget + " :" + sMsg); return; - } else if (strcasecmp(sCommand.c_str(), "PRIVMSG") == 0) { + } else if (sCommand.CaseCmp("PRIVMSG") == 0) { CString sTarget = sLine.Token(1); CString sMsg = sLine.Token(2, true); @@ -202,7 +202,7 @@ void CUserSock::ReadLine(const CString& sData) { uLongIP = CUtils::GetLongIP(GetRemoteIP()); } - if (strcasecmp(sType.c_str(), "CHAT") == 0) { + if (sType.CaseCmp("CHAT") == 0) { if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) { } else { unsigned short uBNCPort = CDCCBounce::DCCRequest(sTarget, uLongIP, uPort, "", true, m_pUser, (m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP(), ""); @@ -210,11 +210,11 @@ void CUserSock::ReadLine(const CString& sData) { PutIRC("PRIVMSG " + sTarget + " :\001DCC CHAT chat " + CString::ToString(CUtils::GetLongIP(sIP)) + " " + CString::ToString(uBNCPort) + "\001"); } } - } else if (strcasecmp(sType.c_str(), "SEND") == 0) { + } else if (sType.CaseCmp("SEND") == 0) { // DCC SEND readme.txt 403120438 5550 1104 if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) { - if ((!m_pUser) || (strcasecmp(sTarget.c_str(), CString(m_pUser->GetStatusPrefix() + "status").c_str()) == 0)) { + if ((!m_pUser) || (sTarget.CaseCmp(CString(m_pUser->GetStatusPrefix() + "status")) == 0)) { if (!m_pUser) { return; } @@ -246,7 +246,7 @@ void CUserSock::ReadLine(const CString& sData) { 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) { + } else if (sType.CaseCmp("RESUME") == 0) { // PRIVMSG user :DCC RESUME "znc.o" 58810 151552 unsigned short uResumePort = atoi(sCTCP.Token(3).c_str()); unsigned long uResumeSize = strtoul(sCTCP.Token(4).c_str(), NULL, 10); @@ -264,7 +264,7 @@ void CUserSock::ReadLine(const CString& sData) { PutIRC("PRIVMSG " + sTarget + " :\001DCC " + sType + " " + sFile + " " + CString::ToString(pSock->GetUserPort()) + " " + sCTCP.Token(4) + "\001"); } } - } else if (strcasecmp(sType.c_str(), "ACCEPT") == 0) { + } else if (sType.CaseCmp("ACCEPT") == 0) { if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) { } else { // Need to lookup the connection by port, filter the port, and forward to the user @@ -310,7 +310,7 @@ void CUserSock::ReadLine(const CString& sData) { return; } - if ((m_pUser) && (strcasecmp(sTarget.c_str(), CString(m_pUser->GetStatusPrefix() + "status").c_str()) == 0)) { + if ((m_pUser) && (sTarget.CaseCmp(CString(m_pUser->GetStatusPrefix() + "status")) == 0)) { #ifdef _MODULES if ((m_pUser) && (m_pUser->GetModules().OnStatusCommand(sMsg))) { return; @@ -359,7 +359,7 @@ void CUserSock::SetNick(const CString& s) { m_sNick = s; if (m_pUser) { - if (strcasecmp(m_sNick.c_str(), m_pUser->GetNick().c_str()) == 0) { + if (m_sNick.CaseCmp(m_pUser->GetNick()) == 0) { m_uKeepNickCounter = 0; } } @@ -385,9 +385,9 @@ void CUserSock::UserCommand(const CString& sLine) { CString sCommand = sLine.Token(0); - if (strcasecmp(sCommand.c_str(), "HELP") == 0) { + if (sCommand.CaseCmp("HELP") == 0) { HelpUser(); - } else if (strcasecmp(sCommand.c_str(), "LISTNICKS") == 0) { + } else if (sCommand.CaseCmp("LISTNICKS") == 0) { CString sChan = sLine.Token(1); if (sChan.empty()) { @@ -436,7 +436,7 @@ void CUserSock::UserCommand(const CString& sLine) { while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); } - } else if (strcasecmp(sCommand.c_str(), "DETACH") == 0) { + } else if (sCommand.CaseCmp("DETACH") == 0) { if (m_pUser) { CString sChan = sLine.Token(1); @@ -454,9 +454,9 @@ void CUserSock::UserCommand(const CString& sLine) { PutStatus("Detaching you from [" + sChan + "]"); pChan->DetachUser(); } - } else if (strcasecmp(sCommand.c_str(), "VERSION") == 0) { + } else if (sCommand.CaseCmp("VERSION") == 0) { PutStatus(CZNC::GetTag()); - } else if (strcasecmp(sCommand.c_str(), "SHUTDOWN") == 0) { + } else if (sCommand.CaseCmp("SHUTDOWN") == 0) { CString sQuitMsg = sLine.Token(1, true); if (!sQuitMsg.empty()) { @@ -464,7 +464,7 @@ void CUserSock::UserCommand(const CString& sLine) { } throw CException(CException::EX_Shutdown); - } else if (strcasecmp(sCommand.c_str(), "JUMP") == 0) { + } else if (sCommand.CaseCmp("JUMP") == 0) { if (m_pUser) { if (m_pIRCSock) { m_pIRCSock->Close(); @@ -472,7 +472,7 @@ void CUserSock::UserCommand(const CString& sLine) { return; } } - } else if (strcasecmp(sCommand.c_str(), "LISTCHANS") == 0) { + } else if (sCommand.CaseCmp("LISTCHANS") == 0) { if (m_pUser) { const vector& vChans = m_pUser->GetChans(); @@ -514,7 +514,7 @@ void CUserSock::UserCommand(const CString& sLine) { } } } - } else if (strcasecmp(sCommand.c_str(), "ADDSERVER") == 0) { + } else if (sCommand.CaseCmp("ADDSERVER") == 0) { CString sServer = sLine.Token(1); if (sServer.empty()) { @@ -532,7 +532,7 @@ void CUserSock::UserCommand(const CString& sLine) { } else { PutStatus("Unable to add that server"); } - } else if (strcasecmp(sCommand.c_str(), "REMSERVER") == 0 || strcasecmp(sCommand.c_str(), "DELSERVER") == 0) { + } else if (sCommand.CaseCmp("REMSERVER") == 0 || sCommand.CaseCmp("DELSERVER") == 0) { CString sServer = sLine.Token(1); if (sServer.empty()) { @@ -552,7 +552,7 @@ void CUserSock::UserCommand(const CString& sLine) { } else { PutStatus("No such server"); } - } else if (strcasecmp(sCommand.c_str(), "LISTSERVERS") == 0) { + } else if (sCommand.CaseCmp("LISTSERVERS") == 0) { if (m_pUser) { const vector& vServers = m_pUser->GetServers(); CTable Table; @@ -579,7 +579,7 @@ void CUserSock::UserCommand(const CString& sLine) { } } } - } else if (strcasecmp(sCommand.c_str(), "TOPICS") == 0) { + } else if (sCommand.CaseCmp("TOPICS") == 0) { if (m_pUser) { const vector& vChans = m_pUser->GetChans(); CTable Table; @@ -604,7 +604,7 @@ void CUserSock::UserCommand(const CString& sLine) { } } } - } else if (strcasecmp(sCommand.c_str(), "SEND") == 0) { + } else if (sCommand.CaseCmp("SEND") == 0) { CString sToNick = sLine.Token(1); CString sFile = sLine.Token(2); @@ -616,7 +616,7 @@ void CUserSock::UserCommand(const CString& sLine) { if (m_pUser) { m_pUser->SendFile(sToNick, sFile); } - } else if (strcasecmp(sCommand.c_str(), "GET") == 0) { + } else if (sCommand.CaseCmp("GET") == 0) { CString sFile = sLine.Token(1); if (sFile.empty()) { @@ -627,7 +627,7 @@ void CUserSock::UserCommand(const CString& sLine) { if (m_pUser) { m_pUser->SendFile(GetNick(), sFile); } - } else if (strcasecmp(sCommand.c_str(), "LISTDCCS") == 0) { + } else if (sCommand.CaseCmp("LISTDCCS") == 0) { TSocketManager& Manager = m_pZNC->GetManager(); CTable Table; @@ -726,7 +726,7 @@ void CUserSock::UserCommand(const CString& sLine) { } else { PutStatus("You have no active DCCs."); } - } else if ((strcasecmp(sCommand.c_str(), "LISTMODS") == 0) || (strcasecmp(sCommand.c_str(), "LISTMODULES") == 0)) { + } else if ((sCommand.CaseCmp("LISTMODS") == 0) || (sCommand.CaseCmp("LISTMODULES") == 0)) { #ifdef _MODULES if (m_pUser) { CModules& Modules = m_pUser->GetModules(); @@ -755,7 +755,7 @@ void CUserSock::UserCommand(const CString& sLine) { PutStatus("Modules are not enabled."); #endif return; - } else if ((strcasecmp(sCommand.c_str(), "LOADMOD") == 0) || (strcasecmp(sCommand.c_str(), "LOADMODULE") == 0)) { + } else if ((sCommand.CaseCmp("LOADMOD") == 0) || (sCommand.CaseCmp("LOADMODULE") == 0)) { CString sMod = sLine.Token(1); CString sArgs = sLine.Token(2, true); @@ -776,7 +776,7 @@ void CUserSock::UserCommand(const CString& sLine) { PutStatus("Unable to load [" + sMod + "] Modules are not enabled."); #endif return; - } else if ((strcasecmp(sCommand.c_str(), "UNLOADMOD") == 0) || (strcasecmp(sCommand.c_str(), "UNLOADMODULE") == 0)) { + } else if ((sCommand.CaseCmp("UNLOADMOD") == 0) || (sCommand.CaseCmp("UNLOADMODULE") == 0)) { CString sMod = sLine.Token(1); if (m_pUser->DenyLoadMod()) { @@ -796,7 +796,7 @@ void CUserSock::UserCommand(const CString& sLine) { PutStatus("Unable to unload [" + sMod + "] Modules are not enabled."); #endif return; - } else if ((strcasecmp(sCommand.c_str(), "RELOADMOD") == 0) || (strcasecmp(sCommand.c_str(), "RELOADMODULE") == 0)) { + } else if ((sCommand.CaseCmp("RELOADMOD") == 0) || (sCommand.CaseCmp("RELOADMODULE") == 0)) { CString sMod = sLine.Token(1); CString sArgs = sLine.Token(2, true); @@ -817,7 +817,7 @@ void CUserSock::UserCommand(const CString& sLine) { PutStatus("Unable to unload [" + sMod + "] Modules are not enabled."); #endif return; - } else if (strcasecmp(sCommand.c_str(), "SETBUFFER") == 0) { + } else if (sCommand.CaseCmp("SETBUFFER") == 0) { CString sChan = sLine.Token(1); if (sChan.empty()) { diff --git a/Utils.cpp b/Utils.cpp index 903489dc..59111af1 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -268,9 +268,9 @@ bool CUtils::GetBoolInput(const CString& sPrompt, bool *pbDefault) { GetInput(sPrompt, sRet, sDefault, "yes/no"); - if (strcasecmp(sRet.c_str(), "yes") == 0) { + if (sRet.CaseCmp("yes") == 0) { return true; - } else if (strcasecmp(sRet.c_str(), "no") == 0) { + } else if (sRet.CaseCmp("no") == 0) { return false; } @@ -381,7 +381,7 @@ CTable::~CTable() { bool CTable::AddColumn(const CString& sName) { for (unsigned int a = 0; a < m_vsHeaders.size(); a++) { - if (strcasecmp(m_vsHeaders[a].c_str(), sName.c_str()) == 0) { + if (m_vsHeaders[a].CaseCmp(sName) == 0) { return false; } } diff --git a/znc.cpp b/znc.cpp index 546a4836..6f590f44 100644 --- a/znc.cpp +++ b/znc.cpp @@ -322,7 +322,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) { const CModInfo& Info = *it; CString sName = Info.GetName(); - if (strcasecmp(sName.Right(3).c_str(), ".so") == 0) { + if (sName.Right(3).CaseCmp(".so") == 0) { sName.RightChomp(3); } @@ -488,12 +488,12 @@ bool CZNC::ParseConfig(const CString& sConfig) { if (pUser) { if (pChan) { - if (strcasecmp(sTag.c_str(), "Chan") == 0) { + if (sTag.CaseCmp("Chan") == 0) { pUser->AddChan(pChan); pChan = NULL; continue; } - } else if (strcasecmp(sTag.c_str(), "User") == 0) { + } else if (sTag.CaseCmp("User") == 0) { CString sErr; if (!pUser->IsValid(sErr)) { @@ -507,7 +507,7 @@ bool CZNC::ParseConfig(const CString& sConfig) { continue; } } - } else if (strcasecmp(sTag.c_str(), "User") == 0) { + } else if (sTag.CaseCmp("User") == 0) { if (pUser) { CUtils::PrintError("You may not nest tags inside of other tags."); return false; @@ -534,7 +534,7 @@ bool CZNC::ParseConfig(const CString& sConfig) { } continue; - } else if (strcasecmp(sTag.c_str(), "Chan") == 0) { + } else if (sTag.CaseCmp("Chan") == 0) { if (!pUser) { CUtils::PrintError(" tags must be nested inside of a tag."); return false; @@ -560,45 +560,45 @@ bool CZNC::ParseConfig(const CString& sConfig) { if ((!sName.empty()) && (!sValue.empty())) { if (pUser) { if (pChan) { - if (strcasecmp(sName.c_str(), "Buffer") == 0) { + if (sName.CaseCmp("Buffer") == 0) { pChan->SetBufferCount(strtoul(sValue.c_str(), NULL, 10)); continue; - } else if (strcasecmp(sName.c_str(), "KeepBuffer") == 0) { - pChan->SetKeepBuffer((strcasecmp(sValue.c_str(), "true") == 0)); + } else if (sName.CaseCmp("KeepBuffer") == 0) { + pChan->SetKeepBuffer((sValue.CaseCmp("true") == 0)); continue; - } else if (strcasecmp(sName.c_str(), "Detached") == 0) { - pChan->SetDetached((strcasecmp(sValue.c_str(), "true") == 0)); + } else if (sName.CaseCmp("Detached") == 0) { + pChan->SetDetached((sValue.CaseCmp("true") == 0)); continue; - } else if (strcasecmp(sName.c_str(), "AutoCycle") == 0) { - pChan->SetAutoCycle((strcasecmp(sValue.c_str(), "true") == 0)); + } else if (sName.CaseCmp("AutoCycle") == 0) { + pChan->SetAutoCycle((sValue.CaseCmp("true") == 0)); continue; - } else if (strcasecmp(sName.c_str(), "Key") == 0) { + } else if (sName.CaseCmp("Key") == 0) { pChan->SetKey(sValue); continue; - } else if (strcasecmp(sName.c_str(), "Modes") == 0) { + } else if (sName.CaseCmp("Modes") == 0) { pChan->SetDefaultModes(sValue); continue; } } else { - if (strcasecmp(sName.c_str(), "Buffer") == 0) { + if (sName.CaseCmp("Buffer") == 0) { pUser->SetBufferCount(strtoul(sValue.c_str(), NULL, 10)); continue; - } else if (strcasecmp(sName.c_str(), "KeepBuffer") == 0) { - pUser->SetKeepBuffer((strcasecmp(sValue.c_str(), "true") == 0)); + } else if (sName.CaseCmp("KeepBuffer") == 0) { + pUser->SetKeepBuffer((sValue.CaseCmp("true") == 0)); continue; - } else if (strcasecmp(sName.c_str(), "Nick") == 0) { + } else if (sName.CaseCmp("Nick") == 0) { pUser->SetNick(sValue); continue; - } else if (strcasecmp(sName.c_str(), "VersionReply") == 0) { + } else if (sName.CaseCmp("VersionReply") == 0) { pUser->SetVersionReply(sValue); continue; - } else if (strcasecmp(sName.c_str(), "QuitMsg") == 0) { + } else if (sName.CaseCmp("QuitMsg") == 0) { pUser->SetQuitMsg(sValue); continue; - } else if (strcasecmp(sName.c_str(), "AltNick") == 0) { + } else if (sName.CaseCmp("AltNick") == 0) { pUser->SetAltNick(sValue); continue; - } else if (strcasecmp(sName.c_str(), "Pass") == 0) { + } else if (sName.CaseCmp("Pass") == 0) { if (sValue.Right(1) == "-") { sValue.RightChomp(); sValue.Trim(); @@ -608,47 +608,47 @@ bool CZNC::ParseConfig(const CString& sConfig) { } continue; - } else if (strcasecmp(sName.c_str(), "AutoCycle") == 0) { - bAutoCycle = (strcasecmp(sValue.c_str(), "true") == 0); + } else if (sName.CaseCmp("AutoCycle") == 0) { + bAutoCycle = (sValue.CaseCmp("true") == 0); continue; - } else if (strcasecmp(sName.c_str(), "Ident") == 0) { + } else if (sName.CaseCmp("Ident") == 0) { pUser->SetIdent(sValue); continue; - } else if (strcasecmp(sName.c_str(), "DenyLoadMod") == 0) { - pUser->SetDenyLoadMod((strcasecmp(sValue.c_str(), "TRUE") == 0)); + } else if (sName.CaseCmp("DenyLoadMod") == 0) { + pUser->SetDenyLoadMod((sValue.CaseCmp("TRUE") == 0)); continue; - } else if (strcasecmp(sName.c_str(), "StatusPrefix") == 0) { + } else if (sName.CaseCmp("StatusPrefix") == 0) { if (!pUser->SetStatusPrefix(sValue)) { CUtils::PrintError("Invalid StatusPrefix [" + sValue + "] Must be 1-5 chars, no spaces."); return false; } continue; - } else if (strcasecmp(sName.c_str(), "DCCLookupMethod") == 0) { - pUser->SetUseClientIP((strcasecmp(sValue.c_str(), "Client") == 0)); + } else if (sName.CaseCmp("DCCLookupMethod") == 0) { + pUser->SetUseClientIP((sValue.CaseCmp("Client") == 0)); continue; - } else if (strcasecmp(sName.c_str(), "RealName") == 0) { + } else if (sName.CaseCmp("RealName") == 0) { pUser->SetRealName(sValue); continue; - } else if (strcasecmp(sName.c_str(), "KeepNick") == 0) { - pUser->SetKeepNick((strcasecmp(sValue.c_str(), "true") == 0)); + } else if (sName.CaseCmp("KeepNick") == 0) { + pUser->SetKeepNick((sValue.CaseCmp("true") == 0)); continue; - } else if (strcasecmp(sName.c_str(), "ChanModes") == 0) { + } else if (sName.CaseCmp("ChanModes") == 0) { pUser->SetDefaultChanModes(sValue); continue; - } else if (strcasecmp(sName.c_str(), "VHost") == 0) { + } else if (sName.CaseCmp("VHost") == 0) { pUser->SetVHost(sValue); continue; - } else if (strcasecmp(sName.c_str(), "Allow") == 0) { + } else if (sName.CaseCmp("Allow") == 0) { pUser->AddAllowedHost(sValue); continue; - } else if (strcasecmp(sName.c_str(), "Server") == 0) { + } else if (sName.CaseCmp("Server") == 0) { CUtils::PrintAction("Adding Server [" + sValue + "]"); CUtils::PrintStatus(pUser->AddServer(sValue)); continue; - } else if (strcasecmp(sName.c_str(), "Chan") == 0) { + } else if (sName.CaseCmp("Chan") == 0) { pUser->AddChan(sValue); continue; - } else if (strcasecmp(sName.c_str(), "LoadModule") == 0) { + } else if (sName.CaseCmp("LoadModule") == 0) { CString sModName = sValue.Token(0); CUtils::PrintAction("Loading Module [" + sModName + "]"); #ifdef _MODULES @@ -669,7 +669,7 @@ bool CZNC::ParseConfig(const CString& sConfig) { } } } else { - if (strcasecmp(sName.c_str(), "ListenPort") == 0) { + if (sName.CaseCmp("ListenPort") == 0) { m_bSSL = false; CString sPort = sValue; if (sPort.Left(1) == "+") { @@ -730,10 +730,10 @@ bool CZNC::ParseConfig(const CString& sConfig) { CUtils::PrintStatus(true); continue; - } else if (strcasecmp(sName.c_str(), "ISpoofFile") == 0) { + } else if (sName.CaseCmp("ISpoofFile") == 0) { m_sISpoofFile = sValue; continue; - } else if (strcasecmp(sName.c_str(), "PidFile") == 0) { + } else if (sName.CaseCmp("PidFile") == 0) { if (!sValue.empty() && sValue[0] != '/') { m_sPidFile = GetZNCPath() + "/" + sValue; } else { @@ -741,7 +741,7 @@ bool CZNC::ParseConfig(const CString& sConfig) { } continue; - } else if (strcasecmp(sName.c_str(), "StatusPrefix") == 0) { + } else if (sName.CaseCmp("StatusPrefix") == 0) { sStatusPrefix = sValue; continue; }