diff --git a/httpd/httpd_1_3/http_config.inc b/httpd/httpd_1_3/http_config.inc index 9a191b7f8..260fb4152 100644 --- a/httpd/httpd_1_3/http_config.inc +++ b/httpd/httpd_1_3/http_config.inc @@ -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} + + child_init: child_init_t; + child_exit: child_exit_t; + post_read_request: hook_t; end; diff --git a/httpd/httpd_1_3/http_core.inc b/httpd/httpd_1_3/http_core.inc index f682cedc8..8a84fdcda 100644 --- a/httpd/httpd_1_3/http_core.inc +++ b/httpd/httpd_1_3/http_core.inc @@ -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} diff --git a/httpd/httpd_1_3/http_log.inc b/httpd/httpd_1_3/http_log.inc index 279bad57d..f28c6597d 100644 --- a/httpd/httpd_1_3/http_log.inc +++ b/httpd/httpd_1_3/http_log.inc @@ -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. } diff --git a/httpd/httpd_1_3/http_protocol.inc b/httpd/httpd_1_3/http_protocol.inc index e60758aa4..b754a4fa0 100644 --- a/httpd/httpd_1_3/http_protocol.inc +++ b/httpd/httpd_1_3/http_protocol.inc @@ -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 diff --git a/httpd/httpd_1_3/httpd.pas b/httpd/httpd_1_3/httpd.pas index 6aceb29a5..65fdfcd22 100644 --- a/httpd/httpd_1_3/httpd.pas +++ b/httpd/httpd_1_3/httpd.pas @@ -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 diff --git a/httpd/httpd_2_2/http_log.inc b/httpd/httpd_2_2/http_log.inc index cd5ad905c..2428d61f7 100644 --- a/httpd/httpd_2_2/http_log.inc +++ b/httpd/httpd_2_2/http_log.inc @@ -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)));} diff --git a/httpd/mod_example.lpi b/httpd/mod_example.lpi index b4c4a1675..d7814caad 100644 --- a/httpd/mod_example.lpi +++ b/httpd/mod_example.lpi @@ -9,6 +9,25 @@ + + + + + + + + + + + + + + + + + + + @@ -22,15 +41,15 @@ - + - - + + - + @@ -263,7 +282,7 @@ - + @@ -273,7 +292,7 @@ - + @@ -283,7 +302,7 @@ - + @@ -294,8 +313,8 @@ - - + + @@ -304,7 +323,7 @@ - + @@ -315,9 +334,9 @@ - - - + + + @@ -375,9 +394,9 @@ - - - + + + @@ -508,28 +527,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + @@ -539,8 +635,8 @@ - - + + diff --git a/httpd/mod_example.lpr b/httpd/mod_example.lpr index f7e3f9cb6..479334dcb 100644 --- a/httpd/mod_example.lpr +++ b/httpd/mod_example.lpr @@ -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('

mod_example Module Content-Handler Output' + LineEnding, r); ap_rputs('

' + LineEnding, r); ap_rputs('

' + 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('
' + LineEnding, r); ap_rprintf(r, ' Server built: "%s"' + LineEnding, [ap_get_server_built()]); ap_rputs('

' + LineEnding, r);; @@ -1341,12 +1342,12 @@ begin begin name := MODULE_NAME; 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_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 } 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 } + cmds := @x_cmds; { command table } + register_hooks := @x_register_hooks; { set up other request processing hooks } end; end. diff --git a/httpd/mod_hello.lpr b/httpd/mod_hello.lpr index 371c48f8a..0e7eb1366 100644 --- a/httpd/mod_hello.lpr +++ b/httpd/mod_hello.lpr @@ -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('' + LineEnding, r); ap_rputs('' + LineEnding, r); ap_rputs('Hello There' + LineEnding, r); @@ -81,7 +82,7 @@ begin ap_rputs('' + LineEnding ,r); ap_rputs('

Hello world

' + LineEnding, r); ap_rputs('This is the first Apache Module working with the new binding from Free Pascal' + LineEnding, r); - ap_rprintf(r, '
A sample line generated by ap_rprintf
' + LineEnding, []); + ap_rprintf(r, '
A sample line generated by %s
' + LineEnding, [PChar('ap_rprintf')]); ap_rputs('' + 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} diff --git a/httpd/testmodule.dpr b/httpd/testmodule.dpr index 8ca894d6f..4d3e67819 100644 --- a/httpd/testmodule.dpr +++ b/httpd/testmodule.dpr @@ -27,7 +27,6 @@ library testmodule; {$ENDIF} uses - minimain in 'minimain.pas'; var diff --git a/httpd/testmodule.lpi b/httpd/testmodule.lpi index ff995cdd2..be3ecd8d4 100644 --- a/httpd/testmodule.lpi +++ b/httpd/testmodule.lpi @@ -8,8 +8,27 @@ - <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>