From fa82890696c498f38643df7df6891434c91c9269 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 24 Apr 2010 17:18:25 -0400 Subject: Moved Commands stuff to its own file and changed Command::name to be ci::string - Will be used after hashing system is rewritten --- src/bots.cpp | 1 + src/command.cpp | 2 +- src/commands.c | 26 +++++++++++++++++++++++++- src/modules.c | 24 ------------------------ 4 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/bots.cpp b/src/bots.cpp index 37cd553d1..e663d9225 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -10,6 +10,7 @@ #include "services.h" #include "modules.h" +#include "commands.h" BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::string &nhost, const std::string &nreal) { diff --git a/src/command.cpp b/src/command.cpp index ea66a7261..fc745fe46 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -10,7 +10,7 @@ #include "services.h" #include "modules.h" -Command::Command(const std::string &sname, size_t min_params, size_t max_params, const std::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission) +Command::Command(const ci::string &sname, size_t min_params, size_t max_params, const std::string &spermission) : MaxParams(max_params), MinParams(min_params), name(sname), permission(spermission) { this->core = 0; this->mod_name = NULL; diff --git a/src/commands.c b/src/commands.c index 19d668137..40363a7d1 100644 --- a/src/commands.c +++ b/src/commands.c @@ -12,12 +12,36 @@ */ #include "services.h" -#include "commands.h" +#include "modules.h" #include "language.h" #include "hashcomp.h" /*************************************************************************/ +/** + * Search the command table gieven for a command. + * @param cmdTable the name of the command table to search + * @param name the name of the command to look for + * @return returns a pointer to the found command struct, or NULL + */ +Command *findCommand(CommandHash * cmdTable[], const char *name) +{ + int idx; + CommandHash *current = NULL; + if (!cmdTable || !name) { + return NULL; + } + + idx = CMD_HASH(name); + + for (current = cmdTable[idx]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + return current->c; + } + } + return NULL; +} + /** * Return the Command corresponding to the given name, or NULL if no such * command exists. diff --git a/src/modules.c b/src/modules.c index 40c10144f..af3aa2f4d 100644 --- a/src/modules.c +++ b/src/modules.c @@ -362,30 +362,6 @@ int Module::DelCommand(CommandHash * cmdTable[], const char *dname) return status; } -/** - * Search the command table gieven for a command. - * @param cmdTable the name of the command table to search - * @param name the name of the command to look for - * @return returns a pointer to the found command struct, or NULL - */ -Command *findCommand(CommandHash * cmdTable[], const char *name) -{ - int idx; - CommandHash *current = NULL; - if (!cmdTable || !name) { - return NULL; - } - - idx = CMD_HASH(name); - - for (current = cmdTable[idx]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - return current->c; - } - } - return NULL; -} - /******************************************************************************* * Message Functions *******************************************************************************/ -- cgit