Go to the source code of this file.
Data Structures | |
| struct | ModuleInfo |
| struct | Module |
| struct | ModuleQEntry |
Defines | |
| #define | MOD_ERR_DL -2 |
| #define | MOD_ERR_MSG -1 |
| #define | MOD_ERR_OK 0 |
| #define | MOD_ERR_STOP 1 |
| #define | MOD_ERR_CRIT 2 |
| #define | MOD_ERR_FATAL 3 |
| #define | MOD_ERR_EXISTS 4 |
| #define | MOD_ERR_NOFILE 5 |
| #define | MOD_ERR_IO 6 |
| #define | MOD_ERR_API 7 |
| #define | MOD_ERR_ABI 8 |
| #define | MOD_ERR_MEMORY 9 |
| #define | MOD_ERR_UNLOAD 10 |
| #define | MOD_ERR_SYNTAX 11 |
| #define | MOD_ERR_UNSAFE 12 |
| #define | MOD_ERR_NOMOD 13 |
| #define | MOD_ERR_SQL 14 |
| #define | MOD_CONT MOD_ERR_OK |
| #define | MOD_STOP MOD_ERR_STOP |
| #define | MOD_CRIT MOD_ERR_CRIT |
| #define | MOD_FATAL MOD_ERR_FATAL |
| #define | MOD_MEMORY MOD_ERR_MEMORY |
| #define | MOD_TYPE_UNKNOWN 0 |
| #define | MOD_TYPE_PROTOCOL 1 |
| #define | MOD_TYPE_CORE 2 |
| #define | MOD_TYPE_STD 3 |
| #define | MOD_TYPE_CLIENT 4 |
| #define | MOD_TYPE_3RD 5 |
| #define | throwModErr(msg,...) |
| #define | format_filename(dest, filestr) |
| #define | ABI_MAJOR 0 |
| #define | ABI_MINOR 5 |
| #define | ABI_PATCH 4 |
| #define | ABI_VERSION ((ABI_MAJOR * 1000) + (ABI_MINOR * 100) + ABI_PATCH) |
| #define | MAKE_ABI(maj, min, patch) ((maj * 1000) + (min * 100) + patch) |
| #define | MODHEADER(name, version, author, abi, load, unload) |
| #define | RTLD_LAZY RTLD_NOW |
| #define | RTLD_GLOBAL 0 |
| #define | RTLD_LOCAL 0 |
| #define | MOD_ACT_LOAD 0 |
| #define | MOD_ACT_UNLOAD 1 |
| #define | MOD_ACT_RELOAD 2 |
| #define | MOD_LOAD_NONE -1 |
| #define | MOD_LOAD_PRE 0 |
| #define | MOD_LOAD_STD 1 |
| #define | MOD_LOAD_POST 2 |
Functions | |
| int | load_protocol () |
| int | load_modules () |
| void | init_modules () |
| void | purge_modules () |
| int | module_open (char *, int) |
| Module * | module_find (char *) |
| int | module_exists (char *) |
| void | module_free (Module *) |
| int | module_close (char *) |
| char * | find_module_dir (char *module) |
| char * | create_mod_temp (char *) |
| ModuleQEntry * | find_mod_que (char *) |
| int | addto_mod_que (char *, int, int) |
| int | run_mod_que (int) |
| int | mod_event_rehash (int, void *) |
| int | mod_event_shutdown (int, void *) |
Variables | |
| char | mod_err_msg [512] |
| int | nomodules |
| dlink_list | modules |
| dlink_list | moduleque |
| #define ABI_MAJOR 0 |
Module ABI Stuff This logic kinda looks off at first glance however we need this to make sure that module API's match, note you can manually change the ABI version on a module however do that at your own risk, as the module ABI specifies which modules the core will work properly with.
| #define ABI_VERSION ((ABI_MAJOR * 1000) + (ABI_MINOR * 100) + ABI_PATCH) |
Definition at line 102 of file module.h.
Referenced by module_open().
| #define format_filename | ( | dest, | |||
| filestr | ) |
char format_file_tmp[MAXPATH]; \ snprintf(format_file_tmp, sizeof(format_file_tmp), "%s%s", (filestr), (strstr(filestr,".so"))? "" : ".so"); \ snprintf((dest), sizeof(dest) - 1, "%s/%s",find_module_dir((format_file_tmp)), (format_file_tmp)); \ memset(format_file_tmp,0,sizeof(format_file_tmp));
This just looks ugly but i wanted to take into account for directories not having a / and having a / So with this said :) this is what i came up with - Twitch
Definition at line 84 of file module.h.
Referenced by create_mod_temp().
| #define MAKE_ABI | ( | maj, | |||
| min, | |||||
| patch | ) | ((maj * 1000) + (min * 100) + patch) |
| #define MOD_ACT_LOAD 0 |
Definition at line 154 of file module.h.
Referenced by load_modules(), and run_mod_que().
| #define MOD_ACT_RELOAD 2 |
Definition at line 156 of file module.h.
Referenced by run_mod_que().
| #define MOD_ACT_UNLOAD 1 |
Definition at line 155 of file module.h.
Referenced by run_mod_que().
| #define MOD_CONT MOD_ERR_OK |
Definition at line 55 of file module.h.
Referenced by Module_Init().
| #define MOD_ERR_API 7 |
Definition at line 43 of file module.h.
Referenced by module_open().
| #define MOD_ERR_EXISTS 4 |
Definition at line 40 of file module.h.
Referenced by module_open().
| #define MOD_ERR_IO 6 |
Definition at line 42 of file module.h.
Referenced by module_open().
| #define MOD_ERR_MEMORY 9 |
Definition at line 45 of file module.h.
Referenced by addto_mod_que(), and module_open().
| #define MOD_ERR_MSG -1 |
Definition at line 31 of file module.h.
Referenced by GetModErr().
| #define MOD_ERR_NOFILE 5 |
Definition at line 41 of file module.h.
Referenced by module_close().
| #define MOD_ERR_OK 0 |
Definition at line 34 of file module.h.
Referenced by addto_mod_que(), load_modules(), module_close(), and module_open().
| #define MOD_ERR_UNLOAD 10 |
Definition at line 46 of file module.h.
Referenced by module_close().
| #define MOD_LOAD_NONE -1 |
Definition at line 162 of file module.h.
Referenced by run_mod_que().
| #define MOD_LOAD_POST 2 |
Definition at line 165 of file module.h.
Referenced by init_modules(), and mod_event_rehash().
| #define MOD_LOAD_PRE 0 |
Definition at line 163 of file module.h.
Referenced by init_modules(), and mod_event_rehash().
| #define MOD_LOAD_STD 1 |
Definition at line 164 of file module.h.
Referenced by init_modules(), load_modules(), and mod_event_rehash().
| #define MOD_STOP MOD_ERR_STOP |
Definition at line 56 of file module.h.
Referenced by Module_Init().
| #define MOD_TYPE_CORE 2 |
Definition at line 65 of file module.h.
Referenced by load_modules().
| #define MOD_TYPE_PROTOCOL 1 |
Definition at line 64 of file module.h.
Referenced by load_protocol(), and purge_modules().
| #define MOD_TYPE_UNKNOWN 0 |
Definition at line 63 of file module.h.
Referenced by run_mod_que().
| #define MODHEADER | ( | name, | |||
| version, | |||||
| author, | |||||
| abi, | |||||
| load, | |||||
| unload | ) |
static int module_build_version() { \ return ABI_VERSION; \ } \ ModuleInfo ModInfo = { \ name, version, author, abi, \ load, unload \ } \
Module Header This struct allows the core to pull in the nessicary information and place it into the module structure.
| name | - The module name -> This is just for personal referance as the core relies on aboslute paths to find and remove modules. | |
| version | - The modules version in free form | |
| abi | - The Binary interface version, this is the version of the API used to interact with this module. | |
| load | - The function called by the core when loading the module | |
| unload | - The function used when unloading a module from the core. |
| #define throwModErr | ( | msg, | |||
| ... | ) |
snprintf(mod_err_msg, sizeof(mod_err_msg), msg, __VA_ARGS__); \ return MOD_ERR_MSG; \
Definition at line 73 of file module.h.
Referenced by module_open().
| int addto_mod_que | ( | char * | , | |
| int | , | |||
| int | ||||
| ) |
Definition at line 620 of file module.c.
References ModuleQEntry::action, dlink_add_tail(), dlink_create(), ModuleQEntry::load, MOD_ERR_MEMORY, MOD_ERR_OK, moduleque, ModuleQEntry::name, and strlcpy().
Referenced by load_modules().
| char* create_mod_temp | ( | char * | file | ) |
Create a temporary module file.
| filename | (string) Path to module file we are copying |
Definition at line 245 of file module.c.
References CfgSettings, format_filename, MAXPATH, MAXREADBUFFER, Conf::network, strlcat(), and TMP_DIR.
Referenced by module_open().
| ModuleQEntry* find_mod_que | ( | char * | file | ) |
Module Que Functions
Module Que Opporations
Definition at line 605 of file module.c.
References DLINK_FOREACH, moduleque, and ModuleQEntry::name.
| char* find_module_dir | ( | char * | module | ) |
Definition at line 446 of file module.c.
References CLIENT_MOD_DIR, CONTRIB_PATH, CPATH, module_exists(), MPATH, and PPATH.
| void init_modules | ( | ) |
Definition at line 87 of file module.c.
References AddEvent, load_modules(), load_protocol(), mod_event_rehash(), mod_event_shutdown(), MOD_LOAD_POST, MOD_LOAD_PRE, MOD_LOAD_STD, and run_mod_que().
Referenced by Run().
| int load_modules | ( | ) |
Definition at line 146 of file module.c.
References addto_mod_que(), alog(), CPATH, DLINK_FOREACH, Exit(), get_config_base(), GetModErr(), HASH, HASH_B, ConfBase::map, MOD_ACT_LOAD, MOD_ERR_OK, MOD_LOAD_STD, MOD_TYPE_CORE, MODULE_DIR, module_find(), module_open(), RUNNING, and sync_state.
Referenced by init_modules().
| int load_protocol | ( | ) |
load_protocol() - Load our given protocol if it fails toss a critical error and return
Definition at line 121 of file module.c.
References alog(), CfgSettings, get_config_entry(), GetModErr(), LOG_FATAL, MOD_TYPE_PROTOCOL, module_open(), Conf::protocol, sendto_console(), and strlcpy().
Referenced by init_modules().
| int mod_event_rehash | ( | int | , | |
| void * | ||||
| ) |
Event Hooks
Definition at line 709 of file module.c.
References MOD_LOAD_POST, MOD_LOAD_PRE, MOD_LOAD_STD, and run_mod_que().
Referenced by init_modules().
| int mod_event_shutdown | ( | int | ac, | |
| void * | args | |||
| ) |
Module Loader Event Hooks
Definition at line 703 of file module.c.
References purge_modules().
Referenced by init_modules().
| int module_close | ( | char * | ) |
Definition at line 517 of file module.c.
References alog(), Module::handle, LOG_MODULE, Module::mi, MOD_ERR_NOFILE, MOD_ERR_OK, MOD_ERR_UNLOAD, ModuleInfo::mod_unregister, module_find(), and module_free().
Referenced by run_mod_que().
| int module_exists | ( | char * | ) |
Definition at line 426 of file module.c.
Referenced by find_module_dir(), and module_free().
| Module* module_find | ( | char * | ) |
Definition at line 540 of file module.c.
References DLINK_FOREACH, modules, and Module::name.
Referenced by load_modules(), module_close(), module_open(), and run_mod_que().
| void module_free | ( | Module * | ) |
Definition at line 493 of file module.c.
References dlink_find_delete(), dlink_free(), Module::file, module_exists(), and modules.
Referenced by module_close(), module_open(), and purge_modules().
| int module_open | ( | char * | filename, | |
| int | type | |||
| ) |
module_open() - Load our module file symbols
| filename | The file we are trying to link against. | |
| type | Type of module we are loading.
|
Definition at line 333 of file module.c.
References ABI_VERSION, Module::age, create_mod_temp(), dlink_add_tail(), dlink_create(), Module::file, Module::handle, Module::mi, MOD_ERR_API, MOD_ERR_EXISTS, MOD_ERR_IO, MOD_ERR_MEMORY, MOD_ERR_OK, ModuleInfo::mod_register, module_find(), module_free(), modules, Module::name, throwModErr, and Module::type.
Referenced by load_modules(), load_protocol(), and run_mod_que().
| void purge_modules | ( | ) |
Definition at line 564 of file module.c.
References DLINK_FOREACH_SAFE, Module::handle, Module::mi, MOD_TYPE_PROTOCOL, ModuleInfo::mod_unregister, module_free(), modules, and Module::type.
Referenced by mod_event_shutdown().
| int run_mod_que | ( | int | ) |
Definition at line 643 of file module.c.
References ModuleQEntry::action, alog(), dlink_delete(), DLINK_FOREACH_SAFE, dlink_free(), GetModErr(), ModuleQEntry::load, LOG_MODULE, MOD_ACT_LOAD, MOD_ACT_RELOAD, MOD_ACT_UNLOAD, MOD_LOAD_NONE, MOD_TYPE_UNKNOWN, module_close(), module_find(), module_open(), moduleque, ModuleQEntry::name, RUNNING, and sync_state.
Referenced by init_modules(), and mod_event_rehash().
| char mod_err_msg[512] |
Definition at line 70 of file module.h.
Referenced by GetModErr().
| dlink_list moduleque |
Definition at line 252 of file module.h.
Referenced by addto_mod_que(), find_mod_que(), and run_mod_que().
| dlink_list modules |
Module Linked List's
Definition at line 251 of file module.h.
Referenced by module_find(), module_free(), module_open(), and purge_modules().
1.6.3