diff options
author | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-05 01:55:04 -0400 |
commit | 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b (patch) | |
tree | 4486f0784bdf050fd7eb225c0cb9df352ce1f45a /src/configreader.cpp | |
parent | 781defb7076ddfddf723ca08cd0a518b6657b64f (diff) |
Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in.
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r-- | src/configreader.cpp | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp deleted file mode 100644 index ca5a64a60..000000000 --- a/src/configreader.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* Configuration file handling. - * - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - */ - -/* Taken from: - * +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2011 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#include "services.h" -#include "config.h" - -ConfigReader::ConfigReader() : conf(Config), error(CONF_NO_ERROR) -{ -} - -ConfigReader::ConfigReader(const Anope::string &filename) : conf(Config), error(CONF_NO_ERROR) -{ -} - -ConfigReader::ConfigReader(ServerConfig *c) : conf(c), error(CONF_NO_ERROR) -{ -} - -ConfigReader::~ConfigReader() -{ -} - -Anope::string ConfigReader::ReadValue(const Anope::string &tag, const Anope::string &name, const Anope::string &default_value, int index, bool allow_linefeeds) -{ - /* Don't need to strlcpy() tag and name anymore, ReadConf() takes const char* */ - Anope::string result; - - if (!conf->ConfValue(conf->config_data, tag, name, default_value, index, result, allow_linefeeds)) - this->error = CONF_VALUE_NOT_FOUND; - - return result; -} - -Anope::string ConfigReader::ReadValue(const Anope::string &tag, const Anope::string &name, int index, bool allow_linefeeds) -{ - return ReadValue(tag, name, "", index, allow_linefeeds); -} - -bool ConfigReader::ReadFlag(const Anope::string &tag, const Anope::string &name, const Anope::string &default_value, int index) -{ - return conf->ConfValueBool(conf->config_data, tag, name, default_value, index); -} - -bool ConfigReader::ReadFlag(const Anope::string &tag, const Anope::string &name, int index) -{ - return ReadFlag(tag, name, "", index); -} - -int ConfigReader::ReadInteger(const Anope::string &tag, const Anope::string &name, const Anope::string &default_value, int index, bool need_positive) -{ - int result; - - if (!conf->ConfValueInteger(conf->config_data, tag, name, default_value, index, result)) - { - this->error = CONF_VALUE_NOT_FOUND; - return 0; - } - - if (need_positive && result < 0) - { - this->error = CONF_INT_NEGATIVE; - return 0; - } - - return result; -} - -int ConfigReader::ReadInteger(const Anope::string &tag, const Anope::string &name, int index, bool need_positive) -{ - return ReadInteger(tag, name, "", index, need_positive); -} - -long ConfigReader::GetError() -{ - long olderr = this->error; - this->error = 0; - return olderr; -} - -int ConfigReader::Enumerate(const Anope::string &tag) const -{ - return conf->ConfValueEnum(conf->config_data, tag); -} - -int ConfigReader::EnumerateValues(const Anope::string &tag, int index) -{ - return conf->ConfVarEnum(conf->config_data, tag, index); -} - -bool ConfigReader::Verify() -{ - return this->readerror; -} |