diff options
| author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
|---|---|---|
| committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-14 20:57:20 +0000 |
| commit | 6c55e0a529c7f1216ff6f63a4fc77ea06a2a3a38 (patch) | |
| tree | 91b0841faf23087ebe0c74dd4269d181a383f1e7 /src/modules.c | |
| parent | 069409cd99cf78ab8bf87a1fe69a833576414fd3 (diff) | |
Insane commit of doom: s/ \t/g
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1681 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules.c')
| -rw-r--r-- | src/modules.c | 2414 |
1 files changed, 1207 insertions, 1207 deletions
diff --git a/src/modules.c b/src/modules.c index 36ffc2ed5..aa8f09b29 100644 --- a/src/modules.c +++ b/src/modules.c @@ -56,23 +56,23 @@ ModuleCallBack *moduleCallBackHead = NULL; char *ModuleGetErrStr(int status) { - const char *module_err_str[] = { - "Module, Okay - No Error", /* MOD_ERR_OK */ - "Module Error, Allocating memory", /* MOD_ERR_MEMORY */ - "Module Error, Not enough parameters", /* MOD_ERR_PARAMS */ - "Module Error, Already loaded", /* MOD_ERR_EXISTS */ - "Module Error, File does not exist", /* MOD_ERR_NOEXIST */ - "Module Error, No User", /* MOD_ERR_NOUSER */ - "Module Error, Error during load time or module returned MOD_STOP", /* MOD_ERR_NOLOAD */ - "Module Error, Unable to unload", /* MOD_ERR_NOUNLOAD */ - "Module Error, Incorrect syntax", /* MOD_ERR_SYNTAX */ - "Module Error, Unable to delete", /* MOD_ERR_NODELETE */ - "Module Error, Unknown Error occuried", /* MOD_ERR_UNKOWN */ - "Module Error, File I/O Error", /* MOD_ERR_FILE_IO */ - "Module Error, No Service found for request", /* MOD_ERR_NOSERVICE */ - "Module Error, No module name for request" /* MOD_ERR_NO_MOD_NAME */ - }; - return (char *) module_err_str[status]; + const char *module_err_str[] = { + "Module, Okay - No Error", /* MOD_ERR_OK */ + "Module Error, Allocating memory", /* MOD_ERR_MEMORY */ + "Module Error, Not enough parameters", /* MOD_ERR_PARAMS */ + "Module Error, Already loaded", /* MOD_ERR_EXISTS */ + "Module Error, File does not exist", /* MOD_ERR_NOEXIST */ + "Module Error, No User", /* MOD_ERR_NOUSER */ + "Module Error, Error during load time or module returned MOD_STOP", /* MOD_ERR_NOLOAD */ + "Module Error, Unable to unload", /* MOD_ERR_NOUNLOAD */ + "Module Error, Incorrect syntax", /* MOD_ERR_SYNTAX */ + "Module Error, Unable to delete", /* MOD_ERR_NODELETE */ + "Module Error, Unknown Error occuried", /* MOD_ERR_UNKOWN */ + "Module Error, File I/O Error", /* MOD_ERR_FILE_IO */ + "Module Error, No Service found for request", /* MOD_ERR_NOSERVICE */ + "Module Error, No module name for request" /* MOD_ERR_NO_MOD_NAME */ + }; + return (char *) module_err_str[status]; } @@ -89,14 +89,14 @@ char *ModuleGetErrStr(int status) */ static int displayCommand(Command * c) { - Command *cmd = NULL; - int i = 0; - alog("Displaying command list for %s", c->name); - for (cmd = c; cmd; cmd = cmd->next) { - alog("%d: 0x%p", ++i, (void *) cmd); - } - alog("end"); - return 0; + Command *cmd = NULL; + int i = 0; + alog("Displaying command list for %s", c->name); + for (cmd = c; cmd; cmd = cmd->next) { + alog("%d: 0x%p", ++i, (void *) cmd); + } + alog("end"); + return 0; } /** @@ -108,21 +108,21 @@ static int displayCommand(Command * c) */ static int displayCommandFromHash(CommandHash * cmdTable[], const char *name) { - CommandHash *current = NULL; - int index = 0; - index = CMD_HASH(name); - if (debug > 1) { - alog("debug: trying to display command %s", name); - } - for (current = cmdTable[index]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - displayCommand(current->c); - } - } - if (debug > 1) { - alog("debug: done displaying command %s", name); - } - return 0; + CommandHash *current = NULL; + int index = 0; + index = CMD_HASH(name); + if (debug > 1) { + alog("debug: trying to display command %s", name); + } + for (current = cmdTable[index]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + displayCommand(current->c); + } + } + if (debug > 1) { + alog("debug: done displaying command %s", name); + } + return 0; } /** @@ -133,14 +133,14 @@ static int displayCommandFromHash(CommandHash * cmdTable[], const char *name) */ static int displayMessage(Message * m) { - Message *msg = NULL; - int i = 0; - alog("Displaying message list for %s", m->name); - for (msg = m; msg; msg = msg->next) { - alog("%d: 0x%p", ++i, (void *) msg); - } - alog("end"); - return 0; + Message *msg = NULL; + int i = 0; + alog("Displaying message list for %s", m->name); + for (msg = m; msg; msg = msg->next) { + alog("%d: 0x%p", ++i, (void *) msg); + } + alog("end"); + return 0; } /** @@ -151,21 +151,21 @@ static int displayMessage(Message * m) */ static int displayMessageFromHash(const char *name) { - MessageHash *current = NULL; - int index = 0; - index = CMD_HASH(name); - if (debug > 1) { - alog("debug: trying to display message %s", name); - } - for (current = IRCD[index]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - displayMessage(current->m); - } - } - if (debug > 1) { - alog("debug: done displaying message %s", name); - } - return 0; + MessageHash *current = NULL; + int index = 0; + index = CMD_HASH(name); + if (debug > 1) { + alog("debug: trying to display message %s", name); + } + for (current = IRCD[index]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + displayMessage(current->m); + } + } + if (debug > 1) { + alog("debug: done displaying message %s", name); + } + return 0; } /************************************************/ @@ -174,14 +174,14 @@ static int displayMessageFromHash(const char *name) * **/ int encryption_module_init(void) { - int ret = 0; + int ret = 0; - alog("Loading Encryption Module: [%s]", EncModule); - ret = ModuleManager::LoadModule(EncModule, NULL); + alog("Loading Encryption Module: [%s]", EncModule); + ret = ModuleManager::LoadModule(EncModule, NULL); if (ret == MOD_ERR_OK) findModule(EncModule)->SetType(ENCRYPTION); - mod_current_module = NULL; - return ret; + mod_current_module = NULL; + return ret; } /** @@ -189,10 +189,10 @@ int encryption_module_init(void) { **/ int protocol_module_init(void) { - int ret = 0; + int ret = 0; - alog("Loading IRCD Protocol Module: [%s]", IRCDModule); - ret = ModuleManager::LoadModule(IRCDModule, NULL); + alog("Loading IRCD Protocol Module: [%s]", IRCDModule); + ret = ModuleManager::LoadModule(IRCDModule, NULL); if (ret == MOD_ERR_OK) { @@ -207,14 +207,14 @@ int protocol_module_init(void) } /* We can assume the ircd supports TS6 here */ - if (UseTS6 && !Numeric) { - alog("UseTS6 requires the setting of Numeric to be enabled."); - ret = -1; - } + if (UseTS6 && !Numeric) { + alog("UseTS6 requires the setting of Numeric to be enabled."); + ret = -1; + } } mod_current_module = NULL; - return ret; + return ret; } /** @@ -247,33 +247,33 @@ void modules_unload_all(bool fini, bool unload_proto) next = mh->next; if (unload_proto || (mh->m->type != PROTOCOL)) { mod_current_module = mh->m; - mod_current_module_name = mh->m->name.c_str(); - mod_current_module_name = NULL; + mod_current_module_name = mh->m->name.c_str(); + mod_current_module_name = NULL; - delete mh->m; - } - mh = next; + delete mh->m; + } + mh = next; } } } void Module::InsertLanguage(int langNumber, int ac, const char **av) { - int i; + int i; if (debug) alog("debug: %s Adding %d texts for language %d", this->name.c_str(), ac, langNumber); - if (this->lang[langNumber].argc > 0) { - moduleDeleteLanguage(langNumber); - } + if (this->lang[langNumber].argc > 0) { + moduleDeleteLanguage(langNumber); + } - this->lang[langNumber].argc = ac; - this->lang[langNumber].argv = - (char **)malloc(sizeof(char *) * ac); - for (i = 0; i < ac; i++) { - this->lang[langNumber].argv[i] = sstrdup(av[i]); - } + this->lang[langNumber].argc = ac; + this->lang[langNumber].argv = + (char **)malloc(sizeof(char *) * ac); + for (i = 0; i < ac; i++) { + this->lang[langNumber].argv[i] = sstrdup(av[i]); + } } /** @@ -283,19 +283,19 @@ void Module::InsertLanguage(int langNumber, int ac, const char **av) */ Module *findModule(const char *name) { - int idx; - ModuleHash *current = NULL; - if (!name) { - return NULL; - } - idx = CMD_HASH(name); - - for (current = MODULE_HASH[idx]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - return current->m; - } - } - return NULL; + int idx; + ModuleHash *current = NULL; + if (!name) { + return NULL; + } + idx = CMD_HASH(name); + + for (current = MODULE_HASH[idx]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + return current->m; + } + } + return NULL; } @@ -315,39 +315,39 @@ Module *findModule(const char *name) * @return a "ready to use" Command struct will be returned */ Command *createCommand(const char *name, int (*func) (User * u), - int (*has_priv) (User * u), int help_all, - int help_reg, int help_oper, int help_admin, - int help_root) + int (*has_priv) (User * u), int help_all, + int help_reg, int help_oper, int help_admin, + int help_root) { - Command *c; - if (!name || !*name) { - return NULL; - } - - if ((c = (Command *)malloc(sizeof(Command))) == NULL) { - fatal("Out of memory!"); - } - c->name = sstrdup(name); - c->routine = func; - c->has_priv = has_priv; - c->helpmsg_all = help_all; - c->helpmsg_reg = help_reg; - c->helpmsg_oper = help_oper; - c->helpmsg_admin = help_admin; - c->helpmsg_root = help_root; - c->help_param1 = NULL; - c->help_param2 = NULL; - c->help_param3 = NULL; - c->help_param4 = NULL; - c->next = NULL; - c->mod_name = NULL; - c->service = NULL; - c->all_help = NULL; - c->regular_help = NULL; - c->oper_help = NULL; - c->admin_help = NULL; - c->root_help = NULL; - return c; + Command *c; + if (!name || !*name) { + return NULL; + } + + if ((c = (Command *)malloc(sizeof(Command))) == NULL) { + fatal("Out of memory!"); + } + c->name = sstrdup(name); + c->routine = func; + c->has_priv = has_priv; + c->helpmsg_all = help_all; + c->helpmsg_reg = help_reg; + c->helpmsg_oper = help_oper; + c->helpmsg_admin = help_admin; + c->helpmsg_root = help_root; + c->help_param1 = NULL; + c->help_param2 = NULL; + c->help_param3 = NULL; + c->help_param4 = NULL; + c->next = NULL; + c->mod_name = NULL; + c->service = NULL; + c->all_help = NULL; + c->regular_help = NULL; + c->oper_help = NULL; + c->admin_help = NULL; + c->root_help = NULL; + return c; } /** @@ -357,43 +357,43 @@ Command *createCommand(const char *name, int (*func) (User * u), */ int destroyCommand(Command * c) { - if (!c) { - return MOD_ERR_PARAMS; - } - if (c->core == 1) { - return MOD_ERR_UNKNOWN; - } - if (c->name) { - free(c->name); - } - c->routine = NULL; - c->has_priv = NULL; - c->helpmsg_all = -1; - c->helpmsg_reg = -1; - c->helpmsg_oper = -1; - c->helpmsg_admin = -1; - c->helpmsg_root = -1; - if (c->help_param1) { - free(c->help_param1); - } - if (c->help_param2) { - free(c->help_param2); - } - if (c->help_param3) { - free(c->help_param3); - } - if (c->help_param4) { - free(c->help_param4); - } - if (c->mod_name) { - free(c->mod_name); - } - if (c->service) { - free(c->service); - } - c->next = NULL; - free(c); - return MOD_ERR_OK; + if (!c) { + return MOD_ERR_PARAMS; + } + if (c->core == 1) { + return MOD_ERR_UNKNOWN; + } + if (c->name) { + free(c->name); + } + c->routine = NULL; + c->has_priv = NULL; + c->helpmsg_all = -1; + c->helpmsg_reg = -1; + c->helpmsg_oper = -1; + c->helpmsg_admin = -1; + c->helpmsg_root = -1; + if (c->help_param1) { + free(c->help_param1); + } + if (c->help_param2) { + free(c->help_param2); + } + if (c->help_param3) { + free(c->help_param3); + } + if (c->help_param4) { + free(c->help_param4); + } + if (c->mod_name) { + free(c->mod_name); + } + if (c->service) { + free(c->service); + } + c->next = NULL; + free(c); + return MOD_ERR_OK; } /** Add a command to a command table. Only for internal use. @@ -407,135 +407,135 @@ int destroyCommand(Command * c) */ static int internal_addCommand(CommandHash * cmdTable[], Command * c, int pos) { - /* We can assume both param's have been checked by this point.. */ - int index = 0; - CommandHash *current = NULL; - CommandHash *newHash = NULL; - CommandHash *lastHash = NULL; - Command *tail = NULL; - - if (!cmdTable || !c || (pos < 0 || pos > 2)) { - return MOD_ERR_PARAMS; - } - - if (mod_current_module_name && !c->mod_name) - return MOD_ERR_NO_MOD_NAME; - - index = CMD_HASH(c->name); - - for (current = cmdTable[index]; current; current = current->next) { - if ((c->service) && (current->c) && (current->c->service) - && (!strcmp(c->service, current->c->service) == 0)) { - continue; - } - if ((stricmp(c->name, 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)", - (void *) c->next, (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)", - (void *) tail, (void *) c); - tail->next = c; - c->next = NULL; - - return MOD_ERR_OK; - } else - return MOD_ERR_EXISTS; - } - lastHash = current; - } - - if ((newHash = (CommandHash *)malloc(sizeof(CommandHash))) == NULL) { - fatal("Out of memory"); - } - newHash->next = NULL; - newHash->name = sstrdup(c->name); - newHash->c = c; - - if (lastHash == NULL) - cmdTable[index] = newHash; - else - lastHash->next = newHash; - - return MOD_ERR_OK; + /* We can assume both param's have been checked by this point.. */ + int index = 0; + CommandHash *current = NULL; + CommandHash *newHash = NULL; + CommandHash *lastHash = NULL; + Command *tail = NULL; + + if (!cmdTable || !c || (pos < 0 || pos > 2)) { + return MOD_ERR_PARAMS; + } + + if (mod_current_module_name && !c->mod_name) + return MOD_ERR_NO_MOD_NAME; + + index = CMD_HASH(c->name); + + for (current = cmdTable[index]; current; current = current->next) { + if ((c->service) && (current->c) && (current->c->service) + && (!strcmp(c->service, current->c->service) == 0)) { + continue; + } + if ((stricmp(c->name, 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)", + (void *) c->next, (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)", + (void *) tail, (void *) c); + tail->next = c; + c->next = NULL; + + return MOD_ERR_OK; + } else + return MOD_ERR_EXISTS; + } + lastHash = current; + } + + if ((newHash = (CommandHash *)malloc(sizeof(CommandHash))) == NULL) { + fatal("Out of memory"); + } + newHash->next = NULL; + newHash->name = sstrdup(c->name); + newHash->c = c; + + if (lastHash == NULL) + cmdTable[index] = newHash; + else + lastHash->next = newHash; + + return MOD_ERR_OK; } int Module::AddCommand(CommandHash * cmdTable[], Command * c, int pos) { - int status; - - if (!cmdTable || !c) { - return MOD_ERR_PARAMS; - } - c->core = 0; - if (!c->mod_name) { - c->mod_name = sstrdup(this->name.c_str()); - } - - - if (cmdTable == HOSTSERV) { - if (s_HostServ) { - c->service = sstrdup(s_HostServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == BOTSERV) { - if (s_BotServ) { - c->service = sstrdup(s_BotServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == MEMOSERV) { - if (s_MemoServ) { - c->service = sstrdup(s_MemoServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == CHANSERV) { - if (s_ChanServ) { - c->service = sstrdup(s_ChanServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == NICKSERV) { - if (s_NickServ) { - c->service = sstrdup(s_NickServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == HELPSERV) { - if (s_HelpServ) { - c->service = sstrdup(s_HelpServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == OPERSERV) { - if (s_OperServ) { - c->service = sstrdup(s_OperServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else - c->service = sstrdup("Unknown"); - - if (debug >= 2) - displayCommandFromHash(cmdTable, c->name); - status = internal_addCommand(cmdTable, c, pos); - if (debug >= 2) - displayCommandFromHash(cmdTable, c->name); - if (status != MOD_ERR_OK) { - alog("ERROR! [%d]", status); - } - return status; + int status; + + if (!cmdTable || !c) { + return MOD_ERR_PARAMS; + } + c->core = 0; + if (!c->mod_name) { + c->mod_name = sstrdup(this->name.c_str()); + } + + + if (cmdTable == HOSTSERV) { + if (s_HostServ) { + c->service = sstrdup(s_HostServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == BOTSERV) { + if (s_BotServ) { + c->service = sstrdup(s_BotServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == MEMOSERV) { + if (s_MemoServ) { + c->service = sstrdup(s_MemoServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == CHANSERV) { + if (s_ChanServ) { + c->service = sstrdup(s_ChanServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == NICKSERV) { + if (s_NickServ) { + c->service = sstrdup(s_NickServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == HELPSERV) { + if (s_HelpServ) { + c->service = sstrdup(s_HelpServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == OPERSERV) { + if (s_OperServ) { + c->service = sstrdup(s_OperServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else + c->service = sstrdup("Unknown"); + + if (debug >= 2) + displayCommandFromHash(cmdTable, c->name); + status = internal_addCommand(cmdTable, c, pos); + if (debug >= 2) + displayCommandFromHash(cmdTable, c->name); + if (status != MOD_ERR_OK) { + alog("ERROR! [%d]", status); + } + return status; } @@ -547,65 +547,65 @@ int Module::AddCommand(CommandHash * cmdTable[], Command * c, int pos) */ static int internal_delCommand(CommandHash * cmdTable[], Command * c, const char *mod_name) { - int index = 0; - CommandHash *current = NULL; - CommandHash *lastHash = NULL; - Command *tail = NULL, *last = NULL; - - if (!c || !cmdTable) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(c->name); - for (current = cmdTable[index]; current; current = current->next) { - if (stricmp(c->name, current->name) == 0) { - if (!lastHash) { - tail = current->c; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->c = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - cmdTable[index] = current->next; - free(current->name); - return MOD_ERR_OK; - } - } else { - tail = current->c; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->c = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - lastHash->next = current->next; - free(current->name); - return MOD_ERR_OK; - } - } - } - lastHash = current; - } - return MOD_ERR_NOEXIST; + int index = 0; + CommandHash *current = NULL; + CommandHash *lastHash = NULL; + Command *tail = NULL, *last = NULL; + + if (!c || !cmdTable) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(c->name); + for (current = cmdTable[index]; current; current = current->next) { + if (stricmp(c->name, current->name) == 0) { + if (!lastHash) { + tail = current->c; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->c = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + cmdTable[index] = current->next; + free(current->name); + return MOD_ERR_OK; + } + } else { + tail = current->c; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->c = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + lastHash->next = current->next; + free(current->name); + return MOD_ERR_OK; + } + } + } + lastHash = current; + } + return MOD_ERR_NOEXIST; } /** @@ -616,29 +616,29 @@ static int internal_delCommand(CommandHash * cmdTable[], Command * c, const char */ int Module::DelCommand(CommandHash * cmdTable[], const char *dname) { - Command *c = NULL; - Command *cmd = NULL; - int status = 0; - - c = findCommand(cmdTable, dname); - if (!c) { - return MOD_ERR_NOEXIST; - } - - - for (cmd = c; cmd; cmd = cmd->next) { - if (cmd->mod_name - && cmd->mod_name == this->name) { - if (debug >= 2) { - displayCommandFromHash(cmdTable, dname); - } - status = internal_delCommand(cmdTable, cmd, this->name.c_str()); - if (debug >= 2) { - displayCommandFromHash(cmdTable, dname); - } - } - } - return status; + Command *c = NULL; + Command *cmd = NULL; + int status = 0; + + c = findCommand(cmdTable, dname); + if (!c) { + return MOD_ERR_NOEXIST; + } + + + for (cmd = c; cmd; cmd = cmd->next) { + if (cmd->mod_name + && cmd->mod_name == this->name) { + if (debug >= 2) { + displayCommandFromHash(cmdTable, dname); + } + status = internal_delCommand(cmdTable, cmd, this->name.c_str()); + if (debug >= 2) { + displayCommandFromHash(cmdTable, dname); + } + } + } + return status; } /** @@ -649,20 +649,20 @@ int Module::DelCommand(CommandHash * cmdTable[], const char *dname) */ 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; + 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; } /******************************************************************************* @@ -676,20 +676,20 @@ Command *findCommand(CommandHash * cmdTable[], const char *name) * @return a new Message object **/ Message *createMessage(const char *name, - int (*func) (const char *source, int ac, const char **av)) + int (*func) (const char *source, int ac, const char **av)) { - Message *m = NULL; - if (!name || !func) { - return NULL; - } - if ((m = (Message *)malloc(sizeof(Message))) == NULL) { - fatal("Out of memory!"); - } - m->name = sstrdup(name); - m->func = func; - m->mod_name = NULL; - m->next = NULL; - return m; + Message *m = NULL; + if (!name || !func) { + return NULL; + } + if ((m = (Message *)malloc(sizeof(Message))) == NULL) { + fatal("Out of memory!"); + } + m->name = sstrdup(name); + m->func = func; + m->mod_name = NULL; + m->next = NULL; + return m; } /** @@ -701,19 +701,19 @@ Message *createMessage(const char *name, **/ Message *findMessage(MessageHash * msgTable[], const char *name) { - int idx; - MessageHash *current = NULL; - if (!msgTable || !name) { - return NULL; - } - idx = CMD_HASH(name); - - for (current = msgTable[idx]; current; current = current->next) { + int idx; + MessageHash *current = NULL; + if (!msgTable || !name) { + return NULL; + } + idx = CMD_HASH(name); + + for (current = msgTable[idx]; current; current = current->next) { if (stricmp(name, current->name) == 0) { return current->m; } - } - return NULL; + } + return NULL; } /** @@ -726,58 +726,58 @@ Message *findMessage(MessageHash * msgTable[], const char *name) int addMessage(MessageHash * msgTable[], Message * m, int pos) { - /* We can assume both param's have been checked by this point.. */ - int index = 0; - MessageHash *current = NULL; - MessageHash *newHash = NULL; - MessageHash *lastHash = NULL; - Message *tail = NULL; - int match = 0; - - if (!msgTable || !m || (pos < 0 || pos > 2)) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(m->name); - - for (current = msgTable[index]; current; current = current->next) { - match = stricmp(m->name, current->name); - if (match == 0) { /* the msg exist's we are a addHead */ - if (pos == 1) { - m->next = current->m; - current->m = m; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) m->next, (void *) m); - return MOD_ERR_OK; - } else if (pos == 2) { - tail = current->m; - while (tail->next) - tail = tail->next; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) tail, (void *) m); - tail->next = m; - m->next = NULL; - return MOD_ERR_OK; - } else - return MOD_ERR_EXISTS; - } - lastHash = current; - } - - if ((newHash = (MessageHash *)malloc(sizeof(MessageHash))) == NULL) { - fatal("Out of memory"); - } - newHash->next = NULL; - newHash->name = sstrdup(m->name); - newHash->m = m; - - if (lastHash == NULL) - msgTable[index] = newHash; - else - lastHash->next = newHash; - return MOD_ERR_OK; + /* We can assume both param's have been checked by this point.. */ + int index = 0; + MessageHash *current = NULL; + MessageHash *newHash = NULL; + MessageHash *lastHash = NULL; + Message *tail = NULL; + int match = 0; + + if (!msgTable || !m || (pos < 0 || pos > 2)) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(m->name); + + for (current = msgTable[index]; current; current = current->next) { + match = stricmp(m->name, current->name); + if (match == 0) { /* the msg exist's we are a addHead */ + if (pos == 1) { + m->next = current->m; + current->m = m; + if (debug) + alog("debug: existing msg: (0x%p), new msg (0x%p)", + (void *) m->next, (void *) m); + return MOD_ERR_OK; + } else if (pos == 2) { + tail = current->m; + while (tail->next) + tail = tail->next; + if (debug) + alog("debug: existing msg: (0x%p), new msg (0x%p)", + (void *) tail, (void *) m); + tail->next = m; + m->next = NULL; + return MOD_ERR_OK; + } else + return MOD_ERR_EXISTS; + } + lastHash = current; + } + + if ((newHash = (MessageHash *)malloc(sizeof(MessageHash))) == NULL) { + fatal("Out of memory"); + } + newHash->next = NULL; + newHash->name = sstrdup(m->name); + newHash->m = m; + + if (lastHash == NULL) + msgTable[index] = newHash; + else + lastHash->next = newHash; + return MOD_ERR_OK; } /** @@ -788,11 +788,11 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos) **/ int addCoreMessage(MessageHash * msgTable[], Message * m) { - if (!msgTable || !m) { - return MOD_ERR_PARAMS; - } - m->core = 1; - return addMessage(msgTable, m, 0); + if (!msgTable || !m) { + return MOD_ERR_PARAMS; + } + m->core = 1; + return addMessage(msgTable, m, 0); } /** @@ -803,30 +803,30 @@ int addCoreMessage(MessageHash * msgTable[], Message * m) **/ int moduleAddMessage(Message * m, int pos) { - int status; - - if (!m) { - return MOD_ERR_PARAMS; - } - - /* ok, this appears to be a module adding a message from outside of AnopeInit, try to look up its module struct for it */ - if ((mod_current_module_name) && (!mod_current_module)) { - mod_current_module = findModule(mod_current_module_name); - } - - if (!mod_current_module) { - return MOD_ERR_UNKNOWN; - } /* shouldnt happen */ - m->core = 0; - if (!m->mod_name) { - m->mod_name = sstrdup(mod_current_module->name.c_str()); - } - - status = addMessage(IRCD, m, pos); - if (debug) { - displayMessageFromHash(m->name); - } - return status; + int status; + + if (!m) { + return MOD_ERR_PARAMS; + } + + /* ok, this appears to be a module adding a me |
