Next: Manual configuration, Previous: Installing, Up: Top [Contents]
LibNetBlock comes with a development package. You can use the following public functions and constants:
void libnetblock_enable(void)
- enables LibNetBlock for the program
that calls this function
const char * libnetblock_version(void)
- returns the runtime version
of the library the program is using
LNB_VERSION
is the compile-time preprocessor string constant containing
the version of the library the program is compiled against
LNB_BANNING_ENV
is the name of the environment variable that can point
to an additional banning file
LNB_BANNING_USERFILE
is the name of the additional banning file that
can be located in the users’ home directories.
If you’re using C or C++ (or any language that can parse C header files), you can use the header file directly. Simply type:
#include <libnetblock.h>
and compile the program with the library, e.g.:
‘gcc -o your_prog your_prog.c -lnetblock -ldl’
If needed, LibNetBlock should be first in link order.
If you want to use LibNetBlock with some other programming language, you can generate bindings to LibNetBlock for that language. You can use SWIG for this purpose. The header file is compatible with SWIG, so you can simply run:
‘swig -<your_lang> [<other options>] /path/to/libnetblock.h’
e.g.
‘swig -php -o lnb_wrap_php.c /usr/include/libnetblock.h’
You can then compile the generated wrapper files:
‘gcc -fpic -c lnb_wrap_*.c’
and link them into one or separate shared libraries:
‘gcc -shared lnb_wrap_*.o -lnetblock -o lnb_wrapper.so’
After this, you can link your program with the wrapper library and LibNetBlock:
‘gcc -o your_prog your_prog.c lnb_wrapper.so -lnetblock -ldl’
or use the library in other languages, as shown in the SWIG examples.
LibNetBlock will not contain the interfaces compiled-in, because there may be incompatibilities between languages or even between different versions of the same language, causing compile-time or other conflicts and unnecessary dependencies.
By using SWIG yourself, you can be sure that such problems will not occur.
Next: Manual configuration, Previous: Installing, Up: Top [Contents]