diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-21 23:45:44 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-21 23:45:44 +0000 |
commit | a30abe26fc803900eaf5dc4c08a31aa1d3c9c89f (patch) | |
tree | 7d59c15a9c23401b91e100ebb9e98df2c7179e53 /src/configreader.cpp | |
parent | ff3eef491aa9e107d09d9dd9560ef7715b37b3b3 (diff) |
Change User::oper to an OperInfo reference
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11945 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r-- | src/configreader.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
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<std::string, ConfigTag*> 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("<type:name> is missing from tag at " + tag->getTagLocation()); - opertypes[name] = tag; + + if (!ServerInstance->IsNick(name.c_str(), Limits.NickMax)) + throw CoreException("<type:name> 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("<oper:name> 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) |