diff options
| author | Adam <Adam@anope.org> | 2011-04-28 22:44:34 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2011-05-16 04:09:32 -0400 |
| commit | 583954d3a1db658281a9afb7b7dd6773726c8c11 (patch) | |
| tree | 6a00865d5738c6d0bc42efb35f3f468c5876eb3e /include | |
| parent | 8fb1604f649bec6f356770daf5df6bb8ab811bbf (diff) | |
Use module type to determine what type each module is instead of its location in the configuration file.
Diffstat (limited to 'include')
| -rw-r--r-- | include/anope.h | 13 | ||||
| -rw-r--r-- | include/config.h | 10 | ||||
| -rw-r--r-- | include/extern.h | 4 | ||||
| -rw-r--r-- | include/modules.h | 49 | ||||
| -rw-r--r-- | include/servers.h | 4 |
5 files changed, 36 insertions, 44 deletions
diff --git a/include/anope.h b/include/anope.h index fb201db1e..b23b68481 100644 --- a/include/anope.h +++ b/include/anope.h @@ -316,9 +316,9 @@ namespace Anope */ extern CoreExport bool Match(const Anope::string &str, const Anope::string &mask, bool case_sensitive = false); - /** Returns a list of pointers to message handlers - * @param The message name as sent by the IRCd - * @return a vector with pointers to the messagehandlers (you can bind more than one handler to a message) + /** Find a message in the message table + * @param name The name of the message were looking for + * @return NULL if we cant find it, or a pointer to the Message if we can */ extern CoreExport std::vector<Message *> FindMessage(const string &name); @@ -438,6 +438,7 @@ class CoreExport Base virtual ~Base(); void AddReference(dynamic_reference_base *r); void DelReference(dynamic_reference_base *r); + static void operator delete(void *ptr); }; class dynamic_reference_base : public Base @@ -469,7 +470,7 @@ class dynamic_reference : public dynamic_reference_base this->invalid = false; this->ref = NULL; } - else if (ref) + else if (this->operator bool()) ref->DelReference(this); } @@ -504,10 +505,10 @@ class dynamic_reference : public dynamic_reference_base this->invalid = false; this->ref = NULL; } - else if (this->ref) + else if (this->operator bool()) this->ref->DelReference(this); this->ref = newref; - if (this->ref) + if (this->operator bool()) this->ref->AddReference(this); } }; diff --git a/include/config.h b/include/config.h index 8d2455c78..8a564e8ec 100644 --- a/include/config.h +++ b/include/config.h @@ -342,9 +342,6 @@ class CoreExport ServerConfig /** Below here is a list of variables which contain the config files values */ - /* IRCd module in use */ - Anope::string IRCDModule; - /* Host to connect to **/ Anope::string LocalHost; /* List of uplink servers to try and connect to */ @@ -667,13 +664,6 @@ class CoreExport ServerConfig /* List of modules to autoload */ std::list<Anope::string> ModulesAutoLoad; - /* Encryption modules */ - std::list<Anope::string> EncModuleList; - /* Database modules */ - std::list<Anope::string> DBModuleList; - - /* The socket engine in use */ - Anope::string SocketEngine; /* User keys to use for generating random hashes for pass codes etc */ unsigned long UserKey1; diff --git a/include/extern.h b/include/extern.h index 555292712..0b319ceaf 100644 --- a/include/extern.h +++ b/include/extern.h @@ -74,8 +74,8 @@ E ConfigurationFile services_conf; E ServerConfig *Config; /**** encrypt.c ****/ -E int enc_encrypt(const Anope::string &src, Anope::string &dest); -E int enc_decrypt(const Anope::string &src, Anope::string &dest); +E void enc_encrypt(const Anope::string &src, Anope::string &dest); +E bool enc_decrypt(const Anope::string &src, Anope::string &dest); /**** hostserv.c ****/ diff --git a/include/modules.h b/include/modules.h index c3f533609..d24348b48 100644 --- a/include/modules.h +++ b/include/modules.h @@ -127,9 +127,6 @@ else \ class Message; -extern CoreExport Module *FindModule(const Anope::string &name); -int protocol_module_init(); - enum ModuleReturn { MOD_ERR_OK, @@ -137,15 +134,9 @@ enum ModuleReturn MOD_ERR_PARAMS, MOD_ERR_EXISTS, MOD_ERR_NOEXIST, - MOD_ERR_NOUSER, MOD_ERR_NOLOAD, - MOD_ERR_NOUNLOAD, - MOD_ERR_SYNTAX, - MOD_ERR_NODELETE, MOD_ERR_UNKNOWN, MOD_ERR_FILE_IO, - MOD_ERR_NOSERVICE, - MOD_ERR_NO_MOD_NAME, MOD_ERR_EXCEPTION, MOD_ERR_VERSION }; @@ -154,7 +145,7 @@ enum ModuleReturn */ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }; /* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */ -enum MODType { MT_BEGIN, THIRD, QATESTED, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, MT_END }; +enum ModType { MT_BEGIN, THIRD, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, MT_END }; typedef std::multimap<Anope::string, Message *> message_map; extern CoreExport message_map MessageMap; @@ -210,6 +201,10 @@ class CoreExport Module : public Extensible */ Anope::string name; + /** What type this module is + */ + ModType type; + /** The temporary path/filename */ Anope::string filename; @@ -234,24 +229,17 @@ class CoreExport Module : public Extensible */ Anope::string author; - /** What type this module is - */ - MODType type; - /** Creates and initialises a new module. + * @param modname The module name * @param loadernick The nickname of the user loading the module. + * @param type The module type */ - Module(const Anope::string &modname, const Anope::string &loadernick); + Module(const Anope::string &modname, const Anope::string &loadernick, ModType type = THIRD); /** Destroys a module, freeing resources it has allocated. */ virtual ~Module(); - /** Sets a given type (CORE,PROTOCOL,3RD etc) on a module. - * @param type The type to set the module as. - */ - void SetType(MODType type); - /** Toggles the permanent flag on a module. If a module is permanent, * then it may not be unloaded. * @@ -1039,10 +1027,10 @@ class CoreExport Module : public Extensible */ virtual void OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg) { } - /** Called when any object is destroyed + /** Called when any object is deleted * @param b The object */ - virtual void OnObjectDestroy(Base *b) { } + virtual void OnDeleteObject(Base *b) { } }; /** Implementation-specific flags which may be set in ModuleManager::Attach() @@ -1096,7 +1084,7 @@ enum Implementation I_OnServerQuit, I_OnTopicUpdated, I_OnEncrypt, I_OnDecrypt, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, - I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnObjectDestroy, + I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnDeleteObject, I_END }; @@ -1139,6 +1127,18 @@ class CoreExport ModuleManager */ static ModuleReturn UnloadModule(Module *m, User * u); + /** Find a module + * @param name The module name + * @return The module + */ + static Module *FindModule(const Anope::string &name); + + /** Find the first module of a certain type + * @param type The module type + * @return The module + */ + static Module *FindFirstOf(ModType type); + /** Checks whether this version of Anope is at least major.minor.patch.build * Throws a ModuleException if not * @param major The major version @@ -1231,8 +1231,9 @@ class CoreExport ModuleManager private: /** Call the module_delete function to safely delete the module * @param m the module to delete + * @return MOD_ERR_OK on success, anything else on fail */ - static void DeleteModule(Module *m); + static ModuleReturn DeleteModule(Module *m); }; /** Class used for callbacks within modules diff --git a/include/servers.h b/include/servers.h index 9e3907668..f2a8ce1b5 100644 --- a/include/servers.h +++ b/include/servers.h @@ -6,8 +6,8 @@ extern CoreExport Server *Me; extern CoreExport void do_server(const Anope::string &source, const Anope::string &servername, unsigned int hops, const Anope::string &descript, const Anope::string &numeric); -extern CoreExport const char *ts6_uid_retrieve(); -extern CoreExport const char *ts6_sid_retrieve(); +extern CoreExport const Anope::string ts6_uid_retrieve(); +extern CoreExport const Anope::string ts6_sid_retrieve(); /* Types of capab */ |
