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
This commit is contained in:
imaginos
2008-03-17 04:21:53 +00:00
parent 835e78fdec
commit df1c36ca08
+33
View File
@@ -13,6 +13,17 @@
#include "User.h"
#include <pwd.h>
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<CUnhandledConfigLines> 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) {