{******************************************************************* * Test library of the Apache Pascal Headers *******************************************************************} library mod_hello; {******************************************************************* * The mode must be objfpc on this unit because the unix code uses * some extensions introduced on Free Pascal *******************************************************************} {$ifdef fpc} {$mode objfpc}{$H+} {$endif} {$IFDEF WIN32} {$DEFINE WINDOWS} {$ENDIF} {$define Apache2_2} uses SysUtils, httpd {$ifndef Apache1_3}, apr{$endif}; var test_module: module; public name 'hello_module'; default_module_ptr: Pmodule; const MODULE_NAME = 'mod_hello.so'; {******************************************************************* * Free Pascal only supports exporting variables on Windows *******************************************************************} {$ifdef WINDOWS} exports test_module name 'test_module'; {$endif} {******************************************************************* * Handles apache requests *******************************************************************} function DefaultHandler(r: Prequest_rec): Integer; cdecl; var RequestedHandler: ; begin RequestedHandler := r^.handler; { We decline to handle a request if hello-handler is not the value of r->handler } if not SameText(RequestedHandler, 'testapache-handler') then begin Result := DECLINED; Exit; end; { The following line just prints a message to the errorlog } ap_log_error(MODULE_NAME, 54, APLOG_NOERRNO or APLOG_NOTICE, {$ifndef Apache1_3}0,{$endif} r^.server, 'mod_hello: %s', [PAnsiChar('Before content is output')]); { We set the content type before doing anything else } {$ifdef Apache1_3} r^.content_type := 'text/html'; // ap_send_http_header(r); {$else} ap_set_content_type(r, 'text/html'); {$endif} { If the request is for a header only, and not a request for the whole content, then return OK now. We don't have to do anything else. } if (r^.header_only <> 0) then begin Result := OK; Exit; end; { Now we just print the contents of the document using the ap_rputs and ap_rprintf functions. More information about the use of these can be found in http_protocol.inc } ap_rputs('' + LineEnding, r); ap_rputs('
' + LineEnding, r); ap_rputs('