Tip of the day: What is shown in WHOIS can be configured in detail via set::whois-details.

Dev:Callback API

From UnrealIRCd documentation wiki
Jump to navigation Jump to search

Callbacks are (pratically) only used for cloaking (if you want to create your own cloaking algorithm). If you are reading this page then most likely you are looking for Hooks instead.

Registering a Callback

Callbacks provide a way for a module to register a function that is called for a specific callback type. Unlike Hooks (which can be chained — multiple modules can hook the same event), only one callback can be registered per callback type. If you register a callback for a type that already has one, it will fail.

Currently callbacks are mainly used for cloaking. If you are looking for a way to be notified about events, you most likely want Hooks instead.

The following registration functions are available, depending on the return type:

  • CallbackAdd() — for callbacks returning int
  • CallbackAddVoid() — for callbacks returning void
  • CallbackAddPVoid() — for callbacks returning void *
  • CallbackAddString() — for callbacks returning char *
  • CallbackAddConstString() — for callbacks returning const char *

Syntax (example for int-returning callback):

Callback *CallbackAdd(Module *module, int cbtype, int (*func)());
  • module — The module registering the callback (use modinfo->handle)
  • cbtype — The callback type (CALLBACKTYPE_*)
  • func — The callback function

Register your callback from MOD_INIT.

CallbackDel

CallbackDel(Callback *cb)

Removes a callback. Modules do not need to call this — it is done automatically on module unload.