diff --git a/httpd/apache_module.asm b/httpd/apache_module.asm new file mode 100644 index 000000000..191515e2b --- /dev/null +++ b/httpd/apache_module.asm @@ -0,0 +1,3 @@ +[SECTION .data] +global test_module +test_module dd 0 diff --git a/httpd/example_module.asm b/httpd/example_module.asm new file mode 100644 index 000000000..5a044fc3b --- /dev/null +++ b/httpd/example_module.asm @@ -0,0 +1,3 @@ +[SECTION .data] +global example_module +example_module dd 0 diff --git a/httpd/httpd_2_0/ap_config.inc b/httpd/httpd_2_0/ap_config.inc new file mode 100644 index 000000000..801fde509 --- /dev/null +++ b/httpd/httpd_2_0/ap_config.inc @@ -0,0 +1,248 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{#include "apr.h" +#include "apr_hooks.h" +#include "apr_optional_hooks.h"} + +{ + * @file ap_config.h + * @brief Symbol export macros and hook functions + } + +{ Although this file doesn't declare any hooks, declare the hook group here } +{ @defgroup hooks Apache Hooks } + +{$ifdef DOXYGEN} +{ define these just so doxygen documents them } + +{ + * AP_DECLARE_STATIC is defined when including Apache's Core headers, + * to provide static linkage when the dynamic library may be unavailable. + * + * @see AP_DECLARE_EXPORT + * + * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when + * including Apache's Core headers, to import and link the symbols from the + * dynamic Apache Core library and assure appropriate indirection and calling + * conventions at compile time. + } +{$define AP_DECLARE_STATIC} +{ + * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic + * library, so that all public symbols are exported. + * + * @see AP_DECLARE_STATIC + } +{$define AP_DECLARE_EXPORT} + +{$endif} { def DOXYGEN } + +//#if !defined(WIN32) +{ + * Apache Core dso functions are declared with AP_DECLARE(), so they may + * use the most appropriate calling convention. Hook functions and other + * Core functions with variable arguments must use AP_DECLARE_NONSTD(). + * @code + * AP_DECLARE(rettype) ap_func(args) + * @endcode + } +//#define AP_DECLARE(type) type + +{ + * Apache Core dso variable argument and hook functions are declared with + * AP_DECLARE_NONSTD(), as they must use the C language calling convention. + * @see AP_DECLARE + * @code + * AP_DECLARE_NONSTD(rettype) ap_func(args [...]) + * @endcode + } +//#define AP_DECLARE_NONSTD(type) type + +{ + * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA. + * This assures the appropriate indirection is invoked at compile time. + * + * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for + * declarations within headers to properly import the variable. + * @code + * AP_DECLARE_DATA type apr_variable + * @endcode + } +{#define AP_DECLARE_DATA + +#elif defined(AP_DECLARE_STATIC) +#define AP_DECLARE(type) type __stdcall +#define AP_DECLARE_NONSTD(type) type +#define AP_DECLARE_DATA +#elif defined(AP_DECLARE_EXPORT) +#define AP_DECLARE(type) __declspec(dllexport) type __stdcall +#define AP_DECLARE_NONSTD(type) __declspec(dllexport) type +#define AP_DECLARE_DATA __declspec(dllexport) +#else +#define AP_DECLARE(type) __declspec(dllimport) type __stdcall +#define AP_DECLARE_NONSTD(type) __declspec(dllimport) type +#define AP_DECLARE_DATA __declspec(dllimport) +#endif + +#if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC)} +{ + * Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA. + * + * Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols + * declared with AP_MODULE_DECLARE_DATA are always exported. + * @code + * module AP_MODULE_DECLARE_DATA mod_tag + * @endcode + } +{#if defined(WIN32) +#define AP_MODULE_DECLARE(type) type __stdcall +#else +#define AP_MODULE_DECLARE(type) type +#endif +#define AP_MODULE_DECLARE_NONSTD(type) type +#define AP_MODULE_DECLARE_DATA +#else} +{ + * AP_MODULE_DECLARE_EXPORT is a no-op. Unless contradicted by the + * AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined. + * + * The old SHARED_MODULE compile-time symbol is now the default behavior, + * so it is no longer referenced anywhere with Apache 2.0. + } +{#define AP_MODULE_DECLARE_EXPORT +#define AP_MODULE_DECLARE(type) __declspec(dllexport) type __stdcall +#define AP_MODULE_DECLARE_NONSTD(type) __declspec(dllexport) type +#define AP_MODULE_DECLARE_DATA __declspec(dllexport) +#endif} + +{ + * Declare a hook function + * @param ret The return type of the hook + * @param name The hook's name (as a literal) + * @param args The arguments the hook function takes, in brackets. + } +{#define AP_DECLARE_HOOK(ret,name,args) \ + APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args) +} +{ @internal } +{#define AP_IMPLEMENT_HOOK_BASE(name) \ + APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name) +} +{ + * Implement an Apache core hook that has no return code, and + * therefore runs all of the registered functions. The implementation + * is called ap_run_name. + * + * @param name The name of the hook + * @param args_decl The declaration of the arguments for the hook, for example + * "(int x,void *y)" + * @param args_use The arguments for the hook as used in a call, for example + * "(x,y)" + * @note If IMPLEMENTing a hook that is not linked into the Apache core, + * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID. + } +{#define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \ + APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use) +} +{ + * Implement an Apache core hook that runs until one of the functions + * returns something other than ok or decline. That return value is + * then returned from the hook runner. If the hooks run to completion, + * then ok is returned. Note that if no hook runs it would probably be + * more correct to return decline, but this currently does not do + * so. The implementation is called ap_run_name. + * + * @param ret The return type of the hook (and the hook runner) + * @param name The name of the hook + * @param args_decl The declaration of the arguments for the hook, for example + * "(int x,void *y)" + * @param args_use The arguments for the hook as used in a call, for example + * "(x,y)" + * @param ok The "ok" return value + * @param decline The "decline" return value + * @return ok, decline or an error. + * @note If IMPLEMENTing a hook that is not linked into the Apache core, + * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL. + } +{#define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \ + APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \ + args_use,ok,decline) +} +{ + * Implement a hook that runs until a function returns something other than + * decline. If all functions return decline, the hook runner returns decline. + * The implementation is called ap_run_name. + * + * @param ret The return type of the hook (and the hook runner) + * @param name The name of the hook + * @param args_decl The declaration of the arguments for the hook, for example + * "(int x,void *y)" + * @param args_use The arguments for the hook as used in a call, for example + * "(x,y)" + * @param decline The "decline" return value + * @return decline or an error. + * @note If IMPLEMENTing a hook that is not linked into the Apache core + * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST. + } +{#define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \ + APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \ + args_use,decline) +} +{ Note that the other optional hook implementations are straightforward but + * have not yet been needed + } + +{ + * Implement an optional hook. This is exactly the same as a standard hook + * implementation, except the hook is optional. + * @see AP_IMPLEMENT_HOOK_RUN_ALL + } +{#define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \ + decline) \ + APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \ + args_use,ok,decline) +} +{ + * Hook an optional hook. Unlike static hooks, this uses a macro instead of a + * function. + } +{#define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \ + APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order) + +#include "os.h" +#if !defined(WIN32) && !defined(NETWARE) +#include "ap_config_auto.h" +#include "ap_config_layout.h" +#endif +#if defined(NETWARE) +#define AP_NONBLOCK_WHEN_MULTI_LISTEN 1 +#endif} + +{ TODO - We need to put OS detection back to make all the following work } + +{$if defined(SUNOS) or defined(IRIX) or defined(NEXT) or defined(AUX) + or defined (UW) or defined(LYNXOS) or defined(TPF)} +{ These systems don't do well with any lingering close code; I don't know + * why -- manoj } +{$define NO_LINGCLOSE} +{$endif} + +{ If APR has OTHER_CHILD logic, use reliable piped logs. } +{$ifdef APR_HAS_OTHER_CHILD} +{$define AP_HAVE_RELIABLE_PIPED_LOGS} +{$endif} + diff --git a/httpd/httpd_2_0/ap_mmn.inc b/httpd/httpd_2_0/ap_mmn.inc new file mode 100644 index 000000000..8e4ec081c --- /dev/null +++ b/httpd/httpd_2_0/ap_mmn.inc @@ -0,0 +1,121 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @package Module Magic Number + } + +{ + * MODULE_MAGIC_NUMBER_MAJOR + * Major API changes that could cause compatibility problems for older modules + * such as structure size changes. No binary compatibility is possible across + * a change in the major version. + * + * MODULE_MAGIC_NUMBER_MINOR + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading MODULE_MAGIC_NUMBER_MAJOR. + * + * See the MODULE_MAGIC_AT_LEAST macro below for an example. + } + +{ + * 20010224 (2.0.13-dev) MODULE_MAGIC_COOKIE reset to "AP20" + * 20010523 (2.0.19-dev) bump for scoreboard structure reordering + * 20010627 (2.0.19-dev) more API changes than I can count + * 20010726 (2.0.22-dev) more big API changes + * 20010808 (2.0.23-dev) dir d_is_absolute bit introduced, bucket changes, etc + * 20010825 (2.0.25-dev) removed d_is_absolute, introduced map_to_storage hook + * 20011002 (2.0.26-dev) removed 1.3-depreciated request_rec.content_language + * 20011127 (2.0.29-dev) bump for postconfig hook change, and removal of socket + * from connection record + * 20011212 (2.0.30-dev) bump for new used_path_info member of request_rec + * 20011218 (2.0.30-dev) bump for new sbh member of conn_rec, different + * declarations for scoreboard, new parameter to + * create_connection hook + * 20020102 (2.0.30-dev) bump for changed type of limit_req_body in + * core_dir_config + * 20020109 (2.0.31-dev) bump for changed shm and scoreboard declarations + * 20020111 (2.0.31-dev) bump for ETag fields added at end of cor_dir_config + * 20020114 (2.0.31-dev) mod_dav changed how it asks its provider to fulfill + * a GET request + * 20020118 (2.0.31-dev) Input filtering split of blocking and mode + * 20020127 (2.0.31-dev) bump for pre_mpm hook change + * 20020128 (2.0.31-dev) bump for pre_config hook change + * 20020218 (2.0.33-dev) bump for AddOutputFilterByType directive + * 20020220 (2.0.33-dev) bump for scoreboard.h structure change + * 20020302 (2.0.33-dev) bump for protocol_filter additions. + * 20020306 (2.0.34-dev) bump for filter type renames. + * 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed + * 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253 + * 20020327 (2.0.35-dev) Add parameter to quick_handler hook + * 20020329 (2.0.35-dev) bump for addition of freelists to bucket API + * 20020329.1 (2.0.36) minor bump for new arg to opt fn ap_cgi_build_command + * 20020506 (2.0.37-dev) Removed r->boundary in request_rec. + * 20020529 (2.0.37-dev) Standardized the names of some apr_pool_*_set funcs + * 20020602 (2.0.37-dev) Bucket API change (metadata buckets) + * 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time + * 20020625 (2.0.40-dev) Changed conn_rec->keepalive to an enumeration + * 20020628 (2.0.40-dev) Added filter_init to filter registration functions + * 20020903 (2.0.41-dev) APR's error constants changed + * 20020903.2 (2.0.46-dev) add ap_escape_logitem + * 20020903.3 (2.0.46-dev) allow_encoded_slashes added to core_dir_config + * 20020903.4 (2.0.47-dev) add ap_is_recursion_limit_exceeded() + * 20020903.5 (2.0.49-dev) add ap_escape_errorlog_item() + * 20020903.6 (2.0.49-dev) add insert_error_filter hook + * 20020903.7 (2.0.49-dev) added XHTML Doctypes + * 20020903.8 (2.0.50-dev) export ap_set_sub_req_protocol and + * ap_finalize_sub_req_protocol on Win32 and NetWare + * 20020903.9 (2.0.51-dev) create pcommands and initialize arrays before + * calling ap_setup_prelinked_modules + * 20020903.10 (2.0.55-dev) add ap_log_cerror() + * 20020903.11 (2.0.55-dev) added trace_enable to core_server_config + * 20020903.12 (2.0.56-dev) added ap_get_server_revision / ap_version_t + } +const + + MODULE_MAGIC_COOKIE = $41503230; { "AP20" } + + MODULE_MAGIC_NUMBER_MAJOR = 20020903; { For 2.0.58 Also works for 2.0.54} + + MODULE_MAGIC_NUMBER_MINOR = 12; // 0...n + +{ + * Determine if the server's current MODULE_MAGIC_NUMBER is at least a + * specified value. + *
+ * Useful for testing for features. + * For example, suppose you wish to use the apr_table_overlap + * function. You can do this: + * + * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2) + * ... use apr_table_overlap() + * #else + * ... alternative code which doesn't use apr_table_overlap() + * #endif + *+ * @param major The major module magic number + * @param minor The minor module magic number + * @deffunc AP_MODULE_MAGIC_AT_LEAST(int major, int minor) + } +{#define AP_MODULE_MAGIC_AT_LEAST(major,minor) \ + ((major) < MODULE_MAGIC_NUMBER_MAJOR \ + || ((major) == MODULE_MAGIC_NUMBER_MAJOR \ + && (minor) <= MODULE_MAGIC_NUMBER_MINOR))} + +{ @deprecated present for backwards compatibility } + MODULE_MAGIC_NUMBER = MODULE_MAGIC_NUMBER_MAJOR; +//#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using + diff --git a/httpd/httpd_2_0/ap_mpm.inc b/httpd/httpd_2_0/ap_mpm.inc new file mode 100644 index 000000000..83af0fbfc --- /dev/null +++ b/httpd/httpd_2_0/ap_mpm.inc @@ -0,0 +1,179 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr_thread_proc.h" + +{ + * @package Multi-Processing Module library + } + +{ + The MPM, "multi-processing model" provides an abstraction of the + interface with the OS for distributing incoming connections to + threads/process for processing. http_main invokes the MPM, and + the MPM runs until a shutdown/restart has been indicated. + The MPM calls out to the apache core via the ap_process_connection + function when a connection arrives. + + The MPM may or may not be multithreaded. In the event that it is + multithreaded, at any instant it guarantees a 1:1 mapping of threads + ap_process_connection invocations. + + Note: In the future it will be possible for ap_process_connection + to return to the MPM prior to finishing the entire connection; and + the MPM will proceed with asynchronous handling for the connection; + in the future the MPM may call ap_process_connection again -- but + does not guarantee it will occur on the same thread as the first call. + + The MPM further guarantees that no asynchronous behaviour such as + longjmps and signals will interfere with the user code that is + invoked through ap_process_connection. The MPM may reserve some + signals for its use (i.e. SIGUSR1), but guarantees that these signals + are ignored when executing outside the MPM code itself. (This + allows broken user code that does not handle EINTR to function + properly.) + + The suggested server restart and stop behaviour will be "graceful". + However the MPM may choose to terminate processes when the user + requests a non-graceful restart/stop. When this occurs, the MPM kills + all threads with extreme prejudice, and destroys the pchild pool. + User cleanups registered in the pchild apr_pool_t will be invoked at + this point. (This can pose some complications, the user cleanups + are asynchronous behaviour not unlike longjmp/signal... but if the + admin is asking for a non-graceful shutdown, how much effort should + we put into doing it in a nice way?) + + unix/posix notes: + - The MPM does not set a SIGALRM handler, user code may use SIGALRM. + But the preferred method of handling timeouts is to use the + timeouts provided by the BUFF abstraction. + - The proper setting for SIGPIPE is SIG_IGN, if user code changes it + for any of their own processing, it must be restored to SIG_IGN + prior to executing or returning to any apache code. + TODO: add SIGPIPE debugging check somewhere to make sure it's SIG_IGN +} + +{ + * This is the function that MPMs must create. This function is responsible + * for controlling the parent and child processes. It will run until a + * restart/shutdown is indicated. + * @param pconf the configuration pool, reset before the config file is read + * @param plog the log pool, reset after the config file is read + * @param server_conf the global server config. + * @return 1 for shutdown 0 otherwise. + * @deffunc int ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf) + } +function ap_mpm_run(pconf, plog: Papr_pool_t; server_conf: Pserver_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_mpm_run' + LibSuff12; + +{ + * predicate indicating if a graceful stop has been requested ... + * used by the connection loop + * @return 1 if a graceful stop has been requested, 0 otherwise + * @deffunc int ap_graceful_stop_signalled(*void) + } +function ap_graceful_stop_signalled: Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_graceful_stop_signalled' + LibSuff0; + +{ + * Spawn a process with privileges that another module has requested + * @param r The request_rec of the current request + * @param newproc The resulting process handle. + * @param progname The program to run + * @param const_args the arguments to pass to the new program. The first + * one should be the program name. + * @param env The new environment apr_table_t for the new process. This + * should be a list of NULL-terminated strings. + * @param attr the procattr we should use to determine how to create the new + * process + * @param p The pool to use. + } +function ap_os_create_privileged_process( + const r: Prequest_rec; + newproc: Papr_proc_t; + const progname, args, env: PChar; + attr: Papr_procattr_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_os_create_privileged_process' + LibSuff28; + +const +{ Subtypes/Values for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED } + AP_MPMQ_NOT_SUPPORTED = 0; { This value specifies whether } + { an MPM is capable of } + { threading or forking. } + AP_MPMQ_STATIC = 1; { This value specifies whether } + { an MPM is using a static # } + { threads or daemons. } + AP_MPMQ_DYNAMIC = 2; { This value specifies whether } + { an MPM is using a dynamic # } + { threads or daemons. } + +{ Values returned for AP_MPMQ_MPM_STATE } + AP_MPMQ_STARTING = 0; + AP_MPMQ_RUNNING = 1; + AP_MPMQ_STOPPING = 2; + + AP_MPMQ_MAX_DAEMON_USED = 1; { Max # of daemons used so far } + AP_MPMQ_IS_THREADED = 2; { MPM can do threading } + AP_MPMQ_IS_FORKED = 3; { MPM can do forking } + AP_MPMQ_HARD_LIMIT_DAEMONS = 4; { The compiled max # daemons } + AP_MPMQ_HARD_LIMIT_THREADS = 5; { The compiled max # threads } + AP_MPMQ_MAX_THREADS = 6; { # of threads/child by config } + AP_MPMQ_MIN_SPARE_DAEMONS = 7; { Min # of spare daemons } + AP_MPMQ_MIN_SPARE_THREADS = 8; { Min # of spare threads } + AP_MPMQ_MAX_SPARE_DAEMONS = 9; { Max # of spare daemons } + AP_MPMQ_MAX_SPARE_THREADS = 10; { Max # of spare threads } + AP_MPMQ_MAX_REQUESTS_DAEMON = 11; { Max # of requests per daemon } + AP_MPMQ_MAX_DAEMONS = 12; { Max # of daemons by config } + AP_MPMQ_MPM_STATE = 13; { starting, running, stopping } + +{ + * Query a property of the current MPM. + * @param query_code One of APM_MPMQ_* + * @param result A location to place the result of the query + * @return APR_SUCCESS or APR_ENOTIMPL + * @deffunc int ap_mpm_query(int query_code, int *result) + } +function ap_mpm_query(query_code: Integer; result: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_mpm_query' + LibSuff8; + +{ Defining GPROF when compiling uses the moncontrol() function to + * disable gprof profiling in the parent, and enable it only for + * request processing in children (or in one_process mode). It's + * absolutely required to get useful gprof results under linux + * because the profile itimers and such are disabled across a + * fork(). It's probably useful elsewhere as well. + } +{#ifdef GPROF +extern void moncontrol(int); +#define AP_MONCONTROL(x) moncontrol(x) +#else +#define AP_MONCONTROL(x) +#endif} + +{$ifdef AP_ENABLE_EXCEPTION_HOOK} +type + ap_exception_info_t = record + sig: Integer; + pid: pid_t; + end; + +AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei)) +{$endif} {AP_ENABLE_EXCEPTION_HOOK} + diff --git a/httpd/httpd_2_0/ap_provider.inc b/httpd/httpd_2_0/ap_provider.inc new file mode 100644 index 000000000..e14d2d34f --- /dev/null +++ b/httpd/httpd_2_0/ap_provider.inc @@ -0,0 +1,50 @@ +{ Copyright 2002-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "ap_config.h" + +{ + * @package Provider API + } + +{ + * This function is used to register a provider with the global + * provider pool. + * @param pool The pool to create any storage from + * @param provider_group The group to store the provider in + * @param provider_name The name for this provider + * @param provider_version The version for this provider + * @param provider Opaque structure for this provider + * @return APR_SUCCESS if all went well + } +function ap_register_provider(pool: Papr_pool_t; + const provider_group, provider_name, provider_version: PChar; + const provider: Pointer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_register_provider' + LibSuff20; + +{ + * This function is used to retrieve a provider from the global + * provider pool. + * @param provider_group The group to look for this provider in + * @param provider_name The name for the provider + * @param provider_version The version for the provider + * @return provider pointer to provider if found, NULL otherwise + } +function ap_lookup_provider(provider_group, provider_name, provider_version: PChar): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_lookup_provider' + LibSuff12; + diff --git a/httpd/httpd_2_0/ap_release.inc b/httpd/httpd_2_0/ap_release.inc new file mode 100644 index 000000000..ae8594ab6 --- /dev/null +++ b/httpd/httpd_2_0/ap_release.inc @@ -0,0 +1,53 @@ +{ Copyright 2001-2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + } + +//#include "apr_general.h" /* stringify */ + +const + AP_SERVER_COPYRIGHT = + 'Copyright 2001-2006 The Apache Software Foundation' + + ' or its licensors, as applicable.'; + +{ + * The below defines the base string of the Server: header. Additional + * tokens can be added via the ap_add_version_component() API call. + * + * The tokens are listed in order of their significance for identifying the + * application. + * + * "Product tokens should be short and to the point -- use of them for + * advertizing or other non-essential information is explicitly forbidden." + * + * Example: "Apache/1.1.0 MrWidget/0.1-alpha" + } + AP_SERVER_BASEVENDOR = 'Apache Software Foundation'; + AP_SERVER_BASEPRODUCT = 'Apache'; + + AP_SERVER_MAJORVERSION_NUMBER = 2; + AP_SERVER_MINORVERSION_NUMBER = 0; + AP_SERVER_PATCHLEVEL_NUMBER = 58; + AP_SERVER_ADD_STRING = ''; + +{ keep old macros as well } +{#define AP_SERVER_MAJORVERSION APR_STRINGIFY(AP_SERVER_MAJORVERSION_NUMBER) +#define AP_SERVER_MINORVERSION APR_STRINGIFY(AP_SERVER_MINORVERSION_NUMBER) +#define AP_SERVER_PATCHLEVEL APR_STRINGIFY(AP_SERVER_PATCHLEVEL_NUMBER) \ + AP_SERVER_ADD_STRING + +#define AP_SERVER_MINORREVISION AP_SERVER_MAJORVERSION "." AP_SERVER_MINORVERSION +#define AP_SERVER_BASEREVISION AP_SERVER_MINORREVISION "." AP_SERVER_PATCHLEVEL +#define AP_SERVER_BASEVERSION AP_SERVER_BASEPRODUCT "/" AP_SERVER_BASEREVISION +#define AP_SERVER_VERSION AP_SERVER_BASEVERSION} + diff --git a/httpd/httpd_2_0/apr/apr.pas b/httpd/httpd_2_0/apr/apr.pas new file mode 100644 index 000000000..ea2be9f9c --- /dev/null +++ b/httpd/httpd_2_0/apr/apr.pas @@ -0,0 +1,234 @@ +{ + apr.pas + + Copyright (C) 2006 Felipe Monteiro de Carvalho + + This unit is a pascal binding for the Apache 2.0.58 headers. + The headers were released under the following copyright: +} +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +unit apr; + +interface + +{$ifdef fpc} + {$mode delphi}{$H+} +{$endif} + +{$IFNDEF FPC} + {$DEFINE WINDOWS} +{$ENDIF} + +{$IFDEF WIN32} + {$DEFINE WINDOWS} +{$ENDIF} + +{$ifdef Unix} + {$PACKRECORDS C} +{$endif} + +uses +{$ifdef WINDOWS} + Windows, winsock, +{$ELSE} + UnixType, +{$ENDIF} + SysUtils, ctypes; + +const +{$IFDEF WINDOWS} + LibAPR = 'libapr.dll'; +{$ELSE} + LibAPR = ''; +{$ENDIF} + +{$IFDEF WINDOWS} + LibNamePrefix = '_'; + LibSuff0 = '@0'; + LibSuff4 = '@4'; + LibSuff8 = '@8'; + LibSuff12 = '@12'; + LibSuff16 = '@16'; + LibSuff20 = '@20'; + LibSuff24 = '@24'; + LibSuff28 = '@28'; + LibSuff32 = '@32'; +{$ELSE} + LibNamePrefix = ''; + LibSuff0 = ''; + LibSuff4 = ''; + LibSuff8 = ''; + LibSuff12 = ''; + LibSuff16 = ''; + LibSuff20 = ''; + LibSuff24 = ''; + LibSuff28 = ''; + LibSuff32 = ''; +{$ENDIF} + +type + uid_t = Integer; + gid_t = Integer; + time_t = LongInt; + size_t = Integer; + pid_t = Integer; + Ppid_t = ^pid_t; + apr_uint16_t = Word; + apr_uint32_t = Cardinal; + apr_int64_t = Int64; + apr_uint64_t = Int64; + apr_socklen_t = Integer; + +type + {$IFDEF WINDOWS} + apr_off_t = Int64; + {$ENDIF} + {$IFDEF UNIX} + apr_off_t = Integer; + {$ENDIF} + + apr_int32_t = Integer; + apr_size_t = size_t; + Papr_size_t = ^apr_size_t; + + va_list = Pointer; + + // Network structures + + sockaddr = record + sa_family: cushort; // address family, AF_xxx + sa_data: array [1..14] of Char; // (NBO) 14 bytes of protocol address + end; + + in_addr = record + s_addr: culong; // load with inet_aton() + end; + + sockaddr_in = record + sin_family: cshort; // e.g. AF_INET + sin_port: cushort; // e.g. htons(3490) + sin_addr: in_addr; // see struct in_addr, below + sin_zero: array [1..8] of Char; // zero this if you want to + end; + + in6_addr = record + Case Integer of + 1: (u6_addr8: array [1..16] of Byte); + 2: (u6_addr16: array [1..8] of Word); + 3: (u6_addr32: array [1..4] of Cardinal); + end; +//#define s6_addr in6_u.u6_addr8 +//#define s6_addr16 in6_u.u6_addr16 +//#define s6_addr32 in6_u.u6_addr32 + + sockaddr_in6 = record + sin6_family: cushort; + sin6_port: Word; + sin6_flowinfo: Cardinal; + sin6_addr: in6_addr; + sin6_scope_id: Cardinal; + end; + + // TEMPORARY + + Papr_xml_ns_scope = Pointer; + + Pap_method_list_t = Pointer; + Pcore_output_filter_ctx_t = Pointer; + Pap_directive_t = Pointer; + Pap_filter_t = Pointer; + Papr_file_t = Pointer; + Papr_off_t = Pointer; + + iovec = record + /// byte count to read/write + iov_len: culong; + /// data to be read/written + iov_base: PChar; + end; + + Piovec = ^iovec; + +{$include apr_errno.inc} +{$include apr_pools.inc} +{$include apr_general.inc} +{$include apr_dso.inc} +{$include apr_user.inc} +{$include apr_time.inc} +{$include apr_tables.inc} +{$include apr_file_info.inc} +{$include apr_file_io.inc} +{$include apr_strings.inc} +{$include apr_lib.inc} +{$include apr_signal.inc} +{$include apr_network_io.inc} +{.$include apr_portable.inc} + +{.$include ../aprutils/apr_uri.inc} + +{$include apr_thread_proc.inc} +{$include apr_version.inc} + +implementation + +{ + Macros transformed into functions in the translation +} + +{ apr_pools.inc } + +{$ifndef DOXYGEN} +function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t; +begin + Result := apr_pool_create_ex(newpool, parent, nil, nil); +end; +{$endif} + +function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t; + abort_fn: apr_abortfunc_t): apr_status_t; +begin + Result := apr_pool_create_ex(newpool, parent, abort_fn, nil); +end; + +{ apr_lib.inc } + +function apr_tolower(c: Char): Char; +var + buf: array[0..1] of Char; +begin + buf[0] := c; + buf[1] := #0; + + buf := StrLower(@buf[0]); + + Result := buf[0]; +end; + +function apr_toupper(c: Char): Char; +var + buf: array[0..1] of Char; +begin + buf[0] := c; + buf[1] := #0; + + buf := StrUpper(@buf[0]); + + Result := buf[0]; +end; + +end. + diff --git a/httpd/httpd_2_0/apr/apr_allocator.inc b/httpd/httpd_2_0/apr/apr_allocator.inc new file mode 100644 index 000000000..576db59a4 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_allocator.inc @@ -0,0 +1,174 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_allocator.h + * @brief APR Internal Memory Allocation + } + +{#include "apr.h" +#include "apr_errno.h" +#define APR_WANT_MEMFUNC < For no good reason? +#include "apr_want.h"} + +{ + * @defgroup apr_allocator Internal Memory Allocation + * @ingroup APR + } + +type +{ the allocator structure } + apr_allocator_t = record end; + Papr_allocator_t = ^apr_allocator_t; + PPapr_allocator_t = ^Papr_allocator_t; + + { the structure which holds information about the allocation } + + Papr_memnode_t = ^apr_memnode_t; + PPapr_memnode_t = ^Papr_memnode_t; + + { basic memory node structure } + + apr_memnode_t = record + next: Papr_memnode_t; {< next memnode } + ref: PPapr_memnode_t; {< reference to self } + index: apr_uint32_t; {< size } + free_index: apr_uint32_t; {< how much free } + first_avail: PChar; {< pointer to first free memory } + endp: PChar; {< pointer to end of free memory } + end; + +{ The base size of a memory node - aligned. } +//#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t)) + +{ Symbolic constants } +const + APR_ALLOCATOR_MAX_FREE_UNLIMITED = 0; + +{ + * Create a new allocator + * @param allocator The allocator we have just created. + * + } +function apr_allocator_create(allocator: PPapr_allocator_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_create' + LibSuff4; + +{ + * Destroy an allocator + * @param allocator The allocator to be destroyed + * @remark Any memnodes not given back to the allocator prior to destroying + * will _not_ be free()d. + } +procedure apr_allocator_destroy(allocator: Papr_allocator_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_destroy' + LibSuff4; + +{ + * Allocate a block of mem from the allocator + * @param allocator The allocator to allocate from + * @param size The size of the mem to allocate (excluding the + * memnode structure) + } +function apr_allocator_alloc(allocator: Papr_allocator_t; + size: apr_size_t): Papr_memnode_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_alloc' + LibSuff8; + +{ + * Free a block of mem, giving it back to the allocator + * @param allocator The allocator to give the mem back to + * @param memnode The memory node to return + } +procedure apr_allocator_free(allocator: Papr_allocator_t; memnode: Papr_memnode_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_free' + LibSuff8; + +//#include "apr_pools.h" + +{ + * Set the owner of the allocator + * @param allocator The allocator to set the owner for + * @param pool The pool that is to own the allocator + * @remark Typically pool is the highest level pool using the allocator + } +{ + * XXX: see if we can come up with something a bit better. Currently + * you can make a pool an owner, but if the pool doesn't use the allocator + * the allocator will never be destroyed. + } +procedure apr_allocator_owner_set(allocator: Papr_allocator_t; pool: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_owner_set' + LibSuff8; + +{ @deprecated @see apr_allocator_owner_set } +{APR_DECLARE(void) apr_allocator_set_owner(apr_allocator_t *allocator, + apr_pool_t *pool); +} +{ + * Get the current owner of the allocator + * @param allocator The allocator to get the owner from + } +function apr_allocator_owner_get(allocator: Papr_allocator_t): Papr_pool_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_owner_get' + LibSuff4; + +{ @deprecated @see apr_allocator_owner_get } +{APR_DECLARE(apr_pool_t *) apr_allocator_get_owner( + apr_allocator_t *allocator); +} +{ + * Set the current threshold at which the allocator should start + * giving blocks back to the system. + * @param allocator The allocator the set the threshold on + * @param size The threshold. 0 == unlimited. + } +procedure apr_allocator_max_free_set(allocator: Papr_allocator_t; size: apr_size_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_max_free_set' + LibSuff8; + +{ @deprecated @see apr_allocator_max_free_set } +{APR_DECLARE(void) apr_allocator_set_max_free(apr_allocator_t *allocator, + apr_size_t size); + +#include "apr_thread_mutex.h"} + +{$ifdef APR_HAS_THREADS} +{ + * Set a mutex for the allocator to use + * @param allocator The allocator to set the mutex for + * @param mutex The mutex + } +APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator, + apr_thread_mutex_t *mutex); + +{ @deprecated @see apr_allocator_mutex_set } +APR_DECLARE(void) apr_allocator_set_mutex(apr_allocator_t *allocator, + apr_thread_mutex_t *mutex); + +{ + * Get the mutex currently set for the allocator + * @param allocator The allocator + } +APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get( + apr_allocator_t *allocator); + +{ @deprecated @see apr_allocator_mutex_get } +APR_DECLARE(apr_thread_mutex_t *) apr_allocator_get_mutex( + apr_allocator_t *allocator); + +{$endif} { APR_HAS_THREADS } + diff --git a/httpd/httpd_2_0/apr/apr_buckets.inc b/httpd/httpd_2_0/apr/apr_buckets.inc new file mode 100644 index 000000000..c018172bc --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_buckets.inc @@ -0,0 +1,1515 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +{ + * @file apr_buckets.h + * @brief APR-UTIL Buckets/Bucket Brigades + } + +{#if defined(APR_BUCKET_DEBUG) && !defined(APR_RING_DEBUG) +#define APR_RING_DEBUG +#endif + +#include "apu.h" +#include "apr_network_io.h" +#include "apr_file_io.h" +#include "apr_general.h" +#include "apr_mmap.h" +#include "apr_errno.h" +#include "apr_ring.h" +#include "apr.h" +#if APR_HAVE_SYS_UIO_H +#include
+ * while (e != APR_BRIGADE_SENTINEL(b)) ( + * ... + * e = APR_BUCKET_NEXT(e); + * ) + *+ * @param b The brigade + * @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 + * @return The first bucket in the brigade + } +//#define APR_BRIGADE_FIRST(b) APR_RING_FIRST(&(b)->list) +{ + * Return the last bucket in a brigade + * @param b The brigade to query + * @return The last bucket in the brigade + } +//#define APR_BRIGADE_LAST(b) APR_RING_LAST(&(b)->list) + +{ + * Iterate through a bucket brigade + * @param e The current bucket + * @param b The brigade to iterate over + * @remark This is the same as either: + *
+ * e = APR_BRIGADE_FIRST(b); + * while (e != APR_BRIGADE_SENTINEL(b)) ( + * ... + * e = APR_BUCKET_NEXT(e); + * ) + * OR + * for (e = APR_BRIGADE_FIRST(b); + * e != APR_BRIGADE_SENTINEL(b); + * e = APR_BUCKET_NEXT(e)) ( + * ... + * ) + *+ * @warning Be aware that you cannot change the value of e within + * the foreach loop, nor can you destroy the bucket it points to. + * Modifying the prev and next pointers of the bucket is dangerous + * but can be done if you're careful. If you change e's value or + * destroy the bucket it points to, then APR_BRIGADE_FOREACH + * will have no way to find out what bucket to use for its next + * iteration. The reason for this can be seen by looking closely + * at the equivalent loops given in the tip above. So, for example, + * if you are writing a loop that empties out a brigade one bucket + * at a time, APR_BRIGADE_FOREACH just won't work for you. Do it + * by hand, like so: + *
+ * while (!APR_BRIGADE_EMPTY(b)) ( + * e = APR_BRIGADE_FIRST(b); + * ... + * apr_bucket_delete(e); + * ) + *+ * @deprecated This macro causes more headaches than it's worth. Use + * one of the alternatives documented here instead; the clarity gained + * in what's really going on is well worth the extra line or two of code. + * This macro will be removed at some point in the future. + } +//#define APR_BRIGADE_FOREACH(e, b) \ +// APR_RING_FOREACH((e), &(b)->list, apr_bucket, link) + +{ + * Insert a list of buckets at the front of a brigade + * @param b The brigade to add to + * @param e The first bucket in a list of buckets to insert + } +{#define APR_BRIGADE_INSERT_HEAD(b, e) do ( \ + apr_bucket *ap__b = (e); \ + APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((b)); \ + ) while (0)} + +{ + * Insert a list of buckets at the end of a brigade + * @param b The brigade to add to + * @param e The first bucket in a list of buckets to insert + } +{#define APR_BRIGADE_INSERT_TAIL(b, e) do begin \ + apr_bucket *ap__b = (e); \ + APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((b)); \ + end while (0)} + +{ + * Concatenate brigade b onto the end of brigade a, leaving brigade b empty + * @param a The first brigade + * @param b The second brigade + } +{#define APR_BRIGADE_CONCAT(a, b) do begin + APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((a)); \ + end while (0);} + +{ + * Prepend brigade b onto the beginning of brigade a, leaving brigade b empty + * @param a The first brigade + * @param b The second brigade + } +{#define APR_BRIGADE_PREPEND(a, b) do begin + APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((a)); \ + end while (0)} + +{ + * Insert a list of buckets before a specified bucket + * @param a The bucket to insert before + * @param b The buckets to insert + } +{#define APR_BUCKET_INSERT_BEFORE(a, b) do begin + apr_bucket *ap__a = (a), *ap__b = (b); \ + APR_RING_INSERT_BEFORE(ap__a, ap__b, link); \ + APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ + end while (0)} + +{ + * Insert a list of buckets after a specified bucket + * @param a The bucket to insert after + * @param b The buckets to insert + } +{#define APR_BUCKET_INSERT_AFTER(a, b) do begin + apr_bucket *ap__a = (a), *ap__b = (b); \ + APR_RING_INSERT_AFTER(ap__a, ap__b, link); \ + APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ + end while (0)} + +{ + * Get the next bucket in the list + * @param e The current bucket + * @return The next bucket + } +//#define APR_BUCKET_NEXT(e) APR_RING_NEXT((e), link) +{ + * Get the previous bucket in the list + * @param e The current bucket + * @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 + } +//#define APR_BUCKET_INIT(e) APR_RING_ELEM_INIT((e), link) + +{ + * Determine if a bucket contains metadata. An empty bucket is + * safe to arbitrarily remove if and only if this is false. + * @param e The bucket to inspect + * @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 + * @return true or false + } +//#define APR_BUCKET_IS_FLUSH(e) ((e)->type == &apr_bucket_type_flush) +{ + * Determine if a bucket is an EOS bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_EOS(e) ((e)->type == &apr_bucket_type_eos) +{ + * Determine if a bucket is a FILE bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_FILE(e) ((e)->type == &apr_bucket_type_file) +{ + * Determine if a bucket is a PIPE bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_PIPE(e) ((e)->type == &apr_bucket_type_pipe) +{ + * Determine if a bucket is a SOCKET bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_SOCKET(e) ((e)->type == &apr_bucket_type_socket) +{ + * Determine if a bucket is a HEAP bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_HEAP(e) ((e)->type == &apr_bucket_type_heap) +{ + * Determine if a bucket is a TRANSIENT bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_TRANSIENT(e) ((e)->type == &apr_bucket_type_transient) +{ + * Determine if a bucket is a IMMORTAL bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_IMMORTAL(e) ((e)->type == &apr_bucket_type_immortal) +//#if APR_HAS_MMAP +{ + * Determine if a bucket is a MMAP bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_MMAP(e) ((e)->type == &apr_bucket_type_mmap) +//#endif +{ + * Determine if a bucket is a POOL bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_POOL(e) ((e)->type == &apr_bucket_type_pool) + +{ + * General-purpose reference counting for the various bucket types. + * + * Any bucket type that keeps track of the resources it uses (i.e. + * most of them except for IMMORTAL, TRANSIENT, and EOS) needs to + * attach a reference count to the resource so that it can be freed + * when the last bucket that uses it goes away. Resource-sharing may + * occur because of bucket splits or buckets that refer to globally + * cached data. } + +{ @see apr_bucket_refcount } + Papr_bucket_refcount = ^apr_bucket_refcount; +{ + * The structure used to manage the shared resource must start with an + * apr_bucket_refcount which is updated by the general-purpose refcount + * code. A pointer to the bucket-type-dependent private data structure + * can be cast to a pointer to an apr_bucket_refcount and vice versa. + } + apr_bucket_refcount = record + { The number of references to this bucket } + refcount: Integer; + end; + +{ ***** Reference-counted bucket types ***** } + +{ @see apr_bucket_heap } + Papr_bucket_heap = ^apr_bucket_heap; +{ + * A bucket referring to data allocated off the heap. + } + free_func_t = procedure (data: Pointer); + + apr_bucket_heap = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The start of the data actually allocated. This should never be + * modified, it is only used to free the bucket. + } + base: PChar; + { how much memory was allocated } + alloc_len: apr_size_t; + { function to use to delete the data } + free_func: free_func_t; + end; + +{ @see apr_bucket_pool } + Papr_bucket_pool = ^apr_bucket_pool; +{ + * A bucket referring to data allocated from a pool + } + apr_bucket_pool = record + { The pool bucket must be able to be easily morphed to a heap + * bucket if the pool gets cleaned up before all references are + * destroyed. This apr_bucket_heap structure is populated automatically + * when the pool gets cleaned up, and subsequent calls to pool_read() + * will result in the apr_bucket in question being morphed into a + * regular heap bucket. (To avoid having to do many extra refcount + * manipulations and b->data manipulations, the apr_bucket_pool + * struct actually *contains* the apr_bucket_heap struct that it + * will become as its first element; the two share their + * apr_bucket_refcount members.) + } + heap: apr_bucket_heap; + { The block of data actually allocated from the pool. + * Segments of this block are referenced by adjusting + * the start and length of the apr_bucket accordingly. + * This will be NULL after the pool gets cleaned up. + } + base: PChar; + { The pool the data was allocated from. When the pool + * is cleaned up, this gets set to NULL as an indicator + * to pool_read() that the data is now on the heap and + * so it should morph the bucket into a regular heap + * bucket before continuing. + } + pool: Papr_pool_t; + { The freelist this structure was allocated from, which is + * needed in the cleanup phase in order to allocate space on the heap + } + list: Papr_bucket_alloc_t; + end; + +{$ifdef APR_HAS_MMAP} +{ @see apr_bucket_mmap } + Papr_bucket_mmap = ^apr_bucket_mmap; +{ + * A bucket referring to an mmap()ed file + } + apr_bucket_mmap = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The mmap this sub_bucket refers to } + mmap: Papr_mmap_t; + end; +{$endif} + +{ @see apr_bucket_file } + Papr_bucket_file = ^apr_bucket_file; +{ + * A bucket referring to an file + } + apr_bucket_file = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The file this bucket refers to } + fd: Papr_file_t; + { The pool into which any needed structures should + * be created while reading from this file bucket } + readpool: Papr_pool_t; +{$ifdef APR_HAS_MMAP} + { Whether this bucket should be memory-mapped if + * a caller tries to read from it } + can_mmap: Integer; +{$endif} { APR_HAS_MMAP } + end; + +{ @see apr_bucket_structs } + Papr_bucket_structs = ^apr_bucket_structs; +{ + * A union of all bucket structures so we know what + * the max size is. + } + apr_bucket_structs = record + case Integer of + 0: (b: apr_bucket); {< Bucket } + 1: (heap: apr_bucket_heap); {< Heap } + 2: (pool: apr_bucket_pool); {< Pool } +{$ifdef APR_HAS_MMAP} + 3: (mmap: apr_bucket_mmap); {< MMap } +{$endif} + 4: (file_: apr_bucket_file); {< File } + end; + +{ + * The amount that apr_bucket_alloc() should allocate in the common case. + * Note: this is twice as big as apr_bucket_structs to allow breathing + * room for third-party bucket types. + } +//#define APR_BUCKET_ALLOC_SIZE APR_ALIGN_DEFAULT(2*sizeof(apr_bucket_structs)) + +{ ***** Bucket Brigade Functions ***** } +{ + * Create a new bucket brigade. The bucket brigade is originally empty. + * @param p The pool to associate with the brigade. Data is not allocated out + * of the pool, but a cleanup is registered. + * @param list The bucket allocator to use + * @return The empty bucket brigade + } +//APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p, +// apr_bucket_alloc_t *list); + +{ + * destroy an entire bucket brigade. This includes destroying all of the + * buckets within the bucket brigade's bucket list. + * @param b The bucket brigade to destroy + } +//APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b); + +{ + * empty out an entire bucket brigade. This includes destroying all of the + * buckets within the bucket brigade's bucket list. This is similar to + * apr_brigade_destroy(), except that it does not deregister the brigade's + * pool cleanup function. + * @param data The bucket brigade to clean up + * @remark Generally, you should use apr_brigade_destroy(). This function + * can be useful in situations where you have a single brigade that + * you wish to reuse many times by destroying all of the buckets in + * the brigade and putting new buckets into it later. + } +//APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data); + +{ + * Split a bucket brigade into two, such that the given bucket is the + * first in the new bucket brigade. This function is useful when a + * filter wants to pass only the initial part of a brigade to the next + * filter. + * @param b The brigade to split + * @param e The first element of the new brigade + * @return The new brigade + } +//APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b, +// apr_bucket *e); + +{ + * Partition a bucket brigade at a given offset (in bytes from the start of + * the brigade). This is useful whenever a filter wants to use known ranges + * of bytes from the brigade; the ranges can even overlap. + * @param b The brigade to partition + * @param point The offset at which to partition the brigade + * @param after_point Returns a pointer to the first bucket after the partition + } +//APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b, +// apr_off_t point, +// apr_bucket **after_point); + +//#if APR_NOT_DONE_YET +{ + * consume nbytes from beginning of b -- call apr_bucket_destroy as + * appropriate, and/or modify start on last element + * @param b The brigade to consume data from + * @param nbytes The number of bytes to consume + } +//APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b, +// apr_off_t nbytes); +//#endif + +{ + * Return the total length of the brigade. + * @param bb The brigade to compute the length of + * @param read_all Read unknown-length buckets to force a size + * @param length Returns the length of the brigade, or -1 if the brigade has + * buckets of indeterminate length and read_all is 0. + } +{APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb, + int read_all, + apr_off_t *length); +} +{ + * Take a bucket brigade and store the data in a flat char* + * @param bb The bucket brigade to create the char* from + * @param c The char* to write into + * @param len The maximum length of the char array. On return, it is the + * actual length of the char array. + } +{APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb, + char *c, + apr_size_t *len); +} +{ + * Creates a pool-allocated string representing a flat bucket brigade + * @param bb The bucket brigade to create the char array from + * @param c On return, the allocated char array + * @param len On return, the length of the char array. + * @param pool The pool to allocate the string from. + } +{APU_DECLARE(apr_status_t) apr_brigade_pflatten(apr_bucket_brigade *bb, + char **c, + apr_size_t *len, + apr_pool_t *pool); +} +{ + * Split a brigade to represent one LF line. + * @param bbOut The bucket brigade that will have the LF line appended to. + * @param bbIn The input bucket brigade to search for a LF-line. + * @param block The blocking mode to be used to split the line. + * @param maxbytes The maximum bytes to read. If this many bytes are seen + * without a LF, the brigade will contain a partial line. + } +{APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut, + apr_bucket_brigade *bbIn, + apr_read_type_e block, + apr_off_t maxbytes); +} +{ + * create an iovec of the elements in a bucket_brigade... return number + * of elements used. This is useful for writing to a file or to the + * network efficiently. + * @param b The bucket brigade to create the iovec from + * @param vec The iovec to create + * @param nvec The number of elements in the iovec. On return, it is the + * number of iovec elements actually filled out. + } +{APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b, + struct iovec *vec, int *nvec); +} +{ + * This function writes a list of strings into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param va A list of strings to add + * @return APR_SUCCESS or error code. + } +{APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + va_list va); +} +{ + * This function writes a string into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param str The string to add + * @param nbyte The number of bytes to write + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b, + apr_brigade_flush flush, void *ctx, + const char *str, apr_size_t nbyte); +} +{ + * This function writes multiple strings into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param vec The strings to add (address plus length for each) + * @param nvec The number of entries in iovec + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + const struct iovec *vec, + apr_size_t nvec); +} +{ + * This function writes a string into a bucket brigade. + * @param bb The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param str The string to add + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb, + apr_brigade_flush flush, void *ctx, + const char *str); +} +{ + * This function writes a character into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param c The character to add + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b, + apr_brigade_flush flush, void *ctx, + const char c); +} +{ + * This function writes an unspecified number of strings into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param ... The strings to add + * @return APR_SUCCESS or error code + } +{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, ...); +} +{ + * Evaluate a printf and put the resulting string at the end + * of the bucket brigade. + * @param b The brigade to write to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param fmt The format of the string to write + * @param ... The arguments to fill out the format + * @return APR_SUCCESS or error code + } +{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + const char *fmt, ...) + __attribute__((format(printf,4,5))); +} +{ + * Evaluate a printf and put the resulting string at the end + * of the bucket brigade. + * @param b The brigade to write to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param fmt The format of the string to write + * @param va The arguments to fill out the format + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + const char *fmt, va_list va); +} +{ ***** Bucket freelist functions ***** } +{ + * Create a bucket allocator. + * @param p This pool's underlying apr_allocator_t is used to allocate memory + * for the bucket allocator. When the pool is destroyed, the bucket + * allocator's cleanup routine will free all memory that has been + * allocated from it. + * @remark The reason the allocator gets its memory from the pool's + * apr_allocator_t rather than from the pool itself is because + * the bucket allocator will free large memory blocks back to the + * allocator when it's done with them, thereby preventing memory + * footprint growth that would occur if we allocated from the pool. + * @warning The allocator must never be used by more than one thread at a time. + } +//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p); + +{ + * Create a bucket allocator. + * @param allocator This apr_allocator_t is used to allocate both the bucket + * allocator and all memory handed out by the bucket allocator. The + * caller is responsible for destroying the bucket allocator and the + * apr_allocator_t -- no automatic cleanups will happen. + * @warning The allocator must never be used by more than one thread at a time. + } +//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex(apr_allocator_t *allocator); + +{ + * Destroy a bucket allocator. + * @param list The allocator to be destroyed + } +//APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list); + +{ + * Allocate memory for use by the buckets. + * @param size The amount to allocate. + * @param list The allocator from which to allocate the memory. + } +//APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list); + +{ + * Free memory previously allocated with apr_bucket_alloc(). + * @param block The block of memory to be freed. + } +//APU_DECLARE_NONSTD(void) apr_bucket_free(void *block); + + +{ ***** Bucket Functions ***** } +{ + * Free the resources used by a bucket. If multiple buckets refer to + * the same resource it is freed when the last one goes away. + * @see apr_bucket_delete() + * @param e The bucket to destroy + } +{#define apr_bucket_destroy(e) do begin + (e)->type->destroy((e)->data); \ + (e)->free(e); \ + end while (0)} + +{ + * Delete a bucket by removing it from its brigade (if any) and then + * destroying it. + * @remark This mainly acts as an aid in avoiding code verbosity. It is + * the preferred exact equivalent to: + *
+ * APR_BUCKET_REMOVE(e); + * apr_bucket_destroy(e); + *+ * @param e The bucket to delete + } +{#define apr_bucket_delete(e) do begin + APR_BUCKET_REMOVE(e); \ + apr_bucket_destroy(e); \ + end while (0)} + +{ + * read the data from the bucket + * @param e The bucket to read from + * @param str The location to store the data in + * @param len The amount of data read + * @param block Whether the read function blocks + } +//#define apr_bucket_read(e,str,len,block) (e)->type->read(e, str, len, block) + +{ + * Setaside data so that stack data is not destroyed on returning from + * the function + * @param e The bucket to setaside + * @param p The pool to setaside into + } +//#define apr_bucket_setaside(e,p) (e)->type->setaside(e,p) + +{ + * Split one bucket in two. + * @param e The bucket to split + * @param point The offset to split the bucket at + } +//#define apr_bucket_split(e,point) (e)->type->split(e, point) + +{ + * Copy a bucket. + * @param e The bucket to copy + * @param c Returns a pointer to the new bucket + } +//#define apr_bucket_copy(e,c) (e)->type->copy(e, c) + +{ Bucket type handling } + +{ + * This function simply returns APR_SUCCESS to denote that the bucket does + * not require anything to happen for its setaside() function. This is + * appropriate for buckets that have "immortal" data -- the data will live + * at least as long as the bucket. + * @param data The bucket to setaside + * @param pool The pool defining the desired lifetime of the bucket data + * @return APR_SUCCESS + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data, + apr_pool_t *pool); +} +{ + * A place holder function that signifies that the setaside function was not + * implemented for this bucket + * @param data The bucket to setaside + * @param pool The pool defining the desired lifetime of the bucket data + * @return APR_ENOTIMPL + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data, + apr_pool_t *pool); +} +{ + * A place holder function that signifies that the split function was not + * implemented for this bucket + * @param data The bucket to split + * @param point The location to split the bucket + * @return APR_ENOTIMPL + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data, + apr_size_t point); +} +{ + * A place holder function that signifies that the copy function was not + * implemented for this bucket + * @param e The bucket to copy + * @param c Returns a pointer to the new bucket + * @return APR_ENOTIMPL + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_copy_notimpl(apr_bucket *e, + apr_bucket **c); +} +{ + * A place holder function that signifies that this bucket does not need + * to do anything special to be destroyed. That's only the case for buckets + * that either have no data (metadata buckets) or buckets whose data pointer + * points to something that's not a bucket-type-specific structure, as with + * simple buckets where data points to a string and pipe buckets where data + * points directly to the apr_file_t. + * @param data The bucket data to destroy + } +//APU_DECLARE_NONSTD(void) apr_bucket_destroy_noop(void *data); + +{ + * There is no apr_bucket_destroy_notimpl, because destruction is required + * to be implemented (it could be a noop, but only if that makes sense for + * the bucket type) + } + +{ There is no apr_bucket_read_notimpl, because it is a required function + } + + +{ 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. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_flush; +{ + * 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 + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_eos; +{ + * The FILE bucket type. This bucket represents a file on disk + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_file; +{ + * The HEAP bucket type. This bucket represents a data allocated from the + * heap. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_heap; +//#if APR_HAS_MMAP +{ + * The MMAP bucket type. This bucket represents an MMAP'ed file + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_mmap; +//#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. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pool; +{ + * The PIPE bucket type. This bucket represents a pipe to another program. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pipe; +{ + * 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 + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_immortal; +{ + * 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 + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_transient; +{ + * The SOCKET bucket type. This bucket represents a socket to another machine + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_socket; + + +{ ***** Simple buckets ***** } + +{ + * Split a simple bucket into two at the given point. Most non-reference + * counting buckets that allow multiple references to the same block of + * data (eg transient and immortal) will use this as their split function + * without any additional type-specific handling. + * @param b The bucket to be split + * @param point The offset of the first byte in the new bucket + * @return APR_EINVAL if the point is not within the bucket; + * APR_ENOMEM if allocation failed; + * or APR_SUCCESS + } +//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *b, +// apr_size_t point); + +{ + * Copy a simple bucket. Most non-reference-counting buckets that allow + * multiple references to the same block of data (eg transient and immortal) + * will use this as their copy function without any additional type-specific + * handling. + * @param a The bucket to copy + * @param b Returns a pointer to the new bucket + * @return APR_ENOMEM if allocation failed; + * or APR_SUCCESS + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a, + apr_bucket **b); + +} +{ ***** Shared, reference-counted buckets ***** } + +{ + * Initialize a bucket containing reference-counted data that may be + * shared. The caller must allocate the bucket if necessary and + * initialize its type-dependent fields, and allocate and initialize + * its own private data structure. This function should only be called + * by type-specific bucket creation functions. + * @param b The bucket to initialize + * @param data A pointer to the private data structure + * with the reference count at the start + * @param start The start of the data in the bucket + * relative to the private base pointer + * @param length The length of the data in the bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data, + apr_off_t start, + apr_size_t length); +} +{ + * Decrement the refcount of the data in the bucket. This function + * should only be called by type-specific bucket destruction functions. + * @param data The private data pointer from the bucket to be destroyed + * @return TRUE or FALSE; TRUE if the reference count is now + * zero, indicating that the shared resource itself can + * be destroyed by the caller. + } +//APU_DECLARE(int) apr_bucket_shared_destroy(void *data); + +{ + * Split a bucket into two at the given point, and adjust the refcount + * to the underlying data. Most reference-counting bucket types will + * be able to use this function as their split function without any + * additional type-specific handling. + * @param b The bucket to be split + * @param point The offset of the first byte in the new bucket + * @return APR_EINVAL if the point is not within the bucket; + * APR_ENOMEM if allocation failed; + * or APR_SUCCESS + } +//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *b, +// apr_size_t point); + +{ + * Copy a refcounted bucket, incrementing the reference count. Most + * reference-counting bucket types will be able to use this function + * as their copy function without any additional type-specific handling. + * @param a The bucket to copy + * @param b Returns a pointer to the new bucket + * @return APR_ENOMEM if allocation failed; + or APR_SUCCESS + } +//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a, +// apr_bucket **b); + + +{ ***** Functions to Create Buckets of varying types ***** } +{ + * Each bucket type foo has two initialization functions: + * apr_bucket_foo_make which sets up some already-allocated memory as a + * bucket of type foo; and apr_bucket_foo_create which allocates memory + * for the bucket, calls apr_bucket_make_foo, and initializes the + * bucket's list pointers. The apr_bucket_foo_make functions are used + * inside the bucket code to change the type of buckets in place; + * other code should call apr_bucket_foo_create. All the initialization + * functions change nothing if they fail. + } + +{ + * Create an End of Stream bucket. This indicates that there is no more data + * coming from down the filter stack. All filters should flush at this point. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_eos_create(apr_bucket_alloc_t *list); + +{ + * Make the bucket passed in an EOS bucket. This indicates that there is no + * more data coming from down the filter stack. All filters should flush at + * this point. + * @param b The bucket to make into an EOS bucket + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_eos_make(apr_bucket *b); + +{ + * Create a flush bucket. This indicates that filters should flush their + * data. There is no guarantee that they will flush it, but this is the + * best we can do. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_flush_create(apr_bucket_alloc_t *list); + +{ + * Make the bucket passed in a FLUSH bucket. This indicates that filters + * should flush their data. There is no guarantee that they will flush it, + * but this is the best we can do. + * @param b The bucket to make into a FLUSH bucket + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_flush_make(apr_bucket *b); + +{ + * Create a bucket referring to long-lived data. + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf, + apr_size_t nbyte, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to long-lived data + * @param b The bucket to make into a IMMORTAL bucket + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_immortal_make(apr_bucket *b, + const char *buf, + apr_size_t nbyte); +} +{ + * Create a bucket referring to data on the stack. + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf, + apr_size_t nbyte, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to stack data + * @param b The bucket to make into a TRANSIENT bucket + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_transient_make(apr_bucket *b, + const char *buf, + apr_size_t nbyte); +} +{ + * Create a bucket referring to memory on the heap. If the caller asks + * for the data to be copied, this function always allocates 4K of + * memory so that more data can be added to the bucket without + * requiring another allocation. Therefore not all the data may be put + * into the bucket. If copying is not requested then the bucket takes + * over responsibility for free()ing the memory. + * @param buf The buffer to insert into the bucket + * @param nbyte The size of the buffer to insert. + * @param free_func Function to use to free the data; NULL indicates that the + * bucket should make a copy of the data + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf, + apr_size_t nbyte, + void ( *free_func)(void *data), + apr_bucket_alloc_t *list);} +{ + * Make the bucket passed in a bucket refer to heap data + * @param b The bucket to make into a HEAP bucket + * @param buf The buffer to insert into the bucket + * @param nbyte The size of the buffer to insert. + * @param free_func Function to use to free the data; NULL indicates that the + * bucket should make a copy of the data + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b, const char *buf, + apr_size_t nbyte, + void ( *free_func)(void *data));} + +{ + * Create a bucket referring to memory allocated from a pool. + * + * @param buf The buffer to insert into the bucket + * @param length The number of bytes referred to by this bucket + * @param pool The pool the memory was allocated from + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf, + apr_size_t length, + apr_pool_t *pool, + apr_bucket_alloc_t *list);} + +{ + * Make the bucket passed in a bucket refer to pool data + * @param b The bucket to make into a pool bucket + * @param buf The buffer to insert into the bucket + * @param length The number of bytes referred to by this bucket + * @param pool The pool the memory was allocated from + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b, const char *buf, + apr_size_t length, + apr_pool_t *pool);} + +//#if APR_HAS_MMAP +{ + * Create a bucket referring to mmap()ed memory. + * @param mm The mmap to insert into the bucket + * @param start The offset of the first byte in the mmap + * that this bucket refers to + * @param length The number of bytes referred to by this bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm, + apr_off_t start, + apr_size_t length, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to an MMAP'ed file + * @param b The bucket to make into a MMAP bucket + * @param mm The mmap to insert into the bucket + * @param start The offset of the first byte in the mmap + * that this bucket refers to + * @param length The number of bytes referred to by this bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm, + apr_off_t start, + apr_size_t length); +#endif} + +{ + * Create a bucket referring to a socket. + * @param thissock The socket to put in the bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *thissock, + apr_bucket_alloc_t *list);} +{ + * Make the bucket passed in a bucket refer to a socket + * @param b The bucket to make into a SOCKET bucket + * @param thissock The socket to put in the bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_socket_make(apr_bucket *b, + apr_socket_t *thissock);} + +{ + * Create a bucket referring to a pipe. + * @param thispipe The pipe to put in the bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *thispipe, + apr_bucket_alloc_t *list);} + +{ + * Make the bucket passed in a bucket refer to a pipe + * @param b The bucket to make into a PIPE bucket + * @param thispipe The pipe to put in the bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pipe_make(apr_bucket *b, + apr_file_t *thispipe);} + +{ + * Create a bucket referring to a file. + * @param fd The file to put in the bucket + * @param offset The offset where the data of interest begins in the file + * @param len The amount of data in the file we are interested in + * @param p The pool into which any needed structures should be created + * while reading from this file bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd, + apr_off_t offset, + apr_size_t len, + apr_pool_t *p, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to a file + * @param b The bucket to make into a FILE bucket + * @param fd The file to put in the bucket + * @param offset The offset where the data of interest begins in the file + * @param len The amount of data in the file we are interested in + * @param p The pool into which any needed structures should be created + * while reading from this file bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd, + apr_off_t offset, + apr_size_t len, apr_pool_t *p); +} +{ + * Enable or disable memory-mapping for a FILE bucket (default is enabled) + * @param b The bucket + * @param enabled Whether memory-mapping should be enabled + * @return APR_SUCCESS normally, or an error code if the operation fails + } +{APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *b, + int enabled);} + diff --git a/httpd/httpd_2_0/apr/apr_dso.inc b/httpd/httpd_2_0/apr/apr_dso.inc new file mode 100644 index 000000000..ec41ea6d6 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_dso.inc @@ -0,0 +1,95 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_dso.h + * @brief APR Dynamic Object Handling Routines + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h"} + +{ + * @defgroup apr_dso Dynamic Object Handling + * @ingroup APR + } + +{$define APR_HAS_DSO} + +{$if defined(APR_HAS_DSO) or defined(DOXYGEN)} + +{ + * Structure for referencing dynamic objects + } +type + apr_dso_handle_t = record + end; + Papr_dso_handle_t = ^apr_dso_handle_t; + PPapr_dso_handle_t = ^Papr_dso_handle_t; + +{ + * Structure for referencing symbols from dynamic objects + } + apr_dso_handle_sym_t = Pointer; + Papr_dso_handle_sym_t = ^apr_dso_handle_sym_t; + PPapr_dso_handle_sym_t = ^Papr_dso_handle_sym_t; + +{ + * Load a DSO library. + * @param res_handle Location to store new handle for the DSO. + * @param path Path to the DSO library + * @param ctx Pool to use. + * @bug We aught to provide an alternative to RTLD_GLOBAL, which + * is the only supported method of loading DSOs today. + } +function apr_dso_load(res_handle: PPapr_dso_handle_t; const path: PChar; + ctx: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_load' + LibSuff12; + +{ + * Close a DSO library. + * @param handle handle to close. + } +function apr_dso_unload(handle: Papr_dso_handle_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_unload' + LibSuff4; + +{ + * Load a symbol from a DSO handle. + * @param ressym Location to store the loaded symbol + * @param handle handle to load the symbol from. + * @param symname Name of the symbol to load. + } +function apr_dso_sym(ressym: Papr_dso_handle_t; handle: Papr_dso_handle_t; + const symname: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_sym' + LibSuff12; + +{ + * Report more information when a DSO function fails. + * @param dso The dso handle that has been opened + * @param buf Location to store the dso error + * @param bufsize The size of the provided buffer + } +function apr_dso_error(dso: Papr_dso_handle_t; buf: PChar; + bufsize: apr_size_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_error' + LibSuff12; + +{$endif} + diff --git a/httpd/httpd_2_0/apr/apr_errno.inc b/httpd/httpd_2_0/apr/apr_errno.inc new file mode 100644 index 000000000..1bbb7f002 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_errno.inc @@ -0,0 +1,1191 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_errno.h + * @brief APR Error Codes + } + +{#include "apr.h" + +#if APR_HAVE_ERRNO_H +#include
+ * APR ERROR VALUES + * APR_ENOSTAT APR was unable to perform a stat on the file + * APR_ENOPOOL APR was not provided a pool with which to allocate memory + * APR_EBADDATE APR was given an invalid date + * APR_EINVALSOCK APR was given an invalid socket + * APR_ENOPROC APR was not given a process structure + * APR_ENOTIME APR was not given a time structure + * APR_ENODIR APR was not given a directory structure + * APR_ENOLOCK APR was not given a lock structure + * APR_ENOPOLL APR was not given a poll structure + * APR_ENOSOCKET APR was not given a socket + * APR_ENOTHREAD APR was not given a thread structure + * APR_ENOTHDKEY APR was not given a thread key structure + * APR_ENOSHMAVAIL There is no more shared memory available + * APR_EDSOOPEN APR was unable to open the dso object. For more + * information call apr_dso_error(). + * APR_EGENERAL General failure (specific information not available) + * APR_EBADIP The specified IP address is invalid + * APR_EBADMASK The specified netmask is invalid + * APR_ESYMNOTFOUND Could not find the requested symbol + *+ * + *
+ * APR STATUS VALUES + * APR_INCHILD Program is currently executing in the child + * APR_INPARENT Program is currently executing in the parent + * APR_DETACH The thread is detached + * APR_NOTDETACH The thread is not detached + * APR_CHILD_DONE The child has finished executing + * APR_CHILD_NOTDONE The child has not finished executing + * APR_TIMEUP The operation did not finish before the timeout + * APR_INCOMPLETE The operation was incomplete although some processing + * was performed and the results are partially valid + * APR_BADCH Getopt found an option not in the option string + * APR_BADARG Getopt found an option that is missing an argument + * and an argument was specified in the option string + * APR_EOF APR has encountered the end of the file + * APR_NOTFOUND APR was unable to find the socket in the poll structure + * APR_ANONYMOUS APR is using anonymous shared memory + * APR_FILEBASED APR is using a file name as the key to the shared memory + * APR_KEYBASED APR is using a shared key as the key to the shared memory + * APR_EINIT Ininitalizer value. If no option has been found, but + * the status variable requires a value, this should be used + * APR_ENOTIMPL The APR function has not been implemented on this + * platform, either because nobody has gotten to it yet, + * or the function is impossible on this platform. + * APR_EMISMATCH Two passwords do not match. + * APR_EABSOLUTE The given path was absolute. + * APR_ERELATIVE The given path was relative. + * APR_EINCOMPLETE The given path was neither relative nor absolute. + * APR_EABOVEROOT The given path was above the root path. + * APR_EBUSY The given lock was busy. + * APR_EPROC_UNKNOWN The given process wasn't recognized by APR + *+ } +{ @see APR_STATUS_IS_ENOSTAT } + APR_ENOSTAT = (APR_OS_START_ERROR + 1); +{ @see APR_STATUS_IS_ENOPOOL } + APR_ENOPOOL = (APR_OS_START_ERROR + 2); +{ empty slot: +3 } +{ @see APR_STATUS_IS_EBADDATE } + APR_EBADDATE = (APR_OS_START_ERROR + 4); +{ @see APR_STATUS_IS_EINVALSOCK } + APR_EINVALSOCK = (APR_OS_START_ERROR + 5); +{ @see APR_STATUS_IS_ENOPROC } + APR_ENOPROC = (APR_OS_START_ERROR + 6); +{ @see APR_STATUS_IS_ENOTIME } + APR_ENOTIME = (APR_OS_START_ERROR + 7); +{ @see APR_STATUS_IS_ENODIR } + APR_ENODIR = (APR_OS_START_ERROR + 8); +{ @see APR_STATUS_IS_ENOLOCK } + APR_ENOLOCK = (APR_OS_START_ERROR + 9); +{ @see APR_STATUS_IS_ENOPOLL } + APR_ENOPOLL = (APR_OS_START_ERROR + 10); +{ @see APR_STATUS_IS_ENOSOCKET } + APR_ENOSOCKET = (APR_OS_START_ERROR + 11); +{ @see APR_STATUS_IS_ENOTHREAD } + APR_ENOTHREAD = (APR_OS_START_ERROR + 12); +{ @see APR_STATUS_IS_ENOTHDKEY } + APR_ENOTHDKEY = (APR_OS_START_ERROR + 13); +{ @see APR_STATUS_IS_EGENERAL } + APR_EGENERAL = (APR_OS_START_ERROR + 14); +{ @see APR_STATUS_IS_ENOSHMAVAIL } + APR_ENOSHMAVAIL = (APR_OS_START_ERROR + 15); +{ @see APR_STATUS_IS_EBADIP } + APR_EBADIP = (APR_OS_START_ERROR + 16); +{ @see APR_STATUS_IS_EBADMASK } + APR_EBADMASK = (APR_OS_START_ERROR + 17); +{ empty slot: +18 } +{ @see APR_STATUS_IS_EDSOPEN } + APR_EDSOOPEN = (APR_OS_START_ERROR + 19); +{ @see APR_STATUS_IS_EABSOLUTE } + APR_EABSOLUTE = (APR_OS_START_ERROR + 20); +{ @see APR_STATUS_IS_ERELATIVE } + APR_ERELATIVE = (APR_OS_START_ERROR + 21); +{ @see APR_STATUS_IS_EINCOMPLETE } + APR_EINCOMPLETE = (APR_OS_START_ERROR + 22); +{ @see APR_STATUS_IS_EABOVEROOT } + APR_EABOVEROOT = (APR_OS_START_ERROR + 23); +{ @see APR_STATUS_IS_EBADPATH } + APR_EBADPATH = (APR_OS_START_ERROR + 24); +{ @see APR_STATUS_IS_EPATHWILD } + APR_EPATHWILD = (APR_OS_START_ERROR + 25); +{ @see APR_STATUS_IS_ESYMNOTFOUND } + APR_ESYMNOTFOUND = (APR_OS_START_ERROR + 26); +{ @see APR_STATUS_IS_EPROC_UNKNOWN } + APR_EPROC_UNKNOWN = (APR_OS_START_ERROR + 27); + +{ + * @defgroup APR_STATUS_IS Status Value Tests + * @warning For any particular error condition, more than one of these tests + * may match. This is because platform-specific error codes may not + * always match the semantics of the POSIX codes these tests (and the + * correcponding APR error codes) are named after. A notable example + * are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on + * Win32 platforms. The programmer should always be aware of this and + * adjust the order of the tests accordingly. + } +{ + * APR was unable to perform a stat on the file + * @warning always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ENOSTAT(s) ((s) == APR_ENOSTAT) +{ + * APR was not provided a pool with which to allocate memory + * @warning always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ENOPOOL(s) ((s) == APR_ENOPOOL) +{ APR was given an invalid date } +//#define APR_STATUS_IS_EBADDATE(s) ((s) == APR_EBADDATE) +{ APR was given an invalid socket } +//#define APR_STATUS_IS_EINVALSOCK(s) ((s) == APR_EINVALSOCK) +{ APR was not given a process structure } +//#define APR_STATUS_IS_ENOPROC(s) ((s) == APR_ENOPROC) +{ APR was not given a time structure } +//#define APR_STATUS_IS_ENOTIME(s) ((s) == APR_ENOTIME) +{ APR was not given a directory structure } +//#define APR_STATUS_IS_ENODIR(s) ((s) == APR_ENODIR) +{ APR was not given a lock structure } +//#define APR_STATUS_IS_ENOLOCK(s) ((s) == APR_ENOLOCK) +{ APR was not given a poll structure } +//#define APR_STATUS_IS_ENOPOLL(s) ((s) == APR_ENOPOLL) +{ APR was not given a socket } +//#define APR_STATUS_IS_ENOSOCKET(s) ((s) == APR_ENOSOCKET) +{ APR was not given a thread structure } +//#define APR_STATUS_IS_ENOTHREAD(s) ((s) == APR_ENOTHREAD) +{ APR was not given a thread key structure } +//#define APR_STATUS_IS_ENOTHDKEY(s) ((s) == APR_ENOTHDKEY) +{ Generic Error which can not be put into another spot } +//#define APR_STATUS_IS_EGENERAL(s) ((s) == APR_EGENERAL) +{ There is no more shared memory available } +//#define APR_STATUS_IS_ENOSHMAVAIL(s) ((s) == APR_ENOSHMAVAIL) +{ The specified IP address is invalid } +//#define APR_STATUS_IS_EBADIP(s) ((s) == APR_EBADIP) +{ The specified netmask is invalid } +//#define APR_STATUS_IS_EBADMASK(s) ((s) == APR_EBADMASK) +{ empty slot: +18 } +{ + * APR was unable to open the dso object. + * For more information call apr_dso_error(). + } +//#if defined(WIN32) +//#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \ +// || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND) +//#else +//#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN) +//#endif +{ The given path was absolute. } +//#define APR_STATUS_IS_EABSOLUTE(s) ((s) == APR_EABSOLUTE) +{ The given path was relative. } +//#define APR_STATUS_IS_ERELATIVE(s) ((s) == APR_ERELATIVE) +{ The given path was neither relative nor absolute. } +//#define APR_STATUS_IS_EINCOMPLETE(s) ((s) == APR_EINCOMPLETE) +{ The given path was above the root path. } +//#define APR_STATUS_IS_EABOVEROOT(s) ((s) == APR_EABOVEROOT) +{ The given path was bad. } +//#define APR_STATUS_IS_EBADPATH(s) ((s) == APR_EBADPATH) +{ The given path contained wildcards. } +//#define APR_STATUS_IS_EPATHWILD(s) ((s) == APR_EPATHWILD) +{ Could not find the requested symbol. + * For more information call apr_dso_error(). + } +//#if defined(WIN32) +//#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \ +// || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND) +//#else +//#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND) +//#endif +{ The given process was not recognized by APR. } +//#define APR_STATUS_IS_EPROC_UNKNOWN(s) ((s) == APR_EPROC_UNKNOWN) + +{ + * @addtogroup APR_Error + } +{ @see APR_STATUS_IS_INCHILD } + APR_INCHILD = (APR_OS_START_STATUS + 1); +{ @see APR_STATUS_IS_INPARENT } + APR_INPARENT = (APR_OS_START_STATUS + 2); +{ @see APR_STATUS_IS_DETACH } + APR_DETACH = (APR_OS_START_STATUS + 3); +{ @see APR_STATUS_IS_NOTDETACH } + APR_NOTDETACH = (APR_OS_START_STATUS + 4); +{ @see APR_STATUS_IS_CHILD_DONE } + APR_CHILD_DONE = (APR_OS_START_STATUS + 5); +{ @see APR_STATUS_IS_CHILD_NOTDONE } + APR_CHILD_NOTDONE = (APR_OS_START_STATUS + 6); +{ @see APR_STATUS_IS_TIMEUP } + APR_TIMEUP = (APR_OS_START_STATUS + 7); +{ @see APR_STATUS_IS_INCOMPLETE } + APR_INCOMPLETE = (APR_OS_START_STATUS + 8); +{ empty slot: +9 } +{ empty slot: +10 } +{ empty slot: +11 } +{ @see APR_STATUS_IS_BADCH } + APR_BADCH = (APR_OS_START_STATUS + 12); +{ @see APR_STATUS_IS_BADARG } + APR_BADARG = (APR_OS_START_STATUS + 13); +{ @see APR_STATUS_IS_EOF } + APR_EOF = (APR_OS_START_STATUS + 14); +{ @see APR_STATUS_IS_NOTFOUND } + APR_NOTFOUND = (APR_OS_START_STATUS + 15); +{ empty slot: +16 } +{ empty slot: +17 } +{ empty slot: +18 } +{ @see APR_STATUS_IS_ANONYMOUS } + APR_ANONYMOUS = (APR_OS_START_STATUS + 19); +{ @see APR_STATUS_IS_FILEBASED } + APR_FILEBASED = (APR_OS_START_STATUS + 20); +{ @see APR_STATUS_IS_KEYBASED } + APR_KEYBASED = (APR_OS_START_STATUS + 21); +{ @see APR_STATUS_IS_EINIT } + APR_EINIT = (APR_OS_START_STATUS + 22); +{ @see APR_STATUS_IS_ENOTIMPL } + APR_ENOTIMPL = (APR_OS_START_STATUS + 23); +{ @see APR_STATUS_IS_EMISMATCH } + APR_EMISMATCH = (APR_OS_START_STATUS + 24); +{ @see APR_STATUS_IS_EBUSY } + APR_EBUSY = (APR_OS_START_STATUS + 25); + +{ + * @addtogroup APR_STATUS_IS + } +{ + * Program is currently executing in the child + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code } +//#define APR_STATUS_IS_INCHILD(s) ((s) == APR_INCHILD) +{ + * Program is currently executing in the parent + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_INPARENT(s) ((s) == APR_INPARENT) +{ + * The thread is detached + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_DETACH(s) ((s) == APR_DETACH) +{ + * The thread is not detached + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_NOTDETACH(s) ((s) == APR_NOTDETACH) +{ + * The child has finished executing + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_CHILD_DONE(s) ((s) == APR_CHILD_DONE) +{ + * The child has not finished executing + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_CHILD_NOTDONE(s) ((s) == APR_CHILD_NOTDONE) +{ + * The operation did not finish before the timeout + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP) +{ + * The operation was incomplete although some processing was performed + * and the results are partially valid. + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_INCOMPLETE(s) ((s) == APR_INCOMPLETE) +{ empty slot: +9 } +{ empty slot: +10 } +{ empty slot: +11 } +{ + * Getopt found an option not in the option string + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_BADCH(s) ((s) == APR_BADCH) +{ + * Getopt found an option not in the option string and an argument was + * specified in the option string + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_BADARG(s) ((s) == APR_BADARG) +{ + * APR has encountered the end of the file + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EOF(s) ((s) == APR_EOF) +{ + * APR was unable to find the socket in the poll structure + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_NOTFOUND(s) ((s) == APR_NOTFOUND) +{ empty slot: +16 } +{ empty slot: +17 } +{ empty slot: +18 } +{ + * APR is using anonymous shared memory + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ANONYMOUS(s) ((s) == APR_ANONYMOUS) +{ + * APR is using a file name as the key to the shared memory + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_FILEBASED(s) ((s) == APR_FILEBASED) +{ + * APR is using a shared key as the key to the shared memory + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_KEYBASED(s) ((s) == APR_KEYBASED) +{ + * Ininitalizer value. If no option has been found, but + * the status variable requires a value, this should be used + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EINIT(s) ((s) == APR_EINIT) +{ + * The APR function has not been implemented on this + * platform, either because nobody has gotten to it yet, + * or the function is impossible on this platform. + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ENOTIMPL(s) ((s) == APR_ENOTIMPL) +{ + * Two passwords do not match. + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EMISMATCH(s) ((s) == APR_EMISMATCH) +{ + * The given lock was busy + * @warning always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EBUSY(s) ((s) == APR_EBUSY) + +{ + * @addtogroup APR_Error APR Error Values + } +{ APR CANONICAL ERROR VALUES } +{ @see APR_STATUS_IS_EACCES } +{#ifdef EACCES +#define APR_EACCES EACCES +#else +#define APR_EACCES (APR_OS_START_CANONERR + 1) +#endif +} +{ @see APR_STATUS_IS_EXIST } +{#ifdef EEXIST +#define APR_EEXIST EEXIST +#else +#define APR_EEXIST (APR_OS_START_CANONERR + 2) +#endif +} +{ @see APR_STATUS_IS_ENAMETOOLONG } +{#ifdef ENAMETOOLONG +#define APR_ENAMETOOLONG ENAMETOOLONG +#else +#define APR_ENAMETOOLONG (APR_OS_START_CANONERR + 3) +#endif +} +{ @see APR_STATUS_IS_ENOENT } +{#ifdef ENOENT +#define APR_ENOENT ENOENT +#else +#define APR_ENOENT (APR_OS_START_CANONERR + 4) +#endif +} +{ @see APR_STATUS_IS_ENOTDIR } +{#ifdef ENOTDIR +#define APR_ENOTDIR ENOTDIR +#else +#define APR_ENOTDIR (APR_OS_START_CANONERR + 5) +#endif +} +{ @see APR_STATUS_IS_ENOSPC } +{#ifdef ENOSPC +#define APR_ENOSPC ENOSPC +#else +#define APR_ENOSPC (APR_OS_START_CANONERR + 6) +#endif +} +{ @see APR_STATUS_IS_ENOMEM } +{#ifdef ENOMEM +#define APR_ENOMEM ENOMEM +#else +#define APR_ENOMEM (APR_OS_START_CANONERR + 7) +#endif +} +{ @see APR_STATUS_IS_EMFILE } +{#ifdef EMFILE +#define APR_EMFILE EMFILE +#else +#define APR_EMFILE (APR_OS_START_CANONERR + 8) +#endif +} +{ @see APR_STATUS_IS_ENFILE } +{#ifdef ENFILE +#define APR_ENFILE ENFILE +#else +#define APR_ENFILE (APR_OS_START_CANONERR + 9) +#endif +} +{ @see APR_STATUS_IS_EBADF } +{#ifdef EBADF +#define APR_EBADF EBADF +#else +#define APR_EBADF (APR_OS_START_CANONERR + 10) +#endif +} +{ @see APR_STATUS_IS_EINVAL } +{#ifdef EINVAL +#define APR_EINVAL EINVAL +#else +#define APR_EINVAL (APR_OS_START_CANONERR + 11) +#endif +} +{ @see APR_STATUS_IS_ESPIPE } +{#ifdef ESPIPE +#define APR_ESPIPE ESPIPE +#else +#define APR_ESPIPE (APR_OS_START_CANONERR + 12) +#endif +} +{ + * @see APR_STATUS_IS_EAGAIN + * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value + } +{#ifdef EAGAIN +#define APR_EAGAIN EAGAIN +#elif defined(EWOULDBLOCK) +#define APR_EAGAIN EWOULDBLOCK +#else +#define APR_EAGAIN (APR_OS_START_CANONERR + 13) +#endif +} +{ @see APR_STATUS_IS_EINTR } +{#ifdef EINTR +#define APR_EINTR EINTR +#else +#define APR_EINTR (APR_OS_START_CANONERR + 14) +#endif +} +{ @see APR_STATUS_IS_ENOTSOCK } +{#ifdef ENOTSOCK +#define APR_ENOTSOCK ENOTSOCK +#else +#define APR_ENOTSOCK (APR_OS_START_CANONERR + 15) +#endif +} +{ @see APR_STATUS_IS_ECONNREFUSED } +{#ifdef ECONNREFUSED +#define APR_ECONNREFUSED ECONNREFUSED +#else +#define APR_ECONNREFUSED (APR_OS_START_CANONERR + 16) +#endif +} +{ @see APR_STATUS_IS_EINPROGRESS } +{#ifdef EINPROGRESS +#define APR_EINPROGRESS EINPROGRESS +#else +#define APR_EINPROGRESS (APR_OS_START_CANONERR + 17) +#endif +} +{ + * @see APR_STATUS_IS_ECONNABORTED + * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value + } + +{#ifdef ECONNABORTED +#define APR_ECONNABORTED ECONNABORTED +#else +#define APR_ECONNABORTED (APR_OS_START_CANONERR + 18) +#endif +} +{ @see APR_STATUS_IS_ECONNRESET } +{#ifdef ECONNRESET +#define APR_ECONNRESET ECONNRESET +#else +#define APR_ECONNRESET (APR_OS_START_CANONERR + 19) +#endif +} +{ @see APR_STATUS_IS_ETIMEDOUT } +{#ifdef ETIMEDOUT +#define APR_ETIMEDOUT ETIMEDOUT +#else +#define APR_ETIMEDOUT (APR_OS_START_CANONERR + 20) +#endif +} +{ @see APR_STATUS_IS_EHOSTUNREACH } +{#ifdef EHOSTUNREACH +#define APR_EHOSTUNREACH EHOSTUNREACH +#else +#define APR_EHOSTUNREACH (APR_OS_START_CANONERR + 21) +#endif +} +{ @see APR_STATUS_IS_ENETUNREACH } +{#ifdef ENETUNREACH +#define APR_ENETUNREACH ENETUNREACH +#else +#define APR_ENETUNREACH (APR_OS_START_CANONERR + 22) +#endif +} +{ @see APR_STATUS_IS_EFTYPE } +{#ifdef EFTYPE +#define APR_EFTYPE EFTYPE +#else +#define APR_EFTYPE (APR_OS_START_CANONERR + 23) +#endif +} +{ @see APR_STATUS_IS_EPIPE } +{#ifdef EPIPE +#define APR_EPIPE EPIPE +#else +#define APR_EPIPE (APR_OS_START_CANONERR + 24) +#endif +} +{ @see APR_STATUS_IS_EXDEV } +{#ifdef EXDEV +#define APR_EXDEV EXDEV +#else +#define APR_EXDEV (APR_OS_START_CANONERR + 25) +#endif +} +{ @see APR_STATUS_IS_ENOTEMPTY } +{#ifdef ENOTEMPTY +#define APR_ENOTEMPTY ENOTEMPTY +#else +#define APR_ENOTEMPTY (APR_OS_START_CANONERR + 26) +#endif + +#if defined(OS2) && !defined(DOXYGEN) + +#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) +#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) + +#define INCL_DOSERRORS +#define INCL_DOS +} +{ Leave these undefined. + * OS2 doesn't rely on the errno concept. + * The API calls always return a result codes which + * should be filtered through APR_FROM_OS_ERROR(). + * + * #define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) + * #define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) + } + +{ A special case, only socket calls require this; + } +{#define apr_get_netos_error() (APR_FROM_OS_ERROR(errno)) +#define apr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e)) +} +{ And this needs to be greped away for good: + } +{#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e)) + +#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS \ + || (s) == APR_OS_START_SYSERR + NO_ERROR) +} +{ These can't sit in a private header, so in spite of the extra size, + * they need to be made available here. + } + SOCBASEERR = 10000; + SOCEPERM = (SOCBASEERR+1); { Not owner } + SOCESRCH = (SOCBASEERR+3); { No such process } + SOCEINTR = (SOCBASEERR+4); { Interrupted system call } + SOCENXIO = (SOCBASEERR+6); { No such device or address } + SOCEBADF = (SOCBASEERR+9); { Bad file number } + SOCEACCES = (SOCBASEERR+13); { Permission denied } + SOCEFAULT = (SOCBASEERR+14); { Bad address } + SOCEINVAL = (SOCBASEERR+22); { Invalid argument } + SOCEMFILE = (SOCBASEERR+24); { Too many open files } + SOCEPIPE = (SOCBASEERR+32); { Broken pipe } + SOCEOS2ERR = (SOCBASEERR+100); { OS/2 Error } + SOCEWOULDBLOCK = (SOCBASEERR+35); { Operation would block } + SOCEINPROGRESS = (SOCBASEERR+36); { Operation now in progress } + SOCEALREADY = (SOCBASEERR+37); { Operation already in progress } + SOCENOTSOCK = (SOCBASEERR+38); { Socket operation on non-socket } + SOCEDESTADDRREQ = (SOCBASEERR+39); { Destination address required } + SOCEMSGSIZE = (SOCBASEERR+40); { Message too long } + SOCEPROTOTYPE = (SOCBASEERR+41); { Protocol wrong type for socket } + SOCENOPROTOOPT = (SOCBASEERR+42); { Protocol not available } + SOCEPROTONOSUPPORT = (SOCBASEERR+43); { Protocol not supported } + SOCESOCKTNOSUPPORT = (SOCBASEERR+44); { Socket type not supported } + SOCEOPNOTSUPP = (SOCBASEERR+45); { Operation not supported on socket } + SOCEPFNOSUPPORT = (SOCBASEERR+46); { Protocol family not supported } + SOCEAFNOSUPPORT = (SOCBASEERR+47); { Address family not supported by protocol family } + SOCEADDRINUSE = (SOCBASEERR+48); { Address already in use } + SOCEADDRNOTAVAIL = (SOCBASEERR+49); { Can't assign requested address } + SOCENETDOWN = (SOCBASEERR+50); { Network is down } + SOCENETUNREACH = (SOCBASEERR+51); { Network is unreachable } + SOCENETRESET = (SOCBASEERR+52); { Network dropped connection on reset } + SOCECONNABORTED = (SOCBASEERR+53); { Software caused connection abort } + SOCECONNRESET = (SOCBASEERR+54); { Connection reset by peer } + SOCENOBUFS = (SOCBASEERR+55); { No buffer space available } + SOCEISCONN = (SOCBASEERR+56); { Socket is already connected } + SOCENOTCONN = (SOCBASEERR+57); { Socket is not connected } + SOCESHUTDOWN = (SOCBASEERR+58); { Can't send after socket shutdown } + SOCETOOMANYREFS = (SOCBASEERR+59); { Too many references: can't splice } + SOCETIMEDOUT = (SOCBASEERR+60); { Connection timed out } + SOCECONNREFUSED = (SOCBASEERR+61); { Connection refused } + SOCELOOP = (SOCBASEERR+62); { Too many levels of symbolic links } + SOCENAMETOOLONG = (SOCBASEERR+63); { File name too long } + SOCEHOSTDOWN = (SOCBASEERR+64); { Host is down } + SOCEHOSTUNREACH = (SOCBASEERR+65); { No route to host } + SOCENOTEMPTY = (SOCBASEERR+66); { Directory not empty } + +{ APR CANONICAL ERROR TESTS } +{#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \ + || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION) +#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \ + || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \ + || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED) +#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \ + || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \ + || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG) +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \ + || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED) +#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) +#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \ + || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL) +#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) +#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \ + || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES) +#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE) +#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION) +#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \ + || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION) +#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ + || (s) == APR_OS_START_SYSERR + SOCEINTR) +#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ + || (s) == APR_OS_START_SYSERR + SOCENOTSOCK) +#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ + || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED) +#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ + || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS) +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == APR_OS_START_SYSERR + SOCECONNABORTED) +#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ + || (s) == APR_OS_START_SYSERR + SOCECONNRESET) +#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT) +#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ + || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH) +#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ + || (s) == APR_OS_START_SYSERR + SOCENETUNREACH) +#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) +#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \ + || (s) == APR_OS_START_SYSERR + SOCEPIPE) +#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE) +#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \ + || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED) +} +{ + Sorry, too tired to wrap this up for OS2... feel free to + fit the following into their best matches. + + ( ERROR_NO_SIGNAL_SENT, ESRCH ), + ( SOCEALREADY, EALREADY ), + ( SOCEDESTADDRREQ, EDESTADDRREQ ), + ( SOCEMSGSIZE, EMSGSIZE ), + ( SOCEPROTOTYPE, EPROTOTYPE ), + ( SOCENOPROTOOPT, ENOPROTOOPT ), + ( SOCEPROTONOSUPPORT, EPROTONOSUPPORT ), + ( SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT ), + ( SOCEOPNOTSUPP, EOPNOTSUPP ), + ( SOCEPFNOSUPPORT, EPFNOSUPPORT ), + ( SOCEAFNOSUPPORT, EAFNOSUPPORT ), + ( SOCEADDRINUSE, EADDRINUSE ), + ( SOCEADDRNOTAVAIL, EADDRNOTAVAIL ), + ( SOCENETDOWN, ENETDOWN ), + ( SOCENETRESET, ENETRESET ), + ( SOCENOBUFS, ENOBUFS ), + ( SOCEISCONN, EISCONN ), + ( SOCENOTCONN, ENOTCONN ), + ( SOCESHUTDOWN, ESHUTDOWN ), + ( SOCETOOMANYREFS, ETOOMANYREFS ), + ( SOCELOOP, ELOOP ), + ( SOCEHOSTDOWN, EHOSTDOWN ), + ( SOCENOTEMPTY, ENOTEMPTY ), + ( SOCEPIPE, EPIPE ) +} + +//#elif defined(WIN32) && !defined(DOXYGEN) { !defined(OS2) } + +{#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) +#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) + +#define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) +#define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))} + +{ A special case, only socket calls require this: + } +{#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) +#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) + +#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS \ + || (s) == APR_OS_START_SYSERR + ERROR_SUCCESS) +} +{ APR CANONICAL ERROR TESTS } +{#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \ + || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \ + || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \ + || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \ + || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \ + || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \ + || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION) +#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \ + || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS) +#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \ + || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \ + || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG) +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES) +#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR \ + || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE) +#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \ + || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL) +#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM \ + || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \ + || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY) +#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \ + || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES) +#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE) +#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \ + || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) +#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \ + || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \ + || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \ + || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \ + || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK) +#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ + || (s) == APR_OS_START_SYSERR + WSAEINTR) +#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ + || (s) == APR_OS_START_SYSERR + WSAENOTSOCK) +#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ + || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED) +#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ + || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS) +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == APR_OS_START_SYSERR + WSAECONNABORTED) +#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ + || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \ + || (s) == APR_OS_START_SYSERR + WSAECONNRESET) +#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) +#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH) +#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAENETUNREACH) +#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE \ + || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT) +#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE) +#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE) +#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \ + || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY) +} +//#elif defined(NETWARE) && !defined(DOXYGEN) { !defined(OS2) && !defined(WIN32) } +{ +#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) +#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) + +#define apr_get_os_error() (errno) +#define apr_set_os_error(e) (errno = (e)) +} +{ A special case, only socket calls require this: } +{#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) +#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) + +#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS) +} +{ APR CANONICAL ERROR TESTS } +{#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES) +#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST) +#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG) +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT) +#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) +#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC) +#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) +#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE) +#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF) +#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL) +#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE) + +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == EWOULDBLOCK \ + || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK) +#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ + || (s) == APR_OS_START_SYSERR + WSAEINTR) +#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ + || (s) == APR_OS_START_SYSERR + WSAENOTSOCK) +#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ + || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED) +#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ + || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS) +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == APR_OS_START_SYSERR + WSAECONNABORTED) +#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ + || (s) == APR_OS_START_SYSERR + WSAECONNRESET) +#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) +#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH) +#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAENETUNREACH) +#define APR_STATUS_IS_ENETDOWN(s) ((s) == APR_OS_START_SYSERR + WSAENETDOWN) +#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) +#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE) +#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV) +#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY) +} +//#else { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) } + +{ + * os error codes are clib error codes + } +{#define APR_FROM_OS_ERROR(e) (e) +#define APR_TO_OS_ERROR(e) (e) + +#define apr_get_os_error() (errno) +#define apr_set_os_error(e) (errno = (e)) +} +{ A special case, only socket calls require this: + } +//#define apr_get_netos_error() (errno) +//#define apr_set_netos_error(e) (errno = (e)) + +{ + * @addtogroup APR_STATUS_IS + } +{ no error } +//#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS) + +{ permission denied } +//#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES) +{ file exists } +//#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST) +{ path name is too long } +//#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG) +{ + * no such file or directory + * @remark + * EMVSCATLG can be returned by the automounter on z/OS for + * paths which do not exist. + } +{#ifdef EMVSCATLG +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ + || (s) == EMVSCATLG) +#else +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT) +#endif} +{ not a directory } +//#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) +{ no space left on device } +//#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC) +{ not enough memory } +//#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) +{ too many open files } +//#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE) +{ file table overflow } +//#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +{ bad file # } +//#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF) +{ invalid argument } +//#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL) +{ illegal seek } +//#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE) + +{ operation would block } +{#if !defined(EWOULDBLOCK) || !defined(EAGAIN) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN) +#elif (EWOULDBLOCK == EAGAIN) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN) +#else +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == EWOULDBLOCK) +#endif +} +{ interrupted system call } +//#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR) +{ socket operation on a non-socket } +//#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK) +{ Connection Refused } +//#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED) +{ operation now in progress } +//#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS) + +{ + * Software caused connection abort + * @remark + * EPROTO on certain older kernels really means ECONNABORTED, so we need to + * ignore it for them. See discussion in new-httpd archives nh.9701 & nh.9603 + * + * There is potentially a bug in Solaris 2.x x<6, and other boxes that + * implement tcp sockets in userland (i.e. on top of STREAMS). On these + * systems, EPROTO can actually result in a fatal loop. See PR#981 for + * example. It's hard to handle both uses of EPROTO. + } +{#ifdef EPROTO +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == EPROTO) +#else +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED) +#endif +} +{ Connection Reset by peer } +//#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET) +{ Operation timed out } +//#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT) +{ no route to host } +//#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH) +{ network is unreachable } +//#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH) +{ inappropiate file type or format } +//#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) +{ broken pipe } +//#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE) +{ cross device link } +//#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV) +{ Directory Not Empty } +//#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY || \ +// (s) == APR_EEXIST) + +//#endif { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) } + diff --git a/httpd/httpd_2_0/apr/apr_file_info.inc b/httpd/httpd_2_0/apr/apr_file_info.inc new file mode 100644 index 000000000..9436d85c2 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_file_info.inc @@ -0,0 +1,434 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_file_info.h + * @brief APR File Information + } + +{#include "apr.h" +#include "apr_user.h" +#include "apr_pools.h" +#include "apr_tables.h" +#include "apr_time.h" +#include "apr_errno.h" + +#if APR_HAVE_SYS_UIO_H +#include
+ * APR_FILEPATH_NATIVE Use native path seperators (e.g. '\' on Win32) + * APR_FILEPATH_TRUENAME Tests that the root exists, and makes it proper + *+ * @param p the pool to allocate the new path string from + * @remark on return, filepath points to the first non-root character in the + * given filepath. In the simplest example, given a filepath of "/foo", + * returns the rootpath of "/" and filepath points at "foo". This is far + * more complex on other platforms, which will canonicalize the root form + * to a consistant format, given the APR_FILEPATH_TRUENAME flag, and also + * test for the validity of that root (e.g., that a drive d:/ or network + * share //machine/foovol/). + * The function returns APR_ERELATIVE if filepath isn't rooted (an + * error), APR_EINCOMPLETE if the root path is ambigious (but potentially + * legitimate, e.g. "/" on Windows is incomplete because it doesn't specify + * the drive letter), or APR_EBADPATH if the root is simply invalid. + * APR_SUCCESS is returned if filepath is an absolute path. + } +function apr_filepath_root(const rootpath, filepath: PPChar; + flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_root' + LibSuff16; + +{ + * Merge additional file path onto the previously processed rootpath + * @param newpath the merged paths returned + * @param rootpath the root file path (NULL uses the current working path) + * @param addpath the path to add to the root path + * @param flags the desired APR_FILEPATH_ rules to apply when merging + * @param p the pool to allocate the new path string from + * @remark if the flag APR_FILEPATH_TRUENAME is given, and the addpath + * contains wildcard characters ('*', '?') on platforms that don't support + * such characters within filenames, the paths will be merged, but the + * result code will be APR_EPATHWILD, and all further segments will not + * reflect the true filenames including the wildcard and following segments. + } +function apr_filepath_merge(newpath: PPChar; const rootpath, addpath: PPChar; + flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_merge' + LibSuff20; + +{ + * Split a search path into separate components + * @param pathelts the returned components of the search path + * @param liststr the search path (e.g., getenv("PATH")) + * @param p the pool to allocate the array and path components from + * @remark empty path componenta do not become part of @a pathelts. + * @remark the path separator in @a liststr is system specific; + * e.g., ':' on Unix, ';' on Windows, etc. + } +function apr_filepath_list_split(pathelts: PPapr_array_header_t; + const liststr: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_list_split' + LibSuff12; + +{ + * Merge a list of search path components into a single search path + * @param liststr the returned search path; may be NULL if @a pathelts is empty + * @param pathelts the components of the search path + * @param p the pool to allocate the search path from + * @remark emtpy strings in the source array are ignored. + * @remark the path separator in @a liststr is system specific; + * e.g., ':' on Unix, ';' on Windows, etc. + } +function apr_filepath_list_merge(liststr: PPChar; + pathelts: Papr_array_header_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_list_merge' + LibSuff12; + +{ + * Return the default file path (for relative file names) + * @param path the default path string returned + * @param flags optional flag APR_FILEPATH_NATIVE to retrieve the + * default file path in os-native format. + * @param p the pool to allocate the default path string from + } +function apr_filepath_get(path: PPChar; flags: apr_int32_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_get' + LibSuff12; + +{ + * Set the default file path (for relative file names) + * @param path the default path returned + * @param p the pool to allocate any working storage + } +function apr_filepath_set(const path: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_set' + LibSuff8; + +const + { The FilePath character encoding is unknown } + APR_FILEPATH_ENCODING_UNKNOWN = 0; + + { The FilePath character encoding is locale-dependent } + APR_FILEPATH_ENCODING_LOCALE = 1; + + { The FilePath character encoding is UTF-8 } + APR_FILEPATH_ENCODING_UTF8 = 2; + +{ + * Determine the encoding used internally by the FilePath functions + * @param style points to a variable which receives the encoding style flag + * @param p the pool to allocate any working storage + * @remark Use @c apr_os_locale_encoding and/or @c apr_os_default_encoding + * to get the name of the path encoding if it's not UTF-8. + } +function apr_filepath_encoding(style: PInteger; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_encoding' + LibSuff8; + diff --git a/httpd/httpd_2_0/apr/apr_file_io.inc b/httpd/httpd_2_0/apr/apr_file_io.inc new file mode 100644 index 000000000..0d94ae577 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_file_io.inc @@ -0,0 +1,807 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_file_io.h + * @brief APR File I/O Handling + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_time.h" +#include "apr_errno.h"} +{.$include apr_file_info.inc} +{#include "apr_inherit.h"} + +//#define APR_WANT_STDIO {< for SEEK_* } +//#define APR_WANT_IOVEC {< for apr_file_writev } +//#include "apr_want.h" + +{ + * @defgroup apr_file_io File I/O Handling Functions + * @ingroup APR + } + +{ + * @defgroup apr_file_open_flags File Open Flags/Routines + } + +{ Note to implementors: Values in the range 0x00100000--0x80000000 + are reserved for platform-specific values. } + +const + APR_READ = $00001; {< Open the file for reading } + APR_WRITE = $00002; {< Open the file for writing } + APR_CREATE = $00004; {< Create the file if not there } + APR_APPEND = $00008; {< Append to the end of the file } + APR_TRUNCATE = $00010; {< Open the file and truncate to 0 length } + APR_BINARY = $00020; {< Open the file in binary mode } + APR_EXCL = $00040; {< Open should fail if APR_CREATE and file + exists. } + APR_BUFFERED = $00080; {< Open the file for buffered I/O } + APR_DELONCLOSE =$00100; {< Delete the file after close } + APR_XTHREAD = $00200; {< Platform dependent tag to open the file + for use across multiple threads } + APR_SHARELOCK = $00400; {< Platform dependent support for higher + level locked read/write access to support + writes across process/machines } + APR_FILE_NOCLEANUP =$00800; {< Do not register a cleanup when the file + is opened } + APR_SENDFILE_ENABLED =$01000; {< Advisory flag that this file should + support apr_sendfile operation } + APR_LARGEFILE = $04000; {< Platform dependent flag to enable large file + support; WARNING see below. } + +{ @warning The APR_LARGEFILE flag only has effect on some platforms + * where sizeof(apr_off_t) == 4. Where implemented, it allows opening + * and writing to a file which exceeds the size which can be + * represented by apr_off_t (2 gigabytes). When a file's size does + * exceed 2Gb, apr_file_info_get() will fail with an error on the + * descriptor, likewise apr_stat()/apr_lstat() will fail on the + * filename. apr_dir_read() will fail with APR_INCOMPLETE on a + * directory entry for a large file depending on the particular + * APR_FINFO_* flags. Generally, it is not recommended to use this + * flag. } + +{ + * @defgroup apr_file_seek_flags File Seek Flags + } + +{ + * @defgroup apr_file_attrs_set_flags File Attribute Flags + } + +{ flags for apr_file_attrs_set } + APR_FILE_ATTR_READONLY = $01; {< File is read-only } + APR_FILE_ATTR_EXECUTABLE =$02; {< File is executable } + APR_FILE_ATTR_HIDDEN = $04; {< File is hidden } + +{ File attributes } +type + apr_fileattrs_t = apr_uint32_t; + +{ should be same as whence type in lseek, POSIX defines this as int } + apr_seek_where_t = Integer; + +{ + * Structure for referencing files. + } + apr_file_t = record end; +// Papr_file_t = ^apr_file_t; + PPapr_file_t = ^Papr_file_t; + +{ File lock types/flags } +{ + * @defgroup apr_file_lock_types File Lock Types + } + +const + APR_FLOCK_SHARED = 1; {< Shared lock. More than one process + or thread can hold a shared lock + at any given time. Essentially, + this is a "read lock", preventing + writers from establishing an + exclusive lock. } + APR_FLOCK_EXCLUSIVE = 2; {< Exclusive lock. Only one process + may hold an exclusive lock at any + given time. This is analogous to + a "write lock". } + + APR_FLOCK_TYPEMASK = $000F; {< mask to extract lock type } + APR_FLOCK_NONBLOCK = $0010; {< do not block while acquiring the + file lock } +{ + * Open the specified file. + * @param newf The opened file descriptor. + * @param fname The full path to the file (using / on all systems) + * @param flag Or'ed value of: + *
+ * APR_READ open for reading + * APR_WRITE open for writing + * APR_CREATE create the file if not there + * APR_APPEND file ptr is set to end prior to all writes + * APR_TRUNCATE set length to zero if file exists + * APR_BINARY not a text file (This flag is ignored on + * UNIX because it has no meaning) + * APR_BUFFERED buffer the data. Default is non-buffered + * APR_EXCL return error if APR_CREATE and file exists + * APR_DELONCLOSE delete the file after closing. + * APR_XTHREAD Platform dependent tag to open the file + * for use across multiple threads + * APR_SHARELOCK Platform dependent support for higher + * level locked read/write access to support + * writes across process/machines + * APR_FILE_NOCLEANUP Do not register a cleanup with the pool + * passed in on the cont argument (see below). + * The apr_os_file_t handle in apr_file_t will not + * be closed when the pool is destroyed. + * APR_SENDFILE_ENABLED Open with appropriate platform semantics + * for sendfile operations. Advisory only, + * apr_sendfile does not check this flag. + *+ * @param perm Access permissions for file. + * @param pool The pool to use. + * @remark If perm is APR_OS_DEFAULT and the file is being created, appropriate + * default permissions will be used. *arg1 must point to a valid file_t, + * or NULL (in which case it will be allocated) + } +function apr_file_open(newf: PPapr_file_t; const fname: PChar; + flag: apr_int32_t; perm: apr_fileperms_t; + pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open' + LibSuff20; + +{ + * Close the specified file. + * @param file The file descriptor to close. + } +function apr_file_close(file_: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_close' + LibSuff4; + +{ + * delete the specified file. + * @param path The full path to the file (using / on all systems) + * @param cont The pool to use. + * @remark If the file is open, it won't be removed until all instances are closed. + } +function apr_file_remove(const path: PChar; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_remove' + LibSuff8; + +{ + * rename the specified file. + * @param from_path The full path to the original file (using / on all systems) + * @param to_path The full path to the new file (using / on all systems) + * @param pool The pool to use. + * @warning If a file exists at the new location, then it will be overwritten. + * Moving files or directories across devices may not be possible. + } +function apr_file_rename(const from_path, to_path: PChar; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_rename' + LibSuff12; + +{ + * copy the specified file to another file. + * @param from_path The full path to the original file (using / on all systems) + * @param to_path The full path to the new file (using / on all systems) + * @param perms Access permissions for the new file if it is created. + * In place of the usual or'd combination of file permissions, the + * value APR_FILE_SOURCE_PERMS may be given, in which case the source + * file's permissions are copied. + * @param pool The pool to use. + * @remark The new file does not need to exist, it will be created if required. + * @warning If the new file already exists, its contents will be overwritten. + } +function apr_file_copy(const from_path, to_path: PChar; + perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_copy' + LibSuff16; + +{ + * append the specified file to another file. + * @param from_path The full path to the source file (using / on all systems) + * @param to_path The full path to the destination file (using / on all systems) + * @param perms Access permissions for the destination file if it is created. + * In place of the usual or'd combination of file permissions, the + * value APR_FILE_SOURCE_PERMS may be given, in which case the source + * file's permissions are copied. + * @param pool The pool to use. + * @remark The new file does not need to exist, it will be created if required. + } +function apr_file_append(const from_path, to_path: PChar; + perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_append' + LibSuff16; + +{ + * Are we at the end of the file + * @param fptr The apr file we are testing. + * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise. + } +function apr_file_eof(fptr: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_eof' + LibSuff4; + +{ + * open standard error as an apr file pointer. + * @param thefile The apr file to use as stderr. + * @param cont The pool to allocate the file out of. + * + * @remark The only reason that the apr_file_open_std* functions exist + * is that you may not always have a stderr/out/in on Windows. This + * is generally a problem with newer versions of Windows and services. + * + * The other problem is that the C library functions generally work + * differently on Windows and Unix. So, by using apr_file_open_std* + * functions, you can get a handle to an APR struct that works with + * the APR functions which are supposed to work identically on all + * platforms. + } +function apr_file_open_stderr(thefile: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open_stderr' + LibSuff8; + +{ + * open standard output as an apr file pointer. + * @param thefile The apr file to use as stdout. + * @param cont The pool to allocate the file out of. + * + * @remark The only reason that the apr_file_open_std* functions exist + * is that you may not always have a stderr/out/in on Windows. This + * is generally a problem with newer versions of Windows and services. + * + * The other problem is that the C library functions generally work + * differently on Windows and Unix. So, by using apr_file_open_std* + * functions, you can get a handle to an APR struct that works with + * the APR functions which are supposed to work identically on all + * platforms. + } +function apr_file_open_stdout(thefile: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open_stdout' + LibSuff8; + +{ + * open standard input as an apr file pointer. + * @param thefile The apr file to use as stdin. + * @param cont The pool to allocate the file out of. + * + * @remark The only reason that the apr_file_open_std* functions exist + * is that you may not always have a stderr/out/in on Windows. This + * is generally a problem with newer versions of Windows and services. + * + * The other problem is that the C library functions generally work + * differently on Windows and Unix. So, by using apr_file_open_std* + * functions, you can get a handle to an APR struct that works with + * the APR functions which are supposed to work identically on all + * platforms. + } +function apr_file_open_stdin(thefile: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open_stdin' + LibSuff8; + +{ + * Read data from the specified file. + * @param thefile The file descriptor to read from. + * @param buf The buffer to store the data to. + * @param nbytes On entry, the number of bytes to read; on exit, the number of bytes read. + * @remark apr_file_read will read up to the specified number of bytes, but + * never more. If there isn't enough data to fill that number of + * bytes, all of the available data is read. The third argument is + * modified to reflect the number of bytes read. If a char was put + * back into the stream via ungetc, it will be the first character + * returned. + * + * It is not possible for both bytes to be read and an APR_EOF or other + * error to be returned. + * + * APR_EINTR is never returned. + } +function apr_file_read(thefile: Papr_file_t; buf: Pointer; + nbytes: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_read' + LibSuff12; + +{ + * Write data to the specified file. + * @param thefile The file descriptor to write to. + * @param buf The buffer which contains the data. + * @param nbytes On entry, the number of bytes to write; on exit, the number + * of bytes written. + * @remark apr_file_write will write up to the specified number of bytes, but never + * more. If the OS cannot write that many bytes, it will write as many + * as it can. The third argument is modified to reflect the * number + * of bytes written. + * + * It is possible for both bytes to be written and an error to be returned. + * + * APR_EINTR is never returned. + } +function apr_file_write(thefile: Papr_file_t; buf: Pointer; + nbytes: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_write' + LibSuff12; + +{ + * Write data from iovec array to the specified file. + * @param thefile The file descriptor to write to. + * @param vec The array from which to get the data to write to the file. + * @param nvec The number of elements in the struct iovec array. This must + * be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function + * will fail with APR_EINVAL. + * @param nbytes The number of bytes written. + * @remark It is possible for both bytes to be written and an error to be returned. + * APR_EINTR is never returned. + * + * apr_file_writev is available even if the underlying operating system + * + * doesn't provide writev(). + } +function apr_file_writev(thefile: Papr_file_t; const vec: Piovec; + nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_writev' + LibSuff16; + +{ + * Read data from the specified file, ensuring that the buffer is filled + * before returning. + * @param thefile The file descriptor to read from. + * @param buf The buffer to store the data to. + * @param nbytes The number of bytes to read. + * @param bytes_read If non-NULL, this will contain the number of bytes read. + * @remark apr_file_read will read up to the specified number of bytes, but never + * more. If there isn't enough data to fill that number of bytes, + * then the process/thread will block until it is available or EOF + * is reached. If a char was put back into the stream via ungetc, + * it will be the first character returned. + * + * It is possible for both bytes to be read and an error to be + * returned. And if *bytes_read is less than nbytes, an + * accompanying error is _always_ returned. + * + * APR_EINTR is never returned. + } +function apr_file_read_full(thefile: Papr_file_t; buf: Pointer; + nbytes: apr_size_t; bytes_read: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_read_full' + LibSuff16; + +{ + * Write data to the specified file, ensuring that all of the data is + * written before returning. + * @param thefile The file descriptor to write to. + * @param buf The buffer which contains the data. + * @param nbytes The number of bytes to write. + * @param bytes_written If non-NULL, this will contain the number of bytes written. + * @remark apr_file_write will write up to the specified number of bytes, but never + * more. If the OS cannot write that many bytes, the process/thread + * will block until they can be written. Exceptional error such as + * "out of space" or "pipe closed" will terminate with an error. + * + * It is possible for both bytes to be written and an error to be + * returned. And if *bytes_written is less than nbytes, an + * accompanying error is _always_ returned. + * + * APR_EINTR is never returned. + } +function apr_file_write_full(thefile: Papr_file_t; buf: Pointer; + nbytes: apr_size_t; bytes_written: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_write_full' + LibSuff16; + +{ + * put a character into the specified file. + * @param ch The character to write. + * @param thefile The file descriptor to write to + } +function apr_file_putc(ch: Char; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_putc' + LibSuff8; + +{ + * get a character from the specified file. + * @param ch The character to read into + * @param thefile The file descriptor to read from + } +function apr_file_getc(ch: PChar; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_getc' + LibSuff8; + +{ + * put a character back onto a specified stream. + * @param ch The character to write. + * @param thefile The file descriptor to write to + } +function apr_file_ungetc(ch: Char; thefile: PPapr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_ungetc' + LibSuff8; + +{ + * Get a string from a specified file. + * @param str The buffer to store the string in. + * @param len The length of the string + * @param thefile The file descriptor to read from + * @remark The buffer will be '\0'-terminated if any characters are stored. + } +function apr_file_gets(str: PChar; len: Integer; + thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_gets' + LibSuff12; + +{ + * Put the string into a specified file. + * @param str The string to write. + * @param thefile The file descriptor to write to + } +function apr_file_puts(const str: PChar; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_puts' + LibSuff8; + +{ + * Flush the file's buffer. + * @param thefile The file descriptor to flush + } +function apr_file_flush(thefile: PPapr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_flush' + LibSuff4; + +{ + * duplicate the specified file descriptor. + * @param new_file The structure to duplicate into. + * @param old_file The file to duplicate. + * @param p The pool to use for the new file. + * @remark *new_file must point to a valid apr_file_t, or point to NULL + } +function apr_file_dup(new_file: PPapr_file_t; old_file: PPapr_file_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_dup' + LibSuff12; + +{ + * duplicate the specified file descriptor and close the original + * @param new_file The old file that is to be closed and reused + * @param old_file The file to duplicate + * @param p The pool to use for the new file + * + * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL + } +function apr_file_dup2(new_file: PPapr_file_t; old_file: PPapr_file_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_dup2' + LibSuff12; + +{ + * move the specified file descriptor to a new pool + * @param new_file Pointer in which to return the new apr_file_t + * @param old_file The file to move + * @param p The pool to which the descriptor is to be moved + * @remark Unlike apr_file_dup2(), this function doesn't do an + * OS dup() operation on the underlying descriptor; it just + * moves the descriptor's apr_file_t wrapper to a new pool. + * @remark The new pool need not be an ancestor of old_file's pool. + * @remark After calling this function, old_file may not be used + } +function apr_file_setaside(new_file: PPapr_file_t; old_file: PPapr_file_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_setaside' + LibSuff12; + +{ + * Move the read/write file offset to a specified byte within a file. + * @param thefile The file descriptor + * @param where How to move the pointer, one of: + *
+ * APR_SET -- set the offset to offset + * APR_CUR -- add the offset to the current position + * APR_END -- add the offset to the current file size + *+ * @param offset The offset to move the pointer to. + * @remark The third argument is modified to be the offset the pointer + was actually moved to. + } +function apr_file_seek(thefile: Papr_file_t; + where: apr_seek_where_t; offset: Papr_off_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_seek' + LibSuff12; + +{ + * Create an anonymous pipe. + * @param in The file descriptor to use as input to the pipe. + * @param out The file descriptor to use as output from the pipe. + * @param cont The pool to operate on. + } +function apr_file_pipe_create(in_: PPapr_file_t; out_: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_pipe_create' + LibSuff12; + +{ + * Create a named pipe. + * @param filename The filename of the named pipe + * @param perm The permissions for the newly created pipe. + * @param cont The pool to operate on. + } +function apr_file_namedpipe_create(const filename: PChar; + perm: apr_fileperms_t; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_namedpipe_create' + LibSuff12; + +{ + * Get the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are getting a timeout for. + * @param timeout The current timeout value in microseconds. + } +function apr_file_pipe_timeout_get(thepipe: Papr_file_t; + timeout: Papr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_get' + LibSuff8; + +{ + * Set the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are setting a timeout on. + * @param timeout The timeout value in microseconds. Values < 0 mean wait + * forever, 0 means do not wait at all. + } +function apr_file_pipe_timeout_set(thepipe: Papr_file_t; + timeout: apr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_set' + LibSuff12; + +{ file (un)locking functions. } + +{ + * Establish a lock on the specified, open file. The lock may be advisory + * or mandatory, at the discretion of the platform. The lock applies to + * the file as a whole, rather than a specific range. Locks are established + * on a per-thread/process basis; a second lock by the same thread will not + * block. + * @param thefile The file to lock. + * @param type The type of lock to establish on the file. + } +function apr_file_lock(thefile: Papr_file_t; type_: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_lock' + LibSuff8; + +{ + * Remove any outstanding locks on the file. + * @param thefile The file to unlock. + } +function apr_file_unlock(thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_unlock' + LibSuff4; + +{accessor and general file_io functions. } + +{ + * return the file name of the current file. + * @param new_path The path of the file. + * @param thefile The currently open file. + } +function apr_file_name_get(const newpath: PPChar; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_name_get' + LibSuff8; + +{ + * Return the data associated with the current file. + * @param data The user data associated with the file. + * @param key The key to use for retreiving data associated with this file. + * @param file The currently open file. + } +function apr_file_data_get(data: PPointer; const key: PChar; + file_: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_data_get' + LibSuff12; + +{ + * Set the data associated with the current file. + * @param file The currently open file. + * @param data The user data to associate with the file. + * @param key The key to use for assocaiteing data with the file. + * @param cleanup The cleanup routine to use when the file is destroyed. + } +//function apr_file_data_set(ch: Char; thefile: PPapr_file_t): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_file_data_set' + LibSuff4; +//APR_DECLARE(apr_status_t) (apr_file_t *file, void *data, +// const char *key, +// apr_status_t (*cleanup)(void *)); + +{ + * Write a string to a file using a printf format. + * @param fptr The file to write to. + * @param format The format string + * @param ... The values to substitute in the format string + * @return The number of bytes written + } +function apr_file_printf(fptr: Papr_file_t; const format: PChar; + othres: array of const): Integer; + cdecl; external LibAPR name 'apr_file_printf'; + +{ + * set the specified file's permission bits. + * @param fname The file (name) to apply the permissions to. + * @param perms The permission bits to apply to the file. + * @warning Some platforms may not be able to apply all of the available + * permission bits; APR_INCOMPLETE will be returned if some permissions + * are specified which could not be set. + * + * Platforms which do not implement this feature will return APR_ENOTIMPL. + } +function apr_file_perms_set(const fname: PChar; + perms: apr_fileperms_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_perms_set' + LibSuff8; + +{ + * Set attributes of the specified file. + * @param fname The full path to the file (using / on all systems) + * @param attributes Or'd combination of + *
+ * APR_FILE_ATTR_READONLY - make the file readonly + * APR_FILE_ATTR_EXECUTABLE - make the file executable + * APR_FILE_ATTR_HIDDEN - make the file hidden + *+ * @param attr_mask Mask of valid bits in attributes. + * @param cont the pool to use. + * @remark This function should be used in preference to explict manipulation + * of the file permissions, because the operations to provide these + * attributes are platform specific and may involve more than simply + * setting permission bits. + * @warning Platforms which do not implement this feature will return + * APR_ENOTIMPL. + } +function apr_file_attrs_set(const fname: PChar; + attributes, attr_mask: apr_fileattrs_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_attrs_set' + LibSuff16; + +{ + * Set the mtime of the specified file. + * @param fname The full path to the file (using / on all systems) + * @param mtime The mtime to apply to the file. + * @param pool The pool to use. + * @warning Platforms which do not implement this feature will return + * APR_ENOTIMPL. + } +function apr_file_mtime_set(const fname: PChar; + mtime: apr_time_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_mtime_set' + LibSuff16; + +{ + * Create a new directory on the file system. + * @param path the path for the directory to be created. (use / on all systems) + * @param perm Permissions for the new direcoty. + * @param cont the pool to use. + } +function apr_dir_make(const path: PChar; perm: apr_fileperms_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dir_make' + LibSuff12; + +{ Creates a new directory on the file system, but behaves like + * 'mkdir -p'. Creates intermediate directories as required. No error + * will be reported if PATH already exists. + * @param path the path for the directory to be created. (use / on all systems) + * @param perm Permissions for the new direcoty. + * @param pool the pool to use. + } +function apr_dir_make_recursive(const path: PChar; + perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dir_make_recursive' + LibSuff12; + +{ + * Remove directory from the file system. + * @param path the path for the directory to be removed. (use / on all systems) + * @param cont the pool to use. + } +function apr_dir_remove(const path: PChar; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dir_remove' + LibSuff8; + +{ + * get the specified file's stats. + * @param finfo Where to store the information about the file. + * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values + * @param thefile The file to get information about. + } +function apr_file_info_get(finfo: Papr_finfo_t; + wanted: apr_int32_t; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_info_get' + LibSuff12; + +{ + * Truncate the file's length to the specified offset + * @param fp The file to truncate + * @param offset The offset to truncate to. + } +function apr_file_trunc(fp: Papr_file_t; offset: apr_off_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_trunc' + LibSuff12; + +{ + * Retrieve the flags that were passed into apr_file_open() + * when the file was opened. + * @return apr_int32_t the flags + } +function apr_file_flags_get(f: Papr_file_t): apr_int32_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_flags_get' + LibSuff4; + +{ + * Get the pool used by the file. + } +{APR_POOL_DECLARE_ACCESSOR(file); +} +{ + * Set a file to be inherited by child processes. + * + } +{APR_DECLARE_INHERIT_SET(file); +} +{ @deprecated @see apr_file_inherit_set } +{APR_DECLARE(void) apr_file_set_inherit(apr_file_t *file); +} +{ + * Unset a file from being inherited by child processes. + } +{APR_DECLARE_INHERIT_UNSET(file); +} +{ @deprecated @see apr_file_inherit_unset } +{APR_DECLARE(void) apr_file_unset_inherit(apr_file_t *file); +} +{ + * Open a temporary file + * @param fp The apr file to use as a temporary file. + * @param templ The template to use when creating a temp file. + * @param flags The flags to open the file with. If this is zero, + * the file is opened with + * APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE + * @param p The pool to allocate the file out of. + * @remark + * This function generates a unique temporary file name from template. + * The last six characters of template must be XXXXXX and these are replaced + * with a string that makes the filename unique. Since it will be modified, + * template must not be a string constant, but should be declared as a character + * array. + * + } +function apr_file_mktemp(fp: PPapr_file_t; templ: PChar; + flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_mktemp' + LibSuff16; + +{ + * Find an existing directory suitable as a temporary storage location. + * @param temp_dir The temp directory. + * @param p The pool to use for any necessary allocations. + * @remark + * This function uses an algorithm to search for a directory that an + * an application can use for temporary storage. Once such a + * directory is found, that location is cached by the library. Thus, + * callers only pay the cost of this algorithm once if that one time + * is successful. + * + } +function apr_temp_dir_get(const temp_dir: PPChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_temp_dir_get' + LibSuff8; + diff --git a/httpd/httpd_2_0/apr/apr_general.inc b/httpd/httpd_2_0/apr/apr_general.inc new file mode 100644 index 000000000..b9e8eff56 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_general.inc @@ -0,0 +1,228 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_general.h + * This is collection of oddballs that didn't fit anywhere else, + * and might move to more appropriate headers with the release + * of APR 1.0. + * @brief APR Miscellaneous library routines + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#if APR_HAVE_SIGNAL_H +#include
+ * + * int sum_values(apr_pool_t *p, apr_hash_t *ht) + * ( + * apr_hash_index_t *hi; + * void *val; + * int sum = 0; + * for (hi = apr_hash_first(p, ht); hi; hi = apr_hash_next(hi)) ( + * apr_hash_this(hi, NULL, NULL, &val); + * sum += *(int * )val; + * ) + * return sum; + * ) + *+ } +function apr_hash_first(p: Papr_pool_t; ht: Papr_hash_t): Papr_hash_index_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_first' + LibSuff8; + +{ + * Continue iterating over the entries in a hash table. + * @param hi The iteration state + * @return a pointer to the updated iteration state. NULL if there are no more + * entries. + } +function apr_hash_next(hi: Papr_hash_index_t): Papr_hash_index_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_next' + LibSuff4; + +{ + * Get the current entry's details from the iteration state. + * @param hi The iteration state + * @param key Return pointer for the pointer to the key. + * @param klen Return pointer for the key length. + * @param val Return pointer for the associated value. + * @remark The return pointers should point to a variable that will be set to the + * corresponding data, or they may be NULL if the data isn't interesting. + } +procedure apr_hash_this(hi: Papr_hash_index_t; const key: PPointer; + klen: Papr_size_t; val: PPointer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_this' + LibSuff16; + +{ + * Get the number of key/value pairs in the hash table. + * @param ht The hash table + * @return The number of key/value pairs in the hash table. + } +function apr_hash_count(ht: Papr_hash_t): cuint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_count' + LibSuff4; + +{ + * Merge two hash tables into one new hash table. The values of the overlay + * hash override the values of the base if both have the same key. + * @param p The pool to use for the new hash table + * @param overlay The table to add to the initial table + * @param base The table that represents the initial values of the new table + * @return A new hash table containing all of the data from the two passed in + } +function apr_hash_overlay(p: Papr_pool_t; + const overlay, base: Papr_hash_t): Papr_hash_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_overlay' + LibSuff12; + +{ + * Merge two hash tables into one new hash table. If the same key + * is present in both tables, call the supplied merge function to + * produce a merged value for the key in the new table. + * @param p The pool to use for the new hash table + * @param h1 The first of the tables to merge + * @param h2 The second of the tables to merge + * @param merger A callback function to merge values, or NULL to + * make values from h1 override values from h2 (same semantics as + * apr_hash_overlay()) + * @param data Client data to pass to the merger function + * @return A new hash table containing all of the data from the two passed in + } +type + apr_hash_merge_t = function (p: Papr_pool_t; const key: Pointer; klen: apr_size_t; + const h1_val, h2_val, data: Pointer): Pointer; cdecl; + +function apr_hash_merge(p: Papr_pool_t; + const h1, h2: Papr_hash_t; + merger: apr_hash_merge_t; const data: Pointer): Papr_hash_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_merge' + LibSuff20; + +{ + * Get a pointer to the pool which the hash table was created in + } +//APR_POOL_DECLARE_ACCESSOR(hash); + diff --git a/httpd/httpd_2_0/apr/apr_lib.inc b/httpd/httpd_2_0/apr/apr_lib.inc new file mode 100644 index 000000000..1b14f7bf6 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_lib.inc @@ -0,0 +1,221 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_lib.h + * This is collection of oddballs that didn't fit anywhere else, + * and might move to more appropriate headers with the release + * of APR 1.0. + * @brief APR general purpose library routines + } + +{#include "apr.h" +#include "apr_errno.h" + +#if APR_HAVE_CTYPE_H +#include
+ * For example: + * "/foo/bar/gum" -> "gum" + * "/foo/bar/gum/" -> "" + * "gum" -> "gum" + * "bs\\path\\stuff" -> "stuff" + *+ } +function apr_filepath_name_get(const pathname: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_name_get' + LibSuff4; + +{ @deprecated @see apr_filepath_name_get } +function apr_filename_of_pathname(const pathname: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filename_of_pathname' + LibSuff4; + +{ + * apr_killpg + * Small utility macros to make things easier to read. Not usually a + * goal, to be sure.. + } + +//#ifdef WIN32 +//#define apr_killpg(x, y) +//#else { WIN32 } +//#ifdef NO_KILLPG +//#define apr_killpg(x, y) (kill (-(x), (y))) +//#else { NO_KILLPG } +//#define apr_killpg(x, y) (killpg ((x), (y))) +//#endif { NO_KILLPG } +//#endif { WIN32 } + +{ + * apr_vformatter() is a generic printf-style formatting routine + * with some extensions. + * @param flush_func The function to call when the buffer is full + * @param c The buffer to write to + * @param fmt The format string + * @param ap The arguments to use to fill out the format string. + * + * @remark + *
+ * The extensions are: + * + * %%pA takes a struct in_addr *, and prints it as a.b.c.d + * %%pI takes an apr_sockaddr_t * and prints it as a.b.c.d:port or + * [ipv6-address]:port + * %%pT takes an apr_os_thread_t * and prints it in decimal + * ('0' is printed if !APR_HAS_THREADS) + * %%pp takes a void * and outputs it in hex + * + * The %%p hacks are to force gcc's printf warning code to skip + * over a pointer argument without complaining. This does + * mean that the ANSI-style %%p (output a void * in hex format) won't + * work as expected at all, but that seems to be a fair trade-off + * for the increased robustness of having printf-warnings work. + * + * Additionally, apr_vformatter allows for arbitrary output methods + * using the apr_vformatter_buff and flush_func. + * + * The apr_vformatter_buff has two elements curpos and endpos. + * curpos is where apr_vformatter will write the next byte of output. + * It proceeds writing output to curpos, and updating curpos, until + * either the end of output is reached, or curpos == endpos (i.e. the + * buffer is full). + * + * If the end of output is reached, apr_vformatter returns the + * number of bytes written. + * + * When the buffer is full, the flush_func is called. The flush_func + * can return -1 to indicate that no further output should be attempted, + * and apr_vformatter will return immediately with -1. Otherwise + * the flush_func should flush the buffer in whatever manner is + * appropriate, re apr_pool_t nitialize curpos and endpos, and return 0. + * + * Note that flush_func is only invoked as a result of attempting to + * write another byte at curpos when curpos >= endpos. So for + * example, it's possible when the output exactly matches the buffer + * space available that curpos == endpos will be true when + * apr_vformatter returns. + * + * apr_vformatter does not call out to any other code, it is entirely + * self-contained. This allows the callers to do things which are + * otherwise "unsafe". For example, apr_psprintf uses the "scratch" + * space at the unallocated end of a block, and doesn't actually + * complete the allocation until apr_vformatter returns. apr_psprintf + * would be completely broken if apr_vformatter were to call anything + * that used this same pool. Similarly http_bprintf() uses the "scratch" + * space at the end of its output buffer, and doesn't actually note + * that the space is in use until it either has to flush the buffer + * or until apr_vformatter returns. + *+ } +type + flush_func_t = function (b: Papr_vformatter_buff_t): Integer; + +function apr_vformatter(flush_func: flush_func_t; + c: Papr_vformatter_buff_t; const fmt: PChar; ap: va_list): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_vformatter' + LibSuff16; + +{ + * Display a prompt and read in the password from stdin. + * @param prompt The prompt to display + * @param pwbuf Buffer to store the password + * @param bufsize The length of the password buffer. + } +function apr_password_get(const prompt: PChar; + pwbuf: PChar; bufsize: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_password_get' + LibSuff12; + +{ + * @defgroup apr_ctype ctype functions + * These macros allow correct support of 8-bit characters on systems which + * support 8-bit characters. Pretty dumb how the cast is required, but + * that's legacy libc for ya. These new macros do not support EOF like + * the standard macros do. Tough. + } +{ @see isalnum } +//#define apr_isalnum(c) (isalnum(((unsigned char)(c)))) +{ @see isalpha } +//#define apr_isalpha(c) (isalpha(((unsigned char)(c)))) +{ @see iscntrl } +//#define apr_iscntrl(c) (iscntrl(((unsigned char)(c)))) +{ @see isdigit } +//#define apr_isdigit(c) (isdigit(((unsigned char)(c)))) +{ @see isgraph } +//#define apr_isgraph(c) (isgraph(((unsigned char)(c)))) +{ @see islower} +//#define apr_islower(c) (islower(((unsigned char)(c)))) +{ @see isascii } +{#ifdef isascii +#define apr_isascii(c) (isascii(((unsigned char)(c)))) +#else +#define apr_isascii(c) (((c) & ~0x7f)==0) +#endif} +{ @see isprint } +//#define apr_isprint(c) (isprint(((unsigned char)(c)))) +{ @see ispunct } +//#define apr_ispunct(c) (ispunct(((unsigned char)(c)))) +{ @see isspace } +//#define apr_isspace(c) (isspace(((unsigned char)(c)))) +{ @see isupper } +//#define apr_isupper(c) (isupper(((unsigned char)(c)))) +{ @see isxdigit } +//#define apr_isxdigit(c) (isxdigit(((unsigned char)(c)))) +{ @see tolower } +function apr_tolower(c: Char): Char; +{ @see toupper } +function apr_toupper(c: Char): Char; + diff --git a/httpd/httpd_2_0/apr/apr_network_io.inc b/httpd/httpd_2_0/apr/apr_network_io.inc new file mode 100644 index 000000000..ea93d118a --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_network_io.inc @@ -0,0 +1,884 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_network_io.h + * @brief APR Network library + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_file_io.h" +#include "apr_errno.h" +#include "apr_inherit.h" + +#if APR_HAVE_NETINET_IN_H +#include
+ * APR_SHUTDOWN_READ no longer allow read requests + * APR_SHUTDOWN_WRITE no longer allow write requests + * APR_SHUTDOWN_READWRITE no longer allow read or write requests + *+ * @see apr_shutdown_how_e + * @remark This does not actually close the socket descriptor, it just + * controls which calls are still valid on the socket. + } +function apr_socket_shutdown(thesocket: Papr_socket_t; + how: apr_shutdown_how_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_shutdown' + LibSuff8; + +{ @deprecated @see apr_socket_shutdown } +function apr_shutdown(thesocket: Papr_socket_t; + how: apr_shutdown_how_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_shutdown' + LibSuff8; + +{ + * Close a socket. + * @param thesocket The socket to close + } +function apr_socket_close(thesocket: Papr_socket_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_close' + LibSuff4; + +{ + * Bind the socket to its associated port + * @param sock The socket to bind + * @param sa The socket address to bind to + * @remark This may be where we will find out if there is any other process + * using the selected port. + } +function apr_socket_bind(sock: Papr_socket_t; + sa: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_bind' + LibSuff8; + +{ @deprecated @see apr_socket_bind } +function apr_bind(sock: Papr_socket_t; + sa: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_bind' + LibSuff8; + +{ + * Listen to a bound socket for connections. + * @param sock The socket to listen on + * @param backlog The number of outstanding connections allowed in the sockets + * listen queue. If this value is less than zero, the listen + * queue size is set to zero. + } +function apr_socket_listen(sock: Papr_socket_t; + backlog: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_listen' + LibSuff8; + +{ @deprecated @see apr_socket_listen } +function apr_listen(sock: Papr_socket_t; + backlog: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_listen' + LibSuff8; + +{ + * Accept a new connection request + * @param new_sock A copy of the socket that is connected to the socket that + * made the connection request. This is the socket which should + * be used for all future communication. + * @param sock The socket we are listening on. + * @param connection_pool The pool for the new socket. + } +function apr_socket_accept(new_sock: PPapr_socket_t; + sock: Papr_socket_t; connection_pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_accept' + LibSuff12; + +{ @deprecated @see apr_socket_accept } +{APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new_sock, + apr_socket_t *sock, + apr_pool_t *connection_pool);} + +{ + * Issue a connection request to a socket either on the same machine + * or a different one. + * @param sock The socket we wish to use for our side of the connection + * @param sa The address of the machine we wish to connect to. If NULL, + * APR assumes that the sockaddr_in in the apr_socket is + * completely filled out. + } +function apr_socket_connect(sock: Papr_socket_t; sa: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_connect' + LibSuff8; + +{ @deprecated @see apr_socket_connect } +//APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa); + +{ + * Create apr_sockaddr_t from hostname, address family, and port. + * @param sa The new apr_sockaddr_t. + * @param hostname The hostname or numeric address string to resolve/parse, or + * NULL to build an address that corresponds to 0.0.0.0 or :: + * @param family The address family to use, or APR_UNSPEC if the system should + * decide. + * @param port The port number. + * @param flags Special processing flags: + *
+ * APR_IPV4_ADDR_OK first query for IPv4 addresses; only look + * for IPv6 addresses if the first query failed; + * only valid if family is APR_UNSPEC and hostname + * isn't NULL; mutually exclusive with + * APR_IPV6_ADDR_OK + * APR_IPV6_ADDR_OK first query for IPv6 addresses; only look + * for IPv4 addresses if the first query failed; + * only valid if family is APR_UNSPEC and hostname + * isn't NULL and APR_HAVE_IPV6; mutually exclusive + * with APR_IPV4_ADDR_OK + *+ * @param p The pool for the apr_sockaddr_t and associated storage. + } +function apr_sockaddr_info_get(sa: PPapr_socket_t; + const hostname: PChar; family: apr_int32_t; + port: apr_port_t; flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_info_get' + LibSuff24; + +{ + * Look up the host name from an apr_sockaddr_t. + * @param hostname The hostname. + * @param sa The apr_sockaddr_t. + * @param flags Special processing flags. + } +function apr_getnameinfo(hostname: PPChar; sa: Papr_socket_t; flags: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_getnameinfo' + LibSuff12; + +{ + * Parse hostname/IP address with scope id and port. + * + * Any of the following strings are accepted: + * 8080 (just the port number) + * www.apache.org (just the hostname) + * www.apache.org:8080 (hostname and port number) + * [fe80::1]:80 (IPv6 numeric address string only) + * [fe80::1%eth0] (IPv6 numeric address string and scope id) + * + * Invalid strings: + * (empty string) + * [abc] (not valid IPv6 numeric address string) + * abc:65536 (invalid port number) + * + * @param addr The new buffer containing just the hostname. On output, *addr + * will be NULL if no hostname/IP address was specfied. + * @param scope_id The new buffer containing just the scope id. On output, + * *scope_id will be NULL if no scope id was specified. + * @param port The port number. On output, *port will be 0 if no port was + * specified. + * ### FIXME: 0 is a legal port (per RFC 1700). this should + * ### return something besides zero if the port is missing. + * @param str The input string to be parsed. + * @param p The pool from which *addr and *scope_id are allocated. + * @remark If scope id shouldn't be allowed, check for scope_id != NULL in + * addition to checking the return code. If addr/hostname should be + * required, check for addr == NULL in addition to checking the + * return code. + } +function apr_parse_addr_port(addr, scope_id: PPChar; port: Papr_port_t; + const str: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_parse_addr_port' + LibSuff20; + +{ + * Get name of the current machine + * @param buf A buffer to store the hostname in. + * @param len The maximum length of the hostname that can be stored in the + * buffer provided. The suggested length is APRMAXHOSTLEN + 1. + * @param cont The pool to use. + * @remark If the buffer was not large enough, an error will be returned. + } +function apr_gethostname(buf: PChar; len: Integer; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_gethostname' + LibSuff12; + +{ + * Return the data associated with the current socket + * @param data The user data associated with the socket. + * @param key The key to associate with the user data. + * @param sock The currently open socket. + } +function apr_socket_data_get(data: PPointer; const key: PChar; + sock: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_data_get' + LibSuff12; + +{ + * Set the data associated with the current socket. + * @param sock The currently open socket. + * @param data The user data to associate with the socket. + * @param key The key to associate with the data. + * @param cleanup The cleanup to call when the socket is destroyed. + } +type + cleanup_t = function (param: Pointer): apr_status_t; + +function apr_socket_data_set(sock: Papr_socket_t; data: Pointer; + const key: PChar; cleanup: cleanup_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_data_set' + LibSuff16; + +{ + * Send data over a network. + * @param sock The socket to send the data over. + * @param buf The buffer which contains the data to be sent. + * @param len On entry, the number of bytes to send; on exit, the number + * of bytes sent. + * @remark + *
+ * This functions acts like a blocking write by default. To change + * this behavior, use apr_socket_timeout_set(). + * + * It is possible for both bytes to be sent and an error to be returned. + * + * APR_EINTR is never returned. + *+ } +function apr_socket_send(sock: Papr_socket_t; const buf: PChar; + len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_send' + LibSuff12; + +{ @deprecated @see apr_socket_send } +{APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf, + apr_size_t *len);} + +{ + * Send multiple packets of data over a network. + * @param sock The socket to send the data over. + * @param vec The array of iovec structs containing the data to send + * @param nvec The number of iovec structs in the array + * @param len Receives the number of bytes actually written + * @remark + *
+ * This functions acts like a blocking write by default. To change + * this behavior, use apr_socket_timeout_set(). + * The number of bytes actually sent is stored in argument 3. + * + * It is possible for both bytes to be sent and an error to be returned. + * + * APR_EINTR is never returned. + *+ } +function apr_socket_sendv(sock: Papr_socket_t; const vec: Piovec; + nvec: apr_int32_t; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_sendv' + LibSuff16; + +{ @deprecated @see apr_socket_sendv } +{APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock, + const struct iovec *vec, + apr_int32_t nvec, apr_size_t *len);} + +{ + * @param sock The socket to send from + * @param where The apr_sockaddr_t describing where to send the data + * @param flags The flags to use + * @param buf The data to send + * @param len The length of the data to send + } +function apr_socket_sendto(sock: Papr_socket_t; where: Papr_sockaddr_t; + flags: apr_int32_t; const buf: PChar; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_sendto' + LibSuff20; + +{ @deprecated @see apr_socket_sendto } +{APR_DECLARE(apr_status_t) apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where, + apr_int32_t flags, const char *buf, + apr_size_t *len);} + +{ + * @param from The apr_sockaddr_t to fill in the recipient info + * @param sock The socket to use + * @param flags The flags to use + * @param buf The buffer to use + * @param len The length of the available buffer + } +function apr_socket_recvfrom(from: Papr_sockaddr_t; sock: Papr_socket_t; + flags: apr_int32_t; buf: PChar; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_recvfrom' + LibSuff20; + +{ @deprecated @see apr_socket_recvfrom } +{APR_DECLARE(apr_status_t) apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, + apr_int32_t flags, char *buf, + apr_size_t *len);} + +{$if defined(APR_HAS_SENDFILE) or defined(DOXYGEN)} + +{ + * Send a file from an open file descriptor to a socket, along with + * optional headers and trailers + * @param sock The socket to which we're writing + * @param file The open file from which to read + * @param hdtr A structure containing the headers and trailers to send + * @param offset Offset into the file where we should begin writing + * @param len (input) - Number of bytes to send from the file + * (output) - Number of bytes actually sent, + * including headers, file, and trailers + * @param flags APR flags that are mapped to OS specific flags + * @remark This functions acts like a blocking write by default. To change + * this behavior, use apr_socket_timeout_set(). + * The number of bytes actually sent is stored in argument 5. + } +function apr_socket_sendfile(sock: Papr_socket_t; file_: Papr_file_t; + hdtr: Papr_hdtr_t; offset: Papr_off_t; len: Papr_size_t; + flags: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_sendfile' + LibSuff24; + +{ @deprecated @see apr_socket_sendfile } +{APR_DECLARE(apr_status_t) apr_sendfile(apr_socket_t *sock, apr_file_t *file, + apr_hdtr_t *hdtr, apr_off_t *offset, + apr_size_t *len, apr_int32_t flags);} + +{$endif} { APR_HAS_SENDFILE } + +{ + * Read data from a network. + * @param sock The socket to read the data from. + * @param buf The buffer to store the data in. + * @param len On entry, the number of bytes to receive; on exit, the number + * of bytes received. + * @remark + *
+ * This functions acts like a blocking read by default. To change + * this behavior, use apr_socket_timeout_set(). + * The number of bytes actually sent is stored in argument 3. + * + * It is possible for both bytes to be received and an APR_EOF or + * other error to be returned. + * + * APR_EINTR is never returned. + *+ } +function apr_socket_recv(sock: Papr_socket_t; buf: PChar; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_recv' + LibSuff12; + +{ @deprecated @see apr_socket_recv } +{APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock, + char *buf, apr_size_t *len);} + +{ + * Setup socket options for the specified socket + * @param sock The socket to set up. + * @param opt The option we would like to configure. One of: + *
+ * APR_SO_DEBUG -- turn on debugging information + * APR_SO_KEEPALIVE -- keep connections active + * APR_SO_LINGER -- lingers on close if data is present + * APR_SO_NONBLOCK -- Turns blocking on/off for socket + * APR_SO_REUSEADDR -- The rules used in validating addresses + * supplied to bind should allow reuse + * of local addresses. + * APR_SO_SNDBUF -- Set the SendBufferSize + * APR_SO_RCVBUF -- Set the ReceiveBufferSize + *+ * @param on Value for the option. + } +function apr_socket_opt_set(sock: Papr_socket_t; opt, on_: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_opt_set' + LibSuff12; + +{ @deprecated @see apr_socket_opt_set } +{APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock, + apr_int32_t opt, apr_int32_t on);} + +{ + * Setup socket timeout for the specified socket + * @param sock The socket to set up. + * @param t Value for the timeout. + *
+ * t > 0 -- read and write calls return APR_TIMEUP if specified time + * elapsess with no data read or written + * t == 0 -- read and write calls never block + * t < 0 -- read and write calls block + *+ } +function apr_socket_timeout_set(sock: Papr_socket_t; t: apr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_timeout_set' + LibSuff12; + +{ + * Query socket options for the specified socket + * @param sock The socket to query + * @param opt The option we would like to query. One of: + *
+ * APR_SO_DEBUG -- turn on debugging information + * APR_SO_KEEPALIVE -- keep connections active + * APR_SO_LINGER -- lingers on close if data is present + * APR_SO_NONBLOCK -- Turns blocking on/off for socket + * APR_SO_REUSEADDR -- The rules used in validating addresses + * supplied to bind should allow reuse + * of local addresses. + * APR_SO_SNDBUF -- Set the SendBufferSize + * APR_SO_RCVBUF -- Set the ReceiveBufferSize + * APR_SO_DISCONNECTED -- Query the disconnected state of the socket. + * (Currently only used on Windows) + *+ * @param on Socket option returned on the call. + } +function apr_socket_opt_get(sock: Papr_socket_t; opt, on_: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_opt_get' + LibSuff12; + +{ @deprecated @see apr_socket_opt_set } +{APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock, + apr_int32_t opt, apr_int32_t *on);} + +{ + * Query socket timeout for the specified socket + * @param sock The socket to query + * @param t Socket timeout returned from the query. + } +function apr_socket_timeout_get(sock: Papr_socket_t; t: Papr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_timeout_get' + LibSuff8; + +{ + * Query the specified socket if at the OOB/Urgent data mark + * @param sock The socket to query + * @param atmark Is set to true if socket is at the OOB/urgent mark, + * otherwise is set to false. + } +function apr_socket_atmark(sock: Papr_socket_t; atmark: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_atmark' + LibSuff8; + +{ + * Return an apr_sockaddr_t from an apr_socket_t + * @param sa The returned apr_sockaddr_t. + * @param which Which interface do we want the apr_sockaddr_t for? + * @param sock The socket to use + } +function apr_socket_addr_get(sa: PPapr_sockaddr_t; + which: apr_interface_e; sock: Papr_socket_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_addr_get' + LibSuff12; + +{ + * Set the port in an APR socket address. + * @param sockaddr The socket address to set. + * @param port The port to be stored in the socket address. + * @deprecated @see apr_sockaddr_info_get + } +function apr_sockaddr_port_set(sockaddr: Papr_sockaddr_t; port: apr_port_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_port_set' + LibSuff8; + +{ + * Return the port in an APR socket address. + * @param port The port from the socket address. + * @param sockaddr The socket address to reference. + * @deprecated Access port field directly. + } +function apr_sockaddr_port_get(port: Papr_port_t; sockaddr: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_port_get' + LibSuff8; + +{ + * Set the IP address in an APR socket address. + * @param sockaddr The socket address to use + * @param addr The IP address to attach to the socket. + * Use APR_ANYADDR to use any IP addr on the machine. + * @deprecated @see apr_sockaddr_info_get + } +function apr_sockaddr_ip_set(sockaddr: Papr_sockaddr_t; const addr: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_ip_set' + LibSuff8; + +{ + * Return the IP address (in numeric address string format) in + * an APR socket address. APR will allocate storage for the IP address + * string from the pool of the apr_sockaddr_t. + * @param addr The IP address. + * @param sockaddr The socket address to reference. + } +function apr_sockaddr_ip_get(addr: PPChar; sockaddr: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_ip_get' + LibSuff8; + +{ + * See if the IP addresses in two APR socket addresses are + * equivalent. Appropriate logic is present for comparing + * IPv4-mapped IPv6 addresses with IPv4 addresses. + * + * @param addr1 One of the APR socket addresses. + * @param addr2 The other APR socket address. + * @remark The return value will be non-zero if the addresses + * are equivalent. + } +function apr_sockaddr_equal(const addr1, addr2: Papr_sockaddr_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_equal' + LibSuff8; + +{$if defined(APR_FILES_AS_SOCKETS) or defined(DOXYGEN)} + +{ + * Convert a File type to a socket so that it can be used in a poll operation. + * @param newsock the newly created socket which represents a file. + * @param file the file to mask as a socket. + * @warning This is not available on all platforms. Platforms that have the + * ability to poll files for data to be read/written/exceptions will + * have the APR_FILES_AS_SOCKETS macro defined as true. + * @deprecated This function has been deprecated, because of the new poll + * implementation. + } +function apr_socket_from_file(newsock: Papr_socket_t; file_: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_connect' + LibSuff8; + +{$endif} { APR_FILES_AS_SOCKETS } + +{ + * Given an apr_sockaddr_t and a service name, set the port for the service + * @param sockaddr The apr_sockaddr_t that will have its port set + * @param servname The name of the service you wish to use + } +function apr_getservbyname(sockaddr: Papr_sockaddr_t; const servname: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_getservbyname' + LibSuff8; + +{ + * Build an ip-subnet representation from an IP address and optional netmask or + * number-of-bits. + * @param ipsub The new ip-subnet representation + * @param ipstr The input IP address string + * @param mask_or_numbits The input netmask or number-of-bits string, or NULL + * @param p The pool to allocate from + } +function apr_ipsubnet_create(ipsub: PPapr_ipsubnet_t; + const ipstr, mask_or_numbits: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ipsubnet_create' + LibSuff16; + +{ + * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet + * representation. + * @param ipsub The ip-subnet representation + * @param sa The socket address to test + * @return non-zero if the socket address is within the subnet, 0 otherwise + } +function apr_ipsubnet_test(ipsub: Papr_ipsubnet_t; sa: Papr_sockaddr_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ipsubnet_test' + LibSuff8; + +{$if defined(APR_HAS_SO_ACCEPTFILTER) or defined(DOXYGEN)} +{ + * Set an OS level accept filter. + * @param sock The socket to put the accept filter on. + * @param name The accept filter + * @param args Any extra args to the accept filter. Passing NULL here removes + * the accept filter. + } +function apr_socket_accept_filter(sock: Papr_socket_t; name, args: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_accept_filter' + LibSuff12; + +{$endif} + +{ + * Return the protocol of the socket. + * @param sock The socket to query. + * @param protocol The returned protocol (e.g., APR_PROTO_TCP). + } +function apr_socket_protocol_get(sock: Papr_socket_t; protocol: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_protocol_get' + LibSuff8; + +{ + * Set a socket to be inherited by child processes. + } +//APR_DECLARE_INHERIT_SET(socket); + +{ @deprecated @see apr_socket_inherit_set } +{APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);} + +{ + * Unset a socket from being inherited by child processes. + } +//APR_DECLARE_INHERIT_UNSET(socket); + +{ @deprecated @see apr_socket_inherit_unset } +{APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);} + diff --git a/httpd/httpd_2_0/apr/apr_pools.inc b/httpd/httpd_2_0/apr/apr_pools.inc new file mode 100644 index 000000000..6ffc3c10c --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_pools.inc @@ -0,0 +1,707 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_pools.h + * @brief APR memory allocation + * + * Resource allocation routines... + * + * designed so that we don't have to keep track of EVERYTHING so that + * it can be explicitly freed later (a fundamentally unsound strategy --- + * particularly in the presence of die()). + * + * Instead, we maintain pools, and allocate items (both memory and I/O + * handlers) from the pools --- currently there are two, one for per + * transaction info, and one for config info. When a transaction is over, + * we can delete everything in the per-transaction apr_pool_t without fear, + * and without thinking too hard about it either. + } + +{#include "apr.h" +#include "apr_errno.h" +#include "apr_general.h"{ { for APR_STRINGIFY } +//#include "apr_want.h" + +{ + * @defgroup apr_pools Memory Pool Functions + * @ingroup APR + * @ + } + +{ The fundamental pool type } +type + apr_pool_t = record end; + Papr_pool_t = ^apr_pool_t; + PPapr_pool_t = ^Papr_pool_t; + +{ + * Declaration helper macro to construct apr_foo_pool_get()s. + * + * This standardized macro is used by opaque (APR) data types to return + * the apr_pool_t that is associated with the data type. + * + * APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the + * accessor function. A typical usage and result would be: + *
+ * APR_POOL_DECLARE_ACCESSOR(file); + * becomes: + * APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob); + *+ * @remark Doxygen unwraps this macro (via doxygen.conf) to provide + * actual help for each specific occurance of apr_foo_pool_get. + * @remark the linkage is specified for APR. It would be possible to expand + * the macros to support other linkages. + } +{#define APR_POOL_DECLARE_ACCESSOR(type) \ + APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ + (const apr_##type##_t *the##type) +} +{ + * Implementation helper macro to provide apr_foo_pool_get()s. + * + * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to + * actually define the function. It assumes the field is named "pool". + } +{#define APR_POOL_IMPLEMENT_ACCESSOR(type) \ + APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ + (const apr_##type##_t *the##type) \} + { return the##type->pool; } + + +{ + * Pool debug levels + * + *
+ * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | + * --------------------------------- + * | | | | | | | | x | General debug code enabled (usefull in + * combination with --with-efence). + * + * | | | | | | | x | | Verbose output on stderr (report + * CREATE, CLEAR, DESTROY). + * + * | | | | x | | | | | Verbose output on stderr (report + * PALLOC, PCALLOC). + * + * | | | | | | x | | | Lifetime checking. On each use of a + * pool, check its lifetime. If the pool + * is out of scope, abort(). + * In combination with the verbose flag + * above, it will output LIFE in such an + * event prior to aborting. + * + * | | | | | x | | | | Pool owner checking. On each use of a + * pool, check if the current thread is the + * pools owner. If not, abort(). In + * combination with the verbose flag above, + * it will output OWNER in such an event + * prior to aborting. Use the debug + * function apr_pool_owner_set() to switch + * a pools ownership. + * + * When no debug level was specified, assume general debug mode. + * If level 0 was specified, debugging is switched off + *+ } +{#if defined(APR_POOL_DEBUG) +#if (APR_POOL_DEBUG != 0) && (APR_POOL_DEBUG - 0 == 0) +#undef APR_POOL_DEBUG +#define APR_POOL_DEBUG 1 +#endif +#else +#define APR_POOL_DEBUG 0 +#endif +} +{ the place in the code where the particular function was called } +//#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__) + + + +{ A function that is called when allocation fails. } +type + apr_abortfunc_t = function (retcode: Integer): Integer; + +{ + * APR memory structure manipulators (pools, tables, and arrays). + } + +{ + * Initialization + } + +{ + * Setup all of the internal structures required to use pools + * @remark Programs do NOT need to call this directly. APR will call this + * automatically from apr_initialize. + * @internal + } +function apr_pool_initialize: apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_initialize' + LibSuff0; + +{ + * Tear down all of the internal structures required to use pools + * @remark Programs do NOT need to call this directly. APR will call this + * automatically from apr_terminate. + * @internal + } +procedure apr_pool_terminate; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_terminate' + LibSuff0; + +{ + * Pool creation/destruction + } + +{$include apr_allocator.inc} + +{ + * Create a new pool. + * @param newpool The pool we have just created. + * @param parent The parent pool. If this is NULL, the new pool is a root + * pool. If it is non-NULL, the new pool will inherit all + * of its parent pool's attributes, except the apr_pool_t will + * be a sub-pool. + * @param abort_fn A function to use if the pool cannot allocate more memory. + * @param allocator The allocator to use with the new pool. If NULL the + * allocator of the parent pool will be used. + } +function apr_pool_create_ex(newpool: PPapr_pool_t; + parent: Papr_pool_t; abort_fn: apr_abortfunc_t; + allocator: Papr_allocator_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_create_ex' + LibSuff16; + +{ + * Debug version of apr_pool_create_ex. + * @param newpool @see apr_pool_create. + * @param parent @see apr_pool_create. + * @param abort_fn @see apr_pool_create. + * @param allocator @see apr_pool_create. + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @remark Only available when APR_POOL_DEBUG is defined. + * Call this directly if you have you apr_pool_create_ex + * calls in a wrapper function and wish to override + * the file_line argument to reflect the caller of + * your wrapper function. If you do not have + * apr_pool_create_ex in a wrapper, trust the macro + * and don't call apr_pool_create_ex_debug directly. + } +function apr_pool_create_ex_debug(newpool: PPapr_pool_t; + parent: Papr_pool_t; abort_fn: apr_abortfunc_t; + allocator: Papr_allocator_t; const file_line: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_create_ex_debug' + LibSuff20; + +{#if APR_POOL_DEBUG +#define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \ + apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \ + APR_POOL__FILE_LINE__) +#endif +} +{ + * Create a new pool. + * @param newpool The pool we have just created. + * @param parent The parent pool. If this is NULL, the new pool is a root + * pool. If it is non-NULL, the new pool will inherit all + * of its parent pool's attributes, except the apr_pool_t will + * be a sub-pool. + } +{$ifdef DOXYGEN} +function apr_pool_create(newpool: PPapr_pool_t; + parent: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_create' + LibSuff8; +{$else} +{.$ifdef APR_POOL_DEBUG} +{#define apr_pool_create(newpool, parent) \ + apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \ + APR_POOL__FILE_LINE__)} +{.$else} +function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t; +{.$endif} +{$endif} + +{ @deprecated @see apr_pool_create_ex } +{#if APR_POOL_DEBUG +#define apr_pool_sub_make(newpool, parent, abort_fn) \ + (void)apr_pool_create_ex_debug(newpool, parent, abort_fn, \ + NULL, \ + APR_POOL__FILE_LINE__) +#else} +function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t; + abort_fn: apr_abortfunc_t): apr_status_t; +//#endif + +{ + * Find the pools allocator + * @param pool The pool to get the allocator from. + } +function apr_pool_allocator_get(pool: Papr_pool_t): Papr_allocator_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_allocator_get' + LibSuff4; + +{ + * Clear all memory in the pool and run all the cleanups. This also destroys all + * subpools. + * @param p The pool to clear + * @remark This does not actually free the memory, it just allows the pool + * to re-use this memory for the next allocation. + * @see apr_pool_destroy() + } +procedure apr_pool_clear(p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_clear' + LibSuff4; + +{ + * Debug version of apr_pool_clear. + * @param p See: apr_pool_clear. + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @remark Only available when APR_POOL_DEBUG is defined. + * Call this directly if you have you apr_pool_clear + * calls in a wrapper function and wish to override + * the file_line argument to reflect the caller of + * your wrapper function. If you do not have + * apr_pool_clear in a wrapper, trust the macro + * and don't call apr_pool_destroy_clear directly. + } +procedure apr_pool_clear_debug(p: Papr_pool_t; const file_line: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_clear_debug' + LibSuff8; + +{#if APR_POOL_DEBUG +#define apr_pool_clear(p) \ + apr_pool_clear_debug(p, APR_POOL__FILE_LINE__) +#endif} + +{ + * Destroy the pool. This takes similar action as apr_pool_clear() and then + * frees all the memory. + * @param p The pool to destroy + * @remark This will actually free the memory + } +procedure apr_pool_destroy(p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_destroy' + LibSuff4; + +{ + * Debug version of apr_pool_destroy. + * @param p See: apr_pool_destroy. + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @remark Only available when APR_POOL_DEBUG is defined. + * Call this directly if you have you apr_pool_destroy + * calls in a wrapper function and wish to override + * the file_line argument to reflect the caller of + * your wrapper function. If you do not have + * apr_pool_destroy in a wrapper, trust the macro + * and don't call apr_pool_destroy_debug directly. + } +procedure apr_pool_destroy_debug(p: Papr_pool_t; const file_line: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_destroy_debug' + LibSuff8; + +{#if APR_POOL_DEBUG +#define apr_pool_destroy(p) \ + apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__) +#endif} + + +{ + * Memory allocation + } + +{ + * Allocate a block of memory from a pool + * @param p The pool to allocate from + * @param size The amount of memory to allocate + * @return The allocated memory + } +function apr_palloc(p: Papr_pool_t; size: apr_size_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_palloc' + LibSuff8; + +{ + * Debug version of apr_palloc + * @param p See: apr_palloc + * @param size See: apr_palloc + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @return See: apr_palloc + } +function apr_palloc_debug(p: Papr_pool_t; size: apr_size_t; + const file_line: PChar): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_palloc_debug' + LibSuff12; + +{#if APR_POOL_DEBUG +#define apr_palloc(p, size) \ + apr_palloc_debug(p, size, APR_POOL__FILE_LINE__) +#endif +} +{ + * Allocate a block of memory from a pool and set all of the memory to 0 + * @param p The pool to allocate from + * @param size The amount of memory to allocate + * @return The allocated memory + } +{#if defined(DOXYGEN)} + +function apr_pcalloc(p: Papr_pool_t; size: apr_size_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pcalloc' + LibSuff8; + +{#elif !APR_POOL_DEBUG +#define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size) +#endif +} +{ + * Debug version of apr_pcalloc + * @param p See: apr_pcalloc + * @param size See: apr_pcalloc + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @return See: apr_pcalloc + } +{APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size, + const char *file_line); + +#if APR_POOL_DEBUG +#define apr_pcalloc(p, size) \ + apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__) +#endif + +} +{ + * Pool Properties + } + +{ + * Set the function to be called when an allocation failure occurs. + * @remark If the program wants APR to exit on a memory allocation error, + * then this function can be called to set the callback to use (for + * performing cleanup and then exiting). If this function is not called, + * then APR will return an error and expect the calling program to + * deal with the error accordingly. + } +procedure apr_pool_abort_set(abortfunc: apr_abortfunc_t; pool: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_abort_set' + LibSuff8; + +{ @deprecated @see apr_pool_abort_set } +{APR_DECLARE(void) apr_pool_set_abort(apr_abortfunc_t abortfunc, + apr_pool_t *pool); +} +{ + * Get the abort function associated with the specified pool. + * @param pool The pool for retrieving the abort function. + * @return The abort function for the given pool. + } +function apr_pool_abort_get(pool: Papr_pool_t): apr_abortfunc_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_abort_get' + LibSuff4; + +{ @deprecated @see apr_pool_abort_get } +//APR_DECLARE(apr_abortfunc_t) apr_pool_get_abort(apr_pool_t *pool); + +{ + * Get the parent pool of the specified pool. + * @param pool The pool for retrieving the parent pool. + * @return The parent of the given pool. + } +function apr_pool_parent_get(pool: Papr_pool_t): Papr_pool_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_parent_get' + LibSuff4; + +{ @deprecated @see apr_pool_parent_get } +//APR_DECLARE(apr_pool_t *) apr_pool_get_parent(apr_pool_t *pool); + +{ + * Determine if pool a is an ancestor of pool b + * @param a The pool to search + * @param b The pool to search for + * @return True if a is an ancestor of b, NULL is considered an ancestor + * of all pools. + } +function apr_pool_is_ancestor(a, b: Papr_pool_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_is_ancestor' + LibSuff8; + +{ + * Tag a pool (give it a name) + * @param pool The pool to tag + * @param tag The tag + } +procedure apr_pool_tag(pool: Papr_pool_t; tag: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_tag' + LibSuff8; + +{ + * User data management + } + +{ + * Set the data associated with the current pool + * @param data The user data associated with the pool. + * @param key The key to use for association + * @param cleanup The cleanup program to use to cleanup the data (NULL if none) + * @param pool The current pool + * @warning The data to be attached to the pool should have a life span + * at least as long as the pool it is being attached to. + * + * Users of APR must take EXTREME care when choosing a key to + * use for their data. It is possible to accidentally overwrite + * data by choosing a key that another part of the program is using. + * Therefore it is advised that steps are taken to ensure that unique + * keys are used for all of the userdata objects in a particular pool + * (the same key in two different pools or a pool and one of its + * subpools is okay) at all times. Careful namespace prefixing of + * key names is a typical way to help ensure this uniqueness. + } +//function apr_pool_userdata_set( +// const data: Pointer; const key: PChar; +// cleanup: function(param: Pointer): apr_status_t, +// pool: Papr_pool_t): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_userdata_set' + LibSuff20; + +{ + * Set the data associated with the current pool + * @param data The user data associated with the pool. + * @param key The key to use for association + * @param cleanup The cleanup program to use to cleanup the data (NULL if none) + * @param pool The current pool + * @note same as apr_pool_userdata_set(), except that this version doesn't + * make a copy of the key (this function is useful, for example, when + * the key is a string literal) + * @warning This should NOT be used if the key could change addresses by + * any means between the apr_pool_userdata_setn() call and a + * subsequent apr_pool_userdata_get() on that key, such as if a + * static string is used as a userdata key in a DSO and the DSO could + * be unloaded and reloaded between the _setn() and the _get(). You + * MUST use apr_pool_userdata_set() in such cases. + * @warning More generally, the key and the data to be attached to the + * pool should have a life span at least as long as the pool itself. + * + } +//function apr_pool_userdata_setn( +// const data: Pointer; const key: PChar; +// cleanup: function(param: Pointer): apr_status_t, +// pool: Papr_pool_t): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_userdata_setn' + LibSuff20; + +{ + * Return the data associated with the current pool. + * @param data The user data associated with the pool. + * @param key The key for the data to retrieve + * @param pool The current pool. + } +function apr_pool_userdata_get(data: PPointer; const key: PChar; + pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_userdata_get' + LibSuff12; + +{ + * Cleanup + * + * Cleanups are performed in the reverse order they were registered. That is: + * Last In, First Out. + } + +{ + * Register a function to be called when a pool is cleared or destroyed + * @param p The pool register the cleanup with + * @param data The data to pass to the cleanup function. + * @param plain_cleanup The function to call when the pool is cleared + * or destroyed + * @param child_cleanup The function to call when a child process is being + * shutdown - this function is called in the child, obviously! + } +type + plain_cleanup_t = function(param: Pointer): apr_status_t; cdecl; + child_cleanup_t = function(param: Pointer): apr_status_t; cdecl; + +procedure apr_pool_cleanup_register(p: Papr_pool_t; + const data: Pointer; + plain_cleanup: plain_cleanup_t; + child_cleanup: child_cleanup_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_cleanup_register' + LibSuff16; + +{ + * Remove a previously registered cleanup function + * @param p The pool remove the cleanup from + * @param data The data to remove from cleanup + * @param cleanup The function to remove from cleanup + * @remarks For some strange reason only the plain_cleanup is handled by this + * function + } +//procedure apr_pool_cleanup_for_exec; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +//APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, +// apr_status_t cleanup)(void ); + +{ + * Replace the child cleanup of a previously registered cleanup + * @param p The pool of the registered cleanup + * @param data The data of the registered cleanup + * @param plain_cleanup The plain cleanup function of the registered cleanup + * @param child_cleanup The function to register as the child cleanup + } +//procedure apr_pool_cleanup_for_exec; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +{APR_DECLARE(void) apr_pool_child_cleanup_set( + apr_pool_t *p, + const void *data, + apr_status_t plain_cleanup)(void , + apr_status_t child_cleanup)(void ); +} +{ + * Run the specified cleanup function immediately and unregister it. Use + * @a data instead of the data that was registered with the cleanup. + * @param p The pool remove the cleanup from + * @param data The data to remove from cleanup + * @param cleanup The function to remove from cleanup + } +//procedure apr_pool_cleanup_for_exec; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +{APR_DECLARE(apr_status_t) apr_pool_cleanup_run( + apr_pool_t *p, + void *data, + apr_status_t cleanup)(void );} + +{ + * An empty cleanup function + * @param data The data to cleanup + } +//APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data); + +{ Preparing for exec() --- close files, etc., but *don't* flush I/O + * buffers, *don't* wait for subprocesses, and *don't* free any memory. + } +{ + * Run all of the child_cleanups, so that any unnecessary files are + * closed because we are about to exec a new program + } +procedure apr_pool_cleanup_for_exec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +{ + * @defgroup PoolDebug Pool Debugging functions. + * + * pools have nested lifetimes -- sub_pools are destroyed when the + * parent pool is cleared. We allow certain liberties with operations + * on things such as tables (and on other structures in a more general + * sense) where we allow the caller to insert values into a table which + * were not allocated from the table's pool. The table's data will + * remain valid as long as all the pools from which its values are + * allocated remain valid. + * + * For example, if B is a sub pool of A, and you build a table T in + * pool B, then it's safe to insert data allocated in A or B into T + * (because B lives at most as long as A does, and T is destroyed when + * B is cleared/destroyed). On the other hand, if S is a table in + * pool A, it is safe to insert data allocated in A into S, but it + * is *not safe* to insert data allocated from B into S... because + * B can be cleared/destroyed before A is (which would leave dangling + * pointers in T's data structures). + * + * In general we say that it is safe to insert data into a table T + * if the data is allocated in any ancestor of T's pool. This is the + * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor + * relationships for all data inserted into tables. APR_POOL_DEBUG also + * provides tools (apr_pool_find, and apr_pool_is_ancestor) for other + * folks to implement similar restrictions for their own data + * structures. + * + * However, sometimes this ancestor requirement is inconvenient -- + * sometimes we're forced to create a sub pool (such as through + * apr_sub_req_lookup_uri), and the sub pool is guaranteed to have + * the same lifetime as the parent pool. This is a guarantee implemented + * by the *caller*, not by the pool code. That is, the caller guarantees + * they won't destroy the sub pool individually prior to destroying the + * parent pool. + * + * In this case the caller must call apr_pool_join() to indicate this + * guarantee to the APR_POOL_DEBUG code. There are a few examples spread + * through the standard modules. + * + * These functions are only implemented when #APR_POOL_DEBUG is set. + * + } +{$if defined(APR_POOL_DEBUG) or defined(DOXYGEN)} +{ + * Guarantee that a subpool has the same lifetime as the parent. + * @param p The parent pool + * @param sub The subpool + } +procedure apr_pool_join(p, sub: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_join' + LibSuff8; + +{ + * Find a pool from something allocated in it. + * @param mem The thing allocated in the pool + * @return The pool it is allocated in + } +function apr_pool_find(const mem: Pointer): Papr_pool_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_find' + LibSuff4; + +{ + * Report the number of bytes currently in the pool + * @param p The pool to inspect + * @param recurse Recurse/include the subpools' sizes + * @return The number of bytes + } +function apr_pool_num_bytes(p: Papr_pool_t; recurse: Integer): apr_size_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_num_bytes' + LibSuff8; + +{ + * Lock a pool + * @param pool The pool to lock + * @param flag The flag + } +procedure apr_pool_lock(pool: Papr_pool_t; flag: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_lock' + LibSuff8; + +{$else} { APR_POOL_DEBUG or DOXYGEN } + +{#ifdef apr_pool_join +#undef apr_pool_join +#endif +#define apr_pool_join(a,b) + +#ifdef apr_pool_lock +#undef apr_pool_lock +#endif +#define apr_pool_lock(pool, lock)} + +{$endif} { APR_POOL_DEBUG or DOXYGEN } + diff --git a/httpd/httpd_2_0/apr/apr_portable.inc b/httpd/httpd_2_0/apr/apr_portable.inc new file mode 100644 index 000000000..415e969c8 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_portable.inc @@ -0,0 +1,540 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ This header file is where you should put ANY platform specific information. + * This should be the only header file that programs need to include that + * actually has platform dependant code which refers to the . + } + +{ + * @file apr_portable.h + * @brief APR Portability Routines + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_thread_proc.h" +#include "apr_file_io.h" +#include "apr_network_io.h" +#include "apr_errno.h" +#include "apr_global_mutex.h" +#include "apr_proc_mutex.h" +#include "apr_time.h" +#include "apr_dso.h" +#include "apr_shm.h" + +#if APR_HAVE_DIRENT_H +#include
+ * We re-implement this function to implement these specific changes: + * 1) strncpy() doesn't always null terminate and we want it to. + * 2) strncpy() null fills, which is bogus, esp. when copy 8byte strings + * into 8k blocks. + * 3) Instead of returning the pointer to the beginning of the + * destination string, we return a pointer to the terminating null + * to allow us to check for truncation. + *+ } +function apr_cpystrn(dst: PChar; const src: PChar; + dst_size: apr_size_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_cpystrn' + LibSuff12; + +{ + * Strip spaces from a string + * @param dest The destination string. It is okay to modify the string + * in place. Namely dest == src + * @param src The string to rid the spaces from. + } +function apr_collapse_spaces(dst: PChar; const src: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_collapse_spaces' + LibSuff8; + +{ + * Convert the arguments to a program from one string to an array of + * strings terminated by a NULL pointer + * @param arg_str The arguments to convert + * @param argv_out Output location. This is a pointer to an array of strings. + * @param token_context Pool to use. + } +function apr_tokenize_to_argv(const arg_str: PChar; + var argv_out: PPChar; token_context: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_tokenize_to_argv' + LibSuff12; + +{ + * Split a string into separate null-terminated tokens. The tokens are + * delimited in the string by one or more characters from the sep + * argument. + * @param str The string to separate; this should be specified on the + * first call to apr_strtok() for a given string, and NULL + * on subsequent calls. + * @param sep The set of delimiters + * @param last Internal state saved by apr_strtok() between calls. + * @return The next token from the string + } +function apr_strtok(str: PChar; + const sep: PChar; last: PPChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strtok' + LibSuff12; + +{ + * @defgroup APR_Strings_Snprintf snprintf implementations + * @warning + * These are snprintf implementations based on apr_vformatter(). + * + * Note that various standards and implementations disagree on the return + * value of snprintf, and side-effects due to %n in the formatting string. + * apr_snprintf (and apr_vsnprintf) behaves as follows: + * + * Process the format string until the entire string is exhausted, or + * the buffer fills. If the buffer fills then stop processing immediately + * (so no further %n arguments are processed), and return the buffer + * length. In all cases the buffer is NUL terminated. It will return the + * number of characters inserted into the buffer, not including the + * terminating NUL. As a special case, if len is 0, apr_snprintf will + * return the number of characters that would have been inserted if + * the buffer had been infinite (in this case, *buffer can be NULL) + * + * In no event does apr_snprintf return a negative number. + * @{ + } + +{ + * snprintf routine based on apr_vformatter. This means it understands the + * same extensions. + * @param buf The buffer to write to + * @param len The size of the buffer + * @param format The format string + * @param ... The arguments to use to fill out the format string. + } +function apr_snprintf(buf: PChar; len: apr_size_t; + const format: PChar; others: array of const): PChar; + cdecl; external LibAPR name 'apr_snprintf'; + +{ + * vsnprintf routine based on apr_vformatter. This means it understands the + * same extensions. + * @param buf The buffer to write to + * @param len The size of the buffer + * @param format The format string + * @param ap The arguments to use to fill out the format string. + } +function apr_vsnprintf(buf: PChar; len: apr_size_t; + const format: PChar; ap: va_list): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_vsnprintf' + LibSuff16; + +{ + * create a string representation of an int, allocated from a pool + * @param p The pool from which to allocate + * @param n The number to format + * @return The string representation of the number + } +function apr_itoa(p: Papr_pool_t; n: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_itoa' + LibSuff8; + +{ + * create a string representation of a long, allocated from a pool + * @param p The pool from which to allocate + * @param n The number to format + * @return The string representation of the number + } +function apr_ltoa(p: Papr_pool_t; n: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ltoa' + LibSuff8; + +{ + * create a string representation of an apr_off_t, allocated from a pool + * @param p The pool from which to allocate + * @param n The number to format + * @return The string representation of the number + } +function apr_off_t_toa(p: Papr_pool_t; n: apr_off_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_off_t_toa' + LibSuff12; + +{ + * parse a numeric string into a 64-bit numeric value + * @param buf The string to parse. It may contain optional whitespace, + * followed by an optional '+' (positive, default) or '-' (negative) + * character, followed by an optional '0x' prefix if base is 0 or 16, + * followed by numeric digits appropriate for base. + * @param end A pointer to the end of the valid character in buf. If + * not nil, it is set to the first invalid character in buf. + * @param base A numeric base in the range between 2 and 36 inclusive, + * or 0. If base is zero, buf will be treated as base ten unless its + * digits are prefixed with '0x', in which case it will be treated as + * base 16. + * @return The numeric value of the string. + } +function apr_strtoi64(const buf: PChar; end_: PPChar; base: Integer): apr_int64_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strtoi64' + LibSuff12; + +{ + * parse a base-10 numeric string into a 64-bit numeric value. + * Equivalent to apr_strtoi64(buf, (char**)NULL, 10). + * @param buf The string to parse + * @return The numeric value of the string + } +function apr_atoi64(const buf: PChar): apr_int64_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_atoi64' + LibSuff4; + +{ + * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an apr_off_t, + * as bytes, K, M, T, etc, to a four character compacted human readable string. + * @param size The size to format + * @param buf The 5 byte text buffer (counting the trailing null) + * @return The buf passed to apr_strfsize() + * @remark All negative sizes report ' - ', apr_strfsize only formats positive values. + } +function apr_strfsize(size: apr_off_t; buf: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strfsize' + LibSuff12; + diff --git a/httpd/httpd_2_0/apr/apr_tables.inc b/httpd/httpd_2_0/apr/apr_tables.inc new file mode 100644 index 000000000..0485f3814 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_tables.inc @@ -0,0 +1,447 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_tables.h + * @brief APR Table library + } + +{ + * @defgroup apr_tables Table and Array Functions + * @ingroup APR + * Tables are used to store entirely opaque structures + * for applications, while Arrays are usually used to + * deal with string lists. + } + +{ the table abstract data type } +type + apr_table_t = record end; + Papr_table_t = ^apr_table_t; + +{ An opaque array type } + apr_array_header_t = record + { The pool the array is allocated out of } + pool: Papr_pool_t; + { The amount of memory allocated for each element of the array } + elt_size: Integer; + { The number of active elements in the array } + nelts: Integer; + { The number of elements allocated in the array } + nalloc: Integer; + { The elements in the array } + elts: PChar; + end; + Papr_array_header_t = ^apr_array_header_t; + PPapr_array_header_t = ^Papr_array_header_t; + +{ + * The (opaque) structure for string-content tables. + } + +{ The type for each entry in a string-content table } + apr_table_entry_t = record + { The key for the current table entry } + key: PChar; { maybe NULL in future; + * check when iterating thru table_elts + } + { The value for the current table entry } + val: PChar; + + { A checksum for the key, for use by the apr_table internals } + key_checksum: apr_uint32_t; + end; + +{ + * Get the elements from a table + * @param t The table + * @return An array containing the contents of the table + } +function apr_table_elts(const t: Papr_table_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_elts' + LibSuff4; + +{ + * Determine if the table is empty + * @param t The table to check + * @return True if empty, False otherwise + } +function apr_is_empty_table(const t: Papr_table_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_is_empty_table' + LibSuff4; + +{ + * Determine if the array is empty + * @param a The array to check + * @return True if empty, False otherwise + } +function apr_is_empty_array(const a: Papr_array_header_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_is_empty_array' + LibSuff4; + +{ + * Create an array + * @param p The pool to allocate the memory out of + * @param nelts the number of elements in the initial array + * @param elt_size The size of each element in the array. + * @return The new array + } +function apr_array_make(p: Papr_pool_t; + nelts, elt_size: Integer): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_make' + LibSuff12; + +{ + * Add a new element to an array + * @param arr The array to add an element to. + * @return Location for the new element in the array. + * @remark If there are no free spots in the array, then this function will + * allocate new space for the new element. + } +function apr_array_push(arr: Papr_array_header_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_push' + LibSuff4; + +{ + * Remove an element from an array + * @param arr The array to remove an element from. + * @return Location of the element in the array. + * @remark If there are no elements in the array, NULL is returned. + } +function apr_array_pop(arr: Papr_array_header_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_pop' + LibSuff4; + +{ + * Concatenate two arrays together + * @param dst The destination array, and the one to go first in the combined + * array + * @param src The source array to add to the destination array + } +procedure apr_array_cat(dst: Papr_array_header_t; + const src: Papr_array_header_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_cat' + LibSuff8; + +{ + * Copy the entire array + * @param p The pool to allocate the copy of the array out of + * @param arr The array to copy + * @return An exact copy of the array passed in + * @remark The alternate apr_array_copy_hdr copies only the header, and arranges + * for the elements to be copied if (and only if) the code subsequently + * does a push or arraycat. + } +function apr_array_copy(p: Papr_pool_t; + const arr: Papr_array_header_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_copy' + LibSuff8; + +{ + * Copy the headers of the array, and arrange for the elements to be copied if + * and only if the code subsequently does a push or arraycat. + * @param p The pool to allocate the copy of the array out of + * @param arr The array to copy + * @return An exact copy of the array passed in + * @remark The alternate apr_array_copy copies the *entire* array. + } +function apr_array_copy_hdr(p: Papr_pool_t; + const arr: Papr_array_header_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_copy_hdr' + LibSuff8; + +{ + * Append one array to the end of another, creating a new array in the process. + * @param p The pool to allocate the new array out of + * @param first The array to put first in the new array. + * @param second The array to put second in the new array. + * @return A new array containing the data from the two arrays passed in. +} +function apr_array_append(p: Papr_pool_t; + const first, second: Papr_array_header_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_append' + LibSuff12; + +{ + * Generates a new string from the apr_pool_t containing the concatenated + * sequence of substrings referenced as elements within the array. The string + * will be empty if all substrings are empty or null, or if there are no + * elements in the array. If sep is non-NUL, it will be inserted between + * elements as a separator. + * @param p The pool to allocate the string out of + * @param arr The array to generate the string from + * @param sep The separator to use + * @return A string containing all of the data in the array. + } +function apr_array_pstrcat(p: Papr_pool_t; + const arr: Papr_array_header_t; sep: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_pstrcat' + LibSuff12; + +{ + * Make a new table + * @param p The pool to allocate the pool out of + * @param nelts The number of elements in the initial table. + * @return The new table. + * @warning This table can only store text data + } +function apr_table_make(p: Papr_pool_t; nelts: Integer): Papr_table_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_make' + LibSuff8; + +{ + * Create a new table and copy another table into it + * @param p The pool to allocate the new table out of + * @param t The table to copy + * @return A copy of the table passed in + } +function apr_table_copy(p: Papr_pool_t; const t: Papr_table_t): Papr_table_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_copy' + LibSuff8; + +{ + * Delete all of the elements from a table + * @param t The table to clear + } +procedure apr_table_clear(t: Papr_table_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_clear' + LibSuff4; + +{ + * Get the value associated with a given key from the table. After this call, + * The data is still in the table + * @param t The table to search for the key + * @param key The key to search for + * @return The value associated with the key + } +function apr_table_get(t: Papr_table_t; key: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_get' + LibSuff8; + +{ + * Add a key/value pair to a table, if another element already exists with the + * same key, this will over-write the old data. + * @param t The table to add the data to. + * @param key The key fo use + * @param val The value to add + * @remark When adding data, this function makes a copy of both the key and the + * value. + } +procedure apr_table_set(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_set' + LibSuff12; + +{ + * Add a key/value pair to a table, if another element already exists with the + * same key, this will over-write the old data. + * @param t The table to add the data to. + * @param key The key to use + * @param val The value to add + * @warning When adding data, this function does not make a copy of the key or + * the value, so care should be taken to ensure that the values will + * not change after they have been added.. + } +procedure apr_table_setn(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_setn' + LibSuff12; + +{ + * Remove data from the table + * @param t The table to remove data from + * @param key The key of the data being removed + } +procedure apr_table_unset(t: Papr_table_t; const key: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_unset' + LibSuff8; + +{ + * Add data to a table by merging the value with data that has already been + * stored + * @param t The table to search for the data + * @param key The key to merge data for + * @param val The data to add + * @remark If the key is not found, then this function acts like apr_table_add + } +procedure apr_table_merge(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_merge' + LibSuff12; + +{ + * Add data to a table by merging the value with data that has already been + * stored + * @param t The table to search for the data + * @param key The key to merge data for + * @param val The data to add + * @remark If the key is not found, then this function acts like apr_table_addn + } +procedure apr_table_mergen(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_mergen' + LibSuff12; + +{ + * Add data to a table, regardless of whether there is another element with the + * same key. + * @param t The table to add to + * @param key The key to use + * @param val The value to add. + * @remark When adding data, this function makes a copy of both the key and the + * value. + } +procedure apr_table_add(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_add' + LibSuff12; + +{ + * Add data to a table, regardless of whether there is another element with the + * same key. + * @param t The table to add to + * @param key The key to use + * @param val The value to add. + * @remark When adding data, this function does not make a copy of the key or the + * value, so care should be taken to ensure that the values will not + * change after they have been added.. + } +procedure apr_table_addn(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_addn' + LibSuff12; + +{ + * Merge two tables into one new table + * @param p The pool to use for the new table + * @param overlay The first table to put in the new table + * @param base The table to add at the end of the new table + * @return A new table containing all of the data from the two passed in + } +function apr_table_overlay(t: Papr_table_t; + const overlay, base: Papr_table_t): Papr_table_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_overlay' + LibSuff12; + +{ + * Declaration prototype for the iterator callback function of apr_table_do() + * and apr_table_vdo(). + * @param rec The data passed as the first argument to apr_table_[v]do() + * @param key The key from this iteration of the table + * @param value The value from this iteration of the table + * @remark Iteration continues while this callback function returns non-zero. + * To export the callback function for apr_table_[v]do() it must be declared + * in the _NONSTD convention. + } +type + apr_table_do_callback_fn_t = function (rec: Pointer; + const key, value: PChar): Integer; + + Papr_table_do_callback_fn_t = ^apr_table_do_callback_fn_t; + +{ + * Iterate over a table running the provided function once for every + * element in the table. If there is data passed in as a vararg, then the + * function is only run on those elements whose key matches something in + * the vararg. If the vararg is NULL, then every element is run through the + * function. Iteration continues while the function returns non-zero. + * @param comp The function to run + * @param rec The data to pass as the first argument to the function + * @param t The table to iterate over + * @param ... The vararg. If this is NULL, then all elements in the table are + * run through the function, otherwise only those whose key matches + * are run. + * @return FALSE if one of the comp() iterations returned zero; TRUE if all + * iterations returned non-zero + * @see apr_table_do_callback_fn_t + } +{APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, + void *rec, const apr_table_t *t, ...); +} +{ + * Iterate over a table running the provided function once for every + * element in the table. If there is data passed in as a vararg, then the + * function is only run on those element's whose key matches something in + * the vararg. If the vararg is NULL, then every element is run through the + * function. Iteration continues while the function returns non-zero. + * @param comp The function to run + * @param rec The data to pass as the first argument to the function + * @param t The table to iterate over + * @param vp The vararg table. If this is NULL, then all elements in the + * table are run through the function, otherwise only those + * whose key matches are run. + * @return FALSE if one of the comp() iterations returned zero; TRUE if all + * iterations returned non-zero + * @see apr_table_do_callback_fn_t + } +function apr_table_vdo(comp: Papr_table_do_callback_fn_t; + rec: Pointer; const t: Papr_table_t; vp: va_list): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_vdo' + LibSuff16; + +const + { flag for overlap to use apr_table_setn } + APR_OVERLAP_TABLES_SET = 0; + { flag for overlap to use apr_table_mergen } + APR_OVERLAP_TABLES_MERGE = 1; + +{ + * For each element in table b, either use setn or mergen to add the data + * to table a. Which method is used is determined by the flags passed in. + * @param a The table to add the data to. + * @param b The table to iterate over, adding its data to table a + * @param flags How to add the table to table a. One of: + * APR_OVERLAP_TABLES_SET Use apr_table_setn + * APR_OVERLAP_TABLES_MERGE Use apr_table_mergen + * @remark This function is highly optimized, and uses less memory and CPU cycles + * than a function that just loops through table b calling other functions. + } +{ + *
+ * Conceptually, apr_table_overlap does this: + * + * apr_array_header_t *barr = apr_table_elts(b); + * apr_table_entry_t *belt = (apr_table_entry_t *)barr->elts; + * int i; + * + * for (i = 0; i < barr->nelts; ++i) ( + * if (flags & APR_OVERLAP_TABLES_MERGE) ( + * apr_table_mergen(a, belt[i].key, belt[i].val); + * ) + * else ( + * apr_table_setn(a, belt[i].key, belt[i].val); + * ) + * ) + * + * Except that it is more efficient (less space and cpu-time) especially + * when b has many elements. + * + * Notice the assumptions on the keys and values in b -- they must be + * in an ancestor of a's pool. In practice b and a are usually from + * the same pool. + *+ } +procedure apr_table_overlap(a: Papr_table_t; + const b: Papr_table_t; flags: cuint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_overlap' + LibSuff12; + +{ + * Eliminate redunandant entries in a table by either overwriting + * or merging duplicates + * + * @param t Table. + * @param flags APR_OVERLAP_TABLES_MERGE to merge, or + * APR_OVERLAP_TABLES_SET to overwrite + } +procedure apr_table_compress(t: Papr_table_t; flags: cuint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_compress' + LibSuff8; + diff --git a/httpd/httpd_2_0/apr/apr_thread_proc.inc b/httpd/httpd_2_0/apr/apr_thread_proc.inc new file mode 100644 index 000000000..c6c5cfadf --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_thread_proc.inc @@ -0,0 +1,845 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_thread_proc.h + * @brief APR Thread and Process Library + } + +{#include "apr.h" +#include "apr_file_io.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#if APR_HAVE_STRUCT_RLIMIT +#include
+ * APR_SHELLCMD -- Anything that the shell can handle + * APR_PROGRAM -- Executable program (default) + * APR_PROGRAM_ENV -- Executable program, copy environment + * APR_PROGRAM_PATH -- Executable program on PATH, copy env + *+ } +function apr_procattr_cmdtype_set(attr: Papr_procattr_t; cmd: apr_cmdtype_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_cmdtype_set' + LibSuff8; + +{ + * Determine if the child should start in detached state. + * @param attr The procattr we care about. + * @param detach Should the child start in detached state? Default is no. + } +function apr_procattr_detach_set(attr: Papr_procattr_t; detach: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_detach_set' + LibSuff8; + +{$ifdef APR_HAVE_STRUCT_RLIMIT} +{ + * Set the Resource Utilization limits when starting a new process. + * @param attr The procattr we care about. + * @param what Which limit to set, one of: + *
+ * APR_LIMIT_CPU + * APR_LIMIT_MEM + * APR_LIMIT_NPROC + * APR_LIMIT_NOFILE + *+ * @param limit Value to set the limit to. + } +function apr_procattr_limit_set(attr: Papr_procattr_t; what: apr_int32_t; + limit: Pointer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_limit_set' + LibSuff12; + +{$endif} + +{ + * Specify an error function to be called in the child process if APR + * encounters an error in the child prior to running the specified program. + * @param attr The procattr describing the child process to be created. + * @param errfn The function to call in the child process. + * @remark At the present time, it will only be called from apr_proc_create() + * on platforms where fork() is used. It will never be called on other + * platforms, on those platforms apr_proc_create() will return the error + * in the parent process rather than invoke the callback in the now-forked + * child process. + } +function apr_procattr_child_errfn_set(attr: Papr_procattr_t; errfn: apr_child_errfn_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_child_errfn_set' + LibSuff8; + +{ + * Specify that apr_proc_create() should do whatever it can to report + * failures to the caller of apr_proc_create(), rather than find out in + * the child. + * @param attr The procattr describing the child process to be created. + * @param chk Flag to indicate whether or not extra work should be done + * to try to report failures to the caller. + * @remark This flag only affects apr_proc_create() on platforms where + * fork() is used. This leads to extra overhead in the calling + * process, but that may help the application handle such + * errors more gracefully. + } +function apr_procattr_error_check_set(attr: Papr_procattr_t; chk: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_error_check_set' + LibSuff8; + +{ + * Determine if the child should start in its own address space or using the + * current one from its parent + * @param attr The procattr we care about. + * @param addrspace Should the child start in its own address space? Default + * is no on NetWare and yes on other platforms. + } +function apr_procattr_addrspace_set(attr: Papr_procattr_t; addrspace: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_addrspace_set' + LibSuff8; + +{$ifdef APR_HAS_FORK} +{ + * This is currently the only non-portable call in APR. This executes + * a standard unix fork. + * @param proc The resulting process handle. + * @param cont The pool to use. + } +function apr_proc_fork(proc: Papr_proc_t; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_fork' + LibSuff8; + +{$endif} + +{ + * Create a new process and execute a new program within that process. + * @param new_proc The resulting process handle. + * @param progname The program to run + * @param args the arguments to pass to the new program. The first + * one should be the program name. + * @param env The new environment table for the new process. This + * should be a list of NULL-terminated strings. This argument + * is ignored for APR_PROGRAM_ENV, APR_PROGRAM_PATH, and + * APR_SHELLCMD_ENV types of commands. + * @param attr the procattr we should use to determine how to create the new + * process + * @param cont The pool to use. + } +function apr_proc_create(new_proc: Papr_proc_t; + const progname: PChar; args, arnv: PPChar; + attr: Papr_procattr_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_create' + LibSuff24; + +{ + * Wait for a child process to die + * @param proc The process handle that corresponds to the desired child process + * @param exitcode The returned exit status of the child, if a child process + * dies, or the signal that caused the child to die. + * On platforms that don't support obtaining this information, + * the status parameter will be returned as APR_ENOTIMPL. + * @param exitwhy Why the child died, the bitwise or of: + *
+ * APR_PROC_EXIT -- process terminated normally + * APR_PROC_SIGNAL -- process was killed by a signal + * APR_PROC_SIGNAL_CORE -- process was killed by a signal, and + * generated a core dump. + *+ * @param waithow How should we wait. One of: + *
+ * APR_WAIT -- block until the child process dies. + * APR_NOWAIT -- return immediately regardless of if the + * child is dead or not. + *+ * @remark The childs status is in the return code to this process. It is one of: + *
+ * APR_CHILD_DONE -- child is no longer running. + * APR_CHILD_NOTDONE -- child is still running. + *+ } +function apr_proc_wait(proc: Papr_proc_t; exitcode: PInteger; + exitwhy: Papr_exit_why_e; waithow: apr_wait_how_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_wait' + LibSuff16; + +{ + * Wait for any current child process to die and return information + * about that child. + * @param proc Pointer to NULL on entry, will be filled out with child's + * information + * @param exitcode The returned exit status of the child, if a child process + * dies, or the signal that caused the child to die. + * On platforms that don't support obtaining this information, + * the status parameter will be returned as APR_ENOTIMPL. + * @param exitwhy Why the child died, the bitwise or of: + *
+ * APR_PROC_EXIT -- process terminated normally + * APR_PROC_SIGNAL -- process was killed by a signal + * APR_PROC_SIGNAL_CORE -- process was killed by a signal, and + * generated a core dump. + *+ * @param waithow How should we wait. One of: + *
+ * APR_WAIT -- block until the child process dies. + * APR_NOWAIT -- return immediately regardless of if the + * child is dead or not. + *+ * @param p Pool to allocate child information out of. + * @bug Passing proc as a *proc rather than **proc was an odd choice + * for some platforms... this should be revisited in 1.0 + } +function apr_proc_wait_all_procs(proc: Papr_proc_t; exitcode: PInteger; + exitwhy: Papr_exit_why_e; waithow: apr_wait_how_e; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_wait_all_procs' + LibSuff20; + +const + APR_PROC_DETACH_FOREGROUND = 0; {< Do not detach } + APR_PROC_DETACH_DAEMONIZE = 1; {< Detach } + +{ + * Detach the process from the controlling terminal. + * @param daemonize set to non-zero if the process should daemonize + * and become a background process, else it will + * stay in the foreground. + } +{ Not present on the dll } +//function apr_proc_detach(daemonize: Integer): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_proc_detach' + LibSuff4; + +{ + * Register an other_child -- a child associated to its registered + * maintence callback. This callback is invoked when the process + * dies, is disconnected or disappears. + * @param proc The child process to register. + * @param maintenance maintenance is a function that is invoked with a + * reason and the data pointer passed here. + * @param data Opaque context data passed to the maintenance function. + * @param write_fd An fd that is probed for writing. If it is ever unwritable + * then the maintenance is invoked with reason + * OC_REASON_UNWRITABLE. + * @param p The pool to use for allocating memory. + * @bug write_fd duplicates the proc->out stream, it's really redundant + * and should be replaced in the APR 1.0 API with a bitflag of which + * proc->in/out/err handles should be health checked. + * @bug no platform currently tests the pipes health. + } +type + maintenance_t = procedure (reason: Integer; param: Pointer; status: Integer); + +procedure apr_proc_other_child_register(proc: Papr_proc_t; + maintenance: maintenance_t; data: Pointer; write_fd: Papr_file_t; + p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_register' + LibSuff20; + +{ + * Stop watching the specified other child. + * @param data The data to pass to the maintenance function. This is + * used to find the process to unregister. + * @warning Since this can be called by a maintenance function while we're + * scanning the other_children list, all scanners should protect + * themself by loading ocr->next before calling any maintenance + * function. + } +procedure apr_proc_other_child_unregister(data: Pointer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_unregister' + LibSuff4; + +{ + * Notify the maintenance callback of a registered other child process + * that application has detected an event, such as death. + * @param proc The process to check + * @param reason The reason code to pass to the maintenance function + * @param status The status to pass to the maintenance function + * @remark An example of code using this behavior; + *
+ * rv = apr_proc_wait_all_procs(&proc, &exitcode, &status, APR_WAIT, p); + * if (APR_STATUS_IS_CHILD_DONE(rv)) ( + * #if APR_HAS_OTHER_CHILD + * if (apr_proc_other_child_alert(&proc, APR_OC_REASON_DEATH, status) + * == APR_SUCCESS) ( + * ; (already handled) + * ) + * else + * #endif + * [... handling non-otherchild processes death ...] + *+ } +function apr_proc_other_child_alert(proc: Papr_proc_t; + reason, status: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_alert' + LibSuff12; + +{ + * Test one specific other child processes and invoke the maintenance callback + * with the appropriate reason code, if still running, or the appropriate reason + * code if the process is no longer healthy. + * @param ocr The registered other child + * @param reason The reason code (e.g. APR_OC_REASON_RESTART) if still running + } +procedure apr_proc_other_child_refresh(ocr: Papr_other_child_rec_t; reason: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_refresh' + LibSuff8; + +{ + * Test all registered other child processes and invoke the maintenance callback + * with the appropriate reason code, if still running, or the appropriate reason + * code if the process is no longer healthy. + * @param reason The reason code (e.g. APR_OC_REASON_RESTART) to running processes + } +procedure apr_proc_other_child_refresh_all(reason: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_refresh_all' + LibSuff4; + +{ @deprecated @see apr_proc_other_child_refresh_all + * @remark Call apr_proc_other_child_refresh_all(APR_OC_REASON_RESTART) + * or apr_proc_other_child_refresh_all(APR_OC_REASON_RUNNING) instead. + * @bug The differing implementations of this function on Win32 (_RUNNING checks) + * and Unix (used only for _RESTART) are the reason it will be dropped with APR 1.0. + } +procedure apr_proc_other_child_check; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_check' + LibSuff0; + +{ @deprecated @see apr_proc_other_child_alert + * @bug This function's name had nothing to do with it's purpose + } +function apr_proc_other_child_read(proc: Papr_proc_t; status: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_read' + LibSuff8; + +{ + * Terminate a process. + * @param proc The process to terminate. + * @param sig How to kill the process. + } +function apr_proc_kill(proc: Papr_proc_t; sig: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_kill' + LibSuff8; + +{ + * Register a process to be killed when a pool dies. + * @param a The pool to use to define the processes lifetime + * @param proc The process to register + * @param how How to kill the process, one of: + *
+ * APR_KILL_NEVER -- process is never sent any signals + * APR_KILL_ALWAYS -- process is sent SIGKILL on apr_pool_t cleanup + * APR_KILL_AFTER_TIMEOUT -- SIGTERM, wait 3 seconds, SIGKILL + * APR_JUST_WAIT -- wait forever for the process to complete + * APR_KILL_ONLY_ONCE -- send SIGTERM and then wait + *+ } +procedure apr_pool_note_subprocess(a: Papr_pool_t; + proc: Papr_proc_t; how: apr_kill_conditions_e); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_note_subprocess' + LibSuff12; + +{.$ifdef APR_HAS_THREADS} + +{$if (defined(APR_HAVE_SIGWAIT) or defined(APR_HAVE_SIGSUSPEND)) and not defined(OS2)} + +{ + * Setup the process for a single thread to be used for all signal handling. + * @warning This must be called before any threads are created + } +function apr_setup_signal_thread: apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_setup_signal_thread' + LibSuff0; + +{ + * Make the current thread listen for signals. This thread will loop + * forever, calling a provided function whenever it receives a signal. That + * functions should return 1 if the signal has been handled, 0 otherwise. + * @param signal_handler The function to call when a signal is received + * apr_status_t apr_signal_thread((int)( *signal_handler)(int signum)) + } +type + signal_handler_t = function (signum: Integer): Integer; + +function apr_signal_thread(signal_handler: signal_handler_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_signal_thread' + LibSuff8; + +{$endif} { (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) } + +{ + * Get the child-pool used by the thread from the thread info. + * @return apr_pool_t the pool + } +//APR_POOL_DECLARE_ACCESSOR(thread); + +//#endif { APR_HAS_THREADS } + diff --git a/httpd/httpd_2_0/apr/apr_time.inc b/httpd/httpd_2_0/apr/apr_time.inc new file mode 100644 index 000000000..929d6930d --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_time.inc @@ -0,0 +1,262 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_time.h + * @brief APR Time Library + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h"} + +{ + * @defgroup apr_time Time Routines + * @ingroup APR + } + +{ month names } +//APR_DECLARE_DATA extern const char apr_month_snames[12][4]; +{ day names } +//APR_DECLARE_DATA extern const char apr_day_snames[7][4]; + + +{ number of microseconds since 00:00:00 january 1, 1970 UTC } +type + apr_time_t = apr_int64_t; + Papr_time_t = ^apr_time_t; + + +{ mechanism to properly type apr_time_t literals } +//#define APR_TIME_C(val) APR_INT64_C(val) + +{ mechanism to properly print apr_time_t values } +// APR_TIME_T_FMT = APR_INT64_T_FMT; + +{ intervals for I/O timeouts, in microseconds } + apr_interval_time_t = apr_int64_t; + Papr_interval_time_t = ^apr_interval_time_t; +{ short interval for I/O timeouts, in microseconds } + apr_short_interval_time_t = apr_int32_t; + +{ number of microseconds per second } +// APR_USEC_PER_SEC APR_TIME_C(1000000) + +{ @return apr_time_t as a second } +//#define apr_time_sec(time) ((time) / APR_USEC_PER_SEC) + +{ @return apr_time_t as a usec } +//#define apr_time_usec(time) ((time) % APR_USEC_PER_SEC) + +{ @return apr_time_t as a msec } +//#define apr_time_msec(time) (((time) / 1000) % 1000) + +{ @return apr_time_t as a msec } +//#define apr_time_as_msec(time) ((time) / 1000) + +{ @return a second as an apr_time_t } +//#define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC) + +{ @return a second and usec combination as an apr_time_t } +//#define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \ +// + (apr_time_t)(usec)) + +{ + * @return the current time + } +function apr_time_now: apr_time_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_now' + LibSuff0; + +{ @see apr_time_exp_t } +type + Papr_time_exp_t = ^apr_time_exp_t; + +{ + * a structure similar to ANSI struct tm with the following differences: + * - tm_usec isn't an ANSI field + * - tm_gmtoff isn't an ANSI field (it's a bsdism) + } + apr_time_exp_t = record + { microseconds past tm_sec } + tm_usec: apr_int32_t; + { (0-61) seconds past tm_min } + tm_sec: apr_int32_t; + { (0-59) minutes past tm_hour } + tm_min: apr_int32_t; + { (0-23) hours past midnight } + tm_hour: apr_int32_t; + { (1-31) day of the month } + tm_mday: apr_int32_t; + { (0-11) month of the year } + tm_mon: apr_int32_t; + { year since 1900 } + tm_year: apr_int32_t; + { (0-6) days since sunday } + tm_wday: apr_int32_t; + { (0-365) days since jan 1 } + tm_yday: apr_int32_t; + { daylight saving time } + tm_isdst: apr_int32_t; + { seconds east of UTC } + tm_gmtoff: apr_int32_t; + end; + +{ + * convert an ansi time_t to an apr_time_t + * @param result the resulting apr_time_t + * @param input the time_t to convert + } +function apr_time_ansi_put(result: Papr_time_t; + input: time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_ansi_put' + LibSuff8; + +{ + * convert a time to its human readable components using an offset + * from GMT + * @param result the exploded time + * @param input the time to explode + * @param offs the number of seconds offset to apply + } +function apr_time_exp_tz(result: Papr_time_exp_t; + input: apr_time_t; offs: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_tz' + LibSuff16; + +{ @deprecated @see apr_time_exp_tz } +function apr_explode_time(result: Papr_time_exp_t; + input: apr_time_t; offs: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_explode_time' + LibSuff16; + +{ + * convert a time to its human readable components in GMT timezone + * @param result the exploded time + * @param input the time to explode + } +function apr_time_exp_gmt(result: Papr_time_exp_t; + input: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_gmt' + LibSuff12; + +{ + * convert a time to its human readable components in local timezone + * @param result the exploded time + * @param input the time to explode + } +function apr_time_exp_lt(result: Papr_time_exp_t; + input: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_lt' + LibSuff12; + +{ @deprecated @see apr_time_exp_lt } +function apr_explode_localtime(result: Papr_time_exp_t; + input: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_explode_localtime' + LibSuff12; + +{ + * Convert time value from human readable format to a numeric apr_time_t + * e.g. elapsed usec since epoch + * @param result the resulting imploded time + * @param input the input exploded time + } +function apr_time_exp_get(result: Papr_time_t; + input: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_get' + LibSuff8; + +{ + * Convert time value from human readable format to a numeric apr_time_t that + * always represents GMT + * @param result the resulting imploded time + * @param input the input exploded time + } +function apr_time_exp_gmt_get(result: Papr_time_t; + input: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_gmt_get' + LibSuff8; + +{ @deprecated @see apr_time_exp_gmt_get } +function apr_implode_gmt(result: Papr_time_t; + input: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_implode_gmt' + LibSuff8; + +{ + * Sleep for the specified number of micro-seconds. + * @param t desired amount of time to sleep. + * @warning May sleep for longer than the specified time. + } +procedure apr_sleep(t: apr_interval_time_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sleep' + LibSuff8; + +{ length of a RFC822 Date } +const APR_RFC822_DATE_LEN = (30); +{ + * apr_rfc822_date formats dates in the RFC822 + * format in an efficient manner. It is a fixed length + * format which requires the indicated amount of storage, + * including the trailing null byte. + * @param date_str String to write to. + * @param t the time to convert + } +function apr_rfc822_date(date_str: PChar; t: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_rfc822_date' + LibSuff12; + +{ length of a CTIME date } +const APR_CTIME_LEN = (25); +{ + * apr_ctime formats dates in the ctime() format + * in an efficient manner. it is a fixed length format + * and requires the indicated amount of storage including + * the trailing null byte. + * Unlike ANSI/ISO C ctime(), apr_ctime() does not include + * a \n at the end of the string. + * @param date_str String to write to. + * @param t the time to convert + } +function apr_ctime(date_str: PChar; t: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ctime' + LibSuff12; + +{ + * formats the exploded time according to the format specified + * @param s string to write to + * @param retsize The length of the returned string + * @param max The maximum length of the string + * @param format The format for the time string + * @param tm The time to convert + } +function apr_strftime(s: PChar; retsize: apr_size_t; + max: apr_size_t; const format: PChar; + tm: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strftime' + LibSuff20; + +{ + * Improve the clock resolution for the lifetime of the given pool. + * Generally this is only desireable on benchmarking and other very + * time-sensitive applications, and has no impact on most platforms. + * @param p The pool to associate the finer clock resolution + } +procedure apr_time_clock_hires(p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_clock_hires' + LibSuff4; + diff --git a/httpd/httpd_2_0/apr/apr_user.inc b/httpd/httpd_2_0/apr/apr_user.inc new file mode 100644 index 000000000..39d496dd8 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_user.inc @@ -0,0 +1,197 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_user.h + * @brief APR User ID Services + } + +{#include "apr.h" +#include "apr_errno.h" +#include "apr_pools.h"} + +{ + * @defgroup apr_user User and Group ID Services + * @ingroup APR + } + +{ + * Structure for determining user ownership. + } +type +{$ifdef WIN32} + apr_uid_t = PSID; +{$else} + apr_uid_t = uid_t; +{$endif} + + Papr_uid_t = ^apr_uid_t; + +{ + * Structure for determining group ownership. + } +{$ifdef WIN32} + apr_gid_t = PSID; +{$else} + apr_gid_t = gid_t; +{$endif} + + Papr_gid_t = ^apr_gid_t; + +{$define APR_HAS_USER} + +{$ifdef APR_HAS_USER} + +{ + * Get the userid (and groupid) of the calling process + * @param userid Returns the user id + * @param groupid Returns the user's group id + * @param p The pool from which to allocate working space + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_current(userid: Papr_uid_t; groupid: Papr_gid_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_current' + LibSuff12; + +{ @deprecated @see apr_uid_current } +{APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid, + apr_gid_t *groupid, + apr_pool_t *p);} +{ + * Get the user name for a specified userid + * @param username Pointer to new string containing user name (on output) + * @param userid The userid + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_name_get(username: PPChar; userid: apr_uid_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_name_get' + LibSuff12; + +{ @deprecated @see apr_uid_name_get } +{APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, + apr_pool_t *p);} +{ + * Get the userid (and groupid) for the specified username + * @param userid Returns the user id + * @param groupid Returns the user's group id + * @param username The username to lookup + * @param p The pool from which to allocate working space + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_get(userid: Papr_uid_t; groupid: Papr_gid_t; + const username: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_get' + LibSuff16; + +{ @deprecated @see apr_uid_get } +{APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid, + const char *username, apr_pool_t *p);} + +{ + * Get the home directory for the named user + * @param dirname Pointer to new string containing directory name (on output) + * @param username The named user + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_homepath_get(dirname: PPChar; const username: PChar; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_homepath_get' + LibSuff12; + +{ @deprecated @see apr_uid_homepath_get } +{APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, + const char *username, + apr_pool_t *p);} + +{ + * Compare two user identifiers for equality. + * @param left One uid to test + * @param right Another uid to test + * @return APR_SUCCESS if the apr_uid_t strutures identify the same user, + * 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} +//APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); + +{ @deprecated @see apr_uid_compare } +//APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right); +{$else} +//#define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{ @deprecated @see apr_uid_compare } +//#define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{$endif} + +{ + * Get the group name for a specified groupid + * @param groupname Pointer to new string containing group name (on output) + * @param groupid The groupid + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_gid_name_get(groupname: PPChar; groupid: apr_gid_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_gid_name_get' + LibSuff12; + +{ @deprecated @see apr_gid_name_get } +{APR_DECLARE(apr_status_t) apr_group_name_get(char **groupname, + apr_gid_t groupid, apr_pool_t *p);} + +{ @deprecated @see apr_gid_name_get } +{APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, + apr_gid_t groupid, apr_pool_t *p);} + +{ + * Get the groupid for a specified group name + * @param groupid Pointer to the group id (on output) + * @param groupname The group name to look up + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_gid_get(groupid: Papr_gid_t; const groupname: PChar; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_gid_get' + LibSuff12; + +{ @deprecated @see apr_gid_get } +{APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid, + const char *groupname, apr_pool_t *p);} + +{ + * Compare two group identifiers for equality. + * @param left One gid to test + * @param right Another gid to test + * @return APR_SUCCESS if the apr_gid_t strutures identify the same group, + * 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} +//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); +{$else} +//#define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{ @deprecated @see apr_gid_compare } +//#define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{$endif} + +{$endif} { ! APR_HAS_USER } + diff --git a/httpd/httpd_2_0/apr/apr_version.inc b/httpd/httpd_2_0/apr/apr_version.inc new file mode 100644 index 000000000..0b6423298 --- /dev/null +++ b/httpd/httpd_2_0/apr/apr_version.inc @@ -0,0 +1,112 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr.h" + +{ + * @file apr_version.h + * @brief APR Versioning Interface + * + * APR's Version + * + * There are several different mechanisms for accessing the version. There + * is a string form, and a set of numbers; in addition, there are constants + * which can be compiled into your application, and you can query the library + * being used for its actual version. + * + * Note that it is possible for an application to detect that it has been + * compiled against a different version of APR by use of the compile-time + * constants and the use of the run-time query function. + * + * APR version numbering follows the guidelines specified in: + * + * http://apr.apache.org/versioning.html + } + +{ The numeric compile-time version constants. These constants are the + * authoritative version numbers for APR. + } + +{ major version + * Major API changes that could cause compatibility problems for older + * programs such as structure size changes. No binary compatibility is + * possible across a change in the major version. + } +const + APR_MAJOR_VERSION = 0; + +{ + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading APR_MAJOR_VERSION + } + APR_MINOR_VERSION = 9; + +{ patch level } + APR_PATCH_VERSION = 12; + +{ + * This symbol is defined for internal, "development" copies of APR. This + * symbol will be #undef'd for releases. + } +{.$undef APR_IS_DEV_VERSION} + + +{ The formatted string of APR's version } +{#define APR_VERSION_STRING \ + APR_STRINGIFY(APR_MAJOR_VERSION) "." \ + APR_STRINGIFY(APR_MINOR_VERSION) "." \ + APR_STRINGIFY(APR_PATCH_VERSION) \ + APR_IS_DEV_STRING} + + +{ + * The numeric version information is broken out into fields within this + * structure. + } +type + apr_version_t = record + major: Integer; {< major number } + minor: Integer; {< minor number } + patch: Integer; {< patch number } + is_dev: Integer; {< is development (1 or 0) } + end; + + Papr_version_t = ^apr_version_t; + +{ + * Return APR's version information information in a numeric form. + * + * @param pvsn Pointer to a version structure for returning the version + * information. + } +procedure apr_version(pvsn: Papr_version_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_version' + LibSuff4; + +{ Return APR's version information as a string. } +function apr_version_string: PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_version_string' + LibSuff0; + + +{ Internal: string form of the "is dev" flag } +{#ifdef APR_IS_DEV_VERSION +#define APR_IS_DEV_STRING "-dev" +#else} +const + APR_IS_DEV_STRING = ''; +//#endif + diff --git a/httpd/httpd_2_0/apriconv/api_version.inc b/httpd/httpd_2_0/apriconv/api_version.inc new file mode 100644 index 000000000..e92d5e83f --- /dev/null +++ b/httpd/httpd_2_0/apriconv/api_version.inc @@ -0,0 +1,99 @@ +{ Copyright 2000-2004 The Apache Software Foundation + * + * Licensed 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. + } + +{#include "apr.h" +#include "apr_version.h" + +#include "apr_iconv.h"} + +{ + * @file api_version.h + * @brief + * + * APR-iconv's Version + * + * There are several different mechanisms for accessing the version. There + * is a string form, and a set of numbers; in addition, there are constants + * which can be compiled into your application, and you can query the library + * being used for its actual version. + * + * Note that it is possible for an application to detect that it has been + * compiled against a different version of API by use of the compile-time + * constants and the use of the run-time query function. + * + * API version numbering follows the guidelines specified in: + * + * http://apr.apache.org/versioning.html + } + +{ The numeric compile-time version constants. These constants are the + * authoritative version numbers for API. + } + +{ major version + * Major API changes that could cause compatibility problems for older + * programs such as structure size changes. No binary compatibility is + * possible across a change in the major version. + } +const + API_MAJOR_VERSION = 0; + +{ + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading API_MAJOR_VERSION + } + API_MINOR_VERSION = 9; + +{ patch level } + API_PATCH_VERSION = 7; + +{ + * This symbol is defined for internal, "development" copies of API. This + * symbol will be #undef'd for releases. + } +{ #define API_IS_DEV_VERSION } + + +{ The formatted string of API's version } +{#define API_VERSION_STRING \ + APR_STRINGIFY(API_MAJOR_VERSION) "." \ + APR_STRINGIFY(API_MINOR_VERSION) "." \ + APR_STRINGIFY(API_PATCH_VERSION) \ + API_IS_DEV_STRING} + +{ + * Return APR-util's version information information in a numeric form. + * + * @param pvsn Pointer to a version structure for returning the version + * information. + } +//procedure api_version(pvsn: Papr_version_t); +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPRIconv name LibNamePrefix + 'api_version' + LibSuff4; + +{ Return API's version information as a string. } +//function api_version_string: PChar; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPRIconv name LibNamePrefix + 'api_version_string' + LibSuff0; + + +{ Internal: string form of the "is dev" flag } +const +{$ifdef API_IS_DEV_VERSION} + API_IS_DEV_STRING = '-dev'; +{$else} + API_IS_DEV_STRING = ''; +{$endif} + diff --git a/httpd/httpd_2_0/apriconv/apr_iconv.inc b/httpd/httpd_2_0/apriconv/apr_iconv.inc new file mode 100644 index 000000000..6550e1766 --- /dev/null +++ b/httpd/httpd_2_0/apriconv/apr_iconv.inc @@ -0,0 +1,113 @@ +{- + * Copyright (c) 1999,2000 + * Konstantin Chuguev. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Konstantin Chuguev + * and its contributors. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + } + +{#include "apr.h" +#include "apr_pools.h" +#include
+ * APR_URI_UNP_OMITSITEPART Suppress "scheme://user\@site:port" + * APR_URI_UNP_OMITUSER Just omit user + * APR_URI_UNP_OMITPASSWORD Just omit password + * APR_URI_UNP_OMITUSERINFO Omit "user:password\@" part + * APR_URI_UNP_REVEALPASSWORD Show plain text password (default: show XXXXXXXX) + * APR_URI_UNP_OMITPATHINFO Show "scheme://user\@site:port" only + * APR_URI_UNP_OMITQUERY Omit "?queryarg" or "#fragment" + *+ * @return The uri as a string + } +function apr_uri_unparse(p: Papr_pool_t; const uptr: Papr_uri_t; + flags: cuint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_uri_unparse' + LibSuff12; + +{ + * Parse a given URI, fill in all supplied fields of a apr_uri_t + * structure. This eliminates the necessity of extracting host, port, + * path, query info repeatedly in the modules. + * @param p The pool to allocate out of + * @param uri The uri to parse + * @param uptr The apr_uri_t to fill out + * @return APR_SUCCESS for success or error code + } +function apr_uri_parse(p: Papr_pool_t; const uri: PChar; + uptr: Papr_uri_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_uri_parse' + LibSuff12; + +{ + * Special case for CONNECT parsing: it comes with the hostinfo part only + * @param p The pool to allocate out of + * @param hostinfo The hostinfo string to parse + * @param uptr The apr_uri_t to fill out + * @return APR_SUCCESS for success or error code + } +function apr_uri_parse_hostinfo(p: Papr_pool_t; + const hostinfo: PChar; uptr: Papr_uri_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_uri_parse_hostinfo' + LibSuff12; + diff --git a/httpd/httpd_2_0/aprutil/apr_xlate.inc b/httpd/httpd_2_0/aprutil/apr_xlate.inc new file mode 100644 index 000000000..7ecd65b69 --- /dev/null +++ b/httpd/httpd_2_0/aprutil/apr_xlate.inc @@ -0,0 +1,152 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{#include "apu.h" +#include "apr_pools.h" +#include "apr_errno.h"} + +{ + * @file apr_xlate.h + * @brief APR I18N translation library + } + +{ + * @defgroup APR_XLATE I18N translation library + * @ingroup APR + } +{ Opaque translation buffer } +type + Papr_xlate_t = Pointer; + PPapr_xlate_t = ^Papr_xlate_t; + +{ + * Set up for converting text from one charset to another. + * @param convset The handle to be filled in by this function + * @param topage The name of the target charset + * @param frompage The name of the source charset + * @param pool The pool to use + * @remark + * Specify APR_DEFAULT_CHARSET for one of the charset + * names to indicate the charset of the source code at + * compile time. This is useful if there are literal + * strings in the source code which must be translated + * according to the charset of the source code. + * APR_DEFAULT_CHARSET is not useful if the source code + * of the caller was not encoded in the same charset as + * APR at compile time. + * + * @remark + * Specify APR_LOCALE_CHARSET for one of the charset + * names to indicate the charset of the current locale. + * + * @remark + * Return APR_EINVAL if unable to procure a convset, or APR_ENOTIMPL + * if charset transcoding is not available in this instance of + * apr-util at all (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_open(convset: PPapr_xlate_t; + const topage, frompage: PChar; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_open' + LibSuff16; + +{ + * This is to indicate the charset of the sourcecode at compile time + * names to indicate the charset of the source code at + * compile time. This is useful if there are literal + * strings in the source code which must be translated + * according to the charset of the source code. + } +//#define APR_DEFAULT_CHARSET (const char *)0 +{ + * To indicate charset names of the current locale + } +//#define APR_LOCALE_CHARSET (const char *)1 + +{ + * Find out whether or not the specified conversion is single-byte-only. + * @param convset The handle allocated by apr_xlate_open, specifying the + * parameters of conversion + * @param onoff Output: whether or not the conversion is single-byte-only + * @remark + * Return APR_ENOTIMPL if charset transcoding is not available + * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_sb_get(convset: Papr_xlate_t; onoff: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_sb_get' + LibSuff8; + +{ @deprecated @see apr_xlate_sb_get } +function apr_xlate_get_sb(convset: Papr_xlate_t; onoff: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_get_sb' + LibSuff8; + +{ + * Convert a buffer of text from one codepage to another. + * @param convset The handle allocated by apr_xlate_open, specifying + * the parameters of conversion + * @param inbuf The address of the source buffer + * @param inbytes_left Input: the amount of input data to be translated + * Output: the amount of input data not yet translated + * @param outbuf The address of the destination buffer + * @param outbytes_left Input: the size of the output buffer + * Output: the amount of the output buffer not yet used + * @remark + * Return APR_ENOTIMPL if charset transcoding is not available + * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_conv_buffer(convset: Papr_xlate_t; const inbuf: PChar; + inbytes_left: Papr_size_t; outbuf: PChar; outbytes_left: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_buffer' + LibSuff20; + +{ @see apr_file_io.h the comment in apr_file_io.h about this hack } +{$ifdef APR_NOT_DONE_YET} +{ + * The purpose of apr_xlate_conv_char is to translate one character + * at a time. This needs to be written carefully so that it works + * with double-byte character sets. + * @param convset The handle allocated by apr_xlate_open, specifying the + * parameters of conversion + * @param inchar The character to convert + * @param outchar The converted character + } +APU_DECLARE(apr_status_t) apr_xlate_conv_char(apr_xlate_t *convset, + char inchar, char outchar); +{$endif} + +{ + * Convert a single-byte character from one charset to another. + * @param convset The handle allocated by apr_xlate_open, specifying the + * parameters of conversion + * @param inchar The single-byte character to convert. + * @warning This only works when converting between single-byte character sets. + * -1 will be returned if the conversion can't be performed. + } +function apr_xlate_conv_byte(convset: Papr_xlate_t; inchar: Char): apr_int32_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_byte' + LibSuff8; + +{ + * Close a codepage translation handle. + * @param convset The codepage translation handle to close + * @remark + * Return APR_ENOTIMPL if charset transcoding is not available + * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_close(convset: Papr_xlate_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_close' + LibSuff4; + diff --git a/httpd/httpd_2_0/aprutil/apr_xml.inc b/httpd/httpd_2_0/aprutil/apr_xml.inc new file mode 100644 index 000000000..9c5a7ecad --- /dev/null +++ b/httpd/httpd_2_0/aprutil/apr_xml.inc @@ -0,0 +1,349 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +{ + * @file apr_xml.h + * @brief APR-UTIL XML Library + } + +{ + * @defgroup APR_Util_XML XML + * @ingroup APR_Util + } +{#include "apr_pools.h" +#include "apr_tables.h" +#include "apr_file_io.h" + +#include "apu.h"} + +{ + * @package Apache XML library + } + +{ -------------------------------------------------------------------- } + +{ ### these will need to move at some point to a more logical spot } + +{ @see apr_text } +type + Papr_text = ^apr_text; + + { Structure to keep a linked list of pieces of text } + + apr_text = record + { The current piece of text } + text: PChar; + { a pointer to the next piece of text } + next: Papr_text; + end; + +{ @see apr_text_header } + Papr_text_header = ^apr_text_header; + +{ A list of pieces of text } + apr_text_header = record + { The first piece of text in the list } + first: Papr_text; + { The last piece of text in the list } + last: Papr_text; + end; + +{ + * Append a piece of text to the end of a list + * @param p The pool to allocate out of + * @param hdr The text header to append to + * @param text The new text to append + } +procedure apr_text_append(p: Papr_pool_t; hdr: Papr_text_header; + const text: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_text_append' + LibSuff12; + +{ -------------------------------------------------------------------- +** +** XML PARSING +} + +{ +** Qualified namespace values +** +** APR_XML_NS_DAV_ID +** We always insert the "DAV:" namespace URI at the head of the +** namespace array. This means that it will always be at ID==0, +** making it much easier to test for. +** +** APR_XML_NS_NONE +** This special ID is used for two situations: +** +** 1) The namespace prefix begins with "xml" (and we do not know +** what it means). Namespace prefixes with "xml" (any case) as +** their first three characters are reserved by the XML Namespaces +** specification for future use. mod_dav will pass these through +** unchanged. When this identifier is used, the prefix is LEFT in +** the element/attribute name. Downstream processing should not +** prepend another prefix. +** +** 2) The element/attribute does not have a namespace. +** +** a) No prefix was used, and a default namespace has not been +** defined. +** b) No prefix was used, and the default namespace was specified +** to mean "no namespace". This is done with a namespace +** declaration of: xmlns="" +** (this declaration is typically used to override a previous +** specification for the default namespace) +** +** In these cases, we need to record that the elem/attr has no +** namespace so that we will not attempt to prepend a prefix. +** All namespaces that are used will have a prefix assigned to +** them -- mod_dav will never set or use the default namespace +** when generating XML. This means that "no prefix" will always +** mean "no namespace". +** +** In both cases, the XML generation will avoid prepending a prefix. +** For the first case, this means the original prefix/name will be +** inserted into the output stream. For the latter case, it means +** the name will have no prefix, and since we never define a default +** namespace, this means it will have no namespace. +** +** Note: currently, mod_dav understands the "xmlns" prefix and the +** "xml:lang" attribute. These are handled specially (they aren't +** left within the XML tree), so the APR_XML_NS_NONE value won't ever +** really apply to these values. +} +const + APR_XML_NS_DAV_ID = 0; {< namespace ID for "DAV:" } + APR_XML_NS_NONE = -10; {< no namespace for this elem/attr } + + APR_XML_NS_ERROR_BASE = -100; {< used only during processing } +{ Is this namespace an error? } +// APR_XML_NS_IS_ERROR(e) ((e) <= APR_XML_NS_ERROR_BASE) + +type +{ @see apr_xml_attr } + Papr_xml_attr = ^apr_xml_attr; +{ @see apr_xml_elem } + Papr_xml_elem = ^apr_xml_elem; +{ @see apr_xml_doc } + Papr_xml_doc = ^apr_xml_doc; + PPapr_xml_doc = ^Papr_xml_doc; + +{ apr_xml_attr: holds a parsed XML attribute } + apr_xml_attr = record + { attribute name } + name: PChar; + { index into namespace array } + ns: Integer; + + { attribute value } + value: PChar; + + { next attribute } + next: Papr_xml_attr; + end; + +{ apr_xml_elem: holds a parsed XML element } + apr_xml_elem = record + { element name } + name: PChar; + { index into namespace array } + ns: Integer; + { xml:lang for attrs/contents } + lang: PChar; + + { cdata right after start tag } + first_cdata: apr_text_header; + { cdata after MY end tag } + following_cdata: apr_text_header; + + { parent element } + parent: Papr_xml_elem; + { next (sibling) element } + next: Papr_xml_elem; + { first child element } + first_child: Papr_xml_elem; + { first attribute } + attr: Papr_xml_attr; + + { used only during parsing } + { last child element } + last_child: Papr_xml_elem; + { namespaces scoped by this elem } + ns_scope: Papr_xml_ns_scope; + + { used by modules during request processing } + { Place for modules to store private data } + priv: Pointer; + end; + +{ Is this XML element empty? } +//#define APR_XML_ELEM_IS_EMPTY(e) ((e)->first_child == NULL && \ +// (e)->first_cdata.first == NULL) + +{ apr_xml_doc: holds a parsed XML document } + apr_xml_doc = record + { root element } + root: Papr_xml_elem; + { array of namespaces used } + namespaces: Papr_array_header_t; + end; + +{ Opaque XML parser structure } + apr_xml_parser = record end; + Papr_xml_parser = ^apr_xml_parser; + PPapr_xml_parser = ^Papr_xml_parser; + +{ + * Create an XML parser + * @param pool The pool for allocating the parser and the parse results. + * @return The new parser. + } +function apr_xml_parser_create(pool: Papr_pool_t): Papr_xml_parser; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_create' + LibSuff4; + +{ + * Parse a File, producing a xml_doc + * @param p The pool for allocating the parse results. + * @param parser A pointer to *parser (needed so calling function can get + * errors), will be set to NULL on successfull completion. + * @param ppdoc A pointer to *apr_xml_doc (which has the parsed results in it) + * @param xmlfd A file to read from. + * @param buffer_length Buffer length which would be suitable + * @return Any errors found during parsing. + } +function apr_xml_parse_file(p: Papr_pool_t; + parser: PPapr_xml_parser; ppdoc: PPapr_xml_doc; + xmlfd: Papr_file_t; buffer_length: apr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parse_file' + LibSuff20; + +{ + * Feed input into the parser + * @param parser The XML parser for parsing this data. + * @param data The data to parse. + * @param len The length of the data. + * @return Any errors found during parsing. + * @remark Use apr_xml_parser_geterror() to get more error information. + } +function apr_xml_parser_feed(parser: Papr_xml_parser; + const data: PChar; len: apr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_feed' + LibSuff12; + +{ + * Terminate the parsing and return the result + * @param parser The XML parser for parsing this data. + * @param pdoc The resulting parse information. May be NULL to simply + * terminate the parsing without fetching the info. + * @return Any errors found during the final stage of parsing. + * @remark Use apr_xml_parser_geterror() to get more error information. + } +function apr_xml_parser_done(parser: Papr_xml_parser; + pdoc: PPapr_xml_doc): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_done' + LibSuff8; + +{ + * Fetch additional error information from the parser. + * @param parser The XML parser to query for errors. + * @param errbuf A buffer for storing error text. + * @param errbufsize The length of the error text buffer. + * @return The error buffer + } +function apr_xml_parser_geterror(parser: Papr_xml_parser; + errbuf: PChar; errbufsize: apr_size_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_geterror' + LibSuff12; + +{ + * Converts an XML element tree to flat text + * @param p The pool to allocate out of + * @param elem The XML element to convert + * @param style How to covert the XML. One of: + *
+ * APR_XML_X2T_FULL start tag, contents, end tag + * APR_XML_X2T_INNER contents only + * APR_XML_X2T_LANG_INNER xml:lang + inner contents + * APR_XML_X2T_FULL_NS_LANG FULL + ns defns + xml:lang + *+ * @param namespaces The namespace of the current XML element + * @param ns_map Namespace mapping + * @param pbuf Buffer to put the converted text into + * @param psize Size of the converted text + } +procedure apr_xml_to_text(p: Papr_pool_t; const elem: Papr_xml_elem; + style: Integer; namespaces: Papr_array_header_t; + ns_map: PInteger; const pbuf: PPChar; psize: Papr_size_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_to_text' + LibSuff28; + +{ style argument values: } +const + APR_XML_X2T_FULL = 0; {< start tag, contents, end tag } + APR_XML_X2T_INNER = 1; {< contents only } + APR_XML_X2T_LANG_INNER = 2; {< xml:lang + inner contents } + APR_XML_X2T_FULL_NS_LANG = 3; {< FULL + ns defns + xml:lang } + +{ + * empty XML element + * @param p The pool to allocate out of + * @param elem The XML element to empty + * @return the string that was stored in the XML element + } +function apr_xml_empty_elem(p: Papr_pool_t; const elem: Papr_xml_elem): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_empty_elem' + LibSuff8; + +{ + * quote an XML string + * Replace '<', '>', and '&' with '<', '>', and '&'. + * @param p The pool to allocate out of + * @param s The string to quote + * @param quotes If quotes is true, then replace '"' with '"'. + * @return The quoted string + * @note If the string does not contain special characters, it is not + * duplicated into the pool and the original string is returned. + } +function apr_xml_quote_string(p: Papr_pool_t; const s: PChar; + quotes: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_quote_string' + LibSuff12; + +{ + * Quote an XML element + * @param p The pool to allocate out of + * @param elem The element to quote + } +procedure apr_xml_quote_elem(p: Papr_pool_t; elem: Papr_xml_elem); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_quote_elem' + LibSuff8; + +{ manage an array of unique URIs: apr_xml_insert_uri() and APR_XML_URI_ITEM() } + +{ + * return the URI's (existing) index, or insert it and return a new index + * @param uri_array array to insert into + * @param uri The uri to insert + * @return int The uri's index + } +function apr_xml_insert_uri(uri_array: Papr_array_header_t; + const uri: PChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_insert_uri' + LibSuff8; + +{ Get the URI item for this XML element } +//#define APR_XML_GET_URI_ITEM(ary, i) (((const char * const *)(ary)->elts)[i]) + diff --git a/httpd/httpd_2_0/aprutil/aprutil.pas b/httpd/httpd_2_0/aprutil/aprutil.pas new file mode 100644 index 000000000..e20627c5d --- /dev/null +++ b/httpd/httpd_2_0/aprutil/aprutil.pas @@ -0,0 +1,64 @@ +{ + aprutil.pas + + Copyright (C) 2006 Felipe Monteiro de Carvalho + + This unit is a pascal binding for the Apache 2.0.58 headers. + The headers were released under the following copyright: +} +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +unit aprutil; + +interface + +{$ifdef fpc} + {$mode delphi}{$H+} +{$endif} + +{$IFNDEF FPC} + {$DEFINE WINDOWS} +{$ENDIF} + +{$IFDEF WIN32} + {$DEFINE WINDOWS} +{$ENDIF} + +{$ifdef Unix} + {$PACKRECORDS C} +{$endif} + +uses +{$ifdef WINDOWS} + Windows, +{$ENDIF} + apr, ctypes; + +const +{$IFDEF WINDOWS} + LibAPRUtil = 'libaprutil.dll'; +{$ELSE} + LibAPRUtil = ''; +{$ENDIF} + +{$include apr_xml.inc} +{$include apr_uri.inc} +{$include apr_md5.inc} + +implementation + +end. + diff --git a/httpd/httpd_2_0/http_config.inc b/httpd/httpd_2_0/http_config.inc new file mode 100644 index 000000000..a46c72494 --- /dev/null +++ b/httpd/httpd_2_0/http_config.inc @@ -0,0 +1,1160 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + Declarations from other files centered here +} +const + (* Hook orderings *) + (** run this hook first, before ANYTHING *) + APR_HOOK_REALLY_FIRST = -10; + (** run this hook first *) + APR_HOOK_FIRST = 0; + (** run this hook somewhere *) + APR_HOOK_MIDDLE = 10; + (** run this hook after every other hook which is defined*) + APR_HOOK_LAST = 20; + (** run this hook last, after EVERYTHING *) + APR_HOOK_REALLY_LAST = 30; + + +//#include "apr_hooks.h" +{.$include util_cfgtree.inc} + +{ + * @file http_config.h + * @brief Apache Configuration + } + +{ + * @defgroup ConfigDirectives Allowed locations for configuration directives. + * + * The allowed locations for a configuration directive are the union of + * those indicated by each set bit in the req_override mask. + } +const + OR_NONE = 0; {< *.conf is not available anywhere in this override } + OR_LIMIT = 1; {< *.conf inside
+ * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, + * "The Foo directive is no longer supported, use Bar"), + *+ } +function ap_set_deprecated(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar; + cdecl; external LibHTTPD name 'ap_set_deprecated'; + +{ + * For modules which need to read config files, open logs, etc. this returns + * the canonical form of fname made absolute to ap_server_root. + * @param p pool to allocate data from + * @param fname The file name + } +function ap_server_root_relative(p: Papr_pool_t; const fname: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_server_root_relative' + LibSuff8; + +{ Finally, the hook for dynamically loading modules in... } + +{ + * Add a module to the server + * @param m The module structure of the module to add + * @param p The pool of the same lifetime as the module + } +procedure ap_add_module(m: Pmodule; p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_add_module' + LibSuff8; + +{ + * Remove a module from the server. There are some caveats: + * when the module is removed, its slot is lost so all the current + * per-dir and per-server configurations are invalid. So we should + * only ever call this function when you are invalidating almost + * all our current data. I.e. when doing a restart. + * @param m the module structure of the module to remove + } +procedure ap_remove_module(m: Pmodule); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_remove_module' + LibSuff4; + +{ + * Add a module to the chained modules list and the list of loaded modules + * @param m The module structure of the module to add + * @param p The pool with the same lifetime as the module + } +procedure ap_add_loaded_module(mod_: Pmodule; p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_add_loaded_module' + LibSuff8; + +{ + * Remove a module fromthe chained modules list and the list of loaded modules + * @param m the module structure of the module to remove + } +procedure ap_remove_loaded_module(m: Pmodule); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_remove_loaded_module' + LibSuff4; + +{ + * Add a module to the list of loaded module based on the name of the + * module + * @param name The name of the module + * @param p The pool valid for the lifetime of the module + * @return 1 on success, 0 on failure + } +function ap_add_named_module(const name: PChar; p: Papr_pool_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_add_named_module' + LibSuff8; + +{ + * Find the name of the specified module + * @param m The module to get the name for + * @return the name of the module + } +function ap_find_module_name(m: Pmodule): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_find_module_name' + LibSuff4; + +{ + * Find a module based on the name of the module + * @param name the name of the module + * @return the module structure if found, NULL otherwise + } +function ap_find_linked_module(const name: PChar): Pmodule; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_find_linked_module' + LibSuff4; + +{ + * Open a ap_configfile_t as apr_file_t + * @param ret_cfg open ap_configfile_t struct pointer + * @param p The pool to allocate the structure from + * @param name the name of the file to open + } +function ap_pcfg_openfile(ret_cfg: PPap_configfile_t; + p: Papr_pool_t; const name: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_pcfg_openfile' + LibSuff12; + +{ + * Allocate a ap_configfile_t handle with user defined functions and params + * @param p The pool to allocate from + * @param descr The name of the file + * @param param The argument passed to getch/getstr/close + * @param getc_func The getch function + * @param gets_func The getstr function + * @param close_func The close function + } +type + getc_func_t = function (param: Pointer): Integer; + gets_func_t = function (buf: Pointer; bufsiz: size_t; param: Pointer): Pointer; + close_func_t = function (param: Pointer): Integer; + +function ap_pcfg_open_custom(p: Papr_pool_t; + const descr: PChar; param: Pointer; + getc_func: getc_func_t; gets_func: gets_func_t; + close_func: close_func_t): Pap_configfile_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_pcfg_open_custom' + LibSuff24; + +{ + * Read one line from open ap_configfile_t, strip LF, increase line number + * @param buf place to store the line read + * @param bufsize size of the buffer + * @param cfp File to read from + * @return 1 on success, 0 on failure + } +function ap_cfg_getline(bug: PChar; + bufsize: size_t; cfp: Pap_configfile_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_cfg_getline' + LibSuff12; + +{ + * Read one char from open configfile_t, increase line number upon LF + * @param cfp The file to read from + * @return the character read + } +function ap_cfg_getc(cfp: Pap_configfile_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_cfg_getc' + LibSuff4; + +{ + * Detach from open ap_configfile_t, calling the close handler + * @param cfp The file to close + * @return 1 on sucess, 0 on failure + } +function ap_cfg_closefile(cfp: Pap_configfile_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_cfg_closefile' + LibSuff4; + +{ + * Read all data between the current
+ * we now proceed to read from the client until we get EOF, or until + * MAX_SECS_TO_LINGER has passed. the reasons for doing this are + * documented in a draft: + * + * http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-connection-00.txt + * + * in a nutshell -- if we don't make this effort we risk causing + * TCP RST packets to be sent which can tear down a connection before + * all the response data has been sent to the client. + *+ * @param c The connection we are closing + } +procedure ap_lingering_close(c: Pconn_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_lingering_close' + LibSuff4; + +//#endif COREPRIVATE + + { Hooks } +{ + * create_connection is a RUN_FIRST hook which allows modules to create + * connections. In general, you should not install filters with the + * create_connection hook. If you require vhost configuration information + * to make filter installation decisions, you must use the pre_connection + * or install_network_transport hook. This hook should close the connection + * if it encounters a fatal error condition. + * + * @param p The pool from which to allocate the connection record + * @param csd The socket that has been accepted + * @param conn_id A unique identifier for this connection. The ID only + * needs to be unique at that time, not forever. + * @param sbh A handle to scoreboard information for this connection. + * @return An allocated connection record or NULL. + } +type + ap_HOOK_create_connection_t = function (p: Papr_pool_t; server: Pserver_rec; + csd: Papr_socket_t; conn_id: cLong; sbh: Pointer; + alloc: Papr_bucket_alloc_t): Pconn_rec; cdecl; + +procedure ap_hook_create_connection(pf: ap_HOOK_create_connection_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_create_connection' + LibSuff16; + +{ + * This hook gives protocol modules an opportunity to set everything up + * before calling the protocol handler. All pre-connection hooks are + * run until one returns something other than ok or decline + * @param c The connection on which the request has been received. + * @param csd The mechanism on which this connection is to be read. + * Most times this will be a socket, but it is up to the module + * that accepts the request to determine the exact type. + * @return OK or DECLINED + * @deffunc int ap_run_pre_connection(conn_rec *c, void *csd) + } +type + ap_HOOK_pre_connection_t = function (c: Pconn_rec; csd: Pointer): Integer; cdecl; + +procedure ap_hook_pre_connection(pf: ap_HOOK_pre_connection_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_pre_connection' + LibSuff16; + +{ + * This hook implements different protocols. After a connection has been + * established, the protocol module must read and serve the request. This + * function does that for each protocol module. The first protocol module + * to handle the request is the last module run. + * @param c The connection on which the request has been received. + * @return OK or DECLINED + * @deffunc int ap_run_process_connection(conn_rec *c) + } +type + ap_HOOK_process_connection_t = function (c: Pconn_rec): Integer; cdecl; + +procedure ap_hook_process_connection(pf: ap_HOOK_process_connection_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_process_connection' + LibSuff16; + +{ End Of Connection (EOC) bucket } + +//AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc; + +{ + * Determine if a bucket is an End Of Connection (EOC) bucket + * @param e The bucket to inspect + * @return true or false + } +//#define AP_BUCKET_IS_EOC(e) (e->type == &ap_bucket_type_eoc) + +{ + * Make the bucket passed in an End Of Connection (EOC) bucket + * @param b The bucket to make into an EOC bucket + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_eoc_make(apr_bucket *b) + } +function ap_bucket_eoc_make(b: Papr_bucket): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_make' + LibSuff4; + +{ + * Create a bucket referring to an End Of Connection (EOC). This indicates + * that the connection will be closed. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_eoc_create(apr_bucket_alloc_t *list) + } +function ap_bucket_eoc_create(list: Papr_bucket_alloc_t): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_create' + LibSuff4; + + diff --git a/httpd/httpd_2_0/http_core.inc b/httpd/httpd_2_0/http_core.inc new file mode 100644 index 000000000..230675a4d --- /dev/null +++ b/httpd/httpd_2_0/http_core.inc @@ -0,0 +1,702 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr.h" +{$include apr/apr_hash.inc} +{#include "apr_optional.h"} +{$include util_filter.inc} + +{#if APR_HAVE_STRUCT_RLIMIT +#include
+ * REMOTE_HOST returns the hostname, or NULL if the hostname + * lookup fails. It will force a DNS lookup according to the + * HostnameLookups setting. + * REMOTE_NAME returns the hostname, or the dotted quad if the + * hostname lookup fails. It will force a DNS lookup according + * to the HostnameLookups setting. + * REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is + * never forced. + * REMOTE_DOUBLE_REV will always force a DNS lookup, and also force + * a double reverse lookup, regardless of the HostnameLookups + * setting. The result is the (double reverse checked) + * hostname, or NULL if any of the lookups fail. + *+ * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address + * string is returned + * @return The remote hostname + * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip) + } +function ap_get_remote_host(conn: Pconn_rec; dir_config: Pointer; + _type: Integer; str_is_ip: PInteger): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_remote_host' + LibSuff16; + +{ + * Retrieve the login name of the remote user. Undef if it could not be + * determined + * @param r The current request + * @return The user logged in to the client machine + * @deffunc const char *ap_get_remote_logname(request_rec *r) + } +function ap_get_remote_logname(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_remote_logname' + LibSuff4; + +{ Used for constructing self-referencing URLs, and things like SERVER_PORT, + * and SERVER_NAME. + } +{ + * build a fully qualified URL from the uri and information in the request rec + * @param p The pool to allocate the URL from + * @param uri The path to the requested file + * @param r The current request + * @return A fully qualified URL + * @deffunc char *ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r) + } +function ap_construct_url(p: Papr_pool_t; const uri: PChar; r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_construct_url' + LibSuff12; + +{ + * Get the current server name from the request + * @param r The current request + * @return the server name + * @deffunc const char *ap_get_server_name(request_rec *r) + } +function ap_get_server_name(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_server_name' + LibSuff4; + +{ + * Get the current server port + * @param The current request + * @return The server's port + * @deffunc apr_port_t ap_get_server_port(const request_rec *r) + } +function ap_get_server_port(r: Prequest_rec): apr_port_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_server_port' + LibSuff4; + +{ + * Return the limit on bytes in request msg body + * @param r The current request + * @return the maximum number of bytes in the request msg body + * @deffunc apr_off_t ap_get_limit_req_body(const request_rec *r) + } +function ap_get_limit_req_body(r: Prequest_rec): apr_off_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_limit_req_body' + LibSuff4; + +{ + * Return the limit on bytes in XML request msg body + * @param r The current request + * @return the maximum number of bytes in XML request msg body + * @deffunc size_t ap_get_limit_xml_body(const request_rec *r) + } +function ap_get_limit_xml_body(r: Prequest_rec): size_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_limit_xml_body' + LibSuff4; + +{ + * Install a custom response handler for a given status + * @param r The current request + * @param status The status for which the custom response should be used + * @param string The custom response. This can be a static string, a file + * or a URL + } +procedure ap_custom_response(r: Prequest_rec; status: Integer; const str: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_custom_response' + LibSuff12; + +{ + * Check if the current request is beyond the configured max. number of redirects or subrequests + * @param r The current request + * @return true (is exceeded) or false + * @deffunc int ap_is_recursion_limit_exceeded(const request_rec *r) + } +function ap_is_recursion_limit_exceeded(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_is_recursion_limit_exceeded' + LibSuff4; + +{ + * Check for a definition from the server command line + * @param name The define to check for + * @return 1 if defined, 0 otherwise + * @deffunc int ap_exists_config_define(const char *name) + } +function ap_exists_config_define(name: PChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_exists_config_define' + LibSuff4; + +{ FIXME! See STATUS about how } +function ap_core_translate(r: Prequest_rec): Integer; + cdecl; external LibHTTPD name 'ap_core_translate'; + +{ Authentication stuff. This is one of the places where compatibility + * with the old config files *really* hurts; they don't discriminate at + * all between different authentication schemes, meaning that we need + * to maintain common state for all of them in the core, and make it + * available to the other modules through interfaces. + } + +{ A structure to keep track of authorization requirements } +type + require_line = record + { Where the require line is in the config file. } + method_mask: apr_int64_t; + { The complete string from the command line } + requirement: PChar; + end; + +{ + * Return the type of authorization required for this request + * @param r The current request + * @return The authorization required + * @deffunc const char *ap_auth_type(request_rec *r) + } +function ap_auth_type(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_auth_type' + LibSuff4; + +{ + * Return the current Authorization realm + * @param r The current request + * @return The current authorization realm + * @deffunc const char *ap_auth_name(request_rec *r) + } +function ap_auth_name(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_auth_name' + LibSuff4; + +{ + * How the requires lines must be met. + * @param r The current request + * @return How the requirements must be met. One of: + *
+ * SATISFY_ANY -- any of the requirements must be met. + * SATISFY_ALL -- all of the requirements must be met. + * SATISFY_NOSPEC -- There are no applicable satisfy lines + *+ * @deffunc int ap_satisfies(request_rec *r) + } +function ap_satisfies(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_satisfies' + LibSuff4; + +{ + * Retrieve information about all of the requires directives for this request + * @param r The current request + * @return An array of all requires directives for this request + * @deffunc const apr_array_header_t *ap_requires(request_rec *r) + } +function ap_requires(p: Papr_array_header_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_requires' + LibSuff4; + +//#ifdef CORE_PRIVATE + +{ + * Core is also unlike other modules in being implemented in more than + * one file... so, data structures are declared here, even though most of + * the code that cares really is in http_core.c. Also, another accessor. + } + +//AP_DECLARE_DATA extern module core_module; + +{ Per-request configuration } + +type + core_request_config = record + { bucket brigade used by getline for look-ahead and + * ap_get_client_block for holding left-over request body } + bb: Papr_bucket_brigade; + + { an array of per-request working data elements, accessed + * by ID using ap_get_request_note() + * (Use ap_register_request_note() during initialization + * to add elements) + } + notes: PPointer; + + { There is a script processor installed on the output filter chain, + * so it needs the default_handler to deliver a (script) file into + * the chain so it can process it. Normally, default_handler only + * serves files on a GET request (assuming the file is actual content), + * since other methods are not content-retrieval. This flag overrides + * that behavior, stating that the "content" is actually a script and + * won't actually be delivered as the response for the non-GET method. + } + deliver_script: Integer; + + { Custom response strings registered via ap_custom_response(), + * or NULL; check per-dir config if nothing found here + } + response_code_strings: PPChar; { from ap_custom_response(), not from + * ErrorDocument + } + { Should addition of charset= be suppressed for this request? + } + suppress_charset: Integer; + end; + +{ Standard entries that are guaranteed to be accessible via + * ap_get_request_note() for each request (additional entries + * can be added with ap_register_request_note()) + } +const + AP_NOTE_DIRECTORY_WALK = 0; + AP_NOTE_LOCATION_WALK = 1; + AP_NOTE_FILE_WALK = 2; + AP_NUM_STD_NOTES = 3; + +{ + * Reserve an element in the core_request_config->notes array + * for some application-specific data + * @return An integer key that can be passed to ap_get_request_note() + * during request processing to access this element for the + * current request. + } +function ap_register_request_note: apr_size_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_register_request_note' + LibSuff0; + +{ + * Retrieve a pointer to an element in the core_request_config->notes array + * @param r The request + * @param note_num A key for the element: either a value obtained from + * ap_register_request_note() or one of the predefined AP_NOTE_* + * values. + * @return NULL if the note_num is invalid, otherwise a pointer to the + * requested note element. + * @remark At the start of a request, each note element is NULL. The + * handle provided by ap_get_request_note() is a pointer-to-pointer + * so that the caller can point the element to some app-specific + * data structure. The caller should guarantee that any such + * structure will last as long as the request itself. + } +function ap_get_request_note(r: Prequest_rec; note_num: apr_size_t): PPointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_request_note' + LibSuff8; + +{ Per-directory configuration } + +type + allow_options_t = cuchar; + overrides_t = cuchar; + +{ + * Bits of info that go into making an ETag for a file + * document. Why a long? Because char historically + * proved too short for Options, and int can be different + * sizes on different platforms. + } + etag_components_t = culong; + +const + ETAG_UNSET = 0; + ETAG_NONE = (1 shl 0); + ETAG_MTIME = (1 shl 1); + ETAG_INODE = (1 shl 2); + ETAG_SIZE = (1 shl 3); + ETAG_BACKWARD = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE); + ETAG_ALL = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE); + + { Hostname resolution etc } + + HOSTNAME_LOOKUP_OFF = 0; + HOSTNAME_LOOKUP_ON = 1; + HOSTNAME_LOOKUP_DOUBLE = 2; + OSTNAME_LOOKUP_UNSET = 3; + + { Hostname resolution etc } + + USE_CANONICAL_NAME_OFF = (0); + USE_CANONICAL_NAME_ON = (1); + USE_CANONICAL_NAME_DNS = (2); + USE_CANONICAL_NAME_UNSET = (3); + + { should we force a charset on any outgoing parameterless content-type? + * if so, which charset? + } + ADD_DEFAULT_CHARSET_OFF = (0); + ADD_DEFAULT_CHARSET_ON = (1); + ADD_DEFAULT_CHARSET_UNSET = (2); + + { + * Run-time performance tuning + } + ENABLE_MMAP_OFF = (0); + ENABLE_MMAP_ON = (1); + ENABLE_MMAP_UNSET = (2); + + ENABLE_SENDFILE_OFF = (0); + ENABLE_SENDFILE_ON = (1); + ENABLE_SENDFILE_UNSET = (2); + +type + server_signature_e = ( + srv_sig_unset, + srv_sig_off, + srv_sig_on, + srv_sig_withmail + ); + + core_dir_config = record + + { path of the directory/regex/etc. see also d_is_fnmatch/absolute below } + d: PChar; + { the number of slashes in d } + d_components: Cardinal; + + { If (opts & OPT_UNSET) then no absolute assignment to options has + * been made. + * invariant: (opts_add & opts_remove) == 0 + * Which said another way means that the last relative (options + or -) + * assignment made to each bit is recorded in exactly one of opts_add + * or opts_remove. + } + opts: allow_options_t; + opts_add: allow_options_t; + opts_remove: allow_options_t; + override_: overrides_t; + + { MIME typing --- the core doesn't do anything at all with this, + * but it does know what to slap on a request for a document which + * goes untyped by other mechanisms before it slips out the door... + } + + ap_default_type: PChar; + + { Authentication stuff. Groan... } + + satisfy: PInteger; { for every method one } + ap_auth_type: PChar; + ap_auth_name: PChar; + ap_requires: Papr_array_header_t; + + { Custom response config. These can contain text or a URL to redirect to. + * if response_code_strings is NULL then there are none in the config, + * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES. + * This lets us do quick merges in merge_core_dir_configs(). + } + + response_code_strings: PPChar; { from ErrorDocument, not from + * ap_custom_response() } + + { Hostname resolution etc } +{ unsigned int hostname_lookups : 4; } + +{ signed int do_rfc1413 : 2; }{ See if client is advertising a username? } + +{ signed int content_md5 : 2; }{ calculate Content-MD5? } + +{ unsigned use_canonical_name : 2; } + + { since is_fnmatch(conf->d) was being called so frequently in + * directory_walk() and its relatives, this field was created and + * is set to the result of that call. + } +{ unsigned d_is_fnmatch : 1; } + + { should we force a charset on any outgoing parameterless content-type? + * if so, which charset? + } +{ unsigned add_default_charset : 2; } + add_default_charset_name: PChar; + + { System Resource Control } +{$ifdef RLIMIT_CPU} + limit_cpu: Prlimit; +{$endif} +{$if defined(RLIMIT_DATA) or defined (RLIMIT_VMEM) or defined(RLIMIT_AS)} + limit_mem: Prlimit; +{$endif} +{$ifdef RLIMIT_NPROC} + limit_nproc: Prlimit; +{$endif} + limit_req_body: apr_off_t; { limit on bytes in request msg body } + limit_xml_body: cLong; { limit on bytes in XML request msg body } + + { logging options } + + server_signature: server_signature_e; + + loglevel: Integer; + + { Access control } + sec_file: Papr_array_header_t; + r: Pregex_t; + + mime_type: PChar; { forced with ForceType } + handler: PChar; { forced with SetHandler } + output_filters: PChar; { forced with SetOutputFilters } + input_filters: PChar; { forced with SetInputFilters } + accept_path_info: Integer; { forced with AcceptPathInfo } + + ct_output_filters: Papr_hash_t; { added with AddOutputFilterByType } + + { + * What attributes/data should be included in ETag generation? + } + etag_bits: etag_components_t; + etag_add: etag_components_t; + etag_remove: etag_components_t; + + { + * Run-time performance tuning + } +{ unsigned int enable_mmap : 2; }{ whether files in this dir can be mmap'ed } + +{ unsigned int enable_sendfile : 2; }{ files in this dir can be mmap'ed } +{ unsigned int allow_encoded_slashes : 1; }{ URLs may contain %2f w/o being + * pitched indiscriminately } + end; + +{ Per-server core configuration } + +const + { TRACE control } + + AP_TRACE_UNSET = -1; + AP_TRACE_DISABLE = 0; + AP_TRACE_ENABLE = 1; + AP_TRACE_EXTENDED = 2; + +type + core_server_config = record + +{$ifdef GPROF} + gprof_dir: PChar; +{$endif} + + { Name translations --- we want the core to be able to do *something* + * so it's at least a minimally functional web server on its own (and + * can be tested that way). But let's keep it to the bare minimum: + } + ap_document_root: PChar; + + { Access control } + + access_name: PChar; + sec_dir: Papr_array_header_t; + sec_url: Papr_array_header_t; + + { recursion backstopper } + redirect_limit: Integer; { maximum number of internal redirects } + subreq_limit: Integer; { maximum nesting level of subrequests } + + { TRACE control } + trace_enable: Integer; + end; + +{ for AddOutputFiltersByType in core.c } +//void ap_add_output_filters_by_type(request_rec *r); + +{ for http_config.c } +//void ap_core_reorder_directories(apr_pool_t *, server_rec *); + +{ for mod_perl } +{AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config); +AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config); +AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config); +AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);} + +//#endif COREPRIVATE + + +{ ---------------------------------------------------------------------- + * + * Runtime status/management + } + +type + ap_mgmt_type_e = ( + ap_mgmt_type_string, + ap_mgmt_type_long, + ap_mgmt_type_hash + ); + + ap_mgmt_value = record + case Integer of + 0: (s_value: PChar); + 1: (i_value: cLong); + 2: (h_value: Papr_hash_t); + end; + + ap_mgmt_item_t = record + description: PChar; + name: PChar; + vtype: ap_mgmt_type_e; + v: ap_mgmt_value; + end; + +{ Handles for core filters } +{extern AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_net_time_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;} + +{ + * This hook provdes a way for modules to provide metrics/statistics about + * their operational status. + * + * @param p A pool to use to create entries in the hash table + * @param val The name of the parameter(s) that is wanted. This is + * tree-structured would be in the form ('*' is all the tree, + * 'module.*' all of the module , 'module.foo.*', or + * 'module.foo.bar' ) + * @param ht The hash table to store the results. Keys are item names, and + * the values point to ap_mgmt_item_t structures. + * @ingroup hooks + } +type + ap_HOOK_get_mgmt_items_t = function(p: Papr_pool_t; const val: PChar; + ht: Papr_hash_t): Integer; cdecl; + +procedure ap_hook_get_mgmt_items(pf: ap_HOOK_get_mgmt_items_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_get_mgmt_items' + LibSuff16; + +{ ---------------------------------------------------------------------- } + +{ ---------------------------------------------------------------------- + * + * I/O logging with mod_logio + } + +{APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out, + (conn_rec *c, apr_off_t bytes));} + diff --git a/httpd/httpd_2_0/http_log.inc b/httpd/httpd_2_0/http_log.inc new file mode 100644 index 000000000..7cb0e36e2 --- /dev/null +++ b/httpd/httpd_2_0/http_log.inc @@ -0,0 +1,338 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr_thread_proc.h" + +{ + * @package Apache logging library + } + +{#ifdef HAVE_SYSLOG +#include
+ * REQUEST_NO_BODY Send 413 error if message has any body + * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length + * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. + *+ * @return either OK or an error code + * @deffunc int ap_setup_client_block(request_rec *r, int read_policy) + } +function ap_setup_client_block(r: Prequest_rec; read_policy: Integer): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_setup_client_block' + LibSuff8; + +{ + * Determine if the client has sent any data. This also sends a + * 100 Continue response to HTTP/1.1 clients, so modules should not be called + * until the module is ready to read content. + * @warning Never call this function more than once. + * @param r The current request + * @return 0 if there is no message to read, 1 otherwise + * @deffunc int ap_should_client_block(request_rec *r) + } +function ap_should_client_block(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_should_client_block' + LibSuff4; + +{ + * Call this in a loop. It will put data into a buffer and return the length + * of the input block + * @param r The current request + * @param buffer The buffer in which to store the data + * @param bufsiz The size of the buffer + * @return Number of bytes inserted into the buffer. When done reading, 0 + * if EOF, or -1 if there was an error + * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz) + } +function ap_get_client_block(r: Prequest_rec; buffer: PChar; bufsiz: apr_size_t): cLong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_client_block' + LibSuff12; + +{ + * In HTTP/1.1, any method can have a body. However, most GET handlers + * wouldn't know what to do with a request body if they received one. + * This helper routine tests for and reads any message body in the request, + * simply discarding whatever it receives. We need to do this because + * failing to read the request body would cause it to be interpreted + * as the next request on a persistent connection. + * @param r The current request + * @return error status if request is malformed, OK otherwise + * @deffunc int ap_discard_request_body(request_rec *r) + } +function ap_discard_request_body(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_discard_request_body' + LibSuff4; + +{ + * Setup the output headers so that the client knows how to authenticate + * itself the next time, if an authentication request failed. This function + * works for both basic and digest authentication + * @param r The current request + * @deffunc void ap_note_auth_failure(request_rec *r) + } +procedure ap_note_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_note_auth_failure' + LibSuff4; + +{ + * Setup the output headers so that the client knows how to authenticate + * itself the next time, if an authentication request failed. This function + * works only for basic authentication + * @param r The current request + * @deffunc void ap_note_basic_auth_failure(request_rec *r) + } +procedure ap_note_basic_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_note_basic_auth_failure' + LibSuff4; + +{ + * Setup the output headers so that the client knows how to authenticate + * itself the next time, if an authentication request failed. This function + * works only for digest authentication + * @param r The current request + * @deffunc void ap_note_digest_auth_failure(request_rec *r) + } +procedure ap_note_digest_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_note_digest_auth_failure' + LibSuff4; + +{ + * Get the password from the request headers + * @param r The current request + * @param pw The password as set in the headers + * @return 0 (OK) if it set the 'pw' argument (and assured + * a correct value in r->user); otherwise it returns + * an error code, either HTTP_INTERNAL_SERVER_ERROR if things are + * really confused, HTTP_UNAUTHORIZED if no authentication at all + * seemed to be in use, or DECLINED if there was authentication but + * it wasn't Basic (in which case, the caller should presumably + * decline as well). + * @deffunc int ap_get_basic_auth_pw(request_rec *r, const char **pw) + } +function ap_get_basic_auth_pw(r: Prequest_rec; pw: PPChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_basic_auth_pw' + LibSuff8; + +{ + * parse_uri: break apart the uri + * @warning Side Effects:
+ * - sets r->args to rest after '?' (or NULL if no '?') + * - sets r->uri to request uri (without r->args part) + * - sets r->hostname (if not set already) from request (scheme://host:port) + *+ * @param r The current request + * @param uri The uri to break apart + * @deffunc void ap_parse_uri(request_rec *r, const char *uri) + } +procedure ap_parse_uri(r: Prequest_rec; const uri: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_parse_uri' + LibSuff8; + +{ + * Get the next line of input for the request + * @param s The buffer into which to read the line + * @param n The size of the buffer + * @param r The request + * @param fold Whether to merge continuation lines + * @return The length of the line, if successful + * n, if the line is too big to fit in the buffer + * -1 for miscellaneous errors + * @deffunc int ap_method_number_of(const char *method) + } +function ap_getline(s: PChar; n: Integer; r: Prequest_rec; fold: Integer): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_getline' + LibSuff16; + +{ + * Get the next line of input for the request + * + * Note: on ASCII boxes, ap_rgetline is a macro which simply calls + * ap_rgetline_core to get the line of input. + * + * on EBCDIC boxes, ap_rgetline is a wrapper function which + * translates ASCII protocol lines to the local EBCDIC code page + * after getting the line of input. + * + * @param s Pointer to the pointer to the buffer into which the line + * should be read; if *s==NULL, a buffer of the necessary size + * to hold the data will be allocated from the request pool + * @param n The size of the buffer + * @param read The length of the line. + * @param r The request + * @param fold Whether to merge continuation lines + * @param bb Working brigade to use when reading buckets + * @return APR_SUCCESS, if successful + * APR_ENOSPC, if the line is too big to fit in the buffer + * Other errors where appropriate + } +{#if APR_CHARSET_EBCDIC +AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, + apr_size_t *read, + request_rec *r, int fold, + apr_bucket_brigade *bb); +#else }{ ASCII box } +{#define ap_rgetline(s, n, read, r, fold, bb) \ + ap_rgetline_core((s), (n), (read), (r), (fold), (bb)) +#endif} + +{AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, + apr_size_t *read, + request_rec *r, int fold, + apr_bucket_brigade *bb);} + +{ + * Get the method number associated with the given string, assumed to + * contain an HTTP method. Returns M_INVALID if not recognized. + * @param method A string containing a valid HTTP method + * @return The method number + } +function ap_method_number_of(const method: PChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_method_number_of' + LibSuff4; + +{ + * Get the method name associated with the given internal method + * number. Returns NULL if not recognized. + * @param p A pool to use for temporary allocations. + * @param methnum An integer value corresponding to an internal method number + * @return The name corresponding to the method number + } +function ap_method_name_of(p: Papr_pool_t; methnum: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_method_name_of' + LibSuff8; + + + { Hooks } + { + * post_read_request --- run right after read_request or internal_redirect, + * and not run during any subrequests. + } +{ + * This hook allows modules to affect the request immediately after the request + * has been read, and before any other phases have been processes. This allows + * modules to make decisions based upon the input header fields + * @param r The current request + * @return OK or DECLINED + * @deffunc ap_run_post_read_request(request_rec *r) + } +type + ap_HOOK_post_read_request_t = function(r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_post_read_request(pf: ap_HOOK_post_read_request_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_post_read_request' + LibSuff16; + +{ + * This hook allows modules to perform any module-specific logging activities + * over and above the normal server things. + * @param r The current request + * @return OK, DECLINED, or HTTP_... + * @deffunc int ap_run_log_transaction(request_rec *r) + } +type + ap_HOOK_log_transaction_t = function(r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_log_transaction(pf: ap_HOOK_log_transaction_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_log_transaction' + LibSuff16; + +{ + * This hook allows modules to retrieve the http method from a request. This + * allows Apache modules to easily extend the methods that Apache understands + * @param r The current request + * @return The http method from the request + * @deffunc const char *ap_run_http_method(const request_rec *r) + } +type + ap_HOOK_http_method_t = function(const r: Prequest_rec): PChar; cdecl; + +procedure ap_hook_http_method(pf: ap_HOOK_http_method_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_http_method' + LibSuff16; + +{ + * Return the default port from the current request + * @param r The current request + * @return The current port + * @deffunc apr_port_t ap_run_default_port(const request_rec *r) + } +type + ap_HOOK_default_port_t = function(const r: Prequest_rec): apr_port_t; cdecl; + +procedure ap_hook_default_port(pf: ap_HOOK_default_port_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_default_port' + LibSuff16; + +{ + * A bucket referring to an HTTP error + * This bucket can be passed down the filter stack to indicate that an + * HTTP error occurred while running a filter. In order for this bucket + * to be used successfully, it MUST be sent as the first bucket in the + * first brigade to be sent from a given filter. + } +type + ap_bucket_error = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The error code } + status: Integer; + { The error string } + data: PChar; + end; + Pap_bucket_error = ^ap_bucket_error; + +//AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error; + +{ + * Determine if a bucket is an error bucket + * @param e The bucket to inspect + * @return true or false + } +//#define AP_BUCKET_IS_ERROR(e) (e->type == &ap_bucket_type_error) + +{ + * Make the bucket passed in an error bucket + * @param b The bucket to make into an error bucket + * @param error The HTTP error code to put in the bucket. + * @param buf An optional error string to put in the bucket. + * @param p A pool to allocate out of. + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p) + } +function ap_bucket_error_make(b: Papr_bucket; error: Integer; + const buf: PChar; p: Papr_pool_t): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_error_make' + LibSuff16; + +{ + * Create a bucket referring to an HTTP error. + * @param error The HTTP error code to put in the bucket. + * @param buf An optional error string to put in the bucket. + * @param p A pool to allocate the error string out of. + * @param list The bucket allocator from which to allocate the bucket + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list) + } +function ap_bucket_error_create(error: Integer; const buf: PChar; + p: Papr_pool_t; list: Papr_bucket_alloc_t): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_error_create' + LibSuff16; + +function ap_byterange_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_byterange_filter'; + +function ap_http_header_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_http_header_filter'; + +function ap_content_length_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_content_length_filter'; + +function ap_old_write_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_old_write_filter'; + +{ + * Setting up the protocol fields for subsidiary requests... + * Also, a wrapup function to keep the internal accounting straight. + } +procedure ap_set_sub_req_protocol(rnew: Prequest_rec; const r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_set_sub_req_protocol' + LibSuff8; + +procedure ap_finalize_sub_req_protocol(sub_r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_finalize_sub_req_protocol' + LibSuff4; + diff --git a/httpd/httpd_2_0/http_request.inc b/httpd/httpd_2_0/http_request.inc new file mode 100644 index 000000000..e2997834f --- /dev/null +++ b/httpd/httpd_2_0/http_request.inc @@ -0,0 +1,460 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{#include "apr_hooks.h" +#include "util_filter.h"} + +const + AP_SUBREQ_NO_ARGS = 0; + AP_SUBREQ_MERGE_ARGS = 1; + +{ + * @file http_request.h + * @brief Apache Request library + } + +{ http_request.c is the code which handles the main line of request + * processing, once a request has been read in (finding the right per- + * directory configuration, building it if necessary, and calling all + * the module dispatch functions in the right order). + * + * The pieces here which are public to the modules, allow them to learn + * how the server would handle some other file or URI, or perhaps even + * direct the server to serve that other file instead of the one the + * client requested directly. + * + * There are two ways to do that. The first is the sub_request mechanism, + * which handles looking up files and URIs as adjuncts to some other + * request (e.g., directory entries for multiviews and directory listings); + * the lookup functions stop short of actually running the request, but + * (e.g., for includes), a module may call for the request to be run + * by calling run_sub_req. The space allocated to create sub_reqs can be + * reclaimed by calling destroy_sub_req --- be sure to copy anything you care + * about which was allocated in its apr_pool_t elsewhere before doing this. + } + +{ + * An internal handler used by the ap_process_request, all subrequest mechanisms + * and the redirect mechanism. + * @param r The request, subrequest or internal redirect to pre-process + * @return The return code for the request + } +function ap_process_request_internal(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_process_request_internal' + LibSuff4; + +{ + * Create a subrequest from the given URI. This subrequest can be + * inspected to find information about the requested URI + * @param new_uri The URI to lookup + * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_lookup_uri(const char *new_uri, const request_rec *r) + } +function ap_sub_req_lookup_uri(const new_uri: PChar; + const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_uri' + LibSuff12; + +{ + * Create a subrequest for the given file. This subrequest can be + * inspected to find information about the requested file + * @param new_file The file to lookup + * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_lookup_file(const char *new_file, const request_rec *r) + } +function ap_sub_req_lookup_file(const new_file: PChar; + const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_file' + LibSuff12; + +{ + * Create a subrequest for the given apr_dir_read result. This subrequest + * can be inspected to find information about the requested file + * @param finfo The apr_dir_read result to lookup + * @param r The current request + * @param subtype What type of subrequest to perform, one of; + *
+ * AP_SUBREQ_NO_ARGS ignore r->args and r->path_info + * AP_SUBREQ_MERGE_ARGS merge r->args and r->path_info + *+ * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_lookup_dirent(apr_finfo_t *finfo, int subtype, const request_rec *r) + * @tip The apr_dir_read flags value APR_FINFO_MIN|APR_FINFO_NAME flag is the + * minimum recommended query if the results will be passed to apr_dir_read. + * The file info passed must include the name, and must have the same relative + * directory as the current request. + } +function ap_sub_req_lookup_dirent(const finfo: Papr_finfo_t; + const r: Prequest_rec; subtype: Integer; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_dirent' + LibSuff16; + +{ + * Create a subrequest for the given URI using a specific method. This + * subrequest can be inspected to find information about the requested URI + * @param method The method to use in the new subrequest + * @param new_uri The URI to lookup + * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_method_uri(const char *method, const char *new_uri, const request_rec *r) + } +function ap_sub_req_method_uri(const method, new_uri: PChar; + const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_method_uri' + LibSuff16; + +{ + * An output filter to strip EOS buckets from sub-requests. This always + * has to be inserted at the end of a sub-requests filter stack. + * @param f The current filter + * @param bb The brigade to filter + * @deffunc apr_status_t ap_sub_req_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) + } +function ap_sub_req_output_filter(f: Pap_filter_t; + bb: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_sub_req_output_filter'; + +{ + * Run the handler for the subrequest + * @param r The subrequest to run + * @return The return code for the subrequest + * @deffunc int ap_run_sub_req(request_rec *r) + } +function ap_run_sub_req(r: Prequest_rec): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_run_sub_req' + LibSuff4; + +{ + * Free the memory associated with a subrequest + * @param r The subrequest to finish + * @deffunc void ap_destroy_sub_req(request_rec *r) + } +procedure ap_destroy_sub_req(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_destroy_sub_req' + LibSuff4; + +{ + * Then there's the case that you want some other request to be served + * as the top-level request INSTEAD of what the client requested directly. + * If so, call this from a handler, and then immediately return OK. + } + +{ + * Redirect the current request to some other uri + * @param new_uri The URI to replace the current request with + * @param r The current request + * @deffunc void ap_internal_redirect(const char *new_uri, request_rec *r) + } +procedure ap_internal_redirect(const new_uri: PChar; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_internal_redirect' + LibSuff8; + +{ + * This function is designed for things like actions or CGI scripts, when + * using AddHandler, and you want to preserve the content type across + * an internal redirect. + * @param new_uri The URI to replace the current request with. + * @param r The current request + * @deffunc void ap_internal_redirect_handler(const char *new_uri, request_rec *r) + } +procedure ap_internal_redirect_handler(const new_uri: PChar; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_internal_redirect_handler' + LibSuff8; + +{ + * Redirect the current request to a sub_req, merging the pools + * @param sub_req A subrequest created from this request + * @param r The current request + * @deffunc void ap_internal_fast_redirect(request_rec *sub_req, request_rec *r) + * @tip the sub_req's pool will be merged into r's pool, be very careful + * not to destroy this subrequest, it will be destroyed with the main request! + } +procedure ap_internal_fast_redirect(sub_req, r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_internal_fast_redirect' + LibSuff8; + +{ + * Can be used within any handler to determine if any authentication + * is required for the current request + * @param r The current request + * @return 1 if authentication is required, 0 otherwise + * @deffunc int ap_some_auth_required(request_rec *r) + } +function ap_some_auth_required(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_some_auth_required' + LibSuff4; + +{ + * Determine if the current request is the main request or a subrequest + * @param r The current request + * @return 1 if this is the main request, 0 otherwise + * @deffunc int ap_is_initial_req(request_rec *r) + } +function ap_is_initial_req(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_is_initial_req' + LibSuff4; + +{ + * Function to set the r->mtime field to the specified value if it's later + * than what's already there. + * @param r The current request + * @param dependency_time Time to set the mtime to + * @deffunc void ap_update_mtime(request_rec *r, apr_time_t dependency_mtime) + } +procedure ap_update_mtime(r: Prequest_rec; dependency_mtime: apr_time_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_update_mtime' + LibSuff12; + +{ + * Add one or more methods to the list permitted to access the resource. + * Usually executed by the content handler before the response header is + * sent, but sometimes invoked at an earlier phase if a module knows it + * can set the list authoritatively. Note that the methods are ADDED + * to any already permitted unless the reset flag is non-zero. The + * list is used to generate the Allow response header field when it + * is needed. + * @param r The pointer to the request identifying the resource. + * @param reset Boolean flag indicating whether this list should + * completely replace any current settings. + * @param ... A NULL-terminated list of strings, each identifying a + * method name to add. + * @return None. + * @deffunc void ap_allow_methods(request_rec *r, int reset, ...) + } +procedure ap_allow_methods(r: Prequest_rec; reset: Integer; others: array of const); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name 'ap_allow_methods'; + +//AP_DECLARE(void) (request_rec *r, int reset, ...); + +{ + * Add one or more methods to the list permitted to access the resource. + * Usually executed by the content handler before the response header is + * sent, but sometimes invoked at an earlier phase if a module knows it + * can set the list authoritatively. Note that the methods are ADDED + * to any already permitted unless the reset flag is non-zero. The + * list is used to generate the Allow response header field when it + * is needed. + * @param r The pointer to the request identifying the resource. + * @param reset Boolean flag indicating whether this list should + * completely replace any current settings. + * @param ... A list of method identifiers, from the "M_" series + * defined in httpd.h, terminated with a value of -1 + * (e.g., "M_GET, M_POST, M_OPTIONS, -1") + * @return None. + * @deffunc void ap_allow_standard_methods(request_rec *r, int reset, ...) + } +procedure ap_allow_standard_methods(r: Prequest_rec; reset: Integer; others: array of const); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name 'ap_allow_standard_methods'; + +//AP_DECLARE(void) (request_rec *r, int reset, ...); + +const + MERGE_ALLOW = 0; + REPLACE_ALLOW = 1; + +//#ifdef CORE_PRIVATE +{ Function called by main.c to handle first-level request } +//void ap_process_request(request_rec *); +{ + * Kill the current request + * @param type Why the request is dieing + * @param r The current request + * @deffunc void ap_die(int type, request_rec *r) + } +procedure ap_die(type_: Integer; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_die' + LibSuff8; + +//#endif COREPRIVATE + +{ Hooks } + +{ + * Gives modules a chance to create their request_config entry when the + * request is created. + * @param r The current request + * @ingroup hooks + } +type + ap_HOOK_create_request_t = function (r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_create_request(pf: ap_HOOK_create_request_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_create_request' + LibSuff16; + +{ + * This hook allow modules an opportunity to translate the URI into an + * actual filename. If no modules do anything special, the server's default + * rules will be followed. + * @param r The current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + } +type + ap_HOOK_translate_name_t = function (r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_translate_name(pf: ap_HOOK_translate_name_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_translate_name' + LibSuff16; + +{ + * This hook allow modules to set the per_dir_config based on their own + * context (such as
+ * Useful for testing for features. + * For example, suppose you wish to use the apr_table_overlap + * function. You can do this: + * + * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2) + * ... use apr_table_overlap() + * #else + * ... alternative code which doesn't use apr_table_overlap() + * #endif + *+ * @param major The major module magic number + * @param minor The minor module magic number + * @deffunc AP_MODULE_MAGIC_AT_LEAST(int major, int minor) + } +{#define AP_MODULE_MAGIC_AT_LEAST(major,minor) \ + ((major) < MODULE_MAGIC_NUMBER_MAJOR \ + || ((major) == MODULE_MAGIC_NUMBER_MAJOR \ + && (minor) <= MODULE_MAGIC_NUMBER_MINOR))} + +{ @deprecated present for backwards compatibility } + MODULE_MAGIC_NUMBER = MODULE_MAGIC_NUMBER_MAJOR; +//#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using + diff --git a/httpd/httpd_2_2/ap_mpm.inc b/httpd/httpd_2_2/ap_mpm.inc new file mode 100644 index 000000000..83af0fbfc --- /dev/null +++ b/httpd/httpd_2_2/ap_mpm.inc @@ -0,0 +1,179 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr_thread_proc.h" + +{ + * @package Multi-Processing Module library + } + +{ + The MPM, "multi-processing model" provides an abstraction of the + interface with the OS for distributing incoming connections to + threads/process for processing. http_main invokes the MPM, and + the MPM runs until a shutdown/restart has been indicated. + The MPM calls out to the apache core via the ap_process_connection + function when a connection arrives. + + The MPM may or may not be multithreaded. In the event that it is + multithreaded, at any instant it guarantees a 1:1 mapping of threads + ap_process_connection invocations. + + Note: In the future it will be possible for ap_process_connection + to return to the MPM prior to finishing the entire connection; and + the MPM will proceed with asynchronous handling for the connection; + in the future the MPM may call ap_process_connection again -- but + does not guarantee it will occur on the same thread as the first call. + + The MPM further guarantees that no asynchronous behaviour such as + longjmps and signals will interfere with the user code that is + invoked through ap_process_connection. The MPM may reserve some + signals for its use (i.e. SIGUSR1), but guarantees that these signals + are ignored when executing outside the MPM code itself. (This + allows broken user code that does not handle EINTR to function + properly.) + + The suggested server restart and stop behaviour will be "graceful". + However the MPM may choose to terminate processes when the user + requests a non-graceful restart/stop. When this occurs, the MPM kills + all threads with extreme prejudice, and destroys the pchild pool. + User cleanups registered in the pchild apr_pool_t will be invoked at + this point. (This can pose some complications, the user cleanups + are asynchronous behaviour not unlike longjmp/signal... but if the + admin is asking for a non-graceful shutdown, how much effort should + we put into doing it in a nice way?) + + unix/posix notes: + - The MPM does not set a SIGALRM handler, user code may use SIGALRM. + But the preferred method of handling timeouts is to use the + timeouts provided by the BUFF abstraction. + - The proper setting for SIGPIPE is SIG_IGN, if user code changes it + for any of their own processing, it must be restored to SIG_IGN + prior to executing or returning to any apache code. + TODO: add SIGPIPE debugging check somewhere to make sure it's SIG_IGN +} + +{ + * This is the function that MPMs must create. This function is responsible + * for controlling the parent and child processes. It will run until a + * restart/shutdown is indicated. + * @param pconf the configuration pool, reset before the config file is read + * @param plog the log pool, reset after the config file is read + * @param server_conf the global server config. + * @return 1 for shutdown 0 otherwise. + * @deffunc int ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf) + } +function ap_mpm_run(pconf, plog: Papr_pool_t; server_conf: Pserver_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_mpm_run' + LibSuff12; + +{ + * predicate indicating if a graceful stop has been requested ... + * used by the connection loop + * @return 1 if a graceful stop has been requested, 0 otherwise + * @deffunc int ap_graceful_stop_signalled(*void) + } +function ap_graceful_stop_signalled: Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_graceful_stop_signalled' + LibSuff0; + +{ + * Spawn a process with privileges that another module has requested + * @param r The request_rec of the current request + * @param newproc The resulting process handle. + * @param progname The program to run + * @param const_args the arguments to pass to the new program. The first + * one should be the program name. + * @param env The new environment apr_table_t for the new process. This + * should be a list of NULL-terminated strings. + * @param attr the procattr we should use to determine how to create the new + * process + * @param p The pool to use. + } +function ap_os_create_privileged_process( + const r: Prequest_rec; + newproc: Papr_proc_t; + const progname, args, env: PChar; + attr: Papr_procattr_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_os_create_privileged_process' + LibSuff28; + +const +{ Subtypes/Values for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED } + AP_MPMQ_NOT_SUPPORTED = 0; { This value specifies whether } + { an MPM is capable of } + { threading or forking. } + AP_MPMQ_STATIC = 1; { This value specifies whether } + { an MPM is using a static # } + { threads or daemons. } + AP_MPMQ_DYNAMIC = 2; { This value specifies whether } + { an MPM is using a dynamic # } + { threads or daemons. } + +{ Values returned for AP_MPMQ_MPM_STATE } + AP_MPMQ_STARTING = 0; + AP_MPMQ_RUNNING = 1; + AP_MPMQ_STOPPING = 2; + + AP_MPMQ_MAX_DAEMON_USED = 1; { Max # of daemons used so far } + AP_MPMQ_IS_THREADED = 2; { MPM can do threading } + AP_MPMQ_IS_FORKED = 3; { MPM can do forking } + AP_MPMQ_HARD_LIMIT_DAEMONS = 4; { The compiled max # daemons } + AP_MPMQ_HARD_LIMIT_THREADS = 5; { The compiled max # threads } + AP_MPMQ_MAX_THREADS = 6; { # of threads/child by config } + AP_MPMQ_MIN_SPARE_DAEMONS = 7; { Min # of spare daemons } + AP_MPMQ_MIN_SPARE_THREADS = 8; { Min # of spare threads } + AP_MPMQ_MAX_SPARE_DAEMONS = 9; { Max # of spare daemons } + AP_MPMQ_MAX_SPARE_THREADS = 10; { Max # of spare threads } + AP_MPMQ_MAX_REQUESTS_DAEMON = 11; { Max # of requests per daemon } + AP_MPMQ_MAX_DAEMONS = 12; { Max # of daemons by config } + AP_MPMQ_MPM_STATE = 13; { starting, running, stopping } + +{ + * Query a property of the current MPM. + * @param query_code One of APM_MPMQ_* + * @param result A location to place the result of the query + * @return APR_SUCCESS or APR_ENOTIMPL + * @deffunc int ap_mpm_query(int query_code, int *result) + } +function ap_mpm_query(query_code: Integer; result: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_mpm_query' + LibSuff8; + +{ Defining GPROF when compiling uses the moncontrol() function to + * disable gprof profiling in the parent, and enable it only for + * request processing in children (or in one_process mode). It's + * absolutely required to get useful gprof results under linux + * because the profile itimers and such are disabled across a + * fork(). It's probably useful elsewhere as well. + } +{#ifdef GPROF +extern void moncontrol(int); +#define AP_MONCONTROL(x) moncontrol(x) +#else +#define AP_MONCONTROL(x) +#endif} + +{$ifdef AP_ENABLE_EXCEPTION_HOOK} +type + ap_exception_info_t = record + sig: Integer; + pid: pid_t; + end; + +AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei)) +{$endif} {AP_ENABLE_EXCEPTION_HOOK} + diff --git a/httpd/httpd_2_2/ap_provider.inc b/httpd/httpd_2_2/ap_provider.inc new file mode 100644 index 000000000..e14d2d34f --- /dev/null +++ b/httpd/httpd_2_2/ap_provider.inc @@ -0,0 +1,50 @@ +{ Copyright 2002-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "ap_config.h" + +{ + * @package Provider API + } + +{ + * This function is used to register a provider with the global + * provider pool. + * @param pool The pool to create any storage from + * @param provider_group The group to store the provider in + * @param provider_name The name for this provider + * @param provider_version The version for this provider + * @param provider Opaque structure for this provider + * @return APR_SUCCESS if all went well + } +function ap_register_provider(pool: Papr_pool_t; + const provider_group, provider_name, provider_version: PChar; + const provider: Pointer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_register_provider' + LibSuff20; + +{ + * This function is used to retrieve a provider from the global + * provider pool. + * @param provider_group The group to look for this provider in + * @param provider_name The name for the provider + * @param provider_version The version for the provider + * @return provider pointer to provider if found, NULL otherwise + } +function ap_lookup_provider(provider_group, provider_name, provider_version: PChar): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_lookup_provider' + LibSuff12; + diff --git a/httpd/httpd_2_2/ap_release.inc b/httpd/httpd_2_2/ap_release.inc new file mode 100644 index 000000000..ae8594ab6 --- /dev/null +++ b/httpd/httpd_2_2/ap_release.inc @@ -0,0 +1,53 @@ +{ Copyright 2001-2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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. + } + +//#include "apr_general.h" /* stringify */ + +const + AP_SERVER_COPYRIGHT = + 'Copyright 2001-2006 The Apache Software Foundation' + + ' or its licensors, as applicable.'; + +{ + * The below defines the base string of the Server: header. Additional + * tokens can be added via the ap_add_version_component() API call. + * + * The tokens are listed in order of their significance for identifying the + * application. + * + * "Product tokens should be short and to the point -- use of them for + * advertizing or other non-essential information is explicitly forbidden." + * + * Example: "Apache/1.1.0 MrWidget/0.1-alpha" + } + AP_SERVER_BASEVENDOR = 'Apache Software Foundation'; + AP_SERVER_BASEPRODUCT = 'Apache'; + + AP_SERVER_MAJORVERSION_NUMBER = 2; + AP_SERVER_MINORVERSION_NUMBER = 0; + AP_SERVER_PATCHLEVEL_NUMBER = 58; + AP_SERVER_ADD_STRING = ''; + +{ keep old macros as well } +{#define AP_SERVER_MAJORVERSION APR_STRINGIFY(AP_SERVER_MAJORVERSION_NUMBER) +#define AP_SERVER_MINORVERSION APR_STRINGIFY(AP_SERVER_MINORVERSION_NUMBER) +#define AP_SERVER_PATCHLEVEL APR_STRINGIFY(AP_SERVER_PATCHLEVEL_NUMBER) \ + AP_SERVER_ADD_STRING + +#define AP_SERVER_MINORREVISION AP_SERVER_MAJORVERSION "." AP_SERVER_MINORVERSION +#define AP_SERVER_BASEREVISION AP_SERVER_MINORREVISION "." AP_SERVER_PATCHLEVEL +#define AP_SERVER_BASEVERSION AP_SERVER_BASEPRODUCT "/" AP_SERVER_BASEREVISION +#define AP_SERVER_VERSION AP_SERVER_BASEVERSION} + diff --git a/httpd/httpd_2_2/apr/apr.pas b/httpd/httpd_2_2/apr/apr.pas new file mode 100644 index 000000000..11efe0e09 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr.pas @@ -0,0 +1,197 @@ +{ + apr.pas + + Copyright (C) 2006 Felipe Monteiro de Carvalho + + This unit is a pascal binding for the Apache 2.0.58 headers. + The headers were released under the following copyright: +} +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +unit apr; + +interface + +{$ifdef fpc} + {$mode delphi}{$H+} +{$endif} + +{$IFNDEF FPC} + {$DEFINE WINDOWS} +{$ENDIF} + +{$IFDEF WIN32} + {$DEFINE WINDOWS} +{$ENDIF} + +{$ifdef Unix} + {$PACKRECORDS C} +{$endif} + +uses +{$ifdef WINDOWS} + Windows, winsock, +{$ELSE} + UnixType, +{$ENDIF} + SysUtils, ctypes; + +const +{$IFDEF WINDOWS} + LibAPR = 'libapr.dll'; +{$ELSE} + LibAPR = ''; +{$ENDIF} + +{$IFDEF WINDOWS} + LibNamePrefix = '_'; + LibSuff0 = '@0'; + LibSuff4 = '@4'; + LibSuff8 = '@8'; + LibSuff12 = '@12'; + LibSuff16 = '@16'; + LibSuff20 = '@20'; + LibSuff24 = '@24'; + LibSuff28 = '@28'; + LibSuff32 = '@32'; +{$ELSE} + LibNamePrefix = ''; + LibSuff0 = ''; + LibSuff4 = ''; + LibSuff8 = ''; + LibSuff12 = ''; + LibSuff16 = ''; + LibSuff20 = ''; + LibSuff24 = ''; + LibSuff28 = ''; + LibSuff32 = ''; +{$ENDIF} + +type + uid_t = Integer; + gid_t = Integer; + time_t = LongInt; + size_t = Integer; + pid_t = Integer; + Ppid_t = ^pid_t; + apr_uint16_t = Word; + apr_uint32_t = Cardinal; + apr_int64_t = Int64; + apr_uint64_t = Int64; + apr_socklen_t = Integer; + +type + {$IFDEF WINDOWS} + apr_off_t = Int64; + {$ENDIF} + {$IFDEF UNIX} + apr_off_t = Integer; + {$ENDIF} + + apr_int32_t = Integer; + apr_size_t = size_t; + Papr_size_t = ^apr_size_t; + + va_list = Pointer; + +// TEMPORARY + Papr_xml_ns_scope = Pointer; + + Pap_method_list_t = Pointer; + Pcore_output_filter_ctx_t = Pointer; + Pap_directive_t = Pointer; + Pap_filter_t = Pointer; + Papr_file_t = Pointer; + Papr_off_t = Pointer; + + iovec = record + /// byte count to read/write + iov_len: culong; + /// data to be read/written + iov_base: PChar; + end; + + Piovec = ^iovec; + +{$include apr_errno.inc} +{$include apr_pools.inc} +{$include apr_general.inc} +{$include apr_dso.inc} +{$include apr_user.inc} +{$include apr_time.inc} +{$include apr_tables.inc} +{$include apr_file_info.inc} +{$include apr_file_io.inc} +{$include apr_strings.inc} +{$include apr_lib.inc} +{$include apr_signal.inc} +{$include apr_network_io.inc} +{.$include apr_portable.inc} + +{.$include ../aprutils/apr_uri.inc} + +{$include apr_thread_proc.inc} +{$include apr_version.inc} + +implementation + +{ + Macros transformed into functions in the translation +} + +{ apr_pools.inc } + +{$ifndef DOXYGEN} +function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t; +begin + Result := apr_pool_create_ex(newpool, parent, nil, nil); +end; +{$endif} + +function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t; + abort_fn: apr_abortfunc_t): apr_status_t; +begin + Result := apr_pool_create_ex(newpool, parent, abort_fn, nil); +end; + +{ apr_lib.inc } + +function apr_tolower(c: Char): Char; +var + buf: array[0..1] of Char; +begin + buf[0] := c; + buf[1] := #0; + + buf := StrLower(@buf[0]); + + Result := buf[0]; +end; + +function apr_toupper(c: Char): Char; +var + buf: array[0..1] of Char; +begin + buf[0] := c; + buf[1] := #0; + + buf := StrUpper(@buf[0]); + + Result := buf[0]; +end; + +end. + diff --git a/httpd/httpd_2_2/apr/apr_allocator.inc b/httpd/httpd_2_2/apr/apr_allocator.inc new file mode 100644 index 000000000..576db59a4 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_allocator.inc @@ -0,0 +1,174 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_allocator.h + * @brief APR Internal Memory Allocation + } + +{#include "apr.h" +#include "apr_errno.h" +#define APR_WANT_MEMFUNC < For no good reason? +#include "apr_want.h"} + +{ + * @defgroup apr_allocator Internal Memory Allocation + * @ingroup APR + } + +type +{ the allocator structure } + apr_allocator_t = record end; + Papr_allocator_t = ^apr_allocator_t; + PPapr_allocator_t = ^Papr_allocator_t; + + { the structure which holds information about the allocation } + + Papr_memnode_t = ^apr_memnode_t; + PPapr_memnode_t = ^Papr_memnode_t; + + { basic memory node structure } + + apr_memnode_t = record + next: Papr_memnode_t; {< next memnode } + ref: PPapr_memnode_t; {< reference to self } + index: apr_uint32_t; {< size } + free_index: apr_uint32_t; {< how much free } + first_avail: PChar; {< pointer to first free memory } + endp: PChar; {< pointer to end of free memory } + end; + +{ The base size of a memory node - aligned. } +//#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t)) + +{ Symbolic constants } +const + APR_ALLOCATOR_MAX_FREE_UNLIMITED = 0; + +{ + * Create a new allocator + * @param allocator The allocator we have just created. + * + } +function apr_allocator_create(allocator: PPapr_allocator_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_create' + LibSuff4; + +{ + * Destroy an allocator + * @param allocator The allocator to be destroyed + * @remark Any memnodes not given back to the allocator prior to destroying + * will _not_ be free()d. + } +procedure apr_allocator_destroy(allocator: Papr_allocator_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_destroy' + LibSuff4; + +{ + * Allocate a block of mem from the allocator + * @param allocator The allocator to allocate from + * @param size The size of the mem to allocate (excluding the + * memnode structure) + } +function apr_allocator_alloc(allocator: Papr_allocator_t; + size: apr_size_t): Papr_memnode_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_alloc' + LibSuff8; + +{ + * Free a block of mem, giving it back to the allocator + * @param allocator The allocator to give the mem back to + * @param memnode The memory node to return + } +procedure apr_allocator_free(allocator: Papr_allocator_t; memnode: Papr_memnode_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_free' + LibSuff8; + +//#include "apr_pools.h" + +{ + * Set the owner of the allocator + * @param allocator The allocator to set the owner for + * @param pool The pool that is to own the allocator + * @remark Typically pool is the highest level pool using the allocator + } +{ + * XXX: see if we can come up with something a bit better. Currently + * you can make a pool an owner, but if the pool doesn't use the allocator + * the allocator will never be destroyed. + } +procedure apr_allocator_owner_set(allocator: Papr_allocator_t; pool: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_owner_set' + LibSuff8; + +{ @deprecated @see apr_allocator_owner_set } +{APR_DECLARE(void) apr_allocator_set_owner(apr_allocator_t *allocator, + apr_pool_t *pool); +} +{ + * Get the current owner of the allocator + * @param allocator The allocator to get the owner from + } +function apr_allocator_owner_get(allocator: Papr_allocator_t): Papr_pool_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_owner_get' + LibSuff4; + +{ @deprecated @see apr_allocator_owner_get } +{APR_DECLARE(apr_pool_t *) apr_allocator_get_owner( + apr_allocator_t *allocator); +} +{ + * Set the current threshold at which the allocator should start + * giving blocks back to the system. + * @param allocator The allocator the set the threshold on + * @param size The threshold. 0 == unlimited. + } +procedure apr_allocator_max_free_set(allocator: Papr_allocator_t; size: apr_size_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_allocator_max_free_set' + LibSuff8; + +{ @deprecated @see apr_allocator_max_free_set } +{APR_DECLARE(void) apr_allocator_set_max_free(apr_allocator_t *allocator, + apr_size_t size); + +#include "apr_thread_mutex.h"} + +{$ifdef APR_HAS_THREADS} +{ + * Set a mutex for the allocator to use + * @param allocator The allocator to set the mutex for + * @param mutex The mutex + } +APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator, + apr_thread_mutex_t *mutex); + +{ @deprecated @see apr_allocator_mutex_set } +APR_DECLARE(void) apr_allocator_set_mutex(apr_allocator_t *allocator, + apr_thread_mutex_t *mutex); + +{ + * Get the mutex currently set for the allocator + * @param allocator The allocator + } +APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get( + apr_allocator_t *allocator); + +{ @deprecated @see apr_allocator_mutex_get } +APR_DECLARE(apr_thread_mutex_t *) apr_allocator_get_mutex( + apr_allocator_t *allocator); + +{$endif} { APR_HAS_THREADS } + diff --git a/httpd/httpd_2_2/apr/apr_buckets.inc b/httpd/httpd_2_2/apr/apr_buckets.inc new file mode 100644 index 000000000..c018172bc --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_buckets.inc @@ -0,0 +1,1515 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +{ + * @file apr_buckets.h + * @brief APR-UTIL Buckets/Bucket Brigades + } + +{#if defined(APR_BUCKET_DEBUG) && !defined(APR_RING_DEBUG) +#define APR_RING_DEBUG +#endif + +#include "apu.h" +#include "apr_network_io.h" +#include "apr_file_io.h" +#include "apr_general.h" +#include "apr_mmap.h" +#include "apr_errno.h" +#include "apr_ring.h" +#include "apr.h" +#if APR_HAVE_SYS_UIO_H +#include
+ * while (e != APR_BRIGADE_SENTINEL(b)) ( + * ... + * e = APR_BUCKET_NEXT(e); + * ) + *+ * @param b The brigade + * @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 + * @return The first bucket in the brigade + } +//#define APR_BRIGADE_FIRST(b) APR_RING_FIRST(&(b)->list) +{ + * Return the last bucket in a brigade + * @param b The brigade to query + * @return The last bucket in the brigade + } +//#define APR_BRIGADE_LAST(b) APR_RING_LAST(&(b)->list) + +{ + * Iterate through a bucket brigade + * @param e The current bucket + * @param b The brigade to iterate over + * @remark This is the same as either: + *
+ * e = APR_BRIGADE_FIRST(b); + * while (e != APR_BRIGADE_SENTINEL(b)) ( + * ... + * e = APR_BUCKET_NEXT(e); + * ) + * OR + * for (e = APR_BRIGADE_FIRST(b); + * e != APR_BRIGADE_SENTINEL(b); + * e = APR_BUCKET_NEXT(e)) ( + * ... + * ) + *+ * @warning Be aware that you cannot change the value of e within + * the foreach loop, nor can you destroy the bucket it points to. + * Modifying the prev and next pointers of the bucket is dangerous + * but can be done if you're careful. If you change e's value or + * destroy the bucket it points to, then APR_BRIGADE_FOREACH + * will have no way to find out what bucket to use for its next + * iteration. The reason for this can be seen by looking closely + * at the equivalent loops given in the tip above. So, for example, + * if you are writing a loop that empties out a brigade one bucket + * at a time, APR_BRIGADE_FOREACH just won't work for you. Do it + * by hand, like so: + *
+ * while (!APR_BRIGADE_EMPTY(b)) ( + * e = APR_BRIGADE_FIRST(b); + * ... + * apr_bucket_delete(e); + * ) + *+ * @deprecated This macro causes more headaches than it's worth. Use + * one of the alternatives documented here instead; the clarity gained + * in what's really going on is well worth the extra line or two of code. + * This macro will be removed at some point in the future. + } +//#define APR_BRIGADE_FOREACH(e, b) \ +// APR_RING_FOREACH((e), &(b)->list, apr_bucket, link) + +{ + * Insert a list of buckets at the front of a brigade + * @param b The brigade to add to + * @param e The first bucket in a list of buckets to insert + } +{#define APR_BRIGADE_INSERT_HEAD(b, e) do ( \ + apr_bucket *ap__b = (e); \ + APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((b)); \ + ) while (0)} + +{ + * Insert a list of buckets at the end of a brigade + * @param b The brigade to add to + * @param e The first bucket in a list of buckets to insert + } +{#define APR_BRIGADE_INSERT_TAIL(b, e) do begin \ + apr_bucket *ap__b = (e); \ + APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((b)); \ + end while (0)} + +{ + * Concatenate brigade b onto the end of brigade a, leaving brigade b empty + * @param a The first brigade + * @param b The second brigade + } +{#define APR_BRIGADE_CONCAT(a, b) do begin + APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((a)); \ + end while (0);} + +{ + * Prepend brigade b onto the beginning of brigade a, leaving brigade b empty + * @param a The first brigade + * @param b The second brigade + } +{#define APR_BRIGADE_PREPEND(a, b) do begin + APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((a)); \ + end while (0)} + +{ + * Insert a list of buckets before a specified bucket + * @param a The bucket to insert before + * @param b The buckets to insert + } +{#define APR_BUCKET_INSERT_BEFORE(a, b) do begin + apr_bucket *ap__a = (a), *ap__b = (b); \ + APR_RING_INSERT_BEFORE(ap__a, ap__b, link); \ + APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ + end while (0)} + +{ + * Insert a list of buckets after a specified bucket + * @param a The bucket to insert after + * @param b The buckets to insert + } +{#define APR_BUCKET_INSERT_AFTER(a, b) do begin + apr_bucket *ap__a = (a), *ap__b = (b); \ + APR_RING_INSERT_AFTER(ap__a, ap__b, link); \ + APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ + end while (0)} + +{ + * Get the next bucket in the list + * @param e The current bucket + * @return The next bucket + } +//#define APR_BUCKET_NEXT(e) APR_RING_NEXT((e), link) +{ + * Get the previous bucket in the list + * @param e The current bucket + * @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 + } +//#define APR_BUCKET_INIT(e) APR_RING_ELEM_INIT((e), link) + +{ + * Determine if a bucket contains metadata. An empty bucket is + * safe to arbitrarily remove if and only if this is false. + * @param e The bucket to inspect + * @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 + * @return true or false + } +//#define APR_BUCKET_IS_FLUSH(e) ((e)->type == &apr_bucket_type_flush) +{ + * Determine if a bucket is an EOS bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_EOS(e) ((e)->type == &apr_bucket_type_eos) +{ + * Determine if a bucket is a FILE bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_FILE(e) ((e)->type == &apr_bucket_type_file) +{ + * Determine if a bucket is a PIPE bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_PIPE(e) ((e)->type == &apr_bucket_type_pipe) +{ + * Determine if a bucket is a SOCKET bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_SOCKET(e) ((e)->type == &apr_bucket_type_socket) +{ + * Determine if a bucket is a HEAP bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_HEAP(e) ((e)->type == &apr_bucket_type_heap) +{ + * Determine if a bucket is a TRANSIENT bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_TRANSIENT(e) ((e)->type == &apr_bucket_type_transient) +{ + * Determine if a bucket is a IMMORTAL bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_IMMORTAL(e) ((e)->type == &apr_bucket_type_immortal) +//#if APR_HAS_MMAP +{ + * Determine if a bucket is a MMAP bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_MMAP(e) ((e)->type == &apr_bucket_type_mmap) +//#endif +{ + * Determine if a bucket is a POOL bucket + * @param e The bucket to inspect + * @return true or false + } +//#define APR_BUCKET_IS_POOL(e) ((e)->type == &apr_bucket_type_pool) + +{ + * General-purpose reference counting for the various bucket types. + * + * Any bucket type that keeps track of the resources it uses (i.e. + * most of them except for IMMORTAL, TRANSIENT, and EOS) needs to + * attach a reference count to the resource so that it can be freed + * when the last bucket that uses it goes away. Resource-sharing may + * occur because of bucket splits or buckets that refer to globally + * cached data. } + +{ @see apr_bucket_refcount } + Papr_bucket_refcount = ^apr_bucket_refcount; +{ + * The structure used to manage the shared resource must start with an + * apr_bucket_refcount which is updated by the general-purpose refcount + * code. A pointer to the bucket-type-dependent private data structure + * can be cast to a pointer to an apr_bucket_refcount and vice versa. + } + apr_bucket_refcount = record + { The number of references to this bucket } + refcount: Integer; + end; + +{ ***** Reference-counted bucket types ***** } + +{ @see apr_bucket_heap } + Papr_bucket_heap = ^apr_bucket_heap; +{ + * A bucket referring to data allocated off the heap. + } + free_func_t = procedure (data: Pointer); + + apr_bucket_heap = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The start of the data actually allocated. This should never be + * modified, it is only used to free the bucket. + } + base: PChar; + { how much memory was allocated } + alloc_len: apr_size_t; + { function to use to delete the data } + free_func: free_func_t; + end; + +{ @see apr_bucket_pool } + Papr_bucket_pool = ^apr_bucket_pool; +{ + * A bucket referring to data allocated from a pool + } + apr_bucket_pool = record + { The pool bucket must be able to be easily morphed to a heap + * bucket if the pool gets cleaned up before all references are + * destroyed. This apr_bucket_heap structure is populated automatically + * when the pool gets cleaned up, and subsequent calls to pool_read() + * will result in the apr_bucket in question being morphed into a + * regular heap bucket. (To avoid having to do many extra refcount + * manipulations and b->data manipulations, the apr_bucket_pool + * struct actually *contains* the apr_bucket_heap struct that it + * will become as its first element; the two share their + * apr_bucket_refcount members.) + } + heap: apr_bucket_heap; + { The block of data actually allocated from the pool. + * Segments of this block are referenced by adjusting + * the start and length of the apr_bucket accordingly. + * This will be NULL after the pool gets cleaned up. + } + base: PChar; + { The pool the data was allocated from. When the pool + * is cleaned up, this gets set to NULL as an indicator + * to pool_read() that the data is now on the heap and + * so it should morph the bucket into a regular heap + * bucket before continuing. + } + pool: Papr_pool_t; + { The freelist this structure was allocated from, which is + * needed in the cleanup phase in order to allocate space on the heap + } + list: Papr_bucket_alloc_t; + end; + +{$ifdef APR_HAS_MMAP} +{ @see apr_bucket_mmap } + Papr_bucket_mmap = ^apr_bucket_mmap; +{ + * A bucket referring to an mmap()ed file + } + apr_bucket_mmap = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The mmap this sub_bucket refers to } + mmap: Papr_mmap_t; + end; +{$endif} + +{ @see apr_bucket_file } + Papr_bucket_file = ^apr_bucket_file; +{ + * A bucket referring to an file + } + apr_bucket_file = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The file this bucket refers to } + fd: Papr_file_t; + { The pool into which any needed structures should + * be created while reading from this file bucket } + readpool: Papr_pool_t; +{$ifdef APR_HAS_MMAP} + { Whether this bucket should be memory-mapped if + * a caller tries to read from it } + can_mmap: Integer; +{$endif} { APR_HAS_MMAP } + end; + +{ @see apr_bucket_structs } + Papr_bucket_structs = ^apr_bucket_structs; +{ + * A union of all bucket structures so we know what + * the max size is. + } + apr_bucket_structs = record + case Integer of + 0: (b: apr_bucket); {< Bucket } + 1: (heap: apr_bucket_heap); {< Heap } + 2: (pool: apr_bucket_pool); {< Pool } +{$ifdef APR_HAS_MMAP} + 3: (mmap: apr_bucket_mmap); {< MMap } +{$endif} + 4: (file_: apr_bucket_file); {< File } + end; + +{ + * The amount that apr_bucket_alloc() should allocate in the common case. + * Note: this is twice as big as apr_bucket_structs to allow breathing + * room for third-party bucket types. + } +//#define APR_BUCKET_ALLOC_SIZE APR_ALIGN_DEFAULT(2*sizeof(apr_bucket_structs)) + +{ ***** Bucket Brigade Functions ***** } +{ + * Create a new bucket brigade. The bucket brigade is originally empty. + * @param p The pool to associate with the brigade. Data is not allocated out + * of the pool, but a cleanup is registered. + * @param list The bucket allocator to use + * @return The empty bucket brigade + } +//APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p, +// apr_bucket_alloc_t *list); + +{ + * destroy an entire bucket brigade. This includes destroying all of the + * buckets within the bucket brigade's bucket list. + * @param b The bucket brigade to destroy + } +//APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b); + +{ + * empty out an entire bucket brigade. This includes destroying all of the + * buckets within the bucket brigade's bucket list. This is similar to + * apr_brigade_destroy(), except that it does not deregister the brigade's + * pool cleanup function. + * @param data The bucket brigade to clean up + * @remark Generally, you should use apr_brigade_destroy(). This function + * can be useful in situations where you have a single brigade that + * you wish to reuse many times by destroying all of the buckets in + * the brigade and putting new buckets into it later. + } +//APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data); + +{ + * Split a bucket brigade into two, such that the given bucket is the + * first in the new bucket brigade. This function is useful when a + * filter wants to pass only the initial part of a brigade to the next + * filter. + * @param b The brigade to split + * @param e The first element of the new brigade + * @return The new brigade + } +//APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b, +// apr_bucket *e); + +{ + * Partition a bucket brigade at a given offset (in bytes from the start of + * the brigade). This is useful whenever a filter wants to use known ranges + * of bytes from the brigade; the ranges can even overlap. + * @param b The brigade to partition + * @param point The offset at which to partition the brigade + * @param after_point Returns a pointer to the first bucket after the partition + } +//APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b, +// apr_off_t point, +// apr_bucket **after_point); + +//#if APR_NOT_DONE_YET +{ + * consume nbytes from beginning of b -- call apr_bucket_destroy as + * appropriate, and/or modify start on last element + * @param b The brigade to consume data from + * @param nbytes The number of bytes to consume + } +//APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b, +// apr_off_t nbytes); +//#endif + +{ + * Return the total length of the brigade. + * @param bb The brigade to compute the length of + * @param read_all Read unknown-length buckets to force a size + * @param length Returns the length of the brigade, or -1 if the brigade has + * buckets of indeterminate length and read_all is 0. + } +{APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb, + int read_all, + apr_off_t *length); +} +{ + * Take a bucket brigade and store the data in a flat char* + * @param bb The bucket brigade to create the char* from + * @param c The char* to write into + * @param len The maximum length of the char array. On return, it is the + * actual length of the char array. + } +{APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb, + char *c, + apr_size_t *len); +} +{ + * Creates a pool-allocated string representing a flat bucket brigade + * @param bb The bucket brigade to create the char array from + * @param c On return, the allocated char array + * @param len On return, the length of the char array. + * @param pool The pool to allocate the string from. + } +{APU_DECLARE(apr_status_t) apr_brigade_pflatten(apr_bucket_brigade *bb, + char **c, + apr_size_t *len, + apr_pool_t *pool); +} +{ + * Split a brigade to represent one LF line. + * @param bbOut The bucket brigade that will have the LF line appended to. + * @param bbIn The input bucket brigade to search for a LF-line. + * @param block The blocking mode to be used to split the line. + * @param maxbytes The maximum bytes to read. If this many bytes are seen + * without a LF, the brigade will contain a partial line. + } +{APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut, + apr_bucket_brigade *bbIn, + apr_read_type_e block, + apr_off_t maxbytes); +} +{ + * create an iovec of the elements in a bucket_brigade... return number + * of elements used. This is useful for writing to a file or to the + * network efficiently. + * @param b The bucket brigade to create the iovec from + * @param vec The iovec to create + * @param nvec The number of elements in the iovec. On return, it is the + * number of iovec elements actually filled out. + } +{APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b, + struct iovec *vec, int *nvec); +} +{ + * This function writes a list of strings into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param va A list of strings to add + * @return APR_SUCCESS or error code. + } +{APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + va_list va); +} +{ + * This function writes a string into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param str The string to add + * @param nbyte The number of bytes to write + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b, + apr_brigade_flush flush, void *ctx, + const char *str, apr_size_t nbyte); +} +{ + * This function writes multiple strings into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param vec The strings to add (address plus length for each) + * @param nvec The number of entries in iovec + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + const struct iovec *vec, + apr_size_t nvec); +} +{ + * This function writes a string into a bucket brigade. + * @param bb The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param str The string to add + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb, + apr_brigade_flush flush, void *ctx, + const char *str); +} +{ + * This function writes a character into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param c The character to add + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b, + apr_brigade_flush flush, void *ctx, + const char c); +} +{ + * This function writes an unspecified number of strings into a bucket brigade. + * @param b The bucket brigade to add to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param ... The strings to add + * @return APR_SUCCESS or error code + } +{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, ...); +} +{ + * Evaluate a printf and put the resulting string at the end + * of the bucket brigade. + * @param b The brigade to write to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param fmt The format of the string to write + * @param ... The arguments to fill out the format + * @return APR_SUCCESS or error code + } +{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + const char *fmt, ...) + __attribute__((format(printf,4,5))); +} +{ + * Evaluate a printf and put the resulting string at the end + * of the bucket brigade. + * @param b The brigade to write to + * @param flush The flush function to use if the brigade is full + * @param ctx The structure to pass to the flush function + * @param fmt The format of the string to write + * @param va The arguments to fill out the format + * @return APR_SUCCESS or error code + } +{APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b, + apr_brigade_flush flush, + void *ctx, + const char *fmt, va_list va); +} +{ ***** Bucket freelist functions ***** } +{ + * Create a bucket allocator. + * @param p This pool's underlying apr_allocator_t is used to allocate memory + * for the bucket allocator. When the pool is destroyed, the bucket + * allocator's cleanup routine will free all memory that has been + * allocated from it. + * @remark The reason the allocator gets its memory from the pool's + * apr_allocator_t rather than from the pool itself is because + * the bucket allocator will free large memory blocks back to the + * allocator when it's done with them, thereby preventing memory + * footprint growth that would occur if we allocated from the pool. + * @warning The allocator must never be used by more than one thread at a time. + } +//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p); + +{ + * Create a bucket allocator. + * @param allocator This apr_allocator_t is used to allocate both the bucket + * allocator and all memory handed out by the bucket allocator. The + * caller is responsible for destroying the bucket allocator and the + * apr_allocator_t -- no automatic cleanups will happen. + * @warning The allocator must never be used by more than one thread at a time. + } +//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex(apr_allocator_t *allocator); + +{ + * Destroy a bucket allocator. + * @param list The allocator to be destroyed + } +//APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list); + +{ + * Allocate memory for use by the buckets. + * @param size The amount to allocate. + * @param list The allocator from which to allocate the memory. + } +//APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list); + +{ + * Free memory previously allocated with apr_bucket_alloc(). + * @param block The block of memory to be freed. + } +//APU_DECLARE_NONSTD(void) apr_bucket_free(void *block); + + +{ ***** Bucket Functions ***** } +{ + * Free the resources used by a bucket. If multiple buckets refer to + * the same resource it is freed when the last one goes away. + * @see apr_bucket_delete() + * @param e The bucket to destroy + } +{#define apr_bucket_destroy(e) do begin + (e)->type->destroy((e)->data); \ + (e)->free(e); \ + end while (0)} + +{ + * Delete a bucket by removing it from its brigade (if any) and then + * destroying it. + * @remark This mainly acts as an aid in avoiding code verbosity. It is + * the preferred exact equivalent to: + *
+ * APR_BUCKET_REMOVE(e); + * apr_bucket_destroy(e); + *+ * @param e The bucket to delete + } +{#define apr_bucket_delete(e) do begin + APR_BUCKET_REMOVE(e); \ + apr_bucket_destroy(e); \ + end while (0)} + +{ + * read the data from the bucket + * @param e The bucket to read from + * @param str The location to store the data in + * @param len The amount of data read + * @param block Whether the read function blocks + } +//#define apr_bucket_read(e,str,len,block) (e)->type->read(e, str, len, block) + +{ + * Setaside data so that stack data is not destroyed on returning from + * the function + * @param e The bucket to setaside + * @param p The pool to setaside into + } +//#define apr_bucket_setaside(e,p) (e)->type->setaside(e,p) + +{ + * Split one bucket in two. + * @param e The bucket to split + * @param point The offset to split the bucket at + } +//#define apr_bucket_split(e,point) (e)->type->split(e, point) + +{ + * Copy a bucket. + * @param e The bucket to copy + * @param c Returns a pointer to the new bucket + } +//#define apr_bucket_copy(e,c) (e)->type->copy(e, c) + +{ Bucket type handling } + +{ + * This function simply returns APR_SUCCESS to denote that the bucket does + * not require anything to happen for its setaside() function. This is + * appropriate for buckets that have "immortal" data -- the data will live + * at least as long as the bucket. + * @param data The bucket to setaside + * @param pool The pool defining the desired lifetime of the bucket data + * @return APR_SUCCESS + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data, + apr_pool_t *pool); +} +{ + * A place holder function that signifies that the setaside function was not + * implemented for this bucket + * @param data The bucket to setaside + * @param pool The pool defining the desired lifetime of the bucket data + * @return APR_ENOTIMPL + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data, + apr_pool_t *pool); +} +{ + * A place holder function that signifies that the split function was not + * implemented for this bucket + * @param data The bucket to split + * @param point The location to split the bucket + * @return APR_ENOTIMPL + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data, + apr_size_t point); +} +{ + * A place holder function that signifies that the copy function was not + * implemented for this bucket + * @param e The bucket to copy + * @param c Returns a pointer to the new bucket + * @return APR_ENOTIMPL + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_copy_notimpl(apr_bucket *e, + apr_bucket **c); +} +{ + * A place holder function that signifies that this bucket does not need + * to do anything special to be destroyed. That's only the case for buckets + * that either have no data (metadata buckets) or buckets whose data pointer + * points to something that's not a bucket-type-specific structure, as with + * simple buckets where data points to a string and pipe buckets where data + * points directly to the apr_file_t. + * @param data The bucket data to destroy + } +//APU_DECLARE_NONSTD(void) apr_bucket_destroy_noop(void *data); + +{ + * There is no apr_bucket_destroy_notimpl, because destruction is required + * to be implemented (it could be a noop, but only if that makes sense for + * the bucket type) + } + +{ There is no apr_bucket_read_notimpl, because it is a required function + } + + +{ 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. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_flush; +{ + * 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 + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_eos; +{ + * The FILE bucket type. This bucket represents a file on disk + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_file; +{ + * The HEAP bucket type. This bucket represents a data allocated from the + * heap. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_heap; +//#if APR_HAS_MMAP +{ + * The MMAP bucket type. This bucket represents an MMAP'ed file + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_mmap; +//#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. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pool; +{ + * The PIPE bucket type. This bucket represents a pipe to another program. + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pipe; +{ + * 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 + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_immortal; +{ + * 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 + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_transient; +{ + * The SOCKET bucket type. This bucket represents a socket to another machine + } +//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_socket; + + +{ ***** Simple buckets ***** } + +{ + * Split a simple bucket into two at the given point. Most non-reference + * counting buckets that allow multiple references to the same block of + * data (eg transient and immortal) will use this as their split function + * without any additional type-specific handling. + * @param b The bucket to be split + * @param point The offset of the first byte in the new bucket + * @return APR_EINVAL if the point is not within the bucket; + * APR_ENOMEM if allocation failed; + * or APR_SUCCESS + } +//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *b, +// apr_size_t point); + +{ + * Copy a simple bucket. Most non-reference-counting buckets that allow + * multiple references to the same block of data (eg transient and immortal) + * will use this as their copy function without any additional type-specific + * handling. + * @param a The bucket to copy + * @param b Returns a pointer to the new bucket + * @return APR_ENOMEM if allocation failed; + * or APR_SUCCESS + } +{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a, + apr_bucket **b); + +} +{ ***** Shared, reference-counted buckets ***** } + +{ + * Initialize a bucket containing reference-counted data that may be + * shared. The caller must allocate the bucket if necessary and + * initialize its type-dependent fields, and allocate and initialize + * its own private data structure. This function should only be called + * by type-specific bucket creation functions. + * @param b The bucket to initialize + * @param data A pointer to the private data structure + * with the reference count at the start + * @param start The start of the data in the bucket + * relative to the private base pointer + * @param length The length of the data in the bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data, + apr_off_t start, + apr_size_t length); +} +{ + * Decrement the refcount of the data in the bucket. This function + * should only be called by type-specific bucket destruction functions. + * @param data The private data pointer from the bucket to be destroyed + * @return TRUE or FALSE; TRUE if the reference count is now + * zero, indicating that the shared resource itself can + * be destroyed by the caller. + } +//APU_DECLARE(int) apr_bucket_shared_destroy(void *data); + +{ + * Split a bucket into two at the given point, and adjust the refcount + * to the underlying data. Most reference-counting bucket types will + * be able to use this function as their split function without any + * additional type-specific handling. + * @param b The bucket to be split + * @param point The offset of the first byte in the new bucket + * @return APR_EINVAL if the point is not within the bucket; + * APR_ENOMEM if allocation failed; + * or APR_SUCCESS + } +//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *b, +// apr_size_t point); + +{ + * Copy a refcounted bucket, incrementing the reference count. Most + * reference-counting bucket types will be able to use this function + * as their copy function without any additional type-specific handling. + * @param a The bucket to copy + * @param b Returns a pointer to the new bucket + * @return APR_ENOMEM if allocation failed; + or APR_SUCCESS + } +//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a, +// apr_bucket **b); + + +{ ***** Functions to Create Buckets of varying types ***** } +{ + * Each bucket type foo has two initialization functions: + * apr_bucket_foo_make which sets up some already-allocated memory as a + * bucket of type foo; and apr_bucket_foo_create which allocates memory + * for the bucket, calls apr_bucket_make_foo, and initializes the + * bucket's list pointers. The apr_bucket_foo_make functions are used + * inside the bucket code to change the type of buckets in place; + * other code should call apr_bucket_foo_create. All the initialization + * functions change nothing if they fail. + } + +{ + * Create an End of Stream bucket. This indicates that there is no more data + * coming from down the filter stack. All filters should flush at this point. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_eos_create(apr_bucket_alloc_t *list); + +{ + * Make the bucket passed in an EOS bucket. This indicates that there is no + * more data coming from down the filter stack. All filters should flush at + * this point. + * @param b The bucket to make into an EOS bucket + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_eos_make(apr_bucket *b); + +{ + * Create a flush bucket. This indicates that filters should flush their + * data. There is no guarantee that they will flush it, but this is the + * best we can do. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_flush_create(apr_bucket_alloc_t *list); + +{ + * Make the bucket passed in a FLUSH bucket. This indicates that filters + * should flush their data. There is no guarantee that they will flush it, + * but this is the best we can do. + * @param b The bucket to make into a FLUSH bucket + * @return The new bucket, or NULL if allocation failed + } +//APU_DECLARE(apr_bucket *) apr_bucket_flush_make(apr_bucket *b); + +{ + * Create a bucket referring to long-lived data. + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf, + apr_size_t nbyte, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to long-lived data + * @param b The bucket to make into a IMMORTAL bucket + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_immortal_make(apr_bucket *b, + const char *buf, + apr_size_t nbyte); +} +{ + * Create a bucket referring to data on the stack. + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf, + apr_size_t nbyte, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to stack data + * @param b The bucket to make into a TRANSIENT bucket + * @param buf The data to insert into the bucket + * @param nbyte The size of the data to insert. + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_transient_make(apr_bucket *b, + const char *buf, + apr_size_t nbyte); +} +{ + * Create a bucket referring to memory on the heap. If the caller asks + * for the data to be copied, this function always allocates 4K of + * memory so that more data can be added to the bucket without + * requiring another allocation. Therefore not all the data may be put + * into the bucket. If copying is not requested then the bucket takes + * over responsibility for free()ing the memory. + * @param buf The buffer to insert into the bucket + * @param nbyte The size of the buffer to insert. + * @param free_func Function to use to free the data; NULL indicates that the + * bucket should make a copy of the data + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf, + apr_size_t nbyte, + void ( *free_func)(void *data), + apr_bucket_alloc_t *list);} +{ + * Make the bucket passed in a bucket refer to heap data + * @param b The bucket to make into a HEAP bucket + * @param buf The buffer to insert into the bucket + * @param nbyte The size of the buffer to insert. + * @param free_func Function to use to free the data; NULL indicates that the + * bucket should make a copy of the data + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b, const char *buf, + apr_size_t nbyte, + void ( *free_func)(void *data));} + +{ + * Create a bucket referring to memory allocated from a pool. + * + * @param buf The buffer to insert into the bucket + * @param length The number of bytes referred to by this bucket + * @param pool The pool the memory was allocated from + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf, + apr_size_t length, + apr_pool_t *pool, + apr_bucket_alloc_t *list);} + +{ + * Make the bucket passed in a bucket refer to pool data + * @param b The bucket to make into a pool bucket + * @param buf The buffer to insert into the bucket + * @param length The number of bytes referred to by this bucket + * @param pool The pool the memory was allocated from + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b, const char *buf, + apr_size_t length, + apr_pool_t *pool);} + +//#if APR_HAS_MMAP +{ + * Create a bucket referring to mmap()ed memory. + * @param mm The mmap to insert into the bucket + * @param start The offset of the first byte in the mmap + * that this bucket refers to + * @param length The number of bytes referred to by this bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm, + apr_off_t start, + apr_size_t length, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to an MMAP'ed file + * @param b The bucket to make into a MMAP bucket + * @param mm The mmap to insert into the bucket + * @param start The offset of the first byte in the mmap + * that this bucket refers to + * @param length The number of bytes referred to by this bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm, + apr_off_t start, + apr_size_t length); +#endif} + +{ + * Create a bucket referring to a socket. + * @param thissock The socket to put in the bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *thissock, + apr_bucket_alloc_t *list);} +{ + * Make the bucket passed in a bucket refer to a socket + * @param b The bucket to make into a SOCKET bucket + * @param thissock The socket to put in the bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_socket_make(apr_bucket *b, + apr_socket_t *thissock);} + +{ + * Create a bucket referring to a pipe. + * @param thispipe The pipe to put in the bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *thispipe, + apr_bucket_alloc_t *list);} + +{ + * Make the bucket passed in a bucket refer to a pipe + * @param b The bucket to make into a PIPE bucket + * @param thispipe The pipe to put in the bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_pipe_make(apr_bucket *b, + apr_file_t *thispipe);} + +{ + * Create a bucket referring to a file. + * @param fd The file to put in the bucket + * @param offset The offset where the data of interest begins in the file + * @param len The amount of data in the file we are interested in + * @param p The pool into which any needed structures should be created + * while reading from this file bucket + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd, + apr_off_t offset, + apr_size_t len, + apr_pool_t *p, + apr_bucket_alloc_t *list); +} +{ + * Make the bucket passed in a bucket refer to a file + * @param b The bucket to make into a FILE bucket + * @param fd The file to put in the bucket + * @param offset The offset where the data of interest begins in the file + * @param len The amount of data in the file we are interested in + * @param p The pool into which any needed structures should be created + * while reading from this file bucket + * @return The new bucket, or NULL if allocation failed + } +{APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd, + apr_off_t offset, + apr_size_t len, apr_pool_t *p); +} +{ + * Enable or disable memory-mapping for a FILE bucket (default is enabled) + * @param b The bucket + * @param enabled Whether memory-mapping should be enabled + * @return APR_SUCCESS normally, or an error code if the operation fails + } +{APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *b, + int enabled);} + diff --git a/httpd/httpd_2_2/apr/apr_dso.inc b/httpd/httpd_2_2/apr/apr_dso.inc new file mode 100644 index 000000000..ec41ea6d6 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_dso.inc @@ -0,0 +1,95 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_dso.h + * @brief APR Dynamic Object Handling Routines + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h"} + +{ + * @defgroup apr_dso Dynamic Object Handling + * @ingroup APR + } + +{$define APR_HAS_DSO} + +{$if defined(APR_HAS_DSO) or defined(DOXYGEN)} + +{ + * Structure for referencing dynamic objects + } +type + apr_dso_handle_t = record + end; + Papr_dso_handle_t = ^apr_dso_handle_t; + PPapr_dso_handle_t = ^Papr_dso_handle_t; + +{ + * Structure for referencing symbols from dynamic objects + } + apr_dso_handle_sym_t = Pointer; + Papr_dso_handle_sym_t = ^apr_dso_handle_sym_t; + PPapr_dso_handle_sym_t = ^Papr_dso_handle_sym_t; + +{ + * Load a DSO library. + * @param res_handle Location to store new handle for the DSO. + * @param path Path to the DSO library + * @param ctx Pool to use. + * @bug We aught to provide an alternative to RTLD_GLOBAL, which + * is the only supported method of loading DSOs today. + } +function apr_dso_load(res_handle: PPapr_dso_handle_t; const path: PChar; + ctx: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_load' + LibSuff12; + +{ + * Close a DSO library. + * @param handle handle to close. + } +function apr_dso_unload(handle: Papr_dso_handle_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_unload' + LibSuff4; + +{ + * Load a symbol from a DSO handle. + * @param ressym Location to store the loaded symbol + * @param handle handle to load the symbol from. + * @param symname Name of the symbol to load. + } +function apr_dso_sym(ressym: Papr_dso_handle_t; handle: Papr_dso_handle_t; + const symname: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_sym' + LibSuff12; + +{ + * Report more information when a DSO function fails. + * @param dso The dso handle that has been opened + * @param buf Location to store the dso error + * @param bufsize The size of the provided buffer + } +function apr_dso_error(dso: Papr_dso_handle_t; buf: PChar; + bufsize: apr_size_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dso_error' + LibSuff12; + +{$endif} + diff --git a/httpd/httpd_2_2/apr/apr_errno.inc b/httpd/httpd_2_2/apr/apr_errno.inc new file mode 100644 index 000000000..1bbb7f002 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_errno.inc @@ -0,0 +1,1191 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_errno.h + * @brief APR Error Codes + } + +{#include "apr.h" + +#if APR_HAVE_ERRNO_H +#include
+ * APR ERROR VALUES + * APR_ENOSTAT APR was unable to perform a stat on the file + * APR_ENOPOOL APR was not provided a pool with which to allocate memory + * APR_EBADDATE APR was given an invalid date + * APR_EINVALSOCK APR was given an invalid socket + * APR_ENOPROC APR was not given a process structure + * APR_ENOTIME APR was not given a time structure + * APR_ENODIR APR was not given a directory structure + * APR_ENOLOCK APR was not given a lock structure + * APR_ENOPOLL APR was not given a poll structure + * APR_ENOSOCKET APR was not given a socket + * APR_ENOTHREAD APR was not given a thread structure + * APR_ENOTHDKEY APR was not given a thread key structure + * APR_ENOSHMAVAIL There is no more shared memory available + * APR_EDSOOPEN APR was unable to open the dso object. For more + * information call apr_dso_error(). + * APR_EGENERAL General failure (specific information not available) + * APR_EBADIP The specified IP address is invalid + * APR_EBADMASK The specified netmask is invalid + * APR_ESYMNOTFOUND Could not find the requested symbol + *+ * + *
+ * APR STATUS VALUES + * APR_INCHILD Program is currently executing in the child + * APR_INPARENT Program is currently executing in the parent + * APR_DETACH The thread is detached + * APR_NOTDETACH The thread is not detached + * APR_CHILD_DONE The child has finished executing + * APR_CHILD_NOTDONE The child has not finished executing + * APR_TIMEUP The operation did not finish before the timeout + * APR_INCOMPLETE The operation was incomplete although some processing + * was performed and the results are partially valid + * APR_BADCH Getopt found an option not in the option string + * APR_BADARG Getopt found an option that is missing an argument + * and an argument was specified in the option string + * APR_EOF APR has encountered the end of the file + * APR_NOTFOUND APR was unable to find the socket in the poll structure + * APR_ANONYMOUS APR is using anonymous shared memory + * APR_FILEBASED APR is using a file name as the key to the shared memory + * APR_KEYBASED APR is using a shared key as the key to the shared memory + * APR_EINIT Ininitalizer value. If no option has been found, but + * the status variable requires a value, this should be used + * APR_ENOTIMPL The APR function has not been implemented on this + * platform, either because nobody has gotten to it yet, + * or the function is impossible on this platform. + * APR_EMISMATCH Two passwords do not match. + * APR_EABSOLUTE The given path was absolute. + * APR_ERELATIVE The given path was relative. + * APR_EINCOMPLETE The given path was neither relative nor absolute. + * APR_EABOVEROOT The given path was above the root path. + * APR_EBUSY The given lock was busy. + * APR_EPROC_UNKNOWN The given process wasn't recognized by APR + *+ } +{ @see APR_STATUS_IS_ENOSTAT } + APR_ENOSTAT = (APR_OS_START_ERROR + 1); +{ @see APR_STATUS_IS_ENOPOOL } + APR_ENOPOOL = (APR_OS_START_ERROR + 2); +{ empty slot: +3 } +{ @see APR_STATUS_IS_EBADDATE } + APR_EBADDATE = (APR_OS_START_ERROR + 4); +{ @see APR_STATUS_IS_EINVALSOCK } + APR_EINVALSOCK = (APR_OS_START_ERROR + 5); +{ @see APR_STATUS_IS_ENOPROC } + APR_ENOPROC = (APR_OS_START_ERROR + 6); +{ @see APR_STATUS_IS_ENOTIME } + APR_ENOTIME = (APR_OS_START_ERROR + 7); +{ @see APR_STATUS_IS_ENODIR } + APR_ENODIR = (APR_OS_START_ERROR + 8); +{ @see APR_STATUS_IS_ENOLOCK } + APR_ENOLOCK = (APR_OS_START_ERROR + 9); +{ @see APR_STATUS_IS_ENOPOLL } + APR_ENOPOLL = (APR_OS_START_ERROR + 10); +{ @see APR_STATUS_IS_ENOSOCKET } + APR_ENOSOCKET = (APR_OS_START_ERROR + 11); +{ @see APR_STATUS_IS_ENOTHREAD } + APR_ENOTHREAD = (APR_OS_START_ERROR + 12); +{ @see APR_STATUS_IS_ENOTHDKEY } + APR_ENOTHDKEY = (APR_OS_START_ERROR + 13); +{ @see APR_STATUS_IS_EGENERAL } + APR_EGENERAL = (APR_OS_START_ERROR + 14); +{ @see APR_STATUS_IS_ENOSHMAVAIL } + APR_ENOSHMAVAIL = (APR_OS_START_ERROR + 15); +{ @see APR_STATUS_IS_EBADIP } + APR_EBADIP = (APR_OS_START_ERROR + 16); +{ @see APR_STATUS_IS_EBADMASK } + APR_EBADMASK = (APR_OS_START_ERROR + 17); +{ empty slot: +18 } +{ @see APR_STATUS_IS_EDSOPEN } + APR_EDSOOPEN = (APR_OS_START_ERROR + 19); +{ @see APR_STATUS_IS_EABSOLUTE } + APR_EABSOLUTE = (APR_OS_START_ERROR + 20); +{ @see APR_STATUS_IS_ERELATIVE } + APR_ERELATIVE = (APR_OS_START_ERROR + 21); +{ @see APR_STATUS_IS_EINCOMPLETE } + APR_EINCOMPLETE = (APR_OS_START_ERROR + 22); +{ @see APR_STATUS_IS_EABOVEROOT } + APR_EABOVEROOT = (APR_OS_START_ERROR + 23); +{ @see APR_STATUS_IS_EBADPATH } + APR_EBADPATH = (APR_OS_START_ERROR + 24); +{ @see APR_STATUS_IS_EPATHWILD } + APR_EPATHWILD = (APR_OS_START_ERROR + 25); +{ @see APR_STATUS_IS_ESYMNOTFOUND } + APR_ESYMNOTFOUND = (APR_OS_START_ERROR + 26); +{ @see APR_STATUS_IS_EPROC_UNKNOWN } + APR_EPROC_UNKNOWN = (APR_OS_START_ERROR + 27); + +{ + * @defgroup APR_STATUS_IS Status Value Tests + * @warning For any particular error condition, more than one of these tests + * may match. This is because platform-specific error codes may not + * always match the semantics of the POSIX codes these tests (and the + * correcponding APR error codes) are named after. A notable example + * are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on + * Win32 platforms. The programmer should always be aware of this and + * adjust the order of the tests accordingly. + } +{ + * APR was unable to perform a stat on the file + * @warning always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ENOSTAT(s) ((s) == APR_ENOSTAT) +{ + * APR was not provided a pool with which to allocate memory + * @warning always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ENOPOOL(s) ((s) == APR_ENOPOOL) +{ APR was given an invalid date } +//#define APR_STATUS_IS_EBADDATE(s) ((s) == APR_EBADDATE) +{ APR was given an invalid socket } +//#define APR_STATUS_IS_EINVALSOCK(s) ((s) == APR_EINVALSOCK) +{ APR was not given a process structure } +//#define APR_STATUS_IS_ENOPROC(s) ((s) == APR_ENOPROC) +{ APR was not given a time structure } +//#define APR_STATUS_IS_ENOTIME(s) ((s) == APR_ENOTIME) +{ APR was not given a directory structure } +//#define APR_STATUS_IS_ENODIR(s) ((s) == APR_ENODIR) +{ APR was not given a lock structure } +//#define APR_STATUS_IS_ENOLOCK(s) ((s) == APR_ENOLOCK) +{ APR was not given a poll structure } +//#define APR_STATUS_IS_ENOPOLL(s) ((s) == APR_ENOPOLL) +{ APR was not given a socket } +//#define APR_STATUS_IS_ENOSOCKET(s) ((s) == APR_ENOSOCKET) +{ APR was not given a thread structure } +//#define APR_STATUS_IS_ENOTHREAD(s) ((s) == APR_ENOTHREAD) +{ APR was not given a thread key structure } +//#define APR_STATUS_IS_ENOTHDKEY(s) ((s) == APR_ENOTHDKEY) +{ Generic Error which can not be put into another spot } +//#define APR_STATUS_IS_EGENERAL(s) ((s) == APR_EGENERAL) +{ There is no more shared memory available } +//#define APR_STATUS_IS_ENOSHMAVAIL(s) ((s) == APR_ENOSHMAVAIL) +{ The specified IP address is invalid } +//#define APR_STATUS_IS_EBADIP(s) ((s) == APR_EBADIP) +{ The specified netmask is invalid } +//#define APR_STATUS_IS_EBADMASK(s) ((s) == APR_EBADMASK) +{ empty slot: +18 } +{ + * APR was unable to open the dso object. + * For more information call apr_dso_error(). + } +//#if defined(WIN32) +//#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \ +// || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND) +//#else +//#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN) +//#endif +{ The given path was absolute. } +//#define APR_STATUS_IS_EABSOLUTE(s) ((s) == APR_EABSOLUTE) +{ The given path was relative. } +//#define APR_STATUS_IS_ERELATIVE(s) ((s) == APR_ERELATIVE) +{ The given path was neither relative nor absolute. } +//#define APR_STATUS_IS_EINCOMPLETE(s) ((s) == APR_EINCOMPLETE) +{ The given path was above the root path. } +//#define APR_STATUS_IS_EABOVEROOT(s) ((s) == APR_EABOVEROOT) +{ The given path was bad. } +//#define APR_STATUS_IS_EBADPATH(s) ((s) == APR_EBADPATH) +{ The given path contained wildcards. } +//#define APR_STATUS_IS_EPATHWILD(s) ((s) == APR_EPATHWILD) +{ Could not find the requested symbol. + * For more information call apr_dso_error(). + } +//#if defined(WIN32) +//#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \ +// || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND) +//#else +//#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND) +//#endif +{ The given process was not recognized by APR. } +//#define APR_STATUS_IS_EPROC_UNKNOWN(s) ((s) == APR_EPROC_UNKNOWN) + +{ + * @addtogroup APR_Error + } +{ @see APR_STATUS_IS_INCHILD } + APR_INCHILD = (APR_OS_START_STATUS + 1); +{ @see APR_STATUS_IS_INPARENT } + APR_INPARENT = (APR_OS_START_STATUS + 2); +{ @see APR_STATUS_IS_DETACH } + APR_DETACH = (APR_OS_START_STATUS + 3); +{ @see APR_STATUS_IS_NOTDETACH } + APR_NOTDETACH = (APR_OS_START_STATUS + 4); +{ @see APR_STATUS_IS_CHILD_DONE } + APR_CHILD_DONE = (APR_OS_START_STATUS + 5); +{ @see APR_STATUS_IS_CHILD_NOTDONE } + APR_CHILD_NOTDONE = (APR_OS_START_STATUS + 6); +{ @see APR_STATUS_IS_TIMEUP } + APR_TIMEUP = (APR_OS_START_STATUS + 7); +{ @see APR_STATUS_IS_INCOMPLETE } + APR_INCOMPLETE = (APR_OS_START_STATUS + 8); +{ empty slot: +9 } +{ empty slot: +10 } +{ empty slot: +11 } +{ @see APR_STATUS_IS_BADCH } + APR_BADCH = (APR_OS_START_STATUS + 12); +{ @see APR_STATUS_IS_BADARG } + APR_BADARG = (APR_OS_START_STATUS + 13); +{ @see APR_STATUS_IS_EOF } + APR_EOF = (APR_OS_START_STATUS + 14); +{ @see APR_STATUS_IS_NOTFOUND } + APR_NOTFOUND = (APR_OS_START_STATUS + 15); +{ empty slot: +16 } +{ empty slot: +17 } +{ empty slot: +18 } +{ @see APR_STATUS_IS_ANONYMOUS } + APR_ANONYMOUS = (APR_OS_START_STATUS + 19); +{ @see APR_STATUS_IS_FILEBASED } + APR_FILEBASED = (APR_OS_START_STATUS + 20); +{ @see APR_STATUS_IS_KEYBASED } + APR_KEYBASED = (APR_OS_START_STATUS + 21); +{ @see APR_STATUS_IS_EINIT } + APR_EINIT = (APR_OS_START_STATUS + 22); +{ @see APR_STATUS_IS_ENOTIMPL } + APR_ENOTIMPL = (APR_OS_START_STATUS + 23); +{ @see APR_STATUS_IS_EMISMATCH } + APR_EMISMATCH = (APR_OS_START_STATUS + 24); +{ @see APR_STATUS_IS_EBUSY } + APR_EBUSY = (APR_OS_START_STATUS + 25); + +{ + * @addtogroup APR_STATUS_IS + } +{ + * Program is currently executing in the child + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code } +//#define APR_STATUS_IS_INCHILD(s) ((s) == APR_INCHILD) +{ + * Program is currently executing in the parent + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_INPARENT(s) ((s) == APR_INPARENT) +{ + * The thread is detached + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_DETACH(s) ((s) == APR_DETACH) +{ + * The thread is not detached + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_NOTDETACH(s) ((s) == APR_NOTDETACH) +{ + * The child has finished executing + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_CHILD_DONE(s) ((s) == APR_CHILD_DONE) +{ + * The child has not finished executing + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_CHILD_NOTDONE(s) ((s) == APR_CHILD_NOTDONE) +{ + * The operation did not finish before the timeout + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP) +{ + * The operation was incomplete although some processing was performed + * and the results are partially valid. + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_INCOMPLETE(s) ((s) == APR_INCOMPLETE) +{ empty slot: +9 } +{ empty slot: +10 } +{ empty slot: +11 } +{ + * Getopt found an option not in the option string + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_BADCH(s) ((s) == APR_BADCH) +{ + * Getopt found an option not in the option string and an argument was + * specified in the option string + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_BADARG(s) ((s) == APR_BADARG) +{ + * APR has encountered the end of the file + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EOF(s) ((s) == APR_EOF) +{ + * APR was unable to find the socket in the poll structure + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_NOTFOUND(s) ((s) == APR_NOTFOUND) +{ empty slot: +16 } +{ empty slot: +17 } +{ empty slot: +18 } +{ + * APR is using anonymous shared memory + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ANONYMOUS(s) ((s) == APR_ANONYMOUS) +{ + * APR is using a file name as the key to the shared memory + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_FILEBASED(s) ((s) == APR_FILEBASED) +{ + * APR is using a shared key as the key to the shared memory + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_KEYBASED(s) ((s) == APR_KEYBASED) +{ + * Ininitalizer value. If no option has been found, but + * the status variable requires a value, this should be used + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EINIT(s) ((s) == APR_EINIT) +{ + * The APR function has not been implemented on this + * platform, either because nobody has gotten to it yet, + * or the function is impossible on this platform. + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_ENOTIMPL(s) ((s) == APR_ENOTIMPL) +{ + * Two passwords do not match. + * @warning + * always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EMISMATCH(s) ((s) == APR_EMISMATCH) +{ + * The given lock was busy + * @warning always use this test, as platform-specific variances may meet this + * more than one error code + } +//#define APR_STATUS_IS_EBUSY(s) ((s) == APR_EBUSY) + +{ + * @addtogroup APR_Error APR Error Values + } +{ APR CANONICAL ERROR VALUES } +{ @see APR_STATUS_IS_EACCES } +{#ifdef EACCES +#define APR_EACCES EACCES +#else +#define APR_EACCES (APR_OS_START_CANONERR + 1) +#endif +} +{ @see APR_STATUS_IS_EXIST } +{#ifdef EEXIST +#define APR_EEXIST EEXIST +#else +#define APR_EEXIST (APR_OS_START_CANONERR + 2) +#endif +} +{ @see APR_STATUS_IS_ENAMETOOLONG } +{#ifdef ENAMETOOLONG +#define APR_ENAMETOOLONG ENAMETOOLONG +#else +#define APR_ENAMETOOLONG (APR_OS_START_CANONERR + 3) +#endif +} +{ @see APR_STATUS_IS_ENOENT } +{#ifdef ENOENT +#define APR_ENOENT ENOENT +#else +#define APR_ENOENT (APR_OS_START_CANONERR + 4) +#endif +} +{ @see APR_STATUS_IS_ENOTDIR } +{#ifdef ENOTDIR +#define APR_ENOTDIR ENOTDIR +#else +#define APR_ENOTDIR (APR_OS_START_CANONERR + 5) +#endif +} +{ @see APR_STATUS_IS_ENOSPC } +{#ifdef ENOSPC +#define APR_ENOSPC ENOSPC +#else +#define APR_ENOSPC (APR_OS_START_CANONERR + 6) +#endif +} +{ @see APR_STATUS_IS_ENOMEM } +{#ifdef ENOMEM +#define APR_ENOMEM ENOMEM +#else +#define APR_ENOMEM (APR_OS_START_CANONERR + 7) +#endif +} +{ @see APR_STATUS_IS_EMFILE } +{#ifdef EMFILE +#define APR_EMFILE EMFILE +#else +#define APR_EMFILE (APR_OS_START_CANONERR + 8) +#endif +} +{ @see APR_STATUS_IS_ENFILE } +{#ifdef ENFILE +#define APR_ENFILE ENFILE +#else +#define APR_ENFILE (APR_OS_START_CANONERR + 9) +#endif +} +{ @see APR_STATUS_IS_EBADF } +{#ifdef EBADF +#define APR_EBADF EBADF +#else +#define APR_EBADF (APR_OS_START_CANONERR + 10) +#endif +} +{ @see APR_STATUS_IS_EINVAL } +{#ifdef EINVAL +#define APR_EINVAL EINVAL +#else +#define APR_EINVAL (APR_OS_START_CANONERR + 11) +#endif +} +{ @see APR_STATUS_IS_ESPIPE } +{#ifdef ESPIPE +#define APR_ESPIPE ESPIPE +#else +#define APR_ESPIPE (APR_OS_START_CANONERR + 12) +#endif +} +{ + * @see APR_STATUS_IS_EAGAIN + * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value + } +{#ifdef EAGAIN +#define APR_EAGAIN EAGAIN +#elif defined(EWOULDBLOCK) +#define APR_EAGAIN EWOULDBLOCK +#else +#define APR_EAGAIN (APR_OS_START_CANONERR + 13) +#endif +} +{ @see APR_STATUS_IS_EINTR } +{#ifdef EINTR +#define APR_EINTR EINTR +#else +#define APR_EINTR (APR_OS_START_CANONERR + 14) +#endif +} +{ @see APR_STATUS_IS_ENOTSOCK } +{#ifdef ENOTSOCK +#define APR_ENOTSOCK ENOTSOCK +#else +#define APR_ENOTSOCK (APR_OS_START_CANONERR + 15) +#endif +} +{ @see APR_STATUS_IS_ECONNREFUSED } +{#ifdef ECONNREFUSED +#define APR_ECONNREFUSED ECONNREFUSED +#else +#define APR_ECONNREFUSED (APR_OS_START_CANONERR + 16) +#endif +} +{ @see APR_STATUS_IS_EINPROGRESS } +{#ifdef EINPROGRESS +#define APR_EINPROGRESS EINPROGRESS +#else +#define APR_EINPROGRESS (APR_OS_START_CANONERR + 17) +#endif +} +{ + * @see APR_STATUS_IS_ECONNABORTED + * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value + } + +{#ifdef ECONNABORTED +#define APR_ECONNABORTED ECONNABORTED +#else +#define APR_ECONNABORTED (APR_OS_START_CANONERR + 18) +#endif +} +{ @see APR_STATUS_IS_ECONNRESET } +{#ifdef ECONNRESET +#define APR_ECONNRESET ECONNRESET +#else +#define APR_ECONNRESET (APR_OS_START_CANONERR + 19) +#endif +} +{ @see APR_STATUS_IS_ETIMEDOUT } +{#ifdef ETIMEDOUT +#define APR_ETIMEDOUT ETIMEDOUT +#else +#define APR_ETIMEDOUT (APR_OS_START_CANONERR + 20) +#endif +} +{ @see APR_STATUS_IS_EHOSTUNREACH } +{#ifdef EHOSTUNREACH +#define APR_EHOSTUNREACH EHOSTUNREACH +#else +#define APR_EHOSTUNREACH (APR_OS_START_CANONERR + 21) +#endif +} +{ @see APR_STATUS_IS_ENETUNREACH } +{#ifdef ENETUNREACH +#define APR_ENETUNREACH ENETUNREACH +#else +#define APR_ENETUNREACH (APR_OS_START_CANONERR + 22) +#endif +} +{ @see APR_STATUS_IS_EFTYPE } +{#ifdef EFTYPE +#define APR_EFTYPE EFTYPE +#else +#define APR_EFTYPE (APR_OS_START_CANONERR + 23) +#endif +} +{ @see APR_STATUS_IS_EPIPE } +{#ifdef EPIPE +#define APR_EPIPE EPIPE +#else +#define APR_EPIPE (APR_OS_START_CANONERR + 24) +#endif +} +{ @see APR_STATUS_IS_EXDEV } +{#ifdef EXDEV +#define APR_EXDEV EXDEV +#else +#define APR_EXDEV (APR_OS_START_CANONERR + 25) +#endif +} +{ @see APR_STATUS_IS_ENOTEMPTY } +{#ifdef ENOTEMPTY +#define APR_ENOTEMPTY ENOTEMPTY +#else +#define APR_ENOTEMPTY (APR_OS_START_CANONERR + 26) +#endif + +#if defined(OS2) && !defined(DOXYGEN) + +#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) +#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) + +#define INCL_DOSERRORS +#define INCL_DOS +} +{ Leave these undefined. + * OS2 doesn't rely on the errno concept. + * The API calls always return a result codes which + * should be filtered through APR_FROM_OS_ERROR(). + * + * #define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) + * #define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e))) + } + +{ A special case, only socket calls require this; + } +{#define apr_get_netos_error() (APR_FROM_OS_ERROR(errno)) +#define apr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e)) +} +{ And this needs to be greped away for good: + } +{#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e)) + +#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS \ + || (s) == APR_OS_START_SYSERR + NO_ERROR) +} +{ These can't sit in a private header, so in spite of the extra size, + * they need to be made available here. + } + SOCBASEERR = 10000; + SOCEPERM = (SOCBASEERR+1); { Not owner } + SOCESRCH = (SOCBASEERR+3); { No such process } + SOCEINTR = (SOCBASEERR+4); { Interrupted system call } + SOCENXIO = (SOCBASEERR+6); { No such device or address } + SOCEBADF = (SOCBASEERR+9); { Bad file number } + SOCEACCES = (SOCBASEERR+13); { Permission denied } + SOCEFAULT = (SOCBASEERR+14); { Bad address } + SOCEINVAL = (SOCBASEERR+22); { Invalid argument } + SOCEMFILE = (SOCBASEERR+24); { Too many open files } + SOCEPIPE = (SOCBASEERR+32); { Broken pipe } + SOCEOS2ERR = (SOCBASEERR+100); { OS/2 Error } + SOCEWOULDBLOCK = (SOCBASEERR+35); { Operation would block } + SOCEINPROGRESS = (SOCBASEERR+36); { Operation now in progress } + SOCEALREADY = (SOCBASEERR+37); { Operation already in progress } + SOCENOTSOCK = (SOCBASEERR+38); { Socket operation on non-socket } + SOCEDESTADDRREQ = (SOCBASEERR+39); { Destination address required } + SOCEMSGSIZE = (SOCBASEERR+40); { Message too long } + SOCEPROTOTYPE = (SOCBASEERR+41); { Protocol wrong type for socket } + SOCENOPROTOOPT = (SOCBASEERR+42); { Protocol not available } + SOCEPROTONOSUPPORT = (SOCBASEERR+43); { Protocol not supported } + SOCESOCKTNOSUPPORT = (SOCBASEERR+44); { Socket type not supported } + SOCEOPNOTSUPP = (SOCBASEERR+45); { Operation not supported on socket } + SOCEPFNOSUPPORT = (SOCBASEERR+46); { Protocol family not supported } + SOCEAFNOSUPPORT = (SOCBASEERR+47); { Address family not supported by protocol family } + SOCEADDRINUSE = (SOCBASEERR+48); { Address already in use } + SOCEADDRNOTAVAIL = (SOCBASEERR+49); { Can't assign requested address } + SOCENETDOWN = (SOCBASEERR+50); { Network is down } + SOCENETUNREACH = (SOCBASEERR+51); { Network is unreachable } + SOCENETRESET = (SOCBASEERR+52); { Network dropped connection on reset } + SOCECONNABORTED = (SOCBASEERR+53); { Software caused connection abort } + SOCECONNRESET = (SOCBASEERR+54); { Connection reset by peer } + SOCENOBUFS = (SOCBASEERR+55); { No buffer space available } + SOCEISCONN = (SOCBASEERR+56); { Socket is already connected } + SOCENOTCONN = (SOCBASEERR+57); { Socket is not connected } + SOCESHUTDOWN = (SOCBASEERR+58); { Can't send after socket shutdown } + SOCETOOMANYREFS = (SOCBASEERR+59); { Too many references: can't splice } + SOCETIMEDOUT = (SOCBASEERR+60); { Connection timed out } + SOCECONNREFUSED = (SOCBASEERR+61); { Connection refused } + SOCELOOP = (SOCBASEERR+62); { Too many levels of symbolic links } + SOCENAMETOOLONG = (SOCBASEERR+63); { File name too long } + SOCEHOSTDOWN = (SOCBASEERR+64); { Host is down } + SOCEHOSTUNREACH = (SOCBASEERR+65); { No route to host } + SOCENOTEMPTY = (SOCBASEERR+66); { Directory not empty } + +{ APR CANONICAL ERROR TESTS } +{#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \ + || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION) +#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \ + || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \ + || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED) +#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \ + || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \ + || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG) +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \ + || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED) +#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) +#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \ + || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL) +#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) +#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \ + || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES) +#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE) +#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION) +#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \ + || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION) +#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ + || (s) == APR_OS_START_SYSERR + SOCEINTR) +#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ + || (s) == APR_OS_START_SYSERR + SOCENOTSOCK) +#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ + || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED) +#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ + || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS) +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == APR_OS_START_SYSERR + SOCECONNABORTED) +#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ + || (s) == APR_OS_START_SYSERR + SOCECONNRESET) +#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT) +#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ + || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH) +#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ + || (s) == APR_OS_START_SYSERR + SOCENETUNREACH) +#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) +#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \ + || (s) == APR_OS_START_SYSERR + SOCEPIPE) +#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE) +#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \ + || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED) +} +{ + Sorry, too tired to wrap this up for OS2... feel free to + fit the following into their best matches. + + ( ERROR_NO_SIGNAL_SENT, ESRCH ), + ( SOCEALREADY, EALREADY ), + ( SOCEDESTADDRREQ, EDESTADDRREQ ), + ( SOCEMSGSIZE, EMSGSIZE ), + ( SOCEPROTOTYPE, EPROTOTYPE ), + ( SOCENOPROTOOPT, ENOPROTOOPT ), + ( SOCEPROTONOSUPPORT, EPROTONOSUPPORT ), + ( SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT ), + ( SOCEOPNOTSUPP, EOPNOTSUPP ), + ( SOCEPFNOSUPPORT, EPFNOSUPPORT ), + ( SOCEAFNOSUPPORT, EAFNOSUPPORT ), + ( SOCEADDRINUSE, EADDRINUSE ), + ( SOCEADDRNOTAVAIL, EADDRNOTAVAIL ), + ( SOCENETDOWN, ENETDOWN ), + ( SOCENETRESET, ENETRESET ), + ( SOCENOBUFS, ENOBUFS ), + ( SOCEISCONN, EISCONN ), + ( SOCENOTCONN, ENOTCONN ), + ( SOCESHUTDOWN, ESHUTDOWN ), + ( SOCETOOMANYREFS, ETOOMANYREFS ), + ( SOCELOOP, ELOOP ), + ( SOCEHOSTDOWN, EHOSTDOWN ), + ( SOCENOTEMPTY, ENOTEMPTY ), + ( SOCEPIPE, EPIPE ) +} + +//#elif defined(WIN32) && !defined(DOXYGEN) { !defined(OS2) } + +{#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) +#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) + +#define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError())) +#define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))} + +{ A special case, only socket calls require this: + } +{#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) +#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) + +#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS \ + || (s) == APR_OS_START_SYSERR + ERROR_SUCCESS) +} +{ APR CANONICAL ERROR TESTS } +{#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \ + || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \ + || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \ + || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \ + || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \ + || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \ + || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \ + || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION) +#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \ + || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS) +#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \ + || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \ + || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG) +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES) +#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR \ + || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE) +#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \ + || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL) +#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM \ + || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \ + || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY) +#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \ + || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES) +#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE) +#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \ + || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) +#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \ + || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \ + || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \ + || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \ + || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \ + || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \ + || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK) +#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ + || (s) == APR_OS_START_SYSERR + WSAEINTR) +#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ + || (s) == APR_OS_START_SYSERR + WSAENOTSOCK) +#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ + || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED) +#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ + || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS) +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == APR_OS_START_SYSERR + WSAECONNABORTED) +#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ + || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \ + || (s) == APR_OS_START_SYSERR + WSAECONNRESET) +#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) +#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH) +#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAENETUNREACH) +#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE \ + || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \ + || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \ + || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \ + || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT) +#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \ + || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE) +#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \ + || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE) +#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \ + || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY) +} +//#elif defined(NETWARE) && !defined(DOXYGEN) { !defined(OS2) && !defined(WIN32) } +{ +#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) +#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) + +#define apr_get_os_error() (errno) +#define apr_set_os_error(e) (errno = (e)) +} +{ A special case, only socket calls require this: } +{#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError())) +#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e))) + +#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS) +} +{ APR CANONICAL ERROR TESTS } +{#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES) +#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST) +#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG) +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT) +#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) +#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC) +#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) +#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE) +#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF) +#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL) +#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE) + +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == EWOULDBLOCK \ + || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK) +#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \ + || (s) == APR_OS_START_SYSERR + WSAEINTR) +#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \ + || (s) == APR_OS_START_SYSERR + WSAENOTSOCK) +#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \ + || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED) +#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \ + || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS) +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == APR_OS_START_SYSERR + WSAECONNABORTED) +#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \ + || (s) == APR_OS_START_SYSERR + WSAECONNRESET) +#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \ + || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT) +#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH) +#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \ + || (s) == APR_OS_START_SYSERR + WSAENETUNREACH) +#define APR_STATUS_IS_ENETDOWN(s) ((s) == APR_OS_START_SYSERR + WSAENETDOWN) +#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) +#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE) +#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV) +#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY) +} +//#else { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) } + +{ + * os error codes are clib error codes + } +{#define APR_FROM_OS_ERROR(e) (e) +#define APR_TO_OS_ERROR(e) (e) + +#define apr_get_os_error() (errno) +#define apr_set_os_error(e) (errno = (e)) +} +{ A special case, only socket calls require this: + } +//#define apr_get_netos_error() (errno) +//#define apr_set_netos_error(e) (errno = (e)) + +{ + * @addtogroup APR_STATUS_IS + } +{ no error } +//#define APR_STATUS_IS_SUCCESS(s) ((s) == APR_SUCCESS) + +{ permission denied } +//#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES) +{ file exists } +//#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST) +{ path name is too long } +//#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG) +{ + * no such file or directory + * @remark + * EMVSCATLG can be returned by the automounter on z/OS for + * paths which do not exist. + } +{#ifdef EMVSCATLG +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \ + || (s) == EMVSCATLG) +#else +#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT) +#endif} +{ not a directory } +//#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR) +{ no space left on device } +//#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC) +{ not enough memory } +//#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM) +{ too many open files } +//#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE) +{ file table overflow } +//#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE) +{ bad file # } +//#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF) +{ invalid argument } +//#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL) +{ illegal seek } +//#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE) + +{ operation would block } +{#if !defined(EWOULDBLOCK) || !defined(EAGAIN) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN) +#elif (EWOULDBLOCK == EAGAIN) +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN) +#else +#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \ + || (s) == EWOULDBLOCK) +#endif +} +{ interrupted system call } +//#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR) +{ socket operation on a non-socket } +//#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK) +{ Connection Refused } +//#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED) +{ operation now in progress } +//#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS) + +{ + * Software caused connection abort + * @remark + * EPROTO on certain older kernels really means ECONNABORTED, so we need to + * ignore it for them. See discussion in new-httpd archives nh.9701 & nh.9603 + * + * There is potentially a bug in Solaris 2.x x<6, and other boxes that + * implement tcp sockets in userland (i.e. on top of STREAMS). On these + * systems, EPROTO can actually result in a fatal loop. See PR#981 for + * example. It's hard to handle both uses of EPROTO. + } +{#ifdef EPROTO +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \ + || (s) == EPROTO) +#else +#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED) +#endif +} +{ Connection Reset by peer } +//#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET) +{ Operation timed out } +//#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT) +{ no route to host } +//#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH) +{ network is unreachable } +//#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH) +{ inappropiate file type or format } +//#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE) +{ broken pipe } +//#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE) +{ cross device link } +//#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV) +{ Directory Not Empty } +//#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY || \ +// (s) == APR_EEXIST) + +//#endif { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) } + diff --git a/httpd/httpd_2_2/apr/apr_file_info.inc b/httpd/httpd_2_2/apr/apr_file_info.inc new file mode 100644 index 000000000..9436d85c2 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_file_info.inc @@ -0,0 +1,434 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_file_info.h + * @brief APR File Information + } + +{#include "apr.h" +#include "apr_user.h" +#include "apr_pools.h" +#include "apr_tables.h" +#include "apr_time.h" +#include "apr_errno.h" + +#if APR_HAVE_SYS_UIO_H +#include
+ * APR_FILEPATH_NATIVE Use native path seperators (e.g. '\' on Win32) + * APR_FILEPATH_TRUENAME Tests that the root exists, and makes it proper + *+ * @param p the pool to allocate the new path string from + * @remark on return, filepath points to the first non-root character in the + * given filepath. In the simplest example, given a filepath of "/foo", + * returns the rootpath of "/" and filepath points at "foo". This is far + * more complex on other platforms, which will canonicalize the root form + * to a consistant format, given the APR_FILEPATH_TRUENAME flag, and also + * test for the validity of that root (e.g., that a drive d:/ or network + * share //machine/foovol/). + * The function returns APR_ERELATIVE if filepath isn't rooted (an + * error), APR_EINCOMPLETE if the root path is ambigious (but potentially + * legitimate, e.g. "/" on Windows is incomplete because it doesn't specify + * the drive letter), or APR_EBADPATH if the root is simply invalid. + * APR_SUCCESS is returned if filepath is an absolute path. + } +function apr_filepath_root(const rootpath, filepath: PPChar; + flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_root' + LibSuff16; + +{ + * Merge additional file path onto the previously processed rootpath + * @param newpath the merged paths returned + * @param rootpath the root file path (NULL uses the current working path) + * @param addpath the path to add to the root path + * @param flags the desired APR_FILEPATH_ rules to apply when merging + * @param p the pool to allocate the new path string from + * @remark if the flag APR_FILEPATH_TRUENAME is given, and the addpath + * contains wildcard characters ('*', '?') on platforms that don't support + * such characters within filenames, the paths will be merged, but the + * result code will be APR_EPATHWILD, and all further segments will not + * reflect the true filenames including the wildcard and following segments. + } +function apr_filepath_merge(newpath: PPChar; const rootpath, addpath: PPChar; + flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_merge' + LibSuff20; + +{ + * Split a search path into separate components + * @param pathelts the returned components of the search path + * @param liststr the search path (e.g., getenv("PATH")) + * @param p the pool to allocate the array and path components from + * @remark empty path componenta do not become part of @a pathelts. + * @remark the path separator in @a liststr is system specific; + * e.g., ':' on Unix, ';' on Windows, etc. + } +function apr_filepath_list_split(pathelts: PPapr_array_header_t; + const liststr: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_list_split' + LibSuff12; + +{ + * Merge a list of search path components into a single search path + * @param liststr the returned search path; may be NULL if @a pathelts is empty + * @param pathelts the components of the search path + * @param p the pool to allocate the search path from + * @remark emtpy strings in the source array are ignored. + * @remark the path separator in @a liststr is system specific; + * e.g., ':' on Unix, ';' on Windows, etc. + } +function apr_filepath_list_merge(liststr: PPChar; + pathelts: Papr_array_header_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_list_merge' + LibSuff12; + +{ + * Return the default file path (for relative file names) + * @param path the default path string returned + * @param flags optional flag APR_FILEPATH_NATIVE to retrieve the + * default file path in os-native format. + * @param p the pool to allocate the default path string from + } +function apr_filepath_get(path: PPChar; flags: apr_int32_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_get' + LibSuff12; + +{ + * Set the default file path (for relative file names) + * @param path the default path returned + * @param p the pool to allocate any working storage + } +function apr_filepath_set(const path: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_set' + LibSuff8; + +const + { The FilePath character encoding is unknown } + APR_FILEPATH_ENCODING_UNKNOWN = 0; + + { The FilePath character encoding is locale-dependent } + APR_FILEPATH_ENCODING_LOCALE = 1; + + { The FilePath character encoding is UTF-8 } + APR_FILEPATH_ENCODING_UTF8 = 2; + +{ + * Determine the encoding used internally by the FilePath functions + * @param style points to a variable which receives the encoding style flag + * @param p the pool to allocate any working storage + * @remark Use @c apr_os_locale_encoding and/or @c apr_os_default_encoding + * to get the name of the path encoding if it's not UTF-8. + } +function apr_filepath_encoding(style: PInteger; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_encoding' + LibSuff8; + diff --git a/httpd/httpd_2_2/apr/apr_file_io.inc b/httpd/httpd_2_2/apr/apr_file_io.inc new file mode 100644 index 000000000..0d94ae577 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_file_io.inc @@ -0,0 +1,807 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_file_io.h + * @brief APR File I/O Handling + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_time.h" +#include "apr_errno.h"} +{.$include apr_file_info.inc} +{#include "apr_inherit.h"} + +//#define APR_WANT_STDIO {< for SEEK_* } +//#define APR_WANT_IOVEC {< for apr_file_writev } +//#include "apr_want.h" + +{ + * @defgroup apr_file_io File I/O Handling Functions + * @ingroup APR + } + +{ + * @defgroup apr_file_open_flags File Open Flags/Routines + } + +{ Note to implementors: Values in the range 0x00100000--0x80000000 + are reserved for platform-specific values. } + +const + APR_READ = $00001; {< Open the file for reading } + APR_WRITE = $00002; {< Open the file for writing } + APR_CREATE = $00004; {< Create the file if not there } + APR_APPEND = $00008; {< Append to the end of the file } + APR_TRUNCATE = $00010; {< Open the file and truncate to 0 length } + APR_BINARY = $00020; {< Open the file in binary mode } + APR_EXCL = $00040; {< Open should fail if APR_CREATE and file + exists. } + APR_BUFFERED = $00080; {< Open the file for buffered I/O } + APR_DELONCLOSE =$00100; {< Delete the file after close } + APR_XTHREAD = $00200; {< Platform dependent tag to open the file + for use across multiple threads } + APR_SHARELOCK = $00400; {< Platform dependent support for higher + level locked read/write access to support + writes across process/machines } + APR_FILE_NOCLEANUP =$00800; {< Do not register a cleanup when the file + is opened } + APR_SENDFILE_ENABLED =$01000; {< Advisory flag that this file should + support apr_sendfile operation } + APR_LARGEFILE = $04000; {< Platform dependent flag to enable large file + support; WARNING see below. } + +{ @warning The APR_LARGEFILE flag only has effect on some platforms + * where sizeof(apr_off_t) == 4. Where implemented, it allows opening + * and writing to a file which exceeds the size which can be + * represented by apr_off_t (2 gigabytes). When a file's size does + * exceed 2Gb, apr_file_info_get() will fail with an error on the + * descriptor, likewise apr_stat()/apr_lstat() will fail on the + * filename. apr_dir_read() will fail with APR_INCOMPLETE on a + * directory entry for a large file depending on the particular + * APR_FINFO_* flags. Generally, it is not recommended to use this + * flag. } + +{ + * @defgroup apr_file_seek_flags File Seek Flags + } + +{ + * @defgroup apr_file_attrs_set_flags File Attribute Flags + } + +{ flags for apr_file_attrs_set } + APR_FILE_ATTR_READONLY = $01; {< File is read-only } + APR_FILE_ATTR_EXECUTABLE =$02; {< File is executable } + APR_FILE_ATTR_HIDDEN = $04; {< File is hidden } + +{ File attributes } +type + apr_fileattrs_t = apr_uint32_t; + +{ should be same as whence type in lseek, POSIX defines this as int } + apr_seek_where_t = Integer; + +{ + * Structure for referencing files. + } + apr_file_t = record end; +// Papr_file_t = ^apr_file_t; + PPapr_file_t = ^Papr_file_t; + +{ File lock types/flags } +{ + * @defgroup apr_file_lock_types File Lock Types + } + +const + APR_FLOCK_SHARED = 1; {< Shared lock. More than one process + or thread can hold a shared lock + at any given time. Essentially, + this is a "read lock", preventing + writers from establishing an + exclusive lock. } + APR_FLOCK_EXCLUSIVE = 2; {< Exclusive lock. Only one process + may hold an exclusive lock at any + given time. This is analogous to + a "write lock". } + + APR_FLOCK_TYPEMASK = $000F; {< mask to extract lock type } + APR_FLOCK_NONBLOCK = $0010; {< do not block while acquiring the + file lock } +{ + * Open the specified file. + * @param newf The opened file descriptor. + * @param fname The full path to the file (using / on all systems) + * @param flag Or'ed value of: + *
+ * APR_READ open for reading + * APR_WRITE open for writing + * APR_CREATE create the file if not there + * APR_APPEND file ptr is set to end prior to all writes + * APR_TRUNCATE set length to zero if file exists + * APR_BINARY not a text file (This flag is ignored on + * UNIX because it has no meaning) + * APR_BUFFERED buffer the data. Default is non-buffered + * APR_EXCL return error if APR_CREATE and file exists + * APR_DELONCLOSE delete the file after closing. + * APR_XTHREAD Platform dependent tag to open the file + * for use across multiple threads + * APR_SHARELOCK Platform dependent support for higher + * level locked read/write access to support + * writes across process/machines + * APR_FILE_NOCLEANUP Do not register a cleanup with the pool + * passed in on the cont argument (see below). + * The apr_os_file_t handle in apr_file_t will not + * be closed when the pool is destroyed. + * APR_SENDFILE_ENABLED Open with appropriate platform semantics + * for sendfile operations. Advisory only, + * apr_sendfile does not check this flag. + *+ * @param perm Access permissions for file. + * @param pool The pool to use. + * @remark If perm is APR_OS_DEFAULT and the file is being created, appropriate + * default permissions will be used. *arg1 must point to a valid file_t, + * or NULL (in which case it will be allocated) + } +function apr_file_open(newf: PPapr_file_t; const fname: PChar; + flag: apr_int32_t; perm: apr_fileperms_t; + pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open' + LibSuff20; + +{ + * Close the specified file. + * @param file The file descriptor to close. + } +function apr_file_close(file_: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_close' + LibSuff4; + +{ + * delete the specified file. + * @param path The full path to the file (using / on all systems) + * @param cont The pool to use. + * @remark If the file is open, it won't be removed until all instances are closed. + } +function apr_file_remove(const path: PChar; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_remove' + LibSuff8; + +{ + * rename the specified file. + * @param from_path The full path to the original file (using / on all systems) + * @param to_path The full path to the new file (using / on all systems) + * @param pool The pool to use. + * @warning If a file exists at the new location, then it will be overwritten. + * Moving files or directories across devices may not be possible. + } +function apr_file_rename(const from_path, to_path: PChar; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_rename' + LibSuff12; + +{ + * copy the specified file to another file. + * @param from_path The full path to the original file (using / on all systems) + * @param to_path The full path to the new file (using / on all systems) + * @param perms Access permissions for the new file if it is created. + * In place of the usual or'd combination of file permissions, the + * value APR_FILE_SOURCE_PERMS may be given, in which case the source + * file's permissions are copied. + * @param pool The pool to use. + * @remark The new file does not need to exist, it will be created if required. + * @warning If the new file already exists, its contents will be overwritten. + } +function apr_file_copy(const from_path, to_path: PChar; + perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_copy' + LibSuff16; + +{ + * append the specified file to another file. + * @param from_path The full path to the source file (using / on all systems) + * @param to_path The full path to the destination file (using / on all systems) + * @param perms Access permissions for the destination file if it is created. + * In place of the usual or'd combination of file permissions, the + * value APR_FILE_SOURCE_PERMS may be given, in which case the source + * file's permissions are copied. + * @param pool The pool to use. + * @remark The new file does not need to exist, it will be created if required. + } +function apr_file_append(const from_path, to_path: PChar; + perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_append' + LibSuff16; + +{ + * Are we at the end of the file + * @param fptr The apr file we are testing. + * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise. + } +function apr_file_eof(fptr: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_eof' + LibSuff4; + +{ + * open standard error as an apr file pointer. + * @param thefile The apr file to use as stderr. + * @param cont The pool to allocate the file out of. + * + * @remark The only reason that the apr_file_open_std* functions exist + * is that you may not always have a stderr/out/in on Windows. This + * is generally a problem with newer versions of Windows and services. + * + * The other problem is that the C library functions generally work + * differently on Windows and Unix. So, by using apr_file_open_std* + * functions, you can get a handle to an APR struct that works with + * the APR functions which are supposed to work identically on all + * platforms. + } +function apr_file_open_stderr(thefile: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open_stderr' + LibSuff8; + +{ + * open standard output as an apr file pointer. + * @param thefile The apr file to use as stdout. + * @param cont The pool to allocate the file out of. + * + * @remark The only reason that the apr_file_open_std* functions exist + * is that you may not always have a stderr/out/in on Windows. This + * is generally a problem with newer versions of Windows and services. + * + * The other problem is that the C library functions generally work + * differently on Windows and Unix. So, by using apr_file_open_std* + * functions, you can get a handle to an APR struct that works with + * the APR functions which are supposed to work identically on all + * platforms. + } +function apr_file_open_stdout(thefile: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open_stdout' + LibSuff8; + +{ + * open standard input as an apr file pointer. + * @param thefile The apr file to use as stdin. + * @param cont The pool to allocate the file out of. + * + * @remark The only reason that the apr_file_open_std* functions exist + * is that you may not always have a stderr/out/in on Windows. This + * is generally a problem with newer versions of Windows and services. + * + * The other problem is that the C library functions generally work + * differently on Windows and Unix. So, by using apr_file_open_std* + * functions, you can get a handle to an APR struct that works with + * the APR functions which are supposed to work identically on all + * platforms. + } +function apr_file_open_stdin(thefile: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_open_stdin' + LibSuff8; + +{ + * Read data from the specified file. + * @param thefile The file descriptor to read from. + * @param buf The buffer to store the data to. + * @param nbytes On entry, the number of bytes to read; on exit, the number of bytes read. + * @remark apr_file_read will read up to the specified number of bytes, but + * never more. If there isn't enough data to fill that number of + * bytes, all of the available data is read. The third argument is + * modified to reflect the number of bytes read. If a char was put + * back into the stream via ungetc, it will be the first character + * returned. + * + * It is not possible for both bytes to be read and an APR_EOF or other + * error to be returned. + * + * APR_EINTR is never returned. + } +function apr_file_read(thefile: Papr_file_t; buf: Pointer; + nbytes: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_read' + LibSuff12; + +{ + * Write data to the specified file. + * @param thefile The file descriptor to write to. + * @param buf The buffer which contains the data. + * @param nbytes On entry, the number of bytes to write; on exit, the number + * of bytes written. + * @remark apr_file_write will write up to the specified number of bytes, but never + * more. If the OS cannot write that many bytes, it will write as many + * as it can. The third argument is modified to reflect the * number + * of bytes written. + * + * It is possible for both bytes to be written and an error to be returned. + * + * APR_EINTR is never returned. + } +function apr_file_write(thefile: Papr_file_t; buf: Pointer; + nbytes: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_write' + LibSuff12; + +{ + * Write data from iovec array to the specified file. + * @param thefile The file descriptor to write to. + * @param vec The array from which to get the data to write to the file. + * @param nvec The number of elements in the struct iovec array. This must + * be smaller than APR_MAX_IOVEC_SIZE. If it isn't, the function + * will fail with APR_EINVAL. + * @param nbytes The number of bytes written. + * @remark It is possible for both bytes to be written and an error to be returned. + * APR_EINTR is never returned. + * + * apr_file_writev is available even if the underlying operating system + * + * doesn't provide writev(). + } +function apr_file_writev(thefile: Papr_file_t; const vec: Piovec; + nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_writev' + LibSuff16; + +{ + * Read data from the specified file, ensuring that the buffer is filled + * before returning. + * @param thefile The file descriptor to read from. + * @param buf The buffer to store the data to. + * @param nbytes The number of bytes to read. + * @param bytes_read If non-NULL, this will contain the number of bytes read. + * @remark apr_file_read will read up to the specified number of bytes, but never + * more. If there isn't enough data to fill that number of bytes, + * then the process/thread will block until it is available or EOF + * is reached. If a char was put back into the stream via ungetc, + * it will be the first character returned. + * + * It is possible for both bytes to be read and an error to be + * returned. And if *bytes_read is less than nbytes, an + * accompanying error is _always_ returned. + * + * APR_EINTR is never returned. + } +function apr_file_read_full(thefile: Papr_file_t; buf: Pointer; + nbytes: apr_size_t; bytes_read: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_read_full' + LibSuff16; + +{ + * Write data to the specified file, ensuring that all of the data is + * written before returning. + * @param thefile The file descriptor to write to. + * @param buf The buffer which contains the data. + * @param nbytes The number of bytes to write. + * @param bytes_written If non-NULL, this will contain the number of bytes written. + * @remark apr_file_write will write up to the specified number of bytes, but never + * more. If the OS cannot write that many bytes, the process/thread + * will block until they can be written. Exceptional error such as + * "out of space" or "pipe closed" will terminate with an error. + * + * It is possible for both bytes to be written and an error to be + * returned. And if *bytes_written is less than nbytes, an + * accompanying error is _always_ returned. + * + * APR_EINTR is never returned. + } +function apr_file_write_full(thefile: Papr_file_t; buf: Pointer; + nbytes: apr_size_t; bytes_written: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_write_full' + LibSuff16; + +{ + * put a character into the specified file. + * @param ch The character to write. + * @param thefile The file descriptor to write to + } +function apr_file_putc(ch: Char; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_putc' + LibSuff8; + +{ + * get a character from the specified file. + * @param ch The character to read into + * @param thefile The file descriptor to read from + } +function apr_file_getc(ch: PChar; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_getc' + LibSuff8; + +{ + * put a character back onto a specified stream. + * @param ch The character to write. + * @param thefile The file descriptor to write to + } +function apr_file_ungetc(ch: Char; thefile: PPapr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_ungetc' + LibSuff8; + +{ + * Get a string from a specified file. + * @param str The buffer to store the string in. + * @param len The length of the string + * @param thefile The file descriptor to read from + * @remark The buffer will be '\0'-terminated if any characters are stored. + } +function apr_file_gets(str: PChar; len: Integer; + thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_gets' + LibSuff12; + +{ + * Put the string into a specified file. + * @param str The string to write. + * @param thefile The file descriptor to write to + } +function apr_file_puts(const str: PChar; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_puts' + LibSuff8; + +{ + * Flush the file's buffer. + * @param thefile The file descriptor to flush + } +function apr_file_flush(thefile: PPapr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_flush' + LibSuff4; + +{ + * duplicate the specified file descriptor. + * @param new_file The structure to duplicate into. + * @param old_file The file to duplicate. + * @param p The pool to use for the new file. + * @remark *new_file must point to a valid apr_file_t, or point to NULL + } +function apr_file_dup(new_file: PPapr_file_t; old_file: PPapr_file_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_dup' + LibSuff12; + +{ + * duplicate the specified file descriptor and close the original + * @param new_file The old file that is to be closed and reused + * @param old_file The file to duplicate + * @param p The pool to use for the new file + * + * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL + } +function apr_file_dup2(new_file: PPapr_file_t; old_file: PPapr_file_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_dup2' + LibSuff12; + +{ + * move the specified file descriptor to a new pool + * @param new_file Pointer in which to return the new apr_file_t + * @param old_file The file to move + * @param p The pool to which the descriptor is to be moved + * @remark Unlike apr_file_dup2(), this function doesn't do an + * OS dup() operation on the underlying descriptor; it just + * moves the descriptor's apr_file_t wrapper to a new pool. + * @remark The new pool need not be an ancestor of old_file's pool. + * @remark After calling this function, old_file may not be used + } +function apr_file_setaside(new_file: PPapr_file_t; old_file: PPapr_file_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_setaside' + LibSuff12; + +{ + * Move the read/write file offset to a specified byte within a file. + * @param thefile The file descriptor + * @param where How to move the pointer, one of: + *
+ * APR_SET -- set the offset to offset + * APR_CUR -- add the offset to the current position + * APR_END -- add the offset to the current file size + *+ * @param offset The offset to move the pointer to. + * @remark The third argument is modified to be the offset the pointer + was actually moved to. + } +function apr_file_seek(thefile: Papr_file_t; + where: apr_seek_where_t; offset: Papr_off_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_seek' + LibSuff12; + +{ + * Create an anonymous pipe. + * @param in The file descriptor to use as input to the pipe. + * @param out The file descriptor to use as output from the pipe. + * @param cont The pool to operate on. + } +function apr_file_pipe_create(in_: PPapr_file_t; out_: PPapr_file_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_pipe_create' + LibSuff12; + +{ + * Create a named pipe. + * @param filename The filename of the named pipe + * @param perm The permissions for the newly created pipe. + * @param cont The pool to operate on. + } +function apr_file_namedpipe_create(const filename: PChar; + perm: apr_fileperms_t; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_namedpipe_create' + LibSuff12; + +{ + * Get the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are getting a timeout for. + * @param timeout The current timeout value in microseconds. + } +function apr_file_pipe_timeout_get(thepipe: Papr_file_t; + timeout: Papr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_get' + LibSuff8; + +{ + * Set the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are setting a timeout on. + * @param timeout The timeout value in microseconds. Values < 0 mean wait + * forever, 0 means do not wait at all. + } +function apr_file_pipe_timeout_set(thepipe: Papr_file_t; + timeout: apr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_set' + LibSuff12; + +{ file (un)locking functions. } + +{ + * Establish a lock on the specified, open file. The lock may be advisory + * or mandatory, at the discretion of the platform. The lock applies to + * the file as a whole, rather than a specific range. Locks are established + * on a per-thread/process basis; a second lock by the same thread will not + * block. + * @param thefile The file to lock. + * @param type The type of lock to establish on the file. + } +function apr_file_lock(thefile: Papr_file_t; type_: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_lock' + LibSuff8; + +{ + * Remove any outstanding locks on the file. + * @param thefile The file to unlock. + } +function apr_file_unlock(thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_unlock' + LibSuff4; + +{accessor and general file_io functions. } + +{ + * return the file name of the current file. + * @param new_path The path of the file. + * @param thefile The currently open file. + } +function apr_file_name_get(const newpath: PPChar; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_name_get' + LibSuff8; + +{ + * Return the data associated with the current file. + * @param data The user data associated with the file. + * @param key The key to use for retreiving data associated with this file. + * @param file The currently open file. + } +function apr_file_data_get(data: PPointer; const key: PChar; + file_: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_data_get' + LibSuff12; + +{ + * Set the data associated with the current file. + * @param file The currently open file. + * @param data The user data to associate with the file. + * @param key The key to use for assocaiteing data with the file. + * @param cleanup The cleanup routine to use when the file is destroyed. + } +//function apr_file_data_set(ch: Char; thefile: PPapr_file_t): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_file_data_set' + LibSuff4; +//APR_DECLARE(apr_status_t) (apr_file_t *file, void *data, +// const char *key, +// apr_status_t (*cleanup)(void *)); + +{ + * Write a string to a file using a printf format. + * @param fptr The file to write to. + * @param format The format string + * @param ... The values to substitute in the format string + * @return The number of bytes written + } +function apr_file_printf(fptr: Papr_file_t; const format: PChar; + othres: array of const): Integer; + cdecl; external LibAPR name 'apr_file_printf'; + +{ + * set the specified file's permission bits. + * @param fname The file (name) to apply the permissions to. + * @param perms The permission bits to apply to the file. + * @warning Some platforms may not be able to apply all of the available + * permission bits; APR_INCOMPLETE will be returned if some permissions + * are specified which could not be set. + * + * Platforms which do not implement this feature will return APR_ENOTIMPL. + } +function apr_file_perms_set(const fname: PChar; + perms: apr_fileperms_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_perms_set' + LibSuff8; + +{ + * Set attributes of the specified file. + * @param fname The full path to the file (using / on all systems) + * @param attributes Or'd combination of + *
+ * APR_FILE_ATTR_READONLY - make the file readonly + * APR_FILE_ATTR_EXECUTABLE - make the file executable + * APR_FILE_ATTR_HIDDEN - make the file hidden + *+ * @param attr_mask Mask of valid bits in attributes. + * @param cont the pool to use. + * @remark This function should be used in preference to explict manipulation + * of the file permissions, because the operations to provide these + * attributes are platform specific and may involve more than simply + * setting permission bits. + * @warning Platforms which do not implement this feature will return + * APR_ENOTIMPL. + } +function apr_file_attrs_set(const fname: PChar; + attributes, attr_mask: apr_fileattrs_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_attrs_set' + LibSuff16; + +{ + * Set the mtime of the specified file. + * @param fname The full path to the file (using / on all systems) + * @param mtime The mtime to apply to the file. + * @param pool The pool to use. + * @warning Platforms which do not implement this feature will return + * APR_ENOTIMPL. + } +function apr_file_mtime_set(const fname: PChar; + mtime: apr_time_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_mtime_set' + LibSuff16; + +{ + * Create a new directory on the file system. + * @param path the path for the directory to be created. (use / on all systems) + * @param perm Permissions for the new direcoty. + * @param cont the pool to use. + } +function apr_dir_make(const path: PChar; perm: apr_fileperms_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dir_make' + LibSuff12; + +{ Creates a new directory on the file system, but behaves like + * 'mkdir -p'. Creates intermediate directories as required. No error + * will be reported if PATH already exists. + * @param path the path for the directory to be created. (use / on all systems) + * @param perm Permissions for the new direcoty. + * @param pool the pool to use. + } +function apr_dir_make_recursive(const path: PChar; + perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dir_make_recursive' + LibSuff12; + +{ + * Remove directory from the file system. + * @param path the path for the directory to be removed. (use / on all systems) + * @param cont the pool to use. + } +function apr_dir_remove(const path: PChar; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_dir_remove' + LibSuff8; + +{ + * get the specified file's stats. + * @param finfo Where to store the information about the file. + * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values + * @param thefile The file to get information about. + } +function apr_file_info_get(finfo: Papr_finfo_t; + wanted: apr_int32_t; thefile: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_info_get' + LibSuff12; + +{ + * Truncate the file's length to the specified offset + * @param fp The file to truncate + * @param offset The offset to truncate to. + } +function apr_file_trunc(fp: Papr_file_t; offset: apr_off_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_trunc' + LibSuff12; + +{ + * Retrieve the flags that were passed into apr_file_open() + * when the file was opened. + * @return apr_int32_t the flags + } +function apr_file_flags_get(f: Papr_file_t): apr_int32_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_flags_get' + LibSuff4; + +{ + * Get the pool used by the file. + } +{APR_POOL_DECLARE_ACCESSOR(file); +} +{ + * Set a file to be inherited by child processes. + * + } +{APR_DECLARE_INHERIT_SET(file); +} +{ @deprecated @see apr_file_inherit_set } +{APR_DECLARE(void) apr_file_set_inherit(apr_file_t *file); +} +{ + * Unset a file from being inherited by child processes. + } +{APR_DECLARE_INHERIT_UNSET(file); +} +{ @deprecated @see apr_file_inherit_unset } +{APR_DECLARE(void) apr_file_unset_inherit(apr_file_t *file); +} +{ + * Open a temporary file + * @param fp The apr file to use as a temporary file. + * @param templ The template to use when creating a temp file. + * @param flags The flags to open the file with. If this is zero, + * the file is opened with + * APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE + * @param p The pool to allocate the file out of. + * @remark + * This function generates a unique temporary file name from template. + * The last six characters of template must be XXXXXX and these are replaced + * with a string that makes the filename unique. Since it will be modified, + * template must not be a string constant, but should be declared as a character + * array. + * + } +function apr_file_mktemp(fp: PPapr_file_t; templ: PChar; + flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_file_mktemp' + LibSuff16; + +{ + * Find an existing directory suitable as a temporary storage location. + * @param temp_dir The temp directory. + * @param p The pool to use for any necessary allocations. + * @remark + * This function uses an algorithm to search for a directory that an + * an application can use for temporary storage. Once such a + * directory is found, that location is cached by the library. Thus, + * callers only pay the cost of this algorithm once if that one time + * is successful. + * + } +function apr_temp_dir_get(const temp_dir: PPChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_temp_dir_get' + LibSuff8; + diff --git a/httpd/httpd_2_2/apr/apr_general.inc b/httpd/httpd_2_2/apr/apr_general.inc new file mode 100644 index 000000000..b9e8eff56 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_general.inc @@ -0,0 +1,228 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_general.h + * This is collection of oddballs that didn't fit anywhere else, + * and might move to more appropriate headers with the release + * of APR 1.0. + * @brief APR Miscellaneous library routines + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#if APR_HAVE_SIGNAL_H +#include
+ * + * int sum_values(apr_pool_t *p, apr_hash_t *ht) + * ( + * apr_hash_index_t *hi; + * void *val; + * int sum = 0; + * for (hi = apr_hash_first(p, ht); hi; hi = apr_hash_next(hi)) ( + * apr_hash_this(hi, NULL, NULL, &val); + * sum += *(int * )val; + * ) + * return sum; + * ) + *+ } +function apr_hash_first(p: Papr_pool_t; ht: Papr_hash_t): Papr_hash_index_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_first' + LibSuff8; + +{ + * Continue iterating over the entries in a hash table. + * @param hi The iteration state + * @return a pointer to the updated iteration state. NULL if there are no more + * entries. + } +function apr_hash_next(hi: Papr_hash_index_t): Papr_hash_index_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_next' + LibSuff4; + +{ + * Get the current entry's details from the iteration state. + * @param hi The iteration state + * @param key Return pointer for the pointer to the key. + * @param klen Return pointer for the key length. + * @param val Return pointer for the associated value. + * @remark The return pointers should point to a variable that will be set to the + * corresponding data, or they may be NULL if the data isn't interesting. + } +procedure apr_hash_this(hi: Papr_hash_index_t; const key: PPointer; + klen: Papr_size_t; val: PPointer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_this' + LibSuff16; + +{ + * Get the number of key/value pairs in the hash table. + * @param ht The hash table + * @return The number of key/value pairs in the hash table. + } +function apr_hash_count(ht: Papr_hash_t): cuint; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_count' + LibSuff4; + +{ + * Merge two hash tables into one new hash table. The values of the overlay + * hash override the values of the base if both have the same key. + * @param p The pool to use for the new hash table + * @param overlay The table to add to the initial table + * @param base The table that represents the initial values of the new table + * @return A new hash table containing all of the data from the two passed in + } +function apr_hash_overlay(p: Papr_pool_t; + const overlay, base: Papr_hash_t): Papr_hash_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_overlay' + LibSuff12; + +{ + * Merge two hash tables into one new hash table. If the same key + * is present in both tables, call the supplied merge function to + * produce a merged value for the key in the new table. + * @param p The pool to use for the new hash table + * @param h1 The first of the tables to merge + * @param h2 The second of the tables to merge + * @param merger A callback function to merge values, or NULL to + * make values from h1 override values from h2 (same semantics as + * apr_hash_overlay()) + * @param data Client data to pass to the merger function + * @return A new hash table containing all of the data from the two passed in + } +type + apr_hash_merge_t = function (p: Papr_pool_t; const key: Pointer; klen: apr_size_t; + const h1_val, h2_val, data: Pointer): Pointer; cdecl; + +function apr_hash_merge(p: Papr_pool_t; + const h1, h2: Papr_hash_t; + merger: apr_hash_merge_t; const data: Pointer): Papr_hash_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_hash_merge' + LibSuff20; + +{ + * Get a pointer to the pool which the hash table was created in + } +//APR_POOL_DECLARE_ACCESSOR(hash); + diff --git a/httpd/httpd_2_2/apr/apr_lib.inc b/httpd/httpd_2_2/apr/apr_lib.inc new file mode 100644 index 000000000..1b14f7bf6 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_lib.inc @@ -0,0 +1,221 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_lib.h + * This is collection of oddballs that didn't fit anywhere else, + * and might move to more appropriate headers with the release + * of APR 1.0. + * @brief APR general purpose library routines + } + +{#include "apr.h" +#include "apr_errno.h" + +#if APR_HAVE_CTYPE_H +#include
+ * For example: + * "/foo/bar/gum" -> "gum" + * "/foo/bar/gum/" -> "" + * "gum" -> "gum" + * "bs\\path\\stuff" -> "stuff" + *+ } +function apr_filepath_name_get(const pathname: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filepath_name_get' + LibSuff4; + +{ @deprecated @see apr_filepath_name_get } +function apr_filename_of_pathname(const pathname: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_filename_of_pathname' + LibSuff4; + +{ + * apr_killpg + * Small utility macros to make things easier to read. Not usually a + * goal, to be sure.. + } + +//#ifdef WIN32 +//#define apr_killpg(x, y) +//#else { WIN32 } +//#ifdef NO_KILLPG +//#define apr_killpg(x, y) (kill (-(x), (y))) +//#else { NO_KILLPG } +//#define apr_killpg(x, y) (killpg ((x), (y))) +//#endif { NO_KILLPG } +//#endif { WIN32 } + +{ + * apr_vformatter() is a generic printf-style formatting routine + * with some extensions. + * @param flush_func The function to call when the buffer is full + * @param c The buffer to write to + * @param fmt The format string + * @param ap The arguments to use to fill out the format string. + * + * @remark + *
+ * The extensions are: + * + * %%pA takes a struct in_addr *, and prints it as a.b.c.d + * %%pI takes an apr_sockaddr_t * and prints it as a.b.c.d:port or + * [ipv6-address]:port + * %%pT takes an apr_os_thread_t * and prints it in decimal + * ('0' is printed if !APR_HAS_THREADS) + * %%pp takes a void * and outputs it in hex + * + * The %%p hacks are to force gcc's printf warning code to skip + * over a pointer argument without complaining. This does + * mean that the ANSI-style %%p (output a void * in hex format) won't + * work as expected at all, but that seems to be a fair trade-off + * for the increased robustness of having printf-warnings work. + * + * Additionally, apr_vformatter allows for arbitrary output methods + * using the apr_vformatter_buff and flush_func. + * + * The apr_vformatter_buff has two elements curpos and endpos. + * curpos is where apr_vformatter will write the next byte of output. + * It proceeds writing output to curpos, and updating curpos, until + * either the end of output is reached, or curpos == endpos (i.e. the + * buffer is full). + * + * If the end of output is reached, apr_vformatter returns the + * number of bytes written. + * + * When the buffer is full, the flush_func is called. The flush_func + * can return -1 to indicate that no further output should be attempted, + * and apr_vformatter will return immediately with -1. Otherwise + * the flush_func should flush the buffer in whatever manner is + * appropriate, re apr_pool_t nitialize curpos and endpos, and return 0. + * + * Note that flush_func is only invoked as a result of attempting to + * write another byte at curpos when curpos >= endpos. So for + * example, it's possible when the output exactly matches the buffer + * space available that curpos == endpos will be true when + * apr_vformatter returns. + * + * apr_vformatter does not call out to any other code, it is entirely + * self-contained. This allows the callers to do things which are + * otherwise "unsafe". For example, apr_psprintf uses the "scratch" + * space at the unallocated end of a block, and doesn't actually + * complete the allocation until apr_vformatter returns. apr_psprintf + * would be completely broken if apr_vformatter were to call anything + * that used this same pool. Similarly http_bprintf() uses the "scratch" + * space at the end of its output buffer, and doesn't actually note + * that the space is in use until it either has to flush the buffer + * or until apr_vformatter returns. + *+ } +type + flush_func_t = function (b: Papr_vformatter_buff_t): Integer; + +function apr_vformatter(flush_func: flush_func_t; + c: Papr_vformatter_buff_t; const fmt: PChar; ap: va_list): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_vformatter' + LibSuff16; + +{ + * Display a prompt and read in the password from stdin. + * @param prompt The prompt to display + * @param pwbuf Buffer to store the password + * @param bufsize The length of the password buffer. + } +function apr_password_get(const prompt: PChar; + pwbuf: PChar; bufsize: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_password_get' + LibSuff12; + +{ + * @defgroup apr_ctype ctype functions + * These macros allow correct support of 8-bit characters on systems which + * support 8-bit characters. Pretty dumb how the cast is required, but + * that's legacy libc for ya. These new macros do not support EOF like + * the standard macros do. Tough. + } +{ @see isalnum } +//#define apr_isalnum(c) (isalnum(((unsigned char)(c)))) +{ @see isalpha } +//#define apr_isalpha(c) (isalpha(((unsigned char)(c)))) +{ @see iscntrl } +//#define apr_iscntrl(c) (iscntrl(((unsigned char)(c)))) +{ @see isdigit } +//#define apr_isdigit(c) (isdigit(((unsigned char)(c)))) +{ @see isgraph } +//#define apr_isgraph(c) (isgraph(((unsigned char)(c)))) +{ @see islower} +//#define apr_islower(c) (islower(((unsigned char)(c)))) +{ @see isascii } +{#ifdef isascii +#define apr_isascii(c) (isascii(((unsigned char)(c)))) +#else +#define apr_isascii(c) (((c) & ~0x7f)==0) +#endif} +{ @see isprint } +//#define apr_isprint(c) (isprint(((unsigned char)(c)))) +{ @see ispunct } +//#define apr_ispunct(c) (ispunct(((unsigned char)(c)))) +{ @see isspace } +//#define apr_isspace(c) (isspace(((unsigned char)(c)))) +{ @see isupper } +//#define apr_isupper(c) (isupper(((unsigned char)(c)))) +{ @see isxdigit } +//#define apr_isxdigit(c) (isxdigit(((unsigned char)(c)))) +{ @see tolower } +function apr_tolower(c: Char): Char; +{ @see toupper } +function apr_toupper(c: Char): Char; + diff --git a/httpd/httpd_2_2/apr/apr_network_io.inc b/httpd/httpd_2_2/apr/apr_network_io.inc new file mode 100644 index 000000000..67b114f4d --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_network_io.inc @@ -0,0 +1,884 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_network_io.h + * @brief APR Network library + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_file_io.h" +#include "apr_errno.h" +#include "apr_inherit.h" + +#if APR_HAVE_NETINET_IN_H +#include
+ * APR_SHUTDOWN_READ no longer allow read requests + * APR_SHUTDOWN_WRITE no longer allow write requests + * APR_SHUTDOWN_READWRITE no longer allow read or write requests + *+ * @see apr_shutdown_how_e + * @remark This does not actually close the socket descriptor, it just + * controls which calls are still valid on the socket. + } +function apr_socket_shutdown(thesocket: Papr_socket_t; + how: apr_shutdown_how_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_shutdown' + LibSuff8; + +{ @deprecated @see apr_socket_shutdown } +function apr_shutdown(thesocket: Papr_socket_t; + how: apr_shutdown_how_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_shutdown' + LibSuff8; + +{ + * Close a socket. + * @param thesocket The socket to close + } +function apr_socket_close(thesocket: Papr_socket_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_close' + LibSuff4; + +{ + * Bind the socket to its associated port + * @param sock The socket to bind + * @param sa The socket address to bind to + * @remark This may be where we will find out if there is any other process + * using the selected port. + } +function apr_socket_bind(sock: Papr_socket_t; + sa: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_bind' + LibSuff8; + +{ @deprecated @see apr_socket_bind } +function apr_bind(sock: Papr_socket_t; + sa: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_bind' + LibSuff8; + +{ + * Listen to a bound socket for connections. + * @param sock The socket to listen on + * @param backlog The number of outstanding connections allowed in the sockets + * listen queue. If this value is less than zero, the listen + * queue size is set to zero. + } +function apr_socket_listen(sock: Papr_socket_t; + backlog: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_listen' + LibSuff8; + +{ @deprecated @see apr_socket_listen } +function apr_listen(sock: Papr_socket_t; + backlog: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_listen' + LibSuff8; + +{ + * Accept a new connection request + * @param new_sock A copy of the socket that is connected to the socket that + * made the connection request. This is the socket which should + * be used for all future communication. + * @param sock The socket we are listening on. + * @param connection_pool The pool for the new socket. + } +function apr_socket_accept(new_sock: PPapr_socket_t; + sock: Papr_socket_t; connection_pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_accept' + LibSuff12; + +{ @deprecated @see apr_socket_accept } +{APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new_sock, + apr_socket_t *sock, + apr_pool_t *connection_pool);} + +{ + * Issue a connection request to a socket either on the same machine + * or a different one. + * @param sock The socket we wish to use for our side of the connection + * @param sa The address of the machine we wish to connect to. If NULL, + * APR assumes that the sockaddr_in in the apr_socket is + * completely filled out. + } +function apr_socket_connect(sock: Papr_socket_t; sa: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_connect' + LibSuff8; + +{ @deprecated @see apr_socket_connect } +//APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa); + +{ + * Create apr_sockaddr_t from hostname, address family, and port. + * @param sa The new apr_sockaddr_t. + * @param hostname The hostname or numeric address string to resolve/parse, or + * NULL to build an address that corresponds to 0.0.0.0 or :: + * @param family The address family to use, or APR_UNSPEC if the system should + * decide. + * @param port The port number. + * @param flags Special processing flags: + *
+ * APR_IPV4_ADDR_OK first query for IPv4 addresses; only look + * for IPv6 addresses if the first query failed; + * only valid if family is APR_UNSPEC and hostname + * isn't NULL; mutually exclusive with + * APR_IPV6_ADDR_OK + * APR_IPV6_ADDR_OK first query for IPv6 addresses; only look + * for IPv4 addresses if the first query failed; + * only valid if family is APR_UNSPEC and hostname + * isn't NULL and APR_HAVE_IPV6; mutually exclusive + * with APR_IPV4_ADDR_OK + *+ * @param p The pool for the apr_sockaddr_t and associated storage. + } +function apr_sockaddr_info_get(sa: PPapr_socket_t; + const hostname: PChar; family: apr_int32_t; + port: apr_port_t; flags: apr_int32_t; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_info_get' + LibSuff24; + +{ + * Look up the host name from an apr_sockaddr_t. + * @param hostname The hostname. + * @param sa The apr_sockaddr_t. + * @param flags Special processing flags. + } +function apr_getnameinfo(hostname: PPChar; sa: Papr_socket_t; flags: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_getnameinfo' + LibSuff12; + +{ + * Parse hostname/IP address with scope id and port. + * + * Any of the following strings are accepted: + * 8080 (just the port number) + * www.apache.org (just the hostname) + * www.apache.org:8080 (hostname and port number) + * [fe80::1]:80 (IPv6 numeric address string only) + * [fe80::1%eth0] (IPv6 numeric address string and scope id) + * + * Invalid strings: + * (empty string) + * [abc] (not valid IPv6 numeric address string) + * abc:65536 (invalid port number) + * + * @param addr The new buffer containing just the hostname. On output, *addr + * will be NULL if no hostname/IP address was specfied. + * @param scope_id The new buffer containing just the scope id. On output, + * *scope_id will be NULL if no scope id was specified. + * @param port The port number. On output, *port will be 0 if no port was + * specified. + * ### FIXME: 0 is a legal port (per RFC 1700). this should + * ### return something besides zero if the port is missing. + * @param str The input string to be parsed. + * @param p The pool from which *addr and *scope_id are allocated. + * @remark If scope id shouldn't be allowed, check for scope_id != NULL in + * addition to checking the return code. If addr/hostname should be + * required, check for addr == NULL in addition to checking the + * return code. + } +function apr_parse_addr_port(addr, scope_id: PPChar; port: Papr_port_t; + const str: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_parse_addr_port' + LibSuff20; + +{ + * Get name of the current machine + * @param buf A buffer to store the hostname in. + * @param len The maximum length of the hostname that can be stored in the + * buffer provided. The suggested length is APRMAXHOSTLEN + 1. + * @param cont The pool to use. + * @remark If the buffer was not large enough, an error will be returned. + } +function apr_gethostname(buf: PChar; len: Integer; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_gethostname' + LibSuff12; + +{ + * Return the data associated with the current socket + * @param data The user data associated with the socket. + * @param key The key to associate with the user data. + * @param sock The currently open socket. + } +function apr_socket_data_get(data: PPointer; const key: PChar; + sock: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_data_get' + LibSuff12; + +{ + * Set the data associated with the current socket. + * @param sock The currently open socket. + * @param data The user data to associate with the socket. + * @param key The key to associate with the data. + * @param cleanup The cleanup to call when the socket is destroyed. + } +type + cleanup_t = function (param: Pointer): apr_status_t; + +function apr_socket_data_set(sock: Papr_socket_t; data: Pointer; + const key: PChar; cleanup: cleanup_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_data_set' + LibSuff16; + +{ + * Send data over a network. + * @param sock The socket to send the data over. + * @param buf The buffer which contains the data to be sent. + * @param len On entry, the number of bytes to send; on exit, the number + * of bytes sent. + * @remark + *
+ * This functions acts like a blocking write by default. To change + * this behavior, use apr_socket_timeout_set(). + * + * It is possible for both bytes to be sent and an error to be returned. + * + * APR_EINTR is never returned. + *+ } +function apr_socket_send(sock: Papr_socket_t; const buf: PChar; + len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_send' + LibSuff12; + +{ @deprecated @see apr_socket_send } +{APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf, + apr_size_t *len);} + +{ + * Send multiple packets of data over a network. + * @param sock The socket to send the data over. + * @param vec The array of iovec structs containing the data to send + * @param nvec The number of iovec structs in the array + * @param len Receives the number of bytes actually written + * @remark + *
+ * This functions acts like a blocking write by default. To change + * this behavior, use apr_socket_timeout_set(). + * The number of bytes actually sent is stored in argument 3. + * + * It is possible for both bytes to be sent and an error to be returned. + * + * APR_EINTR is never returned. + *+ } +function apr_socket_sendv(sock: Papr_socket_t; const vec: Piovec; + nvec: apr_int32_t; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_sendv' + LibSuff16; + +{ @deprecated @see apr_socket_sendv } +{APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock, + const struct iovec *vec, + apr_int32_t nvec, apr_size_t *len);} + +{ + * @param sock The socket to send from + * @param where The apr_sockaddr_t describing where to send the data + * @param flags The flags to use + * @param buf The data to send + * @param len The length of the data to send + } +function apr_socket_sendto(sock: Papr_socket_t; where: Papr_sockaddr_t; + flags: apr_int32_t; const buf: PChar; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_sendto' + LibSuff20; + +{ @deprecated @see apr_socket_sendto } +{APR_DECLARE(apr_status_t) apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where, + apr_int32_t flags, const char *buf, + apr_size_t *len);} + +{ + * @param from The apr_sockaddr_t to fill in the recipient info + * @param sock The socket to use + * @param flags The flags to use + * @param buf The buffer to use + * @param len The length of the available buffer + } +function apr_socket_recvfrom(from: Papr_sockaddr_t; sock: Papr_socket_t; + flags: apr_int32_t; buf: PChar; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_recvfrom' + LibSuff20; + +{ @deprecated @see apr_socket_recvfrom } +{APR_DECLARE(apr_status_t) apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, + apr_int32_t flags, char *buf, + apr_size_t *len);} + +{$if defined(APR_HAS_SENDFILE) or defined(DOXYGEN)} + +{ + * Send a file from an open file descriptor to a socket, along with + * optional headers and trailers + * @param sock The socket to which we're writing + * @param file The open file from which to read + * @param hdtr A structure containing the headers and trailers to send + * @param offset Offset into the file where we should begin writing + * @param len (input) - Number of bytes to send from the file + * (output) - Number of bytes actually sent, + * including headers, file, and trailers + * @param flags APR flags that are mapped to OS specific flags + * @remark This functions acts like a blocking write by default. To change + * this behavior, use apr_socket_timeout_set(). + * The number of bytes actually sent is stored in argument 5. + } +function apr_socket_sendfile(sock: Papr_socket_t; file_: Papr_file_t; + hdtr: Papr_hdtr_t; offset: Papr_off_t; len: Papr_size_t; + flags: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_sendfile' + LibSuff24; + +{ @deprecated @see apr_socket_sendfile } +{APR_DECLARE(apr_status_t) apr_sendfile(apr_socket_t *sock, apr_file_t *file, + apr_hdtr_t *hdtr, apr_off_t *offset, + apr_size_t *len, apr_int32_t flags);} + +{$endif} { APR_HAS_SENDFILE } + +{ + * Read data from a network. + * @param sock The socket to read the data from. + * @param buf The buffer to store the data in. + * @param len On entry, the number of bytes to receive; on exit, the number + * of bytes received. + * @remark + *
+ * This functions acts like a blocking read by default. To change + * this behavior, use apr_socket_timeout_set(). + * The number of bytes actually sent is stored in argument 3. + * + * It is possible for both bytes to be received and an APR_EOF or + * other error to be returned. + * + * APR_EINTR is never returned. + *+ } +function apr_socket_recv(sock: Papr_socket_t; buf: PChar; len: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_recv' + LibSuff12; + +{ @deprecated @see apr_socket_recv } +{APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock, + char *buf, apr_size_t *len);} + +{ + * Setup socket options for the specified socket + * @param sock The socket to set up. + * @param opt The option we would like to configure. One of: + *
+ * APR_SO_DEBUG -- turn on debugging information + * APR_SO_KEEPALIVE -- keep connections active + * APR_SO_LINGER -- lingers on close if data is present + * APR_SO_NONBLOCK -- Turns blocking on/off for socket + * APR_SO_REUSEADDR -- The rules used in validating addresses + * supplied to bind should allow reuse + * of local addresses. + * APR_SO_SNDBUF -- Set the SendBufferSize + * APR_SO_RCVBUF -- Set the ReceiveBufferSize + *+ * @param on Value for the option. + } +function apr_socket_opt_set(sock: Papr_socket_t; opt, on_: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_opt_set' + LibSuff12; + +{ @deprecated @see apr_socket_opt_set } +{APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock, + apr_int32_t opt, apr_int32_t on);} + +{ + * Setup socket timeout for the specified socket + * @param sock The socket to set up. + * @param t Value for the timeout. + *
+ * t > 0 -- read and write calls return APR_TIMEUP if specified time + * elapsess with no data read or written + * t == 0 -- read and write calls never block + * t < 0 -- read and write calls block + *+ } +function apr_socket_timeout_set(sock: Papr_socket_t; t: apr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_timeout_set' + LibSuff12; + +{ + * Query socket options for the specified socket + * @param sock The socket to query + * @param opt The option we would like to query. One of: + *
+ * APR_SO_DEBUG -- turn on debugging information + * APR_SO_KEEPALIVE -- keep connections active + * APR_SO_LINGER -- lingers on close if data is present + * APR_SO_NONBLOCK -- Turns blocking on/off for socket + * APR_SO_REUSEADDR -- The rules used in validating addresses + * supplied to bind should allow reuse + * of local addresses. + * APR_SO_SNDBUF -- Set the SendBufferSize + * APR_SO_RCVBUF -- Set the ReceiveBufferSize + * APR_SO_DISCONNECTED -- Query the disconnected state of the socket. + * (Currently only used on Windows) + *+ * @param on Socket option returned on the call. + } +function apr_socket_opt_get(sock: Papr_socket_t; opt, on_: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_opt_get' + LibSuff12; + +{ @deprecated @see apr_socket_opt_set } +{APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock, + apr_int32_t opt, apr_int32_t *on);} + +{ + * Query socket timeout for the specified socket + * @param sock The socket to query + * @param t Socket timeout returned from the query. + } +function apr_socket_timeout_get(sock: Papr_socket_t; t: Papr_interval_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_timeout_get' + LibSuff8; + +{ + * Query the specified socket if at the OOB/Urgent data mark + * @param sock The socket to query + * @param atmark Is set to true if socket is at the OOB/urgent mark, + * otherwise is set to false. + } +function apr_socket_atmark(sock: Papr_socket_t; atmark: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_atmark' + LibSuff8; + +{ + * Return an apr_sockaddr_t from an apr_socket_t + * @param sa The returned apr_sockaddr_t. + * @param which Which interface do we want the apr_sockaddr_t for? + * @param sock The socket to use + } +function apr_socket_addr_get(sa: PPapr_sockaddr_t; + which: apr_interface_e; sock: Papr_socket_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_addr_get' + LibSuff12; + +{ + * Set the port in an APR socket address. + * @param sockaddr The socket address to set. + * @param port The port to be stored in the socket address. + * @deprecated @see apr_sockaddr_info_get + } +function apr_sockaddr_port_set(sockaddr: Papr_sockaddr_t; port: apr_port_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_port_set' + LibSuff8; + +{ + * Return the port in an APR socket address. + * @param port The port from the socket address. + * @param sockaddr The socket address to reference. + * @deprecated Access port field directly. + } +function apr_sockaddr_port_get(port: Papr_port_t; sockaddr: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_port_get' + LibSuff8; + +{ + * Set the IP address in an APR socket address. + * @param sockaddr The socket address to use + * @param addr The IP address to attach to the socket. + * Use APR_ANYADDR to use any IP addr on the machine. + * @deprecated @see apr_sockaddr_info_get + } +function apr_sockaddr_ip_set(sockaddr: Papr_sockaddr_t; const addr: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_ip_set' + LibSuff8; + +{ + * Return the IP address (in numeric address string format) in + * an APR socket address. APR will allocate storage for the IP address + * string from the pool of the apr_sockaddr_t. + * @param addr The IP address. + * @param sockaddr The socket address to reference. + } +function apr_sockaddr_ip_get(addr: PPChar; sockaddr: Papr_sockaddr_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_ip_get' + LibSuff8; + +{ + * See if the IP addresses in two APR socket addresses are + * equivalent. Appropriate logic is present for comparing + * IPv4-mapped IPv6 addresses with IPv4 addresses. + * + * @param addr1 One of the APR socket addresses. + * @param addr2 The other APR socket address. + * @remark The return value will be non-zero if the addresses + * are equivalent. + } +function apr_sockaddr_equal(const addr1, addr2: Papr_sockaddr_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sockaddr_equal' + LibSuff8; + +{$if defined(APR_FILES_AS_SOCKETS) or defined(DOXYGEN)} + +{ + * Convert a File type to a socket so that it can be used in a poll operation. + * @param newsock the newly created socket which represents a file. + * @param file the file to mask as a socket. + * @warning This is not available on all platforms. Platforms that have the + * ability to poll files for data to be read/written/exceptions will + * have the APR_FILES_AS_SOCKETS macro defined as true. + * @deprecated This function has been deprecated, because of the new poll + * implementation. + } +function apr_socket_from_file(newsock: Papr_socket_t; file_: Papr_file_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_connect' + LibSuff8; + +{$endif} { APR_FILES_AS_SOCKETS } + +{ + * Given an apr_sockaddr_t and a service name, set the port for the service + * @param sockaddr The apr_sockaddr_t that will have its port set + * @param servname The name of the service you wish to use + } +function apr_getservbyname(sockaddr: Papr_sockaddr_t; const servname: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_getservbyname' + LibSuff8; + +{ + * Build an ip-subnet representation from an IP address and optional netmask or + * number-of-bits. + * @param ipsub The new ip-subnet representation + * @param ipstr The input IP address string + * @param mask_or_numbits The input netmask or number-of-bits string, or NULL + * @param p The pool to allocate from + } +function apr_ipsubnet_create(ipsub: PPapr_ipsubnet_t; + const ipstr, mask_or_numbits: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ipsubnet_create' + LibSuff16; + +{ + * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet + * representation. + * @param ipsub The ip-subnet representation + * @param sa The socket address to test + * @return non-zero if the socket address is within the subnet, 0 otherwise + } +function apr_ipsubnet_test(ipsub: Papr_ipsubnet_t; sa: Papr_sockaddr_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ipsubnet_test' + LibSuff8; + +{$if defined(APR_HAS_SO_ACCEPTFILTER) or defined(DOXYGEN)} +{ + * Set an OS level accept filter. + * @param sock The socket to put the accept filter on. + * @param name The accept filter + * @param args Any extra args to the accept filter. Passing NULL here removes + * the accept filter. + } +function apr_socket_accept_filter(sock: Papr_socket_t; name, args: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_accept_filter' + LibSuff12; + +{$endif} + +{ + * Return the protocol of the socket. + * @param sock The socket to query. + * @param protocol The returned protocol (e.g., APR_PROTO_TCP). + } +function apr_socket_protocol_get(sock: Papr_socket_t; protocol: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_socket_protocol_get' + LibSuff8; + +{ + * Set a socket to be inherited by child processes. + } +//APR_DECLARE_INHERIT_SET(socket); + +{ @deprecated @see apr_socket_inherit_set } +{APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);} + +{ + * Unset a socket from being inherited by child processes. + } +//APR_DECLARE_INHERIT_UNSET(socket); + +{ @deprecated @see apr_socket_inherit_unset } +{APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);} + diff --git a/httpd/httpd_2_2/apr/apr_pools.inc b/httpd/httpd_2_2/apr/apr_pools.inc new file mode 100644 index 000000000..6ffc3c10c --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_pools.inc @@ -0,0 +1,707 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_pools.h + * @brief APR memory allocation + * + * Resource allocation routines... + * + * designed so that we don't have to keep track of EVERYTHING so that + * it can be explicitly freed later (a fundamentally unsound strategy --- + * particularly in the presence of die()). + * + * Instead, we maintain pools, and allocate items (both memory and I/O + * handlers) from the pools --- currently there are two, one for per + * transaction info, and one for config info. When a transaction is over, + * we can delete everything in the per-transaction apr_pool_t without fear, + * and without thinking too hard about it either. + } + +{#include "apr.h" +#include "apr_errno.h" +#include "apr_general.h"{ { for APR_STRINGIFY } +//#include "apr_want.h" + +{ + * @defgroup apr_pools Memory Pool Functions + * @ingroup APR + * @ + } + +{ The fundamental pool type } +type + apr_pool_t = record end; + Papr_pool_t = ^apr_pool_t; + PPapr_pool_t = ^Papr_pool_t; + +{ + * Declaration helper macro to construct apr_foo_pool_get()s. + * + * This standardized macro is used by opaque (APR) data types to return + * the apr_pool_t that is associated with the data type. + * + * APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the + * accessor function. A typical usage and result would be: + *
+ * APR_POOL_DECLARE_ACCESSOR(file); + * becomes: + * APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob); + *+ * @remark Doxygen unwraps this macro (via doxygen.conf) to provide + * actual help for each specific occurance of apr_foo_pool_get. + * @remark the linkage is specified for APR. It would be possible to expand + * the macros to support other linkages. + } +{#define APR_POOL_DECLARE_ACCESSOR(type) \ + APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ + (const apr_##type##_t *the##type) +} +{ + * Implementation helper macro to provide apr_foo_pool_get()s. + * + * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to + * actually define the function. It assumes the field is named "pool". + } +{#define APR_POOL_IMPLEMENT_ACCESSOR(type) \ + APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \ + (const apr_##type##_t *the##type) \} + { return the##type->pool; } + + +{ + * Pool debug levels + * + *
+ * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | + * --------------------------------- + * | | | | | | | | x | General debug code enabled (usefull in + * combination with --with-efence). + * + * | | | | | | | x | | Verbose output on stderr (report + * CREATE, CLEAR, DESTROY). + * + * | | | | x | | | | | Verbose output on stderr (report + * PALLOC, PCALLOC). + * + * | | | | | | x | | | Lifetime checking. On each use of a + * pool, check its lifetime. If the pool + * is out of scope, abort(). + * In combination with the verbose flag + * above, it will output LIFE in such an + * event prior to aborting. + * + * | | | | | x | | | | Pool owner checking. On each use of a + * pool, check if the current thread is the + * pools owner. If not, abort(). In + * combination with the verbose flag above, + * it will output OWNER in such an event + * prior to aborting. Use the debug + * function apr_pool_owner_set() to switch + * a pools ownership. + * + * When no debug level was specified, assume general debug mode. + * If level 0 was specified, debugging is switched off + *+ } +{#if defined(APR_POOL_DEBUG) +#if (APR_POOL_DEBUG != 0) && (APR_POOL_DEBUG - 0 == 0) +#undef APR_POOL_DEBUG +#define APR_POOL_DEBUG 1 +#endif +#else +#define APR_POOL_DEBUG 0 +#endif +} +{ the place in the code where the particular function was called } +//#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__) + + + +{ A function that is called when allocation fails. } +type + apr_abortfunc_t = function (retcode: Integer): Integer; + +{ + * APR memory structure manipulators (pools, tables, and arrays). + } + +{ + * Initialization + } + +{ + * Setup all of the internal structures required to use pools + * @remark Programs do NOT need to call this directly. APR will call this + * automatically from apr_initialize. + * @internal + } +function apr_pool_initialize: apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_initialize' + LibSuff0; + +{ + * Tear down all of the internal structures required to use pools + * @remark Programs do NOT need to call this directly. APR will call this + * automatically from apr_terminate. + * @internal + } +procedure apr_pool_terminate; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_terminate' + LibSuff0; + +{ + * Pool creation/destruction + } + +{$include apr_allocator.inc} + +{ + * Create a new pool. + * @param newpool The pool we have just created. + * @param parent The parent pool. If this is NULL, the new pool is a root + * pool. If it is non-NULL, the new pool will inherit all + * of its parent pool's attributes, except the apr_pool_t will + * be a sub-pool. + * @param abort_fn A function to use if the pool cannot allocate more memory. + * @param allocator The allocator to use with the new pool. If NULL the + * allocator of the parent pool will be used. + } +function apr_pool_create_ex(newpool: PPapr_pool_t; + parent: Papr_pool_t; abort_fn: apr_abortfunc_t; + allocator: Papr_allocator_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_create_ex' + LibSuff16; + +{ + * Debug version of apr_pool_create_ex. + * @param newpool @see apr_pool_create. + * @param parent @see apr_pool_create. + * @param abort_fn @see apr_pool_create. + * @param allocator @see apr_pool_create. + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @remark Only available when APR_POOL_DEBUG is defined. + * Call this directly if you have you apr_pool_create_ex + * calls in a wrapper function and wish to override + * the file_line argument to reflect the caller of + * your wrapper function. If you do not have + * apr_pool_create_ex in a wrapper, trust the macro + * and don't call apr_pool_create_ex_debug directly. + } +function apr_pool_create_ex_debug(newpool: PPapr_pool_t; + parent: Papr_pool_t; abort_fn: apr_abortfunc_t; + allocator: Papr_allocator_t; const file_line: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_create_ex_debug' + LibSuff20; + +{#if APR_POOL_DEBUG +#define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \ + apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \ + APR_POOL__FILE_LINE__) +#endif +} +{ + * Create a new pool. + * @param newpool The pool we have just created. + * @param parent The parent pool. If this is NULL, the new pool is a root + * pool. If it is non-NULL, the new pool will inherit all + * of its parent pool's attributes, except the apr_pool_t will + * be a sub-pool. + } +{$ifdef DOXYGEN} +function apr_pool_create(newpool: PPapr_pool_t; + parent: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_create' + LibSuff8; +{$else} +{.$ifdef APR_POOL_DEBUG} +{#define apr_pool_create(newpool, parent) \ + apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \ + APR_POOL__FILE_LINE__)} +{.$else} +function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t; +{.$endif} +{$endif} + +{ @deprecated @see apr_pool_create_ex } +{#if APR_POOL_DEBUG +#define apr_pool_sub_make(newpool, parent, abort_fn) \ + (void)apr_pool_create_ex_debug(newpool, parent, abort_fn, \ + NULL, \ + APR_POOL__FILE_LINE__) +#else} +function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t; + abort_fn: apr_abortfunc_t): apr_status_t; +//#endif + +{ + * Find the pools allocator + * @param pool The pool to get the allocator from. + } +function apr_pool_allocator_get(pool: Papr_pool_t): Papr_allocator_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_allocator_get' + LibSuff4; + +{ + * Clear all memory in the pool and run all the cleanups. This also destroys all + * subpools. + * @param p The pool to clear + * @remark This does not actually free the memory, it just allows the pool + * to re-use this memory for the next allocation. + * @see apr_pool_destroy() + } +procedure apr_pool_clear(p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_clear' + LibSuff4; + +{ + * Debug version of apr_pool_clear. + * @param p See: apr_pool_clear. + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @remark Only available when APR_POOL_DEBUG is defined. + * Call this directly if you have you apr_pool_clear + * calls in a wrapper function and wish to override + * the file_line argument to reflect the caller of + * your wrapper function. If you do not have + * apr_pool_clear in a wrapper, trust the macro + * and don't call apr_pool_destroy_clear directly. + } +procedure apr_pool_clear_debug(p: Papr_pool_t; const file_line: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_clear_debug' + LibSuff8; + +{#if APR_POOL_DEBUG +#define apr_pool_clear(p) \ + apr_pool_clear_debug(p, APR_POOL__FILE_LINE__) +#endif} + +{ + * Destroy the pool. This takes similar action as apr_pool_clear() and then + * frees all the memory. + * @param p The pool to destroy + * @remark This will actually free the memory + } +procedure apr_pool_destroy(p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_destroy' + LibSuff4; + +{ + * Debug version of apr_pool_destroy. + * @param p See: apr_pool_destroy. + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @remark Only available when APR_POOL_DEBUG is defined. + * Call this directly if you have you apr_pool_destroy + * calls in a wrapper function and wish to override + * the file_line argument to reflect the caller of + * your wrapper function. If you do not have + * apr_pool_destroy in a wrapper, trust the macro + * and don't call apr_pool_destroy_debug directly. + } +procedure apr_pool_destroy_debug(p: Papr_pool_t; const file_line: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_destroy_debug' + LibSuff8; + +{#if APR_POOL_DEBUG +#define apr_pool_destroy(p) \ + apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__) +#endif} + + +{ + * Memory allocation + } + +{ + * Allocate a block of memory from a pool + * @param p The pool to allocate from + * @param size The amount of memory to allocate + * @return The allocated memory + } +function apr_palloc(p: Papr_pool_t; size: apr_size_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_palloc' + LibSuff8; + +{ + * Debug version of apr_palloc + * @param p See: apr_palloc + * @param size See: apr_palloc + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @return See: apr_palloc + } +function apr_palloc_debug(p: Papr_pool_t; size: apr_size_t; + const file_line: PChar): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_palloc_debug' + LibSuff12; + +{#if APR_POOL_DEBUG +#define apr_palloc(p, size) \ + apr_palloc_debug(p, size, APR_POOL__FILE_LINE__) +#endif +} +{ + * Allocate a block of memory from a pool and set all of the memory to 0 + * @param p The pool to allocate from + * @param size The amount of memory to allocate + * @return The allocated memory + } +{#if defined(DOXYGEN)} + +function apr_pcalloc(p: Papr_pool_t; size: apr_size_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pcalloc' + LibSuff8; + +{#elif !APR_POOL_DEBUG +#define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size) +#endif +} +{ + * Debug version of apr_pcalloc + * @param p See: apr_pcalloc + * @param size See: apr_pcalloc + * @param file_line Where the function is called from. + * This is usually APR_POOL__FILE_LINE__. + * @return See: apr_pcalloc + } +{APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size, + const char *file_line); + +#if APR_POOL_DEBUG +#define apr_pcalloc(p, size) \ + apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__) +#endif + +} +{ + * Pool Properties + } + +{ + * Set the function to be called when an allocation failure occurs. + * @remark If the program wants APR to exit on a memory allocation error, + * then this function can be called to set the callback to use (for + * performing cleanup and then exiting). If this function is not called, + * then APR will return an error and expect the calling program to + * deal with the error accordingly. + } +procedure apr_pool_abort_set(abortfunc: apr_abortfunc_t; pool: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_abort_set' + LibSuff8; + +{ @deprecated @see apr_pool_abort_set } +{APR_DECLARE(void) apr_pool_set_abort(apr_abortfunc_t abortfunc, + apr_pool_t *pool); +} +{ + * Get the abort function associated with the specified pool. + * @param pool The pool for retrieving the abort function. + * @return The abort function for the given pool. + } +function apr_pool_abort_get(pool: Papr_pool_t): apr_abortfunc_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_abort_get' + LibSuff4; + +{ @deprecated @see apr_pool_abort_get } +//APR_DECLARE(apr_abortfunc_t) apr_pool_get_abort(apr_pool_t *pool); + +{ + * Get the parent pool of the specified pool. + * @param pool The pool for retrieving the parent pool. + * @return The parent of the given pool. + } +function apr_pool_parent_get(pool: Papr_pool_t): Papr_pool_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_parent_get' + LibSuff4; + +{ @deprecated @see apr_pool_parent_get } +//APR_DECLARE(apr_pool_t *) apr_pool_get_parent(apr_pool_t *pool); + +{ + * Determine if pool a is an ancestor of pool b + * @param a The pool to search + * @param b The pool to search for + * @return True if a is an ancestor of b, NULL is considered an ancestor + * of all pools. + } +function apr_pool_is_ancestor(a, b: Papr_pool_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_is_ancestor' + LibSuff8; + +{ + * Tag a pool (give it a name) + * @param pool The pool to tag + * @param tag The tag + } +procedure apr_pool_tag(pool: Papr_pool_t; tag: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_tag' + LibSuff8; + +{ + * User data management + } + +{ + * Set the data associated with the current pool + * @param data The user data associated with the pool. + * @param key The key to use for association + * @param cleanup The cleanup program to use to cleanup the data (NULL if none) + * @param pool The current pool + * @warning The data to be attached to the pool should have a life span + * at least as long as the pool it is being attached to. + * + * Users of APR must take EXTREME care when choosing a key to + * use for their data. It is possible to accidentally overwrite + * data by choosing a key that another part of the program is using. + * Therefore it is advised that steps are taken to ensure that unique + * keys are used for all of the userdata objects in a particular pool + * (the same key in two different pools or a pool and one of its + * subpools is okay) at all times. Careful namespace prefixing of + * key names is a typical way to help ensure this uniqueness. + } +//function apr_pool_userdata_set( +// const data: Pointer; const key: PChar; +// cleanup: function(param: Pointer): apr_status_t, +// pool: Papr_pool_t): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_userdata_set' + LibSuff20; + +{ + * Set the data associated with the current pool + * @param data The user data associated with the pool. + * @param key The key to use for association + * @param cleanup The cleanup program to use to cleanup the data (NULL if none) + * @param pool The current pool + * @note same as apr_pool_userdata_set(), except that this version doesn't + * make a copy of the key (this function is useful, for example, when + * the key is a string literal) + * @warning This should NOT be used if the key could change addresses by + * any means between the apr_pool_userdata_setn() call and a + * subsequent apr_pool_userdata_get() on that key, such as if a + * static string is used as a userdata key in a DSO and the DSO could + * be unloaded and reloaded between the _setn() and the _get(). You + * MUST use apr_pool_userdata_set() in such cases. + * @warning More generally, the key and the data to be attached to the + * pool should have a life span at least as long as the pool itself. + * + } +//function apr_pool_userdata_setn( +// const data: Pointer; const key: PChar; +// cleanup: function(param: Pointer): apr_status_t, +// pool: Papr_pool_t): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_userdata_setn' + LibSuff20; + +{ + * Return the data associated with the current pool. + * @param data The user data associated with the pool. + * @param key The key for the data to retrieve + * @param pool The current pool. + } +function apr_pool_userdata_get(data: PPointer; const key: PChar; + pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_userdata_get' + LibSuff12; + +{ + * Cleanup + * + * Cleanups are performed in the reverse order they were registered. That is: + * Last In, First Out. + } + +{ + * Register a function to be called when a pool is cleared or destroyed + * @param p The pool register the cleanup with + * @param data The data to pass to the cleanup function. + * @param plain_cleanup The function to call when the pool is cleared + * or destroyed + * @param child_cleanup The function to call when a child process is being + * shutdown - this function is called in the child, obviously! + } +type + plain_cleanup_t = function(param: Pointer): apr_status_t; cdecl; + child_cleanup_t = function(param: Pointer): apr_status_t; cdecl; + +procedure apr_pool_cleanup_register(p: Papr_pool_t; + const data: Pointer; + plain_cleanup: plain_cleanup_t; + child_cleanup: child_cleanup_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_cleanup_register' + LibSuff16; + +{ + * Remove a previously registered cleanup function + * @param p The pool remove the cleanup from + * @param data The data to remove from cleanup + * @param cleanup The function to remove from cleanup + * @remarks For some strange reason only the plain_cleanup is handled by this + * function + } +//procedure apr_pool_cleanup_for_exec; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +//APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data, +// apr_status_t cleanup)(void ); + +{ + * Replace the child cleanup of a previously registered cleanup + * @param p The pool of the registered cleanup + * @param data The data of the registered cleanup + * @param plain_cleanup The plain cleanup function of the registered cleanup + * @param child_cleanup The function to register as the child cleanup + } +//procedure apr_pool_cleanup_for_exec; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +{APR_DECLARE(void) apr_pool_child_cleanup_set( + apr_pool_t *p, + const void *data, + apr_status_t plain_cleanup)(void , + apr_status_t child_cleanup)(void ); +} +{ + * Run the specified cleanup function immediately and unregister it. Use + * @a data instead of the data that was registered with the cleanup. + * @param p The pool remove the cleanup from + * @param data The data to remove from cleanup + * @param cleanup The function to remove from cleanup + } +//procedure apr_pool_cleanup_for_exec; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +{APR_DECLARE(apr_status_t) apr_pool_cleanup_run( + apr_pool_t *p, + void *data, + apr_status_t cleanup)(void );} + +{ + * An empty cleanup function + * @param data The data to cleanup + } +//APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data); + +{ Preparing for exec() --- close files, etc., but *don't* flush I/O + * buffers, *don't* wait for subprocesses, and *don't* free any memory. + } +{ + * Run all of the child_cleanups, so that any unnecessary files are + * closed because we are about to exec a new program + } +procedure apr_pool_cleanup_for_exec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0; + +{ + * @defgroup PoolDebug Pool Debugging functions. + * + * pools have nested lifetimes -- sub_pools are destroyed when the + * parent pool is cleared. We allow certain liberties with operations + * on things such as tables (and on other structures in a more general + * sense) where we allow the caller to insert values into a table which + * were not allocated from the table's pool. The table's data will + * remain valid as long as all the pools from which its values are + * allocated remain valid. + * + * For example, if B is a sub pool of A, and you build a table T in + * pool B, then it's safe to insert data allocated in A or B into T + * (because B lives at most as long as A does, and T is destroyed when + * B is cleared/destroyed). On the other hand, if S is a table in + * pool A, it is safe to insert data allocated in A into S, but it + * is *not safe* to insert data allocated from B into S... because + * B can be cleared/destroyed before A is (which would leave dangling + * pointers in T's data structures). + * + * In general we say that it is safe to insert data into a table T + * if the data is allocated in any ancestor of T's pool. This is the + * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor + * relationships for all data inserted into tables. APR_POOL_DEBUG also + * provides tools (apr_pool_find, and apr_pool_is_ancestor) for other + * folks to implement similar restrictions for their own data + * structures. + * + * However, sometimes this ancestor requirement is inconvenient -- + * sometimes we're forced to create a sub pool (such as through + * apr_sub_req_lookup_uri), and the sub pool is guaranteed to have + * the same lifetime as the parent pool. This is a guarantee implemented + * by the *caller*, not by the pool code. That is, the caller guarantees + * they won't destroy the sub pool individually prior to destroying the + * parent pool. + * + * In this case the caller must call apr_pool_join() to indicate this + * guarantee to the APR_POOL_DEBUG code. There are a few examples spread + * through the standard modules. + * + * These functions are only implemented when #APR_POOL_DEBUG is set. + * + } +{$if defined(APR_POOL_DEBUG) or defined(DOXYGEN)} +{ + * Guarantee that a subpool has the same lifetime as the parent. + * @param p The parent pool + * @param sub The subpool + } +procedure apr_pool_join(p, sub: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_join' + LibSuff8; + +{ + * Find a pool from something allocated in it. + * @param mem The thing allocated in the pool + * @return The pool it is allocated in + } +function apr_pool_find(const mem: Pointer): Papr_pool_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_find' + LibSuff4; + +{ + * Report the number of bytes currently in the pool + * @param p The pool to inspect + * @param recurse Recurse/include the subpools' sizes + * @return The number of bytes + } +function apr_pool_num_bytes(p: Papr_pool_t; recurse: Integer): apr_size_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_num_bytes' + LibSuff8; + +{ + * Lock a pool + * @param pool The pool to lock + * @param flag The flag + } +procedure apr_pool_lock(pool: Papr_pool_t; flag: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_lock' + LibSuff8; + +{$else} { APR_POOL_DEBUG or DOXYGEN } + +{#ifdef apr_pool_join +#undef apr_pool_join +#endif +#define apr_pool_join(a,b) + +#ifdef apr_pool_lock +#undef apr_pool_lock +#endif +#define apr_pool_lock(pool, lock)} + +{$endif} { APR_POOL_DEBUG or DOXYGEN } + diff --git a/httpd/httpd_2_2/apr/apr_portable.inc b/httpd/httpd_2_2/apr/apr_portable.inc new file mode 100644 index 000000000..415e969c8 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_portable.inc @@ -0,0 +1,540 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ This header file is where you should put ANY platform specific information. + * This should be the only header file that programs need to include that + * actually has platform dependant code which refers to the . + } + +{ + * @file apr_portable.h + * @brief APR Portability Routines + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_thread_proc.h" +#include "apr_file_io.h" +#include "apr_network_io.h" +#include "apr_errno.h" +#include "apr_global_mutex.h" +#include "apr_proc_mutex.h" +#include "apr_time.h" +#include "apr_dso.h" +#include "apr_shm.h" + +#if APR_HAVE_DIRENT_H +#include
+ * We re-implement this function to implement these specific changes: + * 1) strncpy() doesn't always null terminate and we want it to. + * 2) strncpy() null fills, which is bogus, esp. when copy 8byte strings + * into 8k blocks. + * 3) Instead of returning the pointer to the beginning of the + * destination string, we return a pointer to the terminating null + * to allow us to check for truncation. + *+ } +function apr_cpystrn(dst: PChar; const src: PChar; + dst_size: apr_size_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_cpystrn' + LibSuff12; + +{ + * Strip spaces from a string + * @param dest The destination string. It is okay to modify the string + * in place. Namely dest == src + * @param src The string to rid the spaces from. + } +function apr_collapse_spaces(dst: PChar; const src: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_collapse_spaces' + LibSuff8; + +{ + * Convert the arguments to a program from one string to an array of + * strings terminated by a NULL pointer + * @param arg_str The arguments to convert + * @param argv_out Output location. This is a pointer to an array of strings. + * @param token_context Pool to use. + } +function apr_tokenize_to_argv(const arg_str: PChar; + var argv_out: PPChar; token_context: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_tokenize_to_argv' + LibSuff12; + +{ + * Split a string into separate null-terminated tokens. The tokens are + * delimited in the string by one or more characters from the sep + * argument. + * @param str The string to separate; this should be specified on the + * first call to apr_strtok() for a given string, and NULL + * on subsequent calls. + * @param sep The set of delimiters + * @param last Internal state saved by apr_strtok() between calls. + * @return The next token from the string + } +function apr_strtok(str: PChar; + const sep: PChar; last: PPChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strtok' + LibSuff12; + +{ + * @defgroup APR_Strings_Snprintf snprintf implementations + * @warning + * These are snprintf implementations based on apr_vformatter(). + * + * Note that various standards and implementations disagree on the return + * value of snprintf, and side-effects due to %n in the formatting string. + * apr_snprintf (and apr_vsnprintf) behaves as follows: + * + * Process the format string until the entire string is exhausted, or + * the buffer fills. If the buffer fills then stop processing immediately + * (so no further %n arguments are processed), and return the buffer + * length. In all cases the buffer is NUL terminated. It will return the + * number of characters inserted into the buffer, not including the + * terminating NUL. As a special case, if len is 0, apr_snprintf will + * return the number of characters that would have been inserted if + * the buffer had been infinite (in this case, *buffer can be NULL) + * + * In no event does apr_snprintf return a negative number. + * @{ + } + +{ + * snprintf routine based on apr_vformatter. This means it understands the + * same extensions. + * @param buf The buffer to write to + * @param len The size of the buffer + * @param format The format string + * @param ... The arguments to use to fill out the format string. + } +function apr_snprintf(buf: PChar; len: apr_size_t; + const format: PChar; others: array of const): PChar; + cdecl; external LibAPR name 'apr_snprintf'; + +{ + * vsnprintf routine based on apr_vformatter. This means it understands the + * same extensions. + * @param buf The buffer to write to + * @param len The size of the buffer + * @param format The format string + * @param ap The arguments to use to fill out the format string. + } +function apr_vsnprintf(buf: PChar; len: apr_size_t; + const format: PChar; ap: va_list): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_vsnprintf' + LibSuff16; + +{ + * create a string representation of an int, allocated from a pool + * @param p The pool from which to allocate + * @param n The number to format + * @return The string representation of the number + } +function apr_itoa(p: Papr_pool_t; n: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_itoa' + LibSuff8; + +{ + * create a string representation of a long, allocated from a pool + * @param p The pool from which to allocate + * @param n The number to format + * @return The string representation of the number + } +function apr_ltoa(p: Papr_pool_t; n: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ltoa' + LibSuff8; + +{ + * create a string representation of an apr_off_t, allocated from a pool + * @param p The pool from which to allocate + * @param n The number to format + * @return The string representation of the number + } +function apr_off_t_toa(p: Papr_pool_t; n: apr_off_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_off_t_toa' + LibSuff12; + +{ + * parse a numeric string into a 64-bit numeric value + * @param buf The string to parse. It may contain optional whitespace, + * followed by an optional '+' (positive, default) or '-' (negative) + * character, followed by an optional '0x' prefix if base is 0 or 16, + * followed by numeric digits appropriate for base. + * @param end A pointer to the end of the valid character in buf. If + * not nil, it is set to the first invalid character in buf. + * @param base A numeric base in the range between 2 and 36 inclusive, + * or 0. If base is zero, buf will be treated as base ten unless its + * digits are prefixed with '0x', in which case it will be treated as + * base 16. + * @return The numeric value of the string. + } +function apr_strtoi64(const buf: PChar; end_: PPChar; base: Integer): apr_int64_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strtoi64' + LibSuff12; + +{ + * parse a base-10 numeric string into a 64-bit numeric value. + * Equivalent to apr_strtoi64(buf, (char**)NULL, 10). + * @param buf The string to parse + * @return The numeric value of the string + } +function apr_atoi64(const buf: PChar): apr_int64_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_atoi64' + LibSuff4; + +{ + * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an apr_off_t, + * as bytes, K, M, T, etc, to a four character compacted human readable string. + * @param size The size to format + * @param buf The 5 byte text buffer (counting the trailing null) + * @return The buf passed to apr_strfsize() + * @remark All negative sizes report ' - ', apr_strfsize only formats positive values. + } +function apr_strfsize(size: apr_off_t; buf: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strfsize' + LibSuff12; + diff --git a/httpd/httpd_2_2/apr/apr_tables.inc b/httpd/httpd_2_2/apr/apr_tables.inc new file mode 100644 index 000000000..0485f3814 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_tables.inc @@ -0,0 +1,447 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_tables.h + * @brief APR Table library + } + +{ + * @defgroup apr_tables Table and Array Functions + * @ingroup APR + * Tables are used to store entirely opaque structures + * for applications, while Arrays are usually used to + * deal with string lists. + } + +{ the table abstract data type } +type + apr_table_t = record end; + Papr_table_t = ^apr_table_t; + +{ An opaque array type } + apr_array_header_t = record + { The pool the array is allocated out of } + pool: Papr_pool_t; + { The amount of memory allocated for each element of the array } + elt_size: Integer; + { The number of active elements in the array } + nelts: Integer; + { The number of elements allocated in the array } + nalloc: Integer; + { The elements in the array } + elts: PChar; + end; + Papr_array_header_t = ^apr_array_header_t; + PPapr_array_header_t = ^Papr_array_header_t; + +{ + * The (opaque) structure for string-content tables. + } + +{ The type for each entry in a string-content table } + apr_table_entry_t = record + { The key for the current table entry } + key: PChar; { maybe NULL in future; + * check when iterating thru table_elts + } + { The value for the current table entry } + val: PChar; + + { A checksum for the key, for use by the apr_table internals } + key_checksum: apr_uint32_t; + end; + +{ + * Get the elements from a table + * @param t The table + * @return An array containing the contents of the table + } +function apr_table_elts(const t: Papr_table_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_elts' + LibSuff4; + +{ + * Determine if the table is empty + * @param t The table to check + * @return True if empty, False otherwise + } +function apr_is_empty_table(const t: Papr_table_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_is_empty_table' + LibSuff4; + +{ + * Determine if the array is empty + * @param a The array to check + * @return True if empty, False otherwise + } +function apr_is_empty_array(const a: Papr_array_header_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_is_empty_array' + LibSuff4; + +{ + * Create an array + * @param p The pool to allocate the memory out of + * @param nelts the number of elements in the initial array + * @param elt_size The size of each element in the array. + * @return The new array + } +function apr_array_make(p: Papr_pool_t; + nelts, elt_size: Integer): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_make' + LibSuff12; + +{ + * Add a new element to an array + * @param arr The array to add an element to. + * @return Location for the new element in the array. + * @remark If there are no free spots in the array, then this function will + * allocate new space for the new element. + } +function apr_array_push(arr: Papr_array_header_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_push' + LibSuff4; + +{ + * Remove an element from an array + * @param arr The array to remove an element from. + * @return Location of the element in the array. + * @remark If there are no elements in the array, NULL is returned. + } +function apr_array_pop(arr: Papr_array_header_t): Pointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_pop' + LibSuff4; + +{ + * Concatenate two arrays together + * @param dst The destination array, and the one to go first in the combined + * array + * @param src The source array to add to the destination array + } +procedure apr_array_cat(dst: Papr_array_header_t; + const src: Papr_array_header_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_cat' + LibSuff8; + +{ + * Copy the entire array + * @param p The pool to allocate the copy of the array out of + * @param arr The array to copy + * @return An exact copy of the array passed in + * @remark The alternate apr_array_copy_hdr copies only the header, and arranges + * for the elements to be copied if (and only if) the code subsequently + * does a push or arraycat. + } +function apr_array_copy(p: Papr_pool_t; + const arr: Papr_array_header_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_copy' + LibSuff8; + +{ + * Copy the headers of the array, and arrange for the elements to be copied if + * and only if the code subsequently does a push or arraycat. + * @param p The pool to allocate the copy of the array out of + * @param arr The array to copy + * @return An exact copy of the array passed in + * @remark The alternate apr_array_copy copies the *entire* array. + } +function apr_array_copy_hdr(p: Papr_pool_t; + const arr: Papr_array_header_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_copy_hdr' + LibSuff8; + +{ + * Append one array to the end of another, creating a new array in the process. + * @param p The pool to allocate the new array out of + * @param first The array to put first in the new array. + * @param second The array to put second in the new array. + * @return A new array containing the data from the two arrays passed in. +} +function apr_array_append(p: Papr_pool_t; + const first, second: Papr_array_header_t): Papr_array_header_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_append' + LibSuff12; + +{ + * Generates a new string from the apr_pool_t containing the concatenated + * sequence of substrings referenced as elements within the array. The string + * will be empty if all substrings are empty or null, or if there are no + * elements in the array. If sep is non-NUL, it will be inserted between + * elements as a separator. + * @param p The pool to allocate the string out of + * @param arr The array to generate the string from + * @param sep The separator to use + * @return A string containing all of the data in the array. + } +function apr_array_pstrcat(p: Papr_pool_t; + const arr: Papr_array_header_t; sep: Char): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_array_pstrcat' + LibSuff12; + +{ + * Make a new table + * @param p The pool to allocate the pool out of + * @param nelts The number of elements in the initial table. + * @return The new table. + * @warning This table can only store text data + } +function apr_table_make(p: Papr_pool_t; nelts: Integer): Papr_table_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_make' + LibSuff8; + +{ + * Create a new table and copy another table into it + * @param p The pool to allocate the new table out of + * @param t The table to copy + * @return A copy of the table passed in + } +function apr_table_copy(p: Papr_pool_t; const t: Papr_table_t): Papr_table_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_copy' + LibSuff8; + +{ + * Delete all of the elements from a table + * @param t The table to clear + } +procedure apr_table_clear(t: Papr_table_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_clear' + LibSuff4; + +{ + * Get the value associated with a given key from the table. After this call, + * The data is still in the table + * @param t The table to search for the key + * @param key The key to search for + * @return The value associated with the key + } +function apr_table_get(t: Papr_table_t; key: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_get' + LibSuff8; + +{ + * Add a key/value pair to a table, if another element already exists with the + * same key, this will over-write the old data. + * @param t The table to add the data to. + * @param key The key fo use + * @param val The value to add + * @remark When adding data, this function makes a copy of both the key and the + * value. + } +procedure apr_table_set(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_set' + LibSuff12; + +{ + * Add a key/value pair to a table, if another element already exists with the + * same key, this will over-write the old data. + * @param t The table to add the data to. + * @param key The key to use + * @param val The value to add + * @warning When adding data, this function does not make a copy of the key or + * the value, so care should be taken to ensure that the values will + * not change after they have been added.. + } +procedure apr_table_setn(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_setn' + LibSuff12; + +{ + * Remove data from the table + * @param t The table to remove data from + * @param key The key of the data being removed + } +procedure apr_table_unset(t: Papr_table_t; const key: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_unset' + LibSuff8; + +{ + * Add data to a table by merging the value with data that has already been + * stored + * @param t The table to search for the data + * @param key The key to merge data for + * @param val The data to add + * @remark If the key is not found, then this function acts like apr_table_add + } +procedure apr_table_merge(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_merge' + LibSuff12; + +{ + * Add data to a table by merging the value with data that has already been + * stored + * @param t The table to search for the data + * @param key The key to merge data for + * @param val The data to add + * @remark If the key is not found, then this function acts like apr_table_addn + } +procedure apr_table_mergen(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_mergen' + LibSuff12; + +{ + * Add data to a table, regardless of whether there is another element with the + * same key. + * @param t The table to add to + * @param key The key to use + * @param val The value to add. + * @remark When adding data, this function makes a copy of both the key and the + * value. + } +procedure apr_table_add(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_add' + LibSuff12; + +{ + * Add data to a table, regardless of whether there is another element with the + * same key. + * @param t The table to add to + * @param key The key to use + * @param val The value to add. + * @remark When adding data, this function does not make a copy of the key or the + * value, so care should be taken to ensure that the values will not + * change after they have been added.. + } +procedure apr_table_addn(t: Papr_table_t; const key, val: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_addn' + LibSuff12; + +{ + * Merge two tables into one new table + * @param p The pool to use for the new table + * @param overlay The first table to put in the new table + * @param base The table to add at the end of the new table + * @return A new table containing all of the data from the two passed in + } +function apr_table_overlay(t: Papr_table_t; + const overlay, base: Papr_table_t): Papr_table_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_overlay' + LibSuff12; + +{ + * Declaration prototype for the iterator callback function of apr_table_do() + * and apr_table_vdo(). + * @param rec The data passed as the first argument to apr_table_[v]do() + * @param key The key from this iteration of the table + * @param value The value from this iteration of the table + * @remark Iteration continues while this callback function returns non-zero. + * To export the callback function for apr_table_[v]do() it must be declared + * in the _NONSTD convention. + } +type + apr_table_do_callback_fn_t = function (rec: Pointer; + const key, value: PChar): Integer; + + Papr_table_do_callback_fn_t = ^apr_table_do_callback_fn_t; + +{ + * Iterate over a table running the provided function once for every + * element in the table. If there is data passed in as a vararg, then the + * function is only run on those elements whose key matches something in + * the vararg. If the vararg is NULL, then every element is run through the + * function. Iteration continues while the function returns non-zero. + * @param comp The function to run + * @param rec The data to pass as the first argument to the function + * @param t The table to iterate over + * @param ... The vararg. If this is NULL, then all elements in the table are + * run through the function, otherwise only those whose key matches + * are run. + * @return FALSE if one of the comp() iterations returned zero; TRUE if all + * iterations returned non-zero + * @see apr_table_do_callback_fn_t + } +{APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp, + void *rec, const apr_table_t *t, ...); +} +{ + * Iterate over a table running the provided function once for every + * element in the table. If there is data passed in as a vararg, then the + * function is only run on those element's whose key matches something in + * the vararg. If the vararg is NULL, then every element is run through the + * function. Iteration continues while the function returns non-zero. + * @param comp The function to run + * @param rec The data to pass as the first argument to the function + * @param t The table to iterate over + * @param vp The vararg table. If this is NULL, then all elements in the + * table are run through the function, otherwise only those + * whose key matches are run. + * @return FALSE if one of the comp() iterations returned zero; TRUE if all + * iterations returned non-zero + * @see apr_table_do_callback_fn_t + } +function apr_table_vdo(comp: Papr_table_do_callback_fn_t; + rec: Pointer; const t: Papr_table_t; vp: va_list): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_vdo' + LibSuff16; + +const + { flag for overlap to use apr_table_setn } + APR_OVERLAP_TABLES_SET = 0; + { flag for overlap to use apr_table_mergen } + APR_OVERLAP_TABLES_MERGE = 1; + +{ + * For each element in table b, either use setn or mergen to add the data + * to table a. Which method is used is determined by the flags passed in. + * @param a The table to add the data to. + * @param b The table to iterate over, adding its data to table a + * @param flags How to add the table to table a. One of: + * APR_OVERLAP_TABLES_SET Use apr_table_setn + * APR_OVERLAP_TABLES_MERGE Use apr_table_mergen + * @remark This function is highly optimized, and uses less memory and CPU cycles + * than a function that just loops through table b calling other functions. + } +{ + *
+ * Conceptually, apr_table_overlap does this: + * + * apr_array_header_t *barr = apr_table_elts(b); + * apr_table_entry_t *belt = (apr_table_entry_t *)barr->elts; + * int i; + * + * for (i = 0; i < barr->nelts; ++i) ( + * if (flags & APR_OVERLAP_TABLES_MERGE) ( + * apr_table_mergen(a, belt[i].key, belt[i].val); + * ) + * else ( + * apr_table_setn(a, belt[i].key, belt[i].val); + * ) + * ) + * + * Except that it is more efficient (less space and cpu-time) especially + * when b has many elements. + * + * Notice the assumptions on the keys and values in b -- they must be + * in an ancestor of a's pool. In practice b and a are usually from + * the same pool. + *+ } +procedure apr_table_overlap(a: Papr_table_t; + const b: Papr_table_t; flags: cuint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_overlap' + LibSuff12; + +{ + * Eliminate redunandant entries in a table by either overwriting + * or merging duplicates + * + * @param t Table. + * @param flags APR_OVERLAP_TABLES_MERGE to merge, or + * APR_OVERLAP_TABLES_SET to overwrite + } +procedure apr_table_compress(t: Papr_table_t; flags: cuint); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_table_compress' + LibSuff8; + diff --git a/httpd/httpd_2_2/apr/apr_thread_proc.inc b/httpd/httpd_2_2/apr/apr_thread_proc.inc new file mode 100644 index 000000000..c6c5cfadf --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_thread_proc.inc @@ -0,0 +1,845 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_thread_proc.h + * @brief APR Thread and Process Library + } + +{#include "apr.h" +#include "apr_file_io.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#if APR_HAVE_STRUCT_RLIMIT +#include
+ * APR_SHELLCMD -- Anything that the shell can handle + * APR_PROGRAM -- Executable program (default) + * APR_PROGRAM_ENV -- Executable program, copy environment + * APR_PROGRAM_PATH -- Executable program on PATH, copy env + *+ } +function apr_procattr_cmdtype_set(attr: Papr_procattr_t; cmd: apr_cmdtype_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_cmdtype_set' + LibSuff8; + +{ + * Determine if the child should start in detached state. + * @param attr The procattr we care about. + * @param detach Should the child start in detached state? Default is no. + } +function apr_procattr_detach_set(attr: Papr_procattr_t; detach: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_detach_set' + LibSuff8; + +{$ifdef APR_HAVE_STRUCT_RLIMIT} +{ + * Set the Resource Utilization limits when starting a new process. + * @param attr The procattr we care about. + * @param what Which limit to set, one of: + *
+ * APR_LIMIT_CPU + * APR_LIMIT_MEM + * APR_LIMIT_NPROC + * APR_LIMIT_NOFILE + *+ * @param limit Value to set the limit to. + } +function apr_procattr_limit_set(attr: Papr_procattr_t; what: apr_int32_t; + limit: Pointer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_limit_set' + LibSuff12; + +{$endif} + +{ + * Specify an error function to be called in the child process if APR + * encounters an error in the child prior to running the specified program. + * @param attr The procattr describing the child process to be created. + * @param errfn The function to call in the child process. + * @remark At the present time, it will only be called from apr_proc_create() + * on platforms where fork() is used. It will never be called on other + * platforms, on those platforms apr_proc_create() will return the error + * in the parent process rather than invoke the callback in the now-forked + * child process. + } +function apr_procattr_child_errfn_set(attr: Papr_procattr_t; errfn: apr_child_errfn_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_child_errfn_set' + LibSuff8; + +{ + * Specify that apr_proc_create() should do whatever it can to report + * failures to the caller of apr_proc_create(), rather than find out in + * the child. + * @param attr The procattr describing the child process to be created. + * @param chk Flag to indicate whether or not extra work should be done + * to try to report failures to the caller. + * @remark This flag only affects apr_proc_create() on platforms where + * fork() is used. This leads to extra overhead in the calling + * process, but that may help the application handle such + * errors more gracefully. + } +function apr_procattr_error_check_set(attr: Papr_procattr_t; chk: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_error_check_set' + LibSuff8; + +{ + * Determine if the child should start in its own address space or using the + * current one from its parent + * @param attr The procattr we care about. + * @param addrspace Should the child start in its own address space? Default + * is no on NetWare and yes on other platforms. + } +function apr_procattr_addrspace_set(attr: Papr_procattr_t; addrspace: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_procattr_addrspace_set' + LibSuff8; + +{$ifdef APR_HAS_FORK} +{ + * This is currently the only non-portable call in APR. This executes + * a standard unix fork. + * @param proc The resulting process handle. + * @param cont The pool to use. + } +function apr_proc_fork(proc: Papr_proc_t; cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_fork' + LibSuff8; + +{$endif} + +{ + * Create a new process and execute a new program within that process. + * @param new_proc The resulting process handle. + * @param progname The program to run + * @param args the arguments to pass to the new program. The first + * one should be the program name. + * @param env The new environment table for the new process. This + * should be a list of NULL-terminated strings. This argument + * is ignored for APR_PROGRAM_ENV, APR_PROGRAM_PATH, and + * APR_SHELLCMD_ENV types of commands. + * @param attr the procattr we should use to determine how to create the new + * process + * @param cont The pool to use. + } +function apr_proc_create(new_proc: Papr_proc_t; + const progname: PChar; args, arnv: PPChar; + attr: Papr_procattr_t; + cont: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_create' + LibSuff24; + +{ + * Wait for a child process to die + * @param proc The process handle that corresponds to the desired child process + * @param exitcode The returned exit status of the child, if a child process + * dies, or the signal that caused the child to die. + * On platforms that don't support obtaining this information, + * the status parameter will be returned as APR_ENOTIMPL. + * @param exitwhy Why the child died, the bitwise or of: + *
+ * APR_PROC_EXIT -- process terminated normally + * APR_PROC_SIGNAL -- process was killed by a signal + * APR_PROC_SIGNAL_CORE -- process was killed by a signal, and + * generated a core dump. + *+ * @param waithow How should we wait. One of: + *
+ * APR_WAIT -- block until the child process dies. + * APR_NOWAIT -- return immediately regardless of if the + * child is dead or not. + *+ * @remark The childs status is in the return code to this process. It is one of: + *
+ * APR_CHILD_DONE -- child is no longer running. + * APR_CHILD_NOTDONE -- child is still running. + *+ } +function apr_proc_wait(proc: Papr_proc_t; exitcode: PInteger; + exitwhy: Papr_exit_why_e; waithow: apr_wait_how_e): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_wait' + LibSuff16; + +{ + * Wait for any current child process to die and return information + * about that child. + * @param proc Pointer to NULL on entry, will be filled out with child's + * information + * @param exitcode The returned exit status of the child, if a child process + * dies, or the signal that caused the child to die. + * On platforms that don't support obtaining this information, + * the status parameter will be returned as APR_ENOTIMPL. + * @param exitwhy Why the child died, the bitwise or of: + *
+ * APR_PROC_EXIT -- process terminated normally + * APR_PROC_SIGNAL -- process was killed by a signal + * APR_PROC_SIGNAL_CORE -- process was killed by a signal, and + * generated a core dump. + *+ * @param waithow How should we wait. One of: + *
+ * APR_WAIT -- block until the child process dies. + * APR_NOWAIT -- return immediately regardless of if the + * child is dead or not. + *+ * @param p Pool to allocate child information out of. + * @bug Passing proc as a *proc rather than **proc was an odd choice + * for some platforms... this should be revisited in 1.0 + } +function apr_proc_wait_all_procs(proc: Papr_proc_t; exitcode: PInteger; + exitwhy: Papr_exit_why_e; waithow: apr_wait_how_e; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_wait_all_procs' + LibSuff20; + +const + APR_PROC_DETACH_FOREGROUND = 0; {< Do not detach } + APR_PROC_DETACH_DAEMONIZE = 1; {< Detach } + +{ + * Detach the process from the controlling terminal. + * @param daemonize set to non-zero if the process should daemonize + * and become a background process, else it will + * stay in the foreground. + } +{ Not present on the dll } +//function apr_proc_detach(daemonize: Integer): apr_status_t; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPR name LibNamePrefix + 'apr_proc_detach' + LibSuff4; + +{ + * Register an other_child -- a child associated to its registered + * maintence callback. This callback is invoked when the process + * dies, is disconnected or disappears. + * @param proc The child process to register. + * @param maintenance maintenance is a function that is invoked with a + * reason and the data pointer passed here. + * @param data Opaque context data passed to the maintenance function. + * @param write_fd An fd that is probed for writing. If it is ever unwritable + * then the maintenance is invoked with reason + * OC_REASON_UNWRITABLE. + * @param p The pool to use for allocating memory. + * @bug write_fd duplicates the proc->out stream, it's really redundant + * and should be replaced in the APR 1.0 API with a bitflag of which + * proc->in/out/err handles should be health checked. + * @bug no platform currently tests the pipes health. + } +type + maintenance_t = procedure (reason: Integer; param: Pointer; status: Integer); + +procedure apr_proc_other_child_register(proc: Papr_proc_t; + maintenance: maintenance_t; data: Pointer; write_fd: Papr_file_t; + p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_register' + LibSuff20; + +{ + * Stop watching the specified other child. + * @param data The data to pass to the maintenance function. This is + * used to find the process to unregister. + * @warning Since this can be called by a maintenance function while we're + * scanning the other_children list, all scanners should protect + * themself by loading ocr->next before calling any maintenance + * function. + } +procedure apr_proc_other_child_unregister(data: Pointer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_unregister' + LibSuff4; + +{ + * Notify the maintenance callback of a registered other child process + * that application has detected an event, such as death. + * @param proc The process to check + * @param reason The reason code to pass to the maintenance function + * @param status The status to pass to the maintenance function + * @remark An example of code using this behavior; + *
+ * rv = apr_proc_wait_all_procs(&proc, &exitcode, &status, APR_WAIT, p); + * if (APR_STATUS_IS_CHILD_DONE(rv)) ( + * #if APR_HAS_OTHER_CHILD + * if (apr_proc_other_child_alert(&proc, APR_OC_REASON_DEATH, status) + * == APR_SUCCESS) ( + * ; (already handled) + * ) + * else + * #endif + * [... handling non-otherchild processes death ...] + *+ } +function apr_proc_other_child_alert(proc: Papr_proc_t; + reason, status: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_alert' + LibSuff12; + +{ + * Test one specific other child processes and invoke the maintenance callback + * with the appropriate reason code, if still running, or the appropriate reason + * code if the process is no longer healthy. + * @param ocr The registered other child + * @param reason The reason code (e.g. APR_OC_REASON_RESTART) if still running + } +procedure apr_proc_other_child_refresh(ocr: Papr_other_child_rec_t; reason: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_refresh' + LibSuff8; + +{ + * Test all registered other child processes and invoke the maintenance callback + * with the appropriate reason code, if still running, or the appropriate reason + * code if the process is no longer healthy. + * @param reason The reason code (e.g. APR_OC_REASON_RESTART) to running processes + } +procedure apr_proc_other_child_refresh_all(reason: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_refresh_all' + LibSuff4; + +{ @deprecated @see apr_proc_other_child_refresh_all + * @remark Call apr_proc_other_child_refresh_all(APR_OC_REASON_RESTART) + * or apr_proc_other_child_refresh_all(APR_OC_REASON_RUNNING) instead. + * @bug The differing implementations of this function on Win32 (_RUNNING checks) + * and Unix (used only for _RESTART) are the reason it will be dropped with APR 1.0. + } +procedure apr_proc_other_child_check; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_check' + LibSuff0; + +{ @deprecated @see apr_proc_other_child_alert + * @bug This function's name had nothing to do with it's purpose + } +function apr_proc_other_child_read(proc: Papr_proc_t; status: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_other_child_read' + LibSuff8; + +{ + * Terminate a process. + * @param proc The process to terminate. + * @param sig How to kill the process. + } +function apr_proc_kill(proc: Papr_proc_t; sig: Integer): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_proc_kill' + LibSuff8; + +{ + * Register a process to be killed when a pool dies. + * @param a The pool to use to define the processes lifetime + * @param proc The process to register + * @param how How to kill the process, one of: + *
+ * APR_KILL_NEVER -- process is never sent any signals + * APR_KILL_ALWAYS -- process is sent SIGKILL on apr_pool_t cleanup + * APR_KILL_AFTER_TIMEOUT -- SIGTERM, wait 3 seconds, SIGKILL + * APR_JUST_WAIT -- wait forever for the process to complete + * APR_KILL_ONLY_ONCE -- send SIGTERM and then wait + *+ } +procedure apr_pool_note_subprocess(a: Papr_pool_t; + proc: Papr_proc_t; how: apr_kill_conditions_e); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_pool_note_subprocess' + LibSuff12; + +{.$ifdef APR_HAS_THREADS} + +{$if (defined(APR_HAVE_SIGWAIT) or defined(APR_HAVE_SIGSUSPEND)) and not defined(OS2)} + +{ + * Setup the process for a single thread to be used for all signal handling. + * @warning This must be called before any threads are created + } +function apr_setup_signal_thread: apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_setup_signal_thread' + LibSuff0; + +{ + * Make the current thread listen for signals. This thread will loop + * forever, calling a provided function whenever it receives a signal. That + * functions should return 1 if the signal has been handled, 0 otherwise. + * @param signal_handler The function to call when a signal is received + * apr_status_t apr_signal_thread((int)( *signal_handler)(int signum)) + } +type + signal_handler_t = function (signum: Integer): Integer; + +function apr_signal_thread(signal_handler: signal_handler_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_signal_thread' + LibSuff8; + +{$endif} { (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) } + +{ + * Get the child-pool used by the thread from the thread info. + * @return apr_pool_t the pool + } +//APR_POOL_DECLARE_ACCESSOR(thread); + +//#endif { APR_HAS_THREADS } + diff --git a/httpd/httpd_2_2/apr/apr_time.inc b/httpd/httpd_2_2/apr/apr_time.inc new file mode 100644 index 000000000..929d6930d --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_time.inc @@ -0,0 +1,262 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_time.h + * @brief APR Time Library + } + +{#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h"} + +{ + * @defgroup apr_time Time Routines + * @ingroup APR + } + +{ month names } +//APR_DECLARE_DATA extern const char apr_month_snames[12][4]; +{ day names } +//APR_DECLARE_DATA extern const char apr_day_snames[7][4]; + + +{ number of microseconds since 00:00:00 january 1, 1970 UTC } +type + apr_time_t = apr_int64_t; + Papr_time_t = ^apr_time_t; + + +{ mechanism to properly type apr_time_t literals } +//#define APR_TIME_C(val) APR_INT64_C(val) + +{ mechanism to properly print apr_time_t values } +// APR_TIME_T_FMT = APR_INT64_T_FMT; + +{ intervals for I/O timeouts, in microseconds } + apr_interval_time_t = apr_int64_t; + Papr_interval_time_t = ^apr_interval_time_t; +{ short interval for I/O timeouts, in microseconds } + apr_short_interval_time_t = apr_int32_t; + +{ number of microseconds per second } +// APR_USEC_PER_SEC APR_TIME_C(1000000) + +{ @return apr_time_t as a second } +//#define apr_time_sec(time) ((time) / APR_USEC_PER_SEC) + +{ @return apr_time_t as a usec } +//#define apr_time_usec(time) ((time) % APR_USEC_PER_SEC) + +{ @return apr_time_t as a msec } +//#define apr_time_msec(time) (((time) / 1000) % 1000) + +{ @return apr_time_t as a msec } +//#define apr_time_as_msec(time) ((time) / 1000) + +{ @return a second as an apr_time_t } +//#define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC) + +{ @return a second and usec combination as an apr_time_t } +//#define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \ +// + (apr_time_t)(usec)) + +{ + * @return the current time + } +function apr_time_now: apr_time_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_now' + LibSuff0; + +{ @see apr_time_exp_t } +type + Papr_time_exp_t = ^apr_time_exp_t; + +{ + * a structure similar to ANSI struct tm with the following differences: + * - tm_usec isn't an ANSI field + * - tm_gmtoff isn't an ANSI field (it's a bsdism) + } + apr_time_exp_t = record + { microseconds past tm_sec } + tm_usec: apr_int32_t; + { (0-61) seconds past tm_min } + tm_sec: apr_int32_t; + { (0-59) minutes past tm_hour } + tm_min: apr_int32_t; + { (0-23) hours past midnight } + tm_hour: apr_int32_t; + { (1-31) day of the month } + tm_mday: apr_int32_t; + { (0-11) month of the year } + tm_mon: apr_int32_t; + { year since 1900 } + tm_year: apr_int32_t; + { (0-6) days since sunday } + tm_wday: apr_int32_t; + { (0-365) days since jan 1 } + tm_yday: apr_int32_t; + { daylight saving time } + tm_isdst: apr_int32_t; + { seconds east of UTC } + tm_gmtoff: apr_int32_t; + end; + +{ + * convert an ansi time_t to an apr_time_t + * @param result the resulting apr_time_t + * @param input the time_t to convert + } +function apr_time_ansi_put(result: Papr_time_t; + input: time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_ansi_put' + LibSuff8; + +{ + * convert a time to its human readable components using an offset + * from GMT + * @param result the exploded time + * @param input the time to explode + * @param offs the number of seconds offset to apply + } +function apr_time_exp_tz(result: Papr_time_exp_t; + input: apr_time_t; offs: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_tz' + LibSuff16; + +{ @deprecated @see apr_time_exp_tz } +function apr_explode_time(result: Papr_time_exp_t; + input: apr_time_t; offs: apr_int32_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_explode_time' + LibSuff16; + +{ + * convert a time to its human readable components in GMT timezone + * @param result the exploded time + * @param input the time to explode + } +function apr_time_exp_gmt(result: Papr_time_exp_t; + input: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_gmt' + LibSuff12; + +{ + * convert a time to its human readable components in local timezone + * @param result the exploded time + * @param input the time to explode + } +function apr_time_exp_lt(result: Papr_time_exp_t; + input: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_lt' + LibSuff12; + +{ @deprecated @see apr_time_exp_lt } +function apr_explode_localtime(result: Papr_time_exp_t; + input: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_explode_localtime' + LibSuff12; + +{ + * Convert time value from human readable format to a numeric apr_time_t + * e.g. elapsed usec since epoch + * @param result the resulting imploded time + * @param input the input exploded time + } +function apr_time_exp_get(result: Papr_time_t; + input: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_get' + LibSuff8; + +{ + * Convert time value from human readable format to a numeric apr_time_t that + * always represents GMT + * @param result the resulting imploded time + * @param input the input exploded time + } +function apr_time_exp_gmt_get(result: Papr_time_t; + input: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_exp_gmt_get' + LibSuff8; + +{ @deprecated @see apr_time_exp_gmt_get } +function apr_implode_gmt(result: Papr_time_t; + input: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_implode_gmt' + LibSuff8; + +{ + * Sleep for the specified number of micro-seconds. + * @param t desired amount of time to sleep. + * @warning May sleep for longer than the specified time. + } +procedure apr_sleep(t: apr_interval_time_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_sleep' + LibSuff8; + +{ length of a RFC822 Date } +const APR_RFC822_DATE_LEN = (30); +{ + * apr_rfc822_date formats dates in the RFC822 + * format in an efficient manner. It is a fixed length + * format which requires the indicated amount of storage, + * including the trailing null byte. + * @param date_str String to write to. + * @param t the time to convert + } +function apr_rfc822_date(date_str: PChar; t: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_rfc822_date' + LibSuff12; + +{ length of a CTIME date } +const APR_CTIME_LEN = (25); +{ + * apr_ctime formats dates in the ctime() format + * in an efficient manner. it is a fixed length format + * and requires the indicated amount of storage including + * the trailing null byte. + * Unlike ANSI/ISO C ctime(), apr_ctime() does not include + * a \n at the end of the string. + * @param date_str String to write to. + * @param t the time to convert + } +function apr_ctime(date_str: PChar; t: apr_time_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_ctime' + LibSuff12; + +{ + * formats the exploded time according to the format specified + * @param s string to write to + * @param retsize The length of the returned string + * @param max The maximum length of the string + * @param format The format for the time string + * @param tm The time to convert + } +function apr_strftime(s: PChar; retsize: apr_size_t; + max: apr_size_t; const format: PChar; + tm: Papr_time_exp_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_strftime' + LibSuff20; + +{ + * Improve the clock resolution for the lifetime of the given pool. + * Generally this is only desireable on benchmarking and other very + * time-sensitive applications, and has no impact on most platforms. + * @param p The pool to associate the finer clock resolution + } +procedure apr_time_clock_hires(p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_time_clock_hires' + LibSuff4; + diff --git a/httpd/httpd_2_2/apr/apr_user.inc b/httpd/httpd_2_2/apr/apr_user.inc new file mode 100644 index 000000000..39d496dd8 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_user.inc @@ -0,0 +1,197 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + * @file apr_user.h + * @brief APR User ID Services + } + +{#include "apr.h" +#include "apr_errno.h" +#include "apr_pools.h"} + +{ + * @defgroup apr_user User and Group ID Services + * @ingroup APR + } + +{ + * Structure for determining user ownership. + } +type +{$ifdef WIN32} + apr_uid_t = PSID; +{$else} + apr_uid_t = uid_t; +{$endif} + + Papr_uid_t = ^apr_uid_t; + +{ + * Structure for determining group ownership. + } +{$ifdef WIN32} + apr_gid_t = PSID; +{$else} + apr_gid_t = gid_t; +{$endif} + + Papr_gid_t = ^apr_gid_t; + +{$define APR_HAS_USER} + +{$ifdef APR_HAS_USER} + +{ + * Get the userid (and groupid) of the calling process + * @param userid Returns the user id + * @param groupid Returns the user's group id + * @param p The pool from which to allocate working space + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_current(userid: Papr_uid_t; groupid: Papr_gid_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_current' + LibSuff12; + +{ @deprecated @see apr_uid_current } +{APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid, + apr_gid_t *groupid, + apr_pool_t *p);} +{ + * Get the user name for a specified userid + * @param username Pointer to new string containing user name (on output) + * @param userid The userid + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_name_get(username: PPChar; userid: apr_uid_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_name_get' + LibSuff12; + +{ @deprecated @see apr_uid_name_get } +{APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, + apr_pool_t *p);} +{ + * Get the userid (and groupid) for the specified username + * @param userid Returns the user id + * @param groupid Returns the user's group id + * @param username The username to lookup + * @param p The pool from which to allocate working space + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_get(userid: Papr_uid_t; groupid: Papr_gid_t; + const username: PChar; p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_get' + LibSuff16; + +{ @deprecated @see apr_uid_get } +{APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid, + const char *username, apr_pool_t *p);} + +{ + * Get the home directory for the named user + * @param dirname Pointer to new string containing directory name (on output) + * @param username The named user + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_uid_homepath_get(dirname: PPChar; const username: PChar; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_uid_homepath_get' + LibSuff12; + +{ @deprecated @see apr_uid_homepath_get } +{APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, + const char *username, + apr_pool_t *p);} + +{ + * Compare two user identifiers for equality. + * @param left One uid to test + * @param right Another uid to test + * @return APR_SUCCESS if the apr_uid_t strutures identify the same user, + * 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} +//APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); + +{ @deprecated @see apr_uid_compare } +//APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right); +{$else} +//#define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{ @deprecated @see apr_uid_compare } +//#define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{$endif} + +{ + * Get the group name for a specified groupid + * @param groupname Pointer to new string containing group name (on output) + * @param groupid The groupid + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_gid_name_get(groupname: PPChar; groupid: apr_gid_t; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_gid_name_get' + LibSuff12; + +{ @deprecated @see apr_gid_name_get } +{APR_DECLARE(apr_status_t) apr_group_name_get(char **groupname, + apr_gid_t groupid, apr_pool_t *p);} + +{ @deprecated @see apr_gid_name_get } +{APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, + apr_gid_t groupid, apr_pool_t *p);} + +{ + * Get the groupid for a specified group name + * @param groupid Pointer to the group id (on output) + * @param groupname The group name to look up + * @param p The pool from which to allocate the string + * @remark This function is available only if APR_HAS_USER is defined. + } +function apr_gid_get(groupid: Papr_gid_t; const groupname: PChar; + p: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_gid_get' + LibSuff12; + +{ @deprecated @see apr_gid_get } +{APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid, + const char *groupname, apr_pool_t *p);} + +{ + * Compare two group identifiers for equality. + * @param left One gid to test + * @param right Another gid to test + * @return APR_SUCCESS if the apr_gid_t strutures identify the same group, + * 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} +//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); +{$else} +//#define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{ @deprecated @see apr_gid_compare } +//#define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) +{$endif} + +{$endif} { ! APR_HAS_USER } + diff --git a/httpd/httpd_2_2/apr/apr_version.inc b/httpd/httpd_2_2/apr/apr_version.inc new file mode 100644 index 000000000..0b6423298 --- /dev/null +++ b/httpd/httpd_2_2/apr/apr_version.inc @@ -0,0 +1,112 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr.h" + +{ + * @file apr_version.h + * @brief APR Versioning Interface + * + * APR's Version + * + * There are several different mechanisms for accessing the version. There + * is a string form, and a set of numbers; in addition, there are constants + * which can be compiled into your application, and you can query the library + * being used for its actual version. + * + * Note that it is possible for an application to detect that it has been + * compiled against a different version of APR by use of the compile-time + * constants and the use of the run-time query function. + * + * APR version numbering follows the guidelines specified in: + * + * http://apr.apache.org/versioning.html + } + +{ The numeric compile-time version constants. These constants are the + * authoritative version numbers for APR. + } + +{ major version + * Major API changes that could cause compatibility problems for older + * programs such as structure size changes. No binary compatibility is + * possible across a change in the major version. + } +const + APR_MAJOR_VERSION = 0; + +{ + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading APR_MAJOR_VERSION + } + APR_MINOR_VERSION = 9; + +{ patch level } + APR_PATCH_VERSION = 12; + +{ + * This symbol is defined for internal, "development" copies of APR. This + * symbol will be #undef'd for releases. + } +{.$undef APR_IS_DEV_VERSION} + + +{ The formatted string of APR's version } +{#define APR_VERSION_STRING \ + APR_STRINGIFY(APR_MAJOR_VERSION) "." \ + APR_STRINGIFY(APR_MINOR_VERSION) "." \ + APR_STRINGIFY(APR_PATCH_VERSION) \ + APR_IS_DEV_STRING} + + +{ + * The numeric version information is broken out into fields within this + * structure. + } +type + apr_version_t = record + major: Integer; {< major number } + minor: Integer; {< minor number } + patch: Integer; {< patch number } + is_dev: Integer; {< is development (1 or 0) } + end; + + Papr_version_t = ^apr_version_t; + +{ + * Return APR's version information information in a numeric form. + * + * @param pvsn Pointer to a version structure for returning the version + * information. + } +procedure apr_version(pvsn: Papr_version_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_version' + LibSuff4; + +{ Return APR's version information as a string. } +function apr_version_string: PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPR name LibNamePrefix + 'apr_version_string' + LibSuff0; + + +{ Internal: string form of the "is dev" flag } +{#ifdef APR_IS_DEV_VERSION +#define APR_IS_DEV_STRING "-dev" +#else} +const + APR_IS_DEV_STRING = ''; +//#endif + diff --git a/httpd/httpd_2_2/apriconv/api_version.inc b/httpd/httpd_2_2/apriconv/api_version.inc new file mode 100644 index 000000000..e92d5e83f --- /dev/null +++ b/httpd/httpd_2_2/apriconv/api_version.inc @@ -0,0 +1,99 @@ +{ Copyright 2000-2004 The Apache Software Foundation + * + * Licensed 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. + } + +{#include "apr.h" +#include "apr_version.h" + +#include "apr_iconv.h"} + +{ + * @file api_version.h + * @brief + * + * APR-iconv's Version + * + * There are several different mechanisms for accessing the version. There + * is a string form, and a set of numbers; in addition, there are constants + * which can be compiled into your application, and you can query the library + * being used for its actual version. + * + * Note that it is possible for an application to detect that it has been + * compiled against a different version of API by use of the compile-time + * constants and the use of the run-time query function. + * + * API version numbering follows the guidelines specified in: + * + * http://apr.apache.org/versioning.html + } + +{ The numeric compile-time version constants. These constants are the + * authoritative version numbers for API. + } + +{ major version + * Major API changes that could cause compatibility problems for older + * programs such as structure size changes. No binary compatibility is + * possible across a change in the major version. + } +const + API_MAJOR_VERSION = 0; + +{ + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading API_MAJOR_VERSION + } + API_MINOR_VERSION = 9; + +{ patch level } + API_PATCH_VERSION = 7; + +{ + * This symbol is defined for internal, "development" copies of API. This + * symbol will be #undef'd for releases. + } +{ #define API_IS_DEV_VERSION } + + +{ The formatted string of API's version } +{#define API_VERSION_STRING \ + APR_STRINGIFY(API_MAJOR_VERSION) "." \ + APR_STRINGIFY(API_MINOR_VERSION) "." \ + APR_STRINGIFY(API_PATCH_VERSION) \ + API_IS_DEV_STRING} + +{ + * Return APR-util's version information information in a numeric form. + * + * @param pvsn Pointer to a version structure for returning the version + * information. + } +//procedure api_version(pvsn: Papr_version_t); +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPRIconv name LibNamePrefix + 'api_version' + LibSuff4; + +{ Return API's version information as a string. } +//function api_version_string: PChar; +// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} +// external LibAPRIconv name LibNamePrefix + 'api_version_string' + LibSuff0; + + +{ Internal: string form of the "is dev" flag } +const +{$ifdef API_IS_DEV_VERSION} + API_IS_DEV_STRING = '-dev'; +{$else} + API_IS_DEV_STRING = ''; +{$endif} + diff --git a/httpd/httpd_2_2/apriconv/apr_iconv.inc b/httpd/httpd_2_2/apriconv/apr_iconv.inc new file mode 100644 index 000000000..6550e1766 --- /dev/null +++ b/httpd/httpd_2_2/apriconv/apr_iconv.inc @@ -0,0 +1,113 @@ +{- + * Copyright (c) 1999,2000 + * Konstantin Chuguev. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Konstantin Chuguev + * and its contributors. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + } + +{#include "apr.h" +#include "apr_pools.h" +#include
+ * APR_URI_UNP_OMITSITEPART Suppress "scheme://user\@site:port" + * APR_URI_UNP_OMITUSER Just omit user + * APR_URI_UNP_OMITPASSWORD Just omit password + * APR_URI_UNP_OMITUSERINFO Omit "user:password\@" part + * APR_URI_UNP_REVEALPASSWORD Show plain text password (default: show XXXXXXXX) + * APR_URI_UNP_OMITPATHINFO Show "scheme://user\@site:port" only + * APR_URI_UNP_OMITQUERY Omit "?queryarg" or "#fragment" + *+ * @return The uri as a string + } +function apr_uri_unparse(p: Papr_pool_t; const uptr: Papr_uri_t; + flags: cuint): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_uri_unparse' + LibSuff12; + +{ + * Parse a given URI, fill in all supplied fields of a apr_uri_t + * structure. This eliminates the necessity of extracting host, port, + * path, query info repeatedly in the modules. + * @param p The pool to allocate out of + * @param uri The uri to parse + * @param uptr The apr_uri_t to fill out + * @return APR_SUCCESS for success or error code + } +function apr_uri_parse(p: Papr_pool_t; const uri: PChar; + uptr: Papr_uri_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_uri_parse' + LibSuff12; + +{ + * Special case for CONNECT parsing: it comes with the hostinfo part only + * @param p The pool to allocate out of + * @param hostinfo The hostinfo string to parse + * @param uptr The apr_uri_t to fill out + * @return APR_SUCCESS for success or error code + } +function apr_uri_parse_hostinfo(p: Papr_pool_t; + const hostinfo: PChar; uptr: Papr_uri_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_uri_parse_hostinfo' + LibSuff12; + diff --git a/httpd/httpd_2_2/aprutil/apr_xlate.inc b/httpd/httpd_2_2/aprutil/apr_xlate.inc new file mode 100644 index 000000000..7ecd65b69 --- /dev/null +++ b/httpd/httpd_2_2/aprutil/apr_xlate.inc @@ -0,0 +1,152 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{#include "apu.h" +#include "apr_pools.h" +#include "apr_errno.h"} + +{ + * @file apr_xlate.h + * @brief APR I18N translation library + } + +{ + * @defgroup APR_XLATE I18N translation library + * @ingroup APR + } +{ Opaque translation buffer } +type + Papr_xlate_t = Pointer; + PPapr_xlate_t = ^Papr_xlate_t; + +{ + * Set up for converting text from one charset to another. + * @param convset The handle to be filled in by this function + * @param topage The name of the target charset + * @param frompage The name of the source charset + * @param pool The pool to use + * @remark + * Specify APR_DEFAULT_CHARSET for one of the charset + * names to indicate the charset of the source code at + * compile time. This is useful if there are literal + * strings in the source code which must be translated + * according to the charset of the source code. + * APR_DEFAULT_CHARSET is not useful if the source code + * of the caller was not encoded in the same charset as + * APR at compile time. + * + * @remark + * Specify APR_LOCALE_CHARSET for one of the charset + * names to indicate the charset of the current locale. + * + * @remark + * Return APR_EINVAL if unable to procure a convset, or APR_ENOTIMPL + * if charset transcoding is not available in this instance of + * apr-util at all (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_open(convset: PPapr_xlate_t; + const topage, frompage: PChar; pool: Papr_pool_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_open' + LibSuff16; + +{ + * This is to indicate the charset of the sourcecode at compile time + * names to indicate the charset of the source code at + * compile time. This is useful if there are literal + * strings in the source code which must be translated + * according to the charset of the source code. + } +//#define APR_DEFAULT_CHARSET (const char *)0 +{ + * To indicate charset names of the current locale + } +//#define APR_LOCALE_CHARSET (const char *)1 + +{ + * Find out whether or not the specified conversion is single-byte-only. + * @param convset The handle allocated by apr_xlate_open, specifying the + * parameters of conversion + * @param onoff Output: whether or not the conversion is single-byte-only + * @remark + * Return APR_ENOTIMPL if charset transcoding is not available + * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_sb_get(convset: Papr_xlate_t; onoff: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_sb_get' + LibSuff8; + +{ @deprecated @see apr_xlate_sb_get } +function apr_xlate_get_sb(convset: Papr_xlate_t; onoff: PInteger): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_get_sb' + LibSuff8; + +{ + * Convert a buffer of text from one codepage to another. + * @param convset The handle allocated by apr_xlate_open, specifying + * the parameters of conversion + * @param inbuf The address of the source buffer + * @param inbytes_left Input: the amount of input data to be translated + * Output: the amount of input data not yet translated + * @param outbuf The address of the destination buffer + * @param outbytes_left Input: the size of the output buffer + * Output: the amount of the output buffer not yet used + * @remark + * Return APR_ENOTIMPL if charset transcoding is not available + * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_conv_buffer(convset: Papr_xlate_t; const inbuf: PChar; + inbytes_left: Papr_size_t; outbuf: PChar; outbytes_left: Papr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_buffer' + LibSuff20; + +{ @see apr_file_io.h the comment in apr_file_io.h about this hack } +{$ifdef APR_NOT_DONE_YET} +{ + * The purpose of apr_xlate_conv_char is to translate one character + * at a time. This needs to be written carefully so that it works + * with double-byte character sets. + * @param convset The handle allocated by apr_xlate_open, specifying the + * parameters of conversion + * @param inchar The character to convert + * @param outchar The converted character + } +APU_DECLARE(apr_status_t) apr_xlate_conv_char(apr_xlate_t *convset, + char inchar, char outchar); +{$endif} + +{ + * Convert a single-byte character from one charset to another. + * @param convset The handle allocated by apr_xlate_open, specifying the + * parameters of conversion + * @param inchar The single-byte character to convert. + * @warning This only works when converting between single-byte character sets. + * -1 will be returned if the conversion can't be performed. + } +function apr_xlate_conv_byte(convset: Papr_xlate_t; inchar: Char): apr_int32_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_byte' + LibSuff8; + +{ + * Close a codepage translation handle. + * @param convset The codepage translation handle to close + * @remark + * Return APR_ENOTIMPL if charset transcoding is not available + * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined). + } +function apr_xlate_close(convset: Papr_xlate_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xlate_close' + LibSuff4; + diff --git a/httpd/httpd_2_2/aprutil/apr_xml.inc b/httpd/httpd_2_2/aprutil/apr_xml.inc new file mode 100644 index 000000000..9c5a7ecad --- /dev/null +++ b/httpd/httpd_2_2/aprutil/apr_xml.inc @@ -0,0 +1,349 @@ +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +{ + * @file apr_xml.h + * @brief APR-UTIL XML Library + } + +{ + * @defgroup APR_Util_XML XML + * @ingroup APR_Util + } +{#include "apr_pools.h" +#include "apr_tables.h" +#include "apr_file_io.h" + +#include "apu.h"} + +{ + * @package Apache XML library + } + +{ -------------------------------------------------------------------- } + +{ ### these will need to move at some point to a more logical spot } + +{ @see apr_text } +type + Papr_text = ^apr_text; + + { Structure to keep a linked list of pieces of text } + + apr_text = record + { The current piece of text } + text: PChar; + { a pointer to the next piece of text } + next: Papr_text; + end; + +{ @see apr_text_header } + Papr_text_header = ^apr_text_header; + +{ A list of pieces of text } + apr_text_header = record + { The first piece of text in the list } + first: Papr_text; + { The last piece of text in the list } + last: Papr_text; + end; + +{ + * Append a piece of text to the end of a list + * @param p The pool to allocate out of + * @param hdr The text header to append to + * @param text The new text to append + } +procedure apr_text_append(p: Papr_pool_t; hdr: Papr_text_header; + const text: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_text_append' + LibSuff12; + +{ -------------------------------------------------------------------- +** +** XML PARSING +} + +{ +** Qualified namespace values +** +** APR_XML_NS_DAV_ID +** We always insert the "DAV:" namespace URI at the head of the +** namespace array. This means that it will always be at ID==0, +** making it much easier to test for. +** +** APR_XML_NS_NONE +** This special ID is used for two situations: +** +** 1) The namespace prefix begins with "xml" (and we do not know +** what it means). Namespace prefixes with "xml" (any case) as +** their first three characters are reserved by the XML Namespaces +** specification for future use. mod_dav will pass these through +** unchanged. When this identifier is used, the prefix is LEFT in +** the element/attribute name. Downstream processing should not +** prepend another prefix. +** +** 2) The element/attribute does not have a namespace. +** +** a) No prefix was used, and a default namespace has not been +** defined. +** b) No prefix was used, and the default namespace was specified +** to mean "no namespace". This is done with a namespace +** declaration of: xmlns="" +** (this declaration is typically used to override a previous +** specification for the default namespace) +** +** In these cases, we need to record that the elem/attr has no +** namespace so that we will not attempt to prepend a prefix. +** All namespaces that are used will have a prefix assigned to +** them -- mod_dav will never set or use the default namespace +** when generating XML. This means that "no prefix" will always +** mean "no namespace". +** +** In both cases, the XML generation will avoid prepending a prefix. +** For the first case, this means the original prefix/name will be +** inserted into the output stream. For the latter case, it means +** the name will have no prefix, and since we never define a default +** namespace, this means it will have no namespace. +** +** Note: currently, mod_dav understands the "xmlns" prefix and the +** "xml:lang" attribute. These are handled specially (they aren't +** left within the XML tree), so the APR_XML_NS_NONE value won't ever +** really apply to these values. +} +const + APR_XML_NS_DAV_ID = 0; {< namespace ID for "DAV:" } + APR_XML_NS_NONE = -10; {< no namespace for this elem/attr } + + APR_XML_NS_ERROR_BASE = -100; {< used only during processing } +{ Is this namespace an error? } +// APR_XML_NS_IS_ERROR(e) ((e) <= APR_XML_NS_ERROR_BASE) + +type +{ @see apr_xml_attr } + Papr_xml_attr = ^apr_xml_attr; +{ @see apr_xml_elem } + Papr_xml_elem = ^apr_xml_elem; +{ @see apr_xml_doc } + Papr_xml_doc = ^apr_xml_doc; + PPapr_xml_doc = ^Papr_xml_doc; + +{ apr_xml_attr: holds a parsed XML attribute } + apr_xml_attr = record + { attribute name } + name: PChar; + { index into namespace array } + ns: Integer; + + { attribute value } + value: PChar; + + { next attribute } + next: Papr_xml_attr; + end; + +{ apr_xml_elem: holds a parsed XML element } + apr_xml_elem = record + { element name } + name: PChar; + { index into namespace array } + ns: Integer; + { xml:lang for attrs/contents } + lang: PChar; + + { cdata right after start tag } + first_cdata: apr_text_header; + { cdata after MY end tag } + following_cdata: apr_text_header; + + { parent element } + parent: Papr_xml_elem; + { next (sibling) element } + next: Papr_xml_elem; + { first child element } + first_child: Papr_xml_elem; + { first attribute } + attr: Papr_xml_attr; + + { used only during parsing } + { last child element } + last_child: Papr_xml_elem; + { namespaces scoped by this elem } + ns_scope: Papr_xml_ns_scope; + + { used by modules during request processing } + { Place for modules to store private data } + priv: Pointer; + end; + +{ Is this XML element empty? } +//#define APR_XML_ELEM_IS_EMPTY(e) ((e)->first_child == NULL && \ +// (e)->first_cdata.first == NULL) + +{ apr_xml_doc: holds a parsed XML document } + apr_xml_doc = record + { root element } + root: Papr_xml_elem; + { array of namespaces used } + namespaces: Papr_array_header_t; + end; + +{ Opaque XML parser structure } + apr_xml_parser = record end; + Papr_xml_parser = ^apr_xml_parser; + PPapr_xml_parser = ^Papr_xml_parser; + +{ + * Create an XML parser + * @param pool The pool for allocating the parser and the parse results. + * @return The new parser. + } +function apr_xml_parser_create(pool: Papr_pool_t): Papr_xml_parser; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_create' + LibSuff4; + +{ + * Parse a File, producing a xml_doc + * @param p The pool for allocating the parse results. + * @param parser A pointer to *parser (needed so calling function can get + * errors), will be set to NULL on successfull completion. + * @param ppdoc A pointer to *apr_xml_doc (which has the parsed results in it) + * @param xmlfd A file to read from. + * @param buffer_length Buffer length which would be suitable + * @return Any errors found during parsing. + } +function apr_xml_parse_file(p: Papr_pool_t; + parser: PPapr_xml_parser; ppdoc: PPapr_xml_doc; + xmlfd: Papr_file_t; buffer_length: apr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parse_file' + LibSuff20; + +{ + * Feed input into the parser + * @param parser The XML parser for parsing this data. + * @param data The data to parse. + * @param len The length of the data. + * @return Any errors found during parsing. + * @remark Use apr_xml_parser_geterror() to get more error information. + } +function apr_xml_parser_feed(parser: Papr_xml_parser; + const data: PChar; len: apr_size_t): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_feed' + LibSuff12; + +{ + * Terminate the parsing and return the result + * @param parser The XML parser for parsing this data. + * @param pdoc The resulting parse information. May be NULL to simply + * terminate the parsing without fetching the info. + * @return Any errors found during the final stage of parsing. + * @remark Use apr_xml_parser_geterror() to get more error information. + } +function apr_xml_parser_done(parser: Papr_xml_parser; + pdoc: PPapr_xml_doc): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_done' + LibSuff8; + +{ + * Fetch additional error information from the parser. + * @param parser The XML parser to query for errors. + * @param errbuf A buffer for storing error text. + * @param errbufsize The length of the error text buffer. + * @return The error buffer + } +function apr_xml_parser_geterror(parser: Papr_xml_parser; + errbuf: PChar; errbufsize: apr_size_t): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_geterror' + LibSuff12; + +{ + * Converts an XML element tree to flat text + * @param p The pool to allocate out of + * @param elem The XML element to convert + * @param style How to covert the XML. One of: + *
+ * APR_XML_X2T_FULL start tag, contents, end tag + * APR_XML_X2T_INNER contents only + * APR_XML_X2T_LANG_INNER xml:lang + inner contents + * APR_XML_X2T_FULL_NS_LANG FULL + ns defns + xml:lang + *+ * @param namespaces The namespace of the current XML element + * @param ns_map Namespace mapping + * @param pbuf Buffer to put the converted text into + * @param psize Size of the converted text + } +procedure apr_xml_to_text(p: Papr_pool_t; const elem: Papr_xml_elem; + style: Integer; namespaces: Papr_array_header_t; + ns_map: PInteger; const pbuf: PPChar; psize: Papr_size_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_to_text' + LibSuff28; + +{ style argument values: } +const + APR_XML_X2T_FULL = 0; {< start tag, contents, end tag } + APR_XML_X2T_INNER = 1; {< contents only } + APR_XML_X2T_LANG_INNER = 2; {< xml:lang + inner contents } + APR_XML_X2T_FULL_NS_LANG = 3; {< FULL + ns defns + xml:lang } + +{ + * empty XML element + * @param p The pool to allocate out of + * @param elem The XML element to empty + * @return the string that was stored in the XML element + } +function apr_xml_empty_elem(p: Papr_pool_t; const elem: Papr_xml_elem): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_empty_elem' + LibSuff8; + +{ + * quote an XML string + * Replace '<', '>', and '&' with '<', '>', and '&'. + * @param p The pool to allocate out of + * @param s The string to quote + * @param quotes If quotes is true, then replace '"' with '"'. + * @return The quoted string + * @note If the string does not contain special characters, it is not + * duplicated into the pool and the original string is returned. + } +function apr_xml_quote_string(p: Papr_pool_t; const s: PChar; + quotes: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_quote_string' + LibSuff12; + +{ + * Quote an XML element + * @param p The pool to allocate out of + * @param elem The element to quote + } +procedure apr_xml_quote_elem(p: Papr_pool_t; elem: Papr_xml_elem); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_quote_elem' + LibSuff8; + +{ manage an array of unique URIs: apr_xml_insert_uri() and APR_XML_URI_ITEM() } + +{ + * return the URI's (existing) index, or insert it and return a new index + * @param uri_array array to insert into + * @param uri The uri to insert + * @return int The uri's index + } +function apr_xml_insert_uri(uri_array: Papr_array_header_t; + const uri: PChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibAPRUtil name LibNamePrefix + 'apr_xml_insert_uri' + LibSuff8; + +{ Get the URI item for this XML element } +//#define APR_XML_GET_URI_ITEM(ary, i) (((const char * const *)(ary)->elts)[i]) + diff --git a/httpd/httpd_2_2/aprutil/aprutil.pas b/httpd/httpd_2_2/aprutil/aprutil.pas new file mode 100644 index 000000000..e20627c5d --- /dev/null +++ b/httpd/httpd_2_2/aprutil/aprutil.pas @@ -0,0 +1,64 @@ +{ + aprutil.pas + + Copyright (C) 2006 Felipe Monteiro de Carvalho + + This unit is a pascal binding for the Apache 2.0.58 headers. + The headers were released under the following copyright: +} +{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } +unit aprutil; + +interface + +{$ifdef fpc} + {$mode delphi}{$H+} +{$endif} + +{$IFNDEF FPC} + {$DEFINE WINDOWS} +{$ENDIF} + +{$IFDEF WIN32} + {$DEFINE WINDOWS} +{$ENDIF} + +{$ifdef Unix} + {$PACKRECORDS C} +{$endif} + +uses +{$ifdef WINDOWS} + Windows, +{$ENDIF} + apr, ctypes; + +const +{$IFDEF WINDOWS} + LibAPRUtil = 'libaprutil.dll'; +{$ELSE} + LibAPRUtil = ''; +{$ENDIF} + +{$include apr_xml.inc} +{$include apr_uri.inc} +{$include apr_md5.inc} + +implementation + +end. + diff --git a/httpd/httpd_2_2/http_config.inc b/httpd/httpd_2_2/http_config.inc new file mode 100644 index 000000000..a46c72494 --- /dev/null +++ b/httpd/httpd_2_2/http_config.inc @@ -0,0 +1,1160 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{ + Declarations from other files centered here +} +const + (* Hook orderings *) + (** run this hook first, before ANYTHING *) + APR_HOOK_REALLY_FIRST = -10; + (** run this hook first *) + APR_HOOK_FIRST = 0; + (** run this hook somewhere *) + APR_HOOK_MIDDLE = 10; + (** run this hook after every other hook which is defined*) + APR_HOOK_LAST = 20; + (** run this hook last, after EVERYTHING *) + APR_HOOK_REALLY_LAST = 30; + + +//#include "apr_hooks.h" +{.$include util_cfgtree.inc} + +{ + * @file http_config.h + * @brief Apache Configuration + } + +{ + * @defgroup ConfigDirectives Allowed locations for configuration directives. + * + * The allowed locations for a configuration directive are the union of + * those indicated by each set bit in the req_override mask. + } +const + OR_NONE = 0; {< *.conf is not available anywhere in this override } + OR_LIMIT = 1; {< *.conf inside
+ * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, + * "The Foo directive is no longer supported, use Bar"), + *+ } +function ap_set_deprecated(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar; + cdecl; external LibHTTPD name 'ap_set_deprecated'; + +{ + * For modules which need to read config files, open logs, etc. this returns + * the canonical form of fname made absolute to ap_server_root. + * @param p pool to allocate data from + * @param fname The file name + } +function ap_server_root_relative(p: Papr_pool_t; const fname: PChar): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_server_root_relative' + LibSuff8; + +{ Finally, the hook for dynamically loading modules in... } + +{ + * Add a module to the server + * @param m The module structure of the module to add + * @param p The pool of the same lifetime as the module + } +procedure ap_add_module(m: Pmodule; p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_add_module' + LibSuff8; + +{ + * Remove a module from the server. There are some caveats: + * when the module is removed, its slot is lost so all the current + * per-dir and per-server configurations are invalid. So we should + * only ever call this function when you are invalidating almost + * all our current data. I.e. when doing a restart. + * @param m the module structure of the module to remove + } +procedure ap_remove_module(m: Pmodule); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_remove_module' + LibSuff4; + +{ + * Add a module to the chained modules list and the list of loaded modules + * @param m The module structure of the module to add + * @param p The pool with the same lifetime as the module + } +procedure ap_add_loaded_module(mod_: Pmodule; p: Papr_pool_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_add_loaded_module' + LibSuff8; + +{ + * Remove a module fromthe chained modules list and the list of loaded modules + * @param m the module structure of the module to remove + } +procedure ap_remove_loaded_module(m: Pmodule); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_remove_loaded_module' + LibSuff4; + +{ + * Add a module to the list of loaded module based on the name of the + * module + * @param name The name of the module + * @param p The pool valid for the lifetime of the module + * @return 1 on success, 0 on failure + } +function ap_add_named_module(const name: PChar; p: Papr_pool_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_add_named_module' + LibSuff8; + +{ + * Find the name of the specified module + * @param m The module to get the name for + * @return the name of the module + } +function ap_find_module_name(m: Pmodule): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_find_module_name' + LibSuff4; + +{ + * Find a module based on the name of the module + * @param name the name of the module + * @return the module structure if found, NULL otherwise + } +function ap_find_linked_module(const name: PChar): Pmodule; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_find_linked_module' + LibSuff4; + +{ + * Open a ap_configfile_t as apr_file_t + * @param ret_cfg open ap_configfile_t struct pointer + * @param p The pool to allocate the structure from + * @param name the name of the file to open + } +function ap_pcfg_openfile(ret_cfg: PPap_configfile_t; + p: Papr_pool_t; const name: PChar): apr_status_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_pcfg_openfile' + LibSuff12; + +{ + * Allocate a ap_configfile_t handle with user defined functions and params + * @param p The pool to allocate from + * @param descr The name of the file + * @param param The argument passed to getch/getstr/close + * @param getc_func The getch function + * @param gets_func The getstr function + * @param close_func The close function + } +type + getc_func_t = function (param: Pointer): Integer; + gets_func_t = function (buf: Pointer; bufsiz: size_t; param: Pointer): Pointer; + close_func_t = function (param: Pointer): Integer; + +function ap_pcfg_open_custom(p: Papr_pool_t; + const descr: PChar; param: Pointer; + getc_func: getc_func_t; gets_func: gets_func_t; + close_func: close_func_t): Pap_configfile_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_pcfg_open_custom' + LibSuff24; + +{ + * Read one line from open ap_configfile_t, strip LF, increase line number + * @param buf place to store the line read + * @param bufsize size of the buffer + * @param cfp File to read from + * @return 1 on success, 0 on failure + } +function ap_cfg_getline(bug: PChar; + bufsize: size_t; cfp: Pap_configfile_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_cfg_getline' + LibSuff12; + +{ + * Read one char from open configfile_t, increase line number upon LF + * @param cfp The file to read from + * @return the character read + } +function ap_cfg_getc(cfp: Pap_configfile_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_cfg_getc' + LibSuff4; + +{ + * Detach from open ap_configfile_t, calling the close handler + * @param cfp The file to close + * @return 1 on sucess, 0 on failure + } +function ap_cfg_closefile(cfp: Pap_configfile_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_cfg_closefile' + LibSuff4; + +{ + * Read all data between the current
+ * we now proceed to read from the client until we get EOF, or until + * MAX_SECS_TO_LINGER has passed. the reasons for doing this are + * documented in a draft: + * + * http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-connection-00.txt + * + * in a nutshell -- if we don't make this effort we risk causing + * TCP RST packets to be sent which can tear down a connection before + * all the response data has been sent to the client. + *+ * @param c The connection we are closing + } +procedure ap_lingering_close(c: Pconn_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_lingering_close' + LibSuff4; + +//#endif COREPRIVATE + + { Hooks } +{ + * create_connection is a RUN_FIRST hook which allows modules to create + * connections. In general, you should not install filters with the + * create_connection hook. If you require vhost configuration information + * to make filter installation decisions, you must use the pre_connection + * or install_network_transport hook. This hook should close the connection + * if it encounters a fatal error condition. + * + * @param p The pool from which to allocate the connection record + * @param csd The socket that has been accepted + * @param conn_id A unique identifier for this connection. The ID only + * needs to be unique at that time, not forever. + * @param sbh A handle to scoreboard information for this connection. + * @return An allocated connection record or NULL. + } +type + ap_HOOK_create_connection_t = function (p: Papr_pool_t; server: Pserver_rec; + csd: Papr_socket_t; conn_id: cLong; sbh: Pointer; + alloc: Papr_bucket_alloc_t): Pconn_rec; cdecl; + +procedure ap_hook_create_connection(pf: ap_HOOK_create_connection_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_create_connection' + LibSuff16; + +{ + * This hook gives protocol modules an opportunity to set everything up + * before calling the protocol handler. All pre-connection hooks are + * run until one returns something other than ok or decline + * @param c The connection on which the request has been received. + * @param csd The mechanism on which this connection is to be read. + * Most times this will be a socket, but it is up to the module + * that accepts the request to determine the exact type. + * @return OK or DECLINED + * @deffunc int ap_run_pre_connection(conn_rec *c, void *csd) + } +type + ap_HOOK_pre_connection_t = function (c: Pconn_rec; csd: Pointer): Integer; cdecl; + +procedure ap_hook_pre_connection(pf: ap_HOOK_pre_connection_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_pre_connection' + LibSuff16; + +{ + * This hook implements different protocols. After a connection has been + * established, the protocol module must read and serve the request. This + * function does that for each protocol module. The first protocol module + * to handle the request is the last module run. + * @param c The connection on which the request has been received. + * @return OK or DECLINED + * @deffunc int ap_run_process_connection(conn_rec *c) + } +type + ap_HOOK_process_connection_t = function (c: Pconn_rec): Integer; cdecl; + +procedure ap_hook_process_connection(pf: ap_HOOK_process_connection_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_process_connection' + LibSuff16; + +{ End Of Connection (EOC) bucket } + +//AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc; + +{ + * Determine if a bucket is an End Of Connection (EOC) bucket + * @param e The bucket to inspect + * @return true or false + } +//#define AP_BUCKET_IS_EOC(e) (e->type == &ap_bucket_type_eoc) + +{ + * Make the bucket passed in an End Of Connection (EOC) bucket + * @param b The bucket to make into an EOC bucket + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_eoc_make(apr_bucket *b) + } +function ap_bucket_eoc_make(b: Papr_bucket): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_make' + LibSuff4; + +{ + * Create a bucket referring to an End Of Connection (EOC). This indicates + * that the connection will be closed. + * @param list The freelist from which this bucket should be allocated + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_eoc_create(apr_bucket_alloc_t *list) + } +function ap_bucket_eoc_create(list: Papr_bucket_alloc_t): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_create' + LibSuff4; + + diff --git a/httpd/httpd_2_2/http_core.inc b/httpd/httpd_2_2/http_core.inc new file mode 100644 index 000000000..230675a4d --- /dev/null +++ b/httpd/httpd_2_2/http_core.inc @@ -0,0 +1,702 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr.h" +{$include apr/apr_hash.inc} +{#include "apr_optional.h"} +{$include util_filter.inc} + +{#if APR_HAVE_STRUCT_RLIMIT +#include
+ * REMOTE_HOST returns the hostname, or NULL if the hostname + * lookup fails. It will force a DNS lookup according to the + * HostnameLookups setting. + * REMOTE_NAME returns the hostname, or the dotted quad if the + * hostname lookup fails. It will force a DNS lookup according + * to the HostnameLookups setting. + * REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is + * never forced. + * REMOTE_DOUBLE_REV will always force a DNS lookup, and also force + * a double reverse lookup, regardless of the HostnameLookups + * setting. The result is the (double reverse checked) + * hostname, or NULL if any of the lookups fail. + *+ * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address + * string is returned + * @return The remote hostname + * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip) + } +function ap_get_remote_host(conn: Pconn_rec; dir_config: Pointer; + _type: Integer; str_is_ip: PInteger): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_remote_host' + LibSuff16; + +{ + * Retrieve the login name of the remote user. Undef if it could not be + * determined + * @param r The current request + * @return The user logged in to the client machine + * @deffunc const char *ap_get_remote_logname(request_rec *r) + } +function ap_get_remote_logname(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_remote_logname' + LibSuff4; + +{ Used for constructing self-referencing URLs, and things like SERVER_PORT, + * and SERVER_NAME. + } +{ + * build a fully qualified URL from the uri and information in the request rec + * @param p The pool to allocate the URL from + * @param uri The path to the requested file + * @param r The current request + * @return A fully qualified URL + * @deffunc char *ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r) + } +function ap_construct_url(p: Papr_pool_t; const uri: PChar; r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_construct_url' + LibSuff12; + +{ + * Get the current server name from the request + * @param r The current request + * @return the server name + * @deffunc const char *ap_get_server_name(request_rec *r) + } +function ap_get_server_name(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_server_name' + LibSuff4; + +{ + * Get the current server port + * @param The current request + * @return The server's port + * @deffunc apr_port_t ap_get_server_port(const request_rec *r) + } +function ap_get_server_port(r: Prequest_rec): apr_port_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_server_port' + LibSuff4; + +{ + * Return the limit on bytes in request msg body + * @param r The current request + * @return the maximum number of bytes in the request msg body + * @deffunc apr_off_t ap_get_limit_req_body(const request_rec *r) + } +function ap_get_limit_req_body(r: Prequest_rec): apr_off_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_limit_req_body' + LibSuff4; + +{ + * Return the limit on bytes in XML request msg body + * @param r The current request + * @return the maximum number of bytes in XML request msg body + * @deffunc size_t ap_get_limit_xml_body(const request_rec *r) + } +function ap_get_limit_xml_body(r: Prequest_rec): size_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_limit_xml_body' + LibSuff4; + +{ + * Install a custom response handler for a given status + * @param r The current request + * @param status The status for which the custom response should be used + * @param string The custom response. This can be a static string, a file + * or a URL + } +procedure ap_custom_response(r: Prequest_rec; status: Integer; const str: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_custom_response' + LibSuff12; + +{ + * Check if the current request is beyond the configured max. number of redirects or subrequests + * @param r The current request + * @return true (is exceeded) or false + * @deffunc int ap_is_recursion_limit_exceeded(const request_rec *r) + } +function ap_is_recursion_limit_exceeded(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_is_recursion_limit_exceeded' + LibSuff4; + +{ + * Check for a definition from the server command line + * @param name The define to check for + * @return 1 if defined, 0 otherwise + * @deffunc int ap_exists_config_define(const char *name) + } +function ap_exists_config_define(name: PChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_exists_config_define' + LibSuff4; + +{ FIXME! See STATUS about how } +function ap_core_translate(r: Prequest_rec): Integer; + cdecl; external LibHTTPD name 'ap_core_translate'; + +{ Authentication stuff. This is one of the places where compatibility + * with the old config files *really* hurts; they don't discriminate at + * all between different authentication schemes, meaning that we need + * to maintain common state for all of them in the core, and make it + * available to the other modules through interfaces. + } + +{ A structure to keep track of authorization requirements } +type + require_line = record + { Where the require line is in the config file. } + method_mask: apr_int64_t; + { The complete string from the command line } + requirement: PChar; + end; + +{ + * Return the type of authorization required for this request + * @param r The current request + * @return The authorization required + * @deffunc const char *ap_auth_type(request_rec *r) + } +function ap_auth_type(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_auth_type' + LibSuff4; + +{ + * Return the current Authorization realm + * @param r The current request + * @return The current authorization realm + * @deffunc const char *ap_auth_name(request_rec *r) + } +function ap_auth_name(r: Prequest_rec): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_auth_name' + LibSuff4; + +{ + * How the requires lines must be met. + * @param r The current request + * @return How the requirements must be met. One of: + *
+ * SATISFY_ANY -- any of the requirements must be met. + * SATISFY_ALL -- all of the requirements must be met. + * SATISFY_NOSPEC -- There are no applicable satisfy lines + *+ * @deffunc int ap_satisfies(request_rec *r) + } +function ap_satisfies(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_satisfies' + LibSuff4; + +{ + * Retrieve information about all of the requires directives for this request + * @param r The current request + * @return An array of all requires directives for this request + * @deffunc const apr_array_header_t *ap_requires(request_rec *r) + } +function ap_requires(p: Papr_array_header_t): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_requires' + LibSuff4; + +//#ifdef CORE_PRIVATE + +{ + * Core is also unlike other modules in being implemented in more than + * one file... so, data structures are declared here, even though most of + * the code that cares really is in http_core.c. Also, another accessor. + } + +//AP_DECLARE_DATA extern module core_module; + +{ Per-request configuration } + +type + core_request_config = record + { bucket brigade used by getline for look-ahead and + * ap_get_client_block for holding left-over request body } + bb: Papr_bucket_brigade; + + { an array of per-request working data elements, accessed + * by ID using ap_get_request_note() + * (Use ap_register_request_note() during initialization + * to add elements) + } + notes: PPointer; + + { There is a script processor installed on the output filter chain, + * so it needs the default_handler to deliver a (script) file into + * the chain so it can process it. Normally, default_handler only + * serves files on a GET request (assuming the file is actual content), + * since other methods are not content-retrieval. This flag overrides + * that behavior, stating that the "content" is actually a script and + * won't actually be delivered as the response for the non-GET method. + } + deliver_script: Integer; + + { Custom response strings registered via ap_custom_response(), + * or NULL; check per-dir config if nothing found here + } + response_code_strings: PPChar; { from ap_custom_response(), not from + * ErrorDocument + } + { Should addition of charset= be suppressed for this request? + } + suppress_charset: Integer; + end; + +{ Standard entries that are guaranteed to be accessible via + * ap_get_request_note() for each request (additional entries + * can be added with ap_register_request_note()) + } +const + AP_NOTE_DIRECTORY_WALK = 0; + AP_NOTE_LOCATION_WALK = 1; + AP_NOTE_FILE_WALK = 2; + AP_NUM_STD_NOTES = 3; + +{ + * Reserve an element in the core_request_config->notes array + * for some application-specific data + * @return An integer key that can be passed to ap_get_request_note() + * during request processing to access this element for the + * current request. + } +function ap_register_request_note: apr_size_t; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_register_request_note' + LibSuff0; + +{ + * Retrieve a pointer to an element in the core_request_config->notes array + * @param r The request + * @param note_num A key for the element: either a value obtained from + * ap_register_request_note() or one of the predefined AP_NOTE_* + * values. + * @return NULL if the note_num is invalid, otherwise a pointer to the + * requested note element. + * @remark At the start of a request, each note element is NULL. The + * handle provided by ap_get_request_note() is a pointer-to-pointer + * so that the caller can point the element to some app-specific + * data structure. The caller should guarantee that any such + * structure will last as long as the request itself. + } +function ap_get_request_note(r: Prequest_rec; note_num: apr_size_t): PPointer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_request_note' + LibSuff8; + +{ Per-directory configuration } + +type + allow_options_t = cuchar; + overrides_t = cuchar; + +{ + * Bits of info that go into making an ETag for a file + * document. Why a long? Because char historically + * proved too short for Options, and int can be different + * sizes on different platforms. + } + etag_components_t = culong; + +const + ETAG_UNSET = 0; + ETAG_NONE = (1 shl 0); + ETAG_MTIME = (1 shl 1); + ETAG_INODE = (1 shl 2); + ETAG_SIZE = (1 shl 3); + ETAG_BACKWARD = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE); + ETAG_ALL = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE); + + { Hostname resolution etc } + + HOSTNAME_LOOKUP_OFF = 0; + HOSTNAME_LOOKUP_ON = 1; + HOSTNAME_LOOKUP_DOUBLE = 2; + OSTNAME_LOOKUP_UNSET = 3; + + { Hostname resolution etc } + + USE_CANONICAL_NAME_OFF = (0); + USE_CANONICAL_NAME_ON = (1); + USE_CANONICAL_NAME_DNS = (2); + USE_CANONICAL_NAME_UNSET = (3); + + { should we force a charset on any outgoing parameterless content-type? + * if so, which charset? + } + ADD_DEFAULT_CHARSET_OFF = (0); + ADD_DEFAULT_CHARSET_ON = (1); + ADD_DEFAULT_CHARSET_UNSET = (2); + + { + * Run-time performance tuning + } + ENABLE_MMAP_OFF = (0); + ENABLE_MMAP_ON = (1); + ENABLE_MMAP_UNSET = (2); + + ENABLE_SENDFILE_OFF = (0); + ENABLE_SENDFILE_ON = (1); + ENABLE_SENDFILE_UNSET = (2); + +type + server_signature_e = ( + srv_sig_unset, + srv_sig_off, + srv_sig_on, + srv_sig_withmail + ); + + core_dir_config = record + + { path of the directory/regex/etc. see also d_is_fnmatch/absolute below } + d: PChar; + { the number of slashes in d } + d_components: Cardinal; + + { If (opts & OPT_UNSET) then no absolute assignment to options has + * been made. + * invariant: (opts_add & opts_remove) == 0 + * Which said another way means that the last relative (options + or -) + * assignment made to each bit is recorded in exactly one of opts_add + * or opts_remove. + } + opts: allow_options_t; + opts_add: allow_options_t; + opts_remove: allow_options_t; + override_: overrides_t; + + { MIME typing --- the core doesn't do anything at all with this, + * but it does know what to slap on a request for a document which + * goes untyped by other mechanisms before it slips out the door... + } + + ap_default_type: PChar; + + { Authentication stuff. Groan... } + + satisfy: PInteger; { for every method one } + ap_auth_type: PChar; + ap_auth_name: PChar; + ap_requires: Papr_array_header_t; + + { Custom response config. These can contain text or a URL to redirect to. + * if response_code_strings is NULL then there are none in the config, + * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES. + * This lets us do quick merges in merge_core_dir_configs(). + } + + response_code_strings: PPChar; { from ErrorDocument, not from + * ap_custom_response() } + + { Hostname resolution etc } +{ unsigned int hostname_lookups : 4; } + +{ signed int do_rfc1413 : 2; }{ See if client is advertising a username? } + +{ signed int content_md5 : 2; }{ calculate Content-MD5? } + +{ unsigned use_canonical_name : 2; } + + { since is_fnmatch(conf->d) was being called so frequently in + * directory_walk() and its relatives, this field was created and + * is set to the result of that call. + } +{ unsigned d_is_fnmatch : 1; } + + { should we force a charset on any outgoing parameterless content-type? + * if so, which charset? + } +{ unsigned add_default_charset : 2; } + add_default_charset_name: PChar; + + { System Resource Control } +{$ifdef RLIMIT_CPU} + limit_cpu: Prlimit; +{$endif} +{$if defined(RLIMIT_DATA) or defined (RLIMIT_VMEM) or defined(RLIMIT_AS)} + limit_mem: Prlimit; +{$endif} +{$ifdef RLIMIT_NPROC} + limit_nproc: Prlimit; +{$endif} + limit_req_body: apr_off_t; { limit on bytes in request msg body } + limit_xml_body: cLong; { limit on bytes in XML request msg body } + + { logging options } + + server_signature: server_signature_e; + + loglevel: Integer; + + { Access control } + sec_file: Papr_array_header_t; + r: Pregex_t; + + mime_type: PChar; { forced with ForceType } + handler: PChar; { forced with SetHandler } + output_filters: PChar; { forced with SetOutputFilters } + input_filters: PChar; { forced with SetInputFilters } + accept_path_info: Integer; { forced with AcceptPathInfo } + + ct_output_filters: Papr_hash_t; { added with AddOutputFilterByType } + + { + * What attributes/data should be included in ETag generation? + } + etag_bits: etag_components_t; + etag_add: etag_components_t; + etag_remove: etag_components_t; + + { + * Run-time performance tuning + } +{ unsigned int enable_mmap : 2; }{ whether files in this dir can be mmap'ed } + +{ unsigned int enable_sendfile : 2; }{ files in this dir can be mmap'ed } +{ unsigned int allow_encoded_slashes : 1; }{ URLs may contain %2f w/o being + * pitched indiscriminately } + end; + +{ Per-server core configuration } + +const + { TRACE control } + + AP_TRACE_UNSET = -1; + AP_TRACE_DISABLE = 0; + AP_TRACE_ENABLE = 1; + AP_TRACE_EXTENDED = 2; + +type + core_server_config = record + +{$ifdef GPROF} + gprof_dir: PChar; +{$endif} + + { Name translations --- we want the core to be able to do *something* + * so it's at least a minimally functional web server on its own (and + * can be tested that way). But let's keep it to the bare minimum: + } + ap_document_root: PChar; + + { Access control } + + access_name: PChar; + sec_dir: Papr_array_header_t; + sec_url: Papr_array_header_t; + + { recursion backstopper } + redirect_limit: Integer; { maximum number of internal redirects } + subreq_limit: Integer; { maximum nesting level of subrequests } + + { TRACE control } + trace_enable: Integer; + end; + +{ for AddOutputFiltersByType in core.c } +//void ap_add_output_filters_by_type(request_rec *r); + +{ for http_config.c } +//void ap_core_reorder_directories(apr_pool_t *, server_rec *); + +{ for mod_perl } +{AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config); +AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config); +AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config); +AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);} + +//#endif COREPRIVATE + + +{ ---------------------------------------------------------------------- + * + * Runtime status/management + } + +type + ap_mgmt_type_e = ( + ap_mgmt_type_string, + ap_mgmt_type_long, + ap_mgmt_type_hash + ); + + ap_mgmt_value = record + case Integer of + 0: (s_value: PChar); + 1: (i_value: cLong); + 2: (h_value: Papr_hash_t); + end; + + ap_mgmt_item_t = record + description: PChar; + name: PChar; + vtype: ap_mgmt_type_e; + v: ap_mgmt_value; + end; + +{ Handles for core filters } +{extern AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_net_time_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;} + +{ + * This hook provdes a way for modules to provide metrics/statistics about + * their operational status. + * + * @param p A pool to use to create entries in the hash table + * @param val The name of the parameter(s) that is wanted. This is + * tree-structured would be in the form ('*' is all the tree, + * 'module.*' all of the module , 'module.foo.*', or + * 'module.foo.bar' ) + * @param ht The hash table to store the results. Keys are item names, and + * the values point to ap_mgmt_item_t structures. + * @ingroup hooks + } +type + ap_HOOK_get_mgmt_items_t = function(p: Papr_pool_t; const val: PChar; + ht: Papr_hash_t): Integer; cdecl; + +procedure ap_hook_get_mgmt_items(pf: ap_HOOK_get_mgmt_items_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_get_mgmt_items' + LibSuff16; + +{ ---------------------------------------------------------------------- } + +{ ---------------------------------------------------------------------- + * + * I/O logging with mod_logio + } + +{APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out, + (conn_rec *c, apr_off_t bytes));} + diff --git a/httpd/httpd_2_2/http_log.inc b/httpd/httpd_2_2/http_log.inc new file mode 100644 index 000000000..84b0c637b --- /dev/null +++ b/httpd/httpd_2_2/http_log.inc @@ -0,0 +1,338 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +//#include "apr_thread_proc.h" + +{ + * @package Apache logging library + } + +{#ifdef HAVE_SYSLOG +#include
+ * REQUEST_NO_BODY Send 413 error if message has any body + * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length + * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. + *+ * @return either OK or an error code + * @deffunc int ap_setup_client_block(request_rec *r, int read_policy) + } +function ap_setup_client_block(r: Prequest_rec; read_policy: Integer): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_setup_client_block' + LibSuff8; + +{ + * Determine if the client has sent any data. This also sends a + * 100 Continue response to HTTP/1.1 clients, so modules should not be called + * until the module is ready to read content. + * @warning Never call this function more than once. + * @param r The current request + * @return 0 if there is no message to read, 1 otherwise + * @deffunc int ap_should_client_block(request_rec *r) + } +function ap_should_client_block(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_should_client_block' + LibSuff4; + +{ + * Call this in a loop. It will put data into a buffer and return the length + * of the input block + * @param r The current request + * @param buffer The buffer in which to store the data + * @param bufsiz The size of the buffer + * @return Number of bytes inserted into the buffer. When done reading, 0 + * if EOF, or -1 if there was an error + * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz) + } +function ap_get_client_block(r: Prequest_rec; buffer: PChar; bufsiz: apr_size_t): cLong; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_client_block' + LibSuff12; + +{ + * In HTTP/1.1, any method can have a body. However, most GET handlers + * wouldn't know what to do with a request body if they received one. + * This helper routine tests for and reads any message body in the request, + * simply discarding whatever it receives. We need to do this because + * failing to read the request body would cause it to be interpreted + * as the next request on a persistent connection. + * @param r The current request + * @return error status if request is malformed, OK otherwise + * @deffunc int ap_discard_request_body(request_rec *r) + } +function ap_discard_request_body(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_discard_request_body' + LibSuff4; + +{ + * Setup the output headers so that the client knows how to authenticate + * itself the next time, if an authentication request failed. This function + * works for both basic and digest authentication + * @param r The current request + * @deffunc void ap_note_auth_failure(request_rec *r) + } +procedure ap_note_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_note_auth_failure' + LibSuff4; + +{ + * Setup the output headers so that the client knows how to authenticate + * itself the next time, if an authentication request failed. This function + * works only for basic authentication + * @param r The current request + * @deffunc void ap_note_basic_auth_failure(request_rec *r) + } +procedure ap_note_basic_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_note_basic_auth_failure' + LibSuff4; + +{ + * Setup the output headers so that the client knows how to authenticate + * itself the next time, if an authentication request failed. This function + * works only for digest authentication + * @param r The current request + * @deffunc void ap_note_digest_auth_failure(request_rec *r) + } +procedure ap_note_digest_auth_failure(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_note_digest_auth_failure' + LibSuff4; + +{ + * Get the password from the request headers + * @param r The current request + * @param pw The password as set in the headers + * @return 0 (OK) if it set the 'pw' argument (and assured + * a correct value in r->user); otherwise it returns + * an error code, either HTTP_INTERNAL_SERVER_ERROR if things are + * really confused, HTTP_UNAUTHORIZED if no authentication at all + * seemed to be in use, or DECLINED if there was authentication but + * it wasn't Basic (in which case, the caller should presumably + * decline as well). + * @deffunc int ap_get_basic_auth_pw(request_rec *r, const char **pw) + } +function ap_get_basic_auth_pw(r: Prequest_rec; pw: PPChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_get_basic_auth_pw' + LibSuff8; + +{ + * parse_uri: break apart the uri + * @warning Side Effects:
+ * - sets r->args to rest after '?' (or NULL if no '?') + * - sets r->uri to request uri (without r->args part) + * - sets r->hostname (if not set already) from request (scheme://host:port) + *+ * @param r The current request + * @param uri The uri to break apart + * @deffunc void ap_parse_uri(request_rec *r, const char *uri) + } +procedure ap_parse_uri(r: Prequest_rec; const uri: PChar); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_parse_uri' + LibSuff8; + +{ + * Get the next line of input for the request + * @param s The buffer into which to read the line + * @param n The size of the buffer + * @param r The request + * @param fold Whether to merge continuation lines + * @return The length of the line, if successful + * n, if the line is too big to fit in the buffer + * -1 for miscellaneous errors + * @deffunc int ap_method_number_of(const char *method) + } +function ap_getline(s: PChar; n: Integer; r: Prequest_rec; fold: Integer): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_getline' + LibSuff16; + +{ + * Get the next line of input for the request + * + * Note: on ASCII boxes, ap_rgetline is a macro which simply calls + * ap_rgetline_core to get the line of input. + * + * on EBCDIC boxes, ap_rgetline is a wrapper function which + * translates ASCII protocol lines to the local EBCDIC code page + * after getting the line of input. + * + * @param s Pointer to the pointer to the buffer into which the line + * should be read; if *s==NULL, a buffer of the necessary size + * to hold the data will be allocated from the request pool + * @param n The size of the buffer + * @param read The length of the line. + * @param r The request + * @param fold Whether to merge continuation lines + * @param bb Working brigade to use when reading buckets + * @return APR_SUCCESS, if successful + * APR_ENOSPC, if the line is too big to fit in the buffer + * Other errors where appropriate + } +{#if APR_CHARSET_EBCDIC +AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, + apr_size_t *read, + request_rec *r, int fold, + apr_bucket_brigade *bb); +#else }{ ASCII box } +{#define ap_rgetline(s, n, read, r, fold, bb) \ + ap_rgetline_core((s), (n), (read), (r), (fold), (bb)) +#endif} + +{AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, + apr_size_t *read, + request_rec *r, int fold, + apr_bucket_brigade *bb);} + +{ + * Get the method number associated with the given string, assumed to + * contain an HTTP method. Returns M_INVALID if not recognized. + * @param method A string containing a valid HTTP method + * @return The method number + } +function ap_method_number_of(const method: PChar): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_method_number_of' + LibSuff4; + +{ + * Get the method name associated with the given internal method + * number. Returns NULL if not recognized. + * @param p A pool to use for temporary allocations. + * @param methnum An integer value corresponding to an internal method number + * @return The name corresponding to the method number + } +function ap_method_name_of(p: Papr_pool_t; methnum: Integer): PChar; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_method_name_of' + LibSuff8; + + + { Hooks } + { + * post_read_request --- run right after read_request or internal_redirect, + * and not run during any subrequests. + } +{ + * This hook allows modules to affect the request immediately after the request + * has been read, and before any other phases have been processes. This allows + * modules to make decisions based upon the input header fields + * @param r The current request + * @return OK or DECLINED + * @deffunc ap_run_post_read_request(request_rec *r) + } +type + ap_HOOK_post_read_request_t = function(r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_post_read_request(pf: ap_HOOK_post_read_request_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_post_read_request' + LibSuff16; + +{ + * This hook allows modules to perform any module-specific logging activities + * over and above the normal server things. + * @param r The current request + * @return OK, DECLINED, or HTTP_... + * @deffunc int ap_run_log_transaction(request_rec *r) + } +type + ap_HOOK_log_transaction_t = function(r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_log_transaction(pf: ap_HOOK_log_transaction_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_log_transaction' + LibSuff16; + +{ + * This hook allows modules to retrieve the http method from a request. This + * allows Apache modules to easily extend the methods that Apache understands + * @param r The current request + * @return The http method from the request + * @deffunc const char *ap_run_http_method(const request_rec *r) + } +type + ap_HOOK_http_method_t = function(const r: Prequest_rec): PChar; cdecl; + +procedure ap_hook_http_method(pf: ap_HOOK_http_method_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_http_method' + LibSuff16; + +{ + * Return the default port from the current request + * @param r The current request + * @return The current port + * @deffunc apr_port_t ap_run_default_port(const request_rec *r) + } +type + ap_HOOK_default_port_t = function(const r: Prequest_rec): apr_port_t; cdecl; + +procedure ap_hook_default_port(pf: ap_HOOK_default_port_t; + const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_default_port' + LibSuff16; + +{ + * A bucket referring to an HTTP error + * This bucket can be passed down the filter stack to indicate that an + * HTTP error occurred while running a filter. In order for this bucket + * to be used successfully, it MUST be sent as the first bucket in the + * first brigade to be sent from a given filter. + } +type + ap_bucket_error = record + { Number of buckets using this memory } + refcount: apr_bucket_refcount; + { The error code } + status: Integer; + { The error string } + data: PChar; + end; + Pap_bucket_error = ^ap_bucket_error; + +//AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error; + +{ + * Determine if a bucket is an error bucket + * @param e The bucket to inspect + * @return true or false + } +//#define AP_BUCKET_IS_ERROR(e) (e->type == &ap_bucket_type_error) + +{ + * Make the bucket passed in an error bucket + * @param b The bucket to make into an error bucket + * @param error The HTTP error code to put in the bucket. + * @param buf An optional error string to put in the bucket. + * @param p A pool to allocate out of. + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p) + } +function ap_bucket_error_make(b: Papr_bucket; error: Integer; + const buf: PChar; p: Papr_pool_t): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_error_make' + LibSuff16; + +{ + * Create a bucket referring to an HTTP error. + * @param error The HTTP error code to put in the bucket. + * @param buf An optional error string to put in the bucket. + * @param p A pool to allocate the error string out of. + * @param list The bucket allocator from which to allocate the bucket + * @return The new bucket, or NULL if allocation failed + * @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list) + } +function ap_bucket_error_create(error: Integer; const buf: PChar; + p: Papr_pool_t; list: Papr_bucket_alloc_t): Papr_bucket; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_bucket_error_create' + LibSuff16; + +function ap_byterange_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_byterange_filter'; + +function ap_http_header_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_http_header_filter'; + +function ap_content_length_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_content_length_filter'; + +function ap_old_write_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_old_write_filter'; + +{ + * Setting up the protocol fields for subsidiary requests... + * Also, a wrapup function to keep the internal accounting straight. + } +procedure ap_set_sub_req_protocol(rnew: Prequest_rec; const r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_set_sub_req_protocol' + LibSuff8; + +procedure ap_finalize_sub_req_protocol(sub_r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_finalize_sub_req_protocol' + LibSuff4; + diff --git a/httpd/httpd_2_2/http_request.inc b/httpd/httpd_2_2/http_request.inc new file mode 100644 index 000000000..e2997834f --- /dev/null +++ b/httpd/httpd_2_2/http_request.inc @@ -0,0 +1,460 @@ +{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed 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. + } + +{#include "apr_hooks.h" +#include "util_filter.h"} + +const + AP_SUBREQ_NO_ARGS = 0; + AP_SUBREQ_MERGE_ARGS = 1; + +{ + * @file http_request.h + * @brief Apache Request library + } + +{ http_request.c is the code which handles the main line of request + * processing, once a request has been read in (finding the right per- + * directory configuration, building it if necessary, and calling all + * the module dispatch functions in the right order). + * + * The pieces here which are public to the modules, allow them to learn + * how the server would handle some other file or URI, or perhaps even + * direct the server to serve that other file instead of the one the + * client requested directly. + * + * There are two ways to do that. The first is the sub_request mechanism, + * which handles looking up files and URIs as adjuncts to some other + * request (e.g., directory entries for multiviews and directory listings); + * the lookup functions stop short of actually running the request, but + * (e.g., for includes), a module may call for the request to be run + * by calling run_sub_req. The space allocated to create sub_reqs can be + * reclaimed by calling destroy_sub_req --- be sure to copy anything you care + * about which was allocated in its apr_pool_t elsewhere before doing this. + } + +{ + * An internal handler used by the ap_process_request, all subrequest mechanisms + * and the redirect mechanism. + * @param r The request, subrequest or internal redirect to pre-process + * @return The return code for the request + } +function ap_process_request_internal(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_process_request_internal' + LibSuff4; + +{ + * Create a subrequest from the given URI. This subrequest can be + * inspected to find information about the requested URI + * @param new_uri The URI to lookup + * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_lookup_uri(const char *new_uri, const request_rec *r) + } +function ap_sub_req_lookup_uri(const new_uri: PChar; + const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_uri' + LibSuff12; + +{ + * Create a subrequest for the given file. This subrequest can be + * inspected to find information about the requested file + * @param new_file The file to lookup + * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_lookup_file(const char *new_file, const request_rec *r) + } +function ap_sub_req_lookup_file(const new_file: PChar; + const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_file' + LibSuff12; + +{ + * Create a subrequest for the given apr_dir_read result. This subrequest + * can be inspected to find information about the requested file + * @param finfo The apr_dir_read result to lookup + * @param r The current request + * @param subtype What type of subrequest to perform, one of; + *
+ * AP_SUBREQ_NO_ARGS ignore r->args and r->path_info + * AP_SUBREQ_MERGE_ARGS merge r->args and r->path_info + *+ * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_lookup_dirent(apr_finfo_t *finfo, int subtype, const request_rec *r) + * @tip The apr_dir_read flags value APR_FINFO_MIN|APR_FINFO_NAME flag is the + * minimum recommended query if the results will be passed to apr_dir_read. + * The file info passed must include the name, and must have the same relative + * directory as the current request. + } +function ap_sub_req_lookup_dirent(const finfo: Papr_finfo_t; + const r: Prequest_rec; subtype: Integer; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_dirent' + LibSuff16; + +{ + * Create a subrequest for the given URI using a specific method. This + * subrequest can be inspected to find information about the requested URI + * @param method The method to use in the new subrequest + * @param new_uri The URI to lookup + * @param r The current request + * @param next_filter The first filter the sub_request should use. If this is + * NULL, it defaults to the first filter for the main request + * @return The new request record + * @deffunc request_rec * ap_sub_req_method_uri(const char *method, const char *new_uri, const request_rec *r) + } +function ap_sub_req_method_uri(const method, new_uri: PChar; + const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_sub_req_method_uri' + LibSuff16; + +{ + * An output filter to strip EOS buckets from sub-requests. This always + * has to be inserted at the end of a sub-requests filter stack. + * @param f The current filter + * @param bb The brigade to filter + * @deffunc apr_status_t ap_sub_req_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) + } +function ap_sub_req_output_filter(f: Pap_filter_t; + bb: Papr_bucket_brigade): apr_status_t; + cdecl; external LibHTTPD name 'ap_sub_req_output_filter'; + +{ + * Run the handler for the subrequest + * @param r The subrequest to run + * @return The return code for the subrequest + * @deffunc int ap_run_sub_req(request_rec *r) + } +function ap_run_sub_req(r: Prequest_rec): Prequest_rec; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_run_sub_req' + LibSuff4; + +{ + * Free the memory associated with a subrequest + * @param r The subrequest to finish + * @deffunc void ap_destroy_sub_req(request_rec *r) + } +procedure ap_destroy_sub_req(r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_destroy_sub_req' + LibSuff4; + +{ + * Then there's the case that you want some other request to be served + * as the top-level request INSTEAD of what the client requested directly. + * If so, call this from a handler, and then immediately return OK. + } + +{ + * Redirect the current request to some other uri + * @param new_uri The URI to replace the current request with + * @param r The current request + * @deffunc void ap_internal_redirect(const char *new_uri, request_rec *r) + } +procedure ap_internal_redirect(const new_uri: PChar; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_internal_redirect' + LibSuff8; + +{ + * This function is designed for things like actions or CGI scripts, when + * using AddHandler, and you want to preserve the content type across + * an internal redirect. + * @param new_uri The URI to replace the current request with. + * @param r The current request + * @deffunc void ap_internal_redirect_handler(const char *new_uri, request_rec *r) + } +procedure ap_internal_redirect_handler(const new_uri: PChar; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_internal_redirect_handler' + LibSuff8; + +{ + * Redirect the current request to a sub_req, merging the pools + * @param sub_req A subrequest created from this request + * @param r The current request + * @deffunc void ap_internal_fast_redirect(request_rec *sub_req, request_rec *r) + * @tip the sub_req's pool will be merged into r's pool, be very careful + * not to destroy this subrequest, it will be destroyed with the main request! + } +procedure ap_internal_fast_redirect(sub_req, r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_internal_fast_redirect' + LibSuff8; + +{ + * Can be used within any handler to determine if any authentication + * is required for the current request + * @param r The current request + * @return 1 if authentication is required, 0 otherwise + * @deffunc int ap_some_auth_required(request_rec *r) + } +function ap_some_auth_required(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_some_auth_required' + LibSuff4; + +{ + * Determine if the current request is the main request or a subrequest + * @param r The current request + * @return 1 if this is the main request, 0 otherwise + * @deffunc int ap_is_initial_req(request_rec *r) + } +function ap_is_initial_req(r: Prequest_rec): Integer; + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_is_initial_req' + LibSuff4; + +{ + * Function to set the r->mtime field to the specified value if it's later + * than what's already there. + * @param r The current request + * @param dependency_time Time to set the mtime to + * @deffunc void ap_update_mtime(request_rec *r, apr_time_t dependency_mtime) + } +procedure ap_update_mtime(r: Prequest_rec; dependency_mtime: apr_time_t); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_update_mtime' + LibSuff12; + +{ + * Add one or more methods to the list permitted to access the resource. + * Usually executed by the content handler before the response header is + * sent, but sometimes invoked at an earlier phase if a module knows it + * can set the list authoritatively. Note that the methods are ADDED + * to any already permitted unless the reset flag is non-zero. The + * list is used to generate the Allow response header field when it + * is needed. + * @param r The pointer to the request identifying the resource. + * @param reset Boolean flag indicating whether this list should + * completely replace any current settings. + * @param ... A NULL-terminated list of strings, each identifying a + * method name to add. + * @return None. + * @deffunc void ap_allow_methods(request_rec *r, int reset, ...) + } +procedure ap_allow_methods(r: Prequest_rec; reset: Integer; others: array of const); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name 'ap_allow_methods'; + +//AP_DECLARE(void) (request_rec *r, int reset, ...); + +{ + * Add one or more methods to the list permitted to access the resource. + * Usually executed by the content handler before the response header is + * sent, but sometimes invoked at an earlier phase if a module knows it + * can set the list authoritatively. Note that the methods are ADDED + * to any already permitted unless the reset flag is non-zero. The + * list is used to generate the Allow response header field when it + * is needed. + * @param r The pointer to the request identifying the resource. + * @param reset Boolean flag indicating whether this list should + * completely replace any current settings. + * @param ... A list of method identifiers, from the "M_" series + * defined in httpd.h, terminated with a value of -1 + * (e.g., "M_GET, M_POST, M_OPTIONS, -1") + * @return None. + * @deffunc void ap_allow_standard_methods(request_rec *r, int reset, ...) + } +procedure ap_allow_standard_methods(r: Prequest_rec; reset: Integer; others: array of const); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name 'ap_allow_standard_methods'; + +//AP_DECLARE(void) (request_rec *r, int reset, ...); + +const + MERGE_ALLOW = 0; + REPLACE_ALLOW = 1; + +//#ifdef CORE_PRIVATE +{ Function called by main.c to handle first-level request } +//void ap_process_request(request_rec *); +{ + * Kill the current request + * @param type Why the request is dieing + * @param r The current request + * @deffunc void ap_die(int type, request_rec *r) + } +procedure ap_die(type_: Integer; r: Prequest_rec); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_die' + LibSuff8; + +//#endif COREPRIVATE + +{ Hooks } + +{ + * Gives modules a chance to create their request_config entry when the + * request is created. + * @param r The current request + * @ingroup hooks + } +type + ap_HOOK_create_request_t = function (r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_create_request(pf: ap_HOOK_create_request_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_create_request' + LibSuff16; + +{ + * This hook allow modules an opportunity to translate the URI into an + * actual filename. If no modules do anything special, the server's default + * rules will be followed. + * @param r The current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + } +type + ap_HOOK_translate_name_t = function (r: Prequest_rec): Integer; cdecl; + +procedure ap_hook_translate_name(pf: ap_HOOK_translate_name_t; const aszPre: PPChar; + const aszSucc: PPChar; nOrder: Integer); + {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} + external LibHTTPD name LibNamePrefix + 'ap_hook_translate_name' + LibSuff16; + +{ + * This hook allow modules to set the per_dir_config based on their own + * context (such as
' + LineEnding, r);
+ 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); + ap_rputs(' The format for the callback trace is:' + LineEnding, r); + ap_rputs('
' + LineEnding, r); + ap_rputs('' + LineEnding, r); + ap_rputs(' The <routine-data> is supplied by' + LineEnding, r); + ap_rputs(' the routine when it requests the trace,' + LineEnding, r); + ap_rputs(' and the <applies-to> is extracted' + LineEnding, r); + ap_rputs(' from the configuration record at the time of the trace.' + LineEnding, r); + ap_rputs(' SVR() indicates a server environment' + LineEnding, r); + ap_rputs(' (blank means the main or default server, otherwise it''s' + LineEnding, r); + ap_rputs(' the name of the VirtualHost); DIR()' + LineEnding, r); + ap_rputs(' indicates a location in the URL or filesystem' + LineEnding, r); + ap_rputs(' namespace.' + LineEnding, r); + ap_rputs('
' + LineEnding, r); + ap_rprintf(r, '';
+ PPChar(apr_array_push(t))^ := ap_escape_html(sub_pool, r^.uri);
+ PPChar(apr_array_push(t))^ :=
+ '
) could not be found on this server.' + LineEnding +
+ 'However, we found documents with names similar ' +
+ 'to the one you requested.' + + 'Available documents:' + LineEnding + '