diff options
author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 22:29:18 +0000 |
---|---|---|
committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 22:29:18 +0000 |
commit | d1611b640bcd27e1a91a99ef32127bc722e50a36 (patch) | |
tree | b18c77b07b74b70f5613b106aa2a81baa6227f35 /src/core/ns_access.c | |
parent | 0e5b71923b25d908167e7ef9d07c6c217827e901 (diff) |
Remove User::na, use User::nc everywhere. Will probably break everything, but opens the door to decoupling NC from NA, and means commands can now be run without bothering about changinc nick :)
More tweaking for na/nc usage.
It compiles, but it's still a work in progress.
Again, this compiles, but I *bet* there's no chance in hell it'll work. :)
Slightly better.
Set User::nc correctly.
Fix crash with unregistered nicks in core and ns_access.
Fix glist to work when you're not on that particular nick.
Fix ns_set to not crash and burn horribly.
Fix ns_set and ns_logout to not do bad things.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2076 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core/ns_access.c')
-rw-r--r-- | src/core/ns_access.c | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/core/ns_access.c b/src/core/ns_access.c index 07fce81a4..7afeb1559 100644 --- a/src/core/ns_access.c +++ b/src/core/ns_access.c @@ -20,32 +20,34 @@ void myNickServHelp(User *u); class CommandNSAccess : public Command { private: - CommandReturn DoServAdminList(User *u, std::vector<std::string> ¶ms, NickAlias *na) + CommandReturn DoServAdminList(User *u, std::vector<std::string> ¶ms, NickCore *nc) { const char *mask = params.size() > 2 ? params[2].c_str() : NULL; char **access; int i; - if (!na->nc->accesscount) + if (!nc->accesscount) { - notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X_EMPTY, na->nick); + notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X_EMPTY, nc->display); return MOD_CONT; } +/* reinstate when forbidden is moved to a group flag if (na->status & NS_FORBIDDEN) { notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); return MOD_CONT; } +*/ - if (na->nc->flags & NI_SUSPENDED) + if (nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, nc->display); return MOD_CONT; } notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X, params[1].c_str()); - for (access = na->nc->access, i = 0; i < na->nc->accesscount; ++access, ++i) + for (access = nc->access, i = 0; i < nc->accesscount; ++access, ++i) { if (mask && !match_wild(mask, *access)) continue; @@ -55,7 +57,7 @@ class CommandNSAccess : public Command return MOD_CONT; } - CommandReturn DoAdd(User *u, std::vector<std::string> ¶ms, NickAlias *na, const char *mask) + CommandReturn DoAdd(User *u, std::vector<std::string> ¶ms, NickCore *nc, const char *mask) { char **access; int i; @@ -66,13 +68,13 @@ class CommandNSAccess : public Command return MOD_CONT; } - if (na->nc->accesscount >= NSAccessMax) + if (nc->accesscount >= NSAccessMax) { notice_lang(s_NickServ, u, NICK_ACCESS_REACHED_LIMIT, NSAccessMax); return MOD_CONT; } - for (access = na->nc->access, i = 0; i < na->nc->accesscount; ++access, ++i) + for (access = nc->access, i = 0; i < nc->accesscount; ++access, ++i) { if (!strcmp(*access, mask)) { @@ -81,15 +83,15 @@ class CommandNSAccess : public Command } } - ++na->nc->accesscount; - na->nc->access = static_cast<char **>(srealloc(na->nc->access, sizeof(char *) * na->nc->accesscount)); - na->nc->access[na->nc->accesscount - 1] = sstrdup(mask); + ++nc->accesscount; + nc->access = static_cast<char **>(srealloc(nc->access, sizeof(char *) * nc->accesscount)); + nc->access[nc->accesscount - 1] = sstrdup(mask); notice_lang(s_NickServ, u, NICK_ACCESS_ADDED, mask); return MOD_CONT; } - CommandReturn DoDel(User *u, std::vector<std::string> ¶ms, NickAlias *na, const char *mask) + CommandReturn DoDel(User *u, std::vector<std::string> ¶ms, NickCore *nc, const char *mask) { char **access; int i; @@ -100,12 +102,12 @@ class CommandNSAccess : public Command return MOD_CONT; } - for (access = na->nc->access, i = 0; i < na->nc->accesscount; ++access, ++i) + for (access = nc->access, i = 0; i < nc->accesscount; ++access, ++i) { if (!stricmp(*access, mask)) break; } - if (i == na->nc->accesscount) + if (i == nc->accesscount) { notice_lang(s_NickServ, u, NICK_ACCESS_NOT_FOUND, mask); return MOD_CONT; @@ -113,33 +115,33 @@ class CommandNSAccess : public Command notice_lang(s_NickServ, u, NICK_ACCESS_DELETED, *access); delete [] *access; - --na->nc->accesscount; - if (i < na->nc->accesscount) /* if it wasn't the last entry... */ - memmove(access, access + 1, (na->nc->accesscount - i) * sizeof(char *)); - if (na->nc->accesscount) /* if there are any entries left... */ - na->nc->access = static_cast<char **>(srealloc(na->nc->access, na->nc->accesscount * sizeof(char *))); + --nc->accesscount; + if (i < nc->accesscount) /* if it wasn't the last entry... */ + memmove(access, access + 1, (nc->accesscount - i) * sizeof(char *)); + if (nc->accesscount) /* if there are any entries left... */ + nc->access = static_cast<char **>(srealloc(nc->access, nc->accesscount * sizeof(char *))); else { - free(na->nc->access); - na->nc->access = NULL; + free(nc->access); + nc->access = NULL; } return MOD_CONT; } - CommandReturn DoList(User *u, std::vector<std::string> ¶ms, NickAlias *na, const char *mask) + CommandReturn DoList(User *u, std::vector<std::string> ¶ms, NickCore *nc, const char *mask) { char **access; int i; - if (!na->nc->accesscount) + if (!nc->accesscount) { notice_lang(s_NickServ, u, NICK_ACCESS_LIST_EMPTY, u->nick); return MOD_CONT; } notice_lang(s_NickServ, u, NICK_ACCESS_LIST); - for (access = na->nc->access, i = 0; i < na->nc->accesscount; ++access, ++i) + for (access = nc->access, i = 0; i < nc->accesscount; ++access, ++i) { if (mask && !match_wild(mask, *access)) continue; @@ -160,7 +162,7 @@ class CommandNSAccess : public Command NickAlias *na; if (!stricmp(cmd, "LIST") && is_services_admin(u) && mask && (na = findnick(params[1].c_str()))) - return this->DoServAdminList(u, params, na); + return this->DoServAdminList(u, params, na->nc); if (mask && !strchr(mask, '@')) { @@ -168,20 +170,18 @@ class CommandNSAccess : public Command notice_lang(s_NickServ, u, MORE_INFO, s_NickServ, "ACCESS"); } - else if (!(na = u->na)) - notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); + /* else if (na->status & NS_FORBIDDEN) notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - else if (na->nc->flags & NI_SUSPENDED) - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - else if (!nick_identified(u)) - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + */ + else if (u->nc->flags & NI_SUSPENDED) + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nc->display); else if (!stricmp(cmd, "ADD")) - return this->DoAdd(u, params, na, mask); + return this->DoAdd(u, params, u->nc, mask); else if (!stricmp(cmd, "DEL")) - return this->DoDel(u, params, na, mask); + return this->DoDel(u, params, u->nc, mask); else if (!stricmp(cmd, "LIST")) - return this->DoList(u, params, na, mask); + return this->DoList(u, params, u->nc, mask); else this->OnSyntaxError(u); return MOD_CONT; |