1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 22:26:39 +02:00

Rewrote the config reader to better handle invalid configs.

This prevents Anope from exploding when /os reload has errors.
This commit is contained in:
Adam
2010-08-17 19:27:37 -04:00
parent 2575008baa
commit e65d8b2f3d
195 changed files with 3133 additions and 3249 deletions
+13 -13
View File
@@ -37,14 +37,14 @@ class CommandHSList : public Command
size_t tmp = key.find('-');
if (tmp == Anope::string::npos || tmp == key.length() || tmp == 1)
{
notice_lang(Config.s_HostServ, u, LIST_INCORRECT_RANGE);
notice_lang(Config->s_HostServ, u, LIST_INCORRECT_RANGE);
return MOD_CONT;
}
for (unsigned i = 1, end = key.length(); i < end; ++i)
{
if (!isdigit(key[i]) && i != tmp)
{
notice_lang(Config.s_HostServ, u, LIST_INCORRECT_RANGE);
notice_lang(Config->s_HostServ, u, LIST_INCORRECT_RANGE);
return MOD_CONT;
}
from = convertTo<int>(key.substr(1, tmp - 1));
@@ -61,16 +61,16 @@ class CommandHSList : public Command
if (!key.empty() && key[0] != '#')
{
if ((Anope::Match(na->nick, key) || Anope::Match(na->hostinfo.GetHost(), key)) && display_counter < Config.NSListMax)
if ((Anope::Match(na->nick, key) || Anope::Match(na->hostinfo.GetHost(), key)) && display_counter < Config->NSListMax)
{
++display_counter;
time_t time = na->hostinfo.GetTime();
tm = localtime(&time);
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
if (!na->hostinfo.GetIdent().empty())
notice_lang(Config.s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
notice_lang(Config->s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
else
notice_lang(Config.s_HostServ, u, HOST_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
notice_lang(Config->s_HostServ, u, HOST_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
}
}
else
@@ -79,41 +79,41 @@ class CommandHSList : public Command
* List the host if its in the display range, and not more
* than NSListMax records have been displayed...
**/
if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config.NSListMax)
if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config->NSListMax)
{
++display_counter;
time_t time = na->hostinfo.GetTime();
tm = localtime(&time);
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
if (!na->hostinfo.GetIdent().empty())
notice_lang(Config.s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
notice_lang(Config->s_HostServ, u, HOST_IDENT_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
else
notice_lang(Config.s_HostServ, u, HOST_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
notice_lang(Config->s_HostServ, u, HOST_ENTRY, counter, na->nick.c_str(), na->hostinfo.GetHost().c_str(), na->hostinfo.GetCreator().c_str(), buf);
}
}
++counter;
}
if (!key.empty())
notice_lang(Config.s_HostServ, u, HOST_LIST_KEY_FOOTER, key.c_str(), display_counter);
notice_lang(Config->s_HostServ, u, HOST_LIST_KEY_FOOTER, key.c_str(), display_counter);
else
{
if (from)
notice_lang(Config.s_HostServ, u, HOST_LIST_RANGE_FOOTER, from, to);
notice_lang(Config->s_HostServ, u, HOST_LIST_RANGE_FOOTER, from, to);
else
notice_lang(Config.s_HostServ, u, HOST_LIST_FOOTER, display_counter);
notice_lang(Config->s_HostServ, u, HOST_LIST_FOOTER, display_counter);
}
return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &subcommand)
{
notice_help(Config.s_HostServ, u, HOST_HELP_LIST);
notice_help(Config->s_HostServ, u, HOST_HELP_LIST);
return true;
}
void OnServHelp(User *u)
{
notice_lang(Config.s_HostServ, u, HOST_HELP_CMD_LIST);
notice_lang(Config->s_HostServ, u, HOST_HELP_CMD_LIST);
}
};