diff options
author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 15:22:40 +0000 |
---|---|---|
committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-15 15:22:40 +0000 |
commit | 02452a03756197fbdb976bd8bc41ffd69eeb61fe (patch) | |
tree | 25cec829fe6a15b6080f8d3971d092c4d3cc7364 | |
parent | 83243793468c7af887404ca30c34146436682610 (diff) |
Split Command implementation from definition.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2064 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/modules.h | 38 | ||||
-rw-r--r-- | src/Makefile | 3 | ||||
-rw-r--r-- | src/command.cpp | 49 |
3 files changed, 57 insertions, 33 deletions
diff --git a/include/modules.h b/include/modules.h index 8f441c66b..56d6aece1 100644 --- a/include/modules.h +++ b/include/modules.h @@ -160,52 +160,26 @@ class Command * @param max_params The maximum number of parameters the parser will create, after max_params, all will be combined into the last argument. * NOTE: If max_params is not set (default), there is no limit to the max number of params. */ - Command(const std::string &sname, size_t min_params, size_t max_params = 0) : MaxParams(max_params), MinParams(min_params), name(sname) - { - this->has_priv = NULL; - this->help_param1 = NULL; - this->help_param2 = NULL; - 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; - } - - virtual ~Command() - { - this->has_priv = NULL; - if (this->mod_name) { - delete [] this->mod_name; - } - if (this->service) { - delete [] this->service; - } - this->next = NULL; - } + Command(const std::string &sname, size_t min_params, size_t max_params = 0); + + virtual ~Command(); /** Execute this command. * @param u The user executing the command. */ - virtual CommandReturn Execute(User *u, std::vector<std::string> &) { return MOD_CONT; } + virtual CommandReturn Execute(User *u, std::vector<std::string> &); /** Requested when the user is requesting help on this command. Help on this command should be sent to the user. * @param u The user requesting help * @param subcommand The subcommand the user is requesting help on, or an empty string. (e.g. /ns help set foo bar lol gives a subcommand of "FOO BAR LOL") * @return true if help was provided to the user, false otherwise. */ - virtual bool OnHelp(User *u, const std::string &subcommand) { return false; } + virtual bool OnHelp(User *u, const std::string &subcommand); /** Requested when the user provides bad syntax to this command (not enough params, etc). * @param u The user executing the command. */ - virtual void OnSyntaxError(User *u) { } + virtual void OnSyntaxError(User *u); int (*has_priv)(User *u); /* Returns 1 if user may use command, else 0 */ diff --git a/src/Makefile b/src/Makefile index 0a65cd246..8e41b92ee 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,4 +1,4 @@ -OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o commands.o compat.o \ +OBJS = actions.o base64.o bots.o botserv.o channels.o chanserv.o command.o commands.o compat.o \ config.o datafiles.o encrypt.o events.o hashcomp.o helpserv.o hostserv.o init.o ircd.o language.o log.o mail.o main.o \ memory.o memoserv.o messages.o misc.o modules.o news.o nickserv.o operserv.o \ process.o protocol.o send.o servers.o sessions.o slist.o sockutil.o opertype.o timeout.o users.o module.o modulemanager.o configreader.o \ @@ -40,6 +40,7 @@ bots.o: bots.cpp $(INCLUDES) botserv.o: botserv.c $(INCLUDES) channels.o: channels.c $(INCLUDES) chanserv.o: chanserv.c $(INCLUDES) +command.o: command.cpp $(INCLUDES) commands.o: commands.c $(INCLUDES) compat.o: compat.c $(INCLUDES) config.o: config.c $(INCLUDES) diff --git a/src/command.cpp b/src/command.cpp new file mode 100644 index 000000000..bf05d79d5 --- /dev/null +++ b/src/command.cpp @@ -0,0 +1,49 @@ +#include "services.h" +#include "modules.h" + +Command::Command(const std::string &sname, size_t min_params, size_t max_params) : MaxParams(max_params), MinParams(min_params), name(sname) +{ + this->has_priv = NULL; + this->help_param1 = NULL; + this->help_param2 = NULL; + 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; +} + +Command::~Command() +{ + this->has_priv = NULL; + if (this->mod_name) { + delete [] this->mod_name; + } + if (this->service) { + delete [] this->service; + } + this->next = NULL; +} + +/** Execute this command. + * @param u The user executing the command. + */ +CommandReturn Command::Execute(User *u, std::vector<std::string> &) { return MOD_CONT; } + +/** Requested when the user is requesting help on this command. Help on this command should be sent to the user. + * @param u The user requesting help + * @param subcommand The subcommand the user is requesting help on, or an empty string. (e.g. /ns help set foo bar lol gives a subcommand of "FOO BAR LOL") + * @return true if help was provided to the user, false otherwise. + */ +bool Command::OnHelp(User *u, const std::string &subcommand) { return false; } + +/** Requested when the user provides bad syntax to this command (not enough params, etc). + * @param u The user executing the command. + */ +void Command::OnSyntaxError(User *u) { } |