Overhaul the config parsing

This moves stuff to a two-step model. First, the new class CConfig reads the
config file, parses it and creates a in-memory model of stuff. Only then do we
actually go forward and apply the stuff.

The upside of this is that some config errors are caught before we change
anything on the running upside.

Let's see how much stuff this broke...

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter committed 2011-04-01 21:43:05 +02:00
1 parent ee9686e422
commit 70c7745899
13 files changed
+1037 -613

No files matched your search

+19 -1
View File
@@ -10,8 +10,9 @@
#include "IRCSock.h"
#include "User.h"
#include "znc.h"
#include "Config.h"
CChan::CChan(const CString& sName, CUser* pUser, bool bInConfig) {
CChan::CChan(const CString& sName, CUser* pUser, bool bInConfig, CConfig *pConfig) {
m_sName = sName.Token(0);
m_sKey = sName.Token(1);
m_pUser = pUser;
@@ -27,6 +28,23 @@ CChan::CChan(const CString& sName, CUser* pUser, bool bInConfig) {
m_bKeepBuffer = m_pUser->KeepBuffer();
m_bDisabled = false;
Reset();
if (pConfig) {
CString sValue;
if (pConfig->FindStringEntry("buffer", sValue))
SetBufferCount(sValue.ToUInt(), true);
if (pConfig->FindStringEntry("keepbuffer", sValue))
SetKeepBuffer(sValue.ToBool());
if (pConfig->FindStringEntry("detached", sValue))
SetDetached(sValue.ToBool());
if (pConfig->FindStringEntry("autocycle", sValue))
if (sValue.Equals("true"))
CUtils::PrintError("WARNING: AutoCycle has been removed, instead try -> LoadModule = autocycle " + sName);
if (pConfig->FindStringEntry("key", sValue))
SetKey(sValue);
if (pConfig->FindStringEntry("modes", sValue))
SetDefaultModes(sValue);
}
}
CChan::~CChan() {