diff options
| author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-25 21:58:20 -0400 |
|---|---|---|
| committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-25 21:58:20 -0400 |
| commit | ae38212c1ce829c783edf971081c90137abb49a0 (patch) | |
| tree | 5c652d9cdc38103dec6fa112d57fca882b4e3e44 /src/config.cpp | |
| parent | 15d7f0f6fe8bb903275f603f734c13f65f3aa906 (diff) | |
Epic commit to replace most of the strings in Anope with a single Anope::string class, plus some other little fixes here and there. If you follow 1.9.x development and are testing things, THIS is one of those things that NEEDS testing.
Diffstat (limited to 'src/config.cpp')
| -rw-r--r-- | src/config.cpp | 861 |
1 files changed, 403 insertions, 458 deletions
diff --git a/src/config.cpp b/src/config.cpp index 61f9d586f..c9dcf426a 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -15,29 +15,28 @@ /*************************************************************************/ -ci::string services_conf = "services.conf"; // Services configuration file name +Anope::string services_conf = "services.conf"; // Services configuration file name ServerConfig Config; -static ci::string Modules; -static ci::string EncModules; -static ci::string DBModules; -static ci::string SocketEngineModule; -static ci::string HostCoreModules; -static ci::string MemoCoreModules; -static ci::string BotCoreModules; -static ci::string OperCoreModules; -static ci::string NickCoreModules; -static ci::string ChanCoreModules; -static ci::string DefCon1; -static ci::string DefCon2; -static ci::string DefCon3; -static ci::string DefCon4; -static char *UlineServers; -static ci::string OSNotifications; -static ci::string BSDefaults; -static ci::string CSDefaults; -static char *temp_nsuserhost; -static ci::string NSDefaults; +static Anope::string Modules; +static Anope::string EncModules; +static Anope::string DBModules; +static Anope::string HostCoreModules; +static Anope::string MemoCoreModules; +static Anope::string BotCoreModules; +static Anope::string OperCoreModules; +static Anope::string NickCoreModules; +static Anope::string ChanCoreModules; +static Anope::string DefCon1; +static Anope::string DefCon2; +static Anope::string DefCon3; +static Anope::string DefCon4; +static Anope::string UlineServers; +static Anope::string OSNotifications; +static Anope::string BSDefaults; +static Anope::string CSDefaults; +static Anope::string temp_nsuserhost; +static Anope::string NSDefaults; /*************************************************************************/ @@ -51,48 +50,43 @@ void ServerConfig::ClearStack() include_stack.clear(); } -bool ServerConfig::CheckOnce(const char *tag) +bool ServerConfig::CheckOnce(const Anope::string &tag) { int count = ConfValueEnum(config_data, tag); if (count > 1) - throw ConfigException(std::string("You have more than one <") + tag + "> tag, this is not permitted."); + throw ConfigException("You have more than one <" + tag + "> tag, this is not permitted."); if (count < 1) - throw ConfigException(std::string("You have not defined a <") + tag + "> tag, this is required."); + throw ConfigException("You have not defined a <" + tag + "> tag, this is required."); return true; } -bool NoValidation(ServerConfig *, const char *, const char *, ValueItem &) +bool NoValidation(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &) { return true; } -bool DoneConfItem(ServerConfig *, const char *) +void ServerConfig::ValidateNoSpaces(const Anope::string &p, const Anope::string &tag, const Anope::string &val) { - return true; -} - -void ServerConfig::ValidateNoSpaces(const char *p, const ci::string &tag, const ci::string &val) -{ - for (const char *ptr = p; *ptr; ++ptr) + for (Anope::string::const_iterator ptr = p.begin(), end = p.end(); ptr != end; ++ptr) if (*ptr == ' ') - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> cannot contain spaces"); + throw ConfigException("The value of <" + tag + ":" + val + "> cannot contain spaces"); } /* NOTE: Before anyone asks why we're not using inet_pton for this, it is because inet_pton and friends do not return so much detail, * even in strerror(errno). They just return 'yes' or 'no' to an address without such detail as to whats WRONG with the address. * Because ircd users arent as technical as they used to be (;)) we are going to give more of a useful error message. */ -void ServerConfig::ValidateIP(const char *p, const ci::string &tag, const ci::string &val, bool wild) +void ServerConfig::ValidateIP(const Anope::string &p, const Anope::string &tag, const Anope::string &val, bool wild) { int num_dots = 0, num_seps = 0; bool not_numbers = false, not_hex = false; - if (*p) + if (!p.empty()) { - if (*p == '.') - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is not an IP address"); + if (p[0] == '.') + throw ConfigException("The value of <" + tag + ":" + val + "> is not an IP address"); - for (const char *ptr = p; *ptr; ++ptr) + for (Anope::string::const_iterator ptr = p.begin(), end = p.end(); ptr != end; ++ptr) { if (wild && (*ptr == '*' || *ptr == '?' || *ptr == '/')) continue; @@ -106,7 +100,7 @@ void ServerConfig::ValidateIP(const char *p, const ci::string &tag, const ci::st switch (*ptr) { case ' ': - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is not an IP address"); + throw ConfigException("The value of <" + tag + ":" + val + "> is not an IP address"); case '.': ++num_dots; break; @@ -115,41 +109,41 @@ void ServerConfig::ValidateIP(const char *p, const ci::string &tag, const ci::st } } if (num_dots > 3) - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is an IPv4 address with too many fields!"); + throw ConfigException("The value of <" + tag + ":" + val + "> is an IPv4 address with too many fields!"); if (num_seps > 8) - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is an IPv6 address with too many fields!"); + throw ConfigException("The value of <" + tag + ":" + val + "> is an IPv6 address with too many fields!"); if (!num_seps && num_dots < 3 && !wild) - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> looks to be a malformed IPv4 address"); + throw ConfigException("The value of <" + tag + ":" + val + "> looks to be a malformed IPv4 address"); if (!num_seps && num_dots == 3 && not_numbers) - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> contains non-numeric characters in an IPv4 address"); + throw ConfigException("The value of <" + tag + ":" + val + "> contains non-numeric characters in an IPv4 address"); if (num_seps && not_hex) - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> contains non-hexdecimal characters in an IPv6 address"); + throw ConfigException("The value of <" + tag + ":" + val + "> contains non-hexdecimal characters in an IPv6 address"); if (num_seps && num_dots != 3 && num_dots && !wild) - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is a malformed IPv6 4in6 address"); + throw ConfigException("The value of <" + tag + ":" + val + "> is a malformed IPv6 4in6 address"); } } -void ServerConfig::ValidateHostname(const char *p, const ci::string &tag, const ci::string &val) +void ServerConfig::ValidateHostname(const Anope::string &p, const Anope::string &tag, const Anope::string &val) { - if (!strcasecmp(p, "localhost")) + if (p.equals_ci("localhost")) return; int num_dots = 0, num_seps = 0; - if (*p) + if (!p.empty()) { - if (*p == '.') - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is not a valid hostname"); - for (const char *ptr = p; *ptr; ++ptr) + if (p[0] == '.') + throw ConfigException("The value of <" + tag + ":" + val + "> is not a valid hostname"); + for (unsigned i = 0, end = p.length(); i < end; ++i) { - switch (*ptr) + switch (p[i]) { case ' ': - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is not a valid hostname"); + throw ConfigException("The value of <" + tag + ":" + val + "> is not a valid hostname"); case '.': ++num_dots; break; @@ -159,72 +153,70 @@ void ServerConfig::ValidateHostname(const char *p, const ci::string &tag, const } } if (!num_dots && !num_seps) - throw ConfigException(ci::string("The value of <") + tag + ":" + val + "> is not a valid hostname"); + throw ConfigException("The value of <" + tag + ":" + val + "> is not a valid hostname"); } } -bool ValidateNotEmpty(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateNotEmpty(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { if (data.GetValue().empty()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> cannot be empty!"); + throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty!"); return true; } -bool ValidateNotZero(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateNotZero(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (!data.GetInteger()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> must be non-zero!"); + if (!data.GetInteger() && !dotime(data.GetValue())) + throw ConfigException("The value for <" + tag + ":" + value + "> must be non-zero!"); return true; } -bool ValidateEmailReg(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateEmailReg(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { if (Config.NSEmailReg) { - if (ci::string(value) == "preregexpire") + if (value.equals_ci("preregexpire")) { if (!data.GetInteger()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> must be non-zero when e-mail registration are enabled!"); + throw ConfigException("The value for <" + tag + ":" + value + "> must be non-zero when e-mail registration are enabled!"); } else { if (!data.GetBool()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> must be set to yes when e-mail registrations are enabled!"); + throw ConfigException("The value for <" + tag + ":" + value + "> must be set to yes when e-mail registrations are enabled!"); } } return true; } -bool ValidatePort(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidatePort(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { int port = data.GetInteger(); if (!port) return true; if (port < 1 || port > 65535) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> is not a value port, it must be between 1 and 65535!"); + throw ConfigException("The value for <" + tag + ":" + value + "> is not a value port, it must be between 1 and 65535!"); return true; } -bool ValidateLanguage(ServerConfig *, const char *, const char *, ValueItem &data) +bool ValidateLanguage(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data) { int language = data.GetInteger(); - char maxlang[3]; - snprintf(maxlang, 3, "%d", USED_LANGS); if (language < 1 || language > USED_LANGS) - throw ConfigException(std::string("The value for <nickserv:defaultlanguage> must be between 1 and ") + maxlang + "!"); + throw ConfigException("The value for <nickserv:defaultlanguage> must be between 1 and " + stringify(USED_LANGS) + "!"); data.Set(--language); return true; } -bool ValidateGuestPrefix(ServerConfig *conf, const char *tag, const char *value, ValueItem &data) +bool ValidateGuestPrefix(ServerConfig *conf, const Anope::string &tag, const Anope::string &value, ValueItem &data) { ValidateNotEmpty(conf, tag, value, data); - if (data.GetValue().size() > 21) + if (data.GetValue().length() > 21) throw ConfigException("The value for <nickserv:guestnickprefix> cannot exceed 21 characters in length!"); return true; } -bool ValidateBantype(ServerConfig *, const char *, const char *, ValueItem &data) +bool ValidateBantype(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data) { int bantype = data.GetInteger(); if (bantype < 0 || bantype > 3) @@ -232,53 +224,53 @@ bool ValidateBantype(ServerConfig *, const char *, const char *, ValueItem &data return true; } -bool ValidateBotServ(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateBotServ(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (Config.s_BotServ) + if (!Config.s_BotServ.empty()) { - if (ci::string(value) == "description") + if (value.equals_ci("description")) { if (data.GetValue().empty()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> cannot be empty when BotServ is enabled!"); + throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when BotServ is enabled!"); } - else if (ci::string(value) == "minusers" || ci::string(value) == "badwordsmax" || ci::string(value) == "keepdata") + else if (value.equals_ci("minusers") || value.equals_ci("badwordsmax") || value.equals_ci("keepdata")) { - if (!data.GetInteger()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> must be non-zero when BotServ is enabled!"); + if (!data.GetInteger() && !dotime(data.GetValue())) + throw ConfigException("The value for <" + tag + ":" + value + "> must be non-zero when BotServ is enabled!"); } } return true; } -bool ValidateHostServ(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateHostServ(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (Config.s_HostServ) + if (!Config.s_HostServ.empty()) { - if (ci::string(value) == "description") + if (value.equals_ci("description")) { if (data.GetValue().empty()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> cannot be empty when HostServ is enabled!"); + throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when HostServ is enabled!"); } } return true; } -bool ValidateLimitSessions(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateLimitSessions(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { if (Config.LimitSessions) { - if (ci::string(value) == "maxsessionlimit" || ci::string(value) == "exceptionexpiry") + if (value.equals_ci("maxsessionlimit") || value.equals_ci("exceptionexpiry")) { - if (!data.GetInteger()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> must be non-zero when session limiting is enabled!"); + if (!data.GetInteger() && !dotime(data.GetValue())) + throw ConfigException("The value for <" + tag + ":" + value + "> must be non-zero when session limiting is enabled!"); } } return true; } -bool ValidateDefCon(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateDefCon(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (ci::string(value) == "defaultlevel") + if (value.equals_ci("defaultlevel")) { int level = data.GetInteger(); if (!level) @@ -288,26 +280,26 @@ bool ValidateDefCon(ServerConfig *, const char *tag, const char *value, ValueIte } else if (Config.DefConLevel) { - if ((ci::string(value).substr(0, 5) == "level" && isdigit(value[5])) || ci::string(value) == "chanmodes" || ci::string(value) == "akillreason") + if ((value.substr(0, 5).equals_ci("level") && isdigit(value[5])) || value.equals_ci("chanmodes") || value.equals_ci("akillreason")) { if (data.GetValue().empty()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> cannot be empty when DefCon is enabled!"); + throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when DefCon is enabled!"); } - else if (ci::string(value) == "message" && Config.GlobalOnDefconMore) + else if (value.equals_ci("message") && Config.GlobalOnDefconMore) { if (data.GetValue().empty()) throw ConfigException("The value for <defcon:message> cannot be empty when globalondefconmore is enabled!"); } - else if (ci::string(value) == "sessionlimit" || ci::string(value) == "akillexpire") + else if (value.equals_ci("sessionlimit") || value.equals_ci("akillexpire")) { - if (!data.GetInteger()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> must be non-zero when DefCon is enabled!"); + if (!data.GetInteger() && !dotime(data.GetValue())) + throw ConfigException("The value for <" + tag + ":" + value + "> must be non-zero when DefCon is enabled!"); } } return true; } -bool ValidateNickLen(ServerConfig *, const char *, const char *, ValueItem &data) +bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data) { int nicklen = data.GetInteger(); if (!nicklen) @@ -324,20 +316,20 @@ bool ValidateNickLen(ServerConfig *, const char *, const char *, ValueItem &data return true; } -bool ValidateMail(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateMail(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { if (Config.UseMail) { - if (ci::string(value) == "sendmailpath" || ci::string(value) == "sendfrom") + if (value.equals_ci("sendmailpath") || value.equals_ci("sendfrom")) { if (data.GetValue().empty()) - throw ConfigException(std::string("The value for <") + tag + ":" + value + "> cannot be empty when e-mail is enabled!"); + throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when e-mail is enabled!"); } } return true; } -bool ValidateGlobalOnCycle(ServerConfig *, const char *tag, const char *value, ValueItem &data) +bool ValidateGlobalOnCycle(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) { if (Config.GlobalOnCycle) { @@ -350,7 +342,7 @@ bool ValidateGlobalOnCycle(ServerConfig *, const char *tag, const char *value, V return true; } -void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail) +void ServerConfig::ReportConfigError(const Anope::string &errormessage, bool bail) { Alog() << "There were errors in your configuration file: " << errormessage; if (bail) @@ -360,7 +352,7 @@ void ServerConfig::ReportConfigError(const std::string &errormessage, bool bail) } } -bool InitUplinks(ServerConfig *, const char *, bool bail) +bool InitUplinks(ServerConfig *, const Anope::string &, bool bail) { // If bail is false, we were reloading, don't clear anything if (!bail) @@ -375,13 +367,13 @@ bool InitUplinks(ServerConfig *, const char *, bool bail) return true; } -bool DoUplink(ServerConfig *conf, const char *, const char **, ValueList &values, int *, bool bail) +bool DoUplink(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool bail) { // If bail is false, we were reloading, don't even try to add another uplink if (!bail) return true; // Validation variables - const char *host = values[0].GetString(), *password = values[3].GetString(); + Anope::string host = values[0].GetValue(), password = values[3].GetValue(); int port = values[2].GetInteger(); bool ipv6 = values[1].GetBool(); ValueItem vi_host(host), vi_port(port), vi_password(password); @@ -399,7 +391,7 @@ bool DoUplink(ServerConfig *conf, const char *, const char **, ValueList &values return true; } -bool DoneUplinks(ServerConfig *, const char *, bool bail) +bool DoneUplinks(ServerConfig *, const Anope::string &, bool bail) { // If bail is false, we were reloading, ignore this check if (!bail) @@ -409,7 +401,7 @@ bool DoneUplinks(ServerConfig *, const char *, bool bail) return true; } -static bool InitOperTypes(ServerConfig *, const char *, bool) +static bool InitOperTypes(ServerConfig *, const Anope::string &, bool) { for (std::list<OperType *>::iterator it = Config.MyOperTypes.begin(), it_end = Config.MyOperTypes.end(); it != it_end; ++it) delete *it; @@ -418,12 +410,12 @@ static bool InitOperTypes(ServerConfig *, const char *, bool) return true; } -static bool DoOperType(ServerConfig *conf, const char *, const char **, ValueList &values, int *, bool) +static bool DoOperType(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool) { - const char *name = values[0].GetString(); - const char *inherits = values[1].GetString(); - const char *commands = values[2].GetString(); - const char *privs = values[3].GetString(); + Anope::string name = values[0].GetValue(); + Anope::string inherits = values[1].GetValue(); + Anope::string commands = values[2].GetValue(); + Anope::string privs = values[3].GetValue(); ValueItem vi(name); if (!ValidateNotEmpty(conf, "opertype", "name", vi)) @@ -431,7 +423,7 @@ static bool DoOperType(ServerConfig *conf, const char *, const char **, ValueLis OperType *ot = new OperType(name); - ci::string tok; + Anope::string tok; spacesepstream cmdstr(commands); while (cmdstr.GetToken(tok)) ot->AddCommand(tok); @@ -444,11 +436,11 @@ static bool DoOperType(ServerConfig *conf, const char *, const char **, ValueLis while (inheritstr.GetToken(tok)) { /* Strip leading ' ' after , */ - if (tok.size() > 1 && tok[0] == ' ') + if (tok.length() > 1 && tok[0] == ' ') tok.erase(tok.begin()); for (std::list<OperType *>::iterator it = Config.MyOperTypes.begin(), it_end = Config.MyOperTypes.end(); it != it_end; ++it) { - if ((*it)->GetName() == tok) + if ((*it)->GetName().equals_ci(tok)) { Alog() << "Inheriting commands and privs from " << (*it)->GetName() << " to " << ot->GetName(); ot->Inherits(*it); @@ -461,14 +453,14 @@ static bool DoOperType(ServerConfig *conf, const char *, const char **, ValueLis return true; } -static bool DoneOperTypes(ServerConfig *, const char *, bool) +static bool DoneOperTypes(ServerConfig *, const Anope::string &, bool) { return true; } /*************************************************************************/ -static bool InitOpers(ServerConfig *, const char *, bool) +static bool InitOpers(ServerConfig *, const Anope::string &, bool) { for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it) it->second->ot = NULL; @@ -478,10 +470,10 @@ static bool InitOpers(ServerConfig *, const char *, bool) return true; } -static bool DoOper(ServerConfig *conf, const char *, const char **, ValueList &values, int *, bool) +static bool DoOper(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool) { - const char *name = values[0].GetString(); - const char *type = values[1].GetString(); + Anope::string name = values[0].GetValue(); + Anope::string type = values[1].GetValue(); ValueItem vi(name); if (!ValidateNotEmpty(conf, "oper", "name", vi)) @@ -495,12 +487,11 @@ static bool DoOper(ServerConfig *conf, const char *, const char **, ValueList &v return true; } -static bool DoneOpers(ServerConfig *, const char *, bool) +static bool DoneOpers(ServerConfig *, const Anope::string &, bool) { - // XXX: this is duplicated in config.c - for (std::list<std::pair<ci::string, ci::string> >::iterator it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it) + for (std::list<std::pair<Anope::string, Anope::string> >::iterator it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it) { - ci::string nick = it->first, type = it->second; + Anope::string nick = it->first, type = it->second; NickAlias *na = findnick(nick); if (!na) @@ -514,7 +505,7 @@ static bool DoneOpers(ServerConfig *, const char *, bool) for (std::list<OperType *>::iterator tit = Config.MyOperTypes.begin(), tit_end = Config.MyOperTypes.end(); tit != tit_end; ++tit) { OperType *ot = *tit; - if (ot->GetName() == type) + if (ot->GetName().equals_ci(type)) { Alog() << "Tied oper " << na->nc->display << " to type " << type; na->nc->ot = ot; @@ -526,16 +517,16 @@ static bool DoneOpers(ServerConfig *, const char *, bool) /*************************************************************************/ -bool InitModules(ServerConfig *, const char *, bool) +bool InitModules(ServerConfig *, const Anope::string &, bool) { Modules.clear(); return true; } -bool DoModule(ServerConfig *conf, const char *, const char **, ValueList &values, int *, bool) +bool DoModule(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool) { // First we validate that there was a name in the module block - const char *module = values[0].GetString(); + Anope::string module = values[0].GetValue(); ValueItem vi(module); if (!ValidateNotEmpty(conf, "module", "name", vi)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); @@ -543,11 +534,11 @@ bool DoModule(ServerConfig *conf, const char *, const char **, ValueList &values if (!Modules.empty()) Modules += " "; // Add the module name to the string - Modules += values[0].GetString(); + Modules += values[0].GetValue(); return true; } -bool DoneModules(ServerConfig *, const char *, bool) +bool DoneModules(ServerConfig *, const Anope::string &, bool) { return true; } @@ -556,7 +547,7 @@ int ServerConfig::Read(bool bail) { errstr.clear(); // These tags MUST occur and must ONLY occur once in the config file - static const char *Once[] = {"serverinfo", "networkinfo", "options", "nickserv", "chanserv", "memoserv", "operserv", NULL}; + static const Anope::string Once[] = {"serverinfo", "networkinfo", "options", "nickserv", "chanserv", "memoserv", "operserv", ""}; // These tags can occur ONCE or not at all InitialConfig Values[] = { /* The following comments are from CyberBotX to w00t as examples to use: @@ -612,25 +603,25 @@ int ServerConfig::Read(bool bail) * * We may need to add some other validation functions to handle certain things, we can handle that later. * Any questions about these, w00t, feel free to ask. */ - {"serverinfo", "name", "", new ValueContainerChar(&Config.ServerName), DT_HOSTNAME | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "description", "", new ValueContainerChar(&Config.ServerDesc), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "localhost", "", new ValueContainerChar(&Config.LocalHost), DT_HOSTNAME | DT_NORELOAD, NoValidation}, - {"serverinfo", "type", "", new ValueContainerChar(&Config.IRCDModule), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "id", "", new ValueContainerChar(&Config.Numeric), DT_NOSPACES | DT_NORELOAD, NoValidation}, - {"serverinfo", "ident", "", new ValueContainerChar(&Config.ServiceUser), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "hostname", "", new ValueContainerChar(&Config.ServiceHost), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "pid", "services.pid", new ValueContainerChar(&Config.PIDFilename), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "motd", "services.motd", new ValueContainerChar(&Config.MOTDFilename), DT_CHARPTR, ValidateNotEmpty}, - {"networkinfo", "logchannel", "", new ValueContainerChar(&Config.LogChannel), DT_CHARPTR, NoValidation}, + {"serverinfo", "name", "", new ValueContainerString(&Config.ServerName), DT_HOSTNAME | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "description", "", new ValueContainerString(&Config.ServerDesc), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "localhost", "", new ValueContainerString(&Config.LocalHost), DT_HOSTNAME | DT_NORELOAD, NoValidation}, + {"serverinfo", "type", "", new ValueContainerString(&Config.IRCDModule), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "id", "", new ValueContainerString(&Config.Numeric), DT_NOSPACES | DT_NORELOAD, NoValidation}, + {"serverinfo", "ident", "", new ValueContainerString(&Config.ServiceUser), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "hostname", "", new ValueContainerString(&Config.ServiceHost), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "pid", "services.pid", new ValueContainerString(&Config.PIDFilename), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "motd", "services.motd", new ValueContainerString(&Config.MOTDFilename), DT_STRING, ValidateNotEmpty}, + {"networkinfo", "logchannel", "", new ValueContainerString(&Config.LogChannel), DT_STRING, NoValidation}, {"networkinfo", "logbot", "no", new ValueContainerBool(&Config.LogBot), DT_BOOLEAN, NoValidation}, - {"networkinfo", "networkname", "", new ValueContainerChar(&Config.NetworkName), DT_CHARPTR, ValidateNotEmpty}, + {"networkinfo", "networkname", "", new ValueContainerString(&Config.NetworkName), DT_STRING, ValidateNotEmpty}, {"networkinfo", "nicklen", "0", new ValueContainerUInt(&Config.NickLen), DT_UINTEGER | DT_NORELOAD, ValidateNickLen}, {"networkinfo", "userlen", "10", new ValueContainerUInt(&Config.UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"networkinfo", "hostlen", "64", new ValueContainerUInt(&Config.HostLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, - {"options", "encryption", "", new ValueContainerCIString(&EncModules), DT_CISTRING | DT_NORELOAD, ValidateNotEmpty}, + {"options", "encryption", "", new ValueContainerString(&EncModules), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"options", "passlen", "32", new ValueContainerUInt(&Config.PassLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, - {"options", "database", "", new ValueContainerCIString(&DBModules), DT_CISTRING | DT_NORELOAD, ValidateNotEmpty}, - {"options", "socketengine", "", new ValueContainerCIString(&Config.SocketEngine), DT_CISTRING | DT_NORELOAD, ValidateNotEmpty}, + {"options", "database", "", new ValueContainerString(&DBModules), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"options", "socketengine", "", new ValueContainerString(&Config.SocketEngine), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"options", "userkey1", "0", new ValueContainerLUInt(&Config.UserKey1), DT_LUINTEGER, NoValidation}, {"options", "userkey2", "0", new ValueContainerLUInt(&Config.UserKey2), DT_LUINTEGER, NoValidation}, {"options", "userkey3", "0", new ValueContainerLUInt(&Config.UserKey3), DT_LUINTEGER, NoValidation}, @@ -652,25 +643,25 @@ int ServerConfig::Read(bool bail) {"options", "logusers", "no", new ValueContainerBool(&Config.LogUsers), DT_BOOLEAN, NoValidation}, {"options", "hidestatso", "no", new ValueContainerBool(&Config.HideStatsO), DT_BOOLEAN, NoValidation}, {"options", "globaloncycle", "no", new ValueContainerBool(&Config.GlobalOnCycle), DT_BOOLEAN, NoValidation}, - {"options", "globaloncycledown", "", new ValueContainerChar(&Config.GlobalOnCycleMessage), DT_CHARPTR, ValidateGlobalOnCycle}, - {"options", "globaloncycleup", "", new ValueContainerChar(&Config.GlobalOnCycleUP), DT_CHARPTR, ValidateGlobalOnCycle}, + {"options", "globaloncycledown", "", new ValueContainerString(&Config.GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle}, + {"options", "globaloncycleup", "", new ValueContainerString(&Config.GlobalOnCycleUP), DT_STRING, ValidateGlobalOnCycle}, {"options", "anonymousglobal", "no", new ValueContainerBool(&Config.AnonymousGlobal), DT_BOOLEAN, NoValidation}, {"options", "nickregdelay", "0", new ValueContainerUInt(&Config.NickRegDelay), DT_UINTEGER, NoValidation}, {"options", "restrictopernicks", "no", new ValueContainerBool(&Config.RestrictOperNicks), DT_BOOLEAN, NoValidation}, {"options", "newscount", "3", new ValueContainerUInt(&Config.NewsCount), DT_UINTEGER, NoValidation}, - {"options", "ulineservers", "", new ValueContainerChar(&UlineServers), DT_CHARPTR, NoValidation}, + {"options", "ulineservers", "", new ValueContainerString(&UlineServers), DT_STRING, NoValidation}, {"options", "enablelogchannel", "no", new ValueContainerBool(&LogChan), DT_BOOLEAN, NoValidation}, - {"options", "mlock", "+nrt", new ValueContainerCIString(&Config.MLock), DT_CISTRING, NoValidation}, - {"options", "botmodes", "", new ValueContainerCIString(&Config.BotModes), DT_CISTRING, NoValidation}, + {"options", "mlock", "+nrt", new ValueContainerString(&Config.MLock), DT_STRING, NoValidation}, + {"options", "botmodes", "", new ValueContainerString(&Config.BotModes), DT_STRING, NoValidation}, {"options", "maxretries", "10", new ValueContainerUInt(&Config.MaxRetries), DT_UINTEGER, NoValidation}, {"options", "retrywait", "60", new ValueContainerInt(&Config.RetryWait), DT_INTEGER, ValidateNotZero}, {"options", "hideprivilegedcommands", "no", new ValueContainerBool(&Config.HidePrivilegedCommands), DT_BOOLEAN, ValidateEmailReg}, - {"nickserv", "nick", "NickServ", new ValueContainerChar(&Config.s_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"nickserv", "description", "Nickname Registration Service", new ValueContainerChar(&Config.desc_NickServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, + {"nickserv", "nick", "NickServ", new ValueContainerString(&Config.s_NickServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"nickserv", "description", "Nickname Registration Service", new ValueContainerString(&Config.desc_NickServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"nickserv", "emailregistration", "no", new ValueContainerBool(&Config.NSEmailReg), DT_BOOLEAN, NoValidation}, - {"nickserv", "modules", "", new ValueContainerCIString(&NickCoreModules), DT_CISTRING, NoValidation}, + {"nickserv", "modules", "", new ValueContainerString(&NickCoreModules), DT_STRING, NoValidation}, {"nickserv", "forceemail", "no", new ValueContainerBool(&Config.NSForceEmail), DT_BOOLEAN, ValidateEmailReg}, - {"nickserv", "defaults", "secure memosignon memoreceive", new ValueContainerCIString(&NSDefaults), DT_CISTRING, NoValidation}, + {"nickserv", "defaults", "secure memosignon memoreceive", new ValueContainerString(&NSDefaults), DT_STRING, NoValidation}, {"nickserv", "defaultlanguage", "0", new ValueContainerUInt(&Config.NSDefLanguage), DT_UINTEGER, ValidateLanguage}, {"nickserv", "regdelay", "0", new ValueContainerTime(&Config.NSRegDelay), DT_TIME, NoValidation}, {"nickserv", "resenddelay", "0", new ValueContainerTime(&Config.NSResendDelay), DT_TIME, NoValidation}, @@ -678,63 +669,63 @@ int ServerConfig::Read(bool bail) {"nickserv", "preregexpire", "0", new ValueContainerTime(&Config.NSRExpire), DT_TIME, ValidateEmailReg}, {"nickserv", "maxaliases", "0", new ValueContainerInt(&Config.NSMaxAliases), DT_INTEGER, NoValidation}, {"nickserv", "accessmax", "0", new ValueContainerUInt(&Config.NSAccessMax), DT_UINTEGER, ValidateNotZero}, - {"nickserv", "enforceruser", "", new ValueContainerChar(&temp_nsuserhost), DT_CHARPTR, ValidateNotEmpty}, + {"nickserv", "enforceruser", "", new ValueContainerString(&temp_nsuserhost), DT_STRING, ValidateNotEmpty}, {"nickserv", "releasetimeout", "0", new ValueContainerTime(&Config.NSReleaseTimeout), DT_TIME, ValidateNotZero}, {"nickserv", "allowkillimmed", "no", new ValueContainerBool(&Config.NSAllowKillImmed), DT_BOOLEAN | DT_NORELOAD, NoValidation}, {"nickserv", "nogroupchange", "no", new ValueContainerBool(&Config.NSNoGroupChange), DT_BOOLEAN, NoValidation}, {"nickserv", "listopersonly", "no", new ValueContainerBool(&Config.NSListOpersOnly), DT_BOOLEAN, NoValidation}, {"nickserv", "listmax", "0", new ValueContainerUInt(&Config.NSListMax), DT_UINTEGER, ValidateNotZero}, - {"nickserv", "guestnickprefix", "", new ValueContainerChar(&Config.NSGuestNickPrefix), DT_CHARPTR, ValidateGuestPrefix}, + {"nickserv", "guestnickprefix", "", new ValueContainerString(&Config.NSGuestNickPrefix), DT_STRING, ValidateGuestPrefix}, {"nickserv", "secureadmins", "no", new ValueContainerBool(&Config.NSSecureAdmins), DT_BOOLEAN, NoValidation}, {"nickserv", "strictprivileges", "no", new ValueContainerBool(&Config.NSStrictPrivileges), DT_BOOLEAN, NoValidation}, {"nickserv", "modeonid", "no", new ValueContainerBool(&Config.NSModeOnID), DT_BOOLEAN, NoValidation}, {"nickserv", "addaccessonreg", "no", new ValueContainerBool(&Config.NSAddAccessOnReg), DT_BOOLEAN, NoValidation}, {"mail", "usemail", "no", new ValueContainerBool(&Config.UseMail), DT_BOOLEAN, ValidateEmailReg}, - {"mail", "sendmailpath", "", new ValueContainerChar(&Config.SendMailPath), DT_CHARPTR, ValidateMail}, - {"mail", "sendfrom", "", new ValueContainerChar(&Config.SendFrom), DT_CHARPTR, ValidateMail}, + {"mail", "sendmailpath", "", new ValueContainerString(&Config.SendMailPath), DT_STRING, ValidateMail}, + {"mail", "sendfrom", "", new ValueContainerString(&Config.SendFrom), DT_STRING, ValidateMail}, {"mail", "restrict", "no", new ValueContainerBool(&Config.RestrictMail), DT_BOOLEAN, NoValidation}, {"mail", "delay", "0", new ValueContainerTime(&Config.MailDelay), DT_TIME, NoValidation}, {"mail", "dontquoteaddresses", "no", new ValueContainerBool(&Config.DontQuoteAddresses), DT_BOOLEAN, NoValidation}, - {"chanserv", "nick", "ChanServ", new ValueContainerChar(&Config.s_ChanServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"chanserv", "description", "Channel Registration Service", new ValueContainerChar(&Config.desc_ChanServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"chanserv", "modules", "", new ValueContainerCIString(&ChanCoreModules), DT_CISTRING, NoValidation}, - {"chanserv", "defaults", "keeptopic secure securefounder signkick", new ValueContainerCIString(&CSDefaults), DT_CISTRING, NoValidation}, + {"chanserv", "nick", "ChanServ", new ValueContainerString(&Config.s_ChanServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"chanserv", "description", "Channel Registration Service", new ValueContainerString(&Config.desc_ChanServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"chanserv", "modules", "", new ValueContainerString(&ChanCoreModules), DT_STRING, NoValidation}, + {"chanserv", "defaults", "keeptopic secure securefounder signkick", new ValueContainerString(&CSDefaults), DT_STRING, NoValidation}, {"chanserv", "maxregistered", "0", new ValueContainerUInt(&Config.CSMaxReg), DT_UINTEGER, NoValidation}, {"chanserv", "expire", "14d", new ValueContainerTime(&Config.CSExpire), DT_TIME, NoValidation}, {"chanserv", "defbantype", "2", new ValueContainerInt(&Config.CSDefBantype), DT_INTEGER, ValidateBantype}, {"chanserv", "accessmax", "0", new ValueContainerUInt(&Config.CSAccessMax), DT_UINTEGER, ValidateNotZero}, {"chanserv", "autokickmax", "0", new ValueContainerUInt(&Config.CSAutokickMax), DT_UINTEGER, ValidateNotZero}, - {"chanserv", "autokickreason", "User has been banned from the channel", new ValueContainerChar(&Config.CSAutokickReason), DT_CHARPTR, ValidateNotEmpty}, + {"chanserv", "autokickreason", "User has been banned from the channel", new ValueContainerString(&Config.CSAutokickReason), DT_STRING, ValidateNotEmpty}, {"chanserv", "inhabit", "0", new ValueContainerTime(&Config.CSInhabit), DT_TIME, ValidateNotZero}, {"chanserv", "listopersonly", "no", new ValueContainerBool(&Config.CSListOpersOnly), DT_BOOLEAN, NoValidation}, {"chanserv", "listmax", "0", new ValueContainerUInt(&Config.CSListMax), DT_UINTEGER, ValidateNotZero}, {"chanserv", "opersonly", "no", new ValueContainerBool(&Config.CSOpersOnly), DT_BOOLEAN, NoValidation}, - {"memoserv", "nick", "MemoServ", new ValueContainerChar(&Config.s_MemoServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"memoserv", "description", "Memo Service", new ValueContainerChar(&Config.desc_MemoServ), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, - {"memoserv", "modules", "", new ValueContainerCIString(&MemoCoreModules), DT_CISTRING, NoValidation}, + {"memoserv", "nick", "MemoServ", new ValueContainerString(&Config.s_MemoServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"memoserv", "description", "Memo Service", new ValueContainerString(&Config.desc_MemoServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"memoserv", "modules", "", new ValueContainerString(&MemoCoreModules), DT_STRING, NoValidation}, {"memoserv", "maxmemos", "0", new ValueContainerUInt(&Config.MSMaxMemos), DT_UINTEGER, NoValidation}, {"memoserv", "senddelay", "0", new ValueContainerTime(&Config.MSSendDelay), DT_TIME, NoValidation}, {"memoserv", "notifyall", "no", new ValueContainerBool(&Config.MSNotifyAll), DT_BOOLEAN, NoValidation}, {"memoserv", "memoreceipt", "0", new ValueContainerUInt(&Config.MSMemoReceipt), DT_UINTEGER, NoValidation}, - {"botserv", "nick", "", new ValueContainerChar(&Config.s_BotServ), DT_CHARPTR | DT_NORELOAD, NoValidation}, - {"botserv", "description", "Bot Service", new ValueContainerChar(&Config.desc_BotServ), DT_CHARPTR | DT_NORELOAD, ValidateBotServ}, - {"botserv", "modules", "", new ValueContainerCIString(&BotCoreModules), DT_CISTRING, NoValidation}, - {"botserv", "defaults", "", new ValueContainerCIString(&BSDefaults), DT_CISTRING, NoValidati |
