* Patch from Dennis (Bug ID 25534) to add some APR functions to the interface

git-svn-id: trunk@26573 -
This commit is contained in:
michael 2014-01-24 10:40:22 +00:00
parent e164a16171
commit 7a3cd62e3a
7 changed files with 283 additions and 35 deletions

View File

@ -59,6 +59,7 @@ begin
AddInclude('http_config.inc');
AddInclude('http_core.inc');
AddInclude('util_filter.inc');
AddInclude('util_script.inc');
AddInclude('http_log.inc');
AddInclude('http_protocol.inc');
AddInclude('aprutil/apr_buckets.inc');

View File

@ -138,5 +138,4 @@ type
implementation
end.

View File

@ -53,6 +53,7 @@
type
apr_table_t = record end;
Papr_table_t = ^apr_table_t;
PPapr_table_t = ^Papr_table_T;
//** @see apr_array_header_t */
//typedef struct apr_array_header_t apr_array_header_t;
@ -458,7 +459,7 @@ function apr_table_overlay(t: Papr_table_t;
//typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key,
// const char *value);
type
apr_table_do_callback_fn_t = function (rec: Pointer; const key, value: PChar): Integer;
apr_table_do_callback_fn_t = function (rec: Pointer; const key, value: PChar): Integer; cdecl;
Papr_table_do_callback_fn_t = ^apr_table_do_callback_fn_t;
{**
@ -487,6 +488,12 @@ type
//#endif
// ;
// This has to be a GNU C-Declaration
function apr_table_do(comp: apr_table_do_callback_fn_t; rec: Pointer;
t: Papr_table_t): Integer; cdecl; varargs;
external LibAPR Name 'apr_table_do';
{**
* Iterate over a table running the provided function once for every
* element in the table. The @param vp varargs parameter must be a
@ -509,7 +516,7 @@ type
//APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp,
// void *rec, const apr_table_t *t, va_list vp);
function apr_table_vdo(comp: Papr_table_do_callback_fn_t;
rec: Pointer; const t: Papr_table_t; vp: va_list): Integer;
rec: Pointer; t: Papr_table_t; vp: va_list): Integer;
{$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
external LibAPR name LibNamePrefix + 'apr_table_vdo' + LibSuff16;

View File

@ -49,6 +49,10 @@
const
//** default bucket buffer size - 8KB minus room for memory allocator headers */
APR_BUCKET_BUFF_SIZE = 8000;
//** This bucket type represents actual data to send to the client. */
APR_BUCKET_DATA = 0;
//** This bucket type represents metadata. */
APR_BUCKET_METADATA = 1;
//** Determines how a bucket or brigade should be read */
type
@ -132,16 +136,8 @@ Papr_bucket_alloc_t = ^apr_bucket_alloc_t;
//typedef struct apr_bucket_type_t apr_bucket_type_t;
Papr_bucket_type_t = ^apr_bucket_type_t;
{from below}
is_metadata = (
//** This bucket type represents actual data to send to the client. */
APR_BUCKET_DATA = 0,
//** This bucket type represents metadata. */
APR_BUCKET_METADATA = 1
);
// void ( *destroy)(void *data);
destroy_t = procedure(data: Pointer);
destroy_t = procedure(data: Pointer); cdecl;
// apr_status_t ( *read)(apr_bucket *b, const char **str, apr_size_t *len,
// apr_read_type_e block);
@ -181,7 +177,7 @@ is_metadata = (
* that are the "content" of the brigade and "metadata" describes
* that data but is not a proper part of it.
*}
{is_metadata is moved up}
is_metadata : integer;
// enum {
// /** This bucket type represents actual data to send to the client. */
// APR_BUCKET_DATA = 0,
@ -253,7 +249,7 @@ is_metadata = (
{from below}
// void (*free)(void *e);
free_t = procedure(e: Pointer);
free_t = procedure(e: Pointer); cdecl;
link_t = record
next: Papr_bucket;
@ -341,7 +337,7 @@ is_metadata = (
* Function called when a brigade should be flushed
*}
//typedef apr_status_t (*apr_brigade_flush)(apr_bucket_brigade *bb, void *ctx);
apr_brigade_flush = function(bb: Papr_bucket_brigade; ctx: Pointer): apr_status_t;
apr_brigade_flush = function(bb: Papr_bucket_brigade; ctx: Pointer): apr_status_t; cdecl;
(* fpc -> big part ignored here
{*
@ -392,14 +388,12 @@ apr_brigade_flush = function(bb: Papr_bucket_brigade; ctx: Pointer): apr_status_
* @return The magic pointer value
*/
#define APR_BRIGADE_SENTINEL(b) APR_RING_SENTINEL(&(b)->list, apr_bucket, link)
/**
* Determine if the bucket brigade is empty
* @param b The brigade to check
* @return true or false
*/
#define APR_BRIGADE_EMPTY(b) APR_RING_EMPTY(&(b)->list, apr_bucket, link)
/**
* Return the first bucket in a brigade
* @param b The brigade to query
@ -412,7 +406,6 @@ apr_brigade_flush = function(bb: Papr_bucket_brigade; ctx: Pointer): apr_status_
* @return The last bucket in the brigade
*/
#define APR_BRIGADE_LAST(b) APR_RING_LAST(&(b)->list)
/**
* Insert a list of buckets at the front of a brigade
* @param b The brigade to add to
@ -489,13 +482,11 @@ apr_brigade_flush = function(bb: Papr_bucket_brigade; ctx: Pointer): apr_status_
* @return The previous bucket
*/
#define APR_BUCKET_PREV(e) APR_RING_PREV((e), link)
/**
* Remove a bucket from its bucket brigade
* @param e The bucket to remove
*/
#define APR_BUCKET_REMOVE(e) APR_RING_REMOVE((e), link)
/**
* Initialize a new bucket's prev/next pointers
* @param e The bucket to initialize
@ -509,7 +500,6 @@ apr_brigade_flush = function(bb: Papr_bucket_brigade; ctx: Pointer): apr_status_
* @return true or false
*/
#define APR_BUCKET_IS_METADATA(e) ((e)->type->is_metadata)
/**
* Determine if a bucket is a FLUSH bucket
* @param e The bucket to inspect
@ -607,7 +597,7 @@ Papr_bucket_heap = ^apr_bucket_heap;
{from below}
// void (*free_func)(void *data);
free_func_t = procedure (data: Pointer);
free_func_t = procedure (data: Pointer); cdecl;
{**
* A bucket referring to data allocated off the heap.
@ -819,8 +809,13 @@ APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b,
*/
APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
int read_all,
apr_off_t *length);
apr_off_t *length);*)
function apr_brigade_length(bb: Papr_bucket_brigade; read_all: Integer;
length: Papr_off_t): apr_status_t; {$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
external LibAPRUtil name LibNamePrefix + 'apr_brigade_length' + LibSuff12;
(*
/**
* Take a bucket brigade and store the data in a flat char*
* @param bb The bucket brigade to create the char* from
@ -830,8 +825,13 @@ APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
*/
APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb,
char *c,
apr_size_t *len);
apr_size_t *len);*)
function apr_brigade_flatten(bb: Papr_bucket_brigade; c: Pchar;
len: Papr_size_t): apr_status_t;{$IFDEF WINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF}
external LibAPRUtil name LibNamePrefix + 'apr_brigade_flatten' + LibSuff12;
(*
/**
* Creates a pool-allocated string representing a flat bucket brigade
* @param bb The bucket brigade to create the char array from

View File

@ -119,6 +119,14 @@ type
//#if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
tnoargsfunc = function(parms: Pcmd_parms; mconfig: pointer): Pchar; cdecl;
trawargsfunc = function(parms: Pcmd_parms; mconfig: pointer; args: Pchar): Pchar; cdecl;
ttakeargvfunc = function(parms: Pcmd_parms; mconfig: pointer; argc: longint; argv: PPchar): Pchar; cdecl;
ttake1func = function(parms: Pcmd_parms; mconfig: pointer; w: Pchar): Pchar; cdecl;
ttake2func = function(parms: Pcmd_parms; mconfig: pointer; w, w2: Pchar): Pchar; cdecl;
ttake3func = function(parms: Pcmd_parms; mconfig: pointer; w, w2, w3: Pchar): Pchar; cdecl;
tflagfunc = function(parms: Pcmd_parms; mconfig: pointer; on_: longint): Pchar; cdecl;
{**
* All the types of functions that can be used in directives
* @internal
@ -126,25 +134,25 @@ type
cmd_func = record
case longint of
{** function to call for a no-args *}
0 : ( no_args : function (parms:Pcmd_parms; mconfig:pointer):Pchar;cdecl; );
0 : ( no_args : tnoargsfunc);
{** function to call for a raw-args *}
1 : ( raw_args : function (parms:Pcmd_parms; mconfig:pointer; args:Pchar):Pchar;cdecl; );
1 : ( raw_args : trawargsfunc);
{** function to call for a argv/argc *}
2 : ( take_argv : function (parms:Pcmd_parms; mconfig:pointer; argc:longint; argv:PPchar):Pchar;cdecl; );
2 : ( take_argv : ttakeargvfunc);
{** function to call for a take1 *}
3 : ( take1 : function (parms:Pcmd_parms; mconfig:pointer; w:Pchar):Pchar;cdecl; );
3 : ( take1 : ttake1func);
{** function to call for a take2 *}
4 : ( take2 : function (parms:Pcmd_parms; mconfig:pointer; w:Pchar; w2:Pchar):Pchar;cdecl; );
4 : ( take2 : ttake2func);
{** function to call for a take3 *}
5 : ( take3 : function (parms:Pcmd_parms; mconfig:pointer; w:Pchar; w2:Pchar; w3:Pchar):Pchar;cdecl; );
5 : ( take3 : ttake3func);
{** function to call for a flag *}
6 : ( flag : function (parms:Pcmd_parms; mconfig:pointer; on_:longint):Pchar;cdecl; );
6 : ( flag : tflagfunc);
end;
Pcmd_func = ^cmd_func;
(*

View File

@ -43,6 +43,7 @@
* @
}
unit httpd24;
{$ifdef fpc}
{$mode delphi}{$H+}
{$endif}
@ -50,6 +51,8 @@ unit httpd24;
{$PACKRECORDS C}
{$endif}
{$PACKENUM 4}
{$IFDEF Apache1_3}
{$WARNING Apache1_3 is defined somewhere, but the HTTPD unit included is for Apache2_4}
{$ENDIF}
@ -158,11 +161,101 @@ type
//{$include http_connection.inc}
//{$include http_vhost.inc}
//{$include util_script.inc}
{$include util_script.inc}
//{$include util_time.inc}
//{$include util_md5.inc}
//{$include ap_mpm.inc}
// APRUtil External Variables //
var
{/* All of the bucket types implemented by the core */
/**
* The flush bucket type. This signifies that all data should be flushed to
* the next filter. The flush bucket should be sent with the other buckets.
*/}
apr_bucket_type_flush: apr_bucket_type_t external LibAPRUtil;
{/**
* The EOS bucket type. This signifies that there will be no more data, ever.
* All filters MUST send all data to the next filter when they receive a
* bucket of this type
*/}
apr_bucket_type_eos: apr_bucket_type_t external LibAPRUtil;
{/**
* The FILE bucket type. This bucket represents a file on disk
*/}
apr_bucket_type_file: apr_bucket_type_t external LibAPRUtil;
{/**
* The HEAP bucket type. This bucket represents a data allocated from the
* heap.
*/}
apr_bucket_type_heap: apr_bucket_type_t external LibAPRUtil;
{$IFDEF APR_HAS_MMAP}
{/**
* The MMAP bucket type. This bucket represents an MMAP'ed file
*/}
apr_bucket_type_mmap: apr_bucket_type_t external LibAPRUtil;
{$ENDIF}
{/**
* The POOL bucket type. This bucket represents a data that was allocated
* from a pool. IF this bucket is still available when the pool is cleared,
* the data is copied on to the heap.
*/}
apr_bucket_type_pool: apr_bucket_type_t external LibAPRUtil;
{/**
* The PIPE bucket type. This bucket represents a pipe to another program.
*/}
apr_bucket_type_pipe: apr_bucket_type_t external LibAPRUtil;
{/**
* The IMMORTAL bucket type. This bucket represents a segment of data that
* the creator is willing to take responsibility for. The core will do
* nothing with the data in an immortal bucket
*/}
apr_bucket_type_immortal: apr_bucket_type_t external LibAPRUtil;
{/**
* The TRANSIENT bucket type. This bucket represents a data allocated off
* the stack. When the setaside function is called, this data is copied on
* to the heap
*/}
apr_bucket_type_transient: apr_bucket_type_t external LibAPRUtil;
{/**
* The SOCKET bucket type. This bucket represents a socket to another machine
*/}
apr_bucket_type_socket: apr_bucket_type_t external LibAPRUtil;
//********************************************************************
{ from apr_buckets.inc }
function APR_BRIGADE_SENTINEL(b: Papr_bucket_brigade): Papr_bucket;
function APR_BRIGADE_FIRST(b: Papr_bucket_brigade): Papr_bucket;
function APR_BRIGADE_LAST(b: Papr_bucket_brigade): Papr_bucket;
function APR_BUCKET_NEXT(e: Papr_bucket): Papr_bucket;
function APR_BUCKET_PREV(e: Papr_bucket): Papr_bucket;
procedure APR_BUCKET_REMOVE(e: Papr_bucket);
function APR_BUCKET_IS_METADATA(e: Papr_bucket): boolean;
function APR_BUCKET_IS_FLUSH(e: Papr_bucket): boolean;
function APR_BUCKET_IS_EOS(e: Papr_bucket): boolean;
function APR_BUCKET_IS_FILE(e: Papr_bucket): boolean;
function APR_BUCKET_IS_PIPE(e: Papr_bucket): boolean;
function APR_BUCKET_IS_SOCKET(e: Papr_bucket): boolean;
function APR_BUCKET_IS_HEAP(e: Papr_bucket): boolean;
function APR_BUCKET_IS_TRANSIENT(e: Papr_bucket): boolean;
function APR_BUCKET_IS_IMMORTAL(e: Papr_bucket): boolean;
{$IFDEF APR_HAS_MMAP}
function APR_BUCKET_IS_MMAP(e: Papr_bucket): boolean;
{$ENDIF}
function APR_BUCKET_IS_POOL(e: Papr_bucket): boolean;
function apr_bucket_read(e: Papr_bucket; const str: PPChar; len: Papr_size_t;
block: apr_read_type_e): apr_status_t;
function AP_INIT_TAKE1(directive: Pchar; const take1func : ttake1func;
mconfig: Pointer; where: Integer; help: Pchar): command_rec;
function AP_INIT_TAKE2(directive: Pchar; const take2func: ttake2func;
mconfig: Pointer; where: Integer; help: Pchar): command_rec;
function AP_INIT_TAKE3(directive: Pchar; const take3func: ttake3func;
mconfig: Pointer; where: Integer; help: Pchar): command_rec;
implementation
{ Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
function HTTP_VERSION(major, minor: Integer): Integer;
@ -244,6 +337,146 @@ implementation
ap_escape_html:=ap_escape_html2(p,s,0);
end;
//********************************************************************
{ from apr_buckets.inc }
function APR_BRIGADE_FIRST(b: Papr_bucket_brigade): Papr_bucket; inline;
begin
APR_BRIGADE_FIRST := b^.list.next;
end;
function APR_BRIGADE_LAST(b: Papr_bucket_brigade): Papr_bucket; inline;
begin
APR_BRIGADE_LAST := b^.list.prev;
end;
function APR_BRIGADE_SENTINEL(b: Papr_bucket_brigade): Papr_bucket; inline;
var b_: apr_bucket; // This should technically be <type> and link shouldn't be hard-coded..
begin
APR_BRIGADE_SENTINEL := Papr_bucket(pointer(@b^.list.next) - (pointer(@b_.Link) - pointer(@b_) ) );
end;
function APR_BUCKET_IS_METADATA(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_METADATA := e^.type_^.is_metadata = APR_BUCKET_METADATA;
end;
function APR_BUCKET_IS_FLUSH(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_FLUSH := e^.type_ = @apr_bucket_type_flush;
end;
function APR_BUCKET_IS_EOS(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_EOS := e^.type_ = @apr_bucket_type_eos;
end;
function APR_BUCKET_IS_FILE(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_FILE := e^.type_ = @apr_bucket_type_file;
end;
function APR_BUCKET_IS_PIPE(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_PIPE := e^.type_ = @apr_bucket_type_pipe;
end;
function APR_BUCKET_IS_SOCKET(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_SOCKET := e^.type_ = @apr_bucket_type_socket;
end;
function APR_BUCKET_IS_HEAP(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_HEAP := e^.type_ = @apr_bucket_type_heap;
end;
function APR_BUCKET_IS_TRANSIENT(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_TRANSIENT := e^.type_ = @apr_bucket_type_transient;
end;
function APR_BUCKET_IS_IMMORTAL(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_IMMORTAL := e^.type_ = @apr_bucket_type_immortal;
end;
{$IFDEF APR_HAS_MMAP}
function APR_BUCKET_IS_MMAP(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_MMAP := e^.type_ = @apr_bucket_type_mmap;
end;
{$ENDIF}
function APR_BUCKET_IS_POOL(e: Papr_bucket): boolean; inline;
begin
APR_BUCKET_IS_POOL := e^.type_ = @apr_bucket_type_pool;
end;
function APR_BUCKET_NEXT(e: Papr_bucket): Papr_bucket; inline;
begin
APR_BUCKET_NEXT := e^.link.next;
end;
function APR_BUCKET_PREV(e: Papr_bucket): Papr_bucket; inline;
begin
APR_BUCKET_PREV := e^.link.prev;
end;
procedure APR_BUCKET_REMOVE(e: Papr_bucket); inline;
begin
APR_BUCKET_PREV(e)^.link.next := APR_BUCKET_NEXT(e);
APR_BUCKET_NEXT(e)^.link.prev := APR_BUCKET_PREV(e);
end;
function apr_bucket_read(e: Papr_bucket; const str: PPChar; len: Papr_size_t;
block: apr_read_type_e): apr_status_t; inline;
begin
apr_bucket_read := e^.type_^.read(e, str, len, block);
end;
function AP_INIT_TAKE1(directive: Pchar; const take1func: ttake1func;
mconfig: Pointer; where: Integer; help: Pchar): command_rec; inline;
begin
with result DO
begin
name := directive;
func.take1 := take1func;
cmd_data := mconfig;
req_override := where;
args_how := TAKE1;
errmsg := help;
end;
end;
function AP_INIT_TAKE2(directive: Pchar; const take2func: ttake2func;
mconfig: Pointer; where: Integer; help: Pchar): command_rec; inline;
begin
with result DO
begin
name := directive;
func.take2 := take2func;
cmd_data := mconfig;
req_override := where;
args_how := TAKE2;
errmsg := help;
end;
end;
function AP_INIT_TAKE3(directive: Pchar; const take3func: ttake3func;
mconfig: Pointer; where: Integer; help: Pchar): command_rec; inline;
begin
with result DO
begin
name := directive;
func.take3 := take3func;
cmd_data := mconfig;
req_override := where;
args_how := TAKE3;
errmsg := help;
end;
end;
//********************************************************************
{ from http_config.inc }

View File

@ -135,15 +135,15 @@ type
* @
}
ap_out_filter_func = function (f: Pap_filter_t;
b: Papr_bucket_brigade):apr_status_t;
b: Papr_bucket_brigade):apr_status_t; cdecl;
ap_in_filter_func = function (f: Pap_filter_t;
b: Papr_bucket_brigade;
mode: ap_input_mode_t;
block: apr_read_type_e;
readbytes: apr_off_t): apr_status_t;
readbytes: apr_off_t): apr_status_t; cdecl;
ap_init_filter_func = function (f: Pap_filter_t): Longint;
ap_init_filter_func = function (f: Pap_filter_t): Longint; cdecl;
Pap_filter_func = ^ap_filter_func;
ap_filter_func = record