diff options
| author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-16 06:57:14 +0000 |
|---|---|---|
| committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-01-16 06:57:14 +0000 |
| commit | ff13d00eb50a228e05c4c37b0757082ca8bc9e4a (patch) | |
| tree | 9e3c000e91963de7c696bb3733fbb33a994a445b /src/core | |
| parent | aaf1cefd1c34e08d68725d459cab02128daf72e6 (diff) | |
Removed c_userlist and u_chanlist, replaced with std::list
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2764 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/bs_act.c | 2 | ||||
| -rw-r--r-- | src/core/bs_say.c | 2 | ||||
| -rw-r--r-- | src/core/cs_akick.c | 12 | ||||
| -rw-r--r-- | src/core/cs_clear.c | 121 | ||||
| -rw-r--r-- | src/core/cs_forbid.c | 10 | ||||
| -rw-r--r-- | src/core/cs_set.c | 4 | ||||
| -rw-r--r-- | src/core/cs_suspend.c | 10 | ||||
| -rw-r--r-- | src/core/os_chankill.c | 13 | ||||
| -rw-r--r-- | src/core/os_chanlist.c | 12 | ||||
| -rw-r--r-- | src/core/os_clearmodes.c | 46 | ||||
| -rw-r--r-- | src/core/os_userlist.c | 11 |
11 files changed, 129 insertions, 114 deletions
diff --git a/src/core/bs_act.c b/src/core/bs_act.c index 8c54f9479..7849f322b 100644 --- a/src/core/bs_act.c +++ b/src/core/bs_act.c @@ -39,7 +39,7 @@ class CommandBSAct : public Command return MOD_CONT; } - if (!ci->c || ci->c->usercount < Config.BSMinUsers) + if (!ci->c || ci->c->users.size() < Config.BSMinUsers) { notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str()); return MOD_CONT; diff --git a/src/core/bs_say.c b/src/core/bs_say.c index 6aa2bb552..65fd93922 100644 --- a/src/core/bs_say.c +++ b/src/core/bs_say.c @@ -43,7 +43,7 @@ class CommandBSSay : public Command return MOD_CONT; } - if (!ci->c || ci->c->usercount < Config.BSMinUsers) + if (!ci->c || ci->c->users.size() < Config.BSMinUsers) { notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str()); return MOD_CONT; diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index 983dba89f..2a45cd83c 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -480,7 +480,6 @@ class CommandCSAKick : public Command void DoEnforce(User *u, ChannelInfo *ci, const std::vector<ci::string> ¶ms) { Channel *c = ci->c; - c_userlist *cu, *unext; int count = 0; if (!c) @@ -489,17 +488,14 @@ class CommandCSAKick : public Command return; } - cu = c->users; - - while (cu) + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { - unext = cu->next; - if (ci->CheckKick(cu->user)) + UserContainer *uc = *it++; + + if (ci->CheckKick(uc->user)) { - c->Kick(NULL, cu->user, "%s", Config.CSAutokickReason); count++; } - cu = unext; } notice_lang(Config.s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, ci->name.c_str(), count); diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c index 0cbb192e3..5f95e0cdc 100644 --- a/src/core/cs_clear.c +++ b/src/core/cs_clear.c @@ -38,127 +38,144 @@ class CommandCSClear : public Command if (c) ci = c->ci; - if (!c) { + if (!c) notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!u || !check_access(u, ci, CA_CLEAR)) { + else if (!u || !check_access(u, ci, CA_CLEAR)) notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); - } else if (what == "bans") { + else if (what == "bans") + { c->ClearBans(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_BANS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what == "excepts") { + } + else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what == "excepts") + { c->ClearExcepts(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") { + } + else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what == "invites") + { c->ClearInvites(); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_INVITES, chan); - } else if (what == "modes") { + } + else if (what == "modes") + { c->ClearModes(); check_modes(c); notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_MODES, chan); - } else if (what == "ops") { - const char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */ + } + else if (what == "ops") + { int isop, isadmin, isown; - struct c_userlist *cu, *bnext; - if (ircd->svsmode_ucmode) { - av[0] = chan; + if (ircd->svsmode_ucmode) + { ircdproto->SendSVSModeChan(c, "-o", NULL); - if (owner) { + if (owner) + { modebuf = '-'; modebuf += owner->ModeChar; ircdproto->SendSVSModeChan(c, modebuf.c_str(), NULL); } - if (admin) { + if (admin) + { modebuf = '-'; modebuf += admin->ModeChar; ircdproto->SendSVSModeChan(c, modebuf.c_str(), NULL); } - for (cu = c->users; cu; cu = bnext) + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; - isop = chan_has_user_status(c, cu->user, CUS_OP); - isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); - isown = chan_has_user_status(c, cu->user, CUS_OWNER); + UserContainer *uc = *it; + + isop = chan_has_user_status(c, uc->user, CUS_OP); + isadmin = chan_has_user_status(c, uc->user, CUS_PROTECT); + isown = chan_has_user_status(c, uc->user, CUS_OWNER); if (!isop && !isadmin && !isown) continue; if (isown) - c->RemoveMode(NULL, CMODE_OWNER, cu->user->nick); + c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); if (admin) - c->RemoveMode(NULL, CMODE_PROTECT, cu->user->nick); + c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); if (isop) - c->RemoveMode(NULL, CMODE_OP, cu->user->nick); + c->RemoveMode(NULL, CMODE_OP, uc->user->nick); } - } else { - av[0] = chan; - for (cu = c->users; cu; cu = bnext) + } + else + { + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; - isop = chan_has_user_status(c, cu->user, CUS_OP); - isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); - isown = chan_has_user_status(c, cu->user, CUS_OWNER); + UserContainer *uc = *it; + + isop = chan_has_user_status(c, uc->user, CUS_OP); + isadmin = chan_has_user_status(c, uc->user, CUS_PROTECT); + isown = chan_has_user_status(c, uc->user, CUS_OWNER); if (!isop && !isadmin && !isown) continue; if (isown) - c->RemoveMode(NULL, CMODE_OWNER, cu->user->nick); + c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); if (isadmin) - c->RemoveMode(NULL, CMODE_PROTECT, cu->user->nick); + c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); if (isop) - c->RemoveMode(NULL, CMODE_OP, cu->user->nick); + c->RemoveMode(NULL, CMODE_OP, uc->user->nick); } } - notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_OPS, chan); - } else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && what == "hops") { - struct c_userlist *cu, *bnext; - for (cu = c->users; cu; cu = bnext) + notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_OPS, chan); + } + else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && what == "hops") + { + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; + UserContainer *uc = *it; - if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) + if (!chan_has_user_status(c, uc->user, CUS_HALFOP)) continue; - c->RemoveMode(NULL, CMODE_HALFOP, cu->user->nick); + c->RemoveMode(NULL, CMODE_HALFOP, uc->user->nick); } notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_HOPS, chan); - } else if (what == "voices") { - struct c_userlist *cu, *bnext; - - for (cu = c->users; cu; cu = bnext) + } + else if (what == "voices") + { + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - bnext = cu->next; + UserContainer *uc = *it; - if (!chan_has_user_status(c, cu->user, CUS_VOICE)) + if (!chan_has_user_status(c, uc->user, CUS_VOICE)) continue; - c->RemoveMode(NULL, CMODE_VOICE, cu->user->nick); + c->RemoveMode(NULL, CMODE_VOICE, uc->user->nick); } notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_VOICES, chan); - } else if (what == "users") { - struct c_userlist *cu, *bnext; + } + else if (what == "users") { std::string buf = "CLEAR USERS command from " + u->nick; - for (cu = c->users; cu; cu = bnext) { - bnext = cu->next; - c->Kick(NULL, cu->user, buf.c_str()); + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) + { + UserContainer *uc = *it++; + + c->Kick(NULL, uc->user, buf.c_str()); } + notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_USERS, chan); - } else { - syntax_error(Config.s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); } + else + syntax_error(Config.s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); + return MOD_CONT; } diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index 718cd41a1..57a0b552b 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -67,21 +67,19 @@ class CommandCSForbid : public Command if ((c = findchan(ci->name.c_str()))) { - struct c_userlist *cu, *nextu; - /* Before banning everyone, it might be prudent to clear +e and +I lists.. * to prevent ppl from rejoining.. ~ Viper */ c->ClearExcepts(); c->ClearInvites(); - for (cu = c->users; cu; cu = nextu) + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { - nextu = cu->next; + UserContainer *uc = *it++; - if (is_oper(cu->user)) + if (is_oper(uc->user)) continue; - c->Kick(findbot(Config.s_ChanServ), cu->user, "%s", reason ? reason : getstring(cu->user->nc, CHAN_FORBID_REASON)); + c->Kick(findbot(Config.s_ChanServ), uc->user, "%s", reason ? reason : getstring(uc->user->nc, CHAN_FORBID_REASON)); } } diff --git a/src/core/cs_set.c b/src/core/cs_set.c index 277649cfb..158987acd 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -583,7 +583,7 @@ class CommandCSSet : public Command /* Unset perm mode */ if (cm && ci->c && ci->c->HasMode(CMODE_PERM)) ci->c->RemoveMode(NULL, cm); - if (Config.s_BotServ && ci->bi && ci->c->usercount == Config.BSMinUsers - 1) + if (Config.s_BotServ && ci->bi && ci->c->users.size() == Config.BSMinUsers - 1) ircdproto->SendPart(ci->bi, ci->c, NULL); /* No channel mode, no BotServ, but using ChanServ as the botserv bot @@ -595,7 +595,7 @@ class CommandCSSet : public Command findbot(Config.s_ChanServ)->UnAssign(NULL, ci); } - if (ci->c && !ci->c->users) + if (ci->c && ci->c->users.empty()) delete ci->c; } diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c index e4386b021..03a058629 100644 --- a/src/core/cs_suspend.c +++ b/src/core/cs_suspend.c @@ -62,16 +62,14 @@ class CommandCSSuspend : public Command if ((c = findchan(ci->name.c_str()))) { - struct c_userlist *cu, *nextu; - - for (cu = c->users; cu; cu = nextu) + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { - nextu = cu->next; + UserContainer *uc = *it++; - if (is_oper(cu->user)) + if (is_oper(uc->user)) continue; - c->Kick(NULL, cu->user, "%s", reason ? reason : getstring(cu->user->nc, CHAN_SUSPEND_REASON)); + c->Kick(NULL, uc->user, "%s", reason ? reason : getstring(uc->user->nc, CHAN_SUSPEND_REASON)); } } diff --git a/src/core/os_chankill.c b/src/core/os_chankill.c index ee3038a07..bdb3ecc69 100644 --- a/src/core/os_chankill.c +++ b/src/core/os_chankill.c @@ -28,7 +28,6 @@ class CommandOSChanKill : public Command char reason[BUFSIZE]; time_t expires; char mask[USERMAX + HOSTMAX + 2]; - struct c_userlist *cu, *cunext; unsigned last_param = 1; Channel *c; @@ -70,15 +69,17 @@ class CommandOSChanKill : public Command if ((c = findchan(channel))) { - for (cu = c->users; cu; cu = cunext) + for (CUserList::iterator it = c->users.begin(); it != c->users.end();) { - cunext = cu->next; - if (is_oper(cu->user)) + UserContainer *uc = *it++; + + if (is_oper(uc->user)) continue; + strlcpy(mask, "*@", sizeof(mask)); /* Use *@" for the akill's, */ - strlcat(mask, cu->user->host, sizeof(mask)); + strlcat(mask, uc->user->host, sizeof(mask)); add_akill(NULL, mask, Config.s_OperServ, expires, realreason.c_str()); - check_akill(cu->user->nick.c_str(), cu->user->GetIdent().c_str(), cu->user->host, NULL, NULL); + check_akill(uc->user->nick.c_str(), uc->user->GetIdent().c_str(), uc->user->host, NULL, NULL); } if (Config.WallOSAkill) ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s used CHANKILL on %s (%s)", u->nick.c_str(), channel, realreason.c_str()); diff --git a/src/core/os_chanlist.c b/src/core/os_chanlist.c index e5aa27159..e8faa10f7 100644 --- a/src/core/os_chanlist.c +++ b/src/core/os_chanlist.c @@ -37,22 +37,22 @@ class CommandOSChanList : public Command if (pattern && (u2 = finduser(pattern))) { - struct u_chanlist *uc; - notice_lang(Config.s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick.c_str()); - for (uc = u2->chans; uc; uc = uc->next) + for (UChannelList::iterator it = u2->chans.begin(); it != u2->chans.end(); ++it) { + ChannelContainer *cc = *it; + if (!Modes.empty()) { for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it) { - if (!uc->chan->HasMode(*it)) + if (!cc->chan->HasMode(*it)) continue; } } - notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, uc->chan->name.c_str(), uc->chan->usercount, chan_get_modes(uc->chan, 1, 1), uc->chan->topic ? uc->chan->topic : ""); + notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, cc->chan->name.c_str(), cc->chan->users.size(), chan_get_modes(cc->chan, 1, 1), cc->chan->topic ? cc->chan->topic : ""); } } else @@ -76,7 +76,7 @@ class CommandOSChanList : public Command continue; } } - notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, c->name.c_str(), c->usercount, chan_get_modes(c, 1, 1), c->topic ? c->topic : ""); + notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, c->name.c_str(), c->users.size(), chan_get_modes(c, 1, 1), c->topic ? c->topic : ""); } } } diff --git a/src/core/os_clearmodes.c b/src/core/os_clearmodes.c index 8046abd8f..d0bc4c44b 100644 --- a/src/core/os_clearmodes.c +++ b/src/core/os_clearmodes.c @@ -27,7 +27,6 @@ class CommandOSClearModes : public Command const char *chan = params[0].c_str(); Channel *c; int all = 0; - struct c_userlist *cu, *next; ChannelMode *cm; std::string buf; @@ -62,13 +61,14 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, "-o", NULL); else { - for (cu = c->users; cu; cu = next) + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_OP)) + UserContainer *uc = *it; + + if (!chan_has_user_status(c, uc->user, CUS_OP)) continue; - c->RemoveMode(NULL, CMODE_OP, cu->user->nick); + c->RemoveMode(NULL, CMODE_OP, uc->user->nick); } } @@ -77,13 +77,14 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, "-v", NULL); else { - for (cu = c->users; cu; cu = next) + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_VOICE)) + UserContainer *uc = *it; + + if (!chan_has_user_status(c, uc->user, CUS_VOICE)) continue; - c->RemoveMode(NULL, CMODE_VOICE, cu->user->nick); + c->RemoveMode(NULL, CMODE_VOICE, uc->user->nick); } } @@ -94,13 +95,14 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, "-h", NULL); else { - for (cu = c->users; cu; cu = next) + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) + UserContainer *uc = *it; + + if (!chan_has_user_status(c, uc->user, CUS_HALFOP)) continue; - c->RemoveMode(NULL, CMODE_HALFOP, cu->user->nick); + c->RemoveMode(NULL, CMODE_HALFOP, uc->user->nick); } } } @@ -115,13 +117,14 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, buf.c_str(), NULL); else { - for (cu = c->users; cu; cu = next) + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_OWNER)) + UserContainer *uc = *it; + + if (!chan_has_user_status(c, uc->user, CUS_OWNER)) continue; - c->RemoveMode(NULL, CMODE_OWNER, cu->user->nick); + c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); } } } @@ -136,13 +139,14 @@ class CommandOSClearModes : public Command ircdproto->SendSVSModeChan(c, buf.c_str(), NULL); else { - for (cu = c->users; cu; cu = next) + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) + UserContainer *uc = *it; + + if (!chan_has_user_status(c, uc->user, CUS_PROTECT)) continue; - c->RemoveMode(NULL, CMODE_PROTECT, cu->user->nick); + c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); } } } diff --git a/src/core/os_userlist.c b/src/core/os_userlist.c index 9c4f6ed6a..331818bec 100644 --- a/src/core/os_userlist.c +++ b/src/core/os_userlist.c @@ -36,21 +36,22 @@ class CommandOSUserList : public Command if (pattern && (c = findchan(pattern))) { - struct c_userlist *cu; - notice_lang(Config.s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern); - for (cu = c->users; cu; cu = cu->next) + for (CUserList::iterator cuit = c->users.begin(); cuit != c->users.end(); ++cuit) { + UserContainer *uc = *cuit; + if (!Modes.empty()) { for (std::list<UserModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it) { - if (!cu->user->HasMode(*it)) + if (!uc->user->HasMode(*it)) continue; } } - notice_lang(Config.s_OperServ, u, OPER_USERLIST_RECORD, cu->user->nick.c_str(), cu->user->GetIdent().c_str(), cu->user->GetDisplayedHost().c_str()); + + notice_lang(Config.s_OperServ, u, OPER_USERLIST_RECORD, uc->user->nick.c_str(), uc->user->GetIdent().c_str(), uc->user->GetDisplayedHost().c_str()); } } else |
