summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command.cpp8
-rw-r--r--src/commands.c23
-rw-r--r--src/core/ns_group.c7
-rw-r--r--src/core/ns_help.c2
-rw-r--r--src/core/ns_info.c11
-rw-r--r--src/core/ns_list.c6
-rw-r--r--src/main.c3
-rw-r--r--src/modules.c120
-rw-r--r--src/process.c10
9 files changed, 25 insertions, 165 deletions
diff --git a/src/command.cpp b/src/command.cpp
index 5c754cd8d..752ea370c 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -9,14 +9,9 @@ Command::Command(const std::string &sname, size_t min_params, size_t max_params)
this->help_param3 = NULL;
this->help_param4 = NULL;
this->core = 0;
- this->next = NULL;
this->mod_name = NULL;
this->service = NULL;
- this->all_help = NULL;
- this->regular_help = NULL;
- this->oper_help = NULL;
- this->admin_help = NULL;
- this->root_help = NULL;
+ this->next = NULL;
}
Command::~Command()
@@ -27,7 +22,6 @@ Command::~Command()
if (this->service) {
delete [] this->service;
}
- this->next = NULL;
}
/** Execute this command.
diff --git a/src/commands.c b/src/commands.c
index 4add1c552..e7f5522ed 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -53,7 +53,7 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
{
Command *c = findCommand(cmdTable, cmd);
int retVal = 0;
- Command *current;
+
if (!c)
{
@@ -120,16 +120,12 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
return;
}
+ EventReturn MOD_RESULT = EVENT_CONTINUE;
+ FOREACH_RESULT(I_OnPreCommand, OnPreCommand(u, c->name, params));
+ if (MOD_RESULT == EVENT_STOP)
+ return;
+
retVal = c->Execute(u, params);
- if (retVal == MOD_CONT)
- {
- current = c->next;
- while (current && retVal == MOD_CONT)
- {
- retVal = current->Execute(u, params);
- current = current->next;
- }
- }
}
/*************************************************************************/
@@ -145,9 +141,6 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], const char *
void mod_help_cmd(char *service, User * u, CommandHash * cmdTable[],
const char *cmd)
{
- bool has_had_help = false;
- int cont = MOD_CONT;
-
spacesepstream tokens(cmd);
std::string token;
tokens.GetToken(token);
@@ -156,9 +149,7 @@ void mod_help_cmd(char *service, User * u, CommandHash * cmdTable[],
std::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining();
- for (Command *current = c; current && cont == MOD_CONT; current = current->next)
- has_had_help = current->OnHelp(u, subcommand);
- if (!has_had_help)
+ if (!c->OnHelp(u, subcommand))
notice_lang(service, u, NO_HELP_AVAILABLE, cmd);
}
diff --git a/src/core/ns_group.c b/src/core/ns_group.c
index e9be3fe0d..bac000611 100644
--- a/src/core/ns_group.c
+++ b/src/core/ns_group.c
@@ -208,11 +208,10 @@ class CommandNSGList : public Command
const char *nick = params.size() ? params[0].c_str() : NULL;
NickCore *nc = u->nc;
- int is_servadmin = is_services_admin(u);
int nick_ided = nick_identified(u);
int i;
- if (nick ? (stricmp(nick, u->nick) ? !is_servadmin : !nick_ided) : !nick_ided)
+ if (nick ? (stricmp(nick, u->nick) ? !u->nc->IsServicesOper() : !nick_ided) : !nick_ided)
notice_lang(s_NickServ, u, nick_ided ? ACCESS_DENIED : NICK_IDENTIFY_REQUIRED, s_NickServ);
else if (nick && (!findnick(nick) || !(nc = findnick(nick)->nc)))
notice_lang(s_NickServ, u, !nick ? NICK_NOT_REGISTERED : NICK_X_NOT_REGISTERED, nick);
@@ -237,7 +236,7 @@ class CommandNSGList : public Command
tm = localtime(&expt);
strftime_lang(buf, sizeof(buf), finduser(na2->nick), STRFTIME_DATE_TIME_FORMAT, tm);
}
- notice_lang(s_NickServ, u, is_services_admin(u) && !wont_expire ? NICK_GLIST_REPLY_ADMIN : NICK_GLIST_REPLY, wont_expire ? '!' : ' ', na2->nick, buf);
+ notice_lang(s_NickServ, u, u->nc->IsServicesOper() && !wont_expire ? NICK_GLIST_REPLY_ADMIN : NICK_GLIST_REPLY, wont_expire ? '!' : ' ', na2->nick, buf);
}
}
notice_lang(s_NickServ, u, NICK_GLIST_FOOTER, nc->aliases.count);
@@ -248,7 +247,7 @@ class CommandNSGList : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
- if (is_services_admin(u))
+ if (u->nc && u->nc->IsServicesOper())
notice_help(s_NickServ, u, NICK_SERVADMIN_HELP_GLIST);
else
notice_help(s_NickServ, u, NICK_HELP_GLIST);
diff --git a/src/core/ns_help.c b/src/core/ns_help.c
index 061293824..5c2b164cd 100644
--- a/src/core/ns_help.c
+++ b/src/core/ns_help.c
@@ -44,7 +44,7 @@ class CommandNSHelp : public Command
{
notice_help(s_NickServ, u, NICK_HELP);
moduleDisplayHelp(1, u);
- if (is_services_admin(u))
+ if (u->nc && u->nc->IsServicesOper())
notice_help(s_NickServ, u, NICK_SERVADMIN_HELP);
if (NSExpire >= 86400)
notice_help(s_NickServ, u, NICK_HELP_EXPIRES, NSExpire / 86400);
diff --git a/src/core/ns_info.c b/src/core/ns_info.c
index ed010c71e..d537ff272 100644
--- a/src/core/ns_info.c
+++ b/src/core/ns_info.c
@@ -52,18 +52,17 @@ class CommandNSInfo : public Command
NickAlias *na;
NickRequest *nr = NULL;
/* Being an oper is enough from now on -GD */
- int is_servadmin = is_services_oper(u);
if (!(na = findnick(nick)))
{
if ((nr = findrequestnick(nick)))
{
notice_lang(s_NickServ, u, NICK_IS_PREREG);
- if (param && !stricmp(param, "ALL") && is_servadmin)
+ if (param && !stricmp(param, "ALL") && u->nc->IsServicesOper())
notice_lang(s_NickServ, u, NICK_INFO_EMAIL, nr->email);
else
{
- if (is_servadmin)
+ if (u->nc->IsServicesOper())
notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE, s_NickServ, nr->nick);
}
}
@@ -93,7 +92,7 @@ class CommandNSInfo : public Command
/* Only show hidden fields to owner and sadmins and only when the ALL
* parameter is used. -TheShadow */
- if (param && !stricmp(param, "ALL") && u->nc && (na->nc == u->nc || is_servadmin))
+ if (param && !stricmp(param, "ALL") && u->nc && (na->nc == u->nc || u->nc->IsServicesOper()))
show_hidden = 1;
notice_lang(s_NickServ, u, NICK_INFO_REALNAME, na->nick, na->last_realname);
@@ -180,7 +179,7 @@ class CommandNSInfo : public Command
notice_lang(s_NickServ, u, NICK_INFO_NO_EXPIRE);
else
{
- if (is_services_admin(u))
+ if (u->nc->IsServicesOper())
{
expt = na->last_seen + NSExpire;
tm = localtime(&expt);
@@ -198,7 +197,7 @@ class CommandNSInfo : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
- if (is_services_admin(u))
+ if (u->nc->IsServicesOper())
notice_help(s_NickServ, u, NICK_SERVADMIN_HELP_INFO);
else
notice_help(s_NickServ, u, NICK_HELP_INFO);
diff --git a/src/core/ns_list.c b/src/core/ns_list.c
index 0f06ba7a9..534f371e3 100644
--- a/src/core/ns_list.c
+++ b/src/core/ns_list.c
@@ -45,7 +45,7 @@ class CommandNSList : public Command
NickCore *mync;
unsigned nnicks, i;
char buf[BUFSIZE];
- int is_servadmin = is_services_admin(u);
+ bool is_servadmin = u->nc->IsServicesOper();
int16 matchflags = 0;
NickRequest *nr = NULL;
int nronly = 0;
@@ -194,7 +194,7 @@ class CommandNSList : public Command
bool OnHelp(User *u, const std::string &subcommand)
{
- if (is_services_admin(u))
+ if (u->nc && u->nc->IsServicesOper())
notice_help(s_NickServ, u, NICK_SERVADMIN_HELP_LIST);
else
notice_help(s_NickServ, u, NICK_HELP_LIST);
@@ -204,7 +204,7 @@ class CommandNSList : public Command
void OnSyntaxError(User *u)
{
- if (is_services_admin(u))
+ if (u->nc->IsServicesOper())
syntax_error(s_NickServ, u, "LIST", NICK_LIST_SERVADMIN_SYNTAX);
else
syntax_error(s_NickServ, u, "LIST", NICK_LIST_SYNTAX);
diff --git a/src/main.c b/src/main.c
index 0abc2f360..dad8cb4f8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -91,7 +91,6 @@ const char version_build[] =
/* the space is needed cause if you build with nothing it will complain */
const char version_flags[] = " " VER_OS VER_MYSQL VER_MODULE;
-extern char *mod_current_buffer;
/******** Local variables! ********/
@@ -211,8 +210,6 @@ static void services_shutdown()
ircdproto->SendSquit(ServerName, quitmsg);
if (uplink)
delete [] uplink;
- if (mod_current_buffer)
- delete [] mod_current_buffer;
if (ircd->chanmodes) {
delete [] ircd->chanmodes;
}
diff --git a/src/modules.c b/src/modules.c
index 4ace54ab0..3a850ee6a 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -211,35 +211,15 @@ static int internal_addCommand(Module *m, CommandHash * cmdTable[], Command * c,
&& (!strcmp(c->service, current->c->service) == 0)) {
continue;
}
- if ((stricmp(c->name.c_str(), current->name) == 0)) { /* the cmd exist's we are a addHead */
- if (pos == 1) {
- c->next = current->c;
- current->c = c;
- if (debug)
- alog("debug: existing cmd: (0x%p), new cmd (0x%p)",
- static_cast<void *>(c->next), static_cast<void *>(c));
- return MOD_ERR_OK;
- } else if (pos == 2) {
-
- tail = current->c;
- while (tail->next)
- tail = tail->next;
- if (debug)
- alog("debug: existing cmd: (0x%p), new cmd (0x%p)",
- static_cast<void *>(tail), static_cast<void *>(c));
- tail->next = c;
- c->next = NULL;
-
- return MOD_ERR_OK;
- } else
- return MOD_ERR_EXISTS;
+ if ((stricmp(c->name.c_str(), current->name) == 0))
+ {
+ /* the cmd exists, throw an error */
+ return MOD_ERR_EXISTS;
}
lastHash = current;
}
- if (!(newHash = new CommandHash)) {
- fatal("Out of memory");
- }
+ newHash = new CommandHash;
newHash->next = NULL;
newHash->name = sstrdup(c->name.c_str());
newHash->c = c;
@@ -805,96 +785,6 @@ void moduleCallBackPrepForUnload(const char *mod_name)
}
}
-/**
- * Return a copy of the complete last buffer.
- * This is needed for modules who cant trust the strtok() buffer, as we dont know who will have already messed about with it.
- * @reutrn a pointer to a copy of the last buffer - DONT mess with this, copy if first if you must do things to it.
- **/
-char *moduleGetLastBuffer()
-{
- char *tmp = NULL;
- if (mod_current_buffer) {
- tmp = strchr(mod_current_buffer, ' ');
- if (tmp) {
- tmp++;
- }
- }
- return tmp;
-}
-
-/*******************************************************************************
- * Module HELP Functions
- *******************************************************************************/
- /**
- * Add help for Root admins.
- * @param c the Command to add help for
- * @param func the function to run when this help is asked for
- **/
-int moduleAddRootHelp(Command * c, int (*func) (User * u))
-{
- if (c) {
- c->root_help = func;
- return MOD_STOP;
- }
- return MOD_CONT;
-}
-
- /**
- * Add help for Admins.
- * @param c the Command to add help for
- * @param func the function to run when this help is asked for
- **/
-int moduleAddAdminHelp(Command * c, int (*func) (User * u))
-{
- if (c) {
- c->admin_help = func;
- return MOD_STOP;
- }
- return MOD_CONT;
-}
-
- /**
- * Add help for opers..
- * @param c the Command to add help for
- * @param func the function to run when this help is asked for
- **/
-int moduleAddOperHelp(Command * c, int (*func) (User * u))
-{
- if (c) {
- c->oper_help = func;
- return MOD_STOP;
- }
- return MOD_CONT;
-}
-
-/**
- * Add help for registered users
- * @param c the Command to add help for
- * @param func the function to run when this help is asked for
- **/
-int moduleAddRegHelp(Command * c, int (*func) (User * u))
-{
- if (c) {
- c->regular_help = func;
- return MOD_STOP;
- }
- return MOD_CONT;
-}
-
-/**
- * Add help for all users
- * @param c the Command to add help for
- * @param func the function to run when this help is asked for
- **/
-int moduleAddHelp(Command * c, int (*func) (User * u))
-{
- if (c) {
- c->all_help = func;
- return MOD_STOP;
- }
- return MOD_CONT;
-}
-
void Module::SetNickHelp(void (*func)(User *))
{
this->nickHelp = func;
diff --git a/src/process.c b/src/process.c
index 6730981c4..b0a4bd728 100644
--- a/src/process.c
+++ b/src/process.c
@@ -351,16 +351,6 @@ void process()
alog("debug: av[0] = NULL");
}
- if (mod_current_buffer) {
- delete [] mod_current_buffer;
- }
-
- if (ac >= 1) {
- mod_current_buffer = (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0]));
- } else {
- mod_current_buffer = NULL;
- }
-
/* Do something with the message. */
m = find_message(cmd);
if (m) {