This section describes how to create a new module in C. These modules have complete access to internals, and can completely modify the behaviour of the server. However, before trying to create such modules, please ensure you understand the "License considerations" at the end of this section, and that you agree with it.
You must add the following headers to your source code:
#include <wzd_structs.h> #include <wzd_mod.h>
To easily identify your module, and provide a versioning system, you should add the following just after the includes (in the global section):
MODULE_NAME(your_module_name); MODULE_VERSION(version)Please note that the module name is NOT quoted (e.g: my_module), and that the version is a simple integer (e.g: 103).
The module must provide a function with the following prototype:
int WZD_MODULE_INIT(void);This function will be called when module is loaded, so you can initialize all data needed by module here. If you want to register hooks, you must do it at this point, using function
hook_add(config, mask, hook)You can also register a new protocol using:
hook_add_protocol("sig:",sig_length,function);One optional function can be declared to clean up all data used by module, and will be called when module is unloaded, with the following prototype:
void WZD_MODULE_CLOSE(void)
NOTE: as always as possible, you should declare all your functions and global variables as 'static', to avoid possible clashes with names of other modules
You need the following to compile and use new modules for wzdftpd:
A working version of wzdftpd compiled from sources or the wzdftpd-dev package for your distribution.
wzdftpd provides a helper application to retrieve information about installed libraries
To find the compilation flags, use the following command:
wzd-config --cflags libwzd-core
To find the link flags, use the following command:
wzd-config --libs libwzd-core
If you are using auto* tools, you can include the provided file wzd.m4, which defines the macro
AM_PATH_WZD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])This macro defines the variables WZD_CFLAGS, WZD_LIBS and WZD_VERSION. Just configure and make.
wzdftpd is distributed under GPL. That clearly means that you MUST distribute your module under GPL, if you intend to distribute it (license covers distribution, and it means you must give source to people, or give them access, when you distribute them your module).
This is an intentional behaviour, keep in mind that using wzdftpd you can benefit from a big amount of functions, and that it has taken much time to do it. The only contribution that is asked in exchange is to make your work accessible, so others can benefit it.
If these terms of license are not suitable for you, then you cannot use kernel-level modules. However, you can use external modules without any license restriction.