From a30abe26fc803900eaf5dc4c08a31aa1d3c9c89f Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 21 Oct 2009 23:45:44 +0000 Subject: Change User::oper to an OperInfo reference git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11945 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/configreader.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'src/configreader.cpp') diff --git a/src/configreader.cpp b/src/configreader.cpp index 6932e960e..5d47e1931 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -589,8 +589,10 @@ static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::str } } +typedef std::map LocalIndex; void ServerConfig::CrossCheckOperClassType() { + LocalIndex operclass; for (int i = 0;; ++i) { ConfigTag* tag = ConfValue("class", i); @@ -610,16 +612,49 @@ void ServerConfig::CrossCheckOperClassType() std::string name = tag->getString("name"); if (name.empty()) throw CoreException(" is missing from tag at " + tag->getTagLocation()); - opertypes[name] = tag; + + if (!ServerInstance->IsNick(name.c_str(), Limits.NickMax)) + throw CoreException(" is invalid (value '" + name + "')"); + + OperInfo* ifo = new OperInfo; + oper_blocks[" " + name] = ifo; + ifo->type_block = tag; std::string classname; irc::spacesepstream str(tag->getString("classes")); while (str.GetToken(classname)) { - if (operclass.find(classname) == operclass.end()) + LocalIndex::iterator cls = operclass.find(classname); + if (cls == operclass.end()) throw CoreException("Oper type " + name + " has missing class " + classname); + ifo->class_blocks.push_back(cls->second); } } + + for (int i = 0;; ++i) + { + ConfigTag* tag = ConfValue("oper", i); + if (!tag) + break; + + std::string name = tag->getString("name"); + if (name.empty()) + throw CoreException(" missing from tag at " + tag->getTagLocation()); + + std::string type = tag->getString("type"); + OperIndex::iterator tblk = oper_blocks.find(" " + type); + if (tblk == oper_blocks.end()) + throw CoreException("Oper block " + name + " has missing type " + type); + if (oper_blocks.find(name) != oper_blocks.end()) + throw CoreException("Duplicate oper block with name " + name); + + OperInfo* ifo = new OperInfo; + ifo->name = type; + ifo->oper_block = tag; + ifo->type_block = tblk->second->type_block; + ifo->class_blocks.assign(tblk->second->class_blocks.begin(), tblk->second->class_blocks.end()); + oper_blocks[name] = ifo; + } } void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) @@ -1255,6 +1290,16 @@ std::string ConfigTag::getTagLocation() return src_name + ":" + ConvToStr(src_line); } +std::string OperInfo::getConfig(const std::string& key) +{ + std::string rv; + if (type_block) + type_block->readString(key, rv); + if (oper_block) + oper_block->readString(key, rv); + return rv; +} + /** Read the contents of a file located by `fname' into a file_cache pointed at by `F'. */ bool ServerConfig::ReadFile(file_cache &F, const std::string& fname) -- cgit v1.2.3