diff options
Diffstat (limited to 'src/config.cpp')
-rw-r--r-- | src/config.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/src/config.cpp b/src/config.cpp index f1d237a5d..d7b90a105 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -19,7 +19,7 @@ using namespace Configuration; -File ServicesConf("services.conf", false); // Services configuration file name +File ServicesConf("anope.conf", false); // Configuration file name Conf *Config = NULL; Block::Block(const Anope::string &n) : name(n), linenum(-1) @@ -33,47 +33,32 @@ const Anope::string &Block::GetName() const int Block::CountBlock(const Anope::string &bname) { - if (!this) - return 0; - return blocks.count(bname); } Block* Block::GetBlock(const Anope::string &bname, int num) { - if (!this) - return NULL; - std::pair<block_map::iterator, block_map::iterator> it = blocks.equal_range(bname); for (int i = 0; it.first != it.second; ++it.first, ++i) if (i == num) return &it.first->second; - return NULL; + return &(Config->EmptyBlock); } bool Block::Set(const Anope::string &tag, const Anope::string &value) { - if (!this) - return false; - items[tag] = value; return true; } -const Block::item_map* Block::GetItems() const +const Block::item_map& Block::GetItems() const { - if (this) - return &items; - else - return NULL; + return items; } template<> const Anope::string Block::Get(const Anope::string &tag, const Anope::string& def) const { - if (!this) - return def; - Anope::map<Anope::string>::const_iterator it = items.find(tag); if (it != items.end()) return it->second; @@ -116,7 +101,7 @@ template<typename T> static void ValidateNotZero(const Anope::string &block, con throw ConfigException("The value for <" + block + ":" + name + "> cannot be zero!"); } -Conf::Conf() : Block("") +Conf::Conf() : Block(""), EmptyBlock("") { ReadTimeout = 0; UsePrivmsg = DefPrivmsg = false; @@ -220,7 +205,7 @@ Conf::Conf() : Block("") if (password.find(' ') != Anope::string::npos || password[0] == ':') throw ConfigException("uplink:password is not valid"); - this->Uplinks.push_back(Uplink(host, port, password, ipv6)); + this->Uplinks.emplace_back(host, port, password, ipv6); } for (int i = 0; i < this->CountBlock("module"); ++i) @@ -602,7 +587,7 @@ void Conf::Post(Conf *old) Block *Conf::GetModule(Module *m) { if (!m) - return NULL; + return &(Config->EmptyBlock); return GetModule(m->name); } @@ -654,10 +639,10 @@ Block *Conf::GetCommand(CommandSource &source) return b; } - return NULL; + return &(Config->EmptyBlock); } -File::File(const Anope::string &n, bool e) : name(n), executable(e), fp(NULL) +File::File(const Anope::string &n, bool e) : name(n), executable(e) { } |