Chapter 10. Programming modules

Table of Contents
10.1. Kernel-level modules
10.1.1. Internals
10.1.2. Prerequisites
10.1.3. Compilation
10.1.4. License considerations
10.2. External modules
10.3. Variables
10.3.1. Config variables
10.3.2. User variables
10.3.3. Group variables

10.1. Kernel-level modules

This section describes how to create a new module in C.

10.1.1. Internals

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

10.1.2. Prerequisites

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.

10.1.3. Compilation

If you are using auto* tools, just configure and make.

10.1.4. License considerations

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.