From beb5b49b3f78d5cf193d3b9f4046000fcc01265b Mon Sep 17 00:00:00 2001 From: prozacx Date: Thu, 5 May 2005 18:11:04 +0000 Subject: [PATCH] Changed all references to std::string over to CString git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@240 726aef4b-f618-498e-8847-2d620e286838 --- Buffer.cpp | 10 +-- Buffer.h | 17 +++-- Chan.cpp | 54 ++++++++-------- Chan.h | 68 ++++++++++---------- DCCBounce.cpp | 32 +++++----- DCCBounce.h | 34 +++++----- DCCSock.cpp | 2 +- DCCSock.h | 36 +++++------ FileUtils.cpp | 64 +++++++++---------- FileUtils.h | 91 +++++++++++++------------- IRCSock.cpp | 120 +++++++++++++++++------------------ IRCSock.h | 36 +++++------ Modules.cpp | 140 ++++++++++++++++++++-------------------- Modules.h | 148 +++++++++++++++++++++---------------------- Nick.cpp | 32 +++++----- Nick.h | 29 ++++----- Server.cpp | 8 +-- Server.h | 14 ++-- User.cpp | 118 +++++++++++++++++----------------- User.h | 128 ++++++++++++++++++------------------- UserSock.cpp | 142 ++++++++++++++++++++--------------------- UserSock.h | 34 +++++----- Utils.cpp | 8 +-- Utils.h | 3 +- main.cpp | 10 +-- main.h | 5 +- modules/away.cpp | 67 ++++++++++---------- modules/email.cpp | 51 ++++++++------- modules/raw.cpp | 6 +- modules/sample.cpp | 44 ++++++------- modules/savebuff.cpp | 67 ++++++++++---------- modules/schat.cpp | 84 ++++++++++++------------ modules/shell.cpp | 46 +++++++------- modules/watch.cpp | 88 ++++++++++++------------- znc.cpp | 84 ++++++++++++------------ znc.h | 52 +++++++-------- 36 files changed, 990 insertions(+), 982 deletions(-) diff --git a/Buffer.cpp b/Buffer.cpp index 0d140179..3759ff84 100644 --- a/Buffer.cpp +++ b/Buffer.cpp @@ -1,13 +1,13 @@ #include "Buffer.h" -CBufLine::CBufLine(const string& sPre, const string& sPost) { +CBufLine::CBufLine(const CString& sPre, const CString& sPost) { m_sPre = sPre; m_sPost = sPost; } CBufLine::~CBufLine() {} -void CBufLine::GetLine(const string& sTarget, string& sRet) { +void CBufLine::GetLine(const CString& sTarget, CString& sRet) { sRet = m_sPre + sTarget + m_sPost; } @@ -17,7 +17,7 @@ CBuffer::CBuffer(unsigned int uLineCount) { CBuffer::~CBuffer() {} -int CBuffer::AddLine(const string& sPre, const string& sPost) { +int CBuffer::AddLine(const CString& sPre, const CString& sPost) { if (!m_uLineCount) { return 0; } @@ -30,7 +30,7 @@ int CBuffer::AddLine(const string& sPre, const string& sPost) { return size(); } -bool CBuffer::GetLine(const string& sTarget, string& sRet, unsigned int uIdx) { +bool CBuffer::GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx) { if (uIdx >= size()) { return false; } @@ -39,7 +39,7 @@ bool CBuffer::GetLine(const string& sTarget, string& sRet, unsigned int uIdx) { return true; } -bool CBuffer::GetNextLine(const string& sTarget, string& sRet) { +bool CBuffer::GetNextLine(const CString& sTarget, CString& sRet) { sRet = ""; if (!size()) { diff --git a/Buffer.h b/Buffer.h index b6d730a8..45fa8300 100644 --- a/Buffer.h +++ b/Buffer.h @@ -1,21 +1,20 @@ #ifndef _BUFFER_H #define _BUFFER_H -#include +#include "String.h" #include using std::vector; -using std::string; class CBufLine { public: - CBufLine(const string& sPre, const string& sPost); + CBufLine(const CString& sPre, const CString& sPost); virtual ~CBufLine(); - void GetLine(const string& sTarget, string& sRet); + void GetLine(const CString& sTarget, CString& sRet); private: protected: - string m_sPre; - string m_sPost; + CString m_sPre; + CString m_sPost; }; class CBuffer : private vector { @@ -23,9 +22,9 @@ public: CBuffer(unsigned int uLineCount = 100); virtual ~CBuffer(); - int AddLine(const string& sPre, const string& sPost); - bool GetNextLine(const string& sTarget, string& sRet); - bool GetLine(const string& sTarget, string& sRet, unsigned int uIdx); + int AddLine(const CString& sPre, const CString& sPost); + bool GetNextLine(const CString& sTarget, CString& sRet); + bool GetLine(const CString& sTarget, CString& sRet, unsigned int uIdx); bool IsEmpty() { return empty(); } void Clear() { clear(); } diff --git a/Chan.cpp b/Chan.cpp index 6bba2b8c..ceae479a 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -3,7 +3,7 @@ #include "User.h" #include "Utils.h" -CChan::CChan(const string& sName, CUser* pUser) { +CChan::CChan(const CString& sName, CUser* pUser) { m_sName = CUtils::Token(sName, 0); m_sKey = CUtils::Token(sName, 1); @@ -56,10 +56,10 @@ void CChan::JoinUser() { m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 333 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " " + GetTopicOwner() + " " + CUtils::ToString(GetTopicDate())); } - string sPre = ":" + m_pUser->GetIRCServer() + " 353 " + m_pUser->GetIRCNick().GetNick() + " = " + GetName() + " :"; - string sLine = sPre; + CString sPre = ":" + m_pUser->GetIRCServer() + " 353 " + m_pUser->GetIRCNick().GetNick() + " = " + GetName() + " :"; + CString sLine = sPre; - for (map::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) { + for (map::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) { if (a->second->IsOp()) { sLine += "@"; } else if (a->second->IsVoice()) { @@ -84,7 +84,7 @@ void CChan::JoinUser() { void CChan::SendBuffer() { if (m_pUser->IsUserAttached()) { - const vector& vsBuffer = GetBuffer(); + const vector& vsBuffer = GetBuffer(); if (vsBuffer.size()) { m_pUser->PutUser(":***!znc@znc.com PRIVMSG " + GetName() + " :Buffer Playback..."); @@ -107,8 +107,8 @@ void CChan::DetachUser() { m_bDetached = true; } -string CChan::GetModeString() const { - string sRet; +CString CChan::GetModeCString() const { + CString sRet; if (m_uModes & Secret) { sRet += "s"; } if (m_uModes & Private) { sRet += "p"; } @@ -122,7 +122,7 @@ string CChan::GetModeString() const { return (sRet.empty()) ? sRet : ("+" + sRet); } -void CChan::SetModes(const string& sModes) { +void CChan::SetModes(const CString& sModes) { m_uModes = 0; m_uLimit = 0; m_sKey = ""; @@ -151,7 +151,7 @@ bool CChan::Who() { return true; } -void CChan::OnWho(const string& sNick, const string& sIdent, const string& sHost) { +void CChan::OnWho(const CString& sNick, const CString& sIdent, const CString& sHost) { CNick* pNick = FindNick(sNick); if (pNick) { @@ -160,9 +160,9 @@ void CChan::OnWho(const string& sNick, const string& sIdent, const string& sHost } } -void CChan::ModeChange(const string& sModes, const string& sOpNick) { - string sModeArg = CUtils::Token(sModes, 0); - string sArgs = CUtils::Token(sModes, 1, true); +void CChan::ModeChange(const CString& sModes, const CString& sOpNick) { + CString sModeArg = CUtils::Token(sModes, 0); + CString sArgs = CUtils::Token(sModes, 1, true); bool bAdd = true; #ifdef _MODULES @@ -193,27 +193,27 @@ void CChan::ModeChange(const string& sModes, const string& sOpNick) { } } -string CChan::GetModeArg(string& sArgs) const { - string sRet = sArgs.substr(0, sArgs.find(' ')); +CString CChan::GetModeArg(CString& sArgs) const { + CString sRet = sArgs.substr(0, sArgs.find(' ')); sArgs = (sRet.size() < sArgs.size()) ? sArgs.substr(sRet.size() +1) : ""; return sRet; } void CChan::ClearNicks() { - for (map::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) { + for (map::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) { delete a->second; } m_msNicks.clear(); } -int CChan::AddNicks(const string& sNicks) { +int CChan::AddNicks(const CString& sNicks) { if (IsOn()) { return 0; } int iRet = 0; - string sCurNick; + CString sCurNick; for (unsigned int a = 0; a < sNicks.size(); a++) { switch (sNicks[a]) { @@ -240,7 +240,7 @@ int CChan::AddNicks(const string& sNicks) { return iRet; } -bool CChan::AddNick(const string& sNick) { +bool CChan::AddNick(const CString& sNick) { const char* p = sNick.c_str(); bool bIsOp = false; bool bIsVoice = false; @@ -284,8 +284,8 @@ bool CChan::AddNick(const string& sNick) { return true; } -bool CChan::RemNick(const string& sNick) { - map::iterator it = m_msNicks.find(sNick); +bool CChan::RemNick(const CString& sNick) { + map::iterator it = m_msNicks.find(sNick); if (it == m_msNicks.end()) { return false; } @@ -311,8 +311,8 @@ bool CChan::RemNick(const string& sNick) { return true; } -bool CChan::ChangeNick(const string& sOldNick, const string& sNewNick) { - map::iterator it = m_msNicks.find(sOldNick); +bool CChan::ChangeNick(const CString& sOldNick, const CString& sNewNick) { + map::iterator it = m_msNicks.find(sOldNick); if (it == m_msNicks.end()) { return false; @@ -328,7 +328,7 @@ bool CChan::ChangeNick(const string& sOldNick, const string& sNewNick) { return true; } -void CChan::OnOp(const string& sOpNick, const string& sNick, bool bOpped) { +void CChan::OnOp(const CString& sOpNick, const CString& sNick, bool bOpped) { CNick* pNick = FindNick(sNick); if (pNick) { @@ -359,7 +359,7 @@ void CChan::OnOp(const string& sOpNick, const string& sNick, bool bOpped) { } } -void CChan::OnVoice(const string& sOpNick, const string& sNick, bool bVoiced) { +void CChan::OnVoice(const CString& sOpNick, const CString& sNick, bool bVoiced) { CNick* pNick = FindNick(sNick); if (pNick) { @@ -391,12 +391,12 @@ void CChan::OnVoice(const string& sOpNick, const string& sNick, bool bVoiced) { } } -CNick* CChan::FindNick(const string& sNick) const { - map::const_iterator it = m_msNicks.find(sNick); +CNick* CChan::FindNick(const CString& sNick) const { + map::const_iterator it = m_msNicks.find(sNick); return (it != m_msNicks.end()) ? it->second : NULL; } -int CChan::AddBuffer(const string& sLine) { +int CChan::AddBuffer(const CString& sLine) { // Todo: revisit the buffering if (!m_uBufferCount) { return 0; diff --git a/Chan.h b/Chan.h index ed45de22..48749d02 100644 --- a/Chan.h +++ b/Chan.h @@ -23,7 +23,7 @@ public: Key = 1 << 6 } EMode; - CChan(const string& sName, CUser* pUser); + CChan(const CString& sName, CUser* pUser); virtual ~CChan(); void Reset(); @@ -37,28 +37,28 @@ public: bool DecClientRequests(); bool Who(); - void OnWho(const string& sNick, const string& sIdent, const string& sHost); + void OnWho(const CString& sNick, const CString& sIdent, const CString& sHost); // Modes - void SetModes(const string& s); - void ModeChange(const string& sModes, const string& sNick = ""); - void OnOp(const string& sOpNick, const string& sNick, bool bOpped); - void OnVoice(const string& sOpNick, const string& sNick, bool bVoiced); - string GetModeString() const; - string GetModeArg(string& sArgs) const; + void SetModes(const CString& s); + void ModeChange(const CString& sModes, const CString& sNick = ""); + void OnOp(const CString& sOpNick, const CString& sNick, bool bOpped); + void OnVoice(const CString& sOpNick, const CString& sNick, bool bVoiced); + CString GetModeCString() const; + CString GetModeArg(CString& sArgs) const; // !Modes // Nicks void ClearNicks(); - CNick* FindNick(const string& sNick) const; - int AddNicks(const string& sNicks); - bool AddNick(const string& sNick); - bool RemNick(const string& sNick); - bool ChangeNick(const string& sOldNick, const string& sNewNick); + CNick* FindNick(const CString& sNick) const; + int AddNicks(const CString& sNicks); + bool AddNick(const CString& sNick); + bool RemNick(const CString& sNick); + bool ChangeNick(const CString& sOldNick, const CString& sNewNick); // !Nicks // Buffer - int AddBuffer(const string& sLine); + int AddBuffer(const CString& sLine); void ClearBuffer(); // !Buffer @@ -66,11 +66,11 @@ public: void SetIsOn(bool b) { m_bIsOn = b; if (!b) { Reset(); } else { Joined(); } } void SetOpped(bool b) { m_bIsOp = b; } void SetVoiced(bool b) { m_bIsVoice = b; } - void SetKey(const string& s) { m_sKey = s; } - void SetTopic(const string& s) { m_sTopic = s; } - void SetTopicOwner(const string& s) { m_sTopicOwner = s; } + void SetKey(const CString& s) { m_sKey = s; } + void SetTopic(const CString& s) { m_sTopic = s; } + void SetTopicOwner(const CString& s) { m_sTopicOwner = s; } void SetTopicDate(unsigned long u) { m_ulTopicDate = u; } - void SetDefaultModes(const string& s) { m_sDefaultModes = s; } + void SetDefaultModes(const CString& s) { m_sDefaultModes = s; } void IncOpCount() { m_uOpCount++; } void DecOpCount() { m_uOpCount -= (m_uOpCount > 0); } void IncVoiceCount() { m_uVoiceCount++; } @@ -86,17 +86,17 @@ public: const bool IsOn() const { return m_bIsOn; } const bool IsOp() const { return m_bIsOp; } const bool IsVoice() const { return m_bIsVoice; } - const string& GetName() const { return m_sName; } + const CString& GetName() const { return m_sName; } unsigned int GetModes() const { return m_uModes; } - const string& GetKey() const { return m_sKey; } + const CString& GetKey() const { return m_sKey; } unsigned int GetLimit() const { return m_uLimit; } - const string& GetTopic() const { return m_sTopic; } - const string& GetTopicOwner() const { return m_sTopicOwner; } + const CString& GetTopic() const { return m_sTopic; } + const CString& GetTopicOwner() const { return m_sTopicOwner; } unsigned int GetTopicDate() const { return m_ulTopicDate; } - const string& GetDefaultModes() const { return m_sDefaultModes; } - const vector& GetBans() const { return m_vsBans; } - const vector& GetBuffer() const { return m_vsBuffer; } - const map& GetNicks() const { return m_msNicks; } + const CString& GetDefaultModes() const { return m_sDefaultModes; } + const vector& GetBans() const { return m_vsBans; } + const vector& GetBuffer() const { return m_vsBuffer; } + const map& GetNicks() const { return m_msNicks; } unsigned int GetNickCount() const { return m_msNicks.size(); } unsigned int GetOpCount() const { return m_uOpCount; } unsigned int GetVoiceCount() const { return m_uVoiceCount; } @@ -115,22 +115,22 @@ protected: bool m_bWhoDone; bool m_bKeepBuffer; bool m_bAutoCycle; - string m_sName; - string m_sKey; - string m_sTopic; - string m_sTopicOwner; + CString m_sName; + CString m_sKey; + CString m_sTopic; + CString m_sTopicOwner; unsigned long m_ulTopicDate; CUser* m_pUser; unsigned int m_uLimit; unsigned int m_uModes; - string m_sDefaultModes; - vector m_vsBans; - map m_msNicks; // Todo: make this caseless (irc style) + CString m_sDefaultModes; + vector m_vsBans; + map m_msNicks; // Todo: make this caseless (irc style) unsigned int m_uBufferCount; unsigned int m_uOpCount; unsigned int m_uVoiceCount; unsigned int m_uClientRequests; // Used to tell how many times a client tried to join this chan - vector m_vsBuffer; + vector m_vsBuffer; }; #endif // !_CHAN_H diff --git a/DCCBounce.cpp b/DCCBounce.cpp index bd7b9f72..914b5b21 100644 --- a/DCCBounce.cpp +++ b/DCCBounce.cpp @@ -1,7 +1,7 @@ #include "DCCBounce.h" -void CDCCBounce::ReadLine(const string& sData) { - string sLine = sData; +void CDCCBounce::ReadLine(const CString& sData) { + CString sLine = sData; while ((CUtils::Right(sLine, 1) == "\r") || (CUtils::Right(sLine, 1) == "\n")) { CUtils::RightChomp(sLine); @@ -20,10 +20,10 @@ void CDCCBounce::ReadData(const char* data, int len) { void CDCCBounce::Timeout() { DEBUG_ONLY(cout << GetSockName() << " == Timeout()" << endl); - string sType = (m_bIsChat) ? "Chat" : "Xfer"; + CString sType = (m_bIsChat) ? "Chat" : "Xfer"; if (IsRemote()) { - string sHost = Csock::GetHostName(); + CString sHost = Csock::GetHostName(); if (!sHost.empty()) { sHost = " to [" + sHost + ":" + CUtils::ToString(Csock::GetPort()) + "]"; } else { @@ -39,8 +39,8 @@ void CDCCBounce::Timeout() { void CDCCBounce::ConnectionRefused() { DEBUG_ONLY(cout << GetSockName() << " == ConnectionRefused()" << endl); - string sType = (m_bIsChat) ? "Chat" : "Xfer"; - string sHost = Csock::GetHostName(); + CString sType = (m_bIsChat) ? "Chat" : "Xfer"; + CString sHost = Csock::GetHostName(); if (!sHost.empty()) { sHost = " to [" + sHost + ":" + CUtils::ToString(Csock::GetPort()) + "]"; } else { @@ -52,17 +52,17 @@ void CDCCBounce::ConnectionRefused() { void CDCCBounce::SockError(int iErrno) { DEBUG_ONLY(cout << GetSockName() << " == SockError(" << iErrno << ")" << endl); - string sType = (m_bIsChat) ? "Chat" : "Xfer"; + CString sType = (m_bIsChat) ? "Chat" : "Xfer"; if (IsRemote()) { - string sHost = Csock::GetHostName(); + CString sHost = Csock::GetHostName(); if (!sHost.empty()) { sHost = "[" + sHost + ":" + CUtils::ToString(Csock::GetPort()) + "]"; } - m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + string(strerror(iErrno)) + "]" + sHost); + 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 [" + string(strerror(iErrno)) + "] [" + Csock::GetLocalIP() + ":" + CUtils::ToString(Csock::GetLocalPort()) + "]"); + m_pUser->PutStatus("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + CString(strerror(iErrno)) + "] [" + Csock::GetLocalIP() + ":" + CUtils::ToString(Csock::GetLocalPort()) + "]"); } } @@ -81,7 +81,7 @@ void CDCCBounce::Shutdown() { Close(); } -Csock* CDCCBounce::GetSockObj(const string& sHost, int iPort) { +Csock* CDCCBounce::GetSockObj(const CString& sHost, int iPort) { Close(); if (!m_pManager) { @@ -99,7 +99,7 @@ Csock* CDCCBounce::GetSockObj(const string& sHost, int iPort) { pRemoteSock->SetRemote(true); pSock->SetRemote(false); - if (!m_pManager->Connect(m_sConnectIP, m_uRemotePort, "DCC::" + string((m_bIsChat) ? "Chat" : "XFER") + "::Remote::" + m_sRemoteNick, 60, false, m_sLocalIP, pRemoteSock)) { + if (!m_pManager->Connect(m_sConnectIP, m_uRemotePort, "DCC::" + CString((m_bIsChat) ? "Chat" : "XFER") + "::Remote::" + m_sRemoteNick, 60, false, m_sLocalIP, pRemoteSock)) { pRemoteSock->Close(); } @@ -108,12 +108,12 @@ Csock* CDCCBounce::GetSockObj(const string& sHost, int iPort) { return pSock; } -void CDCCBounce::PutServ(const string& sLine) { +void CDCCBounce::PutServ(const CString& sLine) { DEBUG_ONLY(cout << GetSockName() << " -> [" << sLine << "]" << endl); Write(sLine + "\r\n"); } -void CDCCBounce::PutPeer(const string& sLine) { +void CDCCBounce::PutPeer(const CString& sLine) { if (m_pPeer) { m_pPeer->PutServ(sLine); } else { @@ -121,9 +121,9 @@ void CDCCBounce::PutPeer(const string& sLine) { } } -unsigned short CDCCBounce::DCCRequest(const string& sNick, unsigned long uLongIP, unsigned short uPort, const string& sFileName, bool bIsChat, CUser* pUser, const string& sLocalIP, const string& sRemoteIP) { +unsigned short CDCCBounce::DCCRequest(const CString& sNick, unsigned long uLongIP, unsigned short uPort, const CString& sFileName, bool bIsChat, CUser* pUser, const CString& sLocalIP, const CString& sRemoteIP) { CDCCBounce* pDCCBounce = new CDCCBounce(pUser, uLongIP, uPort, sFileName, sNick, sRemoteIP, sLocalIP, bIsChat); - unsigned short uListenPort = pUser->GetManager()->ListenAllRand("DCC::" + string((bIsChat) ? "Chat" : "Xfer") + "::Local::" + sNick, false, SOMAXCONN, pDCCBounce, 120); + unsigned short uListenPort = pUser->GetManager()->ListenAllRand("DCC::" + CString((bIsChat) ? "Chat" : "Xfer") + "::Local::" + sNick, false, SOMAXCONN, pDCCBounce, 120); return uListenPort; } diff --git a/DCCBounce.h b/DCCBounce.h index 01b59d71..4c598d15 100644 --- a/DCCBounce.h +++ b/DCCBounce.h @@ -7,7 +7,7 @@ class CDCCBounce : public Csock { public: - CDCCBounce(CUser* pUser, unsigned long uLongIP, unsigned short uPort, const string& sFileName, const string& sRemoteNick, const string& sRemoteIP, string sLocalIP, bool bIsChat = false) : Csock() { + CDCCBounce(CUser* pUser, unsigned long uLongIP, unsigned short uPort, const CString& sFileName, const CString& sRemoteNick, const CString& sRemoteIP, CString sLocalIP, bool bIsChat = false) : Csock() { m_uRemotePort = uPort; m_sConnectIP = CUtils::GetIP(uLongIP); m_sRemoteIP = sRemoteIP; @@ -25,7 +25,7 @@ public: } } - CDCCBounce(const string& sHostname, int iport, CUser* pUser, const string& sRemoteNick, const string& sRemoteIP, const string& sFileName, int itimeout = 60, bool bIsChat = false) : Csock(sHostname, iport, itimeout) { + CDCCBounce(const CString& sHostname, int iport, CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, const CString& sFileName, int itimeout = 60, bool bIsChat = false) : Csock(sHostname, iport, itimeout) { m_uRemotePort = 0; m_bIsChat = bIsChat; m_pManager = pUser->GetManager(); @@ -47,9 +47,9 @@ public: } } - static unsigned short DCCRequest(const string& sNick, unsigned long uLongIP, unsigned short uPort, const string& sFileName, bool bIsChat, CUser* pUser, const string& sLocalIP, const string& sRemoteIP); + static unsigned short DCCRequest(const CString& sNick, unsigned long uLongIP, unsigned short uPort, const CString& sFileName, bool bIsChat, CUser* pUser, const CString& sLocalIP, const CString& sRemoteIP); - void ReadLine(const string& sData); + void ReadLine(const CString& sData); virtual void ReadData(const char* data, int len); virtual void Timeout(); virtual void ConnectionRefused(); @@ -57,35 +57,35 @@ public: virtual void Connected(); virtual void Disconnected(); void Shutdown(); - Csock* GetSockObj(const string& sHost, int iPort); - void PutServ(const string& sLine); - void PutPeer(const string& sLine); + Csock* GetSockObj(const CString& sHost, int iPort); + void PutServ(const CString& sLine); + void PutPeer(const CString& sLine); bool IsPeerConnected() { return (m_pPeer) ? m_pPeer->IsConnected() : false; } // Setters void SetPeer(CDCCBounce* p) { m_pPeer = p; } - void SetRemoteIP(const string& s) { m_sRemoteIP = s; } - void SetRemoteNick(const string& s) { m_sRemoteNick = s; } + void SetRemoteIP(const CString& s) { m_sRemoteIP = s; } + void SetRemoteNick(const CString& s) { m_sRemoteNick = s; } void SetManager(TSocketManager* p) { m_pManager = p; } void SetRemote(bool b) { m_bIsRemote = b; } // !Setters // Getters unsigned short GetUserPort() const { return m_uRemotePort; } - const string& GetRemoteIP() const { return m_sRemoteIP; } - const string& GetRemoteNick() const { return m_sRemoteNick; } - const string& GetFileName() const { return m_sFileName; } + const CString& GetRemoteIP() const { return m_sRemoteIP; } + const CString& GetRemoteNick() const { return m_sRemoteNick; } + const CString& GetFileName() const { return m_sFileName; } CDCCBounce* GetPeer() const { return m_pPeer; } TSocketManager* GetManager() const { return m_pManager; } bool IsRemote() { return m_bIsRemote; } // !Getters private: protected: - string m_sRemoteNick; - string m_sRemoteIP; - string m_sConnectIP; - string m_sLocalIP; - string m_sFileName; + CString m_sRemoteNick; + CString m_sRemoteIP; + CString m_sConnectIP; + CString m_sLocalIP; + CString m_sFileName; CUser* m_pUser; CDCCBounce* m_pPeer; TSocketManager* m_pManager; diff --git a/DCCSock.cpp b/DCCSock.cpp index 23bc7fe8..ba009dee 100644 --- a/DCCSock.cpp +++ b/DCCSock.cpp @@ -96,7 +96,7 @@ void CDCCSock::SendPacket() { } } -Csock* CDCCSock::GetSockObj(const string& sHost, int iPort) { +Csock* CDCCSock::GetSockObj(const CString& sHost, int iPort) { Close(); CDCCSock* pSock = new CDCCSock(m_pUser, m_sRemoteNick, m_sLocalFile, m_sModuleName, m_uFileSize, m_pFile); diff --git a/DCCSock.h b/DCCSock.h index 8373fa5c..834fddd1 100644 --- a/DCCSock.h +++ b/DCCSock.h @@ -8,7 +8,7 @@ class CDCCSock : public Csock { public: - CDCCSock(CUser* pUser, const string& sRemoteNick, const string& sLocalFile, const string& sModuleName, unsigned long uFileSize = 0, CFile* pFile = NULL) : Csock() { + CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sLocalFile, const CString& sModuleName, unsigned long uFileSize = 0, CFile* pFile = NULL) : Csock() { m_sRemoteNick = sRemoteNick; m_uFileSize = uFileSize; m_uRemotePort = 0; @@ -21,7 +21,7 @@ public: m_bNoDelFile = false; } - CDCCSock(CUser* pUser, const string& sRemoteNick, const string& sRemoteIP, unsigned short uRemotePort, const string& sLocalFile, unsigned long uFileSize, const string& sModuleName) : Csock() { + CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sLocalFile, unsigned long uFileSize, const CString& sModuleName) : Csock() { m_sRemoteNick = sRemoteNick; m_sRemoteIP = sRemoteIP; m_uRemotePort = uRemotePort; @@ -35,7 +35,7 @@ public: m_bNoDelFile = false; } -/* CDCCSock(CUser* pUser, const string& sHostname, int iport, int itimeout = 60) : Csock(sHostname, iport, itimeout) { +/* CDCCSock(CUser* pUser, const CString& sHostname, int iport, int itimeout = 60) : Csock(sHostname, iport, itimeout) { m_uRemotePort = 0; m_uBytesSoFar = 0; m_uFileSize = 0; @@ -58,7 +58,7 @@ public: virtual void Connected(); virtual void Disconnected(); void SendPacket(); - Csock* GetSockObj(const string& sHost, int iPort); + Csock* GetSockObj(const CString& sHost, int iPort); CFile* OpenFile(bool bWrite = true); bool Seek(unsigned int uPos) { if (m_pFile) { @@ -72,30 +72,30 @@ public: } // Setters - void SetRemoteIP(const string& s) { m_sRemoteIP = s; } - void SetRemoteNick(const string& s) { m_sRemoteNick = s; } - void SetFileName(const string& s) { m_sFileName = s; } + void SetRemoteIP(const CString& s) { m_sRemoteIP = s; } + void SetRemoteNick(const CString& s) { m_sRemoteNick = s; } + void SetFileName(const CString& s) { m_sFileName = s; } void SetFileOffset(unsigned long u) { m_uBytesSoFar = u; } // !Setters // Getters unsigned short GetUserPort() const { return m_uRemotePort; } - const string& GetRemoteNick() const { return m_sRemoteNick; } - const string& GetFileName() const { return m_sFileName; } - const string& GetLocalFile() const { return m_sLocalFile; } - const string& GetModuleName() const { return m_sModuleName; } + const CString& GetRemoteNick() const { return m_sRemoteNick; } + const CString& GetFileName() const { return m_sFileName; } + const CString& GetLocalFile() const { return m_sLocalFile; } + const CString& GetModuleName() const { return m_sModuleName; } CFile* GetFile() { return m_pFile; } double GetProgress() const { return ((m_uFileSize) && (m_uBytesSoFar)) ? (double) (((double) m_uBytesSoFar / (double) m_uFileSize) *100.0) : 0; } - //const string& GetRemoteIP() const { return m_sRemoteIP; } + //const CString& GetRemoteIP() const { return m_sRemoteIP; } // !Getters private: protected: - string m_sRemoteNick; - string m_sRemoteIP; - string m_sFileName; - string m_sLocalFile; - string m_sSendBuf; - string m_sModuleName; + CString m_sRemoteNick; + CString m_sRemoteIP; + CString m_sFileName; + CString m_sLocalFile; + CString m_sSendBuf; + CString m_sModuleName; unsigned short m_uRemotePort; unsigned long m_uFileSize; unsigned long m_uBytesSoFar; diff --git a/FileUtils.cpp b/FileUtils.cpp index d1c461c9..befc29eb 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -1,6 +1,6 @@ #include "FileUtils.h" -CFile::CFile(const string& sLongName) { +CFile::CFile(const CString& sLongName) { m_sLongName = sLongName; m_iFD = -1; @@ -11,8 +11,8 @@ CFile::CFile(const string& sLongName) { CUtils::LeftChomp(m_sShortName); } - string::size_type uPos = m_sShortName.rfind('/'); - if (uPos != string::npos) { + CString::size_type uPos = m_sShortName.rfind('/'); + if (uPos != CString::npos) { m_sShortName = m_sShortName.substr(uPos +1); } } @@ -23,13 +23,13 @@ CFile::~CFile() { } } -bool CFile::IsReg(const string& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_REGULAR, bUseLstat); } -bool CFile::IsDir(const string& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_DIRECTORY, bUseLstat); } -bool CFile::IsChr(const string& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_CHARACTER, bUseLstat); } -bool CFile::IsBlk(const string& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_BLOCK, bUseLstat); } -bool CFile::IsFifo(const string& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_FIFO, bUseLstat); } -bool CFile::IsLnk(const string& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_LINK, bUseLstat); } -bool CFile::IsSock(const string& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_SOCK, bUseLstat); } +bool CFile::IsReg(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_REGULAR, bUseLstat); } +bool CFile::IsDir(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_DIRECTORY, bUseLstat); } +bool CFile::IsChr(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_CHARACTER, bUseLstat); } +bool CFile::IsBlk(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_BLOCK, bUseLstat); } +bool CFile::IsFifo(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_FIFO, bUseLstat); } +bool CFile::IsLnk(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_LINK, bUseLstat); } +bool CFile::IsSock(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_SOCK, bUseLstat); } bool CFile::IsReg(bool bUseLstat) { return CFile::IsReg(m_sLongName, bUseLstat); } bool CFile::IsDir(bool bUseLstat) { return CFile::IsDir(m_sLongName, bUseLstat); } @@ -42,7 +42,7 @@ bool CFile::IsSock(bool bUseLstat) { return CFile::IsSock(m_sLongName, bUseLsta bool CFile::access(int mode) { return (::access(m_sLongName.c_str(), mode) == 0); } // for gettin file types, using fstat instead -bool CFile::FType(const string sFileName, EFileTypes eType, bool bUseLstat) { +bool CFile::FType(const CString sFileName, EFileTypes eType, bool bUseLstat) { struct stat st; if (!bUseLstat) { @@ -86,12 +86,12 @@ unsigned int CFile::GetMTime() const { return CFile::GetMTime(m_sLongName); } unsigned int CFile::GetCTime() const { return CFile::GetCTime(m_sLongName); } int CFile::GetUID() const { return CFile::GetUID(m_sLongName); } int CFile::GetGID() const { return CFile::GetGID(m_sLongName); } -bool CFile::Exists(const string& sFile) { +bool CFile::Exists(const CString& sFile) { struct stat st; return (stat(sFile.c_str(), &st) == 0); } -unsigned long long CFile::GetSize(const string& sFile) { +unsigned long long CFile::GetSize(const CString& sFile) { struct stat st; if(stat(sFile.c_str(), &st) != 0) { return 0; @@ -100,31 +100,31 @@ unsigned long long CFile::GetSize(const string& sFile) { return (S_ISREG(st.st_mode)) ? st.st_size : 0; } -unsigned int CFile::GetATime(const string& sFile) { +unsigned int CFile::GetATime(const CString& sFile) { struct stat st; return (stat(sFile.c_str(), &st) != 0) ? 0 : st.st_atime; } -unsigned int CFile::GetMTime(const string& sFile) { +unsigned int CFile::GetMTime(const CString& sFile) { struct stat st; return (stat(sFile.c_str(), &st) != 0) ? 0 : st.st_mtime; } -unsigned int CFile::GetCTime(const string& sFile) { +unsigned int CFile::GetCTime(const CString& sFile) { struct stat st; return (stat(sFile.c_str(), &st) != 0) ? 0 : st.st_ctime; } -int CFile::GetUID(const string& sFile) { +int CFile::GetUID(const CString& sFile) { struct stat st; return (stat(sFile.c_str(), &st) != 0) ? -1 : (int) st.st_uid; } -int CFile::GetGID(const string& sFile) { +int CFile::GetGID(const CString& sFile) { struct stat st; return (stat(sFile.c_str(), &st) != 0) ? -1 : (int) st.st_gid; } -int CFile::GetInfo(const string& sFile, struct stat& st) { +int CFile::GetInfo(const CString& sFile, struct stat& st) { return stat(sFile.c_str(), &st); } @@ -132,11 +132,11 @@ int CFile::GetInfo(const string& sFile, struct stat& st) { // Functions to manipulate the file on the filesystem // int CFile::Delete() { return CFile::Delete(m_sLongName); } -int CFile::Move(const string& sNewFileName, bool bOverwrite) { +int CFile::Move(const CString& sNewFileName, bool bOverwrite) { return CFile::Move(m_sLongName, sNewFileName, bOverwrite); } -bool CFile::Delete(const string& sFileName) { +bool CFile::Delete(const CString& sFileName) { if(!CFile::Exists(sFileName)) { return false; } @@ -144,12 +144,12 @@ bool CFile::Delete(const string& sFileName) { return (unlink(sFileName.c_str()) == 0) ? true : false; } -bool CFile::Move(const string& sOldFileName, const string& sNewFileName, bool bOverwrite) { +bool CFile::Move(const CString& sOldFileName, const CString& sNewFileName, bool bOverwrite) { if((!bOverwrite) && (CFile::Exists(sNewFileName))) { return false; } - //string sNewLongName = (sNewFileName[0] == '/') ? sNewFileName : m_sPath + "/" + sNewFileName; + //CString sNewLongName = (sNewFileName[0] == '/') ? sNewFileName : m_sPath + "/" + sNewFileName; return (rename(sOldFileName.c_str(), sNewFileName.c_str()) == 0) ? true : false; } @@ -157,7 +157,7 @@ bool CFile::Chmod(mode_t mode) { return CFile::Chmod(m_sLongName, mode); } -bool CFile::Chmod(const string& sFile, mode_t mode) { +bool CFile::Chmod(const CString& sFile, mode_t mode) { return (chmod(sFile.c_str(), mode) == 0); } @@ -182,7 +182,7 @@ int CFile::Read(char *pszBuffer, int iBytes) { return read(m_iFD, pszBuffer, iBytes); } -bool CFile::ReadLine(string & sData) { +bool CFile::ReadLine(CString & sData) { char buff[64]; sData.clear(); if (m_iFD == -1) { @@ -192,8 +192,8 @@ bool CFile::ReadLine(string & sData) { bool bEOF = false; while(true) { - string::size_type iFind = m_sBuffer.find("\n"); - if (iFind != string::npos) { + CString::size_type iFind = m_sBuffer.find("\n"); + if (iFind != CString::npos) { sData = m_sBuffer.substr(0, (iFind + 1)); m_sBuffer.erase(0, (iFind + 1)); break; @@ -221,8 +221,8 @@ bool CFile::ReadLine(string & sData) { } } - string::size_type iFind = m_sBuffer.find("\n"); - if (iFind != string::npos) { + CString::size_type iFind = m_sBuffer.find("\n"); + if (iFind != CString::npos) { return true; } @@ -237,11 +237,11 @@ int CFile::Write(const char *pszBuffer, u_int iBytes) { return write(m_iFD, pszBuffer, iBytes); } -int CFile::Write(const string & sData) { +int CFile::Write(const CString & sData) { return Write(sData.data(), sData.size()); } void CFile::Close() { close(m_iFD); m_iFD = -1; } -string CFile::GetLongName() const { return m_sLongName; } -string CFile::GetShortName() const { return m_sShortName; } +CString CFile::GetLongName() const { return m_sLongName; } +CString CFile::GetShortName() const { return m_sShortName; } void CFile::SetFD(int iFD) { m_iFD = iFD; } diff --git a/FileUtils.h b/FileUtils.h index f7c8bca4..365ddcdd 100644 --- a/FileUtils.h +++ b/FileUtils.h @@ -10,16 +10,15 @@ #include "Utils.h" -#include +#include "String.h" #include #include -using std::string; using std::vector; using std::map; class CFile { public: - CFile(const string& sLongName); + CFile(const CString& sLongName); virtual ~CFile(); enum EFileTypes { @@ -32,13 +31,13 @@ public: FT_SOCK }; - static bool IsReg(const string& sLongName, bool bUseLstat = false); - static bool IsDir(const string& sLongName, bool bUseLstat = false); - static bool IsChr(const string& sLongName, bool bUseLstat = false); - static bool IsBlk(const string& sLongName, bool bUseLstat = false); - static bool IsFifo(const string& sLongName, bool bUseLstat = false); - static bool IsLnk(const string& sLongName, bool bUseLstat = true); - static bool IsSock(const string& sLongName, bool bUseLstat = false); + static bool IsReg(const CString& sLongName, bool bUseLstat = false); + static bool IsDir(const CString& sLongName, bool bUseLstat = false); + static bool IsChr(const CString& sLongName, bool bUseLstat = false); + static bool IsBlk(const CString& sLongName, bool bUseLstat = false); + static bool IsFifo(const CString& sLongName, bool bUseLstat = false); + static bool IsLnk(const CString& sLongName, bool bUseLstat = true); + static bool IsSock(const CString& sLongName, bool bUseLstat = false); bool IsReg(bool bUseLstat = false); bool IsDir(bool bUseLstat = false); @@ -51,7 +50,7 @@ public: bool access(int mode); // for gettin file types, using fstat instead - static bool FType(const string sFileName, EFileTypes eType, bool bUseLstat = false); + static bool FType(const CString sFileName, EFileTypes eType, bool bUseLstat = false); enum EFileAttr { FA_Name, @@ -72,51 +71,51 @@ public: unsigned int GetCTime() const; int GetUID() const; int GetGID() const; - static bool Exists(const string& sFile); + static bool Exists(const CString& sFile); - static unsigned long long GetSize(const string& sFile); - static unsigned int GetATime(const string& sFile); - static unsigned int GetMTime(const string& sFile); - static unsigned int GetCTime(const string& sFile); - static int GetUID(const string& sFile); - static int GetGID(const string& sFile); - static int GetInfo(const string& sFile, struct stat& st); + static unsigned long long GetSize(const CString& sFile); + static unsigned int GetATime(const CString& sFile); + static unsigned int GetMTime(const CString& sFile); + static unsigned int GetCTime(const CString& sFile); + static int GetUID(const CString& sFile); + static int GetGID(const CString& sFile); + static int GetInfo(const CString& sFile, struct stat& st); // // Functions to manipulate the file on the filesystem // int Delete(); - int Move(const string& sNewFileName, bool bOverwrite = false); + int Move(const CString& sNewFileName, bool bOverwrite = false); - static bool Delete(const string& sFileName); - static bool Move(const string& sOldFileName, const string& sNewFileName, bool bOverwrite = false); + static bool Delete(const CString& sFileName); + static bool Move(const CString& sOldFileName, const CString& sNewFileName, bool bOverwrite = false); bool Chmod(mode_t mode); - static bool Chmod(const string& sFile, mode_t mode); + static bool Chmod(const CString& sFile, mode_t mode); bool Seek(unsigned long uPos); bool Open(int iFlags, mode_t iMode = 0644); int Read(char *pszBuffer, int iBytes); - bool ReadLine(string & sData); + bool ReadLine(CString & sData); int Write(const char *pszBuffer, u_int iBytes); - int Write(const string & sData); + int Write(const CString & sData); void Close(); - string GetLongName() const; - string GetShortName() const; + CString GetLongName() const; + CString GetShortName() const; void SetFD(int iFD); private: - string m_sBuffer; + CString m_sBuffer; int m_iFD; protected: - string m_sLongName; //!< Absolute filename (m_sPath + "/" + m_sShortName) - string m_sShortName; //!< Filename alone, without path + CString m_sLongName; //!< Absolute filename (m_sPath + "/" + m_sShortName) + CString m_sShortName; //!< Filename alone, without path }; class CDir : public vector { public: - CDir(const string& sDir) { + CDir(const CString& sDir) { m_bDesc = false; m_eSortAttr = CFile::FA_Name; Fill(sDir); @@ -139,7 +138,7 @@ public: clear(); } - int Fill(const string& sDir) { + int Fill(const CString& sDir) { return FillByWildcard(sDir, "*"); } @@ -149,14 +148,14 @@ public: sort(begin(), end(), TPtrCmp); }*/ - static bool Exists(const string& sDir) { + static bool Exists(const CString& sDir) { CFile cFile(sDir); return (cFile.Exists()) && (cFile.IsDir()); } -/* static bool Create(const string& sDir, mode_t mode = 0755) { - VCstring vSubDirs = sDir.split("[/\\\\]+"); - Cstring sCurDir; +/* static bool Create(const CString& sDir, mode_t mode = 0755) { + VCCString vSubDirs = sDir.split("[/\\\\]+"); + CCString sCurDir; for (unsigned int a = 0; a < vSubDirs.size(); a++) { sCurDir += vSubDirs[a] + "/"; @@ -168,7 +167,7 @@ public: return true; } - int FillByRegex(const Cstring& sDir, const Cstring& sRegex, const Cstring& sFlags = "") { + int FillByRegex(const CCString& sDir, const CCString& sRegex, const CCString& sFlags = "") { CleanUp(); DIR* dir = opendir((sDir.empty()) ? "." : sDir.c_str()); @@ -182,7 +181,7 @@ public: if ((strcmp(de->d_name, ".") == 0) || (strcmp(de->d_name, "..") == 0)) { continue; } - if ((!sRegex.empty()) && (!Cstring::search(de->d_name, sRegex, sFlags))) { + if ((!sRegex.empty()) && (!CCString::search(de->d_name, sRegex, sFlags))) { continue; } @@ -194,7 +193,7 @@ public: return size(); }*/ - int FillByWildcard(const string& sDir, const string& sWildcard) { + int FillByWildcard(const CString& sDir, const CString& sWildcard) { CleanUp(); DIR* dir = opendir((sDir.empty()) ? "." : sDir.c_str()); @@ -220,7 +219,7 @@ public: return size(); } - static unsigned int Chmod(mode_t mode, const string& sWildcard, const string& sDir = ".") { + static unsigned int Chmod(mode_t mode, const CString& sWildcard, const CString& sDir = ".") { CDir cDir; cDir.FillByWildcard(sDir, sWildcard); return cDir.Chmod(mode); @@ -237,7 +236,7 @@ public: return uRet; } - static unsigned int Delete(mode_t mode, const string& sWildcard, const string& sDir = ".") { + static unsigned int Delete(mode_t mode, const CString& sWildcard, const CString& sDir = ".") { CDir cDir; cDir.FillByWildcard(sDir, sWildcard); return cDir.Delete(); @@ -257,7 +256,7 @@ public: CFile::EFileAttr GetSortAttr() { return m_eSortAttr; } bool IsDescending() { return m_bDesc; } -/* static bool MkDir(const string & sPath, mode_t iMode, bool bBuildParents = false, bool bApplyModToParents = false) { +/* static bool MkDir(const CString & sPath, mode_t iMode, bool bBuildParents = false, bool bApplyModToParents = false) { if (sPath.empty()) { WARN("empty path!"); return false; @@ -274,7 +273,7 @@ public: } - VCstring vPath = sPath.TrimRight_n("/").split("/+"); + VCCString vPath = sPath.TrimRight_n("/").split("/+"); if (vPath.empty()) { return false; @@ -283,7 +282,7 @@ public: if (sPath[0] == '/'); vPath[0] = "/" + vPath[0]; - Cstring sCurDir = GetCWD(); + CCString sCurDir = GetCWD(); mode_t uMask = 0000; if (bApplyModToParents) { @@ -319,8 +318,8 @@ public: return (iRet == 0); }*/ - static string GetCWD() { - string sRet; + static CString GetCWD() { + CString sRet; char * pszCurDir = getcwd(NULL, 0); if (pszCurDir) { sRet = pszCurDir; diff --git a/IRCSock.cpp b/IRCSock.cpp index d3067f34..ee074516 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -30,7 +30,7 @@ CIRCSock::~CIRCSock() { m_pUserSock = NULL; } - for (map::iterator a = m_msChans.begin(); a != m_msChans.end(); a++) { + for (map::iterator a = m_msChans.begin(); a != m_msChans.end(); a++) { delete a->second; } @@ -42,8 +42,8 @@ CIRCSock::~CIRCSock() { m_msChans.clear(); } -void CIRCSock::ReadLine(const string& sData) { - string sLine = sData; +void CIRCSock::ReadLine(const CString& sData) { + CString sLine = sData; while ((CUtils::Right(sLine, 1) == "\r") || (CUtils::Right(sLine, 1) == "\n")) { CUtils::RightChomp(sLine); @@ -60,13 +60,13 @@ void CIRCSock::ReadLine(const string& sData) { if (strncasecmp(sLine.c_str(), "PING ", 5) == 0) { PutServ("PONG " + sLine.substr(5)); } else if (CUtils::wildcmp(":* * *", sLine.c_str())) { //"^:(\\S+) (\\d\\d\\d) (.*?) (.*)$", vCap)) { - string sCmd = CUtils::Token(sLine, 1); + CString sCmd = CUtils::Token(sLine, 1); if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) { - string sServer = CUtils::Token(sLine, 0); CUtils::LeftChomp(sServer); + CString sServer = CUtils::Token(sLine, 0); CUtils::LeftChomp(sServer); unsigned int uRaw = strtoul(sCmd.c_str(), NULL, 10); - string sNick = CUtils::Token(sLine, 2); - string sRest = CUtils::Token(sLine, 3, true); + CString sNick = CUtils::Token(sLine, 2); + CString sRest = CUtils::Token(sLine, 3, true); switch (uRaw) { case 1: {// :irc.server.com 001 nick :Welcome to the Internet Relay Network nick @@ -79,7 +79,7 @@ void CIRCSock::ReadLine(const string& sData) { m_pUser->PutStatus("Connected!"); if (m_pUserSock) { - string sClientNick = m_pUserSock->GetNick(); + CString sClientNick = m_pUserSock->GetNick(); if (strcasecmp(sClientNick.c_str(), sNick.c_str()) != 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); @@ -137,11 +137,11 @@ void CIRCSock::ReadLine(const string& sData) { break; case 433: { - string sBadNick = CUtils::Token(sRest, 0); - string sConfNick = m_pUser->GetNick(); + CString sBadNick = CUtils::Token(sRest, 0); + CString sConfNick = m_pUser->GetNick(); if (sNick == "*") { - string sAltNick = m_pUser->GetAltNick(); + 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)) { @@ -151,9 +151,9 @@ void CIRCSock::ReadLine(const string& sData) { } } else if (strcasecmp(sBadNick.c_str(), sAltNick.c_str()) == 0) { PutServ("NICK " + CUtils::Left(sConfNick, 8) + "-"); - } else if (strcasecmp(sBadNick.c_str(), string(CUtils::Left(sConfNick, 8) + "-").c_str()) == 0) { + } else if (strcasecmp(sBadNick.c_str(), CString(CUtils::Left(sConfNick, 8) + "-").c_str()) == 0) { PutServ("NICK " + CUtils::Left(sConfNick, 8) + "|"); - } else if (strcasecmp(sBadNick.c_str(), string(CUtils::Left(sConfNick, 8) + "|").c_str()) == 0) { + } else if (strcasecmp(sBadNick.c_str(), CString(CUtils::Left(sConfNick, 8) + "|").c_str()) == 0) { PutServ("NICK " + CUtils::Left(sConfNick, 8) + "^"); } else { char cLetter = 0; @@ -169,7 +169,7 @@ void CIRCSock::ReadLine(const string& sData) { return; } - string sSend = "NICK " + CUtils::Left(sConfNick, 8) + cLetter++; + CString sSend = "NICK " + CUtils::Left(sConfNick, 8) + cLetter++; PutServ(sSend); } @@ -211,7 +211,7 @@ void CIRCSock::ReadLine(const string& sData) { CChan* pChan = m_pUser->FindChan(CUtils::Token(sLine, 3)); if (pChan) { - string sTopic = CUtils::Token(sLine, 4, true); + CString sTopic = CUtils::Token(sLine, 4, true); CUtils::LeftChomp(sTopic); pChan->SetTopic(sTopic); } @@ -223,7 +223,7 @@ void CIRCSock::ReadLine(const string& sData) { CChan* pChan = m_pUser->FindChan(CUtils::Token(sLine, 3)); if (pChan) { - string sNick = CUtils::Token(sLine, 4); + CString sNick = CUtils::Token(sLine, 4); unsigned long ulDate = strtoul(CUtils::Token(sLine, 5).c_str(), NULL, 10); pChan->SetTopicOwner(sNick); @@ -234,10 +234,10 @@ void CIRCSock::ReadLine(const string& sData) { } case 352: { // :irc.yourserver.com 352 yournick #chan ident theirhost.com irc.theirserver.com theirnick H :0 Real Name - string sServer = CUtils::Token(sLine, 0); - string sNick = CUtils::Token(sLine, 7); - string sIdent = CUtils::Token(sLine, 4); - string sHost = CUtils::Token(sLine, 5); + CString sServer = CUtils::Token(sLine, 0); + CString sNick = CUtils::Token(sLine, 7); + CString sIdent = CUtils::Token(sLine, 4); + CString sHost = CUtils::Token(sLine, 5); CUtils::LeftChomp(sServer); @@ -271,7 +271,7 @@ void CIRCSock::ReadLine(const string& sData) { // Todo: allow for non @+= server msgs CChan* pChan = m_pUser->FindChan(CUtils::Token(sRest, 1)); if (pChan) { - string sNicks = CUtils::Token(sRest, 2, true); + CString sNicks = CUtils::Token(sRest, 2, true); if (CUtils::Left(sNicks, 1) == ":") { CUtils::LeftChomp(sNicks); } @@ -288,7 +288,7 @@ void CIRCSock::ReadLine(const string& sData) { if (pChan) { if (IsUserAttached()) { - const vector& vsBuffer = pChan->GetBuffer(); + const vector& vsBuffer = pChan->GetBuffer(); if (vsBuffer.size()) { PutUser(":***!znc@znc.com PRIVMSG " + pChan->GetName() + " :Buffer Playback..."); @@ -311,7 +311,7 @@ void CIRCSock::ReadLine(const string& sData) { // If we are the only one in the chan, set our default modes if (pChan->GetNickCount() == 1) { - string sModes = pChan->GetDefaultModes(); + CString sModes = pChan->GetDefaultModes(); if (sModes.empty()) { sModes = m_pUser->GetDefaultChanModes(); @@ -328,15 +328,15 @@ void CIRCSock::ReadLine(const string& sData) { } } } else { //if (CUtils::wildcmp(":*!*@* * *", sLine.c_str())) { - string sNickMask = CUtils::Token(sLine, 0); + CString sNickMask = CUtils::Token(sLine, 0); CUtils::LeftChomp(sNickMask); - string sNick = CUtils::Token(sNickMask, 0, false, '!'); - string sCmd = CUtils::Token(sLine, 1); - string sRest = CUtils::Token(sLine, 2, true); + CString sNick = CUtils::Token(sNickMask, 0, false, '!'); + CString sCmd = CUtils::Token(sLine, 1); + CString sRest = CUtils::Token(sLine, 2, true); if (strcasecmp(sCmd.c_str(), "NICK") == 0) { - string sNewNick = sRest; + CString sNewNick = sRest; bool bIsVisible = false; if (CUtils::Left(sNewNick, 1) == ":") { @@ -375,7 +375,7 @@ void CIRCSock::ReadLine(const string& sData) { return; } } else if (strcasecmp(sCmd.c_str(), "QUIT") == 0) { - string sMessage = sRest; + CString sMessage = sRest; bool bIsVisible = false; if (CUtils::Left(sMessage, 1) == ":") { @@ -412,7 +412,7 @@ void CIRCSock::ReadLine(const string& sData) { return; } } else if (strcasecmp(sCmd.c_str(), "JOIN") == 0) { - string sChan = CUtils::Token(sRest, 0); + CString sChan = CUtils::Token(sRest, 0); if (CUtils::Left(sChan, 1) == ":") { CUtils::LeftChomp(sChan); } @@ -432,7 +432,7 @@ void CIRCSock::ReadLine(const string& sData) { } } } else if (strcasecmp(sCmd.c_str(), "PART") == 0) { - string sChan = CUtils::Token(sRest, 0); + CString sChan = CUtils::Token(sRest, 0); if (CUtils::Left(sChan, 1) == ":") { CUtils::LeftChomp(sChan); } @@ -453,8 +453,8 @@ void CIRCSock::ReadLine(const string& sData) { return; } } else if (strcasecmp(sCmd.c_str(), "MODE") == 0) { - string sChan = CUtils::Token(sRest, 0); - string sModes = CUtils::Token(sRest, 1, true); + CString sChan = CUtils::Token(sRest, 0); + CString sModes = CUtils::Token(sRest, 1, true); CChan* pChan = m_pUser->FindChan(sChan); if (pChan) { @@ -466,9 +466,9 @@ void CIRCSock::ReadLine(const string& sData) { } } else if (strcasecmp(sCmd.c_str(), "KICK") == 0) { // :opnick!ident@host.com KICK #chan nick :msg - string sChan = CUtils::Token(sRest, 0); - string sKickedNick = CUtils::Token(sRest, 1); - string sMsg = CUtils::Token(sRest, 2, true); + CString sChan = CUtils::Token(sRest, 0); + CString sKickedNick = CUtils::Token(sRest, 1); + CString sMsg = CUtils::Token(sRest, 2, true); CUtils::LeftChomp(sMsg); CChan* pChan = m_pUser->FindChan(sChan); @@ -481,7 +481,7 @@ void CIRCSock::ReadLine(const string& sData) { } if (strcasecmp(GetNick().c_str(), sKickedNick.c_str()) == 0) { - string sKey; + CString sKey; if (pChan) { sKey = pChan->GetKey(); @@ -499,8 +499,8 @@ void CIRCSock::ReadLine(const string& sData) { CNick Nick(sNickMask); - string sTarget = CUtils::Token(sRest, 0); - string sMsg = CUtils::Token(sRest, 1, true); + CString sTarget = CUtils::Token(sRest, 0); + CString sMsg = CUtils::Token(sRest, 1, true); CUtils::LeftChomp(sMsg); if (CUtils::wildcmp("\001*\001", sMsg.c_str())) { @@ -535,7 +535,7 @@ void CIRCSock::ReadLine(const string& sData) { if (pChan) { CNick Nick(sNickMask); - string sTopic = CUtils::Token(sLine, 3, true); + CString sTopic = CUtils::Token(sLine, 3, true); CUtils::LeftChomp(sTopic); pChan->SetTopicOwner(Nick.GetNick()); pChan->SetTopicDate((unsigned long) time(NULL)); // @todo use local time @@ -545,8 +545,8 @@ void CIRCSock::ReadLine(const string& sData) { // :nick!ident@host.com PRIVMSG #chan :Message CNick Nick(sNickMask); - string sTarget = CUtils::Token(sRest, 0); - string sMsg = CUtils::Token(sRest, 1, true); + CString sTarget = CUtils::Token(sRest, 0); + CString sMsg = CUtils::Token(sRest, 1, true); if (CUtils::Left(sMsg, 1) == ":") { CUtils::LeftChomp(sMsg); @@ -590,14 +590,14 @@ void CIRCSock::ReadLine(const string& sData) { } void CIRCSock::KeepNick() { - const string& sConfNick = m_pUser->GetNick(); + const CString& sConfNick = m_pUser->GetNick(); if ((m_bAuthed) && (m_bKeepNick) && (m_pUser->KeepNick()) && (strcasecmp(GetNick().c_str(), sConfNick.c_str()) != 0)) { PutServ("NICK " + sConfNick); } } -bool CIRCSock::OnCTCPReply(const string& sNickMask, string& sMessage) { +bool CIRCSock::OnCTCPReply(const CString& sNickMask, CString& sMessage) { #ifdef _MODULES if (m_pUser->GetModules().OnCTCPReply(sNickMask, sMessage)) { return true; @@ -607,7 +607,7 @@ bool CIRCSock::OnCTCPReply(const string& sNickMask, string& sMessage) { return false; } -bool CIRCSock::OnPrivCTCP(const string& sNickMask, string& sMessage) { +bool CIRCSock::OnPrivCTCP(const CString& sNickMask, CString& sMessage) { #ifdef _MODULES if (m_pUser->GetModules().OnPrivCTCP(sNickMask, sMessage)) { return true; @@ -616,13 +616,13 @@ bool CIRCSock::OnPrivCTCP(const string& sNickMask, string& sMessage) { if (strcasecmp(sMessage.c_str(), "VERSION") == 0) { if (!IsUserAttached()) { - string sVersionReply = m_pUser->GetVersionReply(); + CString sVersionReply = m_pUser->GetVersionReply(); PutServ("NOTICE " + CNick(sNickMask).GetNick() + " :\001VERSION " + sVersionReply + "\001"); } } else if (strncasecmp(sMessage.c_str(), "DCC ", 4) == 0) { // DCC CHAT chat 2453612361 44592 - string sType = CUtils::Token(sMessage, 1); - string sFile = CUtils::Token(sMessage, 2); + CString sType = CUtils::Token(sMessage, 1); + CString sFile = CUtils::Token(sMessage, 2); unsigned long uLongIP = strtoul(CUtils::Token(sMessage, 3).c_str(), NULL, 10); unsigned short uPort = strtoul(CUtils::Token(sMessage, 4).c_str(), NULL, 10); unsigned long uFileSize = strtoul(CUtils::Token(sMessage, 5).c_str(), NULL, 10); @@ -672,7 +672,7 @@ bool CIRCSock::OnPrivCTCP(const string& sNickMask, string& sMessage) { return false; } -bool CIRCSock::OnPrivNotice(const string& sNickMask, string& sMessage) { +bool CIRCSock::OnPrivNotice(const CString& sNickMask, CString& sMessage) { #ifdef _MODULES if (m_pUser->GetModules().OnPrivNotice(sNickMask, sMessage)) { return true; @@ -686,7 +686,7 @@ bool CIRCSock::OnPrivNotice(const string& sNickMask, string& sMessage) { return false; } -bool CIRCSock::OnPrivMsg(const string& sNickMask, string& sMessage) { +bool CIRCSock::OnPrivMsg(const CString& sNickMask, CString& sMessage) { #ifdef _MODULES if (m_pUser->GetModules().OnPrivMsg(sNickMask, sMessage)) { return true; @@ -700,7 +700,7 @@ bool CIRCSock::OnPrivMsg(const string& sNickMask, string& sMessage) { return false; } -bool CIRCSock::OnChanCTCP(const string& sNickMask, const string& sChan, string& sMessage) { +bool CIRCSock::OnChanCTCP(const CString& sNickMask, const CString& sChan, CString& sMessage) { CChan* pChan = m_pUser->FindChan(sChan); if (pChan) { #ifdef _MODULES @@ -713,7 +713,7 @@ bool CIRCSock::OnChanCTCP(const string& sNickMask, const string& sChan, string& return false; } -bool CIRCSock::OnChanNotice(const string& sNickMask, const string& sChan, string& sMessage) { +bool CIRCSock::OnChanNotice(const CString& sNickMask, const CString& sChan, CString& sMessage) { CChan* pChan = m_pUser->FindChan(sChan); if (pChan) { #ifdef _MODULES @@ -729,7 +729,7 @@ bool CIRCSock::OnChanNotice(const string& sNickMask, const string& sChan, string return ((pChan) && (pChan->IsDetached())); } -bool CIRCSock::OnChanMsg(const string& sNickMask, const string& sChan, string& sMessage) { +bool CIRCSock::OnChanMsg(const CString& sNickMask, const CString& sChan, CString& sMessage) { CChan* pChan = m_pUser->FindChan(sChan); if (pChan) { #ifdef _MODULES @@ -756,7 +756,7 @@ void CIRCSock::UserConnected(CUserSock* pUserSock) { PutUser(":irc.znc.com 001 " + m_pUserSock->GetNick() + " :- Welcome to ZNC -"); } else { unsigned int uIdx = 0; - string sLine; + CString sLine; while (m_RawBuffer.GetLine(GetNick(), sLine, uIdx++)) { PutUser(sLine); @@ -767,7 +767,7 @@ void CIRCSock::UserConnected(CUserSock* pUserSock) { if (m_MotdBuffer.IsEmpty()) { } else { unsigned int uIdx = 0; - string sLine; + CString sLine; while (m_MotdBuffer.GetLine(GetNick(), sLine, uIdx++)) { PutUser(sLine); @@ -781,7 +781,7 @@ void CIRCSock::UserConnected(CUserSock* pUserSock) { } } - string sBufLine; + CString sBufLine; while (m_QueryBuffer.GetNextLine(GetNick(), sBufLine)) { PutUser(sBufLine); } @@ -791,24 +791,24 @@ void CIRCSock::UserDisconnected() { m_pUserSock = NULL; } -void CIRCSock::PutServ(const string& sLine) { +void CIRCSock::PutServ(const CString& sLine) { DEBUG_ONLY(cout << GetSockName() << " -> [" << sLine << "]" << endl); Write(sLine + "\r\n"); } -void CIRCSock::PutUser(const string& sLine) { +void CIRCSock::PutUser(const CString& sLine) { if (m_pUserSock) { m_pUserSock->PutServ(sLine); } } -void CIRCSock::PutStatus(const string& sLine) { +void CIRCSock::PutStatus(const CString& sLine) { if (m_pUserSock) { m_pUserSock->PutStatus(sLine); } } -void CIRCSock::SetNick(const string& sNick) { +void CIRCSock::SetNick(const CString& sNick) { m_Nick.SetNick(sNick); m_pUser->SetIRCNick(m_Nick); diff --git a/IRCSock.h b/IRCSock.h index 2e7cef36..52bb1161 100644 --- a/IRCSock.h +++ b/IRCSock.h @@ -17,16 +17,16 @@ public: virtual ~CIRCSock(); // Message Handlers - bool OnCTCPReply(const string& sNickMask, string& sMessage); - bool OnPrivCTCP(const string& sNickMask, string& sMessage); - bool OnChanCTCP(const string& sNickMask, const string& sChan, string& sMessage); - bool OnPrivMsg(const string& sNickMask, string& sMessage); - bool OnChanMsg(const string& sNickMask, const string& sChan, string& sMessage); - bool OnPrivNotice(const string& sNickMask, string& sMessage); - bool OnChanNotice(const string& sNickMask, const string& sChan, string& sMessage); + bool OnCTCPReply(const CString& sNickMask, CString& sMessage); + bool OnPrivCTCP(const CString& sNickMask, CString& sMessage); + bool OnChanCTCP(const CString& sNickMask, const CString& sChan, CString& sMessage); + bool OnPrivMsg(const CString& sNickMask, CString& sMessage); + bool OnChanMsg(const CString& sNickMask, const CString& sChan, CString& sMessage); + bool OnPrivNotice(const CString& sNickMask, CString& sMessage); + bool OnChanNotice(const CString& sNickMask, const CString& sChan, CString& sMessage); // !Message Handlers - virtual void ReadLine(const string& sData); + virtual void ReadLine(const CString& sData); virtual void Connected(); virtual void Disconnected(); virtual void ConnectionRefused(); @@ -37,23 +37,23 @@ public: bool IsUserAttached() { return (m_pUserSock != NULL); } void UserConnected(CUserSock* pUserSock); void UserDisconnected(); - void PutServ(const string& sLine); - void PutUser(const string& sLine); - void PutStatus(const string& sLine); + void PutServ(const CString& sLine); + void PutUser(const CString& sLine); + void PutStatus(const CString& sLine); // Setters - void SetPass(const string& s) { m_sPass = s; } + void SetPass(const CString& s) { m_sPass = s; } // !Setters // Getters - string GetNickMask() const { + CString GetNickMask() const { return m_Nick.GetNickMask(); } - const string& GetNick() const { return m_Nick.GetNick(); } - const string& GetPass() const { return m_sPass; } + const CString& GetNick() const { return m_Nick.GetNick(); } + const CString& GetPass() const { return m_sPass; } // !Getters private: - void SetNick(const string& sNick); + void SetNick(const CString& sNick); protected: bool m_bISpoofReleased; bool m_bAuthed; @@ -61,11 +61,11 @@ protected: CZNC* m_pZNC; CUser* m_pUser; CNick m_Nick; - string m_sPass; + CString m_sPass; CBuffer m_RawBuffer; CBuffer m_MotdBuffer; CUserSock* m_pUserSock; - map m_msChans; + map m_msChans; unsigned int m_uQueryBufferCount; CBuffer m_QueryBuffer; }; diff --git a/Modules.cpp b/Modules.cpp index 5044d082..6fde74d0 100644 --- a/Modules.cpp +++ b/Modules.cpp @@ -7,7 +7,7 @@ #include "Chan.h" /////////////////// Timer /////////////////// -CTimer::CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const string& sLabel, const string& sDescription) : CCron() { +CTimer::CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) : CCron() { SetName(sLabel); m_sDescription = sDescription; m_pModule = pModule; @@ -24,12 +24,12 @@ CTimer::~CTimer() { } void CTimer::SetModule(CModule* p) { m_pModule = p; } -void CTimer::SetDescription(const string& s) { m_sDescription = s; } +void CTimer::SetDescription(const CString& s) { m_sDescription = s; } CModule* CTimer::GetModule() const { return m_pModule; } -const string& CTimer::GetDescription() const { return m_sDescription; } +const CString& CTimer::GetDescription() const { return m_sDescription; } /////////////////// !Timer /////////////////// -CModule::CModule(void* pDLL, CUser* pUser, const string& sModName) { +CModule::CModule(void* pDLL, CUser* pUser, const CString& sModName) { m_pDLL = pDLL; m_pManager = pUser->GetManager(); m_pUser = pUser; @@ -53,7 +53,7 @@ bool CModule::AddTimer(CTimer* pTimer) { return true; } -bool CModule::RemTimer(const string& sLabel) { +bool CModule::RemTimer(const CString& sLabel) { for (unsigned int a = 0; a < m_vTimers.size(); a++) { CTimer* pTimer = m_vTimers[a]; @@ -78,7 +78,7 @@ bool CModule::UnlinkTimer(CTimer* pTimer) { return false; } -CTimer* CModule::FindTimer(const string& sLabel) { +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) { @@ -114,7 +114,7 @@ void CModule::ListTimers() { if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutModule(sLine); @@ -122,66 +122,66 @@ void CModule::ListTimers() { } } -const string& CModule::GetModName() { return m_sModName; } -string CModule::GetModNick() { return ((m_pUser) ? m_pUser->GetStatusPrefix() : "*") + m_sModName; } +const CString& CModule::GetModName() { return m_sModName; } +CString CModule::GetModNick() { return ((m_pUser) ? m_pUser->GetStatusPrefix() : "*") + m_sModName; } -string CModule::GetDescription() { return "Unknown"; } +CString CModule::GetDescription() { return "Unknown"; } -bool CModule::OnLoad(const string& sArgs) { return true; } +bool CModule::OnLoad(const CString& sArgs) { return true; } bool CModule::OnBoot() { return true; } void CModule::OnUserAttached() {} void CModule::OnUserDetached() {} void CModule::OnIRCDisconnected() {} void CModule::OnIRCConnected() {} -bool CModule::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const string& sFile, unsigned long uFileSize) { return false; } +bool CModule::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) { return false; } void CModule::OnOp(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange) {} void CModule::OnDeop(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange) {} void CModule::OnVoice(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange) {} void CModule::OnDevoice(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange) {} -void CModule::OnRawMode(const CNick& OpNick, const CChan& Channel, const string& sModes, const string& sArgs) {} +void CModule::OnRawMode(const CNick& OpNick, const CChan& Channel, const CString& sModes, const CString& sArgs) {} -bool CModule::OnUserRaw(string& sLine) { return false; } -bool CModule::OnRaw(string& sLine) { return false; } +bool CModule::OnUserRaw(CString& sLine) { return false; } +bool CModule::OnRaw(CString& sLine) { return false; } -bool CModule::OnStatusCommand(const string& sCommand) { return false; } -void CModule::OnModCommand(const string& sCommand) {} -void CModule::OnModNotice(const string& sMessage) {} -void CModule::OnModCTCP(const string& sMessage) {} +bool CModule::OnStatusCommand(const CString& sCommand) { return false; } +void CModule::OnModCommand(const CString& sCommand) {} +void CModule::OnModNotice(const CString& sMessage) {} +void CModule::OnModCTCP(const CString& sMessage) {} -void CModule::OnQuit(const CNick& Nick, const string& sMessage, const vector& vChans) {} -void CModule::OnNick(const CNick& Nick, const string& sNewNick, const vector& vChans) {} -void CModule::OnKick(const CNick& Nick, const string& sKickedNick, const CChan& Channel, const string& sMessage) {} +void CModule::OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) {} +void CModule::OnNick(const CNick& Nick, const CString& sNewNick, const vector& vChans) {} +void CModule::OnKick(const CNick& Nick, const CString& sKickedNick, const CChan& Channel, const CString& sMessage) {} void CModule::OnJoin(const CNick& Nick, const CChan& Channel) {} void CModule::OnPart(const CNick& Nick, const CChan& Channel) {} -bool CModule::OnUserCTCPReply(const CNick& Nick, string& sMessage) { return false; } -bool CModule::OnCTCPReply(const CNick& Nick, string& sMessage) { return false; } -bool CModule::OnUserCTCP(const string& sTarget, string& sMessage) { return false; } -bool CModule::OnPrivCTCP(const CNick& Nick, string& sMessage) { return false; } -bool CModule::OnChanCTCP(const CNick& Nick, const CChan& Channel, string& sMessage) { return false; } -bool CModule::OnUserMsg(const string& sTarget, string& sMessage) { return false; } -bool CModule::OnPrivMsg(const CNick& Nick, string& sMessage) { return false; } -bool CModule::OnChanMsg(const CNick& Nick, const CChan& Channel, string& sMessage) { return false; } -bool CModule::OnUserNotice(const string& sTarget, string& sMessage) { return false; } -bool CModule::OnPrivNotice(const CNick& Nick, string& sMessage) { return false; } -bool CModule::OnChanNotice(const CNick& Nick, const CChan& Channel, string& sMessage) { return false; } +bool CModule::OnUserCTCPReply(const CNick& Nick, CString& sMessage) { return false; } +bool CModule::OnCTCPReply(const CNick& Nick, CString& sMessage) { return false; } +bool CModule::OnUserCTCP(const CString& sTarget, CString& sMessage) { return false; } +bool CModule::OnPrivCTCP(const CNick& Nick, CString& sMessage) { return false; } +bool CModule::OnChanCTCP(const CNick& Nick, const CChan& Channel, CString& sMessage) { return false; } +bool CModule::OnUserMsg(const CString& sTarget, CString& sMessage) { return false; } +bool CModule::OnPrivMsg(const CNick& Nick, CString& sMessage) { return false; } +bool CModule::OnChanMsg(const CNick& Nick, const CChan& Channel, CString& sMessage) { return false; } +bool CModule::OnUserNotice(const CString& sTarget, CString& sMessage) { return false; } +bool CModule::OnPrivNotice(const CNick& Nick, CString& sMessage) { return false; } +bool CModule::OnChanNotice(const CNick& Nick, const CChan& Channel, CString& sMessage) { return false; } void* CModule::GetDLL() { return m_pDLL; } -bool CModule::PutIRC(const string& sLine) { +bool CModule::PutIRC(const CString& sLine) { return (m_pUser) ? m_pUser->PutIRC(sLine) : false; } -bool CModule::PutUser(const string& sLine) { +bool CModule::PutUser(const CString& sLine) { return (m_pUser) ? m_pUser->PutUser(sLine) : false; } -bool CModule::PutStatus(const string& sLine) { +bool CModule::PutStatus(const CString& sLine) { return (m_pUser) ? m_pUser->PutStatus(sLine) : false; } -bool CModule::PutModule(const string& sLine, const string& sIdent, const string& sHost) { +bool CModule::PutModule(const CString& sLine, const CString& sIdent, const CString& sHost) { return (m_pUser) ? m_pUser->PutUser(":" + GetModNick() + "!" + sIdent + "@" + sHost + " PRIVMSG " + m_pUser->GetCurNick() + " :" + sLine) : false; } -bool CModule::PutModNotice(const string& sLine, const string& sIdent, const string& sHost) { +bool CModule::PutModNotice(const CString& sLine, const CString& sIdent, const CString& sHost) { return (m_pUser) ? m_pUser->PutUser(":" + GetModNick() + "!" + sIdent + "@" + sHost + " NOTICE " + m_pUser->GetCurNick() + " :" + sLine) : false; } @@ -190,8 +190,8 @@ CModules::~CModules() {} void CModules::UnloadAll() { while (size()) { - string sRetMsg; - string sModName = (*this)[0]->GetModName(); + CString sRetMsg; + CString sModName = (*this)[0]->GetModName(); UnloadModule(sModName, sRetMsg); } } @@ -202,7 +202,7 @@ void CModules::OnIRCConnected() { } } -bool CModules::OnLoad(const string& sArgs) { +bool CModules::OnLoad(const CString& sArgs) { for (unsigned int a = 0; a < size(); a++) { if (!(*this)[a]->OnLoad(sArgs)) { return false; @@ -240,7 +240,7 @@ void CModules::OnIRCDisconnected() { } } -bool CModules::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const string& sFile, unsigned long uFileSize) { +bool CModules::OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnDCCUserSend(RemoteNick, uLongIP, uPort, sFile, uFileSize)) { return true; @@ -274,13 +274,13 @@ void CModules::OnDevoice(const CNick& OpNick, const CNick& Nick, const CChan& Ch } } -void CModules::OnRawMode(const CNick& OpNick, const CChan& Channel, const string& sModes, const string& sArgs) { +void CModules::OnRawMode(const CNick& OpNick, const CChan& Channel, const CString& sModes, const CString& sArgs) { for (unsigned int a = 0; a < size(); a++) { (*this)[a]->OnRawMode(OpNick, Channel, sModes, sArgs); } } -bool CModules::OnRaw(string& sLine) { +bool CModules::OnRaw(CString& sLine) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnRaw(sLine)) { return true; @@ -290,7 +290,7 @@ bool CModules::OnRaw(string& sLine) { return false; } -bool CModules::OnUserRaw(string& sLine) { +bool CModules::OnUserRaw(CString& sLine) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnUserRaw(sLine)) { return true; @@ -300,19 +300,19 @@ bool CModules::OnUserRaw(string& sLine) { return false; } -void CModules::OnQuit(const CNick& Nick, const string& sMessage, const vector& vChans) { +void CModules::OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) { for (unsigned int a = 0; a < size(); a++) { (*this)[a]->OnQuit(Nick, sMessage, vChans); } } -void CModules::OnNick(const CNick& Nick, const string& sNewNick, const vector& vChans) { +void CModules::OnNick(const CNick& Nick, const CString& sNewNick, const vector& vChans) { for (unsigned int a = 0; a < size(); a++) { (*this)[a]->OnNick(Nick, sNewNick, vChans); } } -void CModules::OnKick(const CNick& Nick, const string& sKickedNick, const CChan& Channel, const string& sMessage) { +void CModules::OnKick(const CNick& Nick, const CString& sKickedNick, const CChan& Channel, const CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { (*this)[a]->OnKick(Nick, sKickedNick, Channel, sMessage); } @@ -330,7 +330,7 @@ void CModules::OnPart(const CNick& Nick, const CChan& Channel) { } } -bool CModules::OnUserCTCP(const string& sTarget, string& sMessage) { +bool CModules::OnUserCTCP(const CString& sTarget, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnUserCTCP(sTarget, sMessage)) { return true; @@ -340,7 +340,7 @@ bool CModules::OnUserCTCP(const string& sTarget, string& sMessage) { return false; } -bool CModules::OnUserCTCPReply(const CNick& Nick, string& sMessage) { +bool CModules::OnUserCTCPReply(const CNick& Nick, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnUserCTCPReply(Nick, sMessage)) { return true; @@ -350,7 +350,7 @@ bool CModules::OnUserCTCPReply(const CNick& Nick, string& sMessage) { return false; } -bool CModules::OnCTCPReply(const CNick& Nick, string& sMessage) { +bool CModules::OnCTCPReply(const CNick& Nick, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnCTCPReply(Nick, sMessage)) { return true; @@ -360,7 +360,7 @@ bool CModules::OnCTCPReply(const CNick& Nick, string& sMessage) { return false; } -bool CModules::OnPrivCTCP(const CNick& Nick, string& sMessage) { +bool CModules::OnPrivCTCP(const CNick& Nick, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnPrivCTCP(Nick, sMessage)) { return true; @@ -370,7 +370,7 @@ bool CModules::OnPrivCTCP(const CNick& Nick, string& sMessage) { return false; } -bool CModules::OnChanCTCP(const CNick& Nick, const CChan& Channel, string& sMessage) { +bool CModules::OnChanCTCP(const CNick& Nick, const CChan& Channel, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnChanCTCP(Nick, Channel, sMessage)) { return true; @@ -380,7 +380,7 @@ bool CModules::OnChanCTCP(const CNick& Nick, const CChan& Channel, string& sMess return false; } -bool CModules::OnUserMsg(const string& sTarget, string& sMessage) { +bool CModules::OnUserMsg(const CString& sTarget, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnUserMsg(sTarget, sMessage)) { return true; @@ -390,7 +390,7 @@ bool CModules::OnUserMsg(const string& sTarget, string& sMessage) { return false; } -bool CModules::OnPrivMsg(const CNick& Nick, string& sMessage) { +bool CModules::OnPrivMsg(const CNick& Nick, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnPrivMsg(Nick, sMessage)) { return true; @@ -400,7 +400,7 @@ bool CModules::OnPrivMsg(const CNick& Nick, string& sMessage) { return false; } -bool CModules::OnChanMsg(const CNick& Nick, const CChan& Channel, string& sMessage) { +bool CModules::OnChanMsg(const CNick& Nick, const CChan& Channel, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnChanMsg(Nick, Channel, sMessage)) { return true; @@ -410,7 +410,7 @@ bool CModules::OnChanMsg(const CNick& Nick, const CChan& Channel, string& sMessa return false; } -bool CModules::OnUserNotice(const string& sTarget, string& sMessage) { +bool CModules::OnUserNotice(const CString& sTarget, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnUserNotice(sTarget, sMessage)) { return true; @@ -420,7 +420,7 @@ bool CModules::OnUserNotice(const string& sTarget, string& sMessage) { return false; } -bool CModules::OnPrivNotice(const CNick& Nick, string& sMessage) { +bool CModules::OnPrivNotice(const CNick& Nick, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnPrivNotice(Nick, sMessage)) { return true; @@ -430,7 +430,7 @@ bool CModules::OnPrivNotice(const CNick& Nick, string& sMessage) { return false; } -bool CModules::OnChanNotice(const CNick& Nick, const CChan& Channel, string& sMessage) { +bool CModules::OnChanNotice(const CNick& Nick, const CChan& Channel, CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnChanNotice(Nick, Channel, sMessage)) { return true; @@ -440,7 +440,7 @@ bool CModules::OnChanNotice(const CNick& Nick, const CChan& Channel, string& sMe return false; } -bool CModules::OnStatusCommand(const string& sCommand) { +bool CModules::OnStatusCommand(const CString& sCommand) { for (unsigned int a = 0; a < size(); a++) { if ((*this)[a]->OnStatusCommand(sCommand)) { return true; @@ -450,25 +450,25 @@ bool CModules::OnStatusCommand(const string& sCommand) { return false; } -void CModules::OnModCommand(const string& sCommand) { +void CModules::OnModCommand(const CString& sCommand) { for (unsigned int a = 0; a < size(); a++) { (*this)[a]->OnModCommand(sCommand); } } -void CModules::OnModNotice(const string& sMessage) { +void CModules::OnModNotice(const CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { (*this)[a]->OnModNotice(sMessage); } } -void CModules::OnModCTCP(const string& sMessage) { +void CModules::OnModCTCP(const CString& sMessage) { for (unsigned int a = 0; a < size(); a++) { (*this)[a]->OnModCTCP(sMessage); } } -CModule* CModules::FindModule(const string& sModule) { +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) { return (*this)[a]; @@ -478,7 +478,7 @@ CModule* CModules::FindModule(const string& sModule) { return NULL; } -bool CModules::LoadModule(const string& sModule, const string& sArgs, CUser* pUser, string& sRetMsg) { +bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) { #ifndef _MODULES sRetMsg = "Unable to load module [" + sModule + "] module support was not enabled."; return false; @@ -502,7 +502,7 @@ bool CModules::LoadModule(const string& sModule, const string& sArgs, CUser* pUs return false; } - string sModPath = pUser->GetCurPath() + "/modules/" + sModule + ".so"; + CString sModPath = pUser->GetCurPath() + "/modules/" + sModule + ".so"; if (!CFile::Exists(sModPath)) { DEBUG_ONLY(cout << "[" << sModPath << "] Not found..." << endl); @@ -511,7 +511,7 @@ bool CModules::LoadModule(const string& sModule, const string& sArgs, CUser* pUs if (!CFile::Exists(sModPath)) { DEBUG_ONLY(cout << "[" << sModPath << "] Not found..." << endl); - sModPath = _MODDIR_ + string("/") + sModule + ".so"; + sModPath = _MODDIR_ + CString("/") + sModule + ".so"; if (!CFile::Exists(sModPath)) { @@ -545,7 +545,7 @@ bool CModules::LoadModule(const string& sModule, const string& sArgs, CUser* pUs return false; } - typedef CModule* (*fp)(void*, CUser* pUser, const string& sModName); + typedef CModule* (*fp)(void*, CUser* pUser, const CString& sModName); fp Load = (fp) dlsym(p, "Load"); if (!Load) { @@ -568,7 +568,7 @@ bool CModules::LoadModule(const string& sModule, const string& sArgs, CUser* pUs #endif // !_MODULES } -bool CModules::UnloadModule(const string& sModule, string& sRetMsg) { +bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) { #ifndef _MODULES sRetMsg = "Unable to unload module [" + sModule + "] module support was not enabled."; return false; @@ -612,7 +612,7 @@ bool CModules::UnloadModule(const string& sModule, string& sRetMsg) { #endif // !_MODULES } -bool CModules::ReloadModule(const string& sModule, const string& sArgs, CUser* pUser, string& sRetMsg) { +bool CModules::ReloadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) { sRetMsg = ""; if (!UnloadModule(sModule, sRetMsg)) { return false; diff --git a/Modules.h b/Modules.h index 3950bd41..2e14fbb5 100644 --- a/Modules.h +++ b/Modules.h @@ -3,14 +3,12 @@ #include "main.h" #include -#include #include using std::vector; -using std::string; #define VERSION 0.034 -#define MODULEDEFS(CLASS) extern "C" { CModule* Load(void* p, CUser* pUser, const string& sModName); void Unload(CModule* pMod); double GetVersion(); } double GetVersion() { return VERSION; } CModule* Load(void* p, CUser* pUser, const string& sModName) { return new CLASS(p, pUser, sModName); } void Unload(CModule* pMod) { if (pMod) { delete pMod; } } -#define MODCONSTRUCTOR(CLASS) CLASS(void *pDLL, CUser* pUser, const string& sModName) : CModule(pDLL, pUser, sModName) +#define MODULEDEFS(CLASS) extern "C" { CModule* Load(void* p, CUser* pUser, const CString& sModName); void Unload(CModule* pMod); double GetVersion(); } double GetVersion() { return VERSION; } CModule* Load(void* p, CUser* pUser, const CString& sModName) { return new CLASS(p, pUser, sModName); } void Unload(CModule* pMod) { if (pMod) { delete pMod; } } +#define MODCONSTRUCTOR(CLASS) CLASS(void *pDLL, CUser* pUser, const CString& sModName) : CModule(pDLL, pUser, sModName) // Forward Declarations class CZNC; @@ -24,29 +22,29 @@ template class TSocketManager; class CTimer : public CCron { public: - CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const string& sLabel, const string& sDescription); + CTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription); virtual ~CTimer(); // Setters void SetModule(CModule* p); - void SetDescription(const string& s); + void SetDescription(const CString& s); // !Setters // Getters CModule* GetModule() const; - const string& GetDescription() const; + const CString& GetDescription() const; // !Getters private: protected: CModule* m_pModule; - string m_sDescription; + CString m_sDescription; }; class CModInfo { public: - CModInfo(const string& sName, const string& sPath, bool bSystem) { + CModInfo(const CString& sName, const CString& sPath, bool bSystem) { m_bSystem = bSystem; m_sName = sName; m_sPath = sPath; @@ -58,82 +56,82 @@ public: } // Getters - const string& GetName() const { return m_sName; } - const string& GetPath() const { return m_sPath; } + const CString& GetName() const { return m_sName; } + const CString& GetPath() const { return m_sPath; } bool IsSystem() const { return m_bSystem; } // !Getters private: protected: bool m_bSystem; - string m_sName; - string m_sPath; + CString m_sName; + CString m_sPath; }; class CModule { public: - CModule(void* pDLL, CUser* pUser, const string& sModName); + CModule(void* pDLL, CUser* pUser, const CString& sModName); virtual ~CModule(); - virtual string GetDescription(); + virtual CString GetDescription(); - virtual bool OnLoad(const string& sArgs); + virtual bool OnLoad(const CString& sArgs); virtual bool OnBoot(); virtual void OnUserAttached(); virtual void OnUserDetached(); virtual void OnIRCDisconnected(); virtual void OnIRCConnected(); - virtual bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const string& sFile, unsigned long uFileSize); + virtual bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize); virtual void OnOp(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); virtual void OnDeop(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); virtual void OnVoice(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); virtual void OnDevoice(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); - virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const string& sModes, const string& sArgs); + virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const CString& sModes, const CString& sArgs); - virtual bool OnUserRaw(string& sLine); - virtual bool OnRaw(string& sLine); + virtual bool OnUserRaw(CString& sLine); + virtual bool OnRaw(CString& sLine); - virtual bool OnStatusCommand(const string& sCommand); - virtual void OnModCommand(const string& sCommand); - virtual void OnModNotice(const string& sMessage); - virtual void OnModCTCP(const string& sMessage); + virtual bool OnStatusCommand(const CString& sCommand); + virtual void OnModCommand(const CString& sCommand); + virtual void OnModNotice(const CString& sMessage); + virtual void OnModCTCP(const CString& sMessage); - virtual void OnQuit(const CNick& Nick, const string& sMessage, const vector& vChans); - virtual void OnNick(const CNick& Nick, const string& sNewNick, const vector& vChans); - virtual void OnKick(const CNick& Nick, const string& sOpNick, const CChan& Channel, const string& sMessage); + virtual void OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans); + virtual void OnNick(const CNick& Nick, const CString& sNewNick, const vector& vChans); + virtual void OnKick(const CNick& Nick, const CString& sOpNick, const CChan& Channel, const CString& sMessage); virtual void OnJoin(const CNick& Nick, const CChan& Channel); virtual void OnPart(const CNick& Nick, const CChan& Channel); - virtual bool OnUserCTCPReply(const CNick& Nick, string& sMessage); - virtual bool OnCTCPReply(const CNick& Nick, string& sMessage); - virtual bool OnUserCTCP(const string& sTarget, string& sMessage); - virtual bool OnPrivCTCP(const CNick& Nick, string& sMessage); - virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, string& sMessage); - virtual bool OnUserMsg(const string& sTarget, string& sMessage); - virtual bool OnPrivMsg(const CNick& Nick, string& sMessage); - virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, string& sMessage); - virtual bool OnUserNotice(const string& sTarget, string& sMessage); - virtual bool OnPrivNotice(const CNick& Nick, string& sMessage); - virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, string& sMessage); + virtual bool OnUserCTCPReply(const CNick& Nick, CString& sMessage); + virtual bool OnCTCPReply(const CNick& Nick, CString& sMessage); + virtual bool OnUserCTCP(const CString& sTarget, CString& sMessage); + virtual bool OnPrivCTCP(const CNick& Nick, CString& sMessage); + virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, CString& sMessage); + virtual bool OnUserMsg(const CString& sTarget, CString& sMessage); + virtual bool OnPrivMsg(const CNick& Nick, CString& sMessage); + virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, CString& sMessage); + virtual bool OnUserNotice(const CString& sTarget, CString& sMessage); + virtual bool OnPrivNotice(const CNick& Nick, CString& sMessage); + virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, CString& sMessage); void * GetDLL(); static double GetVersion() { return VERSION; } - virtual bool PutIRC(const string& sLine); - virtual bool PutUser(const string& sLine); - virtual bool PutStatus(const string& sLine); - virtual bool PutModule(const string& sLine, const string& sIdent = "znc", const string& sHost = "znc.com"); - virtual bool PutModNotice(const string& sLine, const string& sIdent = "znc", const string& sHost = "znc.com"); + virtual bool PutIRC(const CString& sLine); + virtual bool PutUser(const CString& sLine); + virtual bool PutStatus(const CString& sLine); + virtual bool PutModule(const CString& sLine, const CString& sIdent = "znc", const CString& sHost = "znc.com"); + virtual bool PutModNotice(const CString& sLine, const CString& sIdent = "znc", const CString& sHost = "znc.com"); - const string& GetModName(); - string GetModNick(); + const CString& GetModName(); + CString GetModNick(); // Timer stuff bool AddTimer(CTimer* pTimer); - bool RemTimer(const string& sLabel); + bool RemTimer(const CString& sLabel); bool UnlinkTimer(CTimer* pTimer); - CTimer* FindTimer(const string& sLabel); + CTimer* FindTimer(const CString& sLabel); virtual void ListTimers(); // !Timer stuff @@ -142,7 +140,7 @@ protected: void* m_pDLL; TSocketManager* m_pManager; CUser* m_pUser; - string m_sModName; + CString m_sModName; }; class CModules : public vector { @@ -152,51 +150,51 @@ public: void UnloadAll(); - virtual bool OnLoad(const string& sArgs); + virtual bool OnLoad(const CString& sArgs); virtual bool OnBoot(); virtual void OnUserAttached(); virtual void OnUserDetached(); virtual void OnIRCDisconnected(); virtual void OnIRCConnected(); - virtual bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const string& sFile, unsigned long uFileSize); + virtual bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize); virtual void OnOp(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); virtual void OnDeop(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); virtual void OnVoice(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); virtual void OnDevoice(const CNick& OpNick, const CNick& Nick, const CChan& Channel, bool bNoChange); - virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const string& sModes, const string& sArgs); + virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const CString& sModes, const CString& sArgs); - virtual bool OnUserRaw(string& sLine); - virtual bool OnRaw(string& sLine); + virtual bool OnUserRaw(CString& sLine); + virtual bool OnRaw(CString& sLine); - virtual bool OnStatusCommand(const string& sCommand); - virtual void OnModCommand(const string& sCommand); - virtual void OnModNotice(const string& sMessage); - virtual void OnModCTCP(const string& sMessage); + virtual bool OnStatusCommand(const CString& sCommand); + virtual void OnModCommand(const CString& sCommand); + virtual void OnModNotice(const CString& sMessage); + virtual void OnModCTCP(const CString& sMessage); - virtual void OnQuit(const CNick& Nick, const string& sMessage, const vector& vChans); - virtual void OnNick(const CNick& Nick, const string& sNewNick, const vector& vChans); - virtual void OnKick(const CNick& Nick, const string& sOpNick, const CChan& Channel, const string& sMessage); + virtual void OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans); + virtual void OnNick(const CNick& Nick, const CString& sNewNick, const vector& vChans); + virtual void OnKick(const CNick& Nick, const CString& sOpNick, const CChan& Channel, const CString& sMessage); virtual void OnJoin(const CNick& Nick, const CChan& Channel); virtual void OnPart(const CNick& Nick, const CChan& Channel); - virtual bool OnUserCTCPReply(const CNick& Nick, string& sMessage); - virtual bool OnCTCPReply(const CNick& Nick, string& sMessage); - virtual bool OnUserCTCP(const string& sTarget, string& sMessage); - virtual bool OnPrivCTCP(const CNick& Nick, string& sMessage); - virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, string& sMessage); - virtual bool OnUserMsg(const string& sTarget, string& sMessage); - virtual bool OnPrivMsg(const CNick& Nick, string& sMessage); - virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, string& sMessage); - virtual bool OnUserNotice(const string& sTarget, string& sMessage); - virtual bool OnPrivNotice(const CNick& Nick, string& sMessage); - virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, string& sMessage); + virtual bool OnUserCTCPReply(const CNick& Nick, CString& sMessage); + virtual bool OnCTCPReply(const CNick& Nick, CString& sMessage); + virtual bool OnUserCTCP(const CString& sTarget, CString& sMessage); + virtual bool OnPrivCTCP(const CNick& Nick, CString& sMessage); + virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, CString& sMessage); + virtual bool OnUserMsg(const CString& sTarget, CString& sMessage); + virtual bool OnPrivMsg(const CNick& Nick, CString& sMessage); + virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, CString& sMessage); + virtual bool OnUserNotice(const CString& sTarget, CString& sMessage); + virtual bool OnPrivNotice(const CNick& Nick, CString& sMessage); + virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, CString& sMessage); - CModule* FindModule(const string& sModule); - bool LoadModule(const string& sModule, const string& sArgs, CUser* pUser, string& sRetMsg); - bool UnloadModule(const string& sModule, string& sRetMsg); - bool ReloadModule(const string& sModule, const string& sArgs, CUser* pUser, string& sRetMsg); + CModule* FindModule(const CString& sModule); + bool LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg); + bool UnloadModule(const CString& sModule, CString& sRetMsg); + bool ReloadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg); static void GetAvailableMods(set& ssMods, CZNC* pZNC); }; diff --git a/Nick.cpp b/Nick.cpp index 28b23ce9..5d429ff8 100644 --- a/Nick.cpp +++ b/Nick.cpp @@ -7,7 +7,7 @@ CNick::CNick() { m_bIsVoice = false; } -CNick::CNick(const string& sNick) { +CNick::CNick(const CString& sNick) { Parse(sNick); m_bIsOp = false; m_bIsVoice = false; @@ -15,14 +15,14 @@ CNick::CNick(const string& sNick) { CNick::~CNick() {} -void CNick::Parse(const string& sNickMask) { +void CNick::Parse(const CString& sNickMask) { if (sNickMask.empty()) { return; } - string::size_type uPos = sNickMask.find('!'); + CString::size_type uPos = sNickMask.find('!'); - if (uPos == string::npos) { + if (uPos == CString::npos) { m_sNick = sNickMask.substr((sNickMask[0] == ':')); return; } @@ -30,7 +30,7 @@ void CNick::Parse(const string& sNickMask) { m_sNick = sNickMask.substr((sNickMask[0] == ':'), uPos); m_sHost = sNickMask.substr(uPos +1); - if ((uPos = m_sHost.find('@')) != string::npos) { + if ((uPos = m_sHost.find('@')) != CString::npos) { m_sIdent = m_sHost.substr(0, uPos); m_sHost = m_sHost.substr(uPos +1); } @@ -43,9 +43,9 @@ unsigned int CNick::GetCommonChans(vector& vRetChans, CUser* pUser) cons for (unsigned int a = 0; a < vChans.size(); a++) { CChan* pChan = vChans[a]; - const map& msNicks = pChan->GetNicks(); + const map& msNicks = pChan->GetNicks(); - for (map::const_iterator it = msNicks.begin(); it != msNicks.end(); it++) { + for (map::const_iterator it = msNicks.begin(); it != msNicks.end(); it++) { if (strcasecmp(it->first.c_str(), m_sNick.c_str()) == 0) { vRetChans.push_back(pChan); continue; @@ -56,21 +56,21 @@ unsigned int CNick::GetCommonChans(vector& vRetChans, CUser* pUser) cons return vRetChans.size(); } -void CNick::SetNick(const string& s) { m_sNick = s; } -void CNick::SetIdent(const string& s) { m_sIdent = s; } -void CNick::SetHost(const string& s) { m_sHost = s; } +void CNick::SetNick(const CString& s) { m_sNick = s; } +void CNick::SetIdent(const CString& s) { m_sIdent = s; } +void CNick::SetHost(const CString& s) { m_sHost = s; } void CNick::SetOp(bool b) { m_bIsOp = b; } void CNick::SetVoice(bool b) { m_bIsVoice = b; } bool CNick::IsOp() const { return m_bIsOp; } bool CNick::IsVoice() const { return m_bIsVoice; } -const string& CNick::GetNick() const { return m_sNick; } -const string& CNick::GetIdent() const { return m_sIdent; } -const string& CNick::GetHost() const { return m_sHost; } -string CNick::GetNickMask() const { return m_sNick + "!" + m_sIdent + "@" + m_sHost; } +const CString& CNick::GetNick() const { return m_sNick; } +const CString& CNick::GetIdent() const { return m_sIdent; } +const CString& CNick::GetHost() const { return m_sHost; } +CString CNick::GetNickMask() const { return m_sNick + "!" + m_sIdent + "@" + m_sHost; } -string CNick::GetHostMask() const { - string sRet = m_sNick; +CString CNick::GetHostMask() const { + CString sRet = m_sNick; if (!m_sIdent.empty()) { sRet += "!" + m_sIdent; diff --git a/Nick.h b/Nick.h index 5edfc607..7d6ded8d 100644 --- a/Nick.h +++ b/Nick.h @@ -2,8 +2,7 @@ #define _NICK_H #include -#include -using std::string; +#include "String.h" using std::vector; // Forward Decl @@ -15,17 +14,17 @@ class CNick { public: CNick(); - CNick(const string& sNick); + CNick(const CString& sNick); virtual ~CNick(); - void Parse(const string& sNickMask); - string GetHostMask() const; + void Parse(const CString& sNickMask); + CString GetHostMask() const; unsigned int GetCommonChans(vector& vChans, CUser* pUser) const; // Setters - void SetNick(const string& s); - void SetIdent(const string& s); - void SetHost(const string& s); + void SetNick(const CString& s); + void SetIdent(const CString& s); + void SetHost(const CString& s); void SetOp(bool b); void SetVoice(bool b); // !Setters @@ -33,16 +32,16 @@ public: // Getters bool IsOp() const; bool IsVoice() const; - const string& GetNick() const; - const string& GetIdent() const; - const string& GetHost() const; - string GetNickMask() const; + const CString& GetNick() const; + const CString& GetIdent() const; + const CString& GetHost() const; + CString GetNickMask() const; // !Getters private: protected: - string m_sNick; - string m_sIdent; - string m_sHost; + CString m_sNick; + CString m_sIdent; + CString m_sHost; bool m_bIsOp; bool m_bIsVoice; diff --git a/Server.cpp b/Server.cpp index f2d2dfbb..bbdccd26 100644 --- a/Server.cpp +++ b/Server.cpp @@ -1,7 +1,7 @@ #include "main.h" #include "Server.h" -CServer::CServer(const string& sName, unsigned short uPort, const string& sPass, bool bSSL) { +CServer::CServer(const CString& sName, unsigned short uPort, const CString& sPass, bool bSSL) { m_sName = sName; m_uPort = (uPort) ? uPort : 6667; m_sPass = sPass; @@ -10,7 +10,7 @@ CServer::CServer(const string& sName, unsigned short uPort, const string& sPass, CServer::~CServer() {} -bool CServer::IsValidHostName(const string& sHostName) { +bool CServer::IsValidHostName(const CString& sHostName) { const char* p = sHostName.c_str(); if (sHostName.empty()) { @@ -26,8 +26,8 @@ bool CServer::IsValidHostName(const string& sHostName) { return true; } -const string& CServer::GetName() const { return m_sName; } +const CString& CServer::GetName() const { return m_sName; } unsigned short CServer::GetPort() const { return m_uPort; } -const string& CServer::GetPass() const { return m_sPass; } +const CString& CServer::GetPass() const { return m_sPass; } bool CServer::IsSSL() const { return m_bSSL; } diff --git a/Server.h b/Server.h index b3c843f1..df491ea9 100644 --- a/Server.h +++ b/Server.h @@ -1,23 +1,23 @@ #ifndef _SERVER_H #define _SERVER_H -#include +#include "String.h" class CServer { public: - CServer(const string& sName, unsigned short uPort = 6667, const string& sPass = "", bool bSSL = false); + CServer(const CString& sName, unsigned short uPort = 6667, const CString& sPass = "", bool bSSL = false); virtual ~CServer(); - const string& GetName() const; + const CString& GetName() const; unsigned short GetPort() const; - const string& GetPass() const; + const CString& GetPass() const; bool IsSSL() const; - static bool IsValidHostName(const string& sHostName); + static bool IsValidHostName(const CString& sHostName); private: protected: - string m_sName; + CString m_sName; unsigned short m_uPort; - string m_sPass; + CString m_sPass; bool m_bSSL; }; diff --git a/User.cpp b/User.cpp index 47a2d866..696d527b 100644 --- a/User.cpp +++ b/User.cpp @@ -9,7 +9,7 @@ #include "md5.h" #include "Timers.h" -CUser::CUser(const string& sUserName, CZNC* pZNC) { +CUser::CUser(const CString& sUserName, CZNC* pZNC) { m_sUserName = sUserName; m_sNick = sUserName; m_sIdent = sUserName; @@ -47,7 +47,7 @@ bool CUser::OnBoot() { return true; } -bool CUser::AddAllowedHost(const string& sHostMask) { +bool CUser::AddAllowedHost(const CString& sHostMask) { if (m_ssAllowedHosts.find(sHostMask) != m_ssAllowedHosts.end()) { return false; } @@ -56,12 +56,12 @@ bool CUser::AddAllowedHost(const string& sHostMask) { return true; } -bool CUser::IsHostAllowed(const string& sHostMask) { +bool CUser::IsHostAllowed(const CString& sHostMask) { if (m_ssAllowedHosts.empty()) { return true; } - for (set::iterator a = m_ssAllowedHosts.begin(); a != m_ssAllowedHosts.end(); a++) { + for (set::iterator a = m_ssAllowedHosts.begin(); a != m_ssAllowedHosts.end(); a++) { if (CUtils::wildcmp(*a, sHostMask)) { return true; } @@ -70,7 +70,7 @@ bool CUser::IsHostAllowed(const string& sHostMask) { return false; } -bool CUser::IsValidUserName(const string& sUserName) { +bool CUser::IsValidUserName(const CString& sUserName) { const char* p = sUserName.c_str(); if (sUserName.empty()) { @@ -86,7 +86,7 @@ bool CUser::IsValidUserName(const string& sUserName) { return true; } -bool CUser::IsValid(string& sErrMsg) { +bool CUser::IsValid(CString& sErrMsg) { sErrMsg.clear(); if (m_sPass.empty()) { @@ -123,7 +123,7 @@ bool CUser::AddChan(CChan* pChan) { return true; } -bool CUser::AddChan(const string& sName) { +bool CUser::AddChan(const CString& sName) { if (sName.empty()) { return false; } @@ -139,7 +139,7 @@ bool CUser::AddChan(const string& sName) { return true; } -bool CUser::DelChan(const string& 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) { m_vChans.erase(a); @@ -150,7 +150,7 @@ bool CUser::DelChan(const string& sName) { return false; } -CChan* CUser::FindChan(const string& 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) { @@ -161,7 +161,7 @@ CChan* CUser::FindChan(const string& sName) { return NULL; } -CServer* CUser::FindServer(const string& 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) { @@ -172,7 +172,7 @@ CServer* CUser::FindServer(const string& sName) { return NULL; } -bool CUser::DelServer(const string& sName) { +bool CUser::DelServer(const CString& sName) { if (sName.empty()) { return false; } @@ -187,17 +187,17 @@ bool CUser::DelServer(const string& sName) { return false; } -bool CUser::AddServer(const string& sName) { +bool CUser::AddServer(const CString& sName) { if (sName.empty()) { return false; } bool bSSL = false; - string sLine = sName; + CString sLine = sName; CUtils::Trim(sLine); - string sHost = CUtils::Token(sLine, 0); - string sPort = CUtils::Token(sLine, 1); + CString sHost = CUtils::Token(sLine, 0); + CString sPort = CUtils::Token(sLine, 1); if (CUtils::Left(sPort, 1) == "+") { bSSL = true; @@ -205,12 +205,12 @@ bool CUser::AddServer(const string& sName) { } unsigned short uPort = strtoul(sPort.c_str(), NULL, 10); - string sPass = CUtils::Token(sLine, 2, true); + CString sPass = CUtils::Token(sLine, 2, true); return AddServer(sHost, uPort, sPass, bSSL); } -bool CUser::AddServer(const string& sName, unsigned short uPort, const string& sPass, bool bSSL) { +bool CUser::AddServer(const CString& sName, unsigned short uPort, const CString& sPass, bool bSSL) { #ifndef HAVE_LIBSSL if (bSSL) { return false; @@ -242,7 +242,7 @@ CServer* CUser::GetNextServer() { return m_vServers[m_uServerIdx++]; // Todo: cycle through these } -bool CUser::CheckPass(const string& sPass) { +bool CUser::CheckPass(const CString& sPass) { if (!m_bPassHashed) { return (sPass == m_sPass); } @@ -261,7 +261,7 @@ CZNC* CUser::GetZNC() { CUserSock* CUser::GetUserSock() { // Todo: optimize this by saving a pointer to the sock TSocketManager& Manager = m_pZNC->GetManager(); - string sSockName = "USR::" + m_sUserName; + CString sSockName = "USR::" + m_sUserName; for (unsigned int a = 0; a < Manager.size(); a++) { Csock* pSock = Manager[a]; @@ -290,7 +290,7 @@ CIRCSock* CUser::GetIRCSock() { return (CIRCSock*) m_pZNC->GetManager().FindSockByName("IRC::" + m_sUserName); } -string CUser::GetLocalIP() { +CString CUser::GetLocalIP() { CIRCSock* pIRCSock = GetIRCSock(); if (pIRCSock) { @@ -306,7 +306,7 @@ string CUser::GetLocalIP() { return ""; } -bool CUser::PutIRC(const string& sLine) { +bool CUser::PutIRC(const CString& sLine) { CIRCSock* pIRCSock = GetIRCSock(); if (!pIRCSock) { @@ -317,7 +317,7 @@ bool CUser::PutIRC(const string& sLine) { return true; } -bool CUser::PutUser(const string& sLine) { +bool CUser::PutUser(const CString& sLine) { CUserSock* pUserSock = GetUserSock(); if (!pUserSock) { @@ -328,7 +328,7 @@ bool CUser::PutUser(const string& sLine) { return true; } -bool CUser::PutStatus(const string& sLine) { +bool CUser::PutStatus(const CString& sLine) { CUserSock* pUserSock = GetUserSock(); if (!pUserSock) { @@ -339,7 +339,7 @@ bool CUser::PutStatus(const string& sLine) { return true; } -bool CUser::PutModule(const string& sModule, const string& sLine) { +bool CUser::PutModule(const CString& sModule, const CString& sLine) { CUserSock* pUserSock = GetUserSock(); if (!pUserSock) { @@ -350,7 +350,7 @@ bool CUser::PutModule(const string& sModule, const string& sLine) { return true; } -bool CUser::ResumeFile(const string& sRemoteNick, unsigned short uPort, unsigned long uFileSize) { +bool CUser::ResumeFile(const CString& sRemoteNick, unsigned short uPort, unsigned long uFileSize) { TSocketManager& Manager = m_pZNC->GetManager(); for (unsigned int a = 0; a < Manager.size(); a++) { @@ -371,8 +371,8 @@ bool CUser::ResumeFile(const string& sRemoteNick, unsigned short uPort, unsigned return false; } -bool CUser::SendFile(const string& sRemoteNick, const string& sFileName, const string& sModuleName) { - string sFullPath = CUtils::ChangeDir(GetDLPath(), sFileName, GetHomePath()); +bool CUser::SendFile(const CString& sRemoteNick, const CString& sFileName, const CString& sModuleName) { + CString sFullPath = CUtils::ChangeDir(GetDLPath(), sFileName, GetHomePath()); CDCCSock* pSock = new CDCCSock(this, sRemoteNick, sFullPath, sModuleName); CFile* pFile = pSock->OpenFile(false); @@ -396,7 +396,7 @@ bool CUser::SendFile(const string& sRemoteNick, const string& sFileName, const s return true; } -bool CUser::GetFile(const string& sRemoteNick, const string& sRemoteIP, unsigned short uRemotePort, const string& sFileName, unsigned long uFileSize, const string& sModuleName) { +bool CUser::GetFile(const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sFileName, unsigned long uFileSize, const CString& sModuleName) { if (CFile::Exists(sFileName)) { PutModule(sModuleName, "DCC <- [" + sRemoteNick + "][" + sFileName + "] - File already exists."); return false; @@ -418,7 +418,7 @@ bool CUser::GetFile(const string& sRemoteNick, const string& sRemoteIP, unsigned return true; } -string CUser::GetCurNick() { +CString CUser::GetCurNick() { CIRCSock* pIRCSock = GetIRCSock(); if (pIRCSock) { @@ -435,25 +435,25 @@ string CUser::GetCurNick() { } // Setters -void CUser::SetNick(const string& s) { m_sNick = s; } -void CUser::SetAltNick(const string& s) { m_sAltNick = s; } -void CUser::SetIdent(const string& s) { m_sIdent = s; } -void CUser::SetRealName(const string& s) { m_sRealName = s; } -void CUser::SetVHost(const string& s) { m_sVHost = s; } -void CUser::SetPass(const string& s, bool bHashed) { m_sPass = s; m_bPassHashed = bHashed; } +void CUser::SetNick(const CString& s) { m_sNick = s; } +void CUser::SetAltNick(const CString& s) { m_sAltNick = s; } +void CUser::SetIdent(const CString& s) { m_sIdent = s; } +void CUser::SetRealName(const CString& s) { m_sRealName = s; } +void CUser::SetVHost(const CString& s) { m_sVHost = s; } +void CUser::SetPass(const CString& s, bool bHashed) { m_sPass = s; m_bPassHashed = bHashed; } void CUser::SetUseClientIP(bool b) { m_bUseClientIP = b; } void CUser::SetKeepNick(bool b) { m_bKeepNick = b; } void CUser::SetDenyLoadMod(bool b) { m_bDenyLoadMod = b; } -void CUser::SetDefaultChanModes(const string& s) { m_sDefaultChanModes = s; } +void CUser::SetDefaultChanModes(const CString& s) { m_sDefaultChanModes = s; } void CUser::SetIRCNick(const CNick& n) { m_IRCNick = n; } -void CUser::SetIRCServer(const string& s) { m_sIRCServer = s; } -void CUser::SetQuitMsg(const string& s) { m_sQuitMsg = s; } -void CUser::SetVersionReply(const string& s) { m_sVersionReply = s; } +void CUser::SetIRCServer(const CString& s) { m_sIRCServer = s; } +void CUser::SetQuitMsg(const CString& s) { m_sQuitMsg = s; } +void CUser::SetVersionReply(const CString& s) { m_sVersionReply = s; } void CUser::SetBufferCount(unsigned int u) { m_uBufferCount = u; } void CUser::SetKeepBuffer(bool b) { m_bKeepBuffer = b; } -bool CUser::SetStatusPrefix(const string& s) { - if ((!s.empty()) && (s.length() < 6) && (s.find(' ') == string::npos)) { +bool CUser::SetStatusPrefix(const CString& s) { + if ((!s.empty()) && (s.length() < 6) && (s.find(' ') == CString::npos)) { m_sStatusPrefix = s; return true; } @@ -463,32 +463,32 @@ bool CUser::SetStatusPrefix(const string& s) { // !Setters // Getters -const string& CUser::GetUserName() const { return m_sUserName; } -const string& CUser::GetNick() const { return m_sNick; } -const string& CUser::GetAltNick() const { return m_sAltNick; } -const string& CUser::GetIdent() const { return m_sIdent; } -const string& CUser::GetRealName() const { return m_sRealName; } -const string& CUser::GetVHost() const { return m_sVHost; } -const string& CUser::GetPass() const { return m_sPass; } +const CString& CUser::GetUserName() const { return m_sUserName; } +const CString& CUser::GetNick() const { return m_sNick; } +const CString& CUser::GetAltNick() const { return m_sAltNick; } +const CString& CUser::GetIdent() const { return m_sIdent; } +const CString& CUser::GetRealName() const { return m_sRealName; } +const CString& CUser::GetVHost() const { return m_sVHost; } +const CString& CUser::GetPass() const { return m_sPass; } -const string& CUser::GetCurPath() const { return m_pZNC->GetCurPath(); } -const string& CUser::GetDLPath() const { return m_pZNC->GetDLPath(); } -const string& CUser::GetModPath() const { return m_pZNC->GetModPath(); } -const string& CUser::GetHomePath() const { return m_pZNC->GetHomePath(); } -const string& CUser::GetDataPath() const { return m_pZNC->GetDataPath(); } -string CUser::GetPemLocation() const { return m_pZNC->GetPemLocation(); } +const CString& CUser::GetCurPath() const { return m_pZNC->GetCurPath(); } +const CString& CUser::GetDLPath() const { return m_pZNC->GetDLPath(); } +const CString& CUser::GetModPath() const { return m_pZNC->GetModPath(); } +const CString& CUser::GetHomePath() const { return m_pZNC->GetHomePath(); } +const CString& CUser::GetDataPath() const { return m_pZNC->GetDataPath(); } +CString CUser::GetPemLocation() const { return m_pZNC->GetPemLocation(); } bool CUser::UseClientIP() const { return m_bUseClientIP; } bool CUser::KeepNick() const { return m_bKeepNick; } bool CUser::DenyLoadMod() const { return m_bDenyLoadMod; } -const string& CUser::GetStatusPrefix() const { return m_sStatusPrefix; } -const string& CUser::GetDefaultChanModes() const { return m_sDefaultChanModes; } +const CString& CUser::GetStatusPrefix() const { return m_sStatusPrefix; } +const CString& CUser::GetDefaultChanModes() const { return m_sDefaultChanModes; } const vector& CUser::GetChans() const { return m_vChans; } const vector& CUser::GetServers() const { return m_vServers; } const CNick& CUser::GetIRCNick() const { return m_IRCNick; } -const string& CUser::GetIRCServer() const { return m_sIRCServer; } -string CUser::GetQuitMsg() const { return (!m_sQuitMsg.empty()) ? m_sQuitMsg : "ZNC by prozac - http://znc.sourceforge.net"; } -string CUser::GetVersionReply() const { return (!m_sVersionReply.empty()) ? m_sVersionReply : "ZNC by prozac - http://znc.sourceforge.net"; } +const CString& CUser::GetIRCServer() const { return m_sIRCServer; } +CString CUser::GetQuitMsg() const { return (!m_sQuitMsg.empty()) ? m_sQuitMsg : "ZNC by prozac - http://znc.sourceforge.net"; } +CString CUser::GetVersionReply() const { return (!m_sVersionReply.empty()) ? m_sVersionReply : "ZNC by prozac - http://znc.sourceforge.net"; } unsigned int CUser::GetBufferCount() const { return m_uBufferCount; } bool CUser::KeepBuffer() const { return m_bKeepBuffer; } // !Getters diff --git a/User.h b/User.h index 137747fa..517a36c1 100644 --- a/User.h +++ b/User.h @@ -20,23 +20,23 @@ class CUserSock; class CUser { public: - CUser(const string& sUserName, CZNC* pZNC); + CUser(const CString& sUserName, CZNC* pZNC); virtual ~CUser(); - CChan* FindChan(const string& sName); + CChan* FindChan(const CString& sName); bool AddChan(CChan* pChan); - bool AddChan(const string& sName); - bool DelChan(const string& sName); - CServer* FindServer(const string& sName); - bool DelServer(const string& sName); - bool AddServer(const string& sName); - bool AddServer(const string& sName, unsigned short uPort, const string& sPass = "", bool bSSL = false); + bool AddChan(const CString& sName); + bool DelChan(const CString& sName); + CServer* FindServer(const CString& sName); + bool DelServer(const CString& sName); + bool AddServer(const CString& sName); + bool AddServer(const CString& sName, unsigned short uPort, const CString& sPass = "", bool bSSL = false); CServer* GetNextServer(); - bool CheckPass(const string& sPass); - bool AddAllowedHost(const string& sHostMask); - bool IsHostAllowed(const string& sHostMask); - bool IsValid(string& sErrMsg); - static bool IsValidUserName(const string& sUserName); + bool CheckPass(const CString& sPass); + bool AddAllowedHost(const CString& sHostMask); + bool IsHostAllowed(const CString& sHostMask); + bool IsValid(CString& sErrMsg); + static bool IsValidUserName(const CString& sUserName); #ifdef _MODULES // Modules @@ -47,34 +47,34 @@ public: bool OnBoot(); bool IsUserAttached(); - bool PutIRC(const string& sLine); - bool PutUser(const string& sLine); - bool PutStatus(const string& sLine); - bool PutModule(const string& sModule, const string& sLine); + bool PutIRC(const CString& sLine); + bool PutUser(const CString& sLine); + bool PutStatus(const CString& sLine); + bool PutModule(const CString& sModule, const CString& sLine); - string GetLocalIP(); + CString GetLocalIP(); - bool SendFile(const string& sRemoteNick, const string& sFileName, const string& sModuleName = ""); - bool GetFile(const string& sRemoteNick, const string& sRemoteIP, unsigned short uRemotePort, const string& sFileName, unsigned long uFileSize, const string& sModuleName = ""); - bool ResumeFile(const string& sRemoteNick, unsigned short uPort, unsigned long uFileSize); - string GetCurNick(); + bool SendFile(const CString& sRemoteNick, const CString& sFileName, const CString& sModuleName = ""); + bool GetFile(const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sFileName, unsigned long uFileSize, const CString& sModuleName = ""); + bool ResumeFile(const CString& sRemoteNick, unsigned short uPort, unsigned long uFileSize); + CString GetCurNick(); // Setters - void SetNick(const string& s); - void SetAltNick(const string& s); - void SetIdent(const string& s); - void SetRealName(const string& s); - void SetVHost(const string& s); - void SetPass(const string& s, bool bHashed); + void SetNick(const CString& s); + void SetAltNick(const CString& s); + void SetIdent(const CString& s); + void SetRealName(const CString& s); + void SetVHost(const CString& s); + void SetPass(const CString& s, bool bHashed); void SetUseClientIP(bool b); void SetKeepNick(bool b); void SetDenyLoadMod(bool b); - bool SetStatusPrefix(const string& s); - void SetDefaultChanModes(const string& s); + bool SetStatusPrefix(const CString& s); + void SetDefaultChanModes(const CString& s); void SetIRCNick(const CNick& n); - void SetIRCServer(const string& s); - void SetQuitMsg(const string& s); - void SetVersionReply(const string& s); + void SetIRCServer(const CString& s); + void SetQuitMsg(const CString& s); + void SetVersionReply(const CString& s); void SetBufferCount(unsigned int u); void SetKeepBuffer(bool b); // !Setters @@ -84,32 +84,32 @@ public: CIRCSock* GetIRCSock(); TSocketManager* GetManager(); CZNC* GetZNC(); - const string& GetUserName() const; - const string& GetNick() const; - const string& GetAltNick() const; - const string& GetIdent() const; - const string& GetRealName() const; - const string& GetVHost() const; - const string& GetPass() const; + const CString& GetUserName() const; + const CString& GetNick() const; + const CString& GetAltNick() const; + const CString& GetIdent() const; + const CString& GetRealName() const; + const CString& GetVHost() const; + const CString& GetPass() const; - const string& GetCurPath() const; - const string& GetDLPath() const; - const string& GetModPath() const; - const string& GetHomePath() const; - const string& GetDataPath() const; - string GetPemLocation() const; + const CString& GetCurPath() const; + const CString& GetDLPath() const; + const CString& GetModPath() const; + const CString& GetHomePath() const; + const CString& GetDataPath() const; + CString GetPemLocation() const; bool UseClientIP() const; bool KeepNick() const; bool DenyLoadMod() const; - const string& GetStatusPrefix() const; - const string& GetDefaultChanModes() const; + const CString& GetStatusPrefix() const; + const CString& GetDefaultChanModes() const; const vector& GetChans() const; const vector& GetServers() const; const CNick& GetIRCNick() const; - const string& GetIRCServer() const; - string GetQuitMsg() const; - string GetVersionReply() const; + const CString& GetIRCServer() const; + CString GetQuitMsg() const; + CString GetVersionReply() const; unsigned int GetBufferCount() const; bool KeepBuffer() const; // !Getters @@ -117,19 +117,19 @@ private: protected: CZNC* m_pZNC; - string m_sUserName; - string m_sNick; - string m_sAltNick; - string m_sIdent; - string m_sRealName; - string m_sVHost; - string m_sPass; - string m_sStatusPrefix; - string m_sDefaultChanModes; + CString m_sUserName; + CString m_sNick; + CString m_sAltNick; + CString m_sIdent; + CString m_sRealName; + CString m_sVHost; + CString m_sPass; + CString m_sStatusPrefix; + CString m_sDefaultChanModes; CNick m_IRCNick; - string m_sIRCServer; - string m_sQuitMsg; - string m_sVersionReply; + CString m_sIRCServer; + CString m_sQuitMsg; + CString m_sVersionReply; bool m_bPassHashed; bool m_bUseClientIP; @@ -139,7 +139,7 @@ protected: vector m_vServers; vector m_vChans; - set m_ssAllowedHosts; + set m_ssAllowedHosts; unsigned int m_uServerIdx; unsigned int m_uBufferCount; diff --git a/UserSock.cpp b/UserSock.cpp index ef664c90..df8385f1 100644 --- a/UserSock.cpp +++ b/UserSock.cpp @@ -7,8 +7,8 @@ #include "DCCSock.h" #include "Server.h" -void CUserSock::ReadLine(const string& sData) { - string sLine = sData; +void CUserSock::ReadLine(const CString& sData) { + CString sLine = sData; while ((CUtils::Right(sLine, 1) == "\r") || (CUtils::Right(sLine, 1) == "\n")) { CUtils::RightChomp(sLine); @@ -24,14 +24,14 @@ void CUserSock::ReadLine(const string& sData) { } #endif - string sCommand = CUtils::Token(sLine, 0); + CString sCommand = CUtils::Token(sLine, 0); if (strcasecmp(sCommand.c_str(), "ZNC") == 0) { PutStatus("Hello. How may I help you?"); return; } else if (strcasecmp(sCommand.c_str(), "DETACH") == 0) { if (m_pUser) { - string sChan = CUtils::Token(sLine, 1); + CString sChan = CUtils::Token(sLine, 1); if (sChan.empty()) { PutStatusNotice("Usage: /detach <#chan>"); @@ -55,7 +55,7 @@ void CUserSock::ReadLine(const string& sData) { m_bGotPass = true; m_sPass = CUtils::Token(sLine, 1); - if (m_sPass.find(":") != string::npos) { + if (m_sPass.find(":") != CString::npos) { m_sUser = CUtils::Token(m_sPass, 0, false, ':'); m_sPass = CUtils::Token(m_sPass, 1, true, ':'); } @@ -67,7 +67,7 @@ void CUserSock::ReadLine(const string& sData) { return; // Don't forward this msg. ZNC has already registered us. } else if (strcasecmp(sCommand.c_str(), "NICK") == 0) { - string sNick = CUtils::Token(sLine, 1); + CString sNick = CUtils::Token(sLine, 1); if (CUtils::Left(sNick, 1) == ":") { CUtils::LeftChomp(sNick); } @@ -98,7 +98,7 @@ void CUserSock::ReadLine(const string& sData) { return; // Don't forward this msg. ZNC has already registered us. } else if (strcasecmp(sCommand.c_str(), "JOIN") == 0) { - string sChan = CUtils::Token(sLine, 1); + CString sChan = CUtils::Token(sLine, 1); if (CUtils::Left(sChan, 1) == ":") { CUtils::LeftChomp(sChan); } @@ -119,21 +119,21 @@ void CUserSock::ReadLine(const string& sData) { 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) { - string sTarget = CUtils::Token(sLine, 1); - string sMsg = CUtils::Token(sLine, 2, true); + CString sTarget = CUtils::Token(sLine, 1); + CString sMsg = CUtils::Token(sLine, 2, true); if (CUtils::Left(sMsg, 1) == ":") { CUtils::LeftChomp(sMsg); } - if ((!m_pUser) || (strcasecmp(sTarget.c_str(), string(m_pUser->GetStatusPrefix() + "status").c_str())) == 0) { + if ((!m_pUser) || (strcasecmp(sTarget.c_str(), CString(m_pUser->GetStatusPrefix() + "status").c_str())) == 0) { return; } if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) { #ifdef _MODULES if (m_pUser) { - string sModule = sTarget; + CString sModule = sTarget; CUtils::LeftChomp(sModule, m_pUser->GetStatusPrefix().length()); CModule* pModule = m_pUser->GetModules().FindModule(sModule); @@ -159,7 +159,7 @@ void CUserSock::ReadLine(const string& sData) { #ifdef _MODULES if (CUtils::wildcmp("\001*\001", sMsg.c_str())) { - string sCTCP = sMsg; + CString sCTCP = sMsg; CUtils::LeftChomp(sCTCP); CUtils::RightChomp(sCTCP); @@ -178,25 +178,25 @@ void CUserSock::ReadLine(const string& sData) { PutIRC("NOTICE " + sTarget + " :" + sMsg); return; } else if (strcasecmp(sCommand.c_str(), "PRIVMSG") == 0) { - string sTarget = CUtils::Token(sLine, 1); - string sMsg = CUtils::Token(sLine, 2, true); + CString sTarget = CUtils::Token(sLine, 1); + CString sMsg = CUtils::Token(sLine, 2, true); if (CUtils::Left(sMsg, 1) == ":") { CUtils::LeftChomp(sMsg); } if (CUtils::wildcmp("\001*\001", sMsg.c_str())) { - string sCTCP = sMsg; + CString sCTCP = sMsg; CUtils::LeftChomp(sCTCP); CUtils::RightChomp(sCTCP); if (strncasecmp(sCTCP.c_str(), "DCC ", 4) == 0) { - string sType = CUtils::Token(sCTCP, 1); - string sFile = CUtils::Token(sCTCP, 2); + CString sType = CUtils::Token(sCTCP, 1); + CString sFile = CUtils::Token(sCTCP, 2); unsigned long uLongIP = strtoul(CUtils::Token(sCTCP, 3).c_str(), NULL, 10); unsigned short uPort = strtoul(CUtils::Token(sCTCP, 4).c_str(), NULL, 10); unsigned long uFileSize = strtoul(CUtils::Token(sCTCP, 5).c_str(), NULL, 10); - string sIP = (m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP(); + CString sIP = (m_pIRCSock) ? m_pIRCSock->GetLocalIP() : GetLocalIP(); if (!m_pUser->UseClientIP()) { uLongIP = CUtils::GetLongIP(GetRemoteIP()); @@ -214,12 +214,12 @@ void CUserSock::ReadLine(const string& sData) { // 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(), string(m_pUser->GetStatusPrefix() + "status").c_str()) == 0)) { + if ((!m_pUser) || (strcasecmp(sTarget.c_str(), CString(m_pUser->GetStatusPrefix() + "status").c_str()) == 0)) { if (!m_pUser) { return; } - string sPath = m_pUser->GetDLPath(); + CString sPath = m_pUser->GetDLPath(); if (!CFile::Exists(sPath)) { PutStatus("Could not create [" + sPath + "] directory."); return; @@ -228,7 +228,7 @@ void CUserSock::ReadLine(const string& sData) { return; } - string sLocalFile = sPath + "/" + sFile; + CString sLocalFile = sPath + "/" + sFile; if (m_pUser) { m_pUser->GetFile(GetNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize); @@ -287,7 +287,7 @@ void CUserSock::ReadLine(const string& sData) { if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) { #ifdef _MODULES - string sModule = sTarget; + CString sModule = sTarget; CUtils::LeftChomp(sModule, m_pUser->GetStatusPrefix().length()); CModule* pModule = m_pUser->GetModules().FindModule(sModule); @@ -310,7 +310,7 @@ void CUserSock::ReadLine(const string& sData) { return; } - if ((m_pUser) && (strcasecmp(sTarget.c_str(), string(m_pUser->GetStatusPrefix() + "status").c_str()) == 0)) { + if ((m_pUser) && (strcasecmp(sTarget.c_str(), CString(m_pUser->GetStatusPrefix() + "status").c_str()) == 0)) { #ifdef _MODULES if ((m_pUser) && (m_pUser->GetModules().OnStatusCommand(sMsg))) { return; @@ -323,7 +323,7 @@ void CUserSock::ReadLine(const string& sData) { if (strncasecmp(sTarget.c_str(), m_pUser->GetStatusPrefix().c_str(), m_pUser->GetStatusPrefix().length()) == 0) { #ifdef _MODULES if (m_pUser) { - string sModule = sTarget; + CString sModule = sTarget; CUtils::LeftChomp(sModule, m_pUser->GetStatusPrefix().length()); CModule* pModule = m_pUser->GetModules().FindModule(sModule); @@ -355,7 +355,7 @@ void CUserSock::ReadLine(const string& sData) { PutIRC(sLine); } -void CUserSock::SetNick(const string& s) { +void CUserSock::SetNick(const CString& s) { m_sNick = s; if (m_pUser) { @@ -374,7 +374,7 @@ bool CUserSock::DecKeepNickCounter() { return true; } -void CUserSock::UserCommand(const string& sLine) { +void CUserSock::UserCommand(const CString& sLine) { if (!m_pUser) { return; } @@ -383,12 +383,12 @@ void CUserSock::UserCommand(const string& sLine) { return; } - string sCommand = CUtils::Token(sLine, 0); + CString sCommand = CUtils::Token(sLine, 0); if (strcasecmp(sCommand.c_str(), "HELP") == 0) { HelpUser(); } else if (strcasecmp(sCommand.c_str(), "LISTNICKS") == 0) { - string sChan = CUtils::Token(sLine, 1); + CString sChan = CUtils::Token(sLine, 1); if (sChan.empty()) { PutStatus("Usage: ListNicks <#chan>"); @@ -407,7 +407,7 @@ void CUserSock::UserCommand(const string& sLine) { return; } - const map& msNicks = pChan->GetNicks(); + const map& msNicks = pChan->GetNicks(); if (!msNicks.size()) { PutStatus("No nicks on [" + sChan + "]"); @@ -421,7 +421,7 @@ void CUserSock::UserCommand(const string& sLine) { Table.AddColumn("Ident"); Table.AddColumn("Host"); - for (map::const_iterator a = msNicks.begin(); a != msNicks.end(); a++) { + for (map::const_iterator a = msNicks.begin(); a != msNicks.end(); a++) { Table.AddRow(); if (a->second->IsOp()) { Table.SetCell("@", "@"); } if (a->second->IsVoice()) { Table.SetCell("+", "+"); } @@ -431,14 +431,14 @@ void CUserSock::UserCommand(const string& sLine) { } unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); } } else if (strcasecmp(sCommand.c_str(), "DETACH") == 0) { if (m_pUser) { - string sChan = CUtils::Token(sLine, 1); + CString sChan = CUtils::Token(sLine, 1); if (sChan.empty()) { PutStatus("Usage: Detach <#chan>"); @@ -457,7 +457,7 @@ void CUserSock::UserCommand(const string& sLine) { } else if (strcasecmp(sCommand.c_str(), "VERSION") == 0) { PutStatus(CZNC::GetTag()); } else if (strcasecmp(sCommand.c_str(), "SHUTDOWN") == 0) { - string sQuitMsg = CUtils::Token(sLine, 1, true); + CString sQuitMsg = CUtils::Token(sLine, 1, true); if (!sQuitMsg.empty()) { m_pUser->SetQuitMsg(sQuitMsg); @@ -488,13 +488,13 @@ void CUserSock::UserCommand(const string& sLine) { for (unsigned int a = 0; a < vChans.size(); a++) { CChan* pChan = vChans[a]; Table.AddRow(); - Table.SetCell("Name", string((pChan->IsOp()) ? "@" : ((pChan->IsVoice()) ? "+" : "")) + pChan->GetName()); + 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", string((pChan->KeepBuffer()) ? "*" : "") + CUtils::ToString(pChan->GetBufferCount())); + Table.SetCell("Buf", CString((pChan->KeepBuffer()) ? "*" : "") + CUtils::ToString(pChan->GetBufferCount())); - string sModes = pChan->GetModeString(); + CString sModes = pChan->GetModeCString(); unsigned int uLimit = pChan->GetLimit(); - const string& sKey = pChan->GetKey(); + const CString& sKey = pChan->GetKey(); if (uLimit) { sModes += " " + CUtils::ToString(uLimit); } if (!sKey.empty()) { sModes += " " + sKey; } @@ -507,7 +507,7 @@ void CUserSock::UserCommand(const string& sLine) { if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); @@ -515,7 +515,7 @@ void CUserSock::UserCommand(const string& sLine) { } } } else if (strcasecmp(sCommand.c_str(), "ADDSERVER") == 0) { - string sServer = CUtils::Token(sLine, 1); + CString sServer = CUtils::Token(sLine, 1); if (sServer.empty()) { PutStatus("Usage: AddServer [[+]port] [pass]"); @@ -533,7 +533,7 @@ void CUserSock::UserCommand(const string& sLine) { PutStatus("Unable to add that server"); } } else if (strcasecmp(sCommand.c_str(), "REMSERVER") == 0 || strcasecmp(sCommand.c_str(), "DELSERVER") == 0) { - string sServer = CUtils::Token(sLine, 1); + CString sServer = CUtils::Token(sLine, 1); if (sServer.empty()) { PutStatus("Usage: RemServer "); @@ -572,7 +572,7 @@ void CUserSock::UserCommand(const string& sLine) { if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); @@ -597,7 +597,7 @@ void CUserSock::UserCommand(const string& sLine) { if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); @@ -605,8 +605,8 @@ void CUserSock::UserCommand(const string& sLine) { } } } else if (strcasecmp(sCommand.c_str(), "SEND") == 0) { - string sToNick = CUtils::Token(sLine, 1); - string sFile = CUtils::Token(sLine, 2); + CString sToNick = CUtils::Token(sLine, 1); + CString sFile = CUtils::Token(sLine, 2); if ((sToNick.empty()) || (sFile.empty())) { PutStatus("Usage: Send "); @@ -617,7 +617,7 @@ void CUserSock::UserCommand(const string& sLine) { m_pUser->SendFile(sToNick, sFile); } } else if (strcasecmp(sCommand.c_str(), "GET") == 0) { - string sFile = CUtils::Token(sLine, 1); + CString sFile = CUtils::Token(sLine, 1); if (sFile.empty()) { PutStatus("Usage: Get "); @@ -639,7 +639,7 @@ void CUserSock::UserCommand(const string& sLine) { Table.AddColumn("File"); for (unsigned int a = 0; a < Manager.size(); a++) { - const string& sSockName = Manager[a]->GetSockName(); + const CString& sSockName = Manager[a]->GetSockName(); if (strncasecmp(sSockName.c_str(), "DCC::", 5) == 0) { if (strncasecmp(sSockName.c_str() +5, "XFER::REMOTE::", 14) == 0) { @@ -682,7 +682,7 @@ void CUserSock::UserCommand(const string& sLine) { } else if (strncasecmp(sSockName.c_str() +5, "XFER::LOCAL", 11) == 0) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; - string sState = "Waiting"; + CString sState = "Waiting"; if ((pSock->IsConnected()) || (pSock->IsPeerConnected())) { sState = "Halfway"; if ((pSock->IsPeerConnected()) && (pSock->IsPeerConnected())) { @@ -699,7 +699,7 @@ void CUserSock::UserCommand(const string& sLine) { } else if (strncasecmp(sSockName.c_str() +5, "CHAT::LOCAL", 11) == 0) { CDCCBounce* pSock = (CDCCBounce*) Manager[a]; - string sState = "Waiting"; + CString sState = "Waiting"; if ((pSock->IsConnected()) || (pSock->IsPeerConnected())) { sState = "Halfway"; if ((pSock->IsPeerConnected()) && (pSock->IsPeerConnected())) { @@ -718,7 +718,7 @@ void CUserSock::UserCommand(const string& sLine) { if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); @@ -746,7 +746,7 @@ void CUserSock::UserCommand(const string& sLine) { Table.SetCell("Description", CUtils::Ellipsize(Modules[b]->GetDescription(), 128)); } - unsigned int uTableIdx = 0; string sLine; + unsigned int uTableIdx = 0; CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); } @@ -756,8 +756,8 @@ void CUserSock::UserCommand(const string& sLine) { #endif return; } else if ((strcasecmp(sCommand.c_str(), "LOADMOD") == 0) || (strcasecmp(sCommand.c_str(), "LOADMODULE") == 0)) { - string sMod = CUtils::Token(sLine, 1); - string sArgs = CUtils::Token(sLine, 2, true); + CString sMod = CUtils::Token(sLine, 1); + CString sArgs = CUtils::Token(sLine, 2, true); if (m_pUser->DenyLoadMod()) { PutStatus("Unable to load [" + sMod + "] Access Denied."); @@ -769,7 +769,7 @@ void CUserSock::UserCommand(const string& sLine) { return; } - string sModRet; + CString sModRet; m_pUser->GetModules().LoadModule(sMod, sArgs, m_pUser, sModRet); PutStatus(sModRet); #else @@ -777,7 +777,7 @@ void CUserSock::UserCommand(const string& sLine) { #endif return; } else if ((strcasecmp(sCommand.c_str(), "UNLOADMOD") == 0) || (strcasecmp(sCommand.c_str(), "UNLOADMODULE") == 0)) { - string sMod = CUtils::Token(sLine, 1); + CString sMod = CUtils::Token(sLine, 1); if (m_pUser->DenyLoadMod()) { PutStatus("Unable to unload [" + sMod + "] Access Denied."); @@ -789,7 +789,7 @@ void CUserSock::UserCommand(const string& sLine) { return; } - string sModRet; + CString sModRet; m_pUser->GetModules().UnloadModule(sMod, sModRet); PutStatus(sModRet); #else @@ -797,8 +797,8 @@ void CUserSock::UserCommand(const string& sLine) { #endif return; } else if ((strcasecmp(sCommand.c_str(), "RELOADMOD") == 0) || (strcasecmp(sCommand.c_str(), "RELOADMODULE") == 0)) { - string sMod = CUtils::Token(sLine, 1); - string sArgs = CUtils::Token(sLine, 2, true); + CString sMod = CUtils::Token(sLine, 1); + CString sArgs = CUtils::Token(sLine, 2, true); if (m_pUser->DenyLoadMod()) { PutStatus("Unable to reload [" + sMod + "] Access Denied."); @@ -810,7 +810,7 @@ void CUserSock::UserCommand(const string& sLine) { return; } - string sModRet; + CString sModRet; m_pUser->GetModules().ReloadModule(sMod, sArgs, m_pUser, sModRet); PutStatus(sModRet); #else @@ -818,7 +818,7 @@ void CUserSock::UserCommand(const string& sLine) { #endif return; } else if (strcasecmp(sCommand.c_str(), "SETBUFFER") == 0) { - string sChan = CUtils::Token(sLine, 1); + CString sChan = CUtils::Token(sLine, 1); if (sChan.empty()) { PutStatus("Usage: SetBuffer <#chan> [linecount]"); @@ -878,7 +878,7 @@ void CUserSock::HelpUser() { if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutStatus(sLine); @@ -886,7 +886,7 @@ void CUserSock::HelpUser() { } } -bool CUserSock::ConnectionFrom(const string& sHost, int iPort) { +bool CUserSock::ConnectionFrom(const CString& sHost, int iPort) { DEBUG_ONLY(cout << GetSockName() << " == ConnectionFrom(" << sHost << ", " << iPort << ")" << endl); return m_pZNC->IsHostAllowed(sHost); } @@ -969,33 +969,33 @@ void CUserSock::IRCDisconnected() { m_pIRCSock = NULL; } -Csock* CUserSock::GetSockObj(const string& sHost, int iPort) { +Csock* CUserSock::GetSockObj(const CString& sHost, int iPort) { CUserSock* pSock = new CUserSock(sHost, iPort); pSock->SetZNC(m_pZNC); return pSock; } -void CUserSock::PutIRC(const string& sLine) { +void CUserSock::PutIRC(const CString& sLine) { if (m_pIRCSock) { m_pIRCSock->PutServ(sLine); } } -void CUserSock::PutServ(const string& sLine) { +void CUserSock::PutServ(const CString& sLine) { DEBUG_ONLY(cout << GetSockName() << " -> [" << sLine << "]" << endl); Write(sLine + "\r\n"); } -void CUserSock::PutStatusNotice(const string& sLine) { +void CUserSock::PutStatusNotice(const CString& sLine) { PutModNotice("status", sLine); } -void CUserSock::PutStatus(const string& sLine) { +void CUserSock::PutStatus(const CString& sLine) { PutModule("status", sLine); } -void CUserSock::PutModNotice(const string& sModule, const string& sLine) { +void CUserSock::PutModNotice(const CString& sModule, const CString& sLine) { if (!m_pUser) { return; } @@ -1004,7 +1004,7 @@ void CUserSock::PutModNotice(const string& sModule, const string& sLine) { Write(":" + m_pUser->GetStatusPrefix() + ((sModule.empty()) ? "status" : sModule) + "!znc@znc.com NOTICE " + GetNick() + " :" + sLine + "\r\n"); } -void CUserSock::PutModule(const string& sModule, const string& sLine) { +void CUserSock::PutModule(const CString& sModule, const CString& sLine) { if (!m_pUser) { return; } @@ -1013,8 +1013,8 @@ void CUserSock::PutModule(const string& sModule, const string& sLine) { Write(":" + m_pUser->GetStatusPrefix() + ((sModule.empty()) ? "status" : sModule) + "!znc@znc.com PRIVMSG " + GetNick() + " :" + sLine + "\r\n"); } -string CUserSock::GetNick() const { - string sRet; +CString CUserSock::GetNick() const { + CString sRet; if ((m_bAuthed) && (m_pIRCSock)) { sRet = m_pIRCSock->GetNick(); @@ -1023,7 +1023,7 @@ string CUserSock::GetNick() const { return (sRet.empty()) ? m_sNick : sRet; } -string CUserSock::GetNickMask() const { +CString CUserSock::GetNickMask() const { if (m_pIRCSock) { return m_pIRCSock->GetNickMask(); } diff --git a/UserSock.h b/UserSock.h index 970e44dc..2f8b23bf 100644 --- a/UserSock.h +++ b/UserSock.h @@ -15,7 +15,7 @@ public: CUserSock() : Csock() { Init(); } - CUserSock(const string& sHostname, int iport, int itimeout = 60) : Csock(sHostname, iport, itimeout) { + CUserSock(const CString& sHostname, int iport, int itimeout = 60) : Csock(sHostname, iport, itimeout) { Init(); } virtual ~CUserSock() {} @@ -32,34 +32,34 @@ public: EnableReadLine(); } - string GetNick() const; - string GetNickMask() const; + CString GetNick() const; + CString GetNickMask() const; bool DecKeepNickCounter(); - void UserCommand(const string& sCommand); + void UserCommand(const CString& sCommand); void IRCConnected(CIRCSock* pIRCSock); void IRCDisconnected(); void BouncedOff(); bool IsAttached() const { return m_bAuthed; } - void PutIRC(const string& sLine); - void PutServ(const string& sLine); - void PutStatus(const string& sLine); - void PutStatusNotice(const string& sLine); - void PutModule(const string& sModule, const string& sLine); - void PutModNotice(const string& sModule, const string& sLine); + void PutIRC(const CString& sLine); + void PutServ(const CString& sLine); + void PutStatus(const CString& sLine); + void PutStatusNotice(const CString& sLine); + void PutModule(const CString& sModule, const CString& sLine); + void PutModNotice(const CString& sModule, const CString& sLine); - virtual void ReadLine(const string& sData); + virtual void ReadLine(const CString& sData); void HelpUser(); void AuthUser(); virtual void Connected(); virtual void Disconnected(); virtual void ConnectionRefused(); - virtual bool ConnectionFrom(const string& sHost, int iPort); - virtual Csock* GetSockObj(const string& sHost, int iPort); + virtual bool ConnectionFrom(const CString& sHost, int iPort); + virtual Csock* GetSockObj(const CString& sHost, int iPort); void SetZNC(CZNC* pZNC) { m_pZNC = pZNC; } - void SetNick(const string& s); + void SetNick(const CString& s); private: protected: bool m_bAuthed; @@ -68,9 +68,9 @@ protected: bool m_bGotUser; CZNC* m_pZNC; CUser* m_pUser; - string m_sNick; - string m_sPass; - string m_sUser; + CString m_sNick; + CString m_sPass; + CString m_sUser; CIRCSock* m_pIRCSock; unsigned int m_uKeepNickCounter; }; diff --git a/Utils.cpp b/Utils.cpp index 93448fe5..26509577 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -121,21 +121,21 @@ unsigned long CUtils::GetLongIP(const string& sIP) { return (unsigned long) ((atoi(ip[0]) << 24) + (atoi(ip[1]) << 16) + (atoi(ip[2]) << 8) + atoi(ip[3])); } -string CUtils::ChangeDir(const string& sPath, const string& sAdd, const string& sHomeDir) { +CString CUtils::ChangeDir(const CString& sPath, const CString& sAdd, const CString& sHomeDir) { if (sAdd == "~") { return sHomeDir; } - string sAddDir = sAdd; + CString sAddDir = sAdd; if (CUtils::Left(sAddDir, 2) == "~/") { CUtils::LeftChomp(sAddDir); sAddDir = sHomeDir + sAddDir; } - string sRet = ((sAddDir.size()) && (sAddDir[0] == '/')) ? "" : sPath; + CString sRet = ((sAddDir.size()) && (sAddDir[0] == '/')) ? "" : sPath; sAddDir += "/"; - string sCurDir; + CString sCurDir; if (CUtils::Right(sRet, 1) == "/") { CUtils::RightChomp(sRet); diff --git a/Utils.h b/Utils.h index 82c6bbab..b5688ffd 100644 --- a/Utils.h +++ b/Utils.h @@ -7,6 +7,7 @@ #include #include +#include "String.h" #include #include #include @@ -29,7 +30,7 @@ public: static string GetIP(unsigned long addr); static unsigned long GetLongIP(const string& sIP); - static string ChangeDir(const string& sPath, const string& sAdd, const string& sHomeDir); + static CString ChangeDir(const CString& sPath, const CString& sAdd, const CString& sHomeDir); static int MakeDir(const string& sPath, mode_t iMode = 0700); static void PrintError(const string& sMessage); static void PrintMessage(const string& sMessage, bool bStrong = false); diff --git a/main.cpp b/main.cpp index e2027be1..43ebb029 100644 --- a/main.cpp +++ b/main.cpp @@ -18,7 +18,7 @@ static struct option g_LongOpts[] = { }; void GenerateHelp(const char *appname) { - CUtils::PrintMessage("USAGE: " + string(appname) + " [options] [config]"); + CUtils::PrintMessage("USAGE: " + CString(appname) + " [options] [config]"); CUtils::PrintMessage("Options are:"); CUtils::PrintMessage("\t--help"); CUtils::PrintMessage("\t--version Output version information and exit"); @@ -46,7 +46,7 @@ void die(int sig) { } int main(int argc, char** argv) { - string sConfig; + CString sConfig; #ifdef HAVE_LIBSSL // initialize ssl, allow client to have compression enabled if desired @@ -63,7 +63,7 @@ int main(int argc, char** argv) { switch (iArg) { case 1: { // long options if (iOptIndex >= 0) { - string sOption = Lower(g_LongOpts[iOptIndex].name); + CString sOption = Lower(g_LongOpts[iOptIndex].name); if (sOption == "version") { cout << CZNC::GetTag() << endl; return 0; @@ -103,7 +103,7 @@ int main(int argc, char** argv) { if (bMakePem) { CZNC* pZNC = CZNC::New(); pZNC->InitDirs(""); - string sPemFile = pZNC->GetPemLocation(); + CString sPemFile = pZNC->GetPemLocation(); CUtils::PrintAction("Writing Pem file [" + sPemFile + "]"); @@ -131,7 +131,7 @@ int main(int argc, char** argv) { } #endif /* HAVE_LIBSSL */ if (bMakePass) { - string sHash = CUtils::GetHashPass(); + CString sHash = CUtils::GetHashPass(); CUtils::PrintMessage("Use this in the section of your config:"); CUtils::PrintMessage("Pass = " + sHash + " -"); diff --git a/main.h b/main.h index d1069256..e7c68e15 100644 --- a/main.h +++ b/main.h @@ -3,15 +3,14 @@ #ifndef CS_STRING -#define CS_STRING string +#define CS_STRING CString #endif #ifndef _NO_CSOCKET_NS #define _NO_CSOCKET_NS #endif -#include -using std::string; +#include "String.h" #include "Csocket.h" #include "Utils.h" diff --git a/modules/away.cpp b/modules/away.cpp index 0a38884d..d3dfa026 100644 --- a/modules/away.cpp +++ b/modules/away.cpp @@ -20,6 +20,9 @@ * * * $Log$ + * Revision 1.9 2005/05/05 18:11:03 prozacx + * Changed all references to std::string over to CString + * * Revision 1.8 2005/04/18 22:32:24 imaginos * move password reset into BootStrap * @@ -52,7 +55,7 @@ class CAway; class CAwayJob : public CTimer { public: - CAwayJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const string& sLabel, const string& sDescription ) + CAwayJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription ) : CTimer( pModule, uInterval, uCycles, sLabel, sDescription) {} virtual ~CAwayJob() {} @@ -77,7 +80,7 @@ public: SaveBufferToDisk(); } - virtual bool OnLoad(const string& sArgs) + virtual bool OnLoad(const CString& sArgs) { if (!sArgs.empty()) { @@ -118,10 +121,10 @@ public: bool BootStrap() { - string sFile; + CString sFile; if ( DecryptMessages( sFile ) ) { - string sLine; + CString sLine; u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { @@ -142,14 +145,14 @@ public: { if ( !m_sPassword.empty() ) { - string sFile = CRYPT_VERIFICATION_TOKEN; + CString sFile = CRYPT_VERIFICATION_TOKEN; for( u_int b = 0; b < m_vMessages.size(); b++ ) sFile += m_vMessages[b] + "\n"; CBlowfish c( m_sPassword, BF_ENCRYPT ); sFile = c.Crypt( sFile ); - string sPath = GetPath(); + CString sPath = GetPath(); if ( !sPath.empty() ) { WriteFile( sPath, sFile ); @@ -167,14 +170,14 @@ public: Away(); } - virtual string GetDescription() + virtual CString GetDescription() { return ( "Stores messages while away, also auto away" ); } - virtual void OnModCommand( const string& sCommand ) + virtual void OnModCommand( const CString& sCommand ) { - string sCmdName = CUtils::Token(sCommand, 0); + CString sCmdName = CUtils::Token(sCommand, 0); if ( sCmdName == "away" ) { Away(); @@ -193,7 +196,7 @@ public: } else if ( sCmdName == "delete" ) { - string sWhich = CUtils::Token(sCommand, 1); + CString sWhich = CUtils::Token(sCommand, 1); if ( sWhich == "all" ) { PutModNotice( "Deleted " + CUtils::ToString( m_vMessages.size() ) + " Messages.", "away" ); @@ -239,12 +242,12 @@ public: } else if ( sCmdName == "show" ) { - map< string, vector< string> > msvOutput; + map< CString, vector< CString> > msvOutput; for( u_int a = 0; a < m_vMessages.size(); a++ ) { - string sTime = CUtils::Token( m_vMessages[a], 0, false, ':' ); - string sWhom = CUtils::Token( m_vMessages[a], 1, false, ':' ); - string sMessage = CUtils::Token( m_vMessages[a], 2, true, ':' ); + CString sTime = CUtils::Token( m_vMessages[a], 0, false, ':' ); + CString sWhom = CUtils::Token( m_vMessages[a], 1, false, ':' ); + CString sMessage = CUtils::Token( m_vMessages[a], 2, true, ':' ); if ( ( sTime.empty() ) || ( sWhom.empty() ) || ( sMessage.empty() ) ) { @@ -264,13 +267,13 @@ public: m_vMessages.erase( m_vMessages.begin() + a-- ); continue; } - string sTmp = " " + CUtils::ToString( a ) + ") ["; + CString sTmp = " " + CUtils::ToString( a ) + ") ["; sTmp.append( szFormat, iCount ); sTmp += "] "; sTmp += sMessage; msvOutput[sWhom].push_back( sTmp ); } - for( map< string, vector< string> >::iterator it = msvOutput.begin(); it != msvOutput.end(); it++ ) + for( map< CString, vector< CString> >::iterator it = msvOutput.begin(); it != msvOutput.end(); it++ ) { PutModule( it->first, "away" ); for( u_int a = 0; a < it->second.size(); a++ ) @@ -284,16 +287,16 @@ public: } } - string GetPath() + CString GetPath() { - string sBuffer = m_pUser->GetUserName(); - string sRet = m_pUser->GetDataPath() + "/away"; + CString sBuffer = m_pUser->GetUserName(); + CString sRet = m_pUser->GetDataPath() + "/away"; CUtils::MakeDir(sRet); sRet += "/.znc-away-" + CBlowfish::MD5( sBuffer, true ); return( sRet ); } - virtual void Away( bool bForce = false, const string & sReason = "" ) + virtual void Away( bool bForce = false, const CString & sReason = "" ) { if ( ( !m_bIsAway ) || ( bForce ) ) { @@ -304,7 +307,7 @@ public: time_t iTime = time( NULL ); char *pTime = ctime( &iTime ); - string sTime; + CString sTime; if ( pTime ) { sTime = pTime; @@ -337,14 +340,14 @@ public: m_sReason = ""; } - virtual bool OnPrivMsg(const CNick& Nick, string& sMessage) + virtual bool OnPrivMsg(const CNick& Nick, CString& sMessage) { if ( m_bIsAway ) AddMessage( time( NULL ), Nick, sMessage ); return( false ); } - virtual bool OnUserNotice(const string& sTarget, string& sMessage) + virtual bool OnUserNotice(const CString& sTarget, CString& sMessage) { Ping(); if( m_bIsAway ) @@ -352,7 +355,7 @@ public: return( false ); } - virtual bool OnUserMsg(const string& sTarget, string& sMessage) + virtual bool OnUserMsg(const CString& sTarget, CString& sMessage) { Ping(); if( m_bIsAway ) @@ -367,12 +370,12 @@ public: bool IsAway() { return( m_bIsAway ); } private: - string m_sPassword; + CString m_sPassword; bool m_bBootError; - bool DecryptMessages( string & sBuffer ) + bool DecryptMessages( CString & sBuffer ) { - string sMessages = GetPath(); - string sFile; + CString sMessages = GetPath(); + CString sFile; sBuffer = ""; if ( ( sMessages.empty() ) || ( !ReadFile( sMessages, sFile ) ) ) @@ -397,20 +400,20 @@ private: return( true ); } - void AddMessage( time_t iTime, const CNick & Nick, string & sMessage ) + void AddMessage( time_t iTime, const CNick & Nick, CString & sMessage ) { AddMessage( CUtils::ToString( iTime ) + ":" + Nick.GetNickMask() + ":" + sMessage ); } - void AddMessage( const string & sText ) + void AddMessage( const CString & sText ) { m_vMessages.push_back( sText ); } time_t m_iLastSentData; bool m_bIsAway; - vector m_vMessages; - string m_sReason; + vector m_vMessages; + CString m_sReason; }; diff --git a/modules/email.cpp b/modules/email.cpp index 3775a9a9..c1236b02 100644 --- a/modules/email.cpp +++ b/modules/email.cpp @@ -15,11 +15,14 @@ * Author: imaginos * * $Log$ + * Revision 1.4 2005/05/05 18:11:04 prozacx + * Changed all references to std::string over to CString + * * Revision 1.3 2005/05/02 22:34:52 prozacx * Get CFile from FileUtils.h now * * Revision 1.2 2005/04/04 06:35:19 imaginos - * fixed int32's that test against npos to string::size_type + * fixed int32's that test against npos to CString::size_type * * Revision 1.1 2005/03/30 18:46:35 imaginos * moving to standard makefile system, and cpp only extension @@ -32,16 +35,16 @@ struct EmailST { - string sFrom; - string sSubject; - string sUidl; + CString sFrom; + CString sSubject; + CString sUidl; u_int iSize; }; class CEmailJob : public CTimer { public: - CEmailJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const string& sLabel, const string& sDescription ) + CEmailJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription ) : CTimer( pModule, uInterval, uCycles, sLabel, sDescription) {} virtual ~CEmailJob() {} @@ -65,7 +68,7 @@ public: m_pManager->DelSockByAddr( vSocks[a] ); } - virtual bool OnLoad(const string & sArgs) { + virtual bool OnLoad(const CString & sArgs) { m_sMailPath = sArgs; StartParser(); @@ -96,12 +99,12 @@ public: } } - virtual string GetDescription() + virtual CString GetDescription() { return ( "Monitors Email activity on local disk /var/mail/user" ); } - virtual void OnModCommand( const string& sCommand ); + virtual void OnModCommand( const CString& sCommand ); void StartParser(); void ParseEmails( const vector & vEmails ) @@ -117,7 +120,7 @@ public: PutModule( s.str() ); } else { - set ssUidls; + set ssUidls; CTable Table; Table.AddColumn("From"); @@ -141,7 +144,7 @@ public: if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while ( Table.GetLine( uTableIdx++, sLine ) ) { PutModule( sLine ); } @@ -155,16 +158,16 @@ public: private: - string m_sMailPath; + CString m_sMailPath; u_int m_iLastCheck; - set m_ssUidls; + set m_ssUidls; bool m_bInitialized; }; class CEmailFolder : public Csock { public: - CEmailFolder( CEmail *pModule, const string & sMailbox ) : Csock() + CEmailFolder( CEmail *pModule, const CString & sMailbox ) : Csock() { m_pModule = pModule; m_sMailbox = sMailbox; @@ -197,7 +200,7 @@ public: { EmailST tmp; tmp.sUidl = (char *)CMD5( m_sMailBuffer.substr( 0, 255 ) ); - string sLine; + CString sLine; u_int iPos = 0; while( ::ReadLine( m_sMailBuffer, sLine, iPos ) ) { @@ -206,9 +209,9 @@ public: break; // out of the headers if ( strncasecmp( sLine.c_str(), "From: ", 6 ) == 0 ) - tmp.sFrom = sLine.substr( 6, string::npos ); + tmp.sFrom = sLine.substr( 6, CString::npos ); else if ( strncasecmp( sLine.c_str(), "Subject: ", 9 ) == 0 ) - tmp.sSubject = sLine.substr( 9, string::npos ); + tmp.sSubject = sLine.substr( 9, CString::npos ); if ( ( !tmp.sFrom.empty() ) && ( !tmp.sSubject.empty() ) ) break; @@ -218,21 +221,21 @@ public: } private: CEmail *m_pModule; - string m_sMailbox; - string m_sMailBuffer; + CString m_sMailbox; + CString m_sMailBuffer; vector m_vEmails; }; -void CEmail::OnModCommand( const string& sCommand ) +void CEmail::OnModCommand( const CString& sCommand ) { - string::size_type iPos = sCommand.find( " " ); - string sCom, sArgs; - if ( iPos == string::npos ) + CString::size_type iPos = sCommand.find( " " ); + CString sCom, sArgs; + if ( iPos == CString::npos ) sCom = sCommand; else { sCom = sCommand.substr( 0, iPos ); - sArgs = sCommand.substr( iPos + 1, string::npos ); + sArgs = sCommand.substr( iPos + 1, CString::npos ); } if ( sCom == "timers" ) @@ -244,7 +247,7 @@ void CEmail::OnModCommand( const string& sCommand ) void CEmail::StartParser() { - string sParserName = "EMAIL::" + m_pUser->GetUserName(); + CString sParserName = "EMAIL::" + m_pUser->GetUserName(); if ( m_pManager->FindSockByName( sParserName ) ) return; // one at a time sucker diff --git a/modules/raw.cpp b/modules/raw.cpp index 9eb1cda6..cede80db 100644 --- a/modules/raw.cpp +++ b/modules/raw.cpp @@ -9,16 +9,16 @@ public: MODCONSTRUCTOR(CRawMod) {} virtual ~CRawMod() {} - virtual string GetDescription() { + virtual CString GetDescription() { return "View all of the raw traffic."; } - virtual bool OnRaw(string& sLine) { + virtual bool OnRaw(CString& sLine) { PutModule("IRC -> [" + sLine + "]"); return false; } - virtual bool OnUserRaw(string& sLine) { + virtual bool OnUserRaw(CString& sLine) { PutModule("YOU -> [" + sLine + "]"); return false; } diff --git a/modules/sample.cpp b/modules/sample.cpp index bb66d7f5..71810e22 100644 --- a/modules/sample.cpp +++ b/modules/sample.cpp @@ -7,7 +7,7 @@ class CSampleTimer : public CTimer { public: - CSampleTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const string& sLabel, const string& sDescription) : CTimer(pModule, uInterval, uCycles, sLabel, sDescription) {} + CSampleTimer(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription) : CTimer(pModule, uInterval, uCycles, sLabel, sDescription) {} virtual ~CSampleTimer() {} private: @@ -21,7 +21,7 @@ class CSampleMod : public CModule { public: MODCONSTRUCTOR(CSampleMod) {} - virtual bool OnLoad(const string& sArgs) { + virtual bool OnLoad(const CString& sArgs) { PutModule("I'm being loaded with the arguments: [" + sArgs + "]"); //AddTimer(new CSampleTimer(this, 300, 0, "Sample", "Sample timer for sample things.")); //AddTimer(new CSampleTimer(this, 5, 20, "Another", "Another sample timer.")); @@ -38,7 +38,7 @@ public: return true; } - virtual string GetDescription() { + virtual CString GetDescription() { return "To be used as a sample for writing modules."; } @@ -66,25 +66,25 @@ public: PutModule(((bNoChange) ? "[0] " : "[1] [") + OpNick.GetNick() + "] devoiced [" + Nick.GetNick() + "] on [" + Channel.GetName() + "]"); } - virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const string& sModes, const string& sArgs) { + virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const CString& sModes, const CString& sArgs) { PutModule("* " + OpNick.GetNick() + " sets mode: " + sModes + " " + sArgs + " (" + Channel.GetName() + ")"); } - virtual bool OnRaw(string& sLine) { + virtual bool OnRaw(CString& sLine) { // PutModule("OnRaw() [" + sLine + "]"); return false; } - virtual bool OnUserRaw(string& sLine) { + virtual bool OnUserRaw(CString& sLine) { // PutModule("UserRaw() [" + sLine + "]"); return false; } - virtual void OnKick(const CNick& OpNick, const string& sKickedNick, const CChan& Channel, const string& sMessage) { + virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, const CChan& Channel, const CString& sMessage) { PutModule("[" + OpNick.GetNick() + "] kicked [" + sKickedNick + "] from [" + Channel.GetName() + "] with the msg [" + sMessage + "]"); } - virtual void OnQuit(const CNick& Nick, const string& sMessage, const vector& vChans) { + virtual void OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) { PutModule("* Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ") (" + sMessage + ")"); } @@ -96,79 +96,79 @@ public: PutModule("* Parts: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ")"); } - virtual void OnNick(const CNick& OldNick, const string& sNewNick, const vector& vChans) { + virtual void OnNick(const CNick& OldNick, const CString& sNewNick, const vector& vChans) { PutModule("* " + OldNick.GetNick() + " is now known as " + sNewNick); } - virtual bool OnUserCTCPReply(const CNick& Nick, string& sMessage) { + virtual bool OnUserCTCPReply(const CNick& Nick, CString& sMessage) { PutModule("[" + Nick.GetNick() + "] userctcpreply [" + sMessage + "]"); sMessage = "\037" + sMessage + "\037"; return false; } - virtual bool OnCTCPReply(const CNick& Nick, string& sMessage) { + virtual bool OnCTCPReply(const CNick& Nick, CString& sMessage) { PutModule("[" + Nick.GetNick() + "] ctcpreply [" + sMessage + "]"); return false; } - virtual bool OnUserCTCP(const string& sTarget, string& sMessage) { + virtual bool OnUserCTCP(const CString& sTarget, CString& sMessage) { PutModule("[" + sTarget + "] userctcp [" + sMessage + "]"); return false; } - virtual bool OnPrivCTCP(const CNick& Nick, string& sMessage) { + virtual bool OnPrivCTCP(const CNick& Nick, CString& sMessage) { PutModule("[" + Nick.GetNick() + "] privctcp [" + sMessage + "]"); sMessage = "\002" + sMessage + "\002"; return false; } - virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, string& sMessage) { + virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, CString& sMessage) { PutModule("[" + Nick.GetNick() + "] chanctcp [" + sMessage + "] to [" + Channel.GetName() + "]"); sMessage = "\00311,5 " + sMessage + " \003"; return false; } - virtual bool OnUserNotice(const string& sTarget, string& sMessage) { + virtual bool OnUserNotice(const CString& sTarget, CString& sMessage) { PutModule("[" + sTarget + "] usernotice [" + sMessage + "]"); sMessage = "\037" + sMessage + "\037"; return false; } - virtual bool OnPrivNotice(const CNick& Nick, string& sMessage) { + virtual bool OnPrivNotice(const CNick& Nick, CString& sMessage) { PutModule("[" + Nick.GetNick() + "] privnotice [" + sMessage + "]"); sMessage = "\002" + sMessage + "\002"; return false; } - virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, string& sMessage) { + virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, CString& sMessage) { PutModule("[" + Nick.GetNick() + "] channotice [" + sMessage + "] to [" + Channel.GetName() + "]"); sMessage = "\00311,5 " + sMessage + " \003"; return false; } - virtual bool OnUserMsg(const string& sTarget, string& sMessage) { + virtual bool OnUserMsg(const CString& sTarget, CString& sMessage) { PutModule("[" + sTarget + "] usermsg [" + sMessage + "]"); sMessage = "\0034" + sMessage + "\003"; return false; } - virtual bool OnPrivMsg(const CNick& Nick, string& sMessage) { + virtual bool OnPrivMsg(const CNick& Nick, CString& sMessage) { PutModule("[" + Nick.GetNick() + "] privmsg [" + sMessage + "]"); sMessage = "\002" + sMessage + "\002"; return false; } - virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, string& sMessage) { + virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, CString& sMessage) { if (sMessage == "!ping") { PutIRC("PRIVMSG " + Channel.GetName() + " :PONG?"); } @@ -178,13 +178,13 @@ public: return false; } - virtual void OnModCommand(const string& sCommand) { + virtual void OnModCommand(const CString& sCommand) { if (strcasecmp(sCommand.c_str(), "TIMERS") == 0) { ListTimers(); } } - virtual bool OnStatusCommand(const string& sCommand) { + virtual bool OnStatusCommand(const CString& sCommand) { if (strcasecmp(sCommand.c_str(), "SAMPLE") == 0) { PutModule("Hi, I'm your friendly sample module."); return true; diff --git a/modules/savebuff.cpp b/modules/savebuff.cpp index 70972267..127c5fe1 100644 --- a/modules/savebuff.cpp +++ b/modules/savebuff.cpp @@ -26,8 +26,11 @@ * better solution then plain text. * * $Log$ + * Revision 1.19 2005/05/05 18:11:04 prozacx + * Changed all references to std::string over to CString + * * Revision 1.18 2005/04/24 08:05:41 prozacx - * Fixed literal strings of 'savebuff' to now use GetModName() and removed redundant prefix from filenames + * Fixed literal CStrings of 'savebuff' to now use GetModName() and removed redundant prefix from filenames * * Revision 1.17 2005/04/23 18:24:38 imaginos * only work on chans where keepbuffer is true @@ -75,7 +78,7 @@ * Changed path to DataPath * * Revision 1.2 2005/04/04 06:35:19 imaginos - * fixed int32's that test against npos to string::size_type + * fixed int32's that test against npos to CString::size_type * * Revision 1.1 2005/03/30 19:36:20 imaginos * rename files @@ -97,7 +100,7 @@ class CSaveBuff; class CSaveBuffJob : public CTimer { public: - CSaveBuffJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const string& sLabel, const string& sDescription ) + CSaveBuffJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription ) : CTimer( pModule, uInterval, uCycles, sLabel, sDescription) {} virtual ~CSaveBuffJob() {} @@ -123,7 +126,7 @@ public: } } - virtual bool OnLoad(const string& sArgs) + virtual bool OnLoad(const CString& sArgs) { if (!sArgs.empty()) { @@ -164,13 +167,13 @@ public: bool BootStrap( CChan *pChan ) { - string sFile; + CString sFile; if ( DecryptChannel( pChan->GetName(), sFile ) ) { if ( !pChan->GetBuffer().empty() ) return( true ); // reloaded a module probably in this case, so just verify we can decrypt the file - string sLine; + CString sLine; u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { @@ -197,7 +200,7 @@ public: if ( !vChans[a]->KeepBuffer() ) continue; - const vector & vBuffer = vChans[a]->GetBuffer(); + const vector & vBuffer = vChans[a]->GetBuffer(); if ( vBuffer.empty() ) { @@ -207,14 +210,14 @@ public: continue; } - string sFile = CRYPT_VERIFICATION_TOKEN; + CString sFile = CRYPT_VERIFICATION_TOKEN; for( u_int b = 0; b < vBuffer.size(); b++ ) sFile += vBuffer[b] + "\n"; CBlowfish c( m_sPassword, BF_ENCRYPT ); sFile = c.Crypt( sFile ); - string sPath = GetPath( vChans[a]->GetName() ); + CString sPath = GetPath( vChans[a]->GetName() ); if ( !sPath.empty() ) { WriteFile( sPath, sFile ); @@ -224,21 +227,21 @@ public: } } - virtual string GetDescription() + virtual CString GetDescription() { return ( "Stores channel buffers to disk, encrypted." ); } - virtual void OnModCommand( const string& sCommand ) + virtual void OnModCommand( const CString& sCommand ) { - string::size_type iPos = sCommand.find( " " ); - string sCom, sArgs; - if ( iPos == string::npos ) + CString::size_type iPos = sCommand.find( " " ); + CString sCom, sArgs; + if ( iPos == CString::npos ) sCom = sCommand; else { sCom = sCommand.substr( 0, iPos ); - sArgs = sCommand.substr( iPos + 1, string::npos ); + sArgs = sCommand.substr( iPos + 1, CString::npos ); } if ( strcasecmp( sCom.c_str(), "setpass" ) == 0 ) @@ -248,10 +251,10 @@ public: } else if ( strcasecmp( sCom.c_str(), "dumpbuff" ) == 0 ) { - string sFile; + CString sFile; if ( DecryptChannel( sArgs, sFile ) ) { - string sLine; + CString sLine; u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { @@ -262,11 +265,11 @@ public: PutModule( "//!-- EOF " + sArgs ); } else if ( strcasecmp( sCom.c_str(), "replay" ) == 0 ) { - string sFile; + CString sFile; PutUser( ":***!znc@znc.com PRIVMSG " + sArgs + " :Buffer Playback..." ); if ( DecryptChannel( sArgs, sFile ) ) { - string sLine; + CString sLine; u_int iPos = 0; while( ReadLine( sFile, sLine, iPos ) ) { @@ -285,29 +288,29 @@ public: PutModule( "Unknown command [" + sCommand + "]" ); } - string GetPath( const string & sChannel ) + CString GetPath( const CString & sChannel ) { - string sBuffer = m_pUser->GetUserName() + Lower( sChannel ); - string sRet = m_pUser->GetDataPath() + "/" + GetModName(); + CString sBuffer = m_pUser->GetUserName() + Lower( sChannel ); + CString sRet = m_pUser->GetDataPath() + "/" + GetModName(); CUtils::MakeDir(sRet); sRet += "/" + CBlowfish::MD5( sBuffer, true ); return( sRet ); } - string SpoofChanMsg( const string & sChannel, const string & sMesg ) + CString SpoofChanMsg( const CString & sChannel, const CString & sMesg ) { - string sReturn = ":*" + GetModName() + "!znc@znc.com PRIVMSG " + sChannel + " :" + CUtils::ToString( time( NULL ) ) + " " + sMesg; + CString sReturn = ":*" + GetModName() + "!znc@znc.com PRIVMSG " + sChannel + " :" + CUtils::ToString( time( NULL ) ) + " " + sMesg; return( sReturn ); } - virtual void OnRawMode(const CNick& cOpNick, const CChan& cChannel, const string& sModes, const string& sArgs) + virtual void OnRawMode(const CNick& cOpNick, const CChan& cChannel, const CString& sModes, const CString& sArgs) { if ( !cChannel.KeepBuffer() ) return; ((CChan &)cChannel).AddBuffer( SpoofChanMsg( cChannel.GetName(), cOpNick.GetNickMask() + " MODE " + sModes + " " + sArgs ) ); } - virtual void OnQuit(const CNick& cNick, const string& sMessage, const vector& vChans) + virtual void OnQuit(const CNick& cNick, const CString& sMessage, const vector& vChans) { for( u_int a = 0; a < vChans.size(); a++ ) { @@ -317,7 +320,7 @@ public: } } - virtual void OnNick(const CNick& cNick, const string& sNewNick, const vector& vChans) + virtual void OnNick(const CNick& cNick, const CString& sNewNick, const vector& vChans) { for( u_int a = 0; a < vChans.size(); a++ ) { @@ -326,7 +329,7 @@ public: vChans[a]->AddBuffer( SpoofChanMsg( vChans[a]->GetName(), cNick.GetNickMask() + " NICK " + sNewNick ) ); } } - virtual void OnKick(const CNick& cNick, const string& sOpNick, const CChan& cChannel, const string& sMessage) + virtual void OnKick(const CNick& cNick, const CString& sOpNick, const CChan& cChannel, const CString& sMessage) { if ( !cChannel.KeepBuffer() ) return; @@ -347,11 +350,11 @@ public: private: bool m_bBootError; - string m_sPassword; - bool DecryptChannel( const string & sChan, string & sBuffer ) + CString m_sPassword; + bool DecryptChannel( const CString & sChan, CString & sBuffer ) { - string sChannel = GetPath( sChan ); - string sFile; + CString sChannel = GetPath( sChan ); + CString sFile; sBuffer = ""; if ( ( sChannel.empty() ) || ( !ReadFile( sChannel, sFile ) ) ) diff --git a/modules/schat.cpp b/modules/schat.cpp index 7b290aa4..f14af648 100644 --- a/modules/schat.cpp +++ b/modules/schat.cpp @@ -4,6 +4,7 @@ #include "Modules.h" #include "Chan.h" #include "Utils.h" +#include "String.h" #include "FileUtils.h" #include "Csocket.h" #include "md5.h" @@ -15,11 +16,14 @@ * Author: imaginos * * $Log$ + * Revision 1.9 2005/05/05 18:11:04 prozacx + * Changed all references to std::string over to CString + * * Revision 1.8 2005/05/02 22:34:52 prozacx * Get CFile from FileUtils.h now * * Revision 1.7 2005/04/04 06:35:19 imaginos - * fixed int32's that test against npos to string::size_type + * fixed int32's that test against npos to CString::size_type * * Revision 1.6 2005/04/03 23:03:06 imaginos * show this requires ssl @@ -60,18 +64,18 @@ class CSChat; class CRemMarkerJob : public CTimer { public: - CRemMarkerJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const string& sLabel, const string& sDescription ) + CRemMarkerJob( CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription ) : CTimer( pModule, uInterval, uCycles, sLabel, sDescription) {} virtual ~CRemMarkerJob() {} - void SetNick( const string & sNick ) + void SetNick( const CString & sNick ) { m_sNick = sNick; } protected: virtual void RunJob(); - string m_sNick; + CString m_sNick; }; class CSChatSock : public Csock @@ -115,17 +119,17 @@ public: { m_pModule = p; } - void SetChatNick( const string & sNick ) + void SetChatNick( const CString & sNick ) { m_sChatNick = sNick; } - const string & GetChatNick() const { return( m_sChatNick ); } + const CString & GetChatNick() const { return( m_sChatNick ); } virtual void ReadLine( const CS_STRING & sLine ); virtual void Disconnected(); - virtual void AddLine( const string & sLine ) + virtual void AddLine( const CString & sLine ) { m_vBuffer.insert( m_vBuffer.begin(), sLine ); if ( m_vBuffer.size() > 200 ) @@ -142,7 +146,7 @@ public: private: CSChat *m_pModule; - string m_sChatNick; + CString m_sChatNick; vector m_vBuffer; }; @@ -154,7 +158,7 @@ public: MODCONSTRUCTOR(CSChat) {} virtual ~CSChat() { CleanSocks(); } - virtual bool OnLoad( const string & sArgs ) + virtual bool OnLoad( const CString & sArgs ) { m_sPemFile = sArgs; @@ -173,7 +177,7 @@ public: virtual void OnUserAttached() { - string sName = "SCHAT::" + m_pUser->GetUserName(); + CString sName = "SCHAT::" + m_pUser->GetUserName(); for( u_int a = 0; a < m_pManager->size(); a++ ) { if ( ( strncmp( (*m_pManager)[a]->GetSockName().c_str(), sName.c_str(), sName.length() ) != 0 ) || ( (*m_pManager)[a]->GetType() == CSChatSock::LISTENER ) ) @@ -187,7 +191,7 @@ public: void CleanSocks() { - string sName = "SCHAT::" + m_pUser->GetUserName(); + CString sName = "SCHAT::" + m_pUser->GetUserName(); for( u_int a= 0; a < m_pManager->size(); a++ ) { if ( strncmp( (*m_pManager)[a]->GetSockName().c_str(), sName.c_str(), sName.length() ) == 0 ) @@ -195,16 +199,16 @@ public: } } - virtual string GetDescription() + virtual CString GetDescription() { return ( "Secure cross platform (:P) chat system" ); } - virtual bool OnUserRaw( string & sLine ) + virtual bool OnUserRaw( CString & sLine ) { if ( strncasecmp( sLine.c_str(), "schat ", 6 ) == 0 ) { - OnModCommand( "chat " + sLine.substr( 6, string::npos ) ); + OnModCommand( "chat " + sLine.substr( 6, CString::npos ) ); return( true ); } else if ( strcasecmp( sLine.c_str(), "schat" ) == 0 ) @@ -217,22 +221,22 @@ public: return( false ); } - virtual void OnModCommand( const string& sCommand ) + virtual void OnModCommand( const CString& sCommand ) { - string::size_type iPos = sCommand.find( " " ); - string sCom, sArgs; - if ( iPos == string::npos ) + CString::size_type iPos = sCommand.find( " " ); + CString sCom, sArgs; + if ( iPos == CString::npos ) sCom = sCommand; else { sCom = sCommand.substr( 0, iPos ); - sArgs = sCommand.substr( iPos + 1, string::npos ); + sArgs = sCommand.substr( iPos + 1, CString::npos ); } if ( ( strcasecmp( sCom.c_str(), "chat" ) == 0 ) && ( !sArgs.empty() ) ) { - string sSockName = "SCHAT::" + m_pUser->GetUserName(); - string sNick = "(s)" + sArgs; + CString sSockName = "SCHAT::" + m_pUser->GetUserName(); + CString sNick = "(s)" + sArgs; for( u_int a= 0; a < m_pManager->size(); a++ ) { if ( strncmp( (*m_pManager)[a]->GetSockName().c_str(), sSockName.c_str(), sSockName.length() ) != 0 ) @@ -270,7 +274,7 @@ public: } else if ( strcasecmp( sCom.c_str(), "list" ) == 0 ) { - string sName = "SCHAT::" + m_pUser->GetUserName(); + CString sName = "SCHAT::" + m_pUser->GetUserName(); CTable Table; Table.AddColumn( "Nick" ); Table.AddColumn( "Created" ); @@ -292,7 +296,7 @@ public: char *pTime = ctime( &iTime ); if ( pTime ) { - string sTime = pTime; + CString sTime = pTime; CUtils::Trim( sTime ); Table.SetCell( "Created", sTime ); } @@ -315,7 +319,7 @@ public: if ( Table.size() ) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while ( Table.GetLine( uTableIdx++, sLine ) ) PutModule( sLine ); } else @@ -323,7 +327,7 @@ public: } else if ( strcasecmp( sCom.c_str(), "close" ) == 0 ) { - string sName = "SCHAT::" + m_pUser->GetUserName(); + CString sName = "SCHAT::" + m_pUser->GetUserName(); for( u_int a= 0; a < m_pManager->size(); a++ ) { if ( strncmp( (*m_pManager)[a]->GetSockName().c_str(), sName.c_str(), sName.length() ) != 0 ) @@ -360,7 +364,7 @@ public: char *pTime = ctime( &iTime ); if ( pTime ) { - string sTime = pTime; + CString sTime = pTime; CUtils::Trim( sTime ); Table.SetCell( "Created", sTime ); } @@ -389,7 +393,7 @@ public: if ( Table.size() ) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while ( Table.GetLine( uTableIdx++, sLine ) ) PutModule( sLine ); } else @@ -410,7 +414,7 @@ public: PutModule( "Unknown command [" + sCom + "] [" + sArgs + "]" ); } - virtual bool OnPrivCTCP( const CNick& Nick, string& sMessage ) + virtual bool OnPrivCTCP( const CNick& Nick, CString& sMessage ) { if ( strncasecmp( sMessage.c_str(), "DCC SCHAT ", 10 ) == 0 ) { @@ -435,24 +439,24 @@ public: return( false ); } - void AcceptSDCC( const string & sNick, u_long iIP, u_short iPort ) + void AcceptSDCC( const CString & sNick, u_long iIP, u_short iPort ) { CSChatSock *p = new CSChatSock( CUtils::GetIP( iIP ), iPort, 60 ); p->SetModule( this ); p->SetChatNick( sNick ); - string sSockName = "SCHAT::" + m_pUser->GetUserName() + "::" + sNick; + CString sSockName = "SCHAT::" + m_pUser->GetUserName() + "::" + sNick; m_pManager->Connect( CUtils::GetIP( iIP ), iPort, sSockName, 60, true, m_pUser->GetLocalIP(), p ); RemTimer( "Remove " + sNick ); // delete any associated timer to this nick } - virtual bool OnUserMsg( const string& sTarget, string& sMessage ) + virtual bool OnUserMsg( const CString& sTarget, CString& sMessage ) { if ( strncmp( sTarget.c_str(), "(s)", 3 ) == 0 ) { - string sSockName = "SCHAT::" + m_pUser->GetUserName() + "::" + sTarget; + CString sSockName = "SCHAT::" + m_pUser->GetUserName() + "::" + sTarget; CSChatSock *p = (CSChatSock *)m_pManager->FindSockByName( sSockName ); if ( !p ) { - map< string,pair< u_long,u_short > >::iterator it = m_siiWaitingChats.find( sTarget ); + map< CString,pair< u_long,u_short > >::iterator it = m_siiWaitingChats.find( sTarget ); if ( it != m_siiWaitingChats.end() ) { if ( strcasecmp( sMessage.c_str(), "yes" ) != 0 ) @@ -472,17 +476,17 @@ public: return( false ); } - virtual void RemoveMarker( const string & sNick ) + virtual void RemoveMarker( const CString & sNick ) { - map< string,pair< u_long,u_short > >::iterator it = m_siiWaitingChats.find( sNick ); + map< CString,pair< u_long,u_short > >::iterator it = m_siiWaitingChats.find( sNick ); if ( it != m_siiWaitingChats.end() ) m_siiWaitingChats.erase( it ); } - void SendToUser( const string & sFrom, const string & sText ) + void SendToUser( const CString & sFrom, const CString & sText ) { //:*schat!znc@znc.com PRIVMSG Jim : - string sSend = ":" + sFrom + " PRIVMSG " + m_pUser->GetCurNick() + " :" + sText; + CString sSend = ":" + sFrom + " PRIVMSG " + m_pUser->GetCurNick() + " :" + sText; PutUser( sSend ); } @@ -492,8 +496,8 @@ public: } private: - map< string,pair< u_long,u_short > > m_siiWaitingChats; - string m_sPemFile; + map< CString,pair< u_long,u_short > > m_siiWaitingChats; + CString m_sPemFile; }; @@ -503,7 +507,7 @@ void CSChatSock::ReadLine( const CS_STRING & sLine ) { if ( m_pModule ) { - string sText = sLine; + CString sText = sLine; if ( sText[sText.length()-1] == '\n' ) sText.erase( sText.length()-1, 1 ); diff --git a/modules/shell.cpp b/modules/shell.cpp index 97d45bfa..8701fc29 100644 --- a/modules/shell.cpp +++ b/modules/shell.cpp @@ -16,7 +16,7 @@ class CShellMod; class CExecSock : public Csock { public: - CExecSock(CShellMod* pShellMod, const string& sExec) : Csock() { + CExecSock(CShellMod* pShellMod, const CString& sExec) : Csock() { EnableReadLine(); m_pParent = pShellMod; int iReadFD, iWriteFD; @@ -31,13 +31,13 @@ public: } // These next two function's bodies are at the bottom of the file since they reference CShellMod - virtual void ReadLine(const string& sData); + virtual void ReadLine(const CString& sData); virtual void Disconnected(); CShellMod* m_pParent; int m_iPid; - int popen2(int & iReadFD, int & iWriteFD, const string & sCommand) { + int popen2(int & iReadFD, int & iWriteFD, const CString & sCommand) { int rpipes[2] = { -1, -1 }; int wpipes[2] = { -1, -1 }; iReadFD = -1; @@ -101,13 +101,13 @@ public: } } - virtual string GetDescription() { + virtual CString GetDescription() { return "Gives shell access."; } - virtual void OnModCommand(const string& sCommand) { + virtual void OnModCommand(const CString& sCommand) { if ((strcasecmp(sCommand.c_str(), "cd") == 0) || (strncasecmp(sCommand.c_str(), "cd ", 3) == 0)) { - string sPath = CUtils::ChangeDir(m_sPath, ((sCommand.length() == 2) ? m_pUser->GetHomePath() : sCommand.substr(3)), m_pUser->GetHomePath()); + CString sPath = CUtils::ChangeDir(m_sPath, ((sCommand.length() == 2) ? CString(m_pUser->GetHomePath()) : CString(sCommand.substr(3))), m_pUser->GetHomePath()); CFile Dir(sPath); if (Dir.IsDir()) { @@ -120,8 +120,8 @@ public: PutShell("znc$"); } else if (strcasecmp(CUtils::Token(sCommand, 0).c_str(), "SEND") == 0) { - string sToNick = CUtils::Token(sCommand, 1); - string sFile = CUtils::Token(sCommand, 2); + CString sToNick = CUtils::Token(sCommand, 1); + CString sFile = CUtils::Token(sCommand, 2); if ((sToNick.empty()) || (sFile.empty())) { PutShell("usage: Send "); @@ -137,7 +137,7 @@ public: } } } else if (strcasecmp(CUtils::Token(sCommand, 0).c_str(), "GET") == 0) { - string sFile = CUtils::Token(sCommand, 1); + CString sFile = CUtils::Token(sCommand, 1); if (sFile.empty()) { PutShell("usage: Get "); @@ -157,7 +157,7 @@ public: } } - virtual bool OnStatusCommand(const string& sCommand) { + virtual bool OnStatusCommand(const CString& sCommand) { if (strcasecmp(sCommand.c_str(), "SHELL") == 0) { PutShell("-- ZNC Shell Service --"); return true; @@ -166,9 +166,9 @@ public: return false; } - virtual bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const string& sFile, unsigned long uFileSize) { - if (strcasecmp(RemoteNick.GetNick().c_str(), string(GetModNick()).c_str()) == 0) { - string sLocalFile = CUtils::ChangeDir(m_sPath, sFile, m_pUser->GetHomePath()); + virtual bool OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) { + if (strcasecmp(RemoteNick.GetNick().c_str(), CString(GetModNick()).c_str()) == 0) { + CString sLocalFile = CUtils::ChangeDir(m_sPath, sFile, m_pUser->GetHomePath()); m_pUser->GetFile(m_pUser->GetCurNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize, GetModName()); @@ -178,11 +178,11 @@ public: return false; } - void PutShell(const string& sLine) { - string sPath = m_sPath; + void PutShell(const CString& sLine) { + CString sPath = m_sPath; - string::size_type a = sPath.find(' '); - while (a != string::npos) { + CString::size_type a = sPath.find(' '); + while (a != CString::npos) { sPath.replace(a, 1, "_"); a = sPath.find(' '); } @@ -190,22 +190,22 @@ public: PutModule(sLine, m_pUser->GetCurNick(), sPath); } - void RunCommand(const string& sCommand) { + void RunCommand(const CString& sCommand) { m_pManager->AddSock((Csock*) new CExecSock(this, "cd " + m_sPath + " && " + sCommand), "SHELL"); } private: - string m_sPath; + CString m_sPath; }; -void CExecSock::ReadLine(const string& sData) { - string sLine = sData; +void CExecSock::ReadLine(const CString& sData) { + CString sLine = sData; while ((sLine.length()) && (sLine[sLine.length() -1] == '\r') || (sLine[sLine.length() -1] == '\n')) { sLine = sLine.substr(0, sLine.length() -1); } - string::size_type a = sLine.find('\t'); - while (a != string::npos) { + CString::size_type a = sLine.find('\t'); + while (a != CString::npos) { sLine.replace(a, 1, " "); a = sLine.find('\t'); } diff --git a/modules/watch.cpp b/modules/watch.cpp index 66dd2d77..574cce77 100644 --- a/modules/watch.cpp +++ b/modules/watch.cpp @@ -11,14 +11,14 @@ using std::list; class CWatchSource { public: - CWatchSource(const string& sSource, bool bNegated) { + CWatchSource(const CString& sSource, bool bNegated) { m_sSource = sSource; m_bNegated = bNegated; } virtual ~CWatchSource() {} // Getters - const string& GetSource() const { return m_sSource; } + const CString& GetSource() const { return m_sSource; } bool IsNegated() const { return m_bNegated; } // !Getters @@ -27,12 +27,12 @@ public: private: protected: bool m_bNegated; - string m_sSource; + CString m_sSource; }; class CWatchEntry { public: - CWatchEntry(const string& sHostMask, const string& sTarget, const string& sPattern) { + CWatchEntry(const CString& sHostMask, const CString& sTarget, const CString& sPattern) { m_bDisabled = false; m_sPattern = (sPattern.size()) ? sPattern : "*"; @@ -54,7 +54,7 @@ public: } virtual ~CWatchEntry() {} - bool IsMatch(const CNick& Nick, const string& sText, const string& sSource) { + bool IsMatch(const CNick& Nick, const CString& sText, const CString& sSource) { if (IsDisabled()) { return false; } @@ -88,13 +88,13 @@ public: } // Getters - const string& GetHostMask() const { return m_sHostMask; } - const string& GetTarget() const { return m_sTarget; } - const string& GetPattern() const { return m_sPattern; } + const CString& GetHostMask() const { return m_sHostMask; } + const CString& GetTarget() const { return m_sTarget; } + const CString& GetPattern() const { return m_sPattern; } bool IsDisabled() const { return m_bDisabled; } const vector& GetSources() const { return m_vsSources; } - string GetSourcesStr() const { - string sRet; + CString GetSourcesStr() const { + CString sRet; for (unsigned int a = 0; a < m_vsSources.size(); a++) { const CWatchSource& WatchSource = m_vsSources[a]; @@ -115,13 +115,13 @@ public: // !Getters // Setters - void SetHostMask(const string& s) { m_sHostMask = s; } - void SetTarget(const string& s) { m_sTarget = s; } - void SetPattern(const string& s) { m_sPattern = s; } + void SetHostMask(const CString& s) { m_sHostMask = s; } + void SetTarget(const CString& s) { m_sTarget = s; } + void SetPattern(const CString& s) { m_sPattern = s; } void SetDisabled(bool b = true) { m_bDisabled = b; } - void SetSources(const string& sSources) { + void SetSources(const CString& sSources) { unsigned int uIdx = 1; - string sSrc = CUtils::Token(sSources, 0); + CString sSrc = CUtils::Token(sSources, 0); m_vsSources.clear(); @@ -140,9 +140,9 @@ public: // !Setters private: protected: - string m_sHostMask; - string m_sTarget; - string m_sPattern; + CString m_sHostMask; + CString m_sTarget; + CString m_sPattern; bool m_bDisabled; vector m_vsSources; }; @@ -153,23 +153,23 @@ public: m_Buffer.SetLineCount(500); } - virtual bool OnLoad(const string& sArgs) { + virtual bool OnLoad(const CString& sArgs) { return true; } virtual ~CWatcherMod() { } - virtual string GetDescription() { + virtual CString GetDescription() { return "Copy activity from a specific user into a separate window."; } - virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const string& sModes, const string& sArgs) { + virtual void OnRawMode(const CNick& OpNick, const CChan& Channel, const CString& sModes, const CString& sArgs) { Process(OpNick, "* " + OpNick.GetNick() + " sets mode: " + sModes + " " + sArgs + " on " + Channel.GetName(), Channel.GetName()); } virtual void OnUserAttached() { - string sBufLine; + CString sBufLine; while (m_Buffer.GetNextLine(m_pUser->GetCurNick(), sBufLine)) { PutUser(sBufLine); } @@ -177,7 +177,7 @@ public: m_Buffer.Clear(); } - virtual bool OnUserRaw(string& sLine) { + virtual bool OnUserRaw(CString& sLine) { if (strncasecmp(sLine.c_str(), "WATCH ", 6) == 0) { Watch(CUtils::Token(sLine, 1), CUtils::Token(sLine, 2), CUtils::Token(sLine, 3, true), true); return true; @@ -186,11 +186,11 @@ public: return false; } - virtual void OnKick(const CNick& OpNick, const string& sKickedNick, const CChan& Channel, const string& sMessage) { + virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, const CChan& Channel, const CString& sMessage) { Process(OpNick, "* " + OpNick.GetNick() + " kicked " + sKickedNick + " from " + Channel.GetName() + " because [" + sMessage + "]", Channel.GetName()); } - virtual void OnQuit(const CNick& Nick, const string& sMessage, const vector& vChans) { + virtual void OnQuit(const CNick& Nick, const CString& sMessage, const vector& vChans) { Process(Nick, "* Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", ""); } @@ -202,47 +202,47 @@ public: Process(Nick, "* " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") parts " + Channel.GetName(), Channel.GetName()); } - virtual void OnNick(const CNick& OldNick, const string& sNewNick, const vector& vChans) { + virtual void OnNick(const CNick& OldNick, const CString& sNewNick, const vector& vChans) { Process(OldNick, "* " + OldNick.GetNick() + " is now known as " + sNewNick, ""); } - virtual bool OnCTCPReply(const CNick& Nick, string& sMessage) { + virtual bool OnCTCPReply(const CNick& Nick, CString& sMessage) { Process(Nick, "* CTCP: " + Nick.GetNick() + " reply [" + sMessage + "]", "priv"); return false; } - virtual bool OnPrivCTCP(const CNick& Nick, string& sMessage) { + virtual bool OnPrivCTCP(const CNick& Nick, CString& sMessage) { Process(Nick, "* CTCP: " + Nick.GetNick() + " [" + sMessage + "]", "priv"); return false; } - virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, string& sMessage) { + virtual bool OnChanCTCP(const CNick& Nick, const CChan& Channel, CString& sMessage) { Process(Nick, "* CTCP: " + Nick.GetNick() + " [" + sMessage + "] to [" + Channel.GetName() + "]", Channel.GetName()); return false; } - virtual bool OnPrivNotice(const CNick& Nick, string& sMessage) { + virtual bool OnPrivNotice(const CNick& Nick, CString& sMessage) { Process(Nick, "-" + Nick.GetNick() + "- " + sMessage, "priv"); return false; } - virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, string& sMessage) { + virtual bool OnChanNotice(const CNick& Nick, const CChan& Channel, CString& sMessage) { Process(Nick, "-" + Nick.GetNick() + ":" + Channel.GetName() + "- " + sMessage, Channel.GetName()); return false; } - virtual bool OnPrivMsg(const CNick& Nick, string& sMessage) { + virtual bool OnPrivMsg(const CNick& Nick, CString& sMessage) { Process(Nick, "<" + Nick.GetNick() + "> " + sMessage, "priv"); return false; } - virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, string& sMessage) { + virtual bool OnChanMsg(const CNick& Nick, const CChan& Channel, CString& sMessage) { Process(Nick, "<" + Nick.GetNick() + ":" + Channel.GetName() + "> " + sMessage, Channel.GetName()); return false; } - virtual void OnModCommand(const string& sCommand) { - string sCmdName = CUtils::Token(sCommand, 0); + virtual void OnModCommand(const CString& sCommand) { + CString sCmdName = CUtils::Token(sCommand, 0); if (strcasecmp(sCmdName.c_str(), "ADD") == 0 || strcasecmp(sCmdName.c_str(), "WATCH") == 0) { Watch(CUtils::Token(sCommand, 1), CUtils::Token(sCommand, 2), CUtils::Token(sCommand, 3, true)); } else if (strcasecmp(sCmdName.c_str(), "HELP") == 0) { @@ -252,7 +252,7 @@ public: } else if (strcasecmp(sCmdName.c_str(), "DUMP") == 0) { Dump(); } else if (strcasecmp(sCmdName.c_str(), "ENABLE") == 0) { - string sTok = CUtils::Token(sCommand, 1); + CString sTok = CUtils::Token(sCommand, 1); if (sTok == "*") { SetDisabled(~0, false); @@ -260,7 +260,7 @@ public: SetDisabled(atoi(sTok.c_str()), false); } } else if (strcasecmp(sCmdName.c_str(), "DISABLE") == 0) { - string sTok = CUtils::Token(sCommand, 1); + CString sTok = CUtils::Token(sCommand, 1); if (sTok == "*") { SetDisabled(~0, true); @@ -273,7 +273,7 @@ public: m_lsWatchers.clear(); PutModule("All entries cleared."); } else if (strcasecmp(sCmdName.c_str(), "BUFFER") == 0) { - string sCount = CUtils::Token(sCommand, 1); + CString sCount = CUtils::Token(sCommand, 1); if (sCount.size()) { m_Buffer.SetLineCount(atoi(sCount.c_str())); @@ -288,7 +288,7 @@ public: } private: - void Process(const CNick& Nick, const string& sMessage, const string& sSource) { + void Process(const CNick& Nick, const CString& sMessage, const CString& sSource) { for (list::iterator it = m_lsWatchers.begin(); it != m_lsWatchers.end(); it++) { CWatchEntry& WatchEntry = *it; @@ -350,7 +350,7 @@ private: if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutModule(sLine); @@ -388,7 +388,7 @@ private: PutModule("---------------"); } - void SetSources(unsigned int uIdx, const string& sSources) { + void SetSources(unsigned int uIdx, const CString& sSources) { uIdx--; // "convert" index to zero based if (uIdx >= m_lsWatchers.size()) { PutModule("Invalid Id"); @@ -464,7 +464,7 @@ private: if (Table.size()) { unsigned int uTableIdx = 0; - string sLine; + CString sLine; while (Table.GetLine(uTableIdx++, sLine)) { PutModule(sLine); @@ -472,8 +472,8 @@ private: } } - void Watch(const string& sHostMask, const string& sTarget, const string& sPattern, bool bNotice = false) { - string sMessage; + void Watch(const CString& sHostMask, const CString& sTarget, const CString& sPattern, bool bNotice = false) { + CString sMessage; if (sHostMask.size()) { CWatchEntry WatchEntry(sHostMask, sTarget, sPattern); diff --git a/znc.cpp b/znc.cpp index 8227641b..3273f69e 100644 --- a/znc.cpp +++ b/znc.cpp @@ -23,7 +23,7 @@ CZNC::~CZNC() { DeleteUsers(); } -string CZNC::GetTag(bool bIncludeVersion) { +CString CZNC::GetTag(bool bIncludeVersion) { if (!bIncludeVersion) { return "ZNC - by prozac@gmail.com"; } @@ -36,7 +36,7 @@ string CZNC::GetTag(bool bIncludeVersion) { } bool CZNC::OnBoot() { - for (map::iterator it = m_msUsers.begin(); it != m_msUsers.end(); it++) { + for (map::iterator it = m_msUsers.begin(); it != m_msUsers.end(); it++) { if (!it->second->OnBoot()) { return false; } @@ -60,7 +60,7 @@ int CZNC::Loop() { m_itUserIter = m_msUsers.begin(); } - string sSockName = "IRC::" + m_itUserIter->first; + CString sSockName = "IRC::" + m_itUserIter->first; CUser* pUser = m_itUserIter->second; m_itUserIter++; @@ -157,7 +157,7 @@ bool CZNC::WritePidFile(int iPid) { } void CZNC::DeleteUsers() { - for (map::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) { + for (map::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) { delete a->second; } @@ -165,13 +165,13 @@ void CZNC::DeleteUsers() { m_itUserIter = m_msUsers.end(); } -CUser* CZNC::GetUser(const string& sUser) { +CUser* CZNC::GetUser(const CString& sUser) { // Todo: make this case insensitive - map::iterator it = m_msUsers.find(sUser); + map::iterator it = m_msUsers.find(sUser); return (it == m_msUsers.end()) ? NULL : it->second; } -Csock* CZNC::FindSockByName(const string& sSockName) { +Csock* CZNC::FindSockByName(const CString& sSockName) { return m_Manager.FindSockByName(sSockName); } @@ -193,8 +193,8 @@ bool CZNC::Listen() { return m_Manager.ListenAll(m_uListenPort, "_LISTENER", bSSL, SOMAXCONN, pUserSock); } -bool CZNC::IsHostAllowed(const string& sHostMask) { - for (map::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) { +bool CZNC::IsHostAllowed(const CString& sHostMask) { + for (map::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) { if (a->second->IsHostAllowed(sHostMask)) { return true; } @@ -203,13 +203,13 @@ bool CZNC::IsHostAllowed(const string& sHostMask) { return false; } -void CZNC::InitDirs(const string& sArgvPath) { +void CZNC::InitDirs(const CString& sArgvPath) { char buf[PATH_MAX]; getcwd(buf, PATH_MAX); // If the bin was not ran from the current directory, we need to add that dir onto our cwd - string::size_type uPos = sArgvPath.rfind('/'); - m_sCurPath = (uPos == string::npos) ? string(buf) : CUtils::ChangeDir(buf, sArgvPath.substr(0, uPos), ""); + CString::size_type uPos = sArgvPath.rfind('/'); + m_sCurPath = (uPos == CString::npos) ? CString(buf) : CUtils::ChangeDir(buf, sArgvPath.substr(0, uPos), ""); // Try to set the user's home dir, default to binpath on failure struct passwd* pUserInfo = getpwuid(getuid()); @@ -231,8 +231,8 @@ void CZNC::InitDirs(const string& sArgvPath) { } -string CZNC::GetConfigPath(const string& sConfigFile) { - string sRetPath; +CString CZNC::GetConfigPath(const CString& sConfigFile) { + CString sRetPath; if (sConfigFile.empty()) { sRetPath = GetZNCPath() + "/znc.conf"; @@ -249,9 +249,9 @@ string CZNC::GetConfigPath(const string& sConfigFile) { return sRetPath; } -bool CZNC::WriteNewConfig(const string& sConfig) { - string sAnswer, sUser; - vector vsLines; +bool CZNC::WriteNewConfig(const CString& sConfig) { + CString sAnswer, sUser; + vector vsLines; bool bAnswer = false; CUtils::PrintMessage(""); @@ -265,7 +265,7 @@ bool CZNC::WriteNewConfig(const string& sConfig) { bAnswer = CUtils::GetBoolInput("Would you like ZNC to listen using SSL?", false); #endif - vsLines.push_back("ListenPort = " + string((bAnswer) ? "+" : "") + CUtils::ToString(uPort)); + vsLines.push_back("ListenPort = " + CString((bAnswer) ? "+" : "") + CUtils::ToString(uPort)); // !ListenPort // User @@ -275,7 +275,7 @@ bool CZNC::WriteNewConfig(const string& sConfig) { do { vsLines.push_back(""); - string sNick; + CString sNick; do { CUtils::GetInput("Username", sUser, "", "AlphaNumeric"); } while (!CUser::IsValidUserName(sUser)); @@ -320,13 +320,13 @@ bool CZNC::WriteNewConfig(const string& sConfig) { if (CUtils::GetBoolInput("Do you want to automatically load any modules at all?")) { for (set::iterator it = ssMods.begin(); it != ssMods.end(); it++) { const CModInfo& Info = *it; - string sName = Info.GetName(); + CString sName = Info.GetName(); if (strcasecmp(CUtils::Right(sName, 3).c_str(), ".so") == 0) { CUtils::RightChomp(sName, 3); } - if (CUtils::GetBoolInput("Load " + string((Info.IsSystem()) ? "system" : "local") + " module <\033[1m" + sName + "\033[22m>?", false)) { + if (CUtils::GetBoolInput("Load " + CString((Info.IsSystem()) ? "system" : "local") + " module <\033[1m" + sName + "\033[22m>?", false)) { vsLines.push_back("\tLoadModule = " + sName); } } @@ -339,7 +339,7 @@ bool CZNC::WriteNewConfig(const string& sConfig) { CUtils::PrintMessage(""); do { - string sHost, sPass; + CString sHost, sPass; bool bSSL = false; unsigned int uPort = 0; @@ -359,8 +359,8 @@ bool CZNC::WriteNewConfig(const string& sConfig) { CUtils::PrintMessage("-- Channels --"); CUtils::PrintMessage(""); - string sArg = "a"; - string sPost = " for ZNC to automatically join?"; + CString sArg = "a"; + CString sPost = " for ZNC to automatically join?"; bool bDefault = true; while (CUtils::GetBoolInput("Would you like to add " + sArg + " channel" + sPost, bDefault)) { @@ -378,7 +378,7 @@ bool CZNC::WriteNewConfig(const string& sConfig) { } while (CUtils::GetBoolInput("Would you like to setup another user?", false)); // !User - string sConfigFile = GetConfigPath(sConfig); + CString sConfigFile = GetConfigPath(sConfig); CUtils::PrintAction("Writing config [" + sConfigFile + "]"); CFile File(sConfigFile); @@ -406,9 +406,9 @@ bool CZNC::WriteNewConfig(const string& sConfig) { return true; } -bool CZNC::ParseConfig(const string& sConfig) { - string sStatusPrefix; - string sConfigFile = GetConfigPath(sConfig); +bool CZNC::ParseConfig(const CString& sConfig) { + CString sStatusPrefix; + CString sConfigFile = GetConfigPath(sConfig); CUtils::PrintAction("Opening Config [" + sConfigFile + "]"); @@ -441,7 +441,7 @@ bool CZNC::ParseConfig(const string& sConfig) { CUtils::PrintStatus(true); - string sLine; + CString sLine; bool bCommented = false; // support for /**/ style comments bool bAutoCycle = true; CUser* pUser = NULL; // Used to keep track of which user block we are in @@ -477,14 +477,14 @@ bool CZNC::ParseConfig(const string& sConfig) { CUtils::RightChomp(sLine); CUtils::Trim(sLine); - string sTag = sLine.substr(0, sLine.find_first_of(" \t\r\n")); - string sValue = (sTag.size() < sLine.size()) ? sLine.substr(sTag.size() +1) : ""; + CString sTag = sLine.substr(0, sLine.find_first_of(" \t\r\n")); + CString sValue = (sTag.size() < sLine.size()) ? sLine.substr(sTag.size() +1) : ""; CUtils::Trim(sTag); CUtils::Trim(sValue); if (CUtils::Left(sLine, 1) == "/") { - string sTag = sLine.substr(1); + CString sTag = sLine.substr(1); if (pUser) { if (pChan) { @@ -494,7 +494,7 @@ bool CZNC::ParseConfig(const string& sConfig) { continue; } } else if (strcasecmp(sTag.c_str(), "User") == 0) { - string sErr; + CString sErr; if (!pUser->IsValid(sErr)) { CUtils::PrintError("Invalid user [" + pUser->GetUserName() + "] " + sErr); @@ -552,8 +552,8 @@ bool CZNC::ParseConfig(const string& sConfig) { } // If we have a regular line, figure out where it goes - string sName = CUtils::Token(sLine, 0, false, '='); - string sValue = CUtils::Token(sLine, 1, true, '='); + CString sName = CUtils::Token(sLine, 0, false, '='); + CString sValue = CUtils::Token(sLine, 1, true, '='); CUtils::Trim(sName); CUtils::Trim(sValue); @@ -649,11 +649,11 @@ bool CZNC::ParseConfig(const string& sConfig) { pUser->AddChan(sValue); continue; } else if (strcasecmp(sName.c_str(), "LoadModule") == 0) { - string sModName = CUtils::Token(sValue, 0); + CString sModName = CUtils::Token(sValue, 0); CUtils::PrintAction("Loading Module [" + sModName + "]"); #ifdef _MODULES - string sModRet; - string sArgs = CUtils::Token(sValue, 1, true); + CString sModRet; + CString sArgs = CUtils::Token(sValue, 1, true); try { bool bModRet = pUser->GetModules().LoadModule(sModName, sArgs, pUser, sModRet); @@ -671,14 +671,14 @@ bool CZNC::ParseConfig(const string& sConfig) { } else { if (strcasecmp(sName.c_str(), "ListenPort") == 0) { m_bSSL = false; - string sPort = sValue; + CString sPort = sValue; if (CUtils::Left(sPort, 1) == "+") { CUtils::LeftChomp(sPort); m_bSSL = true; } m_uListenPort = strtol(sPort.c_str(), NULL, 10); - CUtils::PrintAction("Binding to port [" + string((m_bSSL) ? "+" : "") + CUtils::ToString(m_uListenPort) + "]"); + CUtils::PrintAction("Binding to port [" + CString((m_bSSL) ? "+" : "") + CUtils::ToString(m_uListenPort) + "]"); #ifndef HAVE_LIBSSL if (m_bSSL) { @@ -686,7 +686,7 @@ bool CZNC::ParseConfig(const string& sConfig) { return false; } #else - string sPemFile = GetPemLocation(); + CString sPemFile = GetPemLocation(); if ((m_bSSL) && (!CFile::Exists(sPemFile))) { CUtils::PrintStatus(false, "Unable to locate pem file: [" + sPemFile + "]"); @@ -714,7 +714,7 @@ bool CZNC::ParseConfig(const string& sConfig) { return false; } - CUtils::PrintAction("Binding to port [" + string((m_bSSL) ? "+" : "") + CUtils::ToString(m_uListenPort) + "]"); + CUtils::PrintAction("Binding to port [" + CString((m_bSSL) ? "+" : "") + CUtils::ToString(m_uListenPort) + "]"); } #endif if (!m_uListenPort) { diff --git a/znc.h b/znc.h index d4120875..eb4c268d 100644 --- a/znc.h +++ b/znc.h @@ -18,27 +18,27 @@ public: int Loop(); void ReleaseISpoof(); bool WritePidFile(int iPid); - CUser* GetUser(const string& sUser); - Csock* FindSockByName(const string& sSockName); + CUser* GetUser(const CString& sUser); + Csock* FindSockByName(const CString& sSockName); bool Listen(); - bool ParseConfig(const string& sConfig); - bool IsHostAllowed(const string& sHostMask); - void InitDirs(const string& sArgvPath); + bool ParseConfig(const CString& sConfig); + bool IsHostAllowed(const CString& sHostMask); + void InitDirs(const CString& sArgvPath); bool OnBoot(); - string GetConfigPath(const string& sConfigFile); - bool WriteNewConfig(const string& sConfig); - static string GetTag(bool bIncludeVersion = true); + CString GetConfigPath(const CString& sConfigFile); + bool WriteNewConfig(const CString& sConfig); + static CString GetTag(bool bIncludeVersion = true); // Getters TSocketManager& GetManager() { return m_Manager; } unsigned int GetListenPort() const { return m_uListenPort; } - const string& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CUtils::MakeDir(m_sCurPath); } return m_sCurPath; } - const string& GetDLPath() const { if (!CFile::Exists(m_sDLPath)) { CUtils::MakeDir(m_sDLPath); } return m_sDLPath; } - const string& GetModPath() const { if (!CFile::Exists(m_sModPath)) { CUtils::MakeDir(m_sModPath); } return m_sModPath; } - const string& GetHomePath() const { if (!CFile::Exists(m_sHomePath)) { CUtils::MakeDir(m_sHomePath); } return m_sHomePath; } - const string& GetZNCPath() const { if (!CFile::Exists(m_sZNCPath)) { CUtils::MakeDir(m_sZNCPath); } return m_sZNCPath; } - const string& GetDataPath() const { if (!CFile::Exists(m_sDataPath)) { CUtils::MakeDir(m_sDataPath); } return m_sDataPath; } - string GetPemLocation() const { return GetZNCPath() + "/znc.pem"; } + const CString& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CUtils::MakeDir(m_sCurPath); } return m_sCurPath; } + const CString& GetDLPath() const { if (!CFile::Exists(m_sDLPath)) { CUtils::MakeDir(m_sDLPath); } return m_sDLPath; } + const CString& GetModPath() const { if (!CFile::Exists(m_sModPath)) { CUtils::MakeDir(m_sModPath); } return m_sModPath; } + const CString& GetHomePath() const { if (!CFile::Exists(m_sHomePath)) { CUtils::MakeDir(m_sHomePath); } return m_sHomePath; } + const CString& GetZNCPath() const { if (!CFile::Exists(m_sZNCPath)) { CUtils::MakeDir(m_sZNCPath); } return m_sZNCPath; } + const CString& GetDataPath() const { if (!CFile::Exists(m_sDataPath)) { CUtils::MakeDir(m_sDataPath); } return m_sDataPath; } + CString GetPemLocation() const { return GetZNCPath() + "/znc.pem"; } bool IsSSL() const { #ifdef HAVE_LIBSSL @@ -57,23 +57,23 @@ public: private: protected: unsigned short m_uListenPort; - map m_msUsers; + map m_msUsers; TSocketManager m_Manager; - string m_sCurPath; - string m_sDLPath; - string m_sModPath; - string m_sHomePath; - string m_sZNCPath; - string m_sDataPath; + CString m_sCurPath; + CString m_sDLPath; + CString m_sModPath; + CString m_sHomePath; + CString m_sZNCPath; + CString m_sDataPath; - string m_sISpoofFile; - string m_sOrigISpoof; - string m_sPidFile; + CString m_sISpoofFile; + CString m_sOrigISpoof; + CString m_sPidFile; CLockFile m_LockFile; bool m_bISpoofLocked; bool m_bSSL; - map::iterator m_itUserIter; // This needs to be reset to m_msUsers.begin() if anything is added or removed to the map + map::iterator m_itUserIter; // This needs to be reset to m_msUsers.begin() if anything is added or removed to the map }; #endif // !_ZNC_H