diff --git a/packages/base/httpd/examples/mod_hello.pp b/packages/base/httpd/examples/mod_hello.pp index 789eb4bd84..b41b2f1abe 100644 --- a/packages/base/httpd/examples/mod_hello.pp +++ b/packages/base/httpd/examples/mod_hello.pp @@ -1,131 +1,484 @@ -{******************************************************************* -* Test library of the Apache Pascal Headers -*******************************************************************} -library mod_hello; - -{$i define.inc} - -uses SysUtils, httpd {$ifndef Apache1_3}, apr{$endif}; - -var - test_module: module; {$ifdef Unix} public name 'test_module'; {$endif} - -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: string; -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', [PChar('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(DOCTYPE_HTML_4_0T, r); - ap_rputs('' + LineEnding, r); - ap_rputs('' + LineEnding, r); - ap_rputs('Hello There' + LineEnding, r); - ap_rputs('' + LineEnding, r); - 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 %s
' + LineEnding, [PChar('ap_rprintf')]); - ap_rputs('' + LineEnding, r); - - { We can either return OK or DECLINED at this point. If we return - * OK, then no other modules will attempt to process this request } - Result := OK; -end; - -{******************************************************************* -* Registers the hooks -*******************************************************************} -{$ifdef apache1_3} - -procedure hw_init(s: PServer_rec; p: PPool); cdecl; -begin -end; - -var - hw_handlers: array[0..1] of handler_rec = - ( - (content_type: 'testapache-handler'; handler: @DefaultHandler), - (content_type: nil; handler: nil) - ); - -{$else} - -procedure RegisterHooks(p: Papr_pool_t); cdecl; -begin - ap_hook_handler(@DefaultHandler, nil, nil, APR_HOOK_MIDDLE); -end; - -{$endif} - -{******************************************************************* -* Library initialization code -*******************************************************************} -begin - FillChar(test_module, SizeOf(test_module), 0); - - {$ifdef apache1_3} - STANDARD_MODULE_STUFF(test_module); - - with test_module do - begin - name := MODULE_NAME; - init := @hw_init; - handlers := hw_handlers; - end; - {$else} - STANDARD20_MODULE_STUFF(test_module); - - with test_module do - begin - name := MODULE_NAME; - register_hooks := @RegisterHooks; - end; - {$endif} -end. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/base/httpd/httpd-1.3/ap_alloc.inc b/packages/base/httpd/httpd-1.3/ap_alloc.inc index 52835f414d..85db365db9 100644 --- a/packages/base/httpd/httpd-1.3/ap_alloc.inc +++ b/packages/base/httpd/httpd-1.3/ap_alloc.inc @@ -36,9 +36,9 @@ } { Need declaration of DIR on Win32 } -{$ifdef WIN32} -//#include "readdir.h" -{$endif} +{.$ifdef Windows} + {$include readdir.inc} +{.$endif} type pool = record end; diff --git a/packages/base/httpd/httpd-1.3/ap_config.inc b/packages/base/httpd/httpd-1.3/ap_config.inc index 9ba30b121a..881aa819ef 100644 --- a/packages/base/httpd/httpd-1.3/ap_config.inc +++ b/packages/base/httpd/httpd-1.3/ap_config.inc @@ -895,7 +895,7 @@ typedef int rlim_t; #include #include -{$else}{$if defined(WIN32)} +{$else}{$if defined(WINDOWS)} { All windows stuff is now in os/win32/os.h } diff --git a/packages/base/httpd/httpd-1.3/buff.inc b/packages/base/httpd/httpd-1.3/buff.inc index a5f2b673ea..29cecc52da 100644 --- a/packages/base/httpd/httpd-1.3/buff.inc +++ b/packages/base/httpd/httpd-1.3/buff.inc @@ -79,7 +79,7 @@ type { could also put pointers to the basic I/O routines here } fd: cint; { the file descriptor } fd_in: cint; { input file descriptor, if different } -{$ifdef WIN32} +{$ifdef WINDOWS} hFH: HANDLE; { Windows filehandle } {$endif} @@ -117,7 +117,7 @@ function ap_bcreate(p: PPool; flags: cint): PBUFF; procedure ap_bpushfd(fb: PBUFF; fd_in, fd_out: cint); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; -{$ifdef WIN32} +{$ifdef WINDOWS} procedure ap_bpushh(fb: PBUFF; hFH: HANDLE); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; @@ -185,7 +185,7 @@ API_EXPORT(int) ap_bfilbuf(BUFF *fb); type child_info = record -{$ifdef WIN32} +{$ifdef WINDOWS} { * These handles are used by ap_call_exec to call * create process with pipe handles. @@ -224,7 +224,7 @@ function ap_bfileno(fb: PBUFF; direction: cint): cint; procedure ap_bhalfduplex(fb: PBUFF); {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD; -{$if defined(WIN32) or defined(NETWARE) or defined(CYGWIN_WINSOCK)} +{$if defined(WINDOWS) or defined(NETWARE) or defined(CYGWIN_WINSOCK)} { ap_recvwithtimeout/ap_sendwithtimeout socket primitives for WinSock } //API_EXPORT(int) ap_sendwithtimeout(int sock, const char *buf, int len, int flags); diff --git a/packages/base/httpd/httpd-1.3/hsregex.inc b/packages/base/httpd/httpd-1.3/hsregex.inc index 4c0d742daa..4fc6bda2b6 100644 --- a/packages/base/httpd/httpd-1.3/hsregex.inc +++ b/packages/base/httpd/httpd-1.3/hsregex.inc @@ -21,7 +21,9 @@ type regoff_t = Integer; -// off_t = regoff_t; +{$ifdef windows} + off_t = regoff_t; +{$endif} Pregex_t = ^regex_t; diff --git a/packages/base/httpd/httpd-1.3/http_core.inc b/packages/base/httpd/httpd-1.3/http_core.inc index dfd64e20d3..40ab79a4af 100644 --- a/packages/base/httpd/httpd-1.3/http_core.inc +++ b/packages/base/httpd/httpd-1.3/http_core.inc @@ -143,7 +143,7 @@ API_EXPORT(const char *) ap_auth_nonce (request_rec *); API_EXPORT(int) ap_satisfies (request_rec *r); API_EXPORT(const array_header *) ap_requires (request_rec *); } -{$ifdef WIN32} +{$ifdef WINDOWS} { * CGI Script stuff for Win32... } @@ -327,7 +327,7 @@ type sec: Parray_header; r: Pregex_t; -{$ifdef WIN32} +{$ifdef WINDOWS} { Where to find interpreter to run scripts } script_interpreter_source: interpreter_source_e; {$endif} diff --git a/packages/base/httpd/httpd-1.3/http_log.inc b/packages/base/httpd/httpd-1.3/http_log.inc index b368f98319..2dcffb18b2 100644 --- a/packages/base/httpd/httpd-1.3/http_log.inc +++ b/packages/base/httpd/httpd-1.3/http_log.inc @@ -44,7 +44,7 @@ {$endif} APLOG_NOERRNO = (APLOG_LEVELMASK + 1); -{$ifdef WIN32} +{$ifdef WINDOWS} { Set to indicate that error msg should come from Win32's GetLastError(), * not errno. } APLOG_WIN32ERROR = ((APLOG_LEVELMASK + 1) * 2); diff --git a/packages/base/httpd/httpd-1.3/httpd.inc b/packages/base/httpd/httpd-1.3/httpd.inc index 5db9c5f6a4..ac96740d2f 100644 --- a/packages/base/httpd/httpd-1.3/httpd.inc +++ b/packages/base/httpd/httpd-1.3/httpd.inc @@ -106,7 +106,7 @@ const DEFAULT_GROUP = '#-1'; {$ifndef DEFAULT_ERRORLOG} -{$if defined(OS2) or defined(WIN32)} +{$if defined(OS2) or defined(WINDOWS)} DEFAULT_ERRORLOG = 'logs/error.log'; {$else} DEFAULT_ERRORLOG = 'logs/error_log'; @@ -172,7 +172,7 @@ const { The path to the shell interpreter, for parsed docs } - {$if defined(OS2) or defined(WIN32)} + {$if defined(OS2) or defined(WINDOWS)} { Set default for OS/2 and Windows file system } SHELL_PATH = 'CMD.EXE'; {$else} @@ -233,7 +233,7 @@ const * the overhead. } {$ifndef HARD_SERVER_LIMIT} -{$ifdef WIN32} +{$ifdef WINDOWS} HARD_SERVER_LIMIT = 1024; {$else}{$if defined(NETWARE)} HARD_SERVER_LIMIT = 2048; @@ -1033,7 +1033,7 @@ API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded); API_EXPORT(char *) ap_uuencode(pool *p, char *string); } -{$if defined(OS2) or defined(WIN32)} +{$if defined(OS2) or defined(WINDOWS)} //API_EXPORT(char *) ap_double_quotes(pool *p, const char *str); //API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str); {$endif} @@ -1129,7 +1129,7 @@ procedure ap_chdir_file(const file_: PChar); #define ap_os_systemcase_filename(p,f) (f)} {$else} //API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file); -{$ifdef WIN32} +{$ifdef WINDOWS} //API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile); //API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile); {$else}{$ifdef OS2} diff --git a/packages/base/httpd/httpd-1.3/readdir.inc b/packages/base/httpd/httpd-1.3/readdir.inc index 4311a5bf2f..201828f62a 100644 --- a/packages/base/httpd/httpd-1.3/readdir.inc +++ b/packages/base/httpd/httpd-1.3/readdir.inc @@ -1,73 +1,77 @@ -{ Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - } - -{ - * Structures and types used to implement opendir/readdir/closedir - * on Windows 95/NT. - } - -{$ifdef WIN32} - -{#include -#include -#include -#include - -#ifndef API_EXPORT -# define API_EXPORT(type) __declspec(dllexport) type __stdcall -#endif} - -{ struct dirent - same as Unix } -type - dirent = record - d_ino: clong; { inode (always 1 in WIN32) } - d_off: off_t; { offset to this dirent } - d_reclen: cushort; { length of d_name } - d_name: array[_MAX_FNAME+1] of Char; { filename (null terminated) } - end; - -{ typedef DIR - not the same as Unix } - DIR = record - handle: clong; { _findfirst/_findnext handle } - offset: cshort; { offset into directory } - finished: cshort; { 1 if there are not more files } -// struct _finddata_t fileinfo; { from _findfirst/_findnext } - fileinfo: Pointer; { from _findfirst/_findnext } - dir: PChar; { the dir we are reading } - dent: dirent; { the dirent to return } - end; - - PDIR = ^DIR; - -{ Function prototypes } -{API_EXPORT(DIR *) opendir(const char *); -API_EXPORT(struct dirent *) readdir(DIR *); -API_EXPORT(int) closedir(DIR *);} - - va_list = Pointer; - -{ - * Simplified declarations for other platforms - } - -{$else} - - PDIR = Pointer; - - va_list = Pointer; - -{$endif} { WIN32 } - +{ Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + } + +{ + * Structures and types used to implement opendir/readdir/closedir + * on Windows 95/NT. + } + +{$ifdef WINDOWS} + +{#include +#include +#include +#include + +#ifndef API_EXPORT +# define API_EXPORT(type) __declspec(dllexport) type __stdcall +#endif} + +{ struct dirent - same as Unix } + +const + _MAX_FNAME = 256; + +type + dirent = record + d_ino: clong; { inode (always 1 in WIN32) } + d_off: off_t; { offset to this dirent } + d_reclen: cushort; { length of d_name } + d_name: array[0.._MAX_FNAME] of Char; { filename (null terminated) } + end; + +{ typedef DIR - not the same as Unix } + DIR = record + handle: clong; { _findfirst/_findnext handle } + offset: cshort; { offset into directory } + finished: cshort; { 1 if there are not more files } +// struct _finddata_t fileinfo; { from _findfirst/_findnext } + fileinfo: Pointer; { from _findfirst/_findnext } + dir: PChar; { the dir we are reading } + dent: dirent; { the dirent to return } + end; + + PDIR = ^DIR; + +{ Function prototypes } +{API_EXPORT(DIR *) opendir(const char *); +API_EXPORT(struct dirent *) readdir(DIR *); +API_EXPORT(int) closedir(DIR *);} + + va_list = Pointer; + +{ + * Simplified declarations for other platforms + } + +{$else} + + PDIR = Pointer; + + va_list = Pointer; + +{$endif} { WINDOWS } + diff --git a/packages/base/httpd/httpd-1.3/win32_os.inc b/packages/base/httpd/httpd-1.3/win32_os.inc index a72f83737e..8371922245 100644 --- a/packages/base/httpd/httpd-1.3/win32_os.inc +++ b/packages/base/httpd/httpd-1.3/win32_os.inc @@ -14,7 +14,7 @@ * limitations under the License. } -{$ifdef WIN32} +{$ifdef WINDOWS} { * Compile the server including all the Windows NT 4.0 header files by @@ -187,5 +187,5 @@ API_EXPORT(const char *) ap_os_dso_error(void);} //#define gettid() ((tid_t)GetCurrentThreadId()) -{$endif} { WIN32 } +{$endif} { WINDOWS } diff --git a/packages/base/httpd/httpd-2.0/apr/apr_thread_proc.inc b/packages/base/httpd/httpd-2.0/apr/apr_thread_proc.inc index c6c5cfadf6..51d0d48a90 100644 --- a/packages/base/httpd/httpd-2.0/apr/apr_thread_proc.inc +++ b/packages/base/httpd/httpd-2.0/apr/apr_thread_proc.inc @@ -131,7 +131,7 @@ type } invoked: PChar; {$endif} -{$if defined(WIN32) or defined(DOXYGEN)} +{$if defined(WINDOWS) or defined(DOXYGEN)} { (Win32 only) Creator's handle granting access to the process * @remark This handle is closed and reset to NULL in every case * corresponding to a waitpid() on Unix which returns the exit status. diff --git a/packages/base/httpd/httpd-2.0/apr/apr_user.inc b/packages/base/httpd/httpd-2.0/apr/apr_user.inc index 39d496dd80..c75c5c59f7 100644 --- a/packages/base/httpd/httpd-2.0/apr/apr_user.inc +++ b/packages/base/httpd/httpd-2.0/apr/apr_user.inc @@ -32,7 +32,7 @@ * Structure for determining user ownership. } type -{$ifdef WIN32} +{$ifdef WINDOWS} apr_uid_t = PSID; {$else} apr_uid_t = uid_t; @@ -43,7 +43,7 @@ type { * Structure for determining group ownership. } -{$ifdef WIN32} +{$ifdef WINDOWS} apr_gid_t = PSID; {$else} apr_gid_t = gid_t; @@ -128,7 +128,7 @@ function apr_uid_homepath_get(dirname: PPChar; const username: PChar; * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid. * @remark This function is available only if APR_HAS_USER is defined. } -{$ifdef WIN32} +{$ifdef WINDOWS} //APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); { @deprecated @see apr_uid_compare } @@ -183,7 +183,7 @@ function apr_gid_get(groupid: Papr_gid_t; const groupname: PChar; * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid. * @remark This function is available only if APR_HAS_USER is defined. } -{$ifdef WIN32} +{$ifdef WINDOWS} //APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right); { @deprecated @see apr_gid_compare } //APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right); diff --git a/packages/base/httpd/httpd-2.2/apr/apr_file_info.inc b/packages/base/httpd/httpd-2.2/apr/apr_file_info.inc index 71df4fd59d..aa660e3b10 100644 --- a/packages/base/httpd/httpd-2.2/apr/apr_file_info.inc +++ b/packages/base/httpd/httpd-2.2/apr/apr_file_info.inc @@ -119,7 +119,7 @@ type } apr_fileperms_t = apr_int32_t; -{$if defined(WIN32) or defined(NETWARE)} +{$if defined(WINDOWS) or defined(NETWARE)} { * Structure for determining the inode of the file. } diff --git a/packages/base/httpd/httpd-2.2/apr/apr_thread_proc.inc b/packages/base/httpd/httpd-2.2/apr/apr_thread_proc.inc index af4c9cedb5..eb5ae019d0 100644 --- a/packages/base/httpd/httpd-2.2/apr/apr_thread_proc.inc +++ b/packages/base/httpd/httpd-2.2/apr/apr_thread_proc.inc @@ -131,7 +131,7 @@ type } invoked: PChar; {$endif} -{$if defined(WIN32) or defined(DOXYGEN)} +{$if defined(WINDOWS) or defined(DOXYGEN)} { (Win32 only) Creator's handle granting access to the process * @remark This handle is closed and reset to NULL in every case * corresponding to a waitpid() on Unix which returns the exit status. diff --git a/packages/base/httpd/httpd-2.2/apr/apr_user.inc b/packages/base/httpd/httpd-2.2/apr/apr_user.inc index 45e14931e4..90383fad37 100644 --- a/packages/base/httpd/httpd-2.2/apr/apr_user.inc +++ b/packages/base/httpd/httpd-2.2/apr/apr_user.inc @@ -32,7 +32,7 @@ * Structure for determining user ownership. } type -{$ifdef WIN32} +{$ifdef WINDOWS} apr_uid_t = PSID; {$else} apr_uid_t = uid_t; @@ -43,7 +43,7 @@ type { * Structure for determining group ownership. } -{$ifdef WIN32} +{$ifdef WINDOWS} apr_gid_t = PSID; {$else} apr_gid_t = gid_t; @@ -112,7 +112,7 @@ function apr_uid_homepath_get(dirname: PPChar; const username: PChar; * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid. * @remark This function is available only if APR_HAS_USER is defined. } -{$ifdef WIN32} +{$ifdef WINDOWS} //APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); {$else} @@ -151,7 +151,7 @@ function apr_gid_get(groupid: Papr_gid_t; const groupname: PChar; * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid. * @remark This function is available only if APR_HAS_USER is defined. } -{$ifdef WIN32} +{$ifdef WINDOWS} //APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right); {$else} //#define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)