FPC and Apache Modules
About
How the bindings work
A basic apache module created with Free Pascal will have a code similar to this:
library mod_hello; {$l hello_module.o} uses httpd; var hello_module: module; {$ifdef Unix}cvar; external; {$endif} default_module_ptr: Pmodule; {$ifdef Win32} exports hello_module name 'hello_module'; {$endif} begin default_module_ptr := @hello_module; FillChar(default_module_ptr^, SizeOf(default_module_ptr^), 0); with default_module_ptr^ do begin version := MODULE_MAGIC_NUMBER_MAJOR; minor_version := MODULE_MAGIC_NUMBER_MINOR; module_index := -1; name := 'mod_hello.so'; magic := MODULE_MAGIC_COOKIE; end; end.
Apache uses a non-standard way to exchange information between the module and the library. Normally libraries export functions, but Apache instead expects a library that exports a variable. The variable is a structure with the module information. This variable needs to be filled with information as soon as the module is loaded.
Now, on Windows we can easely export a variable with Free Pascal. Just put it on the exports section. On Linux, Free Pascal doesn´t yet support exporting variables, so we need a alternative. To work around this we can create a assembler file that will export the variable and then link it into our code.
The file will look like this:
[SECTION .data] global hello_module hello_module dd 0
And the command line to compile this assembler code is: "nasm -f elf hello_module.asm"
How the bindings were created
Screenshot
Authors
License
Download
Status: Under development
Installation
Hello World Module
CVS
Not yet available.
Bug Reporting
Tests are necessary to verify if all functions and structures are declared properly.
You can post Bug Reports here:
Change Log
Help
Please send help requests to the Free Pascal mailling list.