Skip to main content
Version: 2.0.0 ๐Ÿšง

Module API

Module header#

Each module is described by a module header, which is created by the MODULE_HEADER_V1 macro. This includes the module's version, vendor, a brief description, and three optional entry points (constructor, post-init and destructor).

MODULE_HEADER_V1(  "ircd-yeti 1.1.0",  "DareNET Development <https://c.darenet.org/dev>",  "Provides the SETNAME command.",  module_constructor,  module_post_init,  module_destructor);

Module initialzation and cleanup#

Modules may export up to three entry points.

Constructor#

void (*constructor)(Module *mod)

This is the first function to be called. It should only assume that the ircd core is loaded, unless the shared library directly links to some other library. This function can use the MODULE_REQUEST_DEPENDENCY macro to indicate other ircd-yeti modules its depends on.

Post-initialization#

void (*post_init)(Module *mod)

This entry point can be used to perform second-pass initialization, such as for modules that require other ircd-yeti modules to be loaded.

Destructor#

void (*destructor)(ModuleIntent intent)

This function is called just before the module is unloaded, and should release any persistent resources owned by the module. The intent paremeter is used to inform the module if it's being reloaded or unloaded.

Module dependencies#

MODULE_REQUEST_DEPENDENCY(self, module_name)

This macro is used to declare that the currently loading module depends on another module, as named, allowing for stub modules that derive from "super" modules.

MODULE_REQUEST_SYMBOL(self, destination, module_name, symbol)

This macro is used to request a module dependency, and then grab a symbol from it.

Resident modules#

MODULE_MAKE_RESIDENT(module)

This macro ensures that a module will never be unloaded. Any future module_unload() calls on the module will be ignored.

Semi-resident modules#

MODULE_MARK_RELOAD_ONLY(module)

This macro ensures that a module will never be permanently unloaded, but may be reloaded. If for any reason initialization of the module fails after a reloaded, the ircd will exit.

This intended for modules that are necessary for operation of the ircd (e.g., core modules), but should allow upgrading in place.