From df1c36ca08fea12ae9c48ce30affc12765203163 Mon Sep 17 00:00:00 2001 From: imaginos Date: Mon, 17 Mar 2008 04:21:53 +0000 Subject: [PATCH] added back the ability for global modules to handle unhandled config lines git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@980 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/znc.cpp b/znc.cpp index fc782ce6..1a21d0ad 100644 --- a/znc.cpp +++ b/znc.cpp @@ -13,6 +13,17 @@ #include "User.h" #include +namespace +{ // private namespace for local things + struct CUnhandledConfigLines + { + CString m_sName; + CString m_sValue; + CUser *m_pUser; + CChan *m_pChan; + }; +}; + CZNC::CZNC() { #ifdef _MODULES m_pModules = new CGlobalModules(); @@ -929,6 +940,8 @@ bool CZNC::DoRehash(CString& sError) MCString msModules; // Modules are queued for later loading #endif + vector vUnHandledLines; + while (File.ReadLine(sLine)) { uLineNum++; @@ -1381,9 +1394,18 @@ bool CZNC::DoRehash(CString& sError) } } + CUnhandledConfigLines cTmp; + cTmp.m_sName = sName; + cTmp.m_sValue = sValue; + cTmp.m_pChan = pChan; + cTmp.m_pUser = pUser; + vUnHandledLines.push_back( cTmp ); +/* + * giving global modules a chance to work on these, if they aren't handled then a warn is print out, but not an error sError = "Unhandled line " + CString(uLineNum) + " in config: [" + sLine + "]"; CUtils::PrintError(sError); return false; +*/ } #ifdef _MODULES @@ -1456,6 +1478,17 @@ bool CZNC::DoRehash(CString& sError) else CUtils::PrintMessage("Could not unload [" + *it + "]"); } + + // last step, throw unhandled config items at global config + for( u_long a = 0; a < vUnHandledLines.size(); a++ ) + { + if( pChan == vUnHandledLines[a].m_pChan || pUser == vUnHandledLines[a].m_pUser ) + continue; // skip unclosed user or chan + if( !GetModules().OnConfigLine( vUnHandledLines[a].m_sName, vUnHandledLines[a].m_sValue, vUnHandledLines[a].m_pUser, vUnHandledLines[a].m_pChan ) ) + { + CUtils::PrintMessage( "Unhandled config line [" + vUnHandledLines[a].m_sName + "] = [" + vUnHandledLines[a].m_sValue + "]" ); + } + } #endif if (pChan) {