Easyplugins Small plugins which can be called in scripts |
If you want to know how to call easyplugins please have a look at: $system.call() This part of the documentation handles only the way how to write an easyplugin. An easyplugin is simply a dll/so. You can create one like you normally make such so/dll files. The important thing is that these so/dll-files export some of the following functions. Exported functions by easyplugin (C/C++-Examples): _free function (needed) This function is important! Since KVIrc can not free directly the memory of the dll, the plugins need the _free function so that the memory can be freed by the plugin to prevent memory-leaks. |
int _free(void * p) { // Always free the memory here! free(p); return 0; } |
_load function (optional) After the plugin has be loaded, KVIrc will call the _load-function. Here you can prepare your plugin stuff. |
int _load() { return 0; } |
_unload function ((optional) This function will be called before the plugins is unloaded. In this function you can clean up memory or other things. After this call there is no guarantee that the plugin will be kept in memory. |
int _unload() { return 0; } |
_canunload function (optional) The _canunload-function will be called by KVIrc to check if it may unload the plugin. If return value is true KVIrc will unload the plugin, false means he will try unloading it at the next check. Important: KVIrc will ignore this if unload of plugins will be forced! So you have to be sure that the _unload function of your plugins cleans up! |
int _canunload() { return 0; } |
user function This is the general structure of a user function call. The important thing here is the handling of return values. To return a value to KVIrc you have to allocate memory and write the pointer to it into pBuffer. Have a look at the example for more details. |
int about(int argc, char * argv[], char ** pBuffer) { *pBuffer = (char*)malloc(1024); sprintf((char*)*pBuffer, "Hello World"); return 1; } |