diff options
| author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-11 06:03:25 +0000 |
|---|---|---|
| committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-11-11 06:03:25 +0000 |
| commit | b9190ebc16253254cb649faae76119eec3e14b8e (patch) | |
| tree | e1cc12269825f020a14877be1ecfbfa959781710 /src/core | |
| parent | 86e43f1f144cfd04b039a844959af1f7aec3e6da (diff) | |
Moved alot of stuff to constructors and destructors, instead of having functions everywhere to create and destroy objects
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2639 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/cs_drop.c | 2 | ||||
| -rw-r--r-- | src/core/cs_forbid.c | 4 | ||||
| -rw-r--r-- | src/core/cs_register.c | 2 | ||||
| -rw-r--r-- | src/core/cs_set.c | 4 | ||||
| -rw-r--r-- | src/core/ns_drop.c | 4 | ||||
| -rw-r--r-- | src/core/ns_forbid.c | 27 | ||||
| -rw-r--r-- | src/core/ns_group.c | 21 | ||||
| -rw-r--r-- | src/core/ns_register.c | 46 |
8 files changed, 18 insertions, 92 deletions
diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c index 7de9b7327..5d4c43bfb 100644 --- a/src/core/cs_drop.c +++ b/src/core/cs_drop.c @@ -75,7 +75,7 @@ class CommandCSDrop : public Command s_ChanServ, ci->name, u->nick, u->GetIdent().c_str(), u->host, (ci->founder ? ci->founder->display : "(none)")); - delchan(ci); + delete ci; /* We must make sure that the Services admin has not normally the right to * drop the channel before issuing the wallops. diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index 9eefe4cfc..c4c916c1b 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -50,9 +50,9 @@ class CommandCSForbid : public Command } if ((ci = cs_findchan(chan)) != NULL) - delchan(ci); + delete ci; - ci = makechan(chan); + ci = new ChannelInfo(chan); if (!ci) { alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name, u->nick); diff --git a/src/core/cs_register.c b/src/core/cs_register.c index 0ea7e58dc..dbe421110 100644 --- a/src/core/cs_register.c +++ b/src/core/cs_register.c @@ -53,7 +53,7 @@ class CommandCSRegister : public Command notice_lang(s_ChanServ, u, CHAN_MUST_BE_CHANOP); else if (CSMaxReg && u->nc->channelcount >= CSMaxReg && !u->nc->HasPriv("chanserv/no-register-limit")) notice_lang(s_ChanServ, u, u->nc->channelcount > CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, CSMaxReg); - else if (!(ci = makechan(chan))) + else if (!(ci = new ChannelInfo(chan))) { alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan); notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); diff --git a/src/core/cs_set.c b/src/core/cs_set.c index 96c8ae35c..74a1590f0 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -511,7 +511,7 @@ class CommandCSSet : public Command /* Channel doesn't exist, create it internally */ if (!ci->c) { - chan_create(ci->name, time(NULL)); + new Channel(ci->name); if (ci->bi) bot_join(ci); } @@ -553,7 +553,7 @@ class CommandCSSet : public Command if (s_BotServ && ci->bi && ci->c->usercount == BSMinUsers - 1) ircdproto->SendPart(ci->bi, ci->c->name, NULL); if (!ci->c->users) - chan_delete(ci->c); + delete ci->c; /* No channel mode, no BotServ, but using ChanServ as the botserv bot * which was assigned when persist was set on diff --git a/src/core/ns_drop.c b/src/core/ns_drop.c index 1e15aa292..430c57d03 100644 --- a/src/core/ns_drop.c +++ b/src/core/ns_drop.c @@ -45,7 +45,7 @@ class CommandNSDrop : public Command if (WallDrop) ircdproto->SendGlobops(s_NickServ, "\2%s\2 used DROP on \2%s\2", u->nick, nick); alog("%s: %s!%s@%s dropped nickname %s (e-mail: %s)", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, nr->nick, nr->email); - delnickrequest(nr); + delete nr; notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); } else @@ -73,7 +73,7 @@ class CommandNSDrop : public Command ircdproto->SendSQLineDel(na->nick); alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, na->nick, na->nc->display, na->nc->email ? na->nc->email : "none"); - delnick(na); + delete na; FOREACH_MOD(I_OnNickDrop, OnNickDrop(my_nick ? my_nick : nick)); diff --git a/src/core/ns_forbid.c b/src/core/ns_forbid.c index 524dab5e3..4fe0412d9 100644 --- a/src/core/ns_forbid.c +++ b/src/core/ns_forbid.c @@ -15,8 +15,6 @@ #include "module.h" -NickAlias *makenick(const char *nick); - class CommandNSForbid : public Command { public: @@ -50,9 +48,9 @@ class CommandNSForbid : public Command notice_lang(s_NickServ, u, ACCESS_DENIED); return MOD_CONT; } - delnick(na); + delete na; } - na = makenick(nick); + na = new NickAlias(nick, new NickCore(nick)); if (na) { na->SetFlag(NS_FORBIDDEN); @@ -119,25 +117,4 @@ class NSForbid : public Module } }; -NickAlias *makenick(const char *nick) -{ - NickAlias *na; - NickCore *nc; - - /* First make the core */ - nc = new NickCore(); - nc->display = sstrdup(nick); - slist_init(&nc->aliases); - insert_core(nc); - alog("%s: group %s has been created", s_NickServ, nc->display); - - /* Then make the alias */ - na = new NickAlias; - na->nick = sstrdup(nick); - na->nc = nc; - slist_add(&nc->aliases, na); - alpha_insert_alias(na); - return na; -} - MODULE_INIT(NSForbid) diff --git a/src/core/ns_group.c b/src/core/ns_group.c index 5e6354598..f079e2a99 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -15,8 +15,6 @@ #include "module.h" -NickAlias *makealias(const char *nick, NickCore *nc); - class CommandNSGroup : public Command { public: @@ -96,7 +94,7 @@ class CommandNSGroup : public Command * If not, check that it is valid. */ if (findnick(u->nick)) - delnick(findnick(u->nick)); + delete findnick(u->nick); else { int prefixlen = strlen(NSGuestNickPrefix); @@ -108,7 +106,8 @@ class CommandNSGroup : public Command return MOD_CONT; } } - na = makealias(u->nick, target->nc); + + na = new NickAlias(u->nick, target->nc); if (na) { @@ -230,18 +229,4 @@ class NSGroup : public Module } }; -/* Creates a new alias in NickServ database. */ -NickAlias *makealias(const char *nick, NickCore *nc) -{ - NickAlias *na; - - /* Just need to make the alias */ - na = new NickAlias; - na->nick = sstrdup(nick); - na->nc = nc; - slist_add(&nc->aliases, na); - alpha_insert_alias(na); - return na; -} - MODULE_INIT(NSGroup) diff --git a/src/core/ns_register.c b/src/core/ns_register.c index 1a1d2b2eb..27cb51786 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -15,8 +15,6 @@ #include "module.h" -NickRequest *makerequest(const char *nick); -NickAlias *makenick(const char *nick); int do_sendregmail(User *u, NickRequest *nr); class CommandNSConfirm : public Command @@ -24,8 +22,7 @@ class CommandNSConfirm : public Command protected: CommandReturn ActuallyConfirmNick(User *u, NickRequest *nr, bool force) { - NickAlias *na; - na = makenick(nr->nick); + NickAlias *na = new NickAlias(nr->nick, new NickCore(nr->nick)); if (!na) { @@ -69,7 +66,7 @@ class CommandNSConfirm : public Command notice_lang(s_NickServ, u, NICK_REGISTERED, u->nick, na->nc->GetAccess(0).c_str()); else notice_lang(s_NickServ, u, NICK_REGISTERED_NO_MASK, u->nick); - delnickrequest(nr); + delete nr; ircdproto->SendAccountLogin(u, u->nc); ircdproto->SetAutoIdentificationToken(u); @@ -87,7 +84,7 @@ class CommandNSConfirm : public Command User *user = finduser(nr->nick); /* Delrequest must be called before validate_user */ - delnickrequest(nr); + delete nr; if (user) { validate_user(user); @@ -268,7 +265,7 @@ class CommandNSRegister : public CommandNSConfirm for (idx = 0; idx < 9; ++idx) passcode[idx] = chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min]; passcode[idx] = '\0'; - nr = makerequest(u->nick); + nr = new NickRequest(u->nick); nr->passcode = sstrdup(passcode); strscpy(nr->password, pass, PASSMAX); enc_encrypt_in_place(nr->password, PASSMAX); @@ -287,7 +284,7 @@ class CommandNSRegister : public CommandNSConfirm { alog("%s: Unable to send registration verification mail", s_NickServ); notice_lang(s_NickServ, u, NICK_REG_UNABLE); - delnickrequest(nr); /* Delete the NickRequest if we couldnt send the mail */ + delete nr; return MOD_CONT; } } @@ -387,39 +384,6 @@ class NSRegister : public Module /*************************************************************************/ -NickRequest *makerequest(const char *nick) -{ - NickRequest *nr; - - nr = new NickRequest; - nr->nick = sstrdup(nick); - insert_requestnick(nr); - alog("%s: Nick %s has been requested", s_NickServ, nr->nick); - return nr; -} - -/* Creates a full new nick (alias + core) in NickServ database. */ -NickAlias *makenick(const char *nick) -{ - NickAlias *na; - NickCore *nc; - - /* First make the core */ - nc = new NickCore(); - nc->display = sstrdup(nick); - slist_init(&nc->aliases); - insert_core(nc); - alog("%s: group %s has been created", s_NickServ, nc->display); - - /* Then make the alias */ - na = new NickAlias; - na->nick = sstrdup(nick); - na->nc = nc; - slist_add(&nc->aliases, na); - alpha_insert_alias(na); - return na; -} - int do_sendregmail(User *u, NickRequest *nr) { MailInfo *mail = NULL; |
