diff options
author | Adam <Adam@anope.org> | 2010-08-17 19:27:37 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-08-17 19:27:37 -0400 |
commit | e65d8b2f3dfdb40858259b3bb48ef6998c31e62f (patch) | |
tree | fd845bdef5664d025ab19c262ae2c5e9d23d7bb2 /modules/core/ms_info.cpp | |
parent | 2575008baa5c9d0ca789680da1a3b81dc74786f7 (diff) |
Rewrote the config reader to better handle invalid configs.
This prevents Anope from exploding when /os reload has errors.
Diffstat (limited to 'modules/core/ms_info.cpp')
-rw-r--r-- | modules/core/ms_info.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/modules/core/ms_info.cpp b/modules/core/ms_info.cpp index 89b816a60..2dfb6398d 100644 --- a/modules/core/ms_info.cpp +++ b/modules/core/ms_info.cpp @@ -33,12 +33,12 @@ class CommandMSInfo : public Command na = findnick(name); if (!na) { - notice_lang(Config.s_MemoServ, u, NICK_X_NOT_REGISTERED, name.c_str()); + notice_lang(Config->s_MemoServ, u, NICK_X_NOT_REGISTERED, name.c_str()); return MOD_CONT; } else if (na->HasFlag(NS_FORBIDDEN)) { - notice_lang(Config.s_MemoServ, u, NICK_X_FORBIDDEN, name.c_str()); + notice_lang(Config->s_MemoServ, u, NICK_X_FORBIDDEN, name.c_str()); return MOD_CONT; } mi = &na->nc->memos; @@ -48,12 +48,12 @@ class CommandMSInfo : public Command { if (!(ci = cs_findchan(name))) { - notice_lang(Config.s_MemoServ, u, CHAN_X_NOT_REGISTERED, name.c_str()); + notice_lang(Config->s_MemoServ, u, CHAN_X_NOT_REGISTERED, name.c_str()); return MOD_CONT; } else if (!check_access(u, ci, CA_MEMO)) { - notice_lang(Config.s_MemoServ, u, ACCESS_DENIED); + notice_lang(Config->s_MemoServ, u, ACCESS_DENIED); return MOD_CONT; } mi = &ci->memos; @@ -61,7 +61,7 @@ class CommandMSInfo : public Command } else if (!name.empty()) /* It's not a chan and we aren't services admin */ { - notice_lang(Config.s_MemoServ, u, ACCESS_DENIED); + notice_lang(Config->s_MemoServ, u, ACCESS_DENIED); return MOD_CONT; } else @@ -73,13 +73,13 @@ class CommandMSInfo : public Command if (!name.empty() && (ci || na->nc != u->Account())) { if (mi->memos.empty()) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name.c_str()); else if (mi->memos.size() == 1) { if (mi->memos[0]->HasFlag(MF_UNREAD)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name.c_str()); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_MEMO, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_MEMO, name.c_str()); } else { @@ -88,55 +88,55 @@ class CommandMSInfo : public Command if (mi->memos[i]->HasFlag(MF_UNREAD)) ++count; if (count == mi->memos.size()) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_MEMOS_ALL_UNREAD, name.c_str(), count); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_MEMOS_ALL_UNREAD, name.c_str(), count); else if (!count) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_MEMOS, name.c_str(), mi->memos.size()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_MEMOS, name.c_str(), mi->memos.size()); else if (count == 1) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_MEMOS_ONE_UNREAD, name.c_str(), mi->memos.size()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_MEMOS_ONE_UNREAD, name.c_str(), mi->memos.size()); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD, name.c_str(), mi->memos.size(), count); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD, name.c_str(), mi->memos.size(), count); } if (!mi->memomax) { if (hardmax) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name.c_str(), mi->memomax); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name.c_str(), mi->memomax); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_LIMIT, name.c_str(), mi->memomax); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_LIMIT, name.c_str(), mi->memomax); } else if (mi->memomax > 0) { if (hardmax) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name.c_str(), mi->memomax); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name.c_str(), mi->memomax); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_LIMIT, name.c_str(), mi->memomax); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_LIMIT, name.c_str(), mi->memomax); } else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_NO_LIMIT, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_NO_LIMIT, name.c_str()); /* I ripped this code out of ircservices 4.4.5, since I didn't want to rewrite the whole thing (it pisses me off). */ if (na) { if (na->nc->HasFlag(NI_MEMO_RECEIVE) && na->nc->HasFlag(NI_MEMO_SIGNON)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name.c_str()); else if (na->nc->HasFlag(NI_MEMO_RECEIVE)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE, name.c_str()); else if (na->nc->HasFlag(NI_MEMO_SIGNON)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON, name.c_str()); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name.c_str()); } } else /* !name || (!ci || na->nc == u->Account()) */ { if (mi->memos.empty()) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_NO_MEMOS); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_NO_MEMOS); else if (mi->memos.size() == 1) { if (mi->memos[0]->HasFlag(MF_UNREAD)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_MEMO_UNREAD); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_MEMO_UNREAD); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_MEMO); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_MEMO); } else { @@ -145,41 +145,41 @@ class CommandMSInfo : public Command if (mi->memos[i]->HasFlag(MF_UNREAD)) ++count; if (count == mi->memos.size()) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_MEMOS_ALL_UNREAD, count); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_MEMOS_ALL_UNREAD, count); else if (!count) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_MEMOS, mi->memos.size()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_MEMOS, mi->memos.size()); else if (count == 1) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_MEMOS_ONE_UNREAD, mi->memos.size()); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_MEMOS_ONE_UNREAD, mi->memos.size()); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_MEMOS_SOME_UNREAD, mi->memos.size(), count); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_MEMOS_SOME_UNREAD, mi->memos.size(), count); } if (!mi->memomax) { if (!u->Account()->IsServicesOper() && hardmax) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_HARD_LIMIT_ZERO); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_HARD_LIMIT_ZERO); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_LIMIT_ZERO); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_LIMIT_ZERO); } else if (mi->memomax > 0) { if (!u->Account()->IsServicesOper() && hardmax) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_HARD_LIMIT, mi->memomax); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_HARD_LIMIT, mi->memomax); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_LIMIT, mi->memomax); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_LIMIT, mi->memomax); } else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_NO_LIMIT); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_NO_LIMIT); /* Ripped too. But differently because of a seg fault (loughs) */ if (u->Account()->HasFlag(NI_MEMO_RECEIVE) && u->Account()->HasFlag(NI_MEMO_SIGNON)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_NOTIFY_ON); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_NOTIFY_ON); else if (u->Account()->HasFlag(NI_MEMO_RECEIVE)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE); else if (u->Account()->HasFlag(NI_MEMO_SIGNON)) - notice_lang(Config.s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON); else - notice_lang(Config.s_MemoServ, u, MEMO_INFO_NOTIFY_OFF); + notice_lang(Config->s_MemoServ, u, MEMO_INFO_NOTIFY_OFF); } return MOD_CONT; } @@ -187,16 +187,16 @@ class CommandMSInfo : public Command bool OnHelp(User *u, const Anope::string &subcommand) { if (u->Account() && u->Account()->IsServicesOper()) - notice_help(Config.s_MemoServ, u, MEMO_SERVADMIN_HELP_INFO); + notice_help(Config->s_MemoServ, u, MEMO_SERVADMIN_HELP_INFO); else - notice_help(Config.s_MemoServ, u, MEMO_HELP_INFO); + notice_help(Config->s_MemoServ, u, MEMO_HELP_INFO); return true; } void OnServHelp(User *u) { - notice_lang(Config.s_MemoServ, u, MEMO_HELP_CMD_INFO); + notice_lang(Config->s_MemoServ, u, MEMO_HELP_CMD_INFO); } }; |