diff options
author | Robin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-07 23:56:09 +0000 |
---|---|---|
committer | Robin Burchell w00t@inspircd.org <Robin Burchell w00t@inspircd.org@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-11-07 23:56:09 +0000 |
commit | ba73678ade779865edbc4187e23514c46d33a7ab (patch) | |
tree | 922a364be641f3ef722972259d2b23d46f37be3b /src/modules.c | |
parent | 95774907e1d239dc9261f19b58a6044598ae078c (diff) |
Reorganise some more of this, now makes more logical sense, and almost compiles (just some constification left).
NOTE: moduleCopyFile() is now local to modules.c (static), but that should not be an issue for any well-written client code.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1573 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules.c')
-rw-r--r-- | src/modules.c | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/src/modules.c b/src/modules.c index d308e29a1..d7b3aa9dd 100644 --- a/src/modules.c +++ b/src/modules.c @@ -444,7 +444,7 @@ int encryptionModuleLoaded() * @param output the destination to copy the module to * @return MOD_ERR_OK on success */ -int moduleCopyFile(char *name, char *output) +static int moduleCopyFile(const char *name, char *output) { int ch; FILE *source, *target; @@ -513,7 +513,7 @@ int loadModule(const std::string &modname, User * u) if (modname.empty()) return MOD_ERR_PARAMS; - if ((m = findModule(modname.c_str())) != NULL) + if (findModule(modname.c_str()) != NULL) return MOD_ERR_EXISTS; alog("trying to load [%s]", modname.c_str()); @@ -563,51 +563,53 @@ int loadModule(const std::string &modname, User * u) return MOD_ERR_NOLOAD; } - if (func) + if (!func) { - mod_current_module_name = m->name.c_str(); - - /* Create module. - * XXX: we need to handle ModuleException throws here. - */ - std::string nick; - if (u) - nick = u->nick; - else - nick = ""; - - Module *m = func(nick); - mod_current_module = m; - mod_current_user = u; - m->filename = sstrdup(buf); - m->handle = handle; + throw CoreException("Couldn't find constructor, yet moderror wasn't set?"); + } + + mod_current_module_name = modname.c_str(); + + /* Create module. + * XXX: we need to handle ModuleException throws here. + */ + std::string nick; + if (u) + nick = u->nick; + else + nick = ""; + + Module *m = func(nick); + mod_current_module = m; + mod_current_user = u; + m->filename = sstrdup(buf); + m->handle = handle; /* - if (ret == MOD_STOP) { - alog("%s requested unload...", m->name); - unloadModule(m, NULL); - mod_current_module_name = NULL; - return MOD_ERR_NOLOAD; - } + if (ret == MOD_STOP) { + alog("%s requested unload...", m->name); + unloadModule(m, NULL); + mod_current_module_name = NULL; + return MOD_ERR_NOLOAD; + } */ - if (m->type == PROTOCOL && protocolModuleLoaded()) - { - alog("You cannot load two protocol modules"); - ret = MOD_STOP; - } - else if (m->type == ENCRYPTION && encryptionModuleLoaded()) - { - alog("You cannot load two encryption modules"); - ret = MOD_STOP; - } - - mod_current_module_name = NULL; + if (m->type == PROTOCOL && protocolModuleLoaded()) + { + alog("You cannot load two protocol modules"); + ret = MOD_STOP; + } + else if (m->type == ENCRYPTION && encryptionModuleLoaded()) + { + alog("You cannot load two encryption modules"); + ret = MOD_STOP; } + mod_current_module_name = NULL; + if (u) { - ircdproto->SendGlobops(s_OperServ, "%s loaded module %s", u->nick, m->name.c_str()); - notice_lang(s_OperServ, u, OPER_MODULE_LOADED, m->name.c_str()); + ircdproto->SendGlobops(s_OperServ, "%s loaded module %s", u->nick, modname.c_str()); + notice_lang(s_OperServ, u, OPER_MODULE_LOADED, modname.c_str()); } addModule(m); return MOD_ERR_OK; |