diff --git a/Template.cpp b/Template.cpp index 8c5455e8..7bb81950 100644 --- a/Template.cpp +++ b/Template.cpp @@ -90,30 +90,26 @@ void CTemplate::Init() { } */ - ClearPaths(); + ClearPath(); m_pParent = NULL; } -CString CTemplate::ExpandFile(const CString& sFilename, bool bFromInc) { - /*if (sFilename.Left(1) == "/" || sFilename.Left(2) == "./") { +CString CTemplate::ExpandFile(const CString& sFilename) { + if (sFilename.Left(1) == "/" || sFilename.Left(2) == "./") { return sFilename; - }*/ + } - CString sFile(ResolveLiteral(sFilename).TrimLeft_n("/")); + CString sFile(ResolveLiteral(sFilename)); - for (list >::iterator it = m_lsbPaths.begin(); it != m_lsbPaths.end(); it++) { - if (it->second && !bFromInc) { - continue; - } - - CString sRoot = it->first; + for (LCString::iterator it = m_lsPaths.begin(); it != m_lsPaths.end(); it++) { + CString sRoot = *it; CString sFilePath(CDir::ChangeDir(sRoot, sFile)); if (CFile::Exists(sFilePath)) { // This only works if sRoot got a trailing slash! The // code which adds paths makes sure this is true. if (sRoot.empty() || sFilePath.Left(sRoot.length()) == sRoot) { - DEBUG("\t\tFound [" + sFilePath + "]\n"); + //DEBUG("\t\tFound [" + sFilePath + "]\n"); return sFilePath; } else { DEBUG("\t\tOutside of root [" + sFilePath + "] !~ [" + sRoot + "]"); @@ -123,15 +119,15 @@ CString CTemplate::ExpandFile(const CString& sFilename, bool bFromInc) { } } - switch (m_lsbPaths.size()) { + switch (m_lsPaths.size()) { case 0: DEBUG("Unable to find [" + sFile + "] using the current directory"); break; case 1: - DEBUG("Unable to find [" + sFile + "] in the defined path [" + m_lsbPaths.begin()->first + "]"); + DEBUG("Unable to find [" + sFile + "] in the defined path [" + *m_lsPaths.begin()); break; default: - DEBUG("Unable to find [" + sFile + "] in any of the " + CString(m_lsbPaths.size()) + " defined paths"); + DEBUG("Unable to find [" + sFile + "] in any of the " + CString(m_lsPaths.size()) + " defined paths"); } return ""; @@ -142,39 +138,31 @@ void CTemplate::SetPath(const CString& sPaths) { sPaths.Split(":", vsDirs, false); for (size_t a = 0; a < vsDirs.size(); a++) { - AppendPath(vsDirs[a], false); + AppendPath(vsDirs[a]); } } -void CTemplate::PrependPath(const CString& sPath, bool bIncludesOnly) { +void CTemplate::PrependPath(const CString& sPath) { DEBUG("CTemplate::PrependPath(" + sPath + ") == [" + CDir::ChangeDir("./", sPath + "/") + "]"); - m_lsbPaths.push_front(make_pair(CDir::ChangeDir("./", sPath + "/"), bIncludesOnly)); + m_lsPaths.push_front(CDir::ChangeDir("./", sPath + "/")); } -void CTemplate::AppendPath(const CString& sPath, bool bIncludesOnly) { +void CTemplate::AppendPath(const CString& sPath) { DEBUG("CTemplate::AppendPath(" + sPath + ") == [" + CDir::ChangeDir("./", sPath + "/") + "]"); - m_lsbPaths.push_back(make_pair(CDir::ChangeDir("./", sPath + "/"), bIncludesOnly)); + m_lsPaths.push_back(CDir::ChangeDir("./", sPath + "/")); } void CTemplate::RemovePath(const CString& sPath) { DEBUG("CTemplate::RemovePath(" + sPath + ") == [" + CDir::ChangeDir("./", sPath + "/") + "]"); - //m_lsbPaths.remove(CDir::ChangeDir("./", sPath + "/")); - - for (list >::iterator it = m_lsbPaths.begin(); it != m_lsbPaths.end(); it++) { - if (it->first == sPath) { - m_lsbPaths.remove(*it); - RemovePath(sPath); - return; - } - } + m_lsPaths.remove(CDir::ChangeDir("./", sPath + "/")); } -void CTemplate::ClearPaths() { - m_lsbPaths.clear(); +void CTemplate::ClearPath() { + m_lsPaths.clear(); } bool CTemplate::SetFile(const CString& sFileName) { - m_sFileName = ExpandFile(sFileName, false); + m_sFileName = ExpandFile(sFileName); PrependPath(sFileName + "/.."); if (sFileName.empty()) { @@ -242,7 +230,6 @@ bool CTemplate::PrintString(CString& sRet) { } bool CTemplate::Print(ostream& oOut) { - DEBUG("== Print(o) m_sFileName = [" + m_sFileName + "]"); return Print(m_sFileName, oOut); } @@ -324,8 +311,7 @@ bool CTemplate::Print(const CString& sFileName, ostream& oOut) { if (!uSkip) { if (sAction.Equals("INC")) { - if (!Print(ExpandFile(sArgs, true), oOut)) { - DEBUG("Unable to print INC'd file [" + sArgs + "]"); + if (!Print(ExpandFile(sArgs), oOut)) { return false; } } else if (sAction.Equals("SETOPTION")) { @@ -379,7 +365,7 @@ bool CTemplate::Print(const CString& sFileName, ostream& oOut) { sSetBlockVar = sArgs; bInSetBlock = true; } else if (sAction.Equals("EXPAND")) { - sOutput += ExpandFile(sArgs, true); + sOutput += ExpandFile(sArgs); } else if (sAction.Equals("VAR")) { sOutput += GetValue(sArgs); } else if (sAction.Equals("LT")) { diff --git a/Template.h b/Template.h index 951d8c8a..19ae3a48 100644 --- a/Template.h +++ b/Template.h @@ -145,14 +145,14 @@ public: void Init(); CTemplate* GetParent(bool bRoot); - CString ExpandFile(const CString& sFilename, bool bFromInc = false); + CString ExpandFile(const CString& sFilename); bool SetFile(const CString& sFileName); void SetPath(const CString& sPath); // Sets the dir:dir:dir type path to look at for templates, as of right now no ../../.. protection - void PrependPath(const CString& sPath, bool bIncludesOnly = false); - void AppendPath(const CString& sPath, bool bIncludesOnly = false); + void PrependPath(const CString& sPath); + void AppendPath(const CString& sPath); void RemovePath(const CString& sPath); - void ClearPaths(); + void ClearPath(); CString ResolvePath(const CString& sPath, const CString& sFilename); bool PrintString(CString& sRet); bool Print(ostream& oOut = cout); @@ -175,7 +175,7 @@ public: private: CTemplate* m_pParent; CString m_sFileName; - list > m_lsbPaths; + LCString m_lsPaths; map > m_mvLoops; vector m_vLoopContexts; CSmartPtr m_spOptions; diff --git a/User.cpp b/User.cpp index 6a28d6d2..5ec675ea 100644 --- a/User.cpp +++ b/User.cpp @@ -645,8 +645,6 @@ bool CUser::WriteConfig(CFile& File) { PrintLine(File, "QuitMsg", GetQuitMsg()); if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix()) PrintLine(File, "StatusPrefix", GetStatusPrefix()); - if (CZNC::Get().GetSkinName() != GetSkinName()) - PrintLine(File, "Skin", GetSkinName()); PrintLine(File, "ChanModes", GetDefaultChanModes()); PrintLine(File, "Buffer", CString(GetBufferCount())); PrintLine(File, "KeepBuffer", CString(KeepBuffer())); @@ -1249,6 +1247,4 @@ CString CUser::GetQuitMsg() const { return (!m_sQuitMsg.Trim_n().empty()) ? m_sQ const MCString& CUser::GetCTCPReplies() const { return m_mssCTCPReplies; } unsigned int CUser::GetBufferCount() const { return m_uBufferCount; } bool CUser::KeepBuffer() const { return m_bKeepBuffer; } -CString CUser::GetSkinName() const { return (!m_sSkinName.empty()) ? m_sSkinName : CZNC::Get().GetSkinName(); } -//CString CUser::GetSkinName() const { return m_sSkinName; } // !Getters diff --git a/User.h b/User.h index c76b57c4..aeb6d0b8 100644 --- a/User.h +++ b/User.h @@ -169,7 +169,6 @@ public: void SetTimezoneOffset(float b) { m_fTimezoneOffset = b; } void SetJoinTries(unsigned int i) { m_uMaxJoinTries = i; } void SetMaxJoins(unsigned int i) { m_uMaxJoins = i; } - void SetSkinName(const CString& s) { m_sSkinName = s; } void SetIRCConnectEnabled(bool b) { m_bIRCConnectEnabled = b; } void SetIRCAway(bool b) { m_bIRCAway = b; } // !Setters @@ -224,7 +223,6 @@ public: unsigned long long BytesWritten() const { return m_uBytesWritten; } unsigned int JoinTries() const { return m_uMaxJoinTries; } unsigned int MaxJoins() const { return m_uMaxJoins; } - CString GetSkinName() const; // !Getters private: protected: @@ -286,7 +284,6 @@ protected: unsigned long long m_uBytesWritten; unsigned int m_uMaxJoinTries; unsigned int m_uMaxJoins; - CString m_sSkinName; #ifdef _MODULES CModules* m_pModules; diff --git a/ZNCString.cpp b/ZNCString.cpp index 43ba4b6c..0c9a9b4d 100644 --- a/ZNCString.cpp +++ b/ZNCString.cpp @@ -388,25 +388,6 @@ unsigned int CString::Replace(CString& sStr, const CString& sReplace, const CStr CString CString::Token(unsigned int uPos, bool bRest, const CString& sSep, bool bAllowEmpty, const CString& sLeft, const CString& sRight, bool bTrimQuotes) const { - VCString vsTokens; - if (Split(sSep, vsTokens, bAllowEmpty, sLeft, sRight, bTrimQuotes) > uPos) { - CString sRet; - - for (unsigned int a = uPos; a < vsTokens.size(); a++) { - if (a > uPos) { - sRet += sSep; - } - - sRet += vsTokens[a]; - - if (!bRest) { - break; - } - } - - return sRet; - } - const char *sep_str = sSep.c_str(); size_t sep_len = sSep.length(); const char *str = c_str(); diff --git a/modules/webadmin.cpp b/modules/webadmin.cpp index f8ef8912..86c82bc5 100644 --- a/modules/webadmin.cpp +++ b/modules/webadmin.cpp @@ -354,7 +354,6 @@ CWebAdminSock::CWebAdminSock(CWebAdminMod* pModule, const CString& sHostname, un m_pSessionUser = NULL; m_bAdmin = false; SetDocRoot(GetSkinDir()); - m_Template.AppendPath("./"); } CWebAdminSock::~CWebAdminSock() { diff --git a/znc.cpp b/znc.cpp index 35b89e19..9b222c54 100644 --- a/znc.cpp +++ b/znc.cpp @@ -575,11 +575,6 @@ bool CZNC::WriteConfig() { if (!m_sPidFile.empty()) { m_LockFile.Write("PidFile = " + m_sPidFile.FirstLine() + "\n"); } - - if (!m_sSkinName.empty()) { - m_LockFile.Write("Skin = " + m_sSkinName.FirstLine() + "\n"); - } - if (!m_sStatusPrefix.empty()) { m_LockFile.Write("StatusPrefix = " + m_sStatusPrefix.FirstLine() + "\n"); } @@ -1423,9 +1418,6 @@ bool CZNC::DoRehash(CString& sError) } else if (sName.Equals("MaxJoins")) { pUser->SetMaxJoins(sValue.ToUInt()); continue; - } else if (sName.Equals("Skin")) { - pUser->SetSkinName(sValue); - continue; } else if (sName.Equals("LoadModule")) { CString sModName = sValue.Token(0); CUtils::PrintAction("Loading Module [" + sModName + "]"); @@ -1578,9 +1570,6 @@ bool CZNC::DoRehash(CString& sError) } else if (sName.Equals("PidFile")) { m_sPidFile = sValue; continue; - } else if (sName.Equals("Skin")) { - SetSkinName(sValue); - continue; } else if (sName.Equals("StatusPrefix")) { m_sStatusPrefix = sValue; continue; @@ -1762,24 +1751,6 @@ void CZNC::Broadcast(const CString& sMessage, bool bAdminOnly, } } -CModule* CZNC::FindModule(const CString& sModName, const CString& sUsername) { - if (sUsername.empty()) { - return CZNC::Get().GetModules().FindModule(sModName); - } - - CUser* pUser = FindUser(sUsername); - - return (!pUser) ? NULL : pUser->GetModules().FindModule(sModName); -} - -CModule* CZNC::FindModule(const CString& sModName, CUser* pUser) { - if (pUser) { - return pUser->GetModules().FindModule(sModName); - } - - return CZNC::Get().GetModules().FindModule(sModName); -} - CUser* CZNC::FindUser(const CString& sUsername) { map::iterator it = m_msUsers.find(sUsername); diff --git a/znc.h b/znc.h index ef4f81c7..c5bd934f 100644 --- a/znc.h +++ b/znc.h @@ -82,7 +82,6 @@ public: // Setters void SetConfigState(enum ConfigState e) { m_eConfigState = e; } - void SetSkinName(const CString& s) { m_sSkinName = s; } void SetStatusPrefix(const CString& s) { m_sStatusPrefix = (s.empty()) ? "*" : s; } void SetISpoofFile(const CString& s) { m_sISpoofFile = s; } void SetISpoofFormat(const CString& s) { m_sISpoofFormat = (s.empty()) ? "global { reply \"%\" }" : s; } @@ -96,7 +95,6 @@ public: CGlobalModules& GetModules() { return *m_pModules; } size_t FilterUncommonModules(set& ssModules); #endif - CString GetSkinName() const { return m_sSkinName; } const CString& GetStatusPrefix() const { return m_sStatusPrefix; } const CString& GetCurPath() const { if (!CFile::Exists(m_sCurPath)) { CDir::MakeDir(m_sCurPath); } return m_sCurPath; } const CString& GetHomePath() const { if (!CFile::Exists(m_sHomePath)) { CDir::MakeDir(m_sHomePath); } return m_sHomePath; } @@ -117,8 +115,6 @@ public: // Static allocator static CZNC& Get(); CUser* FindUser(const CString& sUsername); - CModule* FindModule(const CString& sModName, const CString& sUsername); - CModule* FindModule(const CString& sModName, CUser* pUser); bool DeleteUser(const CString& sUsername); bool AddUser(CUser* pUser, CString& sErrorRet); const map & GetUserMap() const { return(m_msUsers); } @@ -158,7 +154,6 @@ protected: CString m_sZNCPath; CString m_sConfigFile; - CString m_sSkinName; CString m_sStatusPrefix; CString m_sISpoofFile; CString m_sOrigISpoof; @@ -268,7 +263,7 @@ protected: bool m_bIPV6; unsigned short m_uPort; CString m_sBindHost; - CRealListener* m_pListener; + CRealListener* m_pListener; }; #endif // !_ZNC_H