| 1 |
lftp 2.0 and later support loading modules (shared objects) at |
| 2 |
runtime. Use command `module' to load a module. |
| 3 |
|
| 4 |
It also supports loading certain modules (some of protocols and commands) |
| 5 |
automatically on demand. To compile modular lftp use: |
| 6 |
|
| 7 |
configure --with-modules |
| 8 |
|
| 9 |
You will need GCC and ELF platform (linux, freebsd-3.x, solaris, irix etc). |
| 10 |
|
| 11 |
|
| 12 |
Below are the technical details. |
| 13 |
|
| 14 |
Module is a shared object, after loading it with dlopen(3) lftp does |
| 15 |
dlsym("module_init") and calls this function with parameters argc, argv: |
| 16 |
|
| 17 |
extern "C" |
| 18 |
void module_init(int argc, const char * const *argv); |
| 19 |
|
| 20 |
The argv vector contains the arguments passed to `module' command after |
| 21 |
module name. In case of loading module on demand it is empty. |
| 22 |
|
| 23 |
Note: function _init of a module is called automatically by dlopen. It can |
| 24 |
execute constructors if the module is properly compiled with `gcc -shared'. |
| 25 |
|
| 26 |
To load modules on demand lftp uses protocol or command name to find |
| 27 |
module file. For protocols it looks for proto-<PROTOCOL>.so and for |
| 28 |
commands -- cmd-<COMMAND>.so. The modules register the protocols and |
| 29 |
commands they provide with functions FileAccess::Register and |
| 30 |
CmdExec::RegisterCommand. |
| 31 |
|
| 32 |
lftp searches module for any protocol specified in URL in open command, |
| 33 |
and only for certain compile time defined set of commands -- the commands |
| 34 |
that have NULL instead of function pointer in command table in commands.cc. |