Many Small improvements. mod_example now works with Apache 2.2

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@23 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2006-09-30 19:13:21 +00:00
parent ea7458a135
commit 325ce5ea2a
11 changed files with 227 additions and 101 deletions

View File

@ -170,8 +170,13 @@ type
hook_t = function (param1: Prequest_rec): cint; cdecl;
{$ifdef ULTRIX_BRAIN_DEATH}
child_init_t = procedure ();
child_exit_t = procedure ();
{$else}
child_init_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl;
child_exit_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl;
{$endif}
module_struct = record
version: cint; { API version, *not* module version;
@ -246,13 +251,10 @@ type
* parameters passed here are the same as those passed to the global
* init method above.
}
{$ifdef ULTRIX_BRAIN_DEATH}
void ( *child_init) ();
void ( *child_exit) ();
{$else}
child_init: child_init_t;
child_exit: child_exit_t;
{$endif}
post_read_request: hook_t;
end;

View File

@ -123,11 +123,13 @@ API_EXPORT(const array_header *) ap_requires (request_rec *); }
{
* CGI Script stuff for Win32...
}
typedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32,
eFileTypeSCRIPT, eCommandShell16, eCommandShell32 } file_type_e;
typedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY,
INTERPRETER_SOURCE_SHEBANG } interpreter_source_e;
API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char **);
type
file_type_e = ( eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32,
eFileTypeSCRIPT, eCommandShell16, eCommandShell32 );
interpreter_source_e = ( INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY,
INTERPRETER_SOURCE_SHEBANG );
//API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char **);
{$endif}
{.$ifdef CORE_PRIVATE}
@ -285,7 +287,7 @@ type
{$ifdef WIN32}
{ Where to find interpreter to run scripts }
interpreter_source_e script_interpreter_source;
script_interpreter_source: interpreter_source_e;
{$endif}
{$ifdef CHARSET_EBCDIC}

View File

@ -67,20 +67,23 @@
procedure ap_log_error(
const file_: PChar; line, level: Integer;
const s: Pserver_rec; const fmt: PChar; others: array of const);
cdecl; external LibHTTPD name 'ap_log_error';
cdecl; external LibHTTPD;
// __attribute__((format(printf,5,6)));
procedure ap_log_perror(
procedure ap_log_rerror(
const file_: PChar; line, level: Integer;
const s: Prequest_rec; const fmt: PChar; others: array of const);
cdecl; external LibHTTPD name 'ap_log_perror';
cdecl; external LibHTTPD;
// __attribute__((format(printf,5,6)));
//API_EXPORT(void) ap_error_log2stderr (server_rec *);
procedure ap_error_log2stderr(s: Pserver_rec);
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
procedure ap_log_pid(p: PPool; fname: PChar);
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
//API_EXPORT(void) ap_log_pid (pool *p, char *fname);
{ These are for legacy code, new code should use ap_log_error,
* or ap_log_rerror.
}

View File

@ -37,7 +37,8 @@
{ Send the Status-Line and header fields for HTTP response }
//API_EXPORT(void) ap_send_http_header(request_rec *l);
procedure ap_send_http_header(l: Prequest_rec);
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
{ Send the response to special method requests }
@ -96,19 +97,28 @@ API_EXPORT(size_t) ap_send_mmap(void *mm, request_rec *r, size_t offset,
* definitions of the macros would get a whole lot hairier.
}
//API_EXPORT(int) ap_rputc(int c, request_rec *r);
function ap_rputc(c: cint; r: Prequest_rec): cint;
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
function ap_rputs(const str: PChar; r: Prequest_rec): cint;
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
external LibHTTPD name 'ap_rputs';
// external LibHTTPD name LibNamePrefix + 'ap_rputs' + LibSuff8;
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
{API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...);
API_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
API_EXPORT_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
__attribute__((format(printf,2,3)));
API_EXPORT(int) ap_rflush(request_rec *r);}
function ap_rwrite(const buf: Pointer; nbyte: cint; r: Prequest_rec): cint;
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
function ap_rvputs(r: Prequest_rec; others: array of const): cint;
cdecl; external LibHTTPD;
function ap_vrprintf(r: Prequest_rec; const fmt: PChar; vlist: va_list): cint;
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
function ap_rprintf(r: Prequest_rec; const fmt: PChar; others: array of const): cint;
cdecl; external LibHTTPD;
{ __attribute__((format(printf,2,3)));}
function ap_rflush(r: Prequest_rec): cint;
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
{
* Index used in custom_responses array for a specific error code

View File

@ -39,6 +39,8 @@ unit httpd;
{$PACKRECORDS C}
{$endif}
{$define Apache1_3}
interface
uses
@ -55,15 +57,22 @@ const
{$endif}
{$IFDEF WINDOWS}
LibHTTPD = 'libhttpd.dll';
LibHTTPD = 'ApacheCore.dll';
{$ELSE}
LibHTTPD = '';
{$ENDIF}
{$define Apache1_3}
{ Declarations moved here to be on top of all declarations }
{ Various types}
type
uid_t = Integer;
gid_t = Integer;
time_t = LongInt;
size_t = Integer;
pid_t = Integer;
Ppid_t = ^pid_t;
{ configuration vector structure }
type
ap_conf_vector_t = record end;
@ -140,18 +149,6 @@ begin
mod_.magic := MODULE_MAGIC_COOKIE;
end;
//procedure STANDARD20_MODULE_STUFF(var mod_: module);
//begin
// mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
// mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
// mod_.module_index := -1;
// mod_.name: PChar;
// mod_.dynamic_load_handle := nil;
// mod_.next := nil;
// mod_.magic := MODULE_MAGIC_COOKIE;
// mod_.rewrite_args := nil;
//end;
{ Use this only in MPMs }
//procedure MPM20_MODULE_STUFF(var mod_: module);
//begin

View File

@ -147,8 +147,7 @@ procedure ap_log_error(
const file_: PChar; line, level: Integer;
status: apr_status_t; const s: Pserver_rec;
const fmt: PChar; others: array of const);
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
external LibHTTPD name 'ap_log_perror';
cdecl; external LibHTTPD name 'ap_log_error';
// __attribute__((format(printf,6,7)));
@ -177,7 +176,7 @@ procedure ap_log_perror(
status: apr_status_t; p: Papr_pool_t;
const fmt: PChar; others: array of const);
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
external LibHTTPD name 'ap_log_error';
external LibHTTPD name 'ap_log_perror';
{ __attribute__((format(printf,6,7)));}

View File

@ -9,6 +9,25 @@
<TargetFileExt Value=".exe"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<UseVersionInfo Value="False"/>
<AutoIncrementBuild Value="False"/>
<CurrentVersionNr Value="0"/>
<CurrentMajorRevNr Value="0"/>
<CurrentMinorRevNr Value="0"/>
<CurrentBuildNr Value="0"/>
<ProjectVersion Value="1,0,0,0"/>
<Language Value="0409"/>
<CharSet Value="04E4"/>
<Comments Value=""/>
<CompanyName Value=""/>
<FileDescription Value=""/>
<InternalName Value=""/>
<LegalCopyright Value=""/>
<LegalTrademarks Value=""/>
<OriginalFilename Value=""/>
<ProductName Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)\publishedproject\"/>
@ -22,15 +41,15 @@
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="74">
<Units Count="84">
<Unit0>
<Filename Value="mod_example.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mod_example"/>
<CursorPos X="12" Y="1291"/>
<TopLine Value="1277"/>
<CursorPos X="1" Y="1327"/>
<TopLine Value="1323"/>
<EditorIndex Value="0"/>
<UsageCount Value="63"/>
<UsageCount Value="66"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -263,7 +282,7 @@
<CursorPos X="24" Y="78"/>
<TopLine Value="69"/>
<EditorIndex Value="1"/>
<UsageCount Value="39"/>
<UsageCount Value="42"/>
<Loaded Value="True"/>
</Unit35>
<Unit36>
@ -273,7 +292,7 @@
<CursorPos X="3" Y="142"/>
<TopLine Value="124"/>
<EditorIndex Value="2"/>
<UsageCount Value="39"/>
<UsageCount Value="42"/>
<Loaded Value="True"/>
</Unit36>
<Unit37>
@ -283,7 +302,7 @@
<CursorPos X="56" Y="33"/>
<TopLine Value="29"/>
<EditorIndex Value="3"/>
<UsageCount Value="39"/>
<UsageCount Value="42"/>
<Loaded Value="True"/>
</Unit37>
<Unit38>
@ -294,8 +313,8 @@
</Unit38>
<Unit39>
<Filename Value="httpd_2_0\http_protocol.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<CursorPos X="18" Y="442"/>
<TopLine Value="437"/>
<UsageCount Value="12"/>
</Unit39>
<Unit40>
@ -304,7 +323,7 @@
<CursorPos X="1" Y="19"/>
<TopLine Value="24"/>
<EditorIndex Value="4"/>
<UsageCount Value="18"/>
<UsageCount Value="19"/>
<Loaded Value="True"/>
</Unit40>
<Unit41>
@ -315,9 +334,9 @@
</Unit41>
<Unit42>
<Filename Value="httpd_2_0\util_filter.inc"/>
<CursorPos X="23" Y="27"/>
<TopLine Value="21"/>
<UsageCount Value="9"/>
<CursorPos X="15" Y="498"/>
<TopLine Value="493"/>
<UsageCount Value="10"/>
</Unit42>
<Unit43>
<Filename Value="httpd_2_0\util_script.inc"/>
@ -375,9 +394,9 @@
</Unit51>
<Unit52>
<Filename Value="httpd_2_0\http_log.inc"/>
<CursorPos X="25" Y="227"/>
<TopLine Value="223"/>
<UsageCount Value="12"/>
<CursorPos X="11" Y="141"/>
<TopLine Value="136"/>
<UsageCount Value="13"/>
</Unit52>
<Unit53>
<Filename Value="httpd_2_0\http_main.inc"/>
@ -508,28 +527,105 @@
<TopLine Value="136"/>
<UsageCount Value="9"/>
</Unit73>
<Unit74>
<Filename Value="httpd_2_2\apr\apr.pas"/>
<UnitName Value="apr"/>
<CursorPos X="4" Y="106"/>
<TopLine Value="103"/>
<UsageCount Value="10"/>
</Unit74>
<Unit75>
<Filename Value="httpd_2_2\http_log.inc"/>
<CursorPos X="15" Y="146"/>
<TopLine Value="137"/>
<UsageCount Value="10"/>
</Unit75>
<Unit76>
<Filename Value="..\..\..\lazarus16\fpcsrc\rtl\objpas\sysutils\syspchh.inc"/>
<CursorPos X="13" Y="29"/>
<TopLine Value="20"/>
<UsageCount Value="10"/>
</Unit76>
<Unit77>
<Filename Value="httpd_1_3\ap.inc"/>
<CursorPos X="15" Y="110"/>
<TopLine Value="106"/>
<UsageCount Value="10"/>
</Unit77>
<Unit78>
<Filename Value="httpd_1_3\ap_alloc.inc"/>
<CursorPos X="23" Y="108"/>
<TopLine Value="103"/>
<UsageCount Value="10"/>
</Unit78>
<Unit79>
<Filename Value="httpd_1_3\ap_config.inc"/>
<CursorPos X="28" Y="51"/>
<TopLine Value="44"/>
<UsageCount Value="10"/>
</Unit79>
<Unit80>
<Filename Value="httpd_1_3\buff.inc"/>
<CursorPos X="31" Y="128"/>
<TopLine Value="121"/>
<UsageCount Value="10"/>
</Unit80>
<Unit81>
<Filename Value="httpd_1_3\http_log.inc"/>
<CursorPos X="36" Y="84"/>
<TopLine Value="79"/>
<UsageCount Value="10"/>
</Unit81>
<Unit82>
<Filename Value="httpd_1_3\httpd.inc"/>
<CursorPos X="36" Y="1125"/>
<TopLine Value="1117"/>
<UsageCount Value="10"/>
</Unit82>
<Unit83>
<Filename Value="httpd_1_3\http_protocol.inc"/>
<CursorPos X="44" Y="106"/>
<TopLine Value="103"/>
<UsageCount Value="10"/>
</Unit83>
</Units>
<JumpHistory Count="5" HistoryIndex="4">
<JumpHistory Count="9" HistoryIndex="8">
<Position1>
<Filename Value="httpd_2_0\apr\apr.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="mod_example.lpr"/>
<Caret Line="1298" Column="2" TopLine="1289"/>
</Position1>
<Position2>
<Filename Value="httpd_2_0\apr\apr.pas"/>
<Caret Line="108" Column="6" TopLine="96"/>
<Filename Value="mod_example.lpr"/>
<Caret Line="1235" Column="1" TopLine="1217"/>
</Position2>
<Position3>
<Filename Value="httpd_2_0\apr\apr.pas"/>
<Caret Line="132" Column="17" TopLine="117"/>
<Filename Value="mod_example.lpr"/>
<Caret Line="172" Column="1" TopLine="166"/>
</Position3>
<Position4>
<Filename Value="httpd_2_0\apr\apr.pas"/>
<Caret Line="133" Column="15" TopLine="117"/>
<Filename Value="mod_example.lpr"/>
<Caret Line="590" Column="11" TopLine="568"/>
</Position4>
<Position5>
<Filename Value="httpd_2_0\apr\apr.pas"/>
<Caret Line="132" Column="16" TopLine="118"/>
<Filename Value="mod_example.lpr"/>
<Caret Line="504" Column="3" TopLine="499"/>
</Position5>
<Position6>
<Filename Value="mod_example.lpr"/>
<Caret Line="505" Column="10" TopLine="490"/>
</Position6>
<Position7>
<Filename Value="mod_example.lpr"/>
<Caret Line="583" Column="1" TopLine="565"/>
</Position7>
<Position8>
<Filename Value="mod_example.lpr"/>
<Caret Line="249" Column="1" TopLine="248"/>
</Position8>
<Position9>
<Filename Value="mod_example.lpr"/>
<Caret Line="485" Column="1" TopLine="461"/>
</Position9>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
@ -539,8 +635,8 @@
<Filename Value="mod_example.so"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value="httpd_2_0\;httpd_2_0\apr\;httpd_2_0\apriconv\;httpd_2_0\aprutil\"/>
<SrcPath Value="httpd_2_0\;httpd_2_0\apr\;httpd_2_0\apriconv\;httpd_2_0\aprutil\"/>
<OtherUnitFiles Value="httpd_2_0\;httpd_2_0\apr\;httpd_2_0\aprutil\"/>
<SrcPath Value="httpd_2_0\;httpd_2_0\apr\;httpd_2_0\aprutil\"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>

View File

@ -437,7 +437,7 @@ begin
* on the size (and readability) of the error_log is considerable.
}
if ((EXAMPLE_LOG_EACH = 0) and (s <> nil)) then
ap_log_error(MODULE_NAME, 438, APLOG_DEBUG, 0, s, 'mod_example: %s', [note]);
ap_log_error(MODULE_NAME, 438, APLOG_DEBUG, 0, s, 'mod_example: ', [note]);
end;
{--------------------------------------------------------------------------}
@ -504,6 +504,8 @@ var
dcfg: Px_cfg;
tempstr: PChar;
begin
tempstr := 'Undefined';
if not SameText(r^.handler, 'example-handler') then
begin
Result := DECLINED;
@ -550,8 +552,7 @@ begin
ap_rputs(' <H1><SAMP>mod_example</SAMP> Module Content-Handler Output' + LineEnding, r);
ap_rputs(' </H1>' + LineEnding, r);
ap_rputs(' <P>' + LineEnding, r);
ap_rprintf(r, ' Apache HTTP Server version: "%s"' + LineEnding,
[ap_get_server_version()]);
ap_rprintf(r, ' Apache HTTP Server version: "%s"' + LineEnding, [ap_get_server_version()]);
ap_rputs(' <BR>' + LineEnding, r);
ap_rprintf(r, ' Server built: "%s"' + LineEnding, [ap_get_server_built()]);
ap_rputs(' </P>' + LineEnding, r);;
@ -1343,7 +1344,7 @@ begin
magic := MODULE_MAGIC_COOKIE;
create_dir_config := @x_create_dir_config; { per-directory config creator }
merge_dir_config := @x_merge_dir_config; { dir config merger }
create_server_config := @x_create_server_config; { server config creator }
create_server_config := @x_create_server_config;{ server config creator }
merge_server_config := @x_merge_server_config; { server config merger }
cmds := @x_cmds; { command table }
register_hooks := @x_register_hooks; { set up other request processing hooks }

View File

@ -15,9 +15,9 @@ library mod_hello;
{$DEFINE WINDOWS}
{$ENDIF}
{$define Apache2_0}
{$define Apache2_2} // Change when recompiling to a different Apache version
uses SysUtils, httpd, {$ifndef Apache1_3} apr{$endif};
uses SysUtils, httpd {$ifndef Apache1_3}, apr{$endif};
var
test_module: module; {$ifdef Unix} public name 'test_module'; {$endif}
@ -74,6 +74,7 @@ begin
{ 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(DOCTYPE_HTML_4_0T, r);
ap_rputs('<HTML>' + LineEnding, r);
ap_rputs('<HEAD>' + LineEnding, r);
ap_rputs('<TITLE>Hello There</TITLE>' + LineEnding, r);
@ -81,7 +82,7 @@ begin
ap_rputs('<BODY BGCOLOR="#FFFFFF">' + LineEnding ,r);
ap_rputs('<H1>Hello world</H1>' + LineEnding, r);
ap_rputs('This is the first Apache Module working with the new binding from Free Pascal' + LineEnding, r);
ap_rprintf(r, '<br>A sample line generated by ap_rprintf<br>' + LineEnding, []);
ap_rprintf(r, '<br>A sample line generated by %s <br>' + LineEnding, [PChar('ap_rprintf')]);
ap_rputs('</BODY></HTML>' + LineEnding, r);
{ We can either return OK or DECLINED at this point. If we return
@ -99,9 +100,10 @@ begin
end;
var
hw_handlers: array[0..0] of handler_rec =
hw_handlers: array[0..1] of handler_rec =
(
(content_type: 'hw_app'; handler: @DefaultHandler)
(content_type: 'testapache-handler'; handler: @DefaultHandler),
(content_type: nil; handler: nil)
);
{$else}

View File

@ -27,7 +27,6 @@ library testmodule;
{$ENDIF}
uses
minimain in 'minimain.pas';
var

View File

@ -8,8 +8,27 @@
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
<Title Value="testmodule"/>
<ActiveEditorIndexAtStart Value="0"/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<VersionInfo>
<UseVersionInfo Value="False"/>
<AutoIncrementBuild Value="False"/>
<CurrentVersionNr Value="0"/>
<CurrentMajorRevNr Value="0"/>
<CurrentMinorRevNr Value="0"/>
<CurrentBuildNr Value="0"/>
<ProjectVersion Value="1,0,0,0"/>
<Language Value="0409"/>
<CharSet Value="04E4"/>
<Comments Value=""/>
<CompanyName Value=""/>
<FileDescription Value=""/>
<InternalName Value=""/>
<LegalCopyright Value=""/>
<LegalTrademarks Value=""/>
<OriginalFilename Value=""/>
<ProductName Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
@ -27,8 +46,8 @@
<Filename Value="testmodule.dpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="testmodule"/>
<CursorPos X="2" Y="30"/>
<TopLine Value="20"/>
<CursorPos X="1" Y="30"/>
<TopLine Value="29"/>
<EditorIndex Value="0"/>
<UsageCount Value="110"/>
<Loaded Value="True"/>
@ -164,7 +183,7 @@
<IsPartOfProject Value="True"/>
<UnitName Value="minimain"/>
<CursorPos X="23" Y="8"/>
<TopLine Value="1"/>
<TopLine Value="36"/>
<EditorIndex Value="1"/>
<UsageCount Value="73"/>
<Loaded Value="True"/>
@ -711,15 +730,11 @@
<UsageCount Value="10"/>
</Unit101>
</Units>
<JumpHistory Count="2" HistoryIndex="1">
<JumpHistory Count="1" HistoryIndex="0">
<Position1>
<Filename Value="minimain.pas"/>
<Caret Line="28" Column="11" TopLine="19"/>
<Filename Value="testmodule.dpr"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="minimain.pas"/>
<Caret Line="8" Column="23" TopLine="1"/>
</Position2>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>