From cc40af334e619bb549038238507407866f774f8f Mon Sep 17 00:00:00 2001 From: hongbotian Date: Mon, 30 Nov 2015 01:35:09 -0500 Subject: upload apache JIRA: BOTTLENECK-10 Change-Id: I67eae31de6dc824097dfa56ab454ba36fdd23a2c Signed-off-by: hongbotian --- rubbos/app/apache2/include/ap_compat.h | 28 + rubbos/app/apache2/include/ap_config.h | 256 +++ rubbos/app/apache2/include/ap_config_auto.h | 250 +++ rubbos/app/apache2/include/ap_config_layout.h | 59 + rubbos/app/apache2/include/ap_listen.h | 119 ++ rubbos/app/apache2/include/ap_mmn.h | 127 ++ rubbos/app/apache2/include/ap_mpm.h | 176 ++ rubbos/app/apache2/include/ap_provider.h | 54 + rubbos/app/apache2/include/ap_regkey.h | 218 ++ rubbos/app/apache2/include/ap_release.h | 56 + rubbos/app/apache2/include/apr.h | 414 ++++ rubbos/app/apache2/include/apr_allocator.h | 170 ++ rubbos/app/apache2/include/apr_anylock.h | 128 ++ rubbos/app/apache2/include/apr_atomic.h | 314 +++ rubbos/app/apache2/include/apr_base64.h | 112 ++ rubbos/app/apache2/include/apr_buckets.h | 1495 ++++++++++++++ rubbos/app/apache2/include/apr_compat.h | 231 +++ rubbos/app/apache2/include/apr_date.h | 106 + rubbos/app/apache2/include/apr_dbm.h | 224 +++ rubbos/app/apache2/include/apr_dso.h | 94 + rubbos/app/apache2/include/apr_env.h | 67 + rubbos/app/apache2/include/apr_errno.h | 1219 ++++++++++++ rubbos/app/apache2/include/apr_file_info.h | 421 ++++ rubbos/app/apache2/include/apr_file_io.h | 766 +++++++ rubbos/app/apache2/include/apr_fnmatch.h | 105 + rubbos/app/apache2/include/apr_general.h | 249 +++ rubbos/app/apache2/include/apr_getopt.h | 158 ++ rubbos/app/apache2/include/apr_global_mutex.h | 153 ++ rubbos/app/apache2/include/apr_hash.h | 201 ++ rubbos/app/apache2/include/apr_hooks.h | 273 +++ rubbos/app/apache2/include/apr_inherit.h | 51 + rubbos/app/apache2/include/apr_ldap.h | 176 ++ rubbos/app/apache2/include/apr_ldap_url.h | 84 + rubbos/app/apache2/include/apr_lib.h | 228 +++ rubbos/app/apache2/include/apr_md4.h | 135 ++ rubbos/app/apache2/include/apr_md5.h | 158 ++ rubbos/app/apache2/include/apr_mmap.h | 193 ++ rubbos/app/apache2/include/apr_network_io.h | 845 ++++++++ rubbos/app/apache2/include/apr_optional.h | 99 + rubbos/app/apache2/include/apr_optional_hooks.h | 117 ++ rubbos/app/apache2/include/apr_poll.h | 253 +++ rubbos/app/apache2/include/apr_pools.h | 664 +++++++ rubbos/app/apache2/include/apr_portable.h | 505 +++++ rubbos/app/apache2/include/apr_proc_mutex.h | 166 ++ rubbos/app/apache2/include/apr_queue.h | 138 ++ rubbos/app/apache2/include/apr_reslist.h | 141 ++ rubbos/app/apache2/include/apr_ring.h | 551 ++++++ rubbos/app/apache2/include/apr_rmm.h | 137 ++ rubbos/app/apache2/include/apr_sdbm.h | 175 ++ rubbos/app/apache2/include/apr_sha1.h | 121 ++ rubbos/app/apache2/include/apr_shm.h | 127 ++ rubbos/app/apache2/include/apr_signal.h | 98 + rubbos/app/apache2/include/apr_strings.h | 337 ++++ rubbos/app/apache2/include/apr_strmatch.h | 81 + rubbos/app/apache2/include/apr_support.h | 51 + rubbos/app/apache2/include/apr_tables.h | 422 ++++ rubbos/app/apache2/include/apr_thread_cond.h | 128 ++ rubbos/app/apache2/include/apr_thread_mutex.h | 110 ++ rubbos/app/apache2/include/apr_thread_proc.h | 772 ++++++++ rubbos/app/apache2/include/apr_thread_rwlock.h | 120 ++ rubbos/app/apache2/include/apr_time.h | 245 +++ rubbos/app/apache2/include/apr_uri.h | 181 ++ rubbos/app/apache2/include/apr_user.h | 195 ++ rubbos/app/apache2/include/apr_uuid.h | 76 + rubbos/app/apache2/include/apr_version.h | 115 ++ rubbos/app/apache2/include/apr_want.h | 109 + rubbos/app/apache2/include/apr_xlate.h | 158 ++ rubbos/app/apache2/include/apr_xml.h | 340 ++++ rubbos/app/apache2/include/apu.h | 85 + rubbos/app/apache2/include/apu_compat.h | 116 ++ rubbos/app/apache2/include/apu_version.h | 105 + rubbos/app/apache2/include/apu_want.h | 50 + rubbos/app/apache2/include/expat.h | 1001 ++++++++++ rubbos/app/apache2/include/fdqueue.h | 64 + rubbos/app/apache2/include/http_config.h | 1018 ++++++++++ rubbos/app/apache2/include/http_connection.h | 139 ++ rubbos/app/apache2/include/http_core.h | 640 ++++++ rubbos/app/apache2/include/http_log.h | 334 ++++ rubbos/app/apache2/include/http_main.h | 58 + rubbos/app/apache2/include/http_protocol.h | 697 +++++++ rubbos/app/apache2/include/http_request.h | 373 ++++ rubbos/app/apache2/include/http_vhost.h | 109 + rubbos/app/apache2/include/httpd.h | 1760 +++++++++++++++++ rubbos/app/apache2/include/mod_cgi.h | 62 + rubbos/app/apache2/include/mod_core.h | 80 + rubbos/app/apache2/include/mod_dav.h | 2420 +++++++++++++++++++++++ rubbos/app/apache2/include/mod_include.h | 206 ++ rubbos/app/apache2/include/mod_log_config.h | 63 + rubbos/app/apache2/include/mod_proxy.h | 255 +++ rubbos/app/apache2/include/mod_ssl.h | 724 +++++++ rubbos/app/apache2/include/mod_status.h | 54 + rubbos/app/apache2/include/mpm.h | 50 + rubbos/app/apache2/include/mpm_common.h | 298 +++ rubbos/app/apache2/include/mpm_default.h | 69 + rubbos/app/apache2/include/os.h | 27 + rubbos/app/apache2/include/pcre.h | 113 ++ rubbos/app/apache2/include/pcreposix.h | 88 + rubbos/app/apache2/include/pod.h | 50 + rubbos/app/apache2/include/rfc1413.h | 42 + rubbos/app/apache2/include/scoreboard.h | 197 ++ rubbos/app/apache2/include/ssl_expr.h | 104 + rubbos/app/apache2/include/ssl_expr_parse.h | 27 + rubbos/app/apache2/include/ssl_toolkit_compat.h | 239 +++ rubbos/app/apache2/include/ssl_util_ssl.h | 93 + rubbos/app/apache2/include/ssl_util_table.h | 152 ++ rubbos/app/apache2/include/unixd.h | 109 + rubbos/app/apache2/include/util_cfgtree.h | 79 + rubbos/app/apache2/include/util_charset.h | 54 + rubbos/app/apache2/include/util_ebcdic.h | 78 + rubbos/app/apache2/include/util_filter.h | 516 +++++ rubbos/app/apache2/include/util_ldap.h | 318 +++ rubbos/app/apache2/include/util_md5.h | 70 + rubbos/app/apache2/include/util_script.h | 142 ++ rubbos/app/apache2/include/util_time.h | 85 + rubbos/app/apache2/include/util_xml.h | 46 + 115 files changed, 30304 insertions(+) create mode 100644 rubbos/app/apache2/include/ap_compat.h create mode 100644 rubbos/app/apache2/include/ap_config.h create mode 100644 rubbos/app/apache2/include/ap_config_auto.h create mode 100644 rubbos/app/apache2/include/ap_config_layout.h create mode 100644 rubbos/app/apache2/include/ap_listen.h create mode 100644 rubbos/app/apache2/include/ap_mmn.h create mode 100644 rubbos/app/apache2/include/ap_mpm.h create mode 100644 rubbos/app/apache2/include/ap_provider.h create mode 100644 rubbos/app/apache2/include/ap_regkey.h create mode 100644 rubbos/app/apache2/include/ap_release.h create mode 100644 rubbos/app/apache2/include/apr.h create mode 100644 rubbos/app/apache2/include/apr_allocator.h create mode 100644 rubbos/app/apache2/include/apr_anylock.h create mode 100644 rubbos/app/apache2/include/apr_atomic.h create mode 100644 rubbos/app/apache2/include/apr_base64.h create mode 100644 rubbos/app/apache2/include/apr_buckets.h create mode 100644 rubbos/app/apache2/include/apr_compat.h create mode 100644 rubbos/app/apache2/include/apr_date.h create mode 100644 rubbos/app/apache2/include/apr_dbm.h create mode 100644 rubbos/app/apache2/include/apr_dso.h create mode 100644 rubbos/app/apache2/include/apr_env.h create mode 100644 rubbos/app/apache2/include/apr_errno.h create mode 100644 rubbos/app/apache2/include/apr_file_info.h create mode 100644 rubbos/app/apache2/include/apr_file_io.h create mode 100644 rubbos/app/apache2/include/apr_fnmatch.h create mode 100644 rubbos/app/apache2/include/apr_general.h create mode 100644 rubbos/app/apache2/include/apr_getopt.h create mode 100644 rubbos/app/apache2/include/apr_global_mutex.h create mode 100644 rubbos/app/apache2/include/apr_hash.h create mode 100644 rubbos/app/apache2/include/apr_hooks.h create mode 100644 rubbos/app/apache2/include/apr_inherit.h create mode 100644 rubbos/app/apache2/include/apr_ldap.h create mode 100644 rubbos/app/apache2/include/apr_ldap_url.h create mode 100644 rubbos/app/apache2/include/apr_lib.h create mode 100644 rubbos/app/apache2/include/apr_md4.h create mode 100644 rubbos/app/apache2/include/apr_md5.h create mode 100644 rubbos/app/apache2/include/apr_mmap.h create mode 100644 rubbos/app/apache2/include/apr_network_io.h create mode 100644 rubbos/app/apache2/include/apr_optional.h create mode 100644 rubbos/app/apache2/include/apr_optional_hooks.h create mode 100644 rubbos/app/apache2/include/apr_poll.h create mode 100644 rubbos/app/apache2/include/apr_pools.h create mode 100644 rubbos/app/apache2/include/apr_portable.h create mode 100644 rubbos/app/apache2/include/apr_proc_mutex.h create mode 100644 rubbos/app/apache2/include/apr_queue.h create mode 100644 rubbos/app/apache2/include/apr_reslist.h create mode 100644 rubbos/app/apache2/include/apr_ring.h create mode 100644 rubbos/app/apache2/include/apr_rmm.h create mode 100644 rubbos/app/apache2/include/apr_sdbm.h create mode 100644 rubbos/app/apache2/include/apr_sha1.h create mode 100644 rubbos/app/apache2/include/apr_shm.h create mode 100644 rubbos/app/apache2/include/apr_signal.h create mode 100644 rubbos/app/apache2/include/apr_strings.h create mode 100644 rubbos/app/apache2/include/apr_strmatch.h create mode 100644 rubbos/app/apache2/include/apr_support.h create mode 100644 rubbos/app/apache2/include/apr_tables.h create mode 100644 rubbos/app/apache2/include/apr_thread_cond.h create mode 100644 rubbos/app/apache2/include/apr_thread_mutex.h create mode 100644 rubbos/app/apache2/include/apr_thread_proc.h create mode 100644 rubbos/app/apache2/include/apr_thread_rwlock.h create mode 100644 rubbos/app/apache2/include/apr_time.h create mode 100644 rubbos/app/apache2/include/apr_uri.h create mode 100644 rubbos/app/apache2/include/apr_user.h create mode 100644 rubbos/app/apache2/include/apr_uuid.h create mode 100644 rubbos/app/apache2/include/apr_version.h create mode 100644 rubbos/app/apache2/include/apr_want.h create mode 100644 rubbos/app/apache2/include/apr_xlate.h create mode 100644 rubbos/app/apache2/include/apr_xml.h create mode 100644 rubbos/app/apache2/include/apu.h create mode 100644 rubbos/app/apache2/include/apu_compat.h create mode 100644 rubbos/app/apache2/include/apu_version.h create mode 100644 rubbos/app/apache2/include/apu_want.h create mode 100644 rubbos/app/apache2/include/expat.h create mode 100644 rubbos/app/apache2/include/fdqueue.h create mode 100644 rubbos/app/apache2/include/http_config.h create mode 100644 rubbos/app/apache2/include/http_connection.h create mode 100644 rubbos/app/apache2/include/http_core.h create mode 100644 rubbos/app/apache2/include/http_log.h create mode 100644 rubbos/app/apache2/include/http_main.h create mode 100644 rubbos/app/apache2/include/http_protocol.h create mode 100644 rubbos/app/apache2/include/http_request.h create mode 100644 rubbos/app/apache2/include/http_vhost.h create mode 100644 rubbos/app/apache2/include/httpd.h create mode 100644 rubbos/app/apache2/include/mod_cgi.h create mode 100644 rubbos/app/apache2/include/mod_core.h create mode 100644 rubbos/app/apache2/include/mod_dav.h create mode 100644 rubbos/app/apache2/include/mod_include.h create mode 100644 rubbos/app/apache2/include/mod_log_config.h create mode 100644 rubbos/app/apache2/include/mod_proxy.h create mode 100644 rubbos/app/apache2/include/mod_ssl.h create mode 100644 rubbos/app/apache2/include/mod_status.h create mode 100644 rubbos/app/apache2/include/mpm.h create mode 100644 rubbos/app/apache2/include/mpm_common.h create mode 100644 rubbos/app/apache2/include/mpm_default.h create mode 100644 rubbos/app/apache2/include/os.h create mode 100644 rubbos/app/apache2/include/pcre.h create mode 100644 rubbos/app/apache2/include/pcreposix.h create mode 100644 rubbos/app/apache2/include/pod.h create mode 100644 rubbos/app/apache2/include/rfc1413.h create mode 100644 rubbos/app/apache2/include/scoreboard.h create mode 100644 rubbos/app/apache2/include/ssl_expr.h create mode 100644 rubbos/app/apache2/include/ssl_expr_parse.h create mode 100644 rubbos/app/apache2/include/ssl_toolkit_compat.h create mode 100644 rubbos/app/apache2/include/ssl_util_ssl.h create mode 100644 rubbos/app/apache2/include/ssl_util_table.h create mode 100644 rubbos/app/apache2/include/unixd.h create mode 100644 rubbos/app/apache2/include/util_cfgtree.h create mode 100644 rubbos/app/apache2/include/util_charset.h create mode 100644 rubbos/app/apache2/include/util_ebcdic.h create mode 100644 rubbos/app/apache2/include/util_filter.h create mode 100644 rubbos/app/apache2/include/util_ldap.h create mode 100644 rubbos/app/apache2/include/util_md5.h create mode 100644 rubbos/app/apache2/include/util_script.h create mode 100644 rubbos/app/apache2/include/util_time.h create mode 100644 rubbos/app/apache2/include/util_xml.h (limited to 'rubbos/app/apache2/include') diff --git a/rubbos/app/apache2/include/ap_compat.h b/rubbos/app/apache2/include/ap_compat.h new file mode 100644 index 00000000..4985bc4d --- /dev/null +++ b/rubbos/app/apache2/include/ap_compat.h @@ -0,0 +1,28 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_COMPAT_H +#define AP_COMPAT_H + +/* Drag in apu (and therefore apr) renamed symbols */ +#include "apu_compat.h" + +/* redefine 1.3.x symbols to the new symbol names */ + +#define MODULE_VAR_EXPORT AP_MODULE_DECLARE_DATA +#define ap_send_http_header(r) ; + +#endif /* AP_COMPAT_H */ diff --git a/rubbos/app/apache2/include/ap_config.h b/rubbos/app/apache2/include/ap_config.h new file mode 100644 index 00000000..9d8db24b --- /dev/null +++ b/rubbos/app/apache2/include/ap_config.h @@ -0,0 +1,256 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_CONFIG_H +#define AP_CONFIG_H + +#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(SUNOS4) || defined(IRIX) || defined(NEXT) || defined(AUX3) \ + || defined (UW) || defined(LYNXOS) || 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. */ +#if APR_HAS_OTHER_CHILD +#define AP_HAVE_RELIABLE_PIPED_LOGS TRUE +#endif + +#if APR_CHARSET_EBCDIC && !defined(APACHE_XLATE) +#define APACHE_XLATE +#endif + +#endif /* AP_CONFIG_H */ diff --git a/rubbos/app/apache2/include/ap_config_auto.h b/rubbos/app/apache2/include/ap_config_auto.h new file mode 100644 index 00000000..701a99e1 --- /dev/null +++ b/rubbos/app/apache2/include/ap_config_auto.h @@ -0,0 +1,250 @@ +/* include/ap_config_auto.h. Generated from ap_config_auto.h.in by configure. */ +/* include/ap_config_auto.h.in. Generated from configure.in by autoheader. */ +/* Define this if struct tm has a field tm_gmtoff */ +#define HAVE_GMTOFF 1 + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Location of the source for the current MPM */ +#define APACHE_MPM_DIR "server/mpm/worker" + +/* SuExec root directory */ +/* #undef AP_DOC_ROOT */ + +/* Allow modules to run hook after a fatal exception */ +/* #undef AP_ENABLE_EXCEPTION_HOOK */ + +/* Allow IPv4 connections on IPv6 listening sockets */ +#define AP_ENABLE_V4_MAPPED 1 + +/* Minimum allowed GID */ +/* #undef AP_GID_MIN */ + +/* User allowed to call SuExec */ +/* #undef AP_HTTPD_USER */ + +/* SuExec log file */ +/* #undef AP_LOG_EXEC */ + +/* Listening sockets are non-blocking when there are more than 1 */ +#define AP_NONBLOCK_WHEN_MULTI_LISTEN 1 + +/* safe shell path for SuExec */ +/* #undef AP_SAFE_PATH */ + +/* Signal used to gracefully restart */ +#define AP_SIG_GRACEFUL SIGUSR1 + +/* Signal used to gracefully restart (without SIG prefix) */ +#define AP_SIG_GRACEFUL_SHORT USR1 + +/* Signal used to gracefully restart (as a quoted string) */ +#define AP_SIG_GRACEFUL_STRING "SIGUSR1" + +/* umask for suexec'd process */ +/* #undef AP_SUEXEC_UMASK */ + +/* Location of the MIME types config file, relative to the Apache root + directory */ +#define AP_TYPES_CONFIG_FILE "conf/mime.types" + +/* Minimum allowed UID */ +/* #undef AP_UID_MIN */ + +/* byte order is unknown due to cross-compilation */ +/* #undef AP_UNKNOWN_BYTE_ORDER */ + +/* User subdirectory */ +/* #undef AP_USERDIR_SUFFIX */ + +/* Using autoconf to configure Apache */ +#define AP_USING_AUTOCONF 1 + +/* Define to 1 if you have the `bindprocessor' function. */ +/* #undef HAVE_BINDPROCESSOR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BSTRING_H */ + +/* Define to 1 if you have the `getgrnam' function. */ +#define HAVE_GETGRNAM 1 + +/* Define to 1 if you have the `getpwnam' function. */ +#define HAVE_GETPWNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `prctl' function. */ +#define HAVE_PRCTL 1 + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `SSL_set_cert_store' function. */ +/* #undef HAVE_SSL_SET_CERT_STORE */ + +/* Define to 1 if you have the `SSL_set_state' function. */ +/* #undef HAVE_SSL_SET_STATE */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `syslog' function. */ +#define HAVE_SYSLOG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IPC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PRCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_PROCESSOR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SEM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ZUTIL_H */ + +/* Root directory of the Apache install area */ +#define HTTPD_ROOT "/bottlenecks/rubbos/app/apache2" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Location of the config file, relative to the Apache root directory */ +#define SERVER_CONFIG_FILE "conf/httpd.conf" + +/* This platform doesn't suffer from the thundering herd problem */ +/* #undef SINGLE_LISTEN_UNSERIALIZED_ACCEPT */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Path to suexec binary */ +/* #undef SUEXEC_BIN */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to 'int' if doesn't define it for us */ +/* #undef rlim_t */ diff --git a/rubbos/app/apache2/include/ap_config_layout.h b/rubbos/app/apache2/include/ap_config_layout.h new file mode 100644 index 00000000..968d8f34 --- /dev/null +++ b/rubbos/app/apache2/include/ap_config_layout.h @@ -0,0 +1,59 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_CONFIG_LAYOUT_H +#define AP_CONFIG_LAYOUT_H + +/* Configured Apache directory layout */ +#define DEFAULT_PREFIX "/bottlenecks/rubbos/app/apache2" +#define DEFAULT_EXP_EXEC_PREFIX "/bottlenecks/rubbos/app/apache2" +#define DEFAULT_REL_EXEC_PREFIX "" +#define DEFAULT_EXP_BINDIR "/bottlenecks/rubbos/app/apache2/bin" +#define DEFAULT_REL_BINDIR "bin" +#define DEFAULT_EXP_SBINDIR "/bottlenecks/rubbos/app/apache2/bin" +#define DEFAULT_REL_SBINDIR "bin" +#define DEFAULT_EXP_LIBEXECDIR "/bottlenecks/rubbos/app/apache2/modules" +#define DEFAULT_REL_LIBEXECDIR "modules" +#define DEFAULT_EXP_MANDIR "/bottlenecks/rubbos/app/apache2/man" +#define DEFAULT_REL_MANDIR "man" +#define DEFAULT_EXP_SYSCONFDIR "/bottlenecks/rubbos/app/apache2/conf" +#define DEFAULT_REL_SYSCONFDIR "conf" +#define DEFAULT_EXP_DATADIR "/bottlenecks/rubbos/app/apache2" +#define DEFAULT_REL_DATADIR "" +#define DEFAULT_EXP_INSTALLBUILDDIR "/bottlenecks/rubbos/app/apache2/build" +#define DEFAULT_REL_INSTALLBUILDDIR "build" +#define DEFAULT_EXP_ERRORDIR "/bottlenecks/rubbos/app/apache2/error" +#define DEFAULT_REL_ERRORDIR "error" +#define DEFAULT_EXP_ICONSDIR "/bottlenecks/rubbos/app/apache2/icons" +#define DEFAULT_REL_ICONSDIR "icons" +#define DEFAULT_EXP_HTDOCSDIR "/bottlenecks/rubbos/app/apache2/htdocs" +#define DEFAULT_REL_HTDOCSDIR "htdocs" +#define DEFAULT_EXP_MANUALDIR "/bottlenecks/rubbos/app/apache2/manual" +#define DEFAULT_REL_MANUALDIR "manual" +#define DEFAULT_EXP_CGIDIR "/bottlenecks/rubbos/app/apache2/cgi-bin" +#define DEFAULT_REL_CGIDIR "cgi-bin" +#define DEFAULT_EXP_INCLUDEDIR "/bottlenecks/rubbos/app/apache2/include" +#define DEFAULT_REL_INCLUDEDIR "include" +#define DEFAULT_EXP_LOCALSTATEDIR "/bottlenecks/rubbos/app/apache2" +#define DEFAULT_REL_LOCALSTATEDIR "" +#define DEFAULT_EXP_RUNTIMEDIR "/bottlenecks/rubbos/app/apache2/logs" +#define DEFAULT_REL_RUNTIMEDIR "logs" +#define DEFAULT_EXP_LOGFILEDIR "/bottlenecks/rubbos/app/apache2/logs" +#define DEFAULT_REL_LOGFILEDIR "logs" +#define DEFAULT_EXP_PROXYCACHEDIR "/bottlenecks/rubbos/app/apache2/proxy" +#define DEFAULT_REL_PROXYCACHEDIR "proxy" + +#endif /* AP_CONFIG_LAYOUT_H */ diff --git a/rubbos/app/apache2/include/ap_listen.h b/rubbos/app/apache2/include/ap_listen.h new file mode 100644 index 00000000..291b8266 --- /dev/null +++ b/rubbos/app/apache2/include/ap_listen.h @@ -0,0 +1,119 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_LISTEN_H +#define AP_LISTEN_H + +#include "apr_network_io.h" +#include "httpd.h" +#include "http_config.h" + +/** + * @package Apache Listeners Library + */ + +typedef struct ap_listen_rec ap_listen_rec; +typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans); + +/** + * Apache's listeners record. These are used in the Multi-Processing Modules + * to setup all of the sockets for the MPM to listen to and accept on. + */ +struct ap_listen_rec { + /** + * The next listener in the list + */ + ap_listen_rec *next; + /** + * The actual socket + */ + apr_socket_t *sd; + /** + * The sockaddr the socket should bind to + */ + apr_sockaddr_t *bind_addr; + /** + * The accept function for this socket + */ + accept_function accept_func; + /** + * Is this socket currently active + */ + int active; +/* more stuff here, like which protocol is bound to the port */ +}; + +/** + * The global list of ap_listen_rec structures + */ +AP_DECLARE_DATA extern ap_listen_rec *ap_listeners; + +/** + * Setup all of the defaults for the listener list + */ +void ap_listen_pre_config(void); +#if !defined(SPMT_OS2_MPM) +/** + * Loop through the global ap_listen_rec list and create all of the required + * sockets. This executes the listen and bind on the sockets. + * @param s The global server_rec + * @return The number of open sockets. + * @warning This function is not available to Windows platforms, or the + * Prefork or SPMT_OS2 MPMs. + */ +int ap_setup_listeners(server_rec *s); +#endif +/* Split into two #if's to make the exports scripts easier. + */ +#if defined(SPMT_OS2_MPM) +/** + * Create and open a socket on the specified port. This includes listening + * and binding the socket. + * @param process The process record for the currently running server + * @param port The port to open a socket on. + * @return The number of open sockets + * @warning This function is only available to Windows platforms, or the + * Prefork or SPMT_OS2 MPMs. + */ +int ap_listen_open(process_rec *process, apr_port_t port); +#endif + +/* Although these functions are exported from libmain, they are not really + * public functions. These functions are actually called while parsing the + * config file, when one of the LISTEN_COMMANDS directives is read. These + * should not ever be called by external modules. ALL MPMs should include + * LISTEN_COMMANDS in their command_rec table so that these functions are + * called. + */ +const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg); +const char *ap_set_listener(cmd_parms *cmd, void *dummy, const char *ips); +const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, + const char *arg); +AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd, + void *dummy, + const char *arg); + +#define LISTEN_COMMANDS \ +AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \ + "Maximum length of the queue of pending connections, as used by listen(2)"), \ +AP_INIT_TAKE1("Listen", ap_set_listener, NULL, RSRC_CONF, \ + "A port number or a numeric IP address and a port number"), \ +AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \ + "Send buffer size in bytes"), \ +AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \ + RSRC_CONF, "Receive buffer size in bytes") + +#endif diff --git a/rubbos/app/apache2/include/ap_mmn.h b/rubbos/app/apache2/include/ap_mmn.h new file mode 100644 index 00000000..a3704803 --- /dev/null +++ b/rubbos/app/apache2/include/ap_mmn.h @@ -0,0 +1,127 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_AP_MMN_H +#define APACHE_AP_MMN_H + +/** + * @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 + * 20020903.13 (2.0.62-dev) Add *ftp_directory_charset to proxy_dir_conf + * 20020903.14 (2.0.64-dev) added ap_vhost_iterate_given_conn + */ + +#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */ + +#ifndef MODULE_MAGIC_NUMBER_MAJOR +#define MODULE_MAGIC_NUMBER_MAJOR 20020903 +#endif +#define MODULE_MAGIC_NUMBER_MINOR 14 /* 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 */ +#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR +#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using + +#endif /* !APACHE_AP_MMN_H */ diff --git a/rubbos/app/apache2/include/ap_mpm.h b/rubbos/app/apache2/include/ap_mpm.h new file mode 100644 index 00000000..9e41e904 --- /dev/null +++ b/rubbos/app/apache2/include/ap_mpm.h @@ -0,0 +1,176 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_MPM_H +#define AP_MPM_H + +#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) + */ +AP_DECLARE(int) ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf); + +/** + * 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) + */ +AP_DECLARE(int) ap_graceful_stop_signalled(void); + +/** + * 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. + */ +AP_DECLARE(apr_status_t) ap_os_create_privileged_process( + const request_rec *r, + apr_proc_t *newproc, + const char *progname, + const char * const *args, + const char * const *env, + apr_procattr_t *attr, + apr_pool_t *p); + +/* Subtypes/Values for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED */ +#define AP_MPMQ_NOT_SUPPORTED 0 /* This value specifies whether */ + /* an MPM is capable of */ + /* threading or forking. */ +#define AP_MPMQ_STATIC 1 /* This value specifies whether */ + /* an MPM is using a static # */ + /* threads or daemons. */ +#define AP_MPMQ_DYNAMIC 2 /* This value specifies whether */ + /* an MPM is using a dynamic # */ + /* threads or daemons. */ + +/* Values returned for AP_MPMQ_MPM_STATE */ +#define AP_MPMQ_STARTING 0 +#define AP_MPMQ_RUNNING 1 +#define AP_MPMQ_STOPPING 2 + +#define AP_MPMQ_MAX_DAEMON_USED 1 /* Max # of daemons used so far */ +#define AP_MPMQ_IS_THREADED 2 /* MPM can do threading */ +#define AP_MPMQ_IS_FORKED 3 /* MPM can do forking */ +#define AP_MPMQ_HARD_LIMIT_DAEMONS 4 /* The compiled max # daemons */ +#define AP_MPMQ_HARD_LIMIT_THREADS 5 /* The compiled max # threads */ +#define AP_MPMQ_MAX_THREADS 6 /* # of threads/child by config */ +#define AP_MPMQ_MIN_SPARE_DAEMONS 7 /* Min # of spare daemons */ +#define AP_MPMQ_MIN_SPARE_THREADS 8 /* Min # of spare threads */ +#define AP_MPMQ_MAX_SPARE_DAEMONS 9 /* Max # of spare daemons */ +#define AP_MPMQ_MAX_SPARE_THREADS 10 /* Max # of spare threads */ +#define AP_MPMQ_MAX_REQUESTS_DAEMON 11 /* Max # of requests per daemon */ +#define AP_MPMQ_MAX_DAEMONS 12 /* Max # of daemons by config */ +#define 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) + */ +AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result); + +/* 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 + +#if AP_ENABLE_EXCEPTION_HOOK +typedef struct ap_exception_info_t { + int sig; + pid_t pid; +} ap_exception_info_t; + +AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei)) +#endif /*AP_ENABLE_EXCEPTION_HOOK*/ + +#endif diff --git a/rubbos/app/apache2/include/ap_provider.h b/rubbos/app/apache2/include/ap_provider.h new file mode 100644 index 00000000..e9045bae --- /dev/null +++ b/rubbos/app/apache2/include/ap_provider.h @@ -0,0 +1,54 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_PROVIDER_H +#define AP_PROVIDER_H + +#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 + */ +AP_DECLARE(apr_status_t) ap_register_provider(apr_pool_t *pool, + const char *provider_group, + const char *provider_name, + const char *provider_version, + const void *provider); + +/** + * 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 + */ +AP_DECLARE(void *) ap_lookup_provider(const char *provider_group, + const char *provider_name, + const char *provider_version); + +#endif diff --git a/rubbos/app/apache2/include/ap_regkey.h b/rubbos/app/apache2/include/ap_regkey.h new file mode 100644 index 00000000..d3f41297 --- /dev/null +++ b/rubbos/app/apache2/include/ap_regkey.h @@ -0,0 +1,218 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_REGKEY_H +#define AP_REGKEY_H + +#if defined(WIN32) || defined(DOXYGEN) + +#include "apr.h" +#include "apr_pools.h" +#include "ap_config.h" /* Just for AP_DECLARE */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ap_regkey_t ap_regkey_t; + +/* Used to recover AP_REGKEY_* constants + */ +AP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i); + +/** + * @file ap_regkey.h + * @brief APR-style Win32 Registry Manipulation + */ + +/** + * Win32 Only: Constants for ap_regkey_open() + */ +#define AP_REGKEY_CLASSES_ROOT ap_regkey_const(0) +#define AP_REGKEY_CURRENT_CONFIG ap_regkey_const(1) +#define AP_REGKEY_CURRENT_USER ap_regkey_const(2) +#define AP_REGKEY_LOCAL_MACHINE ap_regkey_const(3) +#define AP_REGKEY_USERS ap_regkey_const(4) +#define AP_REGKEY_PERFORMANCE_DATA ap_regkey_const(5) +#define AP_REGKEY_DYN_DATA ap_regkey_const(6) + +/** + * Win32 Only: Flags for ap_regkey_value_set() + */ +#define AP_REGKEY_EXPAND 0x0001 + +/** + * Win32 Only: Open the specified registry key. + * @param newkey The opened registry key + * @param parentkey The open registry key of the parent, or one of + *
+ *           AP_REGKEY_CLASSES_ROOT
+ *           AP_REGKEY_CURRENT_CONFIG
+ *           AP_REGKEY_CURRENT_USER
+ *           AP_REGKEY_LOCAL_MACHINE
+ *           AP_REGKEY_USERS
+ *           AP_REGKEY_PERFORMANCE_DATA 
+ *           AP_REGKEY_DYN_DATA 
+ * 
+ * @param keyname The path of the key relative to the parent key + * @param flags Or'ed value of: + *
+ *           APR_READ             open key for reading
+ *           APR_WRITE            open key for writing
+ *           APR_CREATE           create the key if it doesn't exist
+ *           APR_EXCL             return error if APR_CREATE and key exists
+ * 
+ * @param pool The pool in which newkey is allocated + */ +AP_DECLARE(apr_status_t) ap_regkey_open(ap_regkey_t **newkey, + const ap_regkey_t *parentkey, + const char *keyname, + apr_int32_t flags, + apr_pool_t *pool); + +/** + * Win32 Only: Close the registry key opened or created by ap_regkey_open(). + * @param key The registry key to close + */ +AP_DECLARE(apr_status_t) ap_regkey_close(ap_regkey_t *key); + +/** + * Win32 Only: Remove the given registry key. + * @param parentkey The open registry key of the parent, or one of + *
+ *           AP_REGKEY_CLASSES_ROOT
+ *           AP_REGKEY_CURRENT_CONFIG
+ *           AP_REGKEY_CURRENT_USER
+ *           AP_REGKEY_LOCAL_MACHINE
+ *           AP_REGKEY_USERS
+ *           AP_REGKEY_PERFORMANCE_DATA 
+ *           AP_REGKEY_DYN_DATA 
+ * 
+ * @param keyname The path of the key relative to the parent key + * @param pool The pool used for temp allocations + * @remark ap_regkey_remove() is not recursive, although it removes + * all values within the given keyname, it will not remove a key + * containing subkeys. + */ +AP_DECLARE(apr_status_t) ap_regkey_remove(const ap_regkey_t *parent, + const char *keyname, + apr_pool_t *pool); + +/** + * Win32 Only: Retrieve a registry value string from an open key. + * @param result The string value retrieved + * @param key The registry key to retrieve the value from + * @param valuename The named value to retrieve (pass "" for the default) + * @param pool The pool used to store the result + * @remark There is no toggle to prevent environment variable expansion + * if the registry value is set with AP_REG_EXPAND (REG_EXPAND_SZ), such + * expansions are always performed. + */ +AP_DECLARE(apr_status_t) ap_regkey_value_get(char **result, + ap_regkey_t *key, + const char *valuename, + apr_pool_t *pool); + +/** + * Win32 Only: Store a registry value string into an open key. + * @param key The registry key to store the value into + * @param valuename The named value to store (pass "" for the default) + * @param value The string to store for the named value + * @param flags The option AP_REGKEY_EXPAND or 0, where AP_REGKEY_EXPAND + * values will find all %foo% variables expanded from the environment. + * @param pool The pool used for temp allocations + */ +AP_DECLARE(apr_status_t) ap_regkey_value_set(ap_regkey_t *key, + const char *valuename, + const char *value, + apr_int32_t flags, + apr_pool_t *pool); + +/** + * Win32 Only: Retrieve a raw byte value from an open key. + * @param result The raw bytes value retrieved + * @param resultsize Pointer to a variable to store the number raw bytes retrieved + * @param key The registry key to retrieve the value from + * @param valuename The named value to retrieve (pass "" for the default) + * @param pool The pool used to store the result + */ +AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result, + apr_size_t *resultsize, + apr_int32_t *resulttype, + ap_regkey_t *key, + const char *valuename, + apr_pool_t *pool); + +/** + * Win32 Only: Store a raw bytes value into an open key. + * @param key The registry key to store the value into + * @param valuename The named value to store (pass "" for the default) + * @param value The bytes to store for the named value + * @param valuesize The number of bytes for value + * @param valuetype The + * values will find all %foo% variables expanded from the environment. + * @param pool The pool used for temp allocations + */ +AP_DECLARE(apr_status_t) ap_regkey_value_raw_set(ap_regkey_t *key, + const char *valuename, + const void *value, + apr_size_t valuesize, + apr_int32_t valuetype, + apr_pool_t *pool); + +/** + * Win32 Only: Retrieve a registry value string from an open key. + * @param result The string elements retrieved from a REG_MULTI_SZ string array + * @param key The registry key to retrieve the value from + * @param valuename The named value to retrieve (pass "" for the default) + * @param pool The pool used to store the result + */ +AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result, + ap_regkey_t *key, + const char *valuename, + apr_pool_t *pool); + +/** + * Win32 Only: Store a registry value string array into an open key. + * @param key The registry key to store the value into + * @param valuename The named value to store (pass "" for the default) + * @param nelts The string elements to store in a REG_MULTI_SZ string array + * @param elts The number of elements in the elts string array + * @param pool The pool used for temp allocations + */ +AP_DECLARE(apr_status_t) ap_regkey_value_array_set(ap_regkey_t *key, + const char *valuename, + int nelts, + const char * const * elts, + apr_pool_t *pool); + +/** + * Win32 Only: Remove a registry value from an open key. + * @param key The registry key to remove the value from + * @param valuename The named value to remove (pass "" for the default) + * @param pool The pool used for temp allocations + */ +AP_DECLARE(apr_status_t) ap_regkey_value_remove(const ap_regkey_t *key, + const char *valuename, + apr_pool_t *pool); + +#ifdef __cplusplus +} +#endif + +#endif /* def WIN32 || def DOXYGEN */ + +#endif /* AP_REGKEY_H */ diff --git a/rubbos/app/apache2/include/ap_release.h b/rubbos/app/apache2/include/ap_release.h new file mode 100644 index 00000000..9fee3f4f --- /dev/null +++ b/rubbos/app/apache2/include/ap_release.h @@ -0,0 +1,56 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_RELEASE_H +#define AP_RELEASE_H + +#include "apr_general.h" /* stringify */ + +#define AP_SERVER_COPYRIGHT \ + "Copyright 2009 The Apache Software Foundation." + +/* + * 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" + */ +#define AP_SERVER_BASEVENDOR "Apache Software Foundation" +#define AP_SERVER_BASEPRODUCT "Apache" + +#define AP_SERVER_MAJORVERSION_NUMBER 2 +#define AP_SERVER_MINORVERSION_NUMBER 0 +#define AP_SERVER_PATCHLEVEL_NUMBER 64 +#define 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 + +#endif diff --git a/rubbos/app/apache2/include/apr.h b/rubbos/app/apache2/include/apr.h new file mode 100644 index 00000000..276e0ab6 --- /dev/null +++ b/rubbos/app/apache2/include/apr.h @@ -0,0 +1,414 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef APR_H +#define APR_H + +/* GENERATED FILE WARNING! DO NOT EDIT apr.h + * + * You must modify apr.h.in instead. + * + * And please, make an effort to stub apr.hw and apr.hnw in the process. + */ + +/** + * @file apr.h + * @brief APR Platform Definitions + * @remark This is a generated header generated from include/apr.h.in by + * ./configure, or copied from include/apr.hw or include/apr.hnw + * for Win32 or Netware by those build environments, respectively. + */ + +/** + * @defgroup APR Apache Portability Runtime library + * @{ + */ +/** + * @defgroup apr_platform Platform Definitions + * @{ + * @warning + * The actual values of macros and typedefs on this page
+ * are platform specific and should NOT be relied upon!
+ */ + +/* So that we can use inline on some critical functions, and use + * GNUC attributes (such as to get -Wall warnings for printf-like + * functions). Only do this in gcc 2.7 or later ... it may work + * on earlier stuff, but why chance it. + * + * We've since discovered that the gcc shipped with NeXT systems + * as "cc" is completely broken. It claims to be __GNUC__ and so + * on, but it doesn't implement half of the things that __GNUC__ + * means. In particular it's missing inline and the __attribute__ + * stuff. So we hack around it. PR#1613. -djg + */ +#if !defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\ + defined(NEXT) +#ifndef __attribute__ +#define __attribute__(__x) +#endif +#define APR_INLINE +#define APR_HAS_INLINE 0 +#else +#define APR_INLINE __inline__ +#define APR_HAS_INLINE 1 +#endif + +#define APR_HAVE_ARPA_INET_H 1 +#define APR_HAVE_CONIO_H 0 +#define APR_HAVE_CRYPT_H 1 +#define APR_HAVE_CTYPE_H 1 +#define APR_HAVE_DIRENT_H 1 +#define APR_HAVE_ERRNO_H 1 +#define APR_HAVE_FCNTL_H 1 +#define APR_HAVE_IO_H 0 +#define APR_HAVE_LIMITS_H 1 +#define APR_HAVE_NETDB_H 1 +#define APR_HAVE_NETINET_IN_H 1 +#define APR_HAVE_NETINET_SCTP_H 0 +#define APR_HAVE_NETINET_SCTP_UIO_H 0 +#define APR_HAVE_NETINET_TCP_H 1 +#define APR_HAVE_PTHREAD_H 1 +#define APR_HAVE_SEMAPHORE_H 1 +#define APR_HAVE_SIGNAL_H 1 +#define APR_HAVE_STDARG_H 1 +#define APR_HAVE_STDINT_H 1 +#define APR_HAVE_STDIO_H 1 +#define APR_HAVE_STDLIB_H 1 +#define APR_HAVE_STRING_H 1 +#define APR_HAVE_STRINGS_H 1 +#define APR_HAVE_SYS_IOCTL_H 1 +#define APR_HAVE_SYS_SENDFILE_H 1 +#define APR_HAVE_SYS_SIGNAL_H 1 +#define APR_HAVE_SYS_SOCKET_H 1 +#define APR_HAVE_SYS_SOCKIO_H 0 +#define APR_HAVE_SYS_SYSLIMITS_H 0 +#define APR_HAVE_SYS_TIME_H 1 +#define APR_HAVE_SYS_TYPES_H 1 +#define APR_HAVE_SYS_UIO_H 1 +#define APR_HAVE_SYS_UN_H 1 +#define APR_HAVE_SYS_WAIT_H 1 +#define APR_HAVE_TIME_H 1 +#define APR_HAVE_UNISTD_H 1 + +/** @} */ + +/* We don't include our conditional headers within the doxyblocks + * or the extern "C" namespace + */ + +#if APR_HAVE_SYS_TYPES_H +#include +#endif + +#if APR_HAVE_SYS_SOCKET_H +#include +#endif + +#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) +/* C99 7.18.4 requires that stdint.h only exposes INT64_C + * and UINT64_C for C++ implementations if this is defined: */ +#define __STDC_CONSTANT_MACROS +#endif + +#if APR_HAVE_STDINT_H +#include +#endif + +#if APR_HAVE_SYS_WAIT_H +#include +#endif + +#ifdef OS2 +#define INCL_DOS +#define INCL_DOSERRORS +#include +#endif + +/* header files for PATH_MAX, _POSIX_PATH_MAX */ +#if APR_HAVE_LIMITS_H +#include +#else +#if APR_HAVE_SYS_SYSLIMITS_H +#include +#endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup apr_platform + * @ingroup APR + * @{ + */ + +#define APR_HAVE_SHMEM_MMAP_TMP 1 +#define APR_HAVE_SHMEM_MMAP_SHM 1 +#define APR_HAVE_SHMEM_MMAP_ZERO 1 +#define APR_HAVE_SHMEM_SHMGET_ANON 1 +#define APR_HAVE_SHMEM_SHMGET 1 +#define APR_HAVE_SHMEM_MMAP_ANON 1 +#define APR_HAVE_SHMEM_BEOS 0 + +#define APR_USE_SHMEM_MMAP_TMP 0 +#define APR_USE_SHMEM_MMAP_SHM 0 +#define APR_USE_SHMEM_MMAP_ZERO 0 +#define APR_USE_SHMEM_SHMGET_ANON 0 +#define APR_USE_SHMEM_SHMGET 1 +#define APR_USE_SHMEM_MMAP_ANON 1 +#define APR_USE_SHMEM_BEOS 0 + +#define APR_USE_FLOCK_SERIALIZE 0 +#define APR_USE_SYSVSEM_SERIALIZE 1 +#define APR_USE_POSIXSEM_SERIALIZE 0 +#define APR_USE_FCNTL_SERIALIZE 0 +#define APR_USE_PROC_PTHREAD_SERIALIZE 0 +#define APR_USE_PTHREAD_SERIALIZE 1 + +#define APR_HAS_FLOCK_SERIALIZE 1 +#define APR_HAS_SYSVSEM_SERIALIZE 1 +#define APR_HAS_POSIXSEM_SERIALIZE 0 +#define APR_HAS_FCNTL_SERIALIZE 1 +#define APR_HAS_PROC_PTHREAD_SERIALIZE 1 +#define APR_HAS_RWLOCK_SERIALIZE 0 + +#define APR_PROCESS_LOCK_IS_GLOBAL 0 + +#define APR_HAVE_CORKABLE_TCP 1 +#define APR_HAVE_GETRLIMIT 1 +#define APR_HAVE_IN_ADDR 1 +#define APR_HAVE_INET_ADDR 1 +#define APR_HAVE_INET_NETWORK 1 +#define APR_HAVE_IPV6 1 +#define APR_HAVE_MEMMOVE 1 +#define APR_HAVE_SETRLIMIT 1 +#define APR_HAVE_SIGACTION 1 +#define APR_HAVE_SIGSUSPEND 1 +#define APR_HAVE_SIGWAIT 1 +#define APR_HAVE_STRCASECMP 1 +#define APR_HAVE_STRDUP 1 +#define APR_HAVE_STRICMP 0 +#define APR_HAVE_STRNCASECMP 1 +#define APR_HAVE_STRNICMP 0 +#define APR_HAVE_STRSTR 1 +#define APR_HAVE_MEMCHR 1 +#define APR_HAVE_STRUCT_RLIMIT 1 +#define APR_HAVE_UNION_SEMUN 0 +#define APR_HAVE_SCTP 0 + +/* APR Feature Macros */ +#define APR_HAS_SHARED_MEMORY 1 +#define APR_HAS_THREADS 1 +#define APR_HAS_SENDFILE 1 +#define APR_HAS_MMAP 1 +#define APR_HAS_FORK 1 +#define APR_HAS_RANDOM 1 +#define APR_HAS_OTHER_CHILD 1 +#define APR_HAS_DSO 1 +#define APR_HAS_SO_ACCEPTFILTER 0 +#define APR_HAS_UNICODE_FS 0 +#define APR_HAS_PROC_INVOKED 0 +#define APR_HAS_USER 1 +#define APR_HAS_LARGE_FILES 0 +#define APR_HAS_XTHREAD_FILES 0 +#define APR_HAS_OS_UUID 0 + +/* APR sets APR_FILES_AS_SOCKETS to 1 on systems where it is possible + * to poll on files/pipes. On such a system, the application can + * call apr_socket_from_file() to get an APR socket representation and + * then pass the socket representation to apr_poll_socket_add(). + */ +#define APR_FILES_AS_SOCKETS 1 + +/* Not all platforms have a real INADDR_NONE. This macro replaces INADDR_NONE + * on all platforms. + */ +#define APR_INADDR_NONE INADDR_NONE + +/* This macro indicates whether or not EBCDIC is the native character set. + */ +#define APR_CHARSET_EBCDIC 0 + +/* If we have a TCP implementation that can be "corked", what flag + * do we use? + */ +#define APR_TCP_NOPUSH_FLAG TCP_CORK + +/* Is the TCP_NODELAY socket option inherited from listening sockets? +*/ +#define APR_TCP_NODELAY_INHERITED 1 + +/* Is the O_NONBLOCK flag inherited from listening sockets? +*/ +#define APR_O_NONBLOCK_INHERITED 0 + +/* Typedefs that APR needs. */ + +typedef unsigned char apr_byte_t; + +typedef short apr_int16_t; +typedef unsigned short apr_uint16_t; + +typedef int apr_int32_t; +typedef unsigned int apr_uint32_t; + +typedef long apr_int64_t; +typedef unsigned long apr_uint64_t; + +typedef size_t apr_size_t; +typedef ssize_t apr_ssize_t; +typedef off_t apr_off_t; +typedef socklen_t apr_socklen_t; + +typedef unsigned long apr_ino_t; + +#define APR_SIZEOF_VOIDP 8 + +/* Mechanisms to properly type numeric literals */ +#define APR_INT64_C(val) INT64_C(val) + +/* Definitions that APR programs need to work properly. */ + +/** + * Thread callbacks from APR functions must be declared with APR_THREAD_FUNC, + * so that they follow the platform's calling convention. + * @example + */ +/** void* APR_THREAD_FUNC my_thread_entry_fn(apr_thread_t *thd, void *data); + */ +#define APR_THREAD_FUNC + +/** + * The public APR functions are declared with APR_DECLARE(), so they may + * use the most appropriate calling convention. Public APR functions with + * variable arguments must use APR_DECLARE_NONSTD(). + * + * @remark Both the declaration and implementations must use the same macro. + * @example + */ +/** APR_DECLARE(rettype) apr_func(args) + * @see APR_DECLARE_NONSTD @see APR_DECLARE_DATA + * @remark Note that when APR compiles the library itself, it passes the + * symbol -DAPR_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) + * to export public symbols from the dynamic library build.\n + * The user must define the APR_DECLARE_STATIC when compiling to target + * the static APR library on some platforms (e.g. Win32.) The public symbols + * are neither exported nor imported when APR_DECLARE_STATIC is defined.\n + * By default, compiling an application and including the APR public + * headers, without defining APR_DECLARE_STATIC, will prepare the code to be + * linked to the dynamic library. + */ +#define APR_DECLARE(type) type + +/** + * The public APR functions using variable arguments are declared with + * APR_DECLARE_NONSTD(), as they must follow the C language calling convention. + * @see APR_DECLARE @see APR_DECLARE_DATA + * @remark Both the declaration and implementations must use the same macro. + * @example + */ +/** APR_DECLARE_NONSTD(rettype) apr_func(args, ...); + */ +#define APR_DECLARE_NONSTD(type) type + +/** + * The public APR variables are declared with AP_MODULE_DECLARE_DATA. + * This assures the appropriate indirection is invoked at compile time. + * @see APR_DECLARE @see APR_DECLARE_NONSTD + * @remark Note that the declaration and implementations use different forms, + * but both must include the macro. + * @example + */ +/** extern APR_DECLARE_DATA type apr_variable;\n + * APR_DECLARE_DATA type apr_variable = value; + */ +#define APR_DECLARE_DATA + +/* Define APR_SSIZE_T_FMT. + * If ssize_t is an integer we define it to be "d", + * if ssize_t is a long int we define it to be "ld", + * if ssize_t is neither we declare an error here. + * I looked for a better way to define this here, but couldn't find one, so + * to find the logic for this definition search for "ssize_t_fmt" in + * configure.in. + */ +#define APR_SSIZE_T_FMT "ld" + +/* And APR_SIZE_T_FMT */ +#define APR_SIZE_T_FMT "ld" + +/* And APR_OFF_T_FMT */ +#define APR_OFF_T_FMT "ld" + +/* And APR_PID_T_FMT */ +#define APR_PID_T_FMT "d" + +/* And APR_INT64_T_FMT */ +#define APR_INT64_T_FMT "ld" +#define APR_INT64_T_FMT_LEN 2 + +/* And APR_UINT64_T_FMT */ +#define APR_UINT64_T_FMT "lu" +#define APR_UINT64_T_FMT_LEN 2 + +/* And APR_UINT64_T_HEX_FMT */ +#define APR_UINT64_T_HEX_FMT "lx" +#define APR_UINT64_T_HEX_FMT_LEN (sizeof(APR_UINT64_T_HEX_FMT) - 1) + +/* Deal with atoi64 variables ... these should move to apr_private.h */ +#define APR_HAVE_INT64_STRFN 1 +#define APR_INT64_STRFN strtol + +/* are we going to force the generic atomic operations */ +#define APR_FORCE_ATOMIC_GENERIC 1 + +/* Does the proc mutex lock threads too */ +#define APR_PROC_MUTEX_IS_GLOBAL 0 + +/* Local machine definition for console and log output. */ +#define APR_EOL_STR "\n" + + +#if APR_HAVE_SYS_WAIT_H +#ifdef WEXITSTATUS +#define apr_wait_t int +#else +#define apr_wait_t union wait +#define WEXITSTATUS(status) (int)((status).w_retcode) +#define WTERMSIG(status) (int)((status).w_termsig) +#endif /* !WEXITSTATUS */ +#endif /* HAVE_SYS_WAIT_H */ + +#if defined(PATH_MAX) +#define APR_PATH_MAX PATH_MAX +#elif defined(_POSIX_PATH_MAX) +#define APR_PATH_MAX _POSIX_PATH_MAX +#else +#error no decision has been made on APR_PATH_MAX for your platform +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* APR_H */ diff --git a/rubbos/app/apache2/include/apr_allocator.h b/rubbos/app/apache2/include/apr_allocator.h new file mode 100644 index 00000000..b880c4e2 --- /dev/null +++ b/rubbos/app/apache2/include/apr_allocator.h @@ -0,0 +1,170 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_ALLOCATOR_H +#define APR_ALLOCATOR_H + +/** + * @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" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup apr_allocator Internal Memory Allocation + * @ingroup APR + * @{ + */ + +/** the allocator structure */ +typedef struct apr_allocator_t apr_allocator_t; +/** the structure which holds information about the allocation */ +typedef struct apr_memnode_t apr_memnode_t; + +/** basic memory node structure */ +struct apr_memnode_t { + apr_memnode_t *next; /**< next memnode */ + apr_memnode_t **ref; /**< reference to self */ + apr_uint32_t index; /**< size */ + apr_uint32_t free_index; /**< how much free */ + char *first_avail; /**< pointer to first free memory */ + char *endp; /**< pointer to end of free memory */ +}; + +/** The base size of a memory node - aligned. */ +#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t)) + +/** Symbolic constants */ +#define APR_ALLOCATOR_MAX_FREE_UNLIMITED 0 + +/** + * Create a new allocator + * @param allocator The allocator we have just created. + * + */ +APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator); + +/** + * 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. + */ +APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator); + +/** + * 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) + */ +APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator, + apr_size_t size); + +/** + * 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 + */ +APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator, + apr_memnode_t *memnode); + +#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. + */ +APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator, + apr_pool_t *pool); + +/** @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 + */ +APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator); + +/** @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. + */ +APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator, + apr_size_t size); + +/** @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" + +#if 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 */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APR_ALLOCATOR_H */ diff --git a/rubbos/app/apache2/include/apr_anylock.h b/rubbos/app/apache2/include/apr_anylock.h new file mode 100644 index 00000000..6b724de2 --- /dev/null +++ b/rubbos/app/apache2/include/apr_anylock.h @@ -0,0 +1,128 @@ +/* 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_anylock.h + * @brief APR-Util transparent any lock flavor wrapper + */ +#ifndef APR_ANYLOCK_H +#define APR_ANYLOCK_H + +#include "apr_proc_mutex.h" +#include "apr_thread_mutex.h" +#include "apr_thread_rwlock.h" + +/** Structure that may contain any APR lock type */ +typedef struct apr_anylock_t { + /** Indicates what type of lock is in lock */ + enum tm_lock { + apr_anylock_none, /**< None */ + apr_anylock_procmutex, /**< Process-based */ + apr_anylock_threadmutex, /**< Thread-based */ + apr_anylock_readlock, /**< Read lock */ + apr_anylock_writelock /**< Write lock */ + } type; + /** Union of all possible APR locks */ + union apr_anylock_u_t { + apr_proc_mutex_t *pm; /**< Process mutex */ +#if APR_HAS_THREADS + apr_thread_mutex_t *tm; /**< Thread mutex */ + apr_thread_rwlock_t *rw; /**< Read-write lock */ +#endif + } lock; +} apr_anylock_t; + +#if APR_HAS_THREADS + +/** Lock an apr_anylock_t structure */ +#define APR_ANYLOCK_LOCK(lck) \ + (((lck)->type == apr_anylock_none) \ + ? APR_SUCCESS \ + : (((lck)->type == apr_anylock_threadmutex) \ + ? apr_thread_mutex_lock((lck)->lock.tm) \ + : (((lck)->type == apr_anylock_procmutex) \ + ? apr_proc_mutex_lock((lck)->lock.pm) \ + : (((lck)->type == apr_anylock_readlock) \ + ? apr_thread_rwlock_rdlock((lck)->lock.rw) \ + : (((lck)->type == apr_anylock_writelock) \ + ? apr_thread_rwlock_wrlock((lck)->lock.rw) \ + : APR_EINVAL))))) + +#else /* APR_HAS_THREADS */ + +#define APR_ANYLOCK_LOCK(lck) \ + (((lck)->type == apr_anylock_none) \ + ? APR_SUCCESS \ + : (((lck)->type == apr_anylock_procmutex) \ + ? apr_proc_mutex_lock((lck)->lock.pm) \ + : APR_EINVAL)) + +#endif /* APR_HAS_THREADS */ + +#if APR_HAS_THREADS + +/** Try to lock an apr_anylock_t structure */ +#define APR_ANYLOCK_TRYLOCK(lck) \ + (((lck)->type == apr_anylock_none) \ + ? APR_SUCCESS \ + : (((lck)->type == apr_anylock_threadmutex) \ + ? apr_thread_mutex_trylock((lck)->lock.tm) \ + : (((lck)->type == apr_anylock_procmutex) \ + ? apr_proc_mutex_trylock((lck)->lock.pm) \ + : (((lck)->type == apr_anylock_readlock) \ + ? apr_thread_rwlock_tryrdlock((lck)->lock.rw) \ + : (((lck)->type == apr_anylock_writelock) \ + ? apr_thread_rwlock_trywrlock((lck)->lock.rw) \ + : APR_EINVAL))))) + +#else /* APR_HAS_THREADS */ + +#define APR_ANYLOCK_TRYLOCK(lck) \ + (((lck)->type == apr_anylock_none) \ + ? APR_SUCCESS \ + : (((lck)->type == apr_anylock_procmutex) \ + ? apr_proc_mutex_trylock((lck)->lock.pm) \ + : APR_EINVAL)) + +#endif /* APR_HAS_THREADS */ + +#if APR_HAS_THREADS + +/** Unlock an apr_anylock_t structure */ +#define APR_ANYLOCK_UNLOCK(lck) \ + (((lck)->type == apr_anylock_none) \ + ? APR_SUCCESS \ + : (((lck)->type == apr_anylock_threadmutex) \ + ? apr_thread_mutex_unlock((lck)->lock.tm) \ + : (((lck)->type == apr_anylock_procmutex) \ + ? apr_proc_mutex_unlock((lck)->lock.pm) \ + : ((((lck)->type == apr_anylock_readlock) || \ + ((lck)->type == apr_anylock_writelock)) \ + ? apr_thread_rwlock_unlock((lck)->lock.rw) \ + : APR_EINVAL)))) + +#else /* APR_HAS_THREADS */ + +#define APR_ANYLOCK_UNLOCK(lck) \ + (((lck)->type == apr_anylock_none) \ + ? APR_SUCCESS \ + : (((lck)->type == apr_anylock_procmutex) \ + ? apr_proc_mutex_unlock((lck)->lock.pm) \ + : APR_EINVAL)) + +#endif /* APR_HAS_THREADS */ + +#endif /* !APR_ANYLOCK_H */ diff --git a/rubbos/app/apache2/include/apr_atomic.h b/rubbos/app/apache2/include/apr_atomic.h new file mode 100644 index 00000000..87889292 --- /dev/null +++ b/rubbos/app/apache2/include/apr_atomic.h @@ -0,0 +1,314 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_ATOMIC_H +#define APR_ATOMIC_H + +/** + * @file apr_atomic.h + * @brief APR Atomic Operations + */ + +#include "apr.h" +#include "apr_pools.h" + +/* Platform includes for atomics */ +#if defined(NETWARE) || defined(__MVS__) /* OS/390 */ +#include +#elif defined(__FreeBSD__) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup apr_atomic Atomic Operations + * @ingroup APR + * @{ + */ + +/* easiest way to get these documented for the moment */ +#if defined(DOXYGEN) +/** + * structure for holding a atomic value. + * this number >only< has a 24 bit size on some platforms + */ +typedef apr_atomic_t; + +/** + * this function is required on some platforms to initialize the + * atomic operation's internal structures + * @param p pool + * @return APR_SUCCESS on successful completion + */ +apr_status_t apr_atomic_init(apr_pool_t *p); +/** + * read the value stored in a atomic variable + * @param mem the pointer + * @warning on certain platforms this number is not stored + * directly in the pointer. in others it is + */ +apr_uint32_t apr_atomic_read(volatile apr_atomic_t *mem); +/** + * set the value for atomic. + * @param mem the pointer + * @param val the value + */ +void apr_atomic_set(volatile apr_atomic_t *mem, apr_uint32_t val); +/** + * Add 'val' to the atomic variable + * @param mem pointer to the atomic value + * @param val the addition + */ +void apr_atomic_add(volatile apr_atomic_t *mem, apr_uint32_t val); + +/** + * increment the atomic variable by 1 + * @param mem pointer to the atomic value + */ +void apr_atomic_inc(volatile apr_atomic_t *mem); + +/** + * decrement the atomic variable by 1 + * @param mem pointer to the atomic value + * @return zero if the value is zero, otherwise non-zero + */ +int apr_atomic_dec(volatile apr_atomic_t *mem); + +/** + * compare the atomic's value with cmp. + * If they are the same swap the value with 'with' + * @param mem pointer to the atomic value + * @param with what to swap it with + * @param cmp the value to compare it to + * @return the old value of the atomic + * @warning do not mix apr_atomic's with the CAS function. + * on some platforms they may be implemented by different mechanisms + */ +apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem, long with, long cmp); + +/** + * compare the pointer's value with cmp. + * If they are the same swap the value with 'with' + * @param mem pointer to the pointer + * @param with what to swap it with + * @param cmp the value to compare it to + * @return the old value of the pointer + */ +void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp); +#else /* !DOXYGEN */ + +/* The following definitions provide optimized, OS-specific + * implementations of the APR atomic functions on various + * platforms. Any atomic operation that isn't redefined as + * a macro here will be declared as a function later, and + * apr_atomic.c will provide a mutex-based default implementation. + */ + +#if defined(WIN32) + +#define apr_atomic_t LONG + +#define apr_atomic_add(mem, val) InterlockedExchangeAdd(mem,val) +#define apr_atomic_dec(mem) InterlockedDecrement(mem) +#define apr_atomic_inc(mem) InterlockedIncrement(mem) +#define apr_atomic_set(mem, val) InterlockedExchange(mem, val) +#define apr_atomic_read(mem) (*mem) +#define apr_atomic_cas(mem,with,cmp) InterlockedCompareExchange(mem,with,cmp) +#define apr_atomic_init(pool) APR_SUCCESS +#define apr_atomic_casptr(mem,with,cmp) InterlockedCompareExchangePointer(mem,with,cmp) + +#elif defined(NETWARE) + +#define apr_atomic_t unsigned long + +#define apr_atomic_add(mem, val) atomic_add(mem,val) +#define apr_atomic_inc(mem) atomic_inc(mem) +#define apr_atomic_set(mem, val) (*mem = val) +#define apr_atomic_read(mem) (*mem) +#define apr_atomic_init(pool) APR_SUCCESS +#define apr_atomic_cas(mem,with,cmp) atomic_cmpxchg((unsigned long *)(mem),(unsigned long)(cmp),(unsigned long)(with)) + +int apr_atomic_dec(apr_atomic_t *mem); +void *apr_atomic_casptr(void **mem, void *with, const void *cmp); +#define APR_OVERRIDE_ATOMIC_DEC 1 +#define APR_OVERRIDE_ATOMIC_CASPTR 1 + +inline int apr_atomic_dec(apr_atomic_t *mem) +{ + return (atomic_xchgadd(mem, 0xFFFFFFFF) - 1); +} + +inline void *apr_atomic_casptr(void **mem, void *with, const void *cmp) +{ + return (void*)atomic_cmpxchg((unsigned long *)mem,(unsigned long)cmp,(unsigned long)with); +} + +#elif defined(__FreeBSD__) + +#define apr_atomic_t apr_uint32_t +#define apr_atomic_add(mem, val) (atomic_add_int(mem,val),mem) +#define apr_atomic_dec(mem) (atomic_subtract_int(mem,1),mem) +#define apr_atomic_inc(mem) (atomic_add_int(mem,1),mem) +#define apr_atomic_set(mem, val) (atomic_set_int(mem, val),mem) +#define apr_atomic_read(mem) (*mem) + +#elif (defined(__linux__) || defined(__EMX__)) && defined(__i386__) && !APR_FORCE_ATOMIC_GENERIC + +#define apr_atomic_t apr_uint32_t +#define apr_atomic_cas(mem,with,cmp) \ +({ apr_atomic_t prev; \ + asm volatile ("lock; cmpxchgl %1, %2" \ + : "=a" (prev) \ + : "r" (with), "m" (*(mem)), "0"(cmp) \ + : "memory"); \ + prev;}) + +#define apr_atomic_add(mem, val) \ +({ register apr_atomic_t last; \ + do { \ + last = *(mem); \ + } while (apr_atomic_cas((mem), last + (val), last) != last); \ + }) + +#define apr_atomic_dec(mem) \ +({ register apr_atomic_t last; \ + do { \ + last = *(mem); \ + } while (apr_atomic_cas((mem), last - 1, last) != last); \ + (--last != 0); }) + +#define apr_atomic_inc(mem) \ +({ register apr_atomic_t last; \ + do { \ + last = *(mem); \ + } while (apr_atomic_cas((mem), last + 1, last) != last); \ + }) + +#define apr_atomic_set(mem, val) (*(mem) = val) +#define apr_atomic_read(mem) (*(mem)) +#define apr_atomic_init(pool) APR_SUCCESS + +#elif defined(__MVS__) /* OS/390 */ + +#define apr_atomic_t cs_t + +apr_int32_t apr_atomic_add(volatile apr_atomic_t *mem, apr_int32_t val); +apr_uint32_t apr_atomic_cas(volatile apr_atomic_t *mem, apr_uint32_t swap, + apr_uint32_t cmp); +#define APR_OVERRIDE_ATOMIC_ADD 1 +#define APR_OVERRIDE_ATOMIC_CAS 1 + +#define apr_atomic_inc(mem) apr_atomic_add(mem, 1) +#define apr_atomic_dec(mem) apr_atomic_add(mem, -1) +#define apr_atomic_init(pool) APR_SUCCESS + +/* warning: the following two operations, _read and _set, are atomic + * if the memory variables are aligned (the usual case). + * + * If you try really hard and manage to mis-align them, they are not + * guaranteed to be atomic on S/390. But then your program will blow up + * with SIGBUS on a sparc, or with a S0C6 abend if you use the mis-aligned + * variables with other apr_atomic_* operations on OS/390. + */ + +#define apr_atomic_read(p) (*p) +#define apr_atomic_set(mem, val) (*mem = val) + +#endif /* end big if-elseif switch for platform-specifics */ + + +/* Default implementation of the atomic API + * The definitions above may override some or all of the + * atomic functions with optimized, platform-specific versions. + * Any operation that hasn't been overridden as a macro above + * is declared as a function here, unless APR_OVERRIDE_ATOMIC_[OPERATION] + * is defined. (The purpose of the APR_OVERRIDE_ATOMIC_* is + * to allow a platform to declare an apr_atomic_*() function + * with a different signature than the default.) + */ + +#if !defined(apr_atomic_t) +#define apr_atomic_t apr_uint32_t +#endif + +#if !defined(apr_atomic_init) && !defined(APR_OVERRIDE_ATOMIC_INIT) +apr_status_t apr_atomic_init(apr_pool_t *p); +#endif + +#if !defined(apr_atomic_read) && !defined(APR_OVERRIDE_ATOMIC_READ) +#define apr_atomic_read(p) *p +#endif + +#if !defined(apr_atomic_set) && !defined(APR_OVERRIDE_ATOMIC_SET) +void apr_atomic_set(volatile apr_atomic_t *mem, apr_uint32_t val); +#define APR_ATOMIC_NEED_DEFAULT_INIT 1 +#endif + +#if !defined(apr_atomic_add) && !defined(APR_OVERRIDE_ATOMIC_ADD) +void apr_atomic_add(volatile apr_atomic_t *mem, apr_uint32_t val); +#define APR_ATOMIC_NEED_DEFAULT_INIT 1 +#endif + +#if !defined(apr_atomic_inc) && !defined(APR_OVERRIDE_ATOMIC_INC) +void apr_atomic_inc(volatile apr_atomic_t *mem); +#define APR_ATOMIC_NEED_DEFAULT_INIT 1 +#endif + +#if !defined(apr_atomic_dec) && !defined(APR_OVERRIDE_ATOMIC_DEC) +int apr_atomic_dec(volatile apr_atomic_t *mem); +#define APR_ATOMIC_NEED_DEFAULT_INIT 1 +#endif + +#if !defined(apr_atomic_cas) && !defined(APR_OVERRIDE_ATOMIC_CAS) +apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem,long with,long cmp); +#define APR_ATOMIC_NEED_DEFAULT_INIT 1 +#endif + +#if !defined(apr_atomic_casptr) && !defined(APR_OVERRIDE_ATOMIC_CASPTR) +#if APR_SIZEOF_VOIDP == 4 +#define apr_atomic_casptr(mem, with, cmp) (void *)apr_atomic_cas((apr_uint32_t *)(mem), (long)(with), (long)cmp) +#else +void *apr_atomic_casptr(volatile void **mem, void *with, const void *cmp); +#define APR_ATOMIC_NEED_DEFAULT_INIT 1 +#endif +#endif + +#ifndef APR_ATOMIC_NEED_DEFAULT_INIT +#define APR_ATOMIC_NEED_DEFAULT_INIT 0 +#endif + +/* If we're using the default versions of any of the atomic functions, + * we'll need the atomic init to set up mutexes. If a platform-specific + * override above has replaced the atomic_init with a macro, it's an error. + */ +#if APR_ATOMIC_NEED_DEFAULT_INIT +#if defined(apr_atomic_init) || defined(APR_OVERRIDE_ATOMIC_INIT) +#error Platform has redefined apr_atomic_init, but other default default atomics require a default apr_atomic_init +#endif +#endif /* APR_ATOMIC_NEED_DEFAULT_INIT */ + +#endif /* !DOXYGEN */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APR_ATOMIC_H */ diff --git a/rubbos/app/apache2/include/apr_base64.h b/rubbos/app/apache2/include/apr_base64.h new file mode 100644 index 00000000..f37614dc --- /dev/null +++ b/rubbos/app/apache2/include/apr_base64.h @@ -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. + * The apr_vsnprintf/apr_snprintf functions are based on, and used with the + * permission of, the SIO stdio-replacement strx_* functions by Panos + * Tsirigotis for xinetd. + */ + +/** + * @file apr_base64.h + * @brief APR-UTIL Base64 Encoding + */ +#ifndef APR_BASE64_H +#define APR_BASE64_H + +#include "apu.h" +#include "apr_general.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup APR_Util_Base64 Base64 Encoding + * @ingroup APR_Util + * @{ + */ + +/* Simple BASE64 encode/decode functions. + * + * As we might encode binary strings, hence we require the length of + * the incoming plain source. And return the length of what we decoded. + * + * The decoding function takes any non valid char (i.e. whitespace, \0 + * or anything non A-Z,0-9 etc as terminal. + * + * plain strings/binary sequences are not assumed '\0' terminated. Encoded + * strings are neither. But probably should. + * + */ + +/** + * Given the length of an un-encrypted string, get the length of the + * encrypted string. + * @param len the length of an unencrypted string. + * @return the length of the string after it is encrypted + */ +APU_DECLARE(int) apr_base64_encode_len(int len); + +/** + * Encode a text string using base64encoding. + * @param coded_dst The destination string for the encoded string. + * @param plain_src The original string in plain text + * @param len_plain_src The length of the plain text string + * @return the length of the encoded string + */ +APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src, + int len_plain_src); + +/** + * Encode an EBCDIC string using base64encoding. + * @param coded_dst The destination string for the encoded string. + * @param plain_src The original string in plain text + * @param len_plain_src The length of the plain text string + * @return the length of the encoded string + */ +APU_DECLARE(int) apr_base64_encode_binary(char * coded_dst, + const unsigned char *plain_src, + int len_plain_src); + +/** + * Determine the maximum buffer length required to decode the plain text + * string given the encoded string. + * @param coded_src The encoded string + * @return the maximum required buffer length for the plain text string + */ +APU_DECLARE(int) apr_base64_decode_len(const char * coded_src); + +/** + * Decode a string to plain text + * @param plain_dst The destination string for the plain text + * @param coded_src The encoded string + * @return the length of the plain text string + */ +APU_DECLARE(int) apr_base64_decode(char * plain_dst, const char *coded_src); + +/** + * Decode an EBCDIC string to plain text + * @param plain_dst The destination string for the plain text + * @param coded_src The encoded string + * @return the length of the plain text string + */ +APU_DECLARE(int) apr_base64_decode_binary(unsigned char * plain_dst, + const char *coded_src); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !APR_BASE64_H */ diff --git a/rubbos/app/apache2/include/apr_buckets.h b/rubbos/app/apache2/include/apr_buckets.h new file mode 100644 index 00000000..7f1b05ff --- /dev/null +++ b/rubbos/app/apache2/include/apr_buckets.h @@ -0,0 +1,1495 @@ +/* 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 + */ + +#ifndef APR_BUCKETS_H +#define APR_BUCKETS_H + +#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 /* for struct iovec */ +#endif +#if APR_HAVE_STDARG_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup APR_Util_Bucket_Brigades Bucket Brigades + * @ingroup APR_Util + * @{ + */ + +/** default bucket buffer size - 8KB minus room for memory allocator headers */ +#define APR_BUCKET_BUFF_SIZE 8000 + +/** Determines how a bucket or brigade should be read */ +typedef enum { + APR_BLOCK_READ, /**< block until data becomes available */ + APR_NONBLOCK_READ /**< return immediately if no data is available */ +} apr_read_type_e; + +/** + * The one-sentence buzzword-laden overview: Bucket brigades represent + * a complex data stream that can be passed through a layered IO + * system without unnecessary copying. A longer overview follows... + * + * A bucket brigade is a doubly linked list (ring) of buckets, so we + * aren't limited to inserting at the front and removing at the end. + * Buckets are only passed around as members of a brigade, although + * singleton buckets can occur for short periods of time. + * + * Buckets are data stores of various types. They can refer to data in + * memory, or part of a file or mmap area, or the output of a process, + * etc. Buckets also have some type-dependent accessor functions: + * read, split, copy, setaside, and destroy. + * + * read returns the address and size of the data in the bucket. If the + * data isn't in memory then it is read in and the bucket changes type + * so that it can refer to the new location of the data. If all the + * data doesn't fit in the bucket then a new bucket is inserted into + * the brigade to hold the rest of it. + * + * split divides the data in a bucket into two regions. After a split + * the original bucket refers to the first part of the data and a new + * bucket inserted into the brigade after the original bucket refers + * to the second part of the data. Reference counts are maintained as + * necessary. + * + * setaside ensures that the data in the bucket has a long enough + * lifetime. Sometimes it is convenient to create a bucket referring + * to data on the stack in the expectation that it will be consumed + * (output to the network) before the stack is unwound. If that + * expectation turns out not to be valid, the setaside function is + * called to move the data somewhere safer. + * + * copy makes a duplicate of the bucket structure as long as it's + * possible to have multiple references to a single copy of the + * data itself. Not all bucket types can be copied. + * + * destroy maintains the reference counts on the resources used by a + * bucket and frees them if necessary. + * + * Note: all of the above functions have wrapper macros (apr_bucket_read(), + * apr_bucket_destroy(), etc), and those macros should be used rather + * than using the function pointers directly. + * + * To write a bucket brigade, they are first made into an iovec, so that we + * don't write too little data at one time. Currently we ignore compacting the + * buckets into as few buckets as possible, but if we really want good + * performance, then we need to compact the buckets before we convert to an + * iovec, or possibly while we are converting to an iovec. + */ + +/* + * Forward declaration of the main types. + */ + +/** @see apr_bucket_brigade */ +typedef struct apr_bucket_brigade apr_bucket_brigade; +/** @see apr_bucket */ +typedef struct apr_bucket apr_bucket; +/** @see apr_bucket_alloc_t */ +typedef struct apr_bucket_alloc_t apr_bucket_alloc_t; + +/** @see apr_bucket_type_t */ +typedef struct apr_bucket_type_t apr_bucket_type_t; + +/** + * Basic bucket type + */ +struct apr_bucket_type_t { + /** + * The name of the bucket type + */ + const char *name; + /** + * The number of functions this bucket understands. Can not be less than + * five. + */ + int num_func; + /** + * Whether the bucket contains metadata (ie, information that + * describes the regular contents of the brigade). The metadata + * is not returned by apr_bucket_read() and is not indicated by + * the ->length of the apr_bucket itself. In other words, an + * empty bucket is safe to arbitrarily remove if and only if it + * contains no metadata. In this sense, "data" is just raw bytes + * that are the "content" of the brigade and "metadata" describes + * that data but is not a proper part of it. + */ + enum { + /** This bucket type represents actual data to send to the client. */ + APR_BUCKET_DATA = 0, + /** This bucket type represents metadata. */ + APR_BUCKET_METADATA = 1 + } is_metadata; + /** + * Free the private data and any resources used by the bucket (if they + * aren't shared with another bucket). This function is required to be + * implemented for all bucket types, though it might be a no-op on some + * of them (namely ones that never allocate any private data structures). + * @param data The private data pointer from the bucket to be destroyed + */ + void (*destroy)(void *data); + + /** + * Read the data from the bucket. This is required to be implemented + * for all bucket types. + * @param b The bucket to read from + * @param str A place to store the data read. Allocation should only be + * done if absolutely necessary. + * @param len The amount of data read. + * @param block Should this read function block if there is more data that + * cannot be read immediately. + */ + apr_status_t (*read)(apr_bucket *b, const char **str, apr_size_t *len, + apr_read_type_e block); + + /** + * Make it possible to set aside the data for at least as long as the + * given pool. Buckets containing data that could potentially die before + * this pool (e.g. the data resides on the stack, in a child pool of + * the given pool, or in a disjoint pool) must somehow copy, shift, or + * transform the data to have the proper lifetime. + * @param e The bucket to convert + * @remark Some bucket types contain data that will always outlive the + * bucket itself. For example no data (EOS and FLUSH), or the data + * resides in global, constant memory (IMMORTAL), or the data is on + * the heap (HEAP). For these buckets, apr_bucket_setaside_noop can + * be used. + */ + apr_status_t (*setaside)(apr_bucket *e, apr_pool_t *pool); + + /** + * Split one bucket in two at the specified position by duplicating + * the bucket structure (not the data) and modifying any necessary + * start/end/offset information. If it's not possible to do this + * for the bucket type (perhaps the length of the data is indeterminate, + * as with pipe and socket buckets), then APR_ENOTIMPL is returned. + * @param e The bucket to split + * @param point The offset of the first byte in the new bucket + */ + apr_status_t (*split)(apr_bucket *e, apr_size_t point); + + /** + * Copy the bucket structure (not the data), assuming that this is + * possible for the bucket type. If it's not, APR_ENOTIMPL is returned. + * @param e The bucket to copy + * @param c Returns a pointer to the new bucket + */ + apr_status_t (*copy)(apr_bucket *e, apr_bucket **c); + +}; + +/** + * apr_bucket structures are allocated on the malloc() heap and + * their lifetime is controlled by the parent apr_bucket_brigade + * structure. Buckets can move from one brigade to another e.g. by + * calling APR_BRIGADE_CONCAT(). In general the data in a bucket has + * the same lifetime as the bucket and is freed when the bucket is + * destroyed; if the data is shared by more than one bucket (e.g. + * after a split) the data is freed when the last bucket goes away. + */ +struct apr_bucket { + /** Links to the rest of the brigade */ + APR_RING_ENTRY(apr_bucket) link; + /** The type of bucket. */ + const apr_bucket_type_t *type; + /** The length of the data in the bucket. This could have been implemented + * with a function, but this is an optimization, because the most + * common thing to do will be to get the length. If the length is unknown, + * the value of this field will be (apr_size_t)(-1). + */ + apr_size_t length; + /** The start of the data in the bucket relative to the private base + * pointer. The vast majority of bucket types allow a fixed block of + * data to be referenced by multiple buckets, each bucket pointing to + * a different segment of the data. That segment starts at base+start + * and ends at base+start+length. + * If the length == (apr_size_t)(-1), then start == -1. + */ + apr_off_t start; + /** type-dependent data hangs off this pointer */ + void *data; + /** + * Pointer to function used to free the bucket. This function should + * always be defined and it should be consistent with the memory + * function used to allocate the bucket. For example, if malloc() is + * used to allocate the bucket, this pointer should point to free(). + * @param e Pointer to the bucket being freed + */ + void (*free)(void *e); + /** The freelist from which this bucket was allocated */ + apr_bucket_alloc_t *list; +}; + +/** A list of buckets */ +struct apr_bucket_brigade { + /** The pool to associate the brigade with. The data is not allocated out + * of the pool, but a cleanup is registered with this pool. If the + * brigade is destroyed by some mechanism other than pool destruction, + * the destroying function is responsible for killing the cleanup. + */ + apr_pool_t *p; + /** The buckets in the brigade are on this list. */ + /* + * The apr_bucket_list structure doesn't actually need a name tag + * because it has no existence independent of struct apr_bucket_brigade; + * the ring macros are designed so that you can leave the name tag + * argument empty in this situation but apparently the Windows compiler + * doesn't like that. + */ + APR_RING_HEAD(apr_bucket_list, apr_bucket) list; + /** The freelist from which this bucket was allocated */ + apr_bucket_alloc_t *bucket_alloc; +}; + + +/** + * Function called when a brigade should be flushed + */ +typedef apr_status_t (*apr_brigade_flush)(apr_bucket_brigade *bb, void *ctx); + +/* + * define APR_BUCKET_DEBUG if you want your brigades to be checked for + * validity at every possible instant. this will slow your code down + * substantially but is a very useful debugging tool. + */ +#ifdef APR_BUCKET_DEBUG + +#define APR_BRIGADE_CHECK_CONSISTENCY(b) \ + APR_RING_CHECK_CONSISTENCY(&(b)->list, apr_bucket, link) + +#define APR_BUCKET_CHECK_CONSISTENCY(e) \ + APR_RING_CHECK_ELEM_CONSISTENCY((e), apr_bucket, link) + +#else +/** + * checks the ring pointers in a bucket brigade for consistency. an + * abort() will be triggered if any inconsistencies are found. + * note: this is a no-op unless APR_BUCKET_DEBUG is defined. + * @param b The brigade + */ +#define APR_BRIGADE_CHECK_CONSISTENCY(b) +/** + * checks the brigade a bucket is in for ring consistency. an + * abort() will be triggered if any inconsistencies are found. + * note: this is a no-op unless APR_BUCKET_DEBUG is defined. + * @param e The bucket + */ +#define APR_BUCKET_CHECK_CONSISTENCY(e) +#endif + + +/** + * Wrappers around the RING macros to reduce the verbosity of the code + * that handles bucket brigades. + */ +/** + * The magic pointer value that indicates the head of the brigade + * @remark This is used to find the beginning and end of the brigade, eg: + *
+ *      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 { \ + apr_bucket *ap__b = (e); \ + APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((b)); \ + } 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 { \ + APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((a)); \ + } 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 { \ + APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link); \ + APR_BRIGADE_CHECK_CONSISTENCY((a)); \ + } 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 { \ + apr_bucket *ap__a = (a), *ap__b = (b); \ + APR_RING_INSERT_BEFORE(ap__a, ap__b, link); \ + APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ + } 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 { \ + apr_bucket *ap__a = (a), *ap__b = (b); \ + APR_RING_INSERT_AFTER(ap__a, ap__b, link); \ + APR_BUCKET_CHECK_CONSISTENCY(ap__a); \ + } 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 */ +typedef struct apr_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. + */ +struct apr_bucket_refcount { + /** The number of references to this bucket */ + int refcount; +}; + +/* ***** Reference-counted bucket types ***** */ + +/** @see apr_bucket_heap */ +typedef struct apr_bucket_heap apr_bucket_heap; +/** + * A bucket referring to data allocated off the heap. + */ +struct apr_bucket_heap { + /** Number of buckets using this memory */ + apr_bucket_refcount refcount; + /** The start of the data actually allocated. This should never be + * modified, it is only used to free the bucket. + */ + char *base; + /** how much memory was allocated */ + apr_size_t alloc_len; + /** function to use to delete the data */ + void (*free_func)(void *data); +}; + +/** @see apr_bucket_pool */ +typedef struct apr_bucket_pool apr_bucket_pool; +/** + * A bucket referring to data allocated from a pool + */ +struct apr_bucket_pool { + /** 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.) + */ + apr_bucket_heap 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. + */ + const char *base; + /** 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. + */ + apr_pool_t *pool; + /** The freelist this structure was allocated from, which is + * needed in the cleanup phase in order to allocate space on the heap + */ + apr_bucket_alloc_t *list; +}; + +#if APR_HAS_MMAP +/** @see apr_bucket_mmap */ +typedef struct apr_bucket_mmap apr_bucket_mmap; +/** + * A bucket referring to an mmap()ed file + */ +struct apr_bucket_mmap { + /** Number of buckets using this memory */ + apr_bucket_refcount refcount; + /** The mmap this sub_bucket refers to */ + apr_mmap_t *mmap; +}; +#endif + +/** @see apr_bucket_file */ +typedef struct apr_bucket_file apr_bucket_file; +/** + * A bucket referring to an file + */ +struct apr_bucket_file { + /** Number of buckets using this memory */ + apr_bucket_refcount refcount; + /** The file this bucket refers to */ + apr_file_t *fd; + /** The pool into which any needed structures should + * be created while reading from this file bucket */ + apr_pool_t *readpool; +#if APR_HAS_MMAP + /** Whether this bucket should be memory-mapped if + * a caller tries to read from it */ + int can_mmap; +#endif /* APR_HAS_MMAP */ +}; + +/** @see apr_bucket_structs */ +typedef union apr_bucket_structs apr_bucket_structs; +/** + * A union of all bucket structures so we know what + * the max size is. + */ +union apr_bucket_structs { + apr_bucket b; /**< Bucket */ + apr_bucket_heap heap; /**< Heap */ + apr_bucket_pool pool; /**< Pool */ +#if APR_HAS_MMAP + apr_bucket_mmap mmap; /**< MMap */ +#endif + apr_bucket_file file; /**< File */ +}; + +/** + * 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 { \ + (e)->type->destroy((e)->data); \ + (e)->free(e); \ + } 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 { \ + APR_BUCKET_REMOVE(e); \ + apr_bucket_destroy(e); \ + } 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); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !APR_BUCKETS_H */ diff --git a/rubbos/app/apache2/include/apr_compat.h b/rubbos/app/apache2/include/apr_compat.h new file mode 100644 index 00000000..45500c0a --- /dev/null +++ b/rubbos/app/apache2/include/apr_compat.h @@ -0,0 +1,231 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_COMPAT_H +#define APR_COMPAT_H + + /** + * @file apr_compat.h + * @brief APR Legacy Apache 1.3 Compatibility + * @deprecated These defines are only present for historical purposes + */ + +/** + * @defgroup apr_compat APR Legacy Apache 1.3 Compatibility + * @ingroup APR + * @{ + */ + +/* redefine 1.3.x symbols to those that now live in libapr */ + +/** @see APR_INLINE */ +#define ap_inline APR_INLINE + +/** @deprecated @see apr_md5_ctx_t */ +#define ap_md5_ctx_t apr_md5_ctx_t +/** @deprecated @see apr_md5_encode */ +#define ap_MD5Encode apr_md5_encode +/** @deprecated @see apr_md5_final */ +#define ap_MD5Final apr_md5_final +/** @deprecated @see apr_md5_init */ +#define ap_MD5Init apr_md5_init +/** @deprecated @see apr_md5_update */ +#define ap_MD5Update apr_md5_update +/** @deprecated @see apr_array_append */ +#define ap_append_arrays apr_array_append +/** @deprecated @see apr_array_cat */ +#define ap_array_cat apr_array_cat +/** @deprecated @see apr_array_header_t */ +#define ap_array_header_t apr_array_header_t +/** @deprecated @see apr_array_pstrcat */ +#define ap_array_pstrcat apr_array_pstrcat +/** @deprecated @see apr_pool_free_blocks_num_bytes */ +#define ap_bytes_in_free_blocks apr_pool_free_blocks_num_bytes +/** @deprecated @see apr_pool_num_bytes */ +#define ap_bytes_in_pool apr_pool_num_bytes +/** @deprecated @see apr_check_file_time */ +#define ap_check_file_time apr_check_file_time +/** @deprecated @see apr_filetype_e */ +#define ap_filetype_e apr_filetype_e +/** @deprecated @see apr_pool_cleanup_for_exec */ +#define ap_cleanup_for_exec apr_pool_cleanup_for_exec +/** @deprecated @see apr_pool_clear */ +#define ap_clear_pool apr_pool_clear +/** @deprecated @see apr_table_clear */ +#define ap_clear_table apr_table_clear +/** @deprecated @see apr_array_copy */ +#define ap_copy_array apr_array_copy +/** @deprecated @see apr_array_copy_hdr */ +#define ap_copy_array_hdr apr_array_copy_hdr +/** @deprecated @see apr_table_copy */ +#define ap_copy_table apr_table_copy +/** @deprecated @see apr_cpystrn */ +#define ap_cpystrn apr_cpystrn +/** @deprecated @see apr_day_snames */ +#define ap_day_snames apr_day_snames +/** @deprecated @see apr_pool_destroy */ +#define ap_destroy_pool apr_pool_destroy +/** @deprecated @see apr_time_exp_t */ +#define ap_exploded_time_t apr_time_exp_t +/** @deprecated @see apr_fnmatch */ +#define ap_fnmatch apr_fnmatch +/** @deprecated @see apr_getopt */ +#define ap_getopt apr_getopt +/** @deprecated @see apr_inet_addr */ +#define ap_inet_addr apr_inet_addr +/** @deprecated @see apr_pool_alloc_init */ +#define ap_init_alloc apr_pool_alloc_init +/** @deprecated @see apr_is_empty_table */ +#define ap_is_empty_table apr_is_empty_table +/** @deprecated @see apr_fnmatch_test */ +#define ap_is_fnmatch apr_fnmatch_test +/** @deprecated @see apr_pool_cleanup_kill */ +#define ap_kill_cleanup apr_pool_cleanup_kill +/** @deprecated @see apr_array_make */ +#define ap_make_array apr_array_make +/** @deprecated @see apr_pool_sub_make */ +#define ap_make_sub_pool apr_pool_sub_make +/** @deprecated @see apr_table_make */ +#define ap_make_table apr_table_make +/** @deprecated @see apr_month_snames */ +#define ap_month_snames apr_month_snames +/** @deprecated @see apr_pool_note_subprocess*/ +#define ap_note_subprocess apr_pool_note_subprocess +/** @deprecated @see apr_pool_cleanup_null */ +#define ap_null_cleanup apr_pool_cleanup_null +/** @deprecated @see apr_filepath_merge */ +#define ap_os_canonical_filename apr_filepath_merge +/** @deprecated @see apr_filepath_merge */ +#define ap_os_case_canonical_filename apr_filepath_merge +/** @deprecated @see apr_dso_load */ +#define ap_os_dso_load apr_dso_load +/** @deprecated @see apr_dso_unload */ +#define ap_os_dso_unload apr_dso_unload +/** @deprecated @see apr_dso_sym */ +#define ap_os_dso_sym apr_dso_sym +/** @deprecated @see apr_dso_error */ +#define ap_os_dso_error apr_dso_error +/** @deprecated @see apr_filepath_merge + * @warning apr_filepath_merge rejects invalid filenames */ +#define ap_os_is_filename_valid apr_filepath_merge +/** @deprecated @see apr_proc_kill */ +#define ap_os_kill apr_proc_kill +/** @deprecated @see apr_filepath_merge */ +#define ap_os_systemcase_canonical_filename apr_filepath_merge +/** @deprecated @see apr_table_overlap */ +#define ap_overlap_tables apr_table_overlap +/** @deprecated @see apr_table_overlay */ +#define ap_overlay_tables apr_table_overlay +/** @deprecated @see apr_palloc */ +#define ap_palloc apr_palloc +/** @deprecated @see apr_pcalloc */ +#define ap_pcalloc apr_pcalloc +/** @deprecated @see apr_pool_join */ +#define ap_pool_join apr_pool_join +/** @deprecated @see apr_psprintf */ +#define ap_psprintf apr_psprintf +/** @deprecated @see apr_pstrcat */ +#define ap_pstrcat apr_pstrcat +/** @deprecated @see apr_pstrdup */ +#define ap_pstrdup apr_pstrdup +/** @deprecated @see apr_pstrndup */ +#define ap_pstrndup apr_pstrndup +/** @deprecated @see apr_array_push */ +#define ap_push_array apr_array_push +/** @deprecated @see apr_pvsprintf */ +#define ap_pvsprintf apr_pvsprintf +/** @deprecated @see apr_pool_cleanup_register */ +#define ap_register_cleanup apr_pool_cleanup_register +/** @deprecated @see apr_proc_other_child_register */ +#define ap_register_other_child apr_proc_other_child_register +/** @deprecated @see apr_pool_cleanup_run */ +#define ap_run_cleanup apr_pool_cleanup_run +/** @deprecated @see apr_signal */ +#define ap_signal apr_signal +/** @deprecated @see apr_snprintf */ +#define ap_snprintf apr_snprintf +/** @deprecated @see apr_table_add */ +#define ap_table_add apr_table_add +/** @deprecated @see apr_table_addn */ +#define ap_table_addn apr_table_addn +/** @deprecated @see apr_table_do */ +#define ap_table_do apr_table_do +/** @deprecated @see apr_table_elts */ +#define ap_table_elts apr_table_elts +/** @deprecated @see apr_table_get */ +#define ap_table_get apr_table_get +/** @deprecated @see apr_table_merge */ +#define ap_table_merge apr_table_merge +/** @deprecated @see apr_table_mergen */ +#define ap_table_mergen apr_table_mergen +/** @deprecated @see apr_table_set */ +#define ap_table_set apr_table_set +/** @deprecated @see apr_table_setn */ +#define ap_table_setn apr_table_setn +/** @deprecated @see apr_table_unset */ +#define ap_table_unset apr_table_unset +/** @deprecated @see apr_proc_other_child_unregister */ +#define ap_unregister_other_child apr_proc_other_child_unregister +/** @deprecated @see apr_password_validate */ +#define ap_validate_password apr_password_validate +/** @deprecated @see apr_vformatter */ +#define ap_vformatter apr_vformatter +/** @deprecated @see apr_vsnprintf */ +#define ap_vsnprintf apr_vsnprintf +/** @deprecated @see apr_wait_t */ +#define ap_wait_t apr_wait_t + +/** @deprecated @see apr_isalnum */ +#define ap_isalnum apr_isalnum +/** @deprecated @see apr_isalpha*/ +#define ap_isalpha apr_isalpha +/** @deprecated @see apr_iscntrl */ +#define ap_iscntrl apr_iscntrl +/** @deprecated @see apr_isdigit */ +#define ap_isdigit apr_isdigit +/** @deprecated @see apr_isgraph */ +#define ap_isgraph apr_isgraph +/** @deprecated @see apr_islower */ +#define ap_islower apr_islower +/** @deprecated @see apr_isascii */ +#define ap_isascii apr_isascii +/** @deprecated @see apr_isprint */ +#define ap_isprint apr_isprint +/** @deprecated @see apr_ispunct */ +#define ap_ispunct apr_ispunct +/** @deprecated @see apr_isspace */ +#define ap_isspace apr_isspace +/** @deprecated @see apr_isupper */ +#define ap_isupper apr_isupper +/** @deprecated @see apr_isxdigit */ +#define ap_isxdigit apr_isxdigit +/** @deprecated @see apr_tolower */ +#define ap_tolower apr_tolower +/** @deprecated @see apr_toupper */ +#define ap_toupper apr_toupper + +/** @deprecated @see APR_USEC_PER_SEC */ +#define AP_USEC_PER_SEC APR_USEC_PER_SEC +/** @deprecated @see APR_RFC822_DATE_LEN */ +#define AP_RFC822_DATE_LEN APR_RFC822_DATE_LEN +/** @deprecated @see APR_OVERLAP_TABLES_MERGE */ +#define AP_OVERLAP_TABLES_MERGE APR_OVERLAP_TABLES_MERGE +/** @deprecated @see APR_OVERLAP_TABLES_SET */ +#define AP_OVERLAP_TABLES_SET APR_OVERLAP_TABLES_SET + +/** @} */ + +#endif /* APR_COMPAT_H */ diff --git a/rubbos/app/apache2/include/apr_date.h b/rubbos/app/apache2/include/apr_date.h new file mode 100644 index 00000000..87500a33 --- /dev/null +++ b/rubbos/app/apache2/include/apr_date.h @@ -0,0 +1,106 @@ +/* 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. + */ + +#ifndef APR_DATE_H +#define APR_DATE_H + +/** + * @file apr_date.h + * @brief APR-UTIL date routines + */ + +/** + * @defgroup APR_Util_Date Date routines + * @ingroup APR_Util + * @{ + */ + +/* + * apr_date.h: prototypes for date parsing utility routines + */ + +#include "apu.h" +#include "apr_time.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** A bad date. */ +#define APR_DATE_BAD ((apr_time_t)0) + +/** + * Compare a string to a mask + * @param data The string to compare + * @param mask Mask characters (arbitrary maximum is 256 characters): + *
+ *   '\@' - uppercase letter
+ *   '\$' - lowercase letter
+ *   '\&' - hex digit
+ *   '#' - digit
+ *   '~' - digit or space
+ *   '*' - swallow remaining characters
+ * 
+ * @remark The mask tests for an exact match for any other character + * @return 1 if the string matches, 0 otherwise + */ +APU_DECLARE(int) apr_date_checkmask(const char *data, const char *mask); + +/** + * Parses an HTTP date in one of three standard forms: + *
+ *     Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
+ *     Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
+ *     Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
+ * 
+ * @param date The date in one of the three formats above + * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or + * 0 if this would be out of range or if the date is invalid. + */ +APU_DECLARE(apr_time_t) apr_date_parse_http(const char *date); + +/** + * Parses a string resembling an RFC 822 date. This is meant to be + * leinent in its parsing of dates. Hence, this will parse a wider + * range of dates than apr_date_parse_http. + * + * The prominent mailer (or poster, if mailer is unknown) that has + * been seen in the wild is included for the unknown formats. + *
+ *     Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
+ *     Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
+ *     Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
+ *     Sun, 6 Nov 1994 08:49:37 GMT   ; RFC 822, updated by RFC 1123
+ *     Sun, 06 Nov 94 08:49:37 GMT    ; RFC 822
+ *     Sun, 6 Nov 94 08:49:37 GMT     ; RFC 822
+ *     Sun, 06 Nov 94 08:49 GMT       ; Unknown [drtr\@ast.cam.ac.uk] 
+ *     Sun, 6 Nov 94 08:49 GMT        ; Unknown [drtr\@ast.cam.ac.uk]
+ *     Sun, 06 Nov 94 8:49:37 GMT     ; Unknown [Elm 70.85]
+ *     Sun, 6 Nov 94 8:49:37 GMT      ; Unknown [Elm 70.85] 
+ * 
+ * + * @param date The date in one of the formats above + * @return the apr_time_t number of microseconds since 1 Jan 1970 GMT, or + * 0 if this would be out of range or if the date is invalid. + */ +APU_DECLARE(apr_time_t) apr_date_parse_rfc(const char *date); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !APR_DATE_H */ diff --git a/rubbos/app/apache2/include/apr_dbm.h b/rubbos/app/apache2/include/apr_dbm.h new file mode 100644 index 00000000..d34f9ad3 --- /dev/null +++ b/rubbos/app/apache2/include/apr_dbm.h @@ -0,0 +1,224 @@ +/* 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. + */ + +#ifndef APR_DBM_H +#define APR_DBM_H + +#include "apu.h" +#include "apr.h" +#include "apr_errno.h" +#include "apr_pools.h" +#include "apr_file_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file apr_dbm.h + * @brief APR-UTIL DBM library + */ +/** + * @defgroup APR_Util_DBM DBM routines + * @ingroup APR_Util + * @{ + */ +/** + * Structure for referencing a dbm + */ +typedef struct apr_dbm_t apr_dbm_t; + +/** + * Structure for referencing the datum record within a dbm + */ +typedef struct +{ + /** pointer to the 'data' to retrieve/store in the DBM */ + char *dptr; + /** size of the 'data' to retrieve/store in the DBM */ + apr_size_t dsize; +} apr_datum_t; + +/* modes to open the DB */ +#define APR_DBM_READONLY 1 /**< open for read-only access */ +#define APR_DBM_READWRITE 2 /**< open for read-write access */ +#define APR_DBM_RWCREATE 3 /**< open for r/w, create if needed */ +#define APR_DBM_RWTRUNC 4 /**< open for r/w, truncating an existing + DB if present */ +/** + * Open a dbm file by file name and type of DBM + * @param dbm The newly opened database + * @param type The type of the DBM (not all may be available at run time) + *
+ *  GDBM for GDBM files
+ *  SDBM for SDBM files
+ *  DB   for berkeley DB files
+ *  NDBM for NDBM files
+ *  default for the default DBM type
+ *  
+ * @param name The dbm file name to open + * @param mode The flag value + *
+ *           APR_DBM_READONLY   open for read-only access
+ *           APR_DBM_READWRITE  open for read-write access
+ *           APR_DBM_RWCREATE   open for r/w, create if needed
+ *           APR_DBM_RWTRUNC    open for r/w, truncate if already there
+ * 
+ * @param perm Permissions to apply to if created + * @param cntxt The pool to use when creating the dbm + * @remark The dbm name may not be a true file name, as many dbm packages + * append suffixes for seperate data and index files. + */ + +APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **dbm, const char* type, + const char *name, + apr_int32_t mode, apr_fileperms_t perm, + apr_pool_t *cntxt); + + +/** + * Open a dbm file by file name + * @param dbm The newly opened database + * @param name The dbm file name to open + * @param mode The flag value + *
+ *           APR_DBM_READONLY   open for read-only access
+ *           APR_DBM_READWRITE  open for read-write access
+ *           APR_DBM_RWCREATE   open for r/w, create if needed
+ *           APR_DBM_RWTRUNC    open for r/w, truncate if already there
+ * 
+ * @param perm Permissions to apply to if created + * @param cntxt The pool to use when creating the dbm + * @remark The dbm name may not be a true file name, as many dbm packages + * append suffixes for seperate data and index files. + */ +APU_DECLARE(apr_status_t) apr_dbm_open(apr_dbm_t **dbm, const char *name, + apr_int32_t mode, apr_fileperms_t perm, + apr_pool_t *cntxt); + +/** + * Close a dbm file previously opened by apr_dbm_open + * @param dbm The database to close + */ +APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm); + +/** + * Fetch a dbm record value by key + * @param dbm The database + * @param key The key datum to find this record + * @param pvalue The value datum retrieved for this record + */ +APU_DECLARE(apr_status_t) apr_dbm_fetch(apr_dbm_t *dbm, apr_datum_t key, + apr_datum_t *pvalue); +/** + * Store a dbm record value by key + * @param dbm The database + * @param key The key datum to store this record by + * @param value The value datum to store in this record + */ +APU_DECLARE(apr_status_t) apr_dbm_store(apr_dbm_t *dbm, apr_datum_t key, + apr_datum_t value); + +/** + * Delete a dbm record value by key + * @param dbm The database + * @param key The key datum of the record to delete + * @remark It is not an error to delete a non-existent record. + */ +APU_DECLARE(apr_status_t) apr_dbm_delete(apr_dbm_t *dbm, apr_datum_t key); + +/** + * Search for a key within the dbm + * @param dbm The database + * @param key The datum describing a key to test + */ +APU_DECLARE(int) apr_dbm_exists(apr_dbm_t *dbm, apr_datum_t key); + +/** + * Retrieve the first record key from a dbm + * @param dbm The database + * @param pkey The key datum of the first record + */ +APU_DECLARE(apr_status_t) apr_dbm_firstkey(apr_dbm_t *dbm, apr_datum_t *pkey); + +/** + * Retrieve the next record key from a dbm + * @param dbm The database + * @param pkey The key datum of the next record + */ +APU_DECLARE(apr_status_t) apr_dbm_nextkey(apr_dbm_t *dbm, apr_datum_t *pkey); + +/** + * Proactively toss any memory associated with the apr_datum_t. + * @param dbm The database + * @param data The datum to free. + */ +APU_DECLARE(void) apr_dbm_freedatum(apr_dbm_t *dbm, apr_datum_t data); + +/** + * Report more information when an apr_dbm function fails. + * @param dbm The database + * @param errcode A DBM-specific value for the error (for logging). If this + * isn't needed, it may be NULL. + * @param errbuf Location to store the error text + * @param errbufsize The size of the provided buffer + * @return The errbuf parameter, for convenience. + */ +APU_DECLARE(char *) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, + char *errbuf, apr_size_t errbufsize); +/** + * If the specified file/path were passed to apr_dbm_open(), return the + * actual file/path names which would be (created and) used. At most, two + * files may be used; used2 may be NULL if only one file is used. + * @param pool The pool for allocating used1 and used2. + * @param type The type of DBM you require info on + * @param pathname The path name to generate used-names from. + * @param used1 The first pathname used by the apr_dbm implementation. + * @param used2 The second pathname used by apr_dbm. If only one file is + * used by the specific implementation, this will be set to NULL. + * @return An error if the specified type is invalid. + * @remark The dbm file(s) don't need to exist. This function only manipulates + * the pathnames. + */ +APU_DECLARE(apr_status_t) apr_dbm_get_usednames_ex(apr_pool_t *pool, + const char *type, + const char *pathname, + const char **used1, + const char **used2); + +/** + * If the specified file/path were passed to apr_dbm_open(), return the + * actual file/path names which would be (created and) used. At most, two + * files may be used; used2 may be NULL if only one file is used. + * @param pool The pool for allocating used1 and used2. + * @param pathname The path name to generate used-names from. + * @param used1 The first pathname used by the apr_dbm implementation. + * @param used2 The second pathname used by apr_dbm. If only one file is + * used by the specific implementation, this will be set to NULL. + * @remark The dbm file(s) don't need to exist. This function only manipulates + * the pathnames. + */ +APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *pool, + const char *pathname, + const char **used1, + const char **used2); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !APR_DBM_H */ diff --git a/rubbos/app/apache2/include/apr_dso.h b/rubbos/app/apache2/include/apr_dso.h new file mode 100644 index 00000000..ac701cfd --- /dev/null +++ b/rubbos/app/apache2/include/apr_dso.h @@ -0,0 +1,94 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_DSO_DOT_H +#define APR_DSO_DOT_H + +/** + * @file apr_dso.h + * @brief APR Dynamic Object Handling Routines + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup apr_dso Dynamic Object Handling + * @ingroup APR + * @{ + */ + +#if APR_HAS_DSO || defined(DOXYGEN) + +/** + * Structure for referencing dynamic objects + */ +typedef struct apr_dso_handle_t apr_dso_handle_t; + +/** + * Structure for referencing symbols from dynamic objects + */ +typedef void * apr_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. + */ +APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, + const char *path, apr_pool_t *ctx); + +/** + * Close a DSO library. + * @param handle handle to close. + */ +APR_DECLARE(apr_status_t) apr_dso_unload(apr_dso_handle_t *handle); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym, + apr_dso_handle_t *handle, + const char *symname); + +/** + * 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 + */ +APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buf, apr_size_t bufsize); + +#endif /* APR_HAS_DSO */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/rubbos/app/apache2/include/apr_env.h b/rubbos/app/apache2/include/apr_env.h new file mode 100644 index 00000000..05419c37 --- /dev/null +++ b/rubbos/app/apache2/include/apr_env.h @@ -0,0 +1,67 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_ENV_H +#define APR_ENV_H +/** + * @file apr_env.h + * @brief APR Environment functions + */ +#include "apr_errno.h" +#include "apr_pools.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_env Functions for manupulating the environment + * @ingroup APR + * @{ + */ + +/** + * Get the value of an environment variable + * @param value the returned value, allocated from @a pool + * @param envvar the name of the environment variable + * @param pool where to allocate @a value and any temporary storage from + */ +APR_DECLARE(apr_status_t) apr_env_get(char **value, const char *envvar, + apr_pool_t *pool); + +/** + * Set the value of an environment variable + * @param envvar the name of the environment variable + * @param value the value to set + * @param pool where to allocate temporary storage from + */ +APR_DECLARE(apr_status_t) apr_env_set(const char *envvar, const char *value, + apr_pool_t *pool); + +/** + * Delete a variable from the environment + * @param envvar the name of the environment variable + * @param pool where to allocate temporary storage from + */ +APR_DECLARE(apr_status_t) apr_env_delete(const char *envvar, apr_pool_t *pool); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_ENV_H */ diff --git a/rubbos/app/apache2/include/apr_errno.h b/rubbos/app/apache2/include/apr_errno.h new file mode 100644 index 00000000..9d1d8447 --- /dev/null +++ b/rubbos/app/apache2/include/apr_errno.h @@ -0,0 +1,1219 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_ERRNO_H +#define APR_ERRNO_H + +/** + * @file apr_errno.h + * @brief APR Error Codes + */ + +#include "apr.h" + +#if APR_HAVE_ERRNO_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_errno Error Codes + * @ingroup APR + * @{ + */ + +/** + * Type for specifying an error or status code. + */ +typedef int apr_status_t; + +/** + * Return a human readable string describing the specified error. + * @param statcode The error code the get a string for. + * @param buf A buffer to hold the error string. + * @param bufsize Size of the buffer to hold the string. + */ +APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf, + apr_size_t bufsize); + +#if defined(DOXYGEN) +/** + * @def APR_FROM_OS_ERROR(os_err_type syserr) + * Fold a platform specific error into an apr_status_t code. + * @return apr_status_t + * @param e The platform os error code. + * @warning macro implementation; the syserr argument may be evaluated + * multiple times. + */ +#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR) + +/** + * @def APR_TO_OS_ERROR(apr_status_t statcode) + * @return os_err_type + * Fold an apr_status_t code back to the native platform defined error. + * @param e The apr_status_t folded platform os error code. + * @warning macro implementation; the statcode argument may be evaluated + * multiple times. If the statcode was not created by apr_get_os_error + * or APR_FROM_OS_ERROR, the results are undefined. + */ +#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR) + +/** @def apr_get_os_error() + * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms + * @remark This retrieves errno, or calls a GetLastError() style function, and + * folds it with APR_FROM_OS_ERROR. Some platforms (such as OS2) have no + * such mechanism, so this call may be unsupported. Do NOT use this + * call for socket errors from socket, send, recv etc! + */ + +/** @def apr_set_os_error(e) + * Reset the last platform error, unfolded from an apr_status_t, on some platforms + * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR() + * @warning This is a macro implementation; the statcode argument may be evaluated + * multiple times. If the statcode was not created by apr_get_os_error + * or APR_FROM_OS_ERROR, the results are undefined. This macro sets + * errno, or calls a SetLastError() style function, unfolding statcode + * with APR_TO_OS_ERROR. Some platforms (such as OS2) have no such + * mechanism, so this call may be unsupported. + */ + +/** @def apr_get_netos_error() + * Return the last socket error, folded into apr_status_t, on all platforms + * @remark This retrieves errno or calls a GetLastSocketError() style function, + * and folds it with APR_FROM_OS_ERROR. + */ + +/** @def apr_set_netos_error(e) + * Reset the last socket error, unfolded from an apr_status_t + * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR() + * @warning This is a macro implementation; the statcode argument may be evaluated + * multiple times. If the statcode was not created by apr_get_os_error + * or APR_FROM_OS_ERROR, the results are undefined. This macro sets + * errno, or calls a WSASetLastError() style function, unfolding + * socketcode with APR_TO_OS_ERROR. + */ + +#endif /* defined(DOXYGEN) */ + +/** + * APR_OS_START_ERROR is where the APR specific error values start. + */ +#define APR_OS_START_ERROR 20000 +/** + * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit + * into one of the error/status ranges below -- except for + * APR_OS_START_USERERR, which see. + */ +#define APR_OS_ERRSPACE_SIZE 50000 +/** + * APR_OS_START_STATUS is where the APR specific status codes start. + */ +#define APR_OS_START_STATUS (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE) +/** + * APR_OS_START_USERERR are reserved for applications that use APR that + * layer their own error codes along with APR's. Note that the + * error immediately following this one is set ten times farther + * away than usual, so that users of apr have a lot of room in + * which to declare custom error codes. + */ +#define APR_OS_START_USERERR (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE) +/** + * APR_OS_START_USEERR is obsolete, defined for compatibility only. + * Use APR_OS_START_USERERR instead. + */ +#define APR_OS_START_USEERR APR_OS_START_USERERR +/** + * APR_OS_START_CANONERR is where APR versions of errno values are defined + * on systems which don't have the corresponding errno. + */ +#define APR_OS_START_CANONERR (APR_OS_START_USERERR \ + + (APR_OS_ERRSPACE_SIZE * 10)) +/** + * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into + * apr_status_t values. + */ +#define APR_OS_START_EAIERR (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE) +/** + * APR_OS_START_SYSERR folds platform-specific system error values into + * apr_status_t values. + */ +#define APR_OS_START_SYSERR (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE) + +/** no error. @see APR_STATUS_IS_SUCCESS */ +#define APR_SUCCESS 0 + +/** + * @defgroup APR_Error APR Error Values + *
+ * 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 */ +#define APR_ENOSTAT (APR_OS_START_ERROR + 1) +/** @see APR_STATUS_IS_ENOPOOL */ +#define APR_ENOPOOL (APR_OS_START_ERROR + 2) +/* empty slot: +3 */ +/** @see APR_STATUS_IS_EBADDATE */ +#define APR_EBADDATE (APR_OS_START_ERROR + 4) +/** @see APR_STATUS_IS_EINVALSOCK */ +#define APR_EINVALSOCK (APR_OS_START_ERROR + 5) +/** @see APR_STATUS_IS_ENOPROC */ +#define APR_ENOPROC (APR_OS_START_ERROR + 6) +/** @see APR_STATUS_IS_ENOTIME */ +#define APR_ENOTIME (APR_OS_START_ERROR + 7) +/** @see APR_STATUS_IS_ENODIR */ +#define APR_ENODIR (APR_OS_START_ERROR + 8) +/** @see APR_STATUS_IS_ENOLOCK */ +#define APR_ENOLOCK (APR_OS_START_ERROR + 9) +/** @see APR_STATUS_IS_ENOPOLL */ +#define APR_ENOPOLL (APR_OS_START_ERROR + 10) +/** @see APR_STATUS_IS_ENOSOCKET */ +#define APR_ENOSOCKET (APR_OS_START_ERROR + 11) +/** @see APR_STATUS_IS_ENOTHREAD */ +#define APR_ENOTHREAD (APR_OS_START_ERROR + 12) +/** @see APR_STATUS_IS_ENOTHDKEY */ +#define APR_ENOTHDKEY (APR_OS_START_ERROR + 13) +/** @see APR_STATUS_IS_EGENERAL */ +#define APR_EGENERAL (APR_OS_START_ERROR + 14) +/** @see APR_STATUS_IS_ENOSHMAVAIL */ +#define APR_ENOSHMAVAIL (APR_OS_START_ERROR + 15) +/** @see APR_STATUS_IS_EBADIP */ +#define APR_EBADIP (APR_OS_START_ERROR + 16) +/** @see APR_STATUS_IS_EBADMASK */ +#define APR_EBADMASK (APR_OS_START_ERROR + 17) +/* empty slot: +18 */ +/** @see APR_STATUS_IS_EDSOPEN */ +#define APR_EDSOOPEN (APR_OS_START_ERROR + 19) +/** @see APR_STATUS_IS_EABSOLUTE */ +#define APR_EABSOLUTE (APR_OS_START_ERROR + 20) +/** @see APR_STATUS_IS_ERELATIVE */ +#define APR_ERELATIVE (APR_OS_START_ERROR + 21) +/** @see APR_STATUS_IS_EINCOMPLETE */ +#define APR_EINCOMPLETE (APR_OS_START_ERROR + 22) +/** @see APR_STATUS_IS_EABOVEROOT */ +#define APR_EABOVEROOT (APR_OS_START_ERROR + 23) +/** @see APR_STATUS_IS_EBADPATH */ +#define APR_EBADPATH (APR_OS_START_ERROR + 24) +/** @see APR_STATUS_IS_EPATHWILD */ +#define APR_EPATHWILD (APR_OS_START_ERROR + 25) +/** @see APR_STATUS_IS_ESYMNOTFOUND */ +#define APR_ESYMNOTFOUND (APR_OS_START_ERROR + 26) +/** @see APR_STATUS_IS_EPROC_UNKNOWN */ +#define 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 */ +#define APR_INCHILD (APR_OS_START_STATUS + 1) +/** @see APR_STATUS_IS_INPARENT */ +#define APR_INPARENT (APR_OS_START_STATUS + 2) +/** @see APR_STATUS_IS_DETACH */ +#define APR_DETACH (APR_OS_START_STATUS + 3) +/** @see APR_STATUS_IS_NOTDETACH */ +#define APR_NOTDETACH (APR_OS_START_STATUS + 4) +/** @see APR_STATUS_IS_CHILD_DONE */ +#define APR_CHILD_DONE (APR_OS_START_STATUS + 5) +/** @see APR_STATUS_IS_CHILD_NOTDONE */ +#define APR_CHILD_NOTDONE (APR_OS_START_STATUS + 6) +/** @see APR_STATUS_IS_TIMEUP */ +#define APR_TIMEUP (APR_OS_START_STATUS + 7) +/** @see APR_STATUS_IS_INCOMPLETE */ +#define APR_INCOMPLETE (APR_OS_START_STATUS + 8) +/* empty slot: +9 */ +/* empty slot: +10 */ +/* empty slot: +11 */ +/** @see APR_STATUS_IS_BADCH */ +#define APR_BADCH (APR_OS_START_STATUS + 12) +/** @see APR_STATUS_IS_BADARG */ +#define APR_BADARG (APR_OS_START_STATUS + 13) +/** @see APR_STATUS_IS_EOF */ +#define APR_EOF (APR_OS_START_STATUS + 14) +/** @see APR_STATUS_IS_NOTFOUND */ +#define APR_NOTFOUND (APR_OS_START_STATUS + 15) +/* empty slot: +16 */ +/* empty slot: +17 */ +/* empty slot: +18 */ +/** @see APR_STATUS_IS_ANONYMOUS */ +#define APR_ANONYMOUS (APR_OS_START_STATUS + 19) +/** @see APR_STATUS_IS_FILEBASED */ +#define APR_FILEBASED (APR_OS_START_STATUS + 20) +/** @see APR_STATUS_IS_KEYBASED */ +#define APR_KEYBASED (APR_OS_START_STATUS + 21) +/** @see APR_STATUS_IS_EINIT */ +#define APR_EINIT (APR_OS_START_STATUS + 22) +/** @see APR_STATUS_IS_ENOTIMPL */ +#define APR_ENOTIMPL (APR_OS_START_STATUS + 23) +/** @see APR_STATUS_IS_EMISMATCH */ +#define APR_EMISMATCH (APR_OS_START_STATUS + 24) +/** @see APR_STATUS_IS_EBUSY */ +#define 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. + */ +#define SOCBASEERR 10000 +#define SOCEPERM (SOCBASEERR+1) /* Not owner */ +#define SOCESRCH (SOCBASEERR+3) /* No such process */ +#define SOCEINTR (SOCBASEERR+4) /* Interrupted system call */ +#define SOCENXIO (SOCBASEERR+6) /* No such device or address */ +#define SOCEBADF (SOCBASEERR+9) /* Bad file number */ +#define SOCEACCES (SOCBASEERR+13) /* Permission denied */ +#define SOCEFAULT (SOCBASEERR+14) /* Bad address */ +#define SOCEINVAL (SOCBASEERR+22) /* Invalid argument */ +#define SOCEMFILE (SOCBASEERR+24) /* Too many open files */ +#define SOCEPIPE (SOCBASEERR+32) /* Broken pipe */ +#define SOCEOS2ERR (SOCBASEERR+100) /* OS/2 Error */ +#define SOCEWOULDBLOCK (SOCBASEERR+35) /* Operation would block */ +#define SOCEINPROGRESS (SOCBASEERR+36) /* Operation now in progress */ +#define SOCEALREADY (SOCBASEERR+37) /* Operation already in progress */ +#define SOCENOTSOCK (SOCBASEERR+38) /* Socket operation on non-socket */ +#define SOCEDESTADDRREQ (SOCBASEERR+39) /* Destination address required */ +#define SOCEMSGSIZE (SOCBASEERR+40) /* Message too long */ +#define SOCEPROTOTYPE (SOCBASEERR+41) /* Protocol wrong type for socket */ +#define SOCENOPROTOOPT (SOCBASEERR+42) /* Protocol not available */ +#define SOCEPROTONOSUPPORT (SOCBASEERR+43) /* Protocol not supported */ +#define SOCESOCKTNOSUPPORT (SOCBASEERR+44) /* Socket type not supported */ +#define SOCEOPNOTSUPP (SOCBASEERR+45) /* Operation not supported on socket */ +#define SOCEPFNOSUPPORT (SOCBASEERR+46) /* Protocol family not supported */ +#define SOCEAFNOSUPPORT (SOCBASEERR+47) /* Address family not supported by protocol family */ +#define SOCEADDRINUSE (SOCBASEERR+48) /* Address already in use */ +#define SOCEADDRNOTAVAIL (SOCBASEERR+49) /* Can't assign requested address */ +#define SOCENETDOWN (SOCBASEERR+50) /* Network is down */ +#define SOCENETUNREACH (SOCBASEERR+51) /* Network is unreachable */ +#define SOCENETRESET (SOCBASEERR+52) /* Network dropped connection on reset */ +#define SOCECONNABORTED (SOCBASEERR+53) /* Software caused connection abort */ +#define SOCECONNRESET (SOCBASEERR+54) /* Connection reset by peer */ +#define SOCENOBUFS (SOCBASEERR+55) /* No buffer space available */ +#define SOCEISCONN (SOCBASEERR+56) /* Socket is already connected */ +#define SOCENOTCONN (SOCBASEERR+57) /* Socket is not connected */ +#define SOCESHUTDOWN (SOCBASEERR+58) /* Can't send after socket shutdown */ +#define SOCETOOMANYREFS (SOCBASEERR+59) /* Too many references: can't splice */ +#define SOCETIMEDOUT (SOCBASEERR+60) /* Connection timed out */ +#define SOCECONNREFUSED (SOCBASEERR+61) /* Connection refused */ +#define SOCELOOP (SOCBASEERR+62) /* Too many levels of symbolic links */ +#define SOCENAMETOOLONG (SOCBASEERR+63) /* File name too long */ +#define SOCEHOSTDOWN (SOCBASEERR+64) /* Host is down */ +#define SOCEHOSTUNREACH (SOCBASEERR+65) /* No route to host */ +#define 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) */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_ERRNO_H */ diff --git a/rubbos/app/apache2/include/apr_file_info.h b/rubbos/app/apache2/include/apr_file_info.h new file mode 100644 index 00000000..7e613d85 --- /dev/null +++ b/rubbos/app/apache2/include/apr_file_info.h @@ -0,0 +1,421 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_FILE_INFO_H +#define APR_FILE_INFO_H + +/** + * @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 +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_file_info File Information + * @ingroup APR + * @{ + */ + +/* Many applications use the type member to determine the + * existance of a file or initialization of the file info, + * so the APR_NOFILE value must be distinct from APR_UNKFILE. + */ + +/** apr_filetype_e values for the filetype member of the + * apr_file_info_t structure + * @warning: Not all of the filetypes below can be determined. + * For example, a given platform might not correctly report + * a socket descriptor as APR_SOCK if that type isn't + * well-identified on that platform. In such cases where + * a filetype exists but cannot be described by the recognized + * flags below, the filetype will be APR_UNKFILE. If the + * filetype member is not determined, the type will be APR_NOFILE. + */ + +typedef enum { + APR_NOFILE = 0, /**< no file type determined */ + APR_REG, /**< a regular file */ + APR_DIR, /**< a directory */ + APR_CHR, /**< a character device */ + APR_BLK, /**< a block device */ + APR_PIPE, /**< a FIFO / pipe */ + APR_LNK, /**< a symbolic link */ + APR_SOCK, /**< a [unix domain] socket */ + APR_UNKFILE = 127 /**< a file of some other unknown type */ +} apr_filetype_e; + +/** + * @defgroup apr_file_permissions File Permissions flags + * @{ + */ + +#define APR_USETID 0x8000 /**< Set user id */ +#define APR_UREAD 0x0400 /**< Read by user */ +#define APR_UWRITE 0x0200 /**< Write by user */ +#define APR_UEXECUTE 0x0100 /**< Execute by user */ + +#define APR_GSETID 0x4000 /**< Set group id */ +#define APR_GREAD 0x0040 /**< Read by group */ +#define APR_GWRITE 0x0020 /**< Write by group */ +#define APR_GEXECUTE 0x0010 /**< Execute by group */ + +#define APR_WSTICKY 0x2000 /**< Sticky bit */ +#define APR_WREAD 0x0004 /**< Read by others */ +#define APR_WWRITE 0x0002 /**< Write by others */ +#define APR_WEXECUTE 0x0001 /**< Execute by others */ + +#define APR_OS_DEFAULT 0x0FFF /**< use OS's default permissions */ + +/* additional permission flags for apr_file_copy and apr_file_append */ +#define APR_FILE_SOURCE_PERMS 0x1000 /**< Copy source file's permissions */ + +/** @} */ + + +/** + * Structure for referencing directories. + */ +typedef struct apr_dir_t apr_dir_t; +/** + * Structure for determining file permissions. + */ +typedef apr_int32_t apr_fileperms_t; +#if (defined WIN32) || (defined NETWARE) +/** + * Structure for determining the device the file is on. + */ +typedef apr_uint32_t apr_dev_t; +#else +/** + * Structure for determining the device the file is on. + */ +typedef dev_t apr_dev_t; +#endif + +/** + * @defgroup apr_file_stat Stat Functions + * @{ + */ +/** file info structure */ +typedef struct apr_finfo_t apr_finfo_t; + +#define APR_FINFO_LINK 0x00000001 /**< Stat the link not the file itself if it is a link */ +#define APR_FINFO_MTIME 0x00000010 /**< Modification Time */ +#define APR_FINFO_CTIME 0x00000020 /**< Creation Time */ +#define APR_FINFO_ATIME 0x00000040 /**< Access Time */ +#define APR_FINFO_SIZE 0x00000100 /**< Size of the file */ +#define APR_FINFO_CSIZE 0x00000200 /**< Storage size consumed by the file */ +#define APR_FINFO_DEV 0x00001000 /**< Device */ +#define APR_FINFO_INODE 0x00002000 /**< Inode */ +#define APR_FINFO_NLINK 0x00004000 /**< Number of links */ +#define APR_FINFO_TYPE 0x00008000 /**< Type */ +#define APR_FINFO_USER 0x00010000 /**< User */ +#define APR_FINFO_GROUP 0x00020000 /**< Group */ +#define APR_FINFO_UPROT 0x00100000 /**< User protection bits */ +#define APR_FINFO_GPROT 0x00200000 /**< Group protection bits */ +#define APR_FINFO_WPROT 0x00400000 /**< World protection bits */ +#define APR_FINFO_ICASE 0x01000000 /**< if dev is case insensitive */ +#define APR_FINFO_NAME 0x02000000 /**< ->name in proper case */ + +#define APR_FINFO_MIN 0x00008170 /**< type, mtime, ctime, atime, size */ +#define APR_FINFO_IDENT 0x00003000 /**< dev and inode */ +#define APR_FINFO_OWNER 0x00030000 /**< user and group */ +#define APR_FINFO_PROT 0x00700000 /**< all protections */ +#define APR_FINFO_NORM 0x0073b170 /**< an atomic unix apr_stat() */ +#define APR_FINFO_DIRENT 0x02000000 /**< an atomic unix apr_dir_read() */ + +/** + * The file information structure. This is analogous to the POSIX + * stat structure. + */ +struct apr_finfo_t { + /** Allocates memory and closes lingering handles in the specified pool */ + apr_pool_t *pool; + /** The bitmask describing valid fields of this apr_finfo_t structure + * including all available 'wanted' fields and potentially more */ + apr_int32_t valid; + /** The access permissions of the file. Mimics Unix access rights. */ + apr_fileperms_t protection; + /** The type of file. One of APR_REG, APR_DIR, APR_CHR, APR_BLK, APR_PIPE, + * APR_LNK or APR_SOCK. If the type is undetermined, the value is APR_NOFILE. + * If the type cannot be determined, the value is APR_UNKFILE. + */ + apr_filetype_e filetype; + /** The user id that owns the file */ + apr_uid_t user; + /** The group id that owns the file */ + apr_gid_t group; + /** The inode of the file. */ + apr_ino_t inode; + /** The id of the device the file is on. */ + apr_dev_t device; + /** The number of hard links to the file. */ + apr_int32_t nlink; + /** The size of the file */ + apr_off_t size; + /** The storage size consumed by the file */ + apr_off_t csize; + /** The time the file was last accessed */ + apr_time_t atime; + /** The time the file was last modified */ + apr_time_t mtime; + /** The time the file was last changed */ + apr_time_t ctime; + /** The pathname of the file (possibly unrooted) */ + const char *fname; + /** The file's name (no path) in filesystem case */ + const char *name; + /** The file's handle, if accessed (can be submitted to apr_duphandle) */ + struct apr_file_t *filehand; +}; + +/** + * get the specified file's stats. The file is specified by filename, + * instead of using a pre-opened file. + * @param finfo Where to store the information about the file, which is + * never touched if the call fails. + * @param fname The name of the file to stat. + * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ + values + * @param cont the pool to use to allocate the new file. + * + * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may + * not be filled in, and you need to check the @c finfo->valid bitmask + * to verify that what you're looking for is there. + */ +APR_DECLARE(apr_status_t) apr_stat(apr_finfo_t *finfo, const char *fname, + apr_int32_t wanted, apr_pool_t *cont); + +/** + * get the specified file's stats. The file is specified by filename, + * instead of using a pre-opened file. If the file is a symlink, this function + * will get the stats for the symlink not the file the symlink refers to. + * @param finfo Where to store the information about the file, which is + * never touched if the call fails. + * @param fname The name of the file to stat. + * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values + * @param cont the pool to use to allocate the new file. + * @deprecated This function is deprecated, it's equivalent to calling apr_stat with + * the wanted flag value APR_FINFO_LINK + */ +APR_DECLARE(apr_status_t) apr_lstat(apr_finfo_t *finfo, const char *fname, + apr_int32_t wanted, apr_pool_t *cont); +/** @} */ +/** + * @defgroup apr_dir Directory Manipulation Functions + * @{ + */ + +/** + * Open the specified directory. + * @param new_dir The opened directory descriptor. + * @param dirname The full path to the directory (use / on all systems) + * @param cont The pool to use. + */ +APR_DECLARE(apr_status_t) apr_dir_open(apr_dir_t **new_dir, + const char *dirname, + apr_pool_t *cont); + +/** + * close the specified directory. + * @param thedir the directory descriptor to close. + */ +APR_DECLARE(apr_status_t) apr_dir_close(apr_dir_t *thedir); + +/** + * Read the next entry from the specified directory. + * @param finfo the file info structure and filled in by apr_dir_read + * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ + values + * @param thedir the directory descriptor returned from apr_dir_open + * @remark No ordering is guaranteed for the entries read. + * + * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may + * not be filled in, and you need to check the @c finfo->valid bitmask + * to verify that what you're looking for is there. + */ +APR_DECLARE(apr_status_t) apr_dir_read(apr_finfo_t *finfo, apr_int32_t wanted, + apr_dir_t *thedir); + +/** + * Rewind the directory to the first entry. + * @param thedir the directory descriptor to rewind. + */ +APR_DECLARE(apr_status_t) apr_dir_rewind(apr_dir_t *thedir); +/** @} */ + +/** + * @defgroup apr_filepath Filepath Manipulation Functions + * @{ + */ + +/** Cause apr_filepath_merge to fail if addpath is above rootpath */ +#define APR_FILEPATH_NOTABOVEROOT 0x01 + +/** internal: Only meaningful with APR_FILEPATH_NOTABOVEROOT */ +#define APR_FILEPATH_SECUREROOTTEST 0x02 + +/** Cause apr_filepath_merge to fail if addpath is above rootpath, + * even given a rootpath /foo/bar and an addpath ../bar/bash + */ +#define APR_FILEPATH_SECUREROOT 0x03 + +/** Fail apr_filepath_merge if the merged path is relative */ +#define APR_FILEPATH_NOTRELATIVE 0x04 + +/** Fail apr_filepath_merge if the merged path is absolute */ +#define APR_FILEPATH_NOTABSOLUTE 0x08 + +/** Return the file system's native path format (e.g. path delimiters + * of ':' on MacOS9, '\' on Win32, etc.) */ +#define APR_FILEPATH_NATIVE 0x10 + +/** Resolve the true case of existing directories and file elements + * of addpath, (resolving any aliases on Win32) and append a proper + * trailing slash if a directory + */ +#define APR_FILEPATH_TRUENAME 0x20 + +/** + * Extract the rootpath from the given filepath + * @param rootpath the root file path returned with APR_SUCCESS or APR_EINCOMPLETE + * @param filepath the pathname to parse for its root component + * @param flags the desired rules to apply, from + *
+ *      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. + */ +APR_DECLARE(apr_status_t) apr_filepath_root(const char **rootpath, + const char **filepath, + apr_int32_t flags, + apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath, + const char *rootpath, + const char *addpath, + apr_int32_t flags, + apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_filepath_list_split(apr_array_header_t **pathelts, + const char *liststr, + apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_filepath_list_merge(char **liststr, + apr_array_header_t *pathelts, + apr_pool_t *p); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_filepath_get(char **path, apr_int32_t flags, + apr_pool_t *p); + +/** + * Set the default file path (for relative file names) + * @param path the default path returned + * @param p the pool to allocate any working storage + */ +APR_DECLARE(apr_status_t) apr_filepath_set(const char *path, apr_pool_t *p); + +/** The FilePath character encoding is unknown */ +#define APR_FILEPATH_ENCODING_UNKNOWN 0 + +/** The FilePath character encoding is locale-dependent */ +#define APR_FILEPATH_ENCODING_LOCALE 1 + +/** The FilePath character encoding is UTF-8 */ +#define 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. + */ +APR_DECLARE(apr_status_t) apr_filepath_encoding(int *style, apr_pool_t *p); +/** @} */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_FILE_INFO_H */ diff --git a/rubbos/app/apache2/include/apr_file_io.h b/rubbos/app/apache2/include/apr_file_io.h new file mode 100644 index 00000000..bfa7a1bf --- /dev/null +++ b/rubbos/app/apache2/include/apr_file_io.h @@ -0,0 +1,766 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_FILE_IO_H +#define APR_FILE_IO_H + +/** + * @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.h" +#include "apr_inherit.h" + +#define APR_WANT_STDIO /**< for SEEK_* */ +#define APR_WANT_IOVEC /**< for apr_file_writev */ +#include "apr_want.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @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. */ + +#define APR_READ 0x00001 /**< Open the file for reading */ +#define APR_WRITE 0x00002 /**< Open the file for writing */ +#define APR_CREATE 0x00004 /**< Create the file if not there */ +#define APR_APPEND 0x00008 /**< Append to the end of the file */ +#define APR_TRUNCATE 0x00010 /**< Open the file and truncate to 0 length */ +#define APR_BINARY 0x00020 /**< Open the file in binary mode */ +#define APR_EXCL 0x00040 /**< Open should fail if APR_CREATE and file + exists. */ +#define APR_BUFFERED 0x00080 /**< Open the file for buffered I/O */ +#define APR_DELONCLOSE 0x00100 /**< Delete the file after close */ +#define APR_XTHREAD 0x00200 /**< Platform dependent tag to open the file + for use across multiple threads */ +#define APR_SHARELOCK 0x00400 /**< Platform dependent support for higher + level locked read/write access to support + writes across process/machines */ +#define APR_FILE_NOCLEANUP 0x00800 /**< Do not register a cleanup when the file + is opened */ +#define APR_SENDFILE_ENABLED 0x01000 /**< Advisory flag that this file should + support apr_sendfile operation */ +#define APR_LARGEFILE 0x04000 /**< 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 + * @{ + */ + +/* flags for apr_file_seek */ +/** Set the file position */ +#define APR_SET SEEK_SET +/** Current */ +#define APR_CUR SEEK_CUR +/** Go to end of file */ +#define APR_END SEEK_END +/** @} */ + +/** + * @defgroup apr_file_attrs_set_flags File Attribute Flags + * @{ + */ + +/* flags for apr_file_attrs_set */ +#define APR_FILE_ATTR_READONLY 0x01 /**< File is read-only */ +#define APR_FILE_ATTR_EXECUTABLE 0x02 /**< File is executable */ +#define APR_FILE_ATTR_HIDDEN 0x04 /**< File is hidden */ +/** @} */ + +/** File attributes */ +typedef apr_uint32_t apr_fileattrs_t; + +/** should be same as whence type in lseek, POSIX defines this as int */ +typedef int apr_seek_where_t; + +/** + * Structure for referencing files. + */ +typedef struct apr_file_t apr_file_t; + +/* File lock types/flags */ +/** + * @defgroup apr_file_lock_types File Lock Types + * @{ + */ + +#define 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. */ +#define 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". */ + +#define APR_FLOCK_TYPEMASK 0x000F /**< mask to extract lock type */ +#define APR_FLOCK_NONBLOCK 0x0010 /**< 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) + */ +APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **newf, const char *fname, + apr_int32_t flag, apr_fileperms_t perm, + apr_pool_t *pool); + +/** + * Close the specified file. + * @param file The file descriptor to close. + */ +APR_DECLARE(apr_status_t) apr_file_close(apr_file_t *file); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_remove(const char *path, apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_rename(const char *from_path, + const char *to_path, + apr_pool_t *pool); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_copy(const char *from_path, + const char *to_path, + apr_fileperms_t perms, + apr_pool_t *pool); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_append(const char *from_path, + const char *to_path, + apr_fileperms_t perms, + apr_pool_t *pool); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_eof(apr_file_t *fptr); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_open_stderr(apr_file_t **thefile, + apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_open_stdout(apr_file_t **thefile, + apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_open_stdin(apr_file_t **thefile, + apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, + apr_size_t *nbytes); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, + apr_size_t *nbytes); + +/** + * 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(). + */ +APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, + const struct iovec *vec, + apr_size_t nvec, apr_size_t *nbytes); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_read_full(apr_file_t *thefile, void *buf, + apr_size_t nbytes, + apr_size_t *bytes_read); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_write_full(apr_file_t *thefile, const void *buf, + apr_size_t nbytes, + apr_size_t *bytes_written); + +/** + * put a character into the specified file. + * @param ch The character to write. + * @param thefile The file descriptor to write to + */ +APR_DECLARE(apr_status_t) apr_file_putc(char ch, apr_file_t *thefile); + +/** + * get a character from the specified file. + * @param ch The character to read into + * @param thefile The file descriptor to read from + */ +APR_DECLARE(apr_status_t) apr_file_getc(char *ch, apr_file_t *thefile); + +/** + * put a character back onto a specified stream. + * @param ch The character to write. + * @param thefile The file descriptor to write to + */ +APR_DECLARE(apr_status_t) apr_file_ungetc(char ch, apr_file_t *thefile); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_gets(char *str, int len, apr_file_t *thefile); + +/** + * Put the string into a specified file. + * @param str The string to write. + * @param thefile The file descriptor to write to + */ +APR_DECLARE(apr_status_t) apr_file_puts(const char *str, apr_file_t *thefile); + +/** + * Flush the file's buffer. + * @param thefile The file descriptor to flush + */ +APR_DECLARE(apr_status_t) apr_file_flush(apr_file_t *thefile); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_file_dup(apr_file_t **new_file, + apr_file_t *old_file, + apr_pool_t *p); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file, + apr_file_t *old_file, + apr_pool_t *p); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_file_setaside(apr_file_t **new_file, + apr_file_t *old_file, + apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_seek(apr_file_t *thefile, + apr_seek_where_t where, + apr_off_t *offset); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, + apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, + apr_fileperms_t perm, + apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_pipe_timeout_get(apr_file_t *thepipe, + apr_interval_time_t *timeout); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_pipe_timeout_set(apr_file_t *thepipe, + apr_interval_time_t timeout); + +/** 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. + */ +APR_DECLARE(apr_status_t) apr_file_lock(apr_file_t *thefile, int type); + +/** + * Remove any outstanding locks on the file. + * @param thefile The file to unlock. + */ +APR_DECLARE(apr_status_t) apr_file_unlock(apr_file_t *thefile); + +/**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. + */ +APR_DECLARE(apr_status_t) apr_file_name_get(const char **new_path, + apr_file_t *thefile); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_data_get(void **data, const char *key, + apr_file_t *file); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_data_set(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 + */ +APR_DECLARE_NONSTD(int) apr_file_printf(apr_file_t *fptr, + const char *format, ...) + __attribute__((format(printf,2,3))); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_perms_set(const char *fname, + apr_fileperms_t perms); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_attrs_set(const char *fname, + apr_fileattrs_t attributes, + apr_fileattrs_t attr_mask, + apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_mtime_set(const char *fname, + apr_time_t mtime, + apr_pool_t *pool); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_dir_make(const char *path, apr_fileperms_t perm, + apr_pool_t *cont); + +/** 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. + */ +APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path, + apr_fileperms_t perm, + apr_pool_t *pool); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_dir_remove(const char *path, apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_file_info_get(apr_finfo_t *finfo, + apr_int32_t wanted, + apr_file_t *thefile); + + +/** + * Truncate the file's length to the specified offset + * @param fp The file to truncate + * @param offset The offset to truncate to. + * @remark The read/write file offset is repositioned to offset. + */ +APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *fp, apr_off_t offset); + +/** + * Retrieve the flags that were passed into apr_file_open() + * when the file was opened. + * @return apr_int32_t the flags + */ +APR_DECLARE(apr_int32_t) apr_file_flags_get(apr_file_t *f); + +/** + * 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. + * + */ +APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *templ, + apr_int32_t flags, apr_pool_t *p); + + +/** + * 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. + * + */ +APR_DECLARE(apr_status_t) apr_temp_dir_get(const char **temp_dir, + apr_pool_t *p); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_FILE_IO_H */ diff --git a/rubbos/app/apache2/include/apr_fnmatch.h b/rubbos/app/apache2/include/apr_fnmatch.h new file mode 100644 index 00000000..8be40fc8 --- /dev/null +++ b/rubbos/app/apache2/include/apr_fnmatch.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. 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 the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + */ + +/* This file has been modified by the Apache Software Foundation. */ +#ifndef _APR_FNMATCH_H_ +#define _APR_FNMATCH_H_ + +/** + * @file apr_fnmatch.h + * @brief APR FNMatch Functions + */ + +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup apr_fnmatch Filename Matching Functions + * @ingroup APR + * @{ + */ + +#define APR_FNM_NOMATCH 1 /**< Match failed. */ + +#define APR_FNM_NOESCAPE 0x01 /**< Disable backslash escaping. */ +#define APR_FNM_PATHNAME 0x02 /**< Slash must be matched by slash. */ +#define APR_FNM_PERIOD 0x04 /**< Period must be matched by period. */ +#define APR_FNM_CASE_BLIND 0x08 /**< Compare characters case-insensitively. + * @remark This flag is an Apache addition + */ + +#define FNM_NOMATCH APR_FNM_NOMATCH /**< @deprecated @see APR_FNM_NOMATCH */ +#define FNM_NOESCAPE APR_FNM_NOESCAPE /**< @deprecated @see APR_FNM_NOESCAPE */ +#define FNM_PATHNAME APR_FNM_PATHNAME /**< @deprecated @see APR_FNM_PATHNAME */ +#define FNM_PERIOD APR_FNM_PERIOD /**< @deprecated @see APR_FNM_PERIOD */ +#define FNM_CASE_BLIND APR_FNM_CASE_BLIND /**< @deprecated @see APR_FNM_CASE_BLIND */ + +/** + * Try to match the string to the given pattern, return APR_SUCCESS if + * match, else return APR_FNM_NOMATCH. + * @param pattern The pattern to match to + * @param strings The string we are trying to match + * @param flags flags to use in the match. Bitwise OR of: + *
+ *              APR_FNM_NOESCAPE       Disable backslash escaping
+ *              APR_FNM_PATHNAME       Slash must be matched by slash
+ *              APR_FNM_PERIOD         Period must be matched by period
+ *              APR_FNM_CASE_BLIND     Compare characters case-insensitively.
+ * 
+ */ + +APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, + const char *strings, int flags); + +/** + * Determine if the given pattern is a regular expression. + * @param pattern The pattern to search for glob characters. + * @return non-zero if pattern has any glob characters in it + */ +APR_DECLARE(int) apr_fnmatch_test(const char *pattern); + +/** @deprecated @see apr_fnmatch_test */ +APR_DECLARE(int) apr_is_fnmatch(const char *pattern); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_APR_FNMATCH_H_ */ diff --git a/rubbos/app/apache2/include/apr_general.h b/rubbos/app/apache2/include/apr_general.h new file mode 100644 index 00000000..10e150b9 --- /dev/null +++ b/rubbos/app/apache2/include/apr_general.h @@ -0,0 +1,249 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_GENERAL_H +#define APR_GENERAL_H + +/** + * @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 +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_general Miscellaneous library routines + * @ingroup APR + * 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. + * @{ + */ + +/** FALSE */ +#ifndef FALSE +#define FALSE 0 +#endif +/** TRUE */ +#ifndef TRUE +#define TRUE (!FALSE) +#endif + +/** a space */ +#define APR_ASCII_BLANK '\040' +/** a carrige return */ +#define APR_ASCII_CR '\015' +/** a line feed */ +#define APR_ASCII_LF '\012' +/** a tab */ +#define APR_ASCII_TAB '\011' + +/** signal numbers typedef */ +typedef int apr_signum_t; + +/** + * Finding offsets of elements within structures. + * Taken from the X code... they've sweated portability of this stuff + * so we don't have to. Sigh... + * @param p_type pointer type name + * @param field data field within the structure pointed to + * @return offset + */ + +#if defined(CRAY) || (defined(__arm) && !defined(LINUX)) +#ifdef __STDC__ +#define APR_OFFSET(p_type,field) _Offsetof(p_type,field) +#else +#ifdef CRAY2 +#define APR_OFFSET(p_type,field) \ + (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) + +#else /* !CRAY2 */ + +#define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field)) + +#endif /* !CRAY2 */ +#endif /* __STDC__ */ +#else /* ! (CRAY || __arm) */ + +#define APR_OFFSET(p_type,field) \ + ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) + +#endif /* !CRAY */ + +/** + * Finding offsets of elements within structures. + * @param s_type structure type name + * @param field data field within the structure + * @return offset + */ +#if defined(offsetof) && !defined(__cplusplus) +#define APR_OFFSETOF(s_type,field) offsetof(s_type,field) +#else +#define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field) +#endif + +/** @deprecated @see APR_OFFSET */ +#define APR_XtOffset APR_OFFSET + +/** @deprecated @see APR_OFFSETOF */ +#define APR_XtOffsetOf APR_OFFSETOF + +#ifndef DOXYGEN + +/* A couple of prototypes for functions in case some platform doesn't + * have it + */ +#if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP) +#define strcasecmp(s1, s2) stricmp(s1, s2) +#elif (!APR_HAVE_STRCASECMP) +int strcasecmp(const char *a, const char *b); +#endif + +#if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP) +#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n) +#elif (!APR_HAVE_STRNCASECMP) +int strncasecmp(const char *a, const char *b, size_t n); +#endif + +#endif + +/** + * Alignment macros + */ + +/* APR_ALIGN() is only to be used to align on a power of 2 boundary */ +#define APR_ALIGN(size, boundary) \ + (((size) + ((boundary) - 1)) & ~((boundary) - 1)) + +/** Default alignment */ +#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8) + + +/** + * String and memory functions + */ + +/** Properly quote a value as a string in the C preprocessor */ +#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n) +/** Helper macro for APR_STRINGIFY */ +#define APR_STRINGIFY_HELPER(n) #n + +#if (!APR_HAVE_MEMMOVE) +#define memmove(a,b,c) bcopy(b,a,c) +#endif + +#if (!APR_HAVE_MEMCHR) +void *memchr(const void *s, int c, size_t n); +#endif + +/** @} */ + +/** + * @defgroup apr_library Library initialization and termination + * @{ + */ + +/** + * Setup any APR internal data structures. This MUST be the first function + * called for any APR library. + * @remark See apr_app_initialize if this is an application, rather than + * a library consumer of apr. + */ +APR_DECLARE(apr_status_t) apr_initialize(void); + +/** + * Set up an application with normalized argc, argv (and optionally env) in + * order to deal with platform-specific oddities, such as Win32 services, + * code pages and signals. This must be the first function called for any + * APR program. + * @param argc Pointer to the argc that may be corrected + * @param argv Pointer to the argv that may be corrected + * @param env Pointer to the env that may be corrected, may be NULL + * @remark See apr_initialize if this is a library consumer of apr. + * Otherwise, this call is identical to apr_initialize, and must be closed + * with a call to apr_terminate at the end of program execution. + */ +APR_DECLARE(apr_status_t) apr_app_initialize(int *argc, + char const * const * *argv, + char const * const * *env); + +/** + * Tear down any APR internal data structures which aren't torn down + * automatically. + * @remark An APR program must call this function at termination once it + * has stopped using APR services. The APR developers suggest using + * atexit to ensure this is called. When using APR from a language + * other than C that has problems with the calling convention, use + * apr_terminate2() instead. + */ +APR_DECLARE_NONSTD(void) apr_terminate(void); + +/** + * Tear down any APR internal data structures which aren't torn down + * automatically, same as apr_terminate + * @remark An APR program must call either the apr_terminate or apr_terminate2 + * function once it it has finished using APR services. The APR + * developers suggest using atexit(apr_terminate) to ensure this is done. + * apr_terminate2 exists to allow non-c language apps to tear down apr, + * while apr_terminate is recommended from c language applications. + */ +APR_DECLARE(void) apr_terminate2(void); + +/** @} */ + +/** + * @defgroup apr_random Random Functions + * @{ + */ + +#if APR_HAS_RANDOM || defined(DOXYGEN) + +/* TODO: I'm not sure this is the best place to put this prototype...*/ +/** + * Generate random bytes. + * @param buf Buffer to fill with random bytes + * @param length Length of buffer in bytes (becomes apr_size_t in APR 1.0) + */ +#ifdef APR_ENABLE_FOR_1_0 +APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, + apr_size_t length); +#else +APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, + int length); +#endif + +#endif +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_GENERAL_H */ diff --git a/rubbos/app/apache2/include/apr_getopt.h b/rubbos/app/apache2/include/apr_getopt.h new file mode 100644 index 00000000..131aa4b3 --- /dev/null +++ b/rubbos/app/apache2/include/apr_getopt.h @@ -0,0 +1,158 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_GETOPT_H +#define APR_GETOPT_H + +/** + * @file apr_getopt.h + * @brief APR Command Arguments (getopt) + */ + +#include "apr_pools.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_getopt Command Argument Parsing + * @ingroup APR + * @{ + */ + +/** + * defintion of a error function + */ +typedef void (apr_getopt_err_fn_t)(void *arg, const char *err, ...); + +/** @see apr_getopt_t */ +typedef struct apr_getopt_t apr_getopt_t; + +/** + * Structure to store command line argument information. + */ +struct apr_getopt_t { + /** context for processing */ + apr_pool_t *cont; + /** function to print error message (NULL == no messages) */ + apr_getopt_err_fn_t *errfn; + /** user defined first arg to pass to error message */ + void *errarg; + /** index into parent argv vector */ + int ind; + /** character checked for validity */ + int opt; + /** reset getopt */ + int reset; + /** count of arguments */ + int argc; + /** array of pointers to arguments */ + const char **argv; + /** argument associated with option */ + char const* place; + /** set to nonzero to support interleaving options with regular args */ + int interleave; + /** start of non-option arguments skipped for interleaving */ + int skip_start; + /** end of non-option arguments skipped for interleaving */ + int skip_end; +}; + +/** @see apr_getopt_option_t */ +typedef struct apr_getopt_option_t apr_getopt_option_t; + +/** + * Structure used to describe options that getopt should search for. + */ +struct apr_getopt_option_t { + /** long option name, or NULL if option has no long name */ + const char *name; + /** option letter, or a value greater than 255 if option has no letter */ + int optch; + /** nonzero if option takes an argument */ + int has_arg; + /** a description of the option */ + const char *description; +}; + +/** + * Initialize the arguments for parsing by apr_getopt(). + * @param os The options structure created for apr_getopt() + * @param cont The pool to operate on + * @param argc The number of arguments to parse + * @param argv The array of arguments to parse + * @remark Arguments 2 and 3 are most commonly argc and argv from main(argc, argv) + * The errfn is initialized to fprintf(stderr... but may be overridden. + */ +APR_DECLARE(apr_status_t) apr_getopt_init(apr_getopt_t **os, apr_pool_t *cont, + int argc, const char * const *argv); + +/** + * Parse the options initialized by apr_getopt_init(). + * @param os The apr_opt_t structure returned by apr_getopt_init() + * @param opts A string of characters that are acceptable options to the + * program. Characters followed by ":" are required to have an + * option associated + * @param option_ch The next option character parsed + * @param option_arg The argument following the option character: + * @return There are four potential status values on exit. They are: + *
+ *             APR_EOF      --  No more options to parse
+ *             APR_BADCH    --  Found a bad option character
+ *             APR_BADARG   --  No argument followed the option flag
+ *             APR_SUCCESS  --  The next option was found.
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_getopt(apr_getopt_t *os, const char *opts, + char *option_ch, const char **option_arg); + +/** + * Parse the options initialized by apr_getopt_init(), accepting long + * options beginning with "--" in addition to single-character + * options beginning with "-". + * @param os The apr_getopt_t structure created by apr_getopt_init() + * @param opts A pointer to a list of apr_getopt_option_t structures, which + * can be initialized with { "name", optch, has_args }. has_args + * is nonzero if the option requires an argument. A structure + * with an optch value of 0 terminates the list. + * @param option_ch Receives the value of "optch" from the apr_getopt_option_t + * structure corresponding to the next option matched. + * @param option_arg Receives the argument following the option, if any. + * @return There are four potential status values on exit. They are: + *
+ *             APR_EOF      --  No more options to parse
+ *             APR_BADCH    --  Found a bad option character
+ *             APR_BADARG   --  No argument followed the option flag
+ *             APR_SUCCESS  --  The next option was found.
+ * 
+ * When APR_SUCCESS is returned, os->ind gives the index of the first + * non-option argument. On error, a message will be printed to stdout unless + * os->err is set to 0. If os->interleave is set to nonzero, options can come + * after arguments, and os->argv will be permuted to leave non-option arguments + * at the end (the original argv is unaffected). + */ +APR_DECLARE(apr_status_t) apr_getopt_long(apr_getopt_t *os, + const apr_getopt_option_t *opts, + int *option_ch, + const char **option_arg); +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_GETOPT_H */ diff --git a/rubbos/app/apache2/include/apr_global_mutex.h b/rubbos/app/apache2/include/apr_global_mutex.h new file mode 100644 index 00000000..9316001c --- /dev/null +++ b/rubbos/app/apache2/include/apr_global_mutex.h @@ -0,0 +1,153 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_GLOBAL_MUTEX_H +#define APR_GLOBAL_MUTEX_H + +/** + * @file apr_global_mutex.h + * @brief APR Global Locking Routines + */ + +#include "apr.h" +#include "apr_proc_mutex.h" /* only for apr_lockmech_e */ +#include "apr_pools.h" +#include "apr_errno.h" +#if APR_PROC_MUTEX_IS_GLOBAL +#include "apr_proc_mutex.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup APR_GlobalMutex Global Locking Routines + * @ingroup APR + * @{ + */ + +#if !APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN) + +/** Opaque global mutex structure. */ +typedef struct apr_global_mutex_t apr_global_mutex_t; + +/* Function definitions */ + +/** + * Create and initialize a mutex that can be used to synchronize both + * processes and threads. Note: There is considerable overhead in using + * this API if only cross-process or cross-thread mutual exclusion is + * required. See apr_proc_mutex.h and apr_thread_mutex.h for more + * specialized lock routines. + * @param mutex the memory address where the newly created mutex will be + * stored. + * @param fname A file name to use if the lock mechanism requires one. This + * argument should always be provided. The lock code itself will + * determine if it should be used. + * @param mech The mechanism to use for the interprocess lock, if any; one of + *
+ *            APR_LOCK_FCNTL
+ *            APR_LOCK_FLOCK
+ *            APR_LOCK_SYSVSEM
+ *            APR_LOCK_POSIXSEM
+ *            APR_LOCK_PROC_PTHREAD
+ *            APR_LOCK_DEFAULT     pick the default mechanism for the platform
+ * 
+ * @param pool the pool from which to allocate the mutex. + * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports + * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. + */ +APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex, + const char *fname, + apr_lockmech_e mech, + apr_pool_t *pool); + +/** + * Re-open a mutex in a child process. + * @param mutex The newly re-opened mutex structure. + * @param fname A file name to use if the mutex mechanism requires one. This + * argument should always be provided. The mutex code itself will + * determine if it should be used. This filename should be the + * same one that was passed to apr_global_mutex_create(). + * @param pool The pool to operate on. + * @remark This function must be called to maintain portability, even + * if the underlying lock mechanism does not require it. + */ +APR_DECLARE(apr_status_t) apr_global_mutex_child_init( + apr_global_mutex_t **mutex, + const char *fname, + apr_pool_t *pool); + +/** + * Acquire the lock for the given mutex. If the mutex is already locked, + * the current thread will be put to sleep until the lock becomes available. + * @param mutex the mutex on which to acquire the lock. + */ +APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex); + +/** + * Attempt to acquire the lock for the given mutex. If the mutex has already + * been acquired, the call returns immediately with APR_EBUSY. Note: it + * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine + * if the return value was APR_EBUSY, for portability reasons. + * @param mutex the mutex on which to attempt the lock acquiring. + */ +APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex); + +/** + * Release the lock for the given mutex. + * @param mutex the mutex from which to release the lock. + */ +APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex); + +/** + * Destroy the mutex and free the memory associated with the lock. + * @param mutex the mutex to destroy. + */ +APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex); + +/** + * Get the pool used by this global_mutex. + * @return apr_pool_t the pool + */ +APR_POOL_DECLARE_ACCESSOR(global_mutex); + +#else /* APR_PROC_MUTEX_IS_GLOBAL */ + +/* Some platforms [e.g. Win32] have cross process locks that are truly + * global locks, since there isn't the concept of cross-process locks. + * Define these platforms in terms of an apr_proc_mutex_t. + */ + +#define apr_global_mutex_t apr_proc_mutex_t +#define apr_global_mutex_create apr_proc_mutex_create +#define apr_global_mutex_child_init apr_proc_mutex_child_init +#define apr_global_mutex_lock apr_proc_mutex_lock +#define apr_global_mutex_trylock apr_proc_mutex_trylock +#define apr_global_mutex_unlock apr_proc_mutex_unlock +#define apr_global_mutex_destroy apr_proc_mutex_destroy +#define apr_global_mutex_pool_get apr_proc_mutex_pool_get + +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ndef APR_GLOBAL_MUTEX_H */ diff --git a/rubbos/app/apache2/include/apr_hash.h b/rubbos/app/apache2/include/apr_hash.h new file mode 100644 index 00000000..87795c4a --- /dev/null +++ b/rubbos/app/apache2/include/apr_hash.h @@ -0,0 +1,201 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_HASH_H +#define APR_HASH_H + +/** + * @file apr_hash.h + * @brief APR Hash Tables + */ + +#include "apr_pools.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup apr_hash Hash Tables + * @ingroup APR + * @{ + */ + +/** + * When passing a key to apr_hash_set or apr_hash_get, this value can be + * passed to indicate a string-valued key, and have apr_hash compute the + * length automatically. + * + * @remark apr_hash will use strlen(key) for the length. The null-terminator + * is not included in the hash value (why throw a constant in?). + * Since the hash table merely references the provided key (rather + * than copying it), apr_hash_this() will return the null-term'd key. + */ +#define APR_HASH_KEY_STRING (-1) + +/** + * Abstract type for hash tables. + */ +typedef struct apr_hash_t apr_hash_t; + +/** + * Abstract type for scanning hash tables. + */ +typedef struct apr_hash_index_t apr_hash_index_t; + +/** + * Create a hash table. + * @param pool The pool to allocate the hash table out of + * @return The hash table just created + */ +APR_DECLARE(apr_hash_t *) apr_hash_make(apr_pool_t *pool); + +/** + * Make a copy of a hash table + * @param pool The pool from which to allocate the new hash table + * @param h The hash table to clone + * @return The hash table just created + * @remark Makes a shallow copy + */ +APR_DECLARE(apr_hash_t *) apr_hash_copy(apr_pool_t *pool, + const apr_hash_t *h); + +/** + * Associate a value with a key in a hash table. + * @param ht The hash table + * @param key Pointer to the key + * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length. + * @param val Value to associate with the key + * @remark If the value is NULL the hash entry is deleted. + */ +APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, const void *key, + apr_ssize_t klen, const void *val); + +/** + * Look up the value associated with a key in a hash table. + * @param ht The hash table + * @param key Pointer to the key + * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length. + * @return Returns NULL if the key is not present. + */ +APR_DECLARE(void *) apr_hash_get(apr_hash_t *ht, const void *key, + apr_ssize_t klen); + +/** + * Start iterating over the entries in a hash table. + * @param p The pool to allocate the apr_hash_index_t iterator. If this + * pool is NULL, then an internal, non-thread-safe iterator is used. + * @param ht The hash table + * @remark There is no restriction on adding or deleting hash entries during + * an iteration (although the results may be unpredictable unless all you do + * is delete the current entry) and multiple iterations can be in + * progress at the same time. + + * @example + */ +/** + *
+ * 
+ * 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;
+ * }
+ * 
+ */ +APR_DECLARE(apr_hash_index_t *) apr_hash_first(apr_pool_t *p, apr_hash_t *ht); + +/** + * 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. + */ +APR_DECLARE(apr_hash_index_t *) apr_hash_next(apr_hash_index_t *hi); + +/** + * 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. + */ +APR_DECLARE(void) apr_hash_this(apr_hash_index_t *hi, const void **key, + apr_ssize_t *klen, void **val); + +/** + * 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. + */ +APR_DECLARE(unsigned int) apr_hash_count(apr_hash_t *ht); + +/** + * 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 + */ +APR_DECLARE(apr_hash_t *) apr_hash_overlay(apr_pool_t *p, + const apr_hash_t *overlay, + const apr_hash_t *base); + +/** + * 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 + */ +APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p, + const apr_hash_t *h1, + const apr_hash_t *h2, + void * (*merger)(apr_pool_t *p, + const void *key, + apr_ssize_t klen, + const void *h1_val, + const void *h2_val, + const void *data), + const void *data); + +/** + * Get a pointer to the pool which the hash table was created in + */ +APR_POOL_DECLARE_ACCESSOR(hash); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APR_HASH_H */ diff --git a/rubbos/app/apache2/include/apr_hooks.h b/rubbos/app/apache2/include/apr_hooks.h new file mode 100644 index 00000000..73435b82 --- /dev/null +++ b/rubbos/app/apache2/include/apr_hooks.h @@ -0,0 +1,273 @@ +/* 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. + */ + +#ifndef APR_HOOKS_H +#define APR_HOOKS_H + +#include "apu.h" +/* For apr_array_header_t */ +#include "apr_tables.h" + +/** + * @file apr_hooks.h + * @brief Apache hook functions + */ + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @defgroup APR_Util_Hook Hook Functions + * @ingroup APR_Util + * @{ + */ +/** macro to return the prototype of the hook function */ +#define APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \ +link##_DECLARE(apr_array_header_t *) ns##_hook_get_##name(void) + +/** macro to declare the hook correctly */ +#define APR_DECLARE_EXTERNAL_HOOK(ns,link,ret,name,args) \ +typedef ret ns##_HOOK_##name##_t args; \ +link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf, \ + const char * const *aszPre, \ + const char * const *aszSucc, int nOrder); \ +link##_DECLARE(ret) ns##_run_##name args; \ +APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name); \ +typedef struct ns##_LINK_##name##_t \ + { \ + ns##_HOOK_##name##_t *pFunc; \ + const char *szName; \ + const char * const *aszPredecessors; \ + const char * const *aszSuccessors; \ + int nOrder; \ + } ns##_LINK_##name##_t; + +/** macro to declare the hook structure */ +#define APR_HOOK_STRUCT(members) \ +static struct { members } _hooks; + +/** macro to link the hook structure */ +#define APR_HOOK_LINK(name) \ + apr_array_header_t *link_##name; + +/** macro to implement the hook */ +#define APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ +link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf,const char * const *aszPre, \ + const char * const *aszSucc,int nOrder) \ + { \ + ns##_LINK_##name##_t *pHook; \ + if(!_hooks.link_##name) \ + { \ + _hooks.link_##name=apr_array_make(apr_hook_global_pool,1,sizeof(ns##_LINK_##name##_t)); \ + apr_hook_sort_register(#name,&_hooks.link_##name); \ + } \ + pHook=apr_array_push(_hooks.link_##name); \ + pHook->pFunc=pf; \ + pHook->aszPredecessors=aszPre; \ + pHook->aszSuccessors=aszSucc; \ + pHook->nOrder=nOrder; \ + pHook->szName=apr_hook_debug_current; \ + if(apr_hook_debug_enabled) \ + apr_hook_debug_show(#name,aszPre,aszSucc); \ + } \ + APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \ + { \ + return _hooks.link_##name; \ + } + +/** + * Implement a hook that has no return code, and therefore runs all of the + * registered functions + * @param ns The namespace prefix of the hook functions + * @param link The linkage declaration prefix of the hook + * @param name The name of the hook + * @param args_decl The declaration of the arguments for the hook + * @param args_use The names for the arguments for the hook + * @note The link prefix FOO corresponds to FOO_DECLARE() macros, which + * provide export linkage from the module that IMPLEMENTs the hook, and + * import linkage from external modules that link to the hook's module. + */ +#define APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ns,link,name,args_decl,args_use) \ +APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ +link##_DECLARE(void) ns##_run_##name args_decl \ + { \ + ns##_LINK_##name##_t *pHook; \ + int n; \ +\ + if(!_hooks.link_##name) \ + return; \ +\ + pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ + for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ + pHook[n].pFunc args_use; \ + } + +/* FIXME: note that this returns ok when nothing is run. I suspect it should + really return decline, but that breaks Apache currently - Ben +*/ +/** + * Implement a hook that runs until one of the functions returns something + * other than OK or DECLINE + * @param ns The namespace prefix of the hook functions + * @param link The linkage declaration prefix of the hook + * @param ret Type to return + * @param name The name of the hook + * @param args_decl The declaration of the arguments for the hook + * @param args_use The names for the arguments for the hook + * @param ok Success value + * @param decline Decline value + * @note The link prefix FOO corresponds to FOO_DECLARE() macros, which + * provide export linkage from the module that IMPLEMENTs the hook, and + * import linkage from external modules that link to the hook's module. + */ +#define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \ +APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ +link##_DECLARE(ret) ns##_run_##name args_decl \ + { \ + ns##_LINK_##name##_t *pHook; \ + int n; \ + ret rv; \ +\ + if(!_hooks.link_##name) \ + return ok; \ +\ + pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ + for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ + { \ + rv=pHook[n].pFunc args_use; \ +\ + if(rv != ok && rv != decline) \ + return rv; \ + } \ + return ok; \ + } + + +/** + * Implement a hook that runs until the first function returns something + * other than the value of decline + * @param ns The namespace prefix of the hook functions + * @param link The linkage declaration prefix of the hook + * @param name The name of the hook + * @param ret Type to return + * @param args_decl The declaration of the arguments for the hook + * @param args_use The names for the arguments for the hook + * @param decline Decline value + * @note The link prefix FOO corresponds to FOO_DECLARE() macros, which + * provide export linkage from the module that IMPLEMENTs the hook, and + * import linkage from external modules that link to the hook's module. + */ +#define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ns,link,ret,name,args_decl,args_use,decline) \ +APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ +link##_DECLARE(ret) ns##_run_##name args_decl \ + { \ + ns##_LINK_##name##_t *pHook; \ + int n; \ + ret rv; \ +\ + if(!_hooks.link_##name) \ + return decline; \ +\ + pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ + for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ + { \ + rv=pHook[n].pFunc args_use; \ +\ + if(rv != decline) \ + return rv; \ + } \ + return decline; \ + } + + /* Hook orderings */ +/** run this hook first, before ANYTHING */ +#define APR_HOOK_REALLY_FIRST (-10) +/** run this hook first */ +#define APR_HOOK_FIRST 0 +/** run this hook somewhere */ +#define APR_HOOK_MIDDLE 10 +/** run this hook after every other hook which is defined*/ +#define APR_HOOK_LAST 20 +/** run this hook last, after EVERYTHING */ +#define APR_HOOK_REALLY_LAST 30 + +/** + * The global pool used to allocate any memory needed by the hooks. + */ +APU_DECLARE_DATA extern apr_pool_t *apr_hook_global_pool; + +/** @deprecated @see apr_hook_global_pool */ +APU_DECLARE_DATA extern apr_pool_t *apr_global_hook_pool; + +/** + * A global variable to determine if debugging information about the + * hooks functions should be printed + */ +APU_DECLARE_DATA extern int apr_hook_debug_enabled; + +/** @deprecated @see apr_hook_debug_enabled */ +APU_DECLARE_DATA extern int apr_debug_module_hooks; + +/** + * The name of the module that is currently registering a function + */ +APU_DECLARE_DATA extern const char *apr_hook_debug_current; + +/** @deprecated @see apr_hook_debug_current */ +APU_DECLARE_DATA extern const char *apr_current_hooking_module; + +/** + * Register a hook function to be sorted + * @param szHookName The name of the Hook the function is registered for + * @param aHooks The array which stores all of the functions for this hook + */ +APU_DECLARE(void) apr_hook_sort_register(const char *szHookName, + apr_array_header_t **aHooks); +/** + * Sort all of the registerd functions for a given hook + */ +APU_DECLARE(void) apr_hook_sort_all(void); + +/** @deprecated @see apr_hook_sort_all */ +APU_DECLARE(void) apr_sort_hooks(void); + +/** + * Print all of the information about the current hook. This is used for + * debugging purposes. + * @param szName The name of the hook + * @param aszPre All of the functions in the predecessor array + * @param aszSucc All of the functions in the successor array + */ +APU_DECLARE(void) apr_hook_debug_show(const char *szName, + const char * const *aszPre, + const char * const *aszSucc); + +/** @deprecated @see apr_hook_debug_show */ +APU_DECLARE(void) apr_show_hook(const char *szName, + const char * const *aszPre, + const char * const *aszSucc); + +/** + * Remove all currently registered functions. + */ +APU_DECLARE(void) apr_hook_deregister_all(void); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* APR_HOOKS_H */ diff --git a/rubbos/app/apache2/include/apr_inherit.h b/rubbos/app/apache2/include/apr_inherit.h new file mode 100644 index 00000000..b7f7480f --- /dev/null +++ b/rubbos/app/apache2/include/apr_inherit.h @@ -0,0 +1,51 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_INHERIT_H +#define APR_INHERIT_H + +/** + * @file apr_inherit.h + * @brief APR File Handle Inheritance Helpers + * @remark This internal header includes internal declaration helpers + * for other headers to declare apr_foo_inherit_[un]set functions. + */ + +/** + * Prototype for type-specific declarations of apr_foo_inherit_set + * functions. + * @remark Doxygen unwraps this macro (via doxygen.conf) to provide + * actual help for each specific occurance of apr_foo_inherit_set. + * @remark the linkage is specified for APR. It would be possible to expand + * the macros to support other linkages. + */ +#define APR_DECLARE_INHERIT_SET(type) \ + APR_DECLARE(apr_status_t) apr_##type##_inherit_set( \ + apr_##type##_t *the##type) + +/** + * Prototype for type-specific declarations of apr_foo_inherit_unset + * functions. + * @remark Doxygen unwraps this macro (via doxygen.conf) to provide + * actual help for each specific occurance of apr_foo_inherit_unset. + * @remark the linkage is specified for APR. It would be possible to expand + * the macros to support other linkages. + */ +#define APR_DECLARE_INHERIT_UNSET(type) \ + APR_DECLARE(apr_status_t) apr_##type##_inherit_unset( \ + apr_##type##_t *the##type) + +#endif /* ! APR_INHERIT_H */ diff --git a/rubbos/app/apache2/include/apr_ldap.h b/rubbos/app/apache2/include/apr_ldap.h new file mode 100644 index 00000000..fc737456 --- /dev/null +++ b/rubbos/app/apache2/include/apr_ldap.h @@ -0,0 +1,176 @@ +/* Copyright 2002-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. + */ + +/* + * apr_ldap.h is generated from apr_ldap.h.in by configure -- do not edit apr_ldap.h + */ +/** + * @file apr_ldap.h + * @brief APR-UTIL LDAP + */ +#ifndef APU_LDAP_H +#define APU_LDAP_H + +/** + * @defgroup APR_Util_LDAP LDAP + * @ingroup APR_Util + * @{ + */ + + +/* + * This switches LDAP support on or off. + */ + +/* this will be defined if LDAP support was compiled into apr-util */ +#define APR_HAS_LDAP 0 + +/* this whole thing disappears if LDAP is not enabled */ +#if !APR_HAS_LDAP + +#define APR_HAS_NETSCAPE_LDAPSDK 0 +#define APR_HAS_NOVELL_LDAPSDK 0 +#define APR_HAS_OPENLDAP_LDAPSDK 0 +#define APR_HAS_MICROSOFT_LDAPSDK 0 +#define APR_HAS_OTHER_LDAPSDK 0 + +#define APR_HAS_LDAP_SSL 0 +#define APR_HAS_LDAP_URL_PARSE 0 + + +#else /* ldap support available */ + +#ifdef APR_NOT_READY_YET +/* FIXME: this code awaits support from apu-conf.m4 */ + + /* There a several LDAPv3 SDKs available on various platforms + * define which LDAP SDK is used + */ +#define APR_HAS_NETSCAPE_LDAPSDK @apu_has_ldap_netscape@ +#define APR_HAS_NOVELL_LDAPSDK @apu_has_ldap_novell@ +#define APR_HAS_OPENLDAP_LDAPSDK @apu_has_ldap_openldap@ +#define APR_HAS_MICROSOFT_LDAPSDK @apu_has_ldap_microsoft@ +#define APR_HAS_OTHER_LDAPSDK @apu_has_ldap_other@ + + /* define if LDAP SSL support is available + */ +#define APR_HAS_LDAP_SSL @apu_has_ldap_ssl@ + +#else /* APR_NOT_READY_YET */ + +/* FIXME: remove this when above code works. Default to build with + * OpenLDAP until apu-conf.m4 support exists */ +#define APR_HAS_OPENLDAP_LDAPSDK 1 +#define APR_HAS_LDAP_SSL 1 + +#endif /* APR_NOT_READY_YET */ + + /* If no APR_HAS_xxx_LDAPSDK is defined error out + * Define if the SDK supports the ldap_url_parse function + */ +#if APR_HAS_NETSCAPE_LDAPSDK + #define APR_HAS_LDAP_URL_PARSE 1 +#elif APR_HAS_NOVELL_LDAPSDK + #define APR_HAS_LDAP_URL_PARSE 1 +#elif APR_HAS_OPENLDAP_LDAPSDK + #define APR_HAS_LDAP_URL_PARSE 1 +#elif APR_HAS_MICROSOFT_LDAPSDK + #define APR_HAS_LDAP_URL_PARSE 0 +#elif APR_HAS_OTHER_LDAPSDK + #define APR_HAS_LDAP_URL_PARSE 0 +#else + #define APR_HAS_LDAP_URL_PARSE 0 + #error "ERROR no LDAP SDK defined!" +#endif + +/* These are garbage, our public macros are always APR_HAS_ prefixed, + * and use 0/1 values, not defined/undef semantics. + * + * Will be deprecated in APR 1.0 + */ +#if APR_HAS_LDAP +#define APU_HAS_LDAP +#endif + +/* LDAP header files */ + +#if APR_HAS_NETSCAPE_LDAPSDK + + +#if APR_HAS_LDAP_SSL + +#endif +#endif + +#if APR_HAS_NOVELL_LDAPSDK + + +#if APR_HAS_LDAP_SSL + +#endif +#endif + +#if APR_HAS_OPENLDAP_LDAPSDK +#if !defined(LDAP_DEPRECATED) +/* Ensure that the "deprecated" interfaces are still exposed + * with OpenLDAP >= 2.3; these were exposed by default in earlier + * releases. */ +#define LDAP_DEPRECATED 1 +#endif + + +#endif + +/* MS & v2 LDAP SDKs don't use const parameters in their prototypes, + * LDAPv3 SDKs mostly use const. Bridge the gap for clean compilation. + */ + +#if LDAP_VERSION_MAX <= 2 || APR_HAS_MICROSOFT_LDAPSDK || defined(DOXYGEN) +/** + * Cast away constness to compile cleanly against v2 and MS LDAP SDKs + * @param conststr The value to un-constify on older LDAP SDKs + */ +#define APR_LDAP_UNCONST(conststr) ((char *)(conststr)) +#else +#define APR_LDAP_UNCONST(conststr) (conststr) +#endif + +#ifndef __cplusplus +/** + * Cast away constness to compile against v2 and MS LDAP SDKs + * @param conststr The value to un-constify on older LDAP SDKs + * @bug The apr_ldap.h macro const_cast violated three rules; + * it was a C++ reserved keyword, it violated the uppercase-only + * style guideline for apr macros, and it was not namespace protected. + * It exists here soley to avoid breaking legacy sources using APR 0.9. + * @deprecated @see APR_LDAP_UNCONST + */ +#define const_cast(conststr) APR_LDAP_UNCONST(conststr) +#endif + +#include "apr_ldap_url.h" + +/* Define some errors that are mysteriously gone from OpenLDAP 2.x */ +#ifndef LDAP_URL_ERR_NOTLDAP +#define LDAP_URL_ERR_NOTLDAP LDAP_URL_ERR_BADSCHEME +#endif + +#ifndef LDAP_URL_ERR_NODN +#define LDAP_URL_ERR_NODN LDAP_URL_ERR_BADURL +#endif + +/** @} */ +#endif /* APR_HAS_LDAP */ +#endif /* APU_LDAP_H */ diff --git a/rubbos/app/apache2/include/apr_ldap_url.h b/rubbos/app/apache2/include/apr_ldap_url.h new file mode 100644 index 00000000..b1813830 --- /dev/null +++ b/rubbos/app/apache2/include/apr_ldap_url.h @@ -0,0 +1,84 @@ +/* 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. + */ + +#ifndef APR_LDAP_URL_H +#define APR_LDAP_URL_H + +#include "apr_ldap.h" + +#if APR_HAS_LDAP +#if APR_HAS_LDAP_URL_PARSE + +#define apr_ldap_url_desc_t LDAPURLDesc +#define apr_ldap_is_ldap_url(url) ldap_is_ldap_url(url) +#define apr_ldap_is_ldaps_url(url) ldap_is_ldaps_url(url) +#define apr_ldap_is_ldapi_url(url) ldap_is_ldapi_url(url) +#define apr_ldap_url_parse(url, ludpp) ldap_url_parse(url, ludpp) +#define apr_ldap_free_urldesc(ludp) ldap_free_urldesc(ludp) + +#else /* ! APR_HAS_LDAP_URL_PARSE */ + +/* + * types for ldap URL handling + */ +typedef struct apr_ldap_url_desc_t { + struct apr_ldap_url_desc_t *lud_next; + char *lud_scheme; + char *lud_host; + int lud_port; + char *lud_dn; + char **lud_attrs; + int lud_scope; + char *lud_filter; + char **lud_exts; + int lud_crit_exts; +} apr_ldap_url_desc_t; + +#ifndef LDAP_URL_SUCCESS +#define LDAP_URL_SUCCESS 0x00 /* Success */ +#define LDAP_URL_ERR_MEM 0x01 /* can't allocate memory space */ +#define LDAP_URL_ERR_PARAM 0x02 /* parameter is bad */ +#define LDAP_URL_ERR_BADSCHEME 0x03 /* URL doesn't begin with "ldap[si]://" */ +#define LDAP_URL_ERR_BADENCLOSURE 0x04 /* URL is missing trailing ">" */ +#define LDAP_URL_ERR_BADURL 0x05 /* URL is bad */ +#define LDAP_URL_ERR_BADHOST 0x06 /* host port is bad */ +#define LDAP_URL_ERR_BADATTRS 0x07 /* bad (or missing) attributes */ +#define LDAP_URL_ERR_BADSCOPE 0x08 /* scope string is invalid (or missing) */ +#define LDAP_URL_ERR_BADFILTER 0x09 /* bad or missing filter */ +#define LDAP_URL_ERR_BADEXTS 0x0a /* bad or missing extensions */ +#endif + +/* + * in url.c + * + * need _ext varients + */ +APU_DECLARE(int) apr_ldap_is_ldap_url(const char *url); + +APU_DECLARE(int) apr_ldap_is_ldaps_url(const char *url); + +APU_DECLARE(int) apr_ldap_is_ldapi_url(const char *url); + +APU_DECLARE(int) apr_ldap_url_parse(const char *url, + apr_ldap_url_desc_t **ludpp); + +APU_DECLARE(void) apr_ldap_free_urldesc(apr_ldap_url_desc_t *ludp); + +#endif /* ! APR_HAS_LDAP_URL_PARSE */ + +#endif /* APR_HAS_LDAP */ + +#endif /* APR_LDAP_URL_H */ diff --git a/rubbos/app/apache2/include/apr_lib.h b/rubbos/app/apache2/include/apr_lib.h new file mode 100644 index 00000000..2d9ce534 --- /dev/null +++ b/rubbos/app/apache2/include/apr_lib.h @@ -0,0 +1,228 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_LIB_H +#define APR_LIB_H + +/** + * @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 +#endif +#if APR_HAVE_STDARG_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_lib General Purpose Library Routines + * @ingroup APR + * 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. + * @{ + */ + +/** A constant representing a 'large' string. */ +#define HUGE_STRING_LEN 8192 + +/* + * Define the structures used by the APR general-purpose library. + */ + +/** @see apr_vformatter_buff_t */ +typedef struct apr_vformatter_buff_t apr_vformatter_buff_t; + +/** + * Structure used by the variable-formatter routines. + */ +struct apr_vformatter_buff_t { + /** The current position */ + char *curpos; + /** The end position of the format string */ + char *endpos; +}; + +/** + * return the final element of the pathname + * @param pathname The path to get the final element of + * @return the final element of the path + * @remark + *
+ * For example:
+ *                 "/foo/bar/gum"    -> "gum"
+ *                 "/foo/bar/gum/"   -> ""
+ *                 "gum"             -> "gum"
+ *                 "bs\\path\\stuff" -> "stuff"
+ * 
+ */ +APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname); + +/** @deprecated @see apr_filepath_name_get */ +APR_DECLARE(const char *) apr_filename_of_pathname(const char *pathname); + +/** + * 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.
+ * 
+ */ +APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *b), + apr_vformatter_buff_t *c, const char *fmt, + va_list ap); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_password_get(const char *prompt, char *pwbuf, + apr_size_t *bufsize); + +/** @} */ + +/** + * @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 */ +#define apr_tolower(c) (tolower(((unsigned char)(c)))) +/** @see toupper */ +#define apr_toupper(c) (toupper(((unsigned char)(c)))) + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_LIB_H */ diff --git a/rubbos/app/apache2/include/apr_md4.h b/rubbos/app/apache2/include/apr_md4.h new file mode 100644 index 00000000..42d108df --- /dev/null +++ b/rubbos/app/apache2/include/apr_md4.h @@ -0,0 +1,135 @@ +/* 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. + */ +/* This is derived from material copyright RSA Data Security, Inc. + * Their notice is reproduced below in its entirety. + * + * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + * rights reserved. + * + * License to copy and use this software is granted provided that it + * is identified as the "RSA Data Security, Inc. MD4 Message-Digest + * Algorithm" in all material mentioning or referencing this software + * or this function. + * + * License is also granted to make and use derivative works provided + * that such works are identified as "derived from the RSA Data + * Security, Inc. MD4 Message-Digest Algorithm" in all material + * mentioning or referencing the derived work. + * + * RSA Data Security, Inc. makes no representations concerning either + * the merchantability of this software or the suitability of this + * software for any particular purpose. It is provided "as is" + * without express or implied warranty of any kind. + * + * These notices must be retained in any copies of any part of this + * documentation and/or software. + */ + +#ifndef APR_MD4_H +#define APR_MD4_H + +#include "apu.h" +#include "apr_xlate.h" +/** + * @file apr_md4.h + * @brief APR-UTIL MD4 Library + */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup APR_Util_MD4 MD4 Library + * @ingroup APR_Util + * @{ + */ + +/** The digestsize for MD4 */ +#define APR_MD4_DIGESTSIZE 16 + +/** @see apr_md4_ctx_t */ +typedef struct apr_md4_ctx_t apr_md4_ctx_t; + +/** MD4 context. */ +struct apr_md4_ctx_t { + /** state (ABCD) */ + apr_uint32_t state[4]; + /** number of bits, modulo 2^64 (lsb first) */ + apr_uint32_t count[2]; + /** input buffer */ + unsigned char buffer[64]; +#if APR_HAS_XLATE + /** translation handle */ + apr_xlate_t *xlate; +#endif +}; + +/** + * MD4 Initialize. Begins an MD4 operation, writing a new context. + * @param context The MD4 context to initialize. + */ +APU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context); + +#if APR_HAS_XLATE +/** + * MDr4 translation setup. Provides the APR translation handle to be used + * for translating the content before calculating the digest. + * @param context The MD4 content to set the translation for. + * @param xlate The translation handle to use for this MD4 context + */ +APU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context, + apr_xlate_t *xlate); +#else +#define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL +#endif + +/** + * MD4 block update operation. Continue an MD4 message-digest operation, + * processing another message block, and updating the context. + * @param context The MD4 content to update. + * @param input next message block to update + * @param inputLen The length of the next message block + */ +APU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context, + const unsigned char *input, + apr_size_t inputLen); + +/** + * MD4 finalization. Ends an MD4 message-digest operation, writing the + * message digest and zeroing the context + * @param digest The final MD4 digest + * @param context The MD4 content we are finalizing. + */ +APU_DECLARE(apr_status_t) apr_md4_final( + unsigned char digest[APR_MD4_DIGESTSIZE], + apr_md4_ctx_t *context); + +/** + * MD4 digest computation + * @param digest The MD4 digest + * @param input message block to use + * @param inputLen The length of the message block + */ +APU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE], + const unsigned char *input, + apr_size_t inputLen); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !APR_MD4_H */ diff --git a/rubbos/app/apache2/include/apr_md5.h b/rubbos/app/apache2/include/apr_md5.h new file mode 100644 index 00000000..83b6171a --- /dev/null +++ b/rubbos/app/apache2/include/apr_md5.h @@ -0,0 +1,158 @@ +/* + * This is work is derived from material Copyright RSA Data Security, Inc. + * + * The RSA copyright statement and Licence for that original material is + * included below. This is followed by the Apache copyright statement and + * licence for the modifications made to that material. + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + +/* 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. + */ + +#ifndef APR_MD5_H +#define APR_MD5_H + +#include "apu.h" +#include "apr_xlate.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @file apr_md5.h + * @brief APR MD5 Routines + */ + +/** + * @defgroup APR_MD5 MD5 Routines + * @ingroup APR + * @{ + */ + +/** The MD5 digest size */ +#define APR_MD5_DIGESTSIZE 16 +#define MD5_DIGESTSIZE APR_MD5_DIGESTSIZE /**< @deprecated */ + +/** @see apr_md5_ctx_t */ +typedef struct apr_md5_ctx_t apr_md5_ctx_t; + +/** MD5 context. */ +struct apr_md5_ctx_t { + /** state (ABCD) */ + apr_uint32_t state[4]; + /** number of bits, modulo 2^64 (lsb first) */ + apr_uint32_t count[2]; + /** input buffer */ + unsigned char buffer[64]; + /** translation handle + * ignored if xlate is unsupported + */ + apr_xlate_t *xlate; +}; + +/** + * MD5 Initialize. Begins an MD5 operation, writing a new context. + * @param context The MD5 context to initialize. + */ +APU_DECLARE(apr_status_t) apr_md5_init(apr_md5_ctx_t *context); + +/** + * MD5 translation setup. Provides the APR translation handle to be used + * for translating the content before calculating the digest. + * @param context The MD5 content to set the translation for. + * @param xlate The translation handle to use for this MD5 context + */ +APU_DECLARE(apr_status_t) apr_md5_set_xlate(apr_md5_ctx_t *context, + apr_xlate_t *xlate); + +/** + * MD5 block update operation. Continue an MD5 message-digest operation, + * processing another message block, and updating the context. + * @param context The MD5 content to update. + * @param input next message block to update + * @param inputLen The length of the next message block + */ +APU_DECLARE(apr_status_t) apr_md5_update(apr_md5_ctx_t *context, + const void *input, + apr_size_t inputLen); + +/** + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * message digest and zeroing the context + * @param digest The final MD5 digest + * @param context The MD5 content we are finalizing. + */ +APU_DECLARE(apr_status_t) apr_md5_final(unsigned char digest[APR_MD5_DIGESTSIZE], + apr_md5_ctx_t *context); + +/** + * MD5 in one step + * @param digest The final MD5 digest + * @param input The message block to use + * @param inputLen The length of the message block + */ +APU_DECLARE(apr_status_t) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE], + const void *input, + apr_size_t inputLen); + +/** + * Encode a password using an MD5 algorithm + * @param password The password to encode + * @param salt The salt to use for the encoding + * @param result The string to store the encoded password in + * @param nbytes The length of the string + */ +APU_DECLARE(apr_status_t) apr_md5_encode(const char *password, const char *salt, + char *result, apr_size_t nbytes); + + +/** + * Validate any password encypted with any algorithm that APR understands + * @param passwd The password to validate + * @param hash The password to validate against + */ +APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd, + const char *hash); + + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !APR_MD5_H */ diff --git a/rubbos/app/apache2/include/apr_mmap.h b/rubbos/app/apache2/include/apr_mmap.h new file mode 100644 index 00000000..3070acca --- /dev/null +++ b/rubbos/app/apache2/include/apr_mmap.h @@ -0,0 +1,193 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_MMAP_H +#define APR_MMAP_H + +/** + * @file apr_mmap.h + * @brief APR MMAP routines + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" +#include "apr_ring.h" +#include "apr_file_io.h" /* for apr_file_t */ + +#ifdef BEOS +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_mmap MMAP (Memory Map) Routines + * @ingroup APR + * @{ + */ + +/** MMap opened for reading */ +#define APR_MMAP_READ 1 +/** MMap opened for writing */ +#define APR_MMAP_WRITE 2 + +/** @see apr_mmap_t */ +typedef struct apr_mmap_t apr_mmap_t; + +/** + * @remark + * As far as I can tell the only really sane way to store an MMAP is as a + * void * and a length. BeOS requires this area_id, but that's just a little + * something extra. I am exposing this type, because it doesn't make much + * sense to keep it private, and opening it up makes some stuff easier in + * Apache. + */ +/** The MMAP structure */ +struct apr_mmap_t { + /** The pool the mmap structure was allocated out of. */ + apr_pool_t *cntxt; +#ifdef BEOS + /** An area ID. Only valid on BeOS */ + area_id area; +#endif +#ifdef WIN32 + /** The handle of the file mapping */ + HANDLE mhandle; + /** The start of the real memory page area (mapped view) */ + void *mv; + /** The physical start, size and offset */ + apr_off_t pstart; + apr_size_t psize; + apr_off_t poffset; +#endif + /** The start of the memory mapped area */ + void *mm; + /** The amount of data in the mmap */ + apr_size_t size; + /** @deprecated this field is no longer used and will be removed + * in APR 1.0 */ + int unused; + /** ring of apr_mmap_t's that reference the same + * mmap'ed region; acts in place of a reference count */ + APR_RING_ENTRY(apr_mmap_t) link; +}; + +#if APR_HAS_MMAP || defined(DOXYGEN) + +/** @def APR_MMAP_THRESHOLD + * Files have to be at least this big before they're mmap()d. This is to deal + * with systems where the expense of doing an mmap() and an munmap() outweighs + * the benefit for small files. It shouldn't be set lower than 1. + */ +#ifdef MMAP_THRESHOLD +# define APR_MMAP_THRESHOLD MMAP_THRESHOLD +#else +# ifdef SUNOS4 +# define APR_MMAP_THRESHOLD (8*1024) +# else +# define APR_MMAP_THRESHOLD 1 +# endif /* SUNOS4 */ +#endif /* MMAP_THRESHOLD */ + +/** @def APR_MMAP_LIMIT + * Maximum size of MMap region + */ +#ifdef MMAP_LIMIT +# define APR_MMAP_LIMIT MMAP_LIMIT +#else +# define APR_MMAP_LIMIT (4*1024*1024) +#endif /* MMAP_LIMIT */ + +/** Can this file be MMaped */ +#define APR_MMAP_CANDIDATE(filelength) \ + ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT)) + +/* Function definitions */ + +/** + * Create a new mmap'ed file out of an existing APR file. + * @param newmmap The newly created mmap'ed file. + * @param file The file turn into an mmap. + * @param offset The offset into the file to start the data pointer at. + * @param size The size of the file + * @param flag bit-wise or of: + *
+ *          APR_MMAP_READ       MMap opened for reading
+ *          APR_MMAP_WRITE      MMap opened for writing
+ * 
+ * @param cntxt The pool to use when creating the mmap. + */ +APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **newmmap, + apr_file_t *file, apr_off_t offset, + apr_size_t size, apr_int32_t flag, + apr_pool_t *cntxt); + +/** + * Duplicate the specified MMAP. + * @param new_mmap The structure to duplicate into. + * @param old_mmap The mmap to duplicate. + * @param p The pool to use for new_mmap. + * @param transfer_ownership DEPRECATED: this param is now ignored + * and should be removed prior to APR 1.0 + */ +APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, + apr_mmap_t *old_mmap, + apr_pool_t *p, + int transfer_ownership); + +#if defined(DOXYGEN) +/** + * Transfer the specified MMAP to a different pool + * @param new_mmap The structure to duplicate into. + * @param old_mmap The file to transfer. + * @param p The pool to use for new_mmap. + * @deprecated Just use apr_mmap_dup(). The transfer_ownership flag will + * go away soon anyway. + */ +APR_DECLARE(apr_status_t) apr_mmap_setaside(apr_mmap_t **new_mmap, + apr_mmap_t *old_mmap, + apr_pool_t *p); +#else +#define apr_mmap_setaside(new_mmap, old_mmap, p) apr_mmap_dup(new_mmap, old_mmap, p, 1) +#endif /* DOXYGEN */ + +/** + * Remove a mmap'ed. + * @param mm The mmap'ed file. + */ +APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm); + +/** + * Move the pointer into the mmap'ed file to the specified offset. + * @param addr The pointer to the offset specified. + * @param mm The mmap'ed file. + * @param offset The offset to move to. + */ +APR_DECLARE(apr_status_t) apr_mmap_offset(void **addr, apr_mmap_t *mm, + apr_off_t offset); + +#endif /* APR_HAS_MMAP */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_MMAP_H */ diff --git a/rubbos/app/apache2/include/apr_network_io.h b/rubbos/app/apache2/include/apr_network_io.h new file mode 100644 index 00000000..2bc6ef1e --- /dev/null +++ b/rubbos/app/apache2/include/apr_network_io.h @@ -0,0 +1,845 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_NETWORK_IO_H +#define APR_NETWORK_IO_H +/** + * @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 +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_network_io Network Routines + * @ingroup APR + * @{ + */ + +#ifndef APR_MAX_SECS_TO_LINGER +/** Maximum seconds to linger */ +#define APR_MAX_SECS_TO_LINGER 30 +#endif + +#ifndef MAX_SECS_TO_LINGER +/** @deprecated @see APR_MAX_SECS_TO_LINGER */ +#define MAX_SECS_TO_LINGER APR_MAX_SECS_TO_LINGER +#endif + +#ifndef APRMAXHOSTLEN +/** Maximum hostname length */ +#define APRMAXHOSTLEN 256 +#endif + +#ifndef APR_ANYADDR +/** Default 'any' address */ +#define APR_ANYADDR "0.0.0.0" +#endif + +/** + * @defgroup apr_sockopt Socket option definitions + * @{ + */ +#define APR_SO_LINGER 1 /**< Linger */ +#define APR_SO_KEEPALIVE 2 /**< Keepalive */ +#define APR_SO_DEBUG 4 /**< Debug */ +#define APR_SO_NONBLOCK 8 /**< Non-blocking IO */ +#define APR_SO_REUSEADDR 16 /**< Reuse addresses */ +#define APR_SO_TIMEOUT 32 /**< Timeout */ +#define APR_SO_SNDBUF 64 /**< Send buffer */ +#define APR_SO_RCVBUF 128 /**< Receive buffer */ +#define APR_SO_DISCONNECTED 256 /**< Disconnected */ +#define APR_TCP_NODELAY 512 /**< For SCTP sockets, this is mapped + * to STCP_NODELAY internally. + */ +#define APR_TCP_NOPUSH 1024 /**< No push */ +#define APR_RESET_NODELAY 2048 /**< This flag is ONLY set internally + * when we set APR_TCP_NOPUSH with + * APR_TCP_NODELAY set to tell us that + * APR_TCP_NODELAY should be turned on + * again when NOPUSH is turned off + */ +#define APR_INCOMPLETE_READ 4096 /**< Set on non-blocking sockets + * (timeout != 0) on which the + * previous read() did not fill a buffer + * completely. the next apr_socket_recv() + * will first call select()/poll() rather than + * going straight into read(). (Can also + * be set by an application to force a + * select()/poll() call before the next + * read, in cases where the app expects + * that an immediate read would fail.) + */ +#define APR_INCOMPLETE_WRITE 8192 /**< like APR_INCOMPLETE_READ, but for write + * @see APR_INCOMPLETE_READ + */ +#define APR_IPV6_V6ONLY 16384 /**< Don't accept IPv4 connections on an + * IPv6 listening socket. + */ + +/** @} */ + +/** Define what type of socket shutdown should occur. */ +typedef enum { + APR_SHUTDOWN_READ, /**< no longer allow read request */ + APR_SHUTDOWN_WRITE, /**< no longer allow write requests */ + APR_SHUTDOWN_READWRITE /**< no longer allow read or write requests */ +} apr_shutdown_how_e; + +#define APR_IPV4_ADDR_OK 0x01 /**< @see apr_sockaddr_info_get() */ +#define APR_IPV6_ADDR_OK 0x02 /**< @see apr_sockaddr_info_get() */ + +#if (!APR_HAVE_IN_ADDR) +/** + * We need to make sure we always have an in_addr type, so APR will just + * define it ourselves, if the platform doesn't provide it. + */ +struct in_addr { + apr_uint32_t s_addr; /**< storage to hold the IP# */ +}; +#endif + +/** + * @def APR_INET + * Not all platforms have these defined, so we'll define them here + * The default values come from FreeBSD 4.1.1 + */ +#define APR_INET AF_INET +/** @def APR_UNSPEC + * Let the system decide which address family to use + */ +#ifdef AF_UNSPEC +#define APR_UNSPEC AF_UNSPEC +#else +#define APR_UNSPEC 0 +#endif +#if APR_HAVE_IPV6 +#define APR_INET6 AF_INET6 +#endif + +/** + * @defgroup IP_Proto IP Protocol Definitions for use when creating sockets + * @{ + */ +#define APR_PROTO_TCP 6 /**< TCP */ +#define APR_PROTO_UDP 17 /**< UDP */ +#define APR_PROTO_SCTP 132 /**< SCTP */ +/** @} */ + +/** + * Enum to tell us if we're interested in remote or local socket + */ +typedef enum { + APR_LOCAL, + APR_REMOTE +} apr_interface_e; + +/** + * The specific declaration of inet_addr's ... some platforms fall back + * inet_network (this is not good, but necessary) + */ + +#if APR_HAVE_INET_ADDR +#define apr_inet_addr inet_addr +#elif APR_HAVE_INET_NETWORK /* only DGUX, as far as I know */ +/** + * @warning + * not generally safe... inet_network() and inet_addr() perform + * different functions */ +#define apr_inet_addr inet_network +#endif + +/** A structure to represent sockets */ +typedef struct apr_socket_t apr_socket_t; +/** + * A structure to encapsulate headers and trailers for apr_socket_sendfile + */ +typedef struct apr_hdtr_t apr_hdtr_t; +/** A structure to represent in_addr */ +typedef struct in_addr apr_in_addr_t; +/** A structure to represent an IP subnet */ +typedef struct apr_ipsubnet_t apr_ipsubnet_t; + +/** @remark use apr_uint16_t just in case some system has a short that isn't 16 bits... */ +typedef apr_uint16_t apr_port_t; + +/** @remark It's defined here as I think it should all be platform safe... + * @see apr_sockaddr_t + */ +typedef struct apr_sockaddr_t apr_sockaddr_t; +/** + * APRs socket address type, used to ensure protocol independence + */ +struct apr_sockaddr_t { + /** The pool to use... */ + apr_pool_t *pool; + /** The hostname */ + char *hostname; + /** Either a string of the port number or the service name for the port */ + char *servname; + /** The numeric port */ + apr_port_t port; + /** The family */ + apr_int32_t family; + /** Union of either IPv4 or IPv6 sockaddr. */ + union { + /** IPv4 sockaddr structure */ + struct sockaddr_in sin; +#if APR_HAVE_IPV6 + /** IPv6 sockaddr structure */ + struct sockaddr_in6 sin6; +#endif + } sa; + /** How big is the sockaddr we're using? */ + apr_socklen_t salen; + /** How big is the ip address structure we're using? */ + int ipaddr_len; + /** How big should the address buffer be? 16 for v4 or 46 for v6 + * used in inet_ntop... */ + int addr_str_len; + /** This points to the IP address structure within the appropriate + * sockaddr structure. */ + void *ipaddr_ptr; + /** If multiple addresses were found by apr_sockaddr_info_get(), this + * points to a representation of the next address. */ + apr_sockaddr_t *next; +}; + +#if APR_HAS_SENDFILE +/** + * Support reusing the socket on platforms which support it (from disconnect, + * specifically Win32. + * @remark Optional flag passed into apr_socket_sendfile() + */ +#define APR_SENDFILE_DISCONNECT_SOCKET 1 +#endif + +/** A structure to encapsulate headers and trailers for apr_socket_sendfile */ +struct apr_hdtr_t { + /** An iovec to store the headers sent before the file. */ + struct iovec* headers; + /** number of headers in the iovec */ + int numheaders; + /** An iovec to store the trailers sent after the file. */ + struct iovec* trailers; + /** number of trailers in the iovec */ + int numtrailers; +}; + +/* function definitions */ + +/** + * Create a socket. + * @remark With APR 1.0, this function follows the prototype + * of apr_socket_create_ex. + * @param new_sock The new socket that has been set up. + * @param family The address family of the socket (e.g., APR_INET). + * @param type The type of the socket (e.g., SOCK_STREAM). + * @param cont The pool to use + */ +APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new_sock, + int family, int type, + apr_pool_t *cont); + +/** + * Create a socket. + * @remark With APR 1.0, this function is deprecated and apr_socket_create + * follows this prototype. + * @param new_sock The new socket that has been set up. + * @param family The address family of the socket (e.g., APR_INET). + * @param type The type of the socket (e.g., SOCK_STREAM). + * @param protocol The protocol of the socket (e.g., APR_PROTO_TCP). + * @param cont The pool to use + */ +APR_DECLARE(apr_status_t) apr_socket_create_ex(apr_socket_t **new_sock, + int family, int type, + int protocol, + apr_pool_t *cont); + +/** + * Shutdown either reading, writing, or both sides of a socket. + * @param thesocket The socket to close + * @param how How to shutdown the socket. One of: + *
+ *            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. + */ +APR_DECLARE(apr_status_t) apr_socket_shutdown(apr_socket_t *thesocket, + apr_shutdown_how_e how); + +/** @deprecated @see apr_socket_shutdown */ +APR_DECLARE(apr_status_t) apr_shutdown(apr_socket_t *thesocket, + apr_shutdown_how_e how); + +/** + * Close a socket. + * @param thesocket The socket to close + */ +APR_DECLARE(apr_status_t) apr_socket_close(apr_socket_t *thesocket); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_socket_bind(apr_socket_t *sock, + apr_sockaddr_t *sa); + +/** @deprecated @see apr_socket_bind */ +APR_DECLARE(apr_status_t) apr_bind(apr_socket_t *sock, apr_sockaddr_t *sa); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_socket_listen(apr_socket_t *sock, + apr_int32_t backlog); + +/** @deprecated @see apr_socket_listen */ +APR_DECLARE(apr_status_t) apr_listen(apr_socket_t *sock, apr_int32_t backlog); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_socket_accept(apr_socket_t **new_sock, + apr_socket_t *sock, + apr_pool_t *connection_pool); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock, + apr_sockaddr_t *sa); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa, + const char *hostname, + apr_int32_t family, + apr_port_t port, + apr_int32_t flags, + apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname, + apr_sockaddr_t *sa, + apr_int32_t flags); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr, + char **scope_id, + apr_port_t *port, + const char *str, + apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len, apr_pool_t *cont); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key, + apr_socket_t *sock); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, + const char *key, + apr_status_t (*cleanup)(void*)); + +/** + * 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.
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, + apr_size_t *len); + +/** @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.
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, + const struct iovec *vec, + apr_int32_t nvec, apr_size_t *len); + +/** @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 + */ +APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, + apr_sockaddr_t *where, + apr_int32_t flags, const char *buf, + apr_size_t *len); + +/** @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 + */ + +APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, + apr_socket_t *sock, + apr_int32_t flags, char *buf, + apr_size_t *len); + +/** @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 APR_HAS_SENDFILE || 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. + */ +APR_DECLARE(apr_status_t) apr_socket_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); + +/** @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.
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, + char *buf, apr_size_t *len); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, + apr_int32_t opt, apr_int32_t on); + +/** @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
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_socket_timeout_set(apr_socket_t *sock, + apr_interval_time_t t); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock, + apr_int32_t opt, apr_int32_t *on); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock, + apr_interval_time_t *t); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, + int *atmark); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_socket_addr_get(apr_sockaddr_t **sa, + apr_interface_e which, + apr_socket_t *sock); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_sockaddr_port_set(apr_sockaddr_t *sockaddr, + apr_port_t port); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_sockaddr_port_get(apr_port_t *port, + apr_sockaddr_t *sockaddr); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_sockaddr_ip_set(apr_sockaddr_t *sockaddr, + const char *addr); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_sockaddr_ip_get(char **addr, + apr_sockaddr_t *sockaddr); + +/** + * 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. + */ +APR_DECLARE(int) apr_sockaddr_equal(const apr_sockaddr_t *addr1, + const apr_sockaddr_t *addr2); + + +#if APR_FILES_AS_SOCKETS || 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. + */ +APR_DECLARE(apr_status_t) apr_socket_from_file(apr_socket_t **newsock, + apr_file_t *file); + +#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 + */ +APR_DECLARE(apr_status_t) apr_getservbyname(apr_sockaddr_t *sockaddr, + const char *servname); +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_ipsubnet_create(apr_ipsubnet_t **ipsub, + const char *ipstr, + const char *mask_or_numbits, + apr_pool_t *p); + +/** + * 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 + */ +APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa); + +#if APR_HAS_SO_ACCEPTFILTER || 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. + */ +apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name, + char *args); +#endif + +/** + * Return the protocol of the socket. + * @param sock The socket to query. + * @param protocol The returned protocol (e.g., APR_PROTO_TCP). + */ +APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, + int *protocol); + +/** + * 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); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_NETWORK_IO_H */ + diff --git a/rubbos/app/apache2/include/apr_optional.h b/rubbos/app/apache2/include/apr_optional.h new file mode 100644 index 00000000..32e2ac3c --- /dev/null +++ b/rubbos/app/apache2/include/apr_optional.h @@ -0,0 +1,99 @@ +/* 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. + */ + +#ifndef APR_OPTIONAL_H +#define APR_OPTIONAL_H + +#include "apu.h" +/** + * @file apr_optional.h + * @brief APR-UTIL registration of functions exported by modules + */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup APR_Util_Opt Optional Functions + * @ingroup APR_Util + * + * Typesafe registration and retrieval of functions that may not be present + * (i.e. functions exported by optional modules) + * @{ + */ + +/** + * The type of an optional function. + * @param name The name of the function + */ +#define APR_OPTIONAL_FN_TYPE(name) apr_OFN_##name##_t + +/** + * Declare an optional function. + * @param ret The return type of the function + * @param name The name of the function + * @param args The function arguments (including brackets) + */ +#define APR_DECLARE_OPTIONAL_FN(ret,name,args) \ +typedef ret (APR_OPTIONAL_FN_TYPE(name)) args + +/** + * XXX: This doesn't belong here, then! + * Private function! DO NOT USE! + * @internal + */ + +typedef void (apr_opt_fn_t)(void); +/** @internal */ +APU_DECLARE_NONSTD(void) apr_dynamic_fn_register(const char *szName, + apr_opt_fn_t *pfn); + +/** @internal deprecated function, see apr_dynamic_fn_register */ +APU_DECLARE_NONSTD(void) apr_register_optional_fn(const char *szName, + apr_opt_fn_t *pfn); + +/** + * Register an optional function. This can be later retrieved, type-safely, by + * name. Like all global functions, the name must be unique. Note that, + * confusingly but correctly, the function itself can be static! + * @param name The name of the function + */ +#define APR_REGISTER_OPTIONAL_FN(name) do { \ + APR_OPTIONAL_FN_TYPE(name) *apu__opt = name; \ + apr_dynamic_fn_register(#name,(apr_opt_fn_t *)apu__opt); \ +} while (0) + +/** @internal + * Private function! DO NOT USE! + */ +APU_DECLARE(apr_opt_fn_t *) apr_dynamic_fn_retrieve(const char *szName); + +/** @internal deprecated function, see apr_dynamic_fn_retrieve */ +APU_DECLARE(apr_opt_fn_t *) apr_retrieve_optional_fn(const char *szName); + +/** + * Retrieve an optional function. Returns NULL if the function is not present. + * @param name The name of the function + */ +#define APR_RETRIEVE_OPTIONAL_FN(name) \ + (APR_OPTIONAL_FN_TYPE(name) *)apr_dynamic_fn_retrieve(#name) + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* APR_OPTIONAL_H */ diff --git a/rubbos/app/apache2/include/apr_optional_hooks.h b/rubbos/app/apache2/include/apr_optional_hooks.h new file mode 100644 index 00000000..7d01ab00 --- /dev/null +++ b/rubbos/app/apache2/include/apr_optional_hooks.h @@ -0,0 +1,117 @@ +/* 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_optional_hooks.h + * @brief Apache optional hook functions + */ + + +#ifndef APR_OPTIONAL_HOOK_H +#define APR_OPTIONAL_HOOK_H + +#include "apr_tables.h" + +#ifdef __cplusplus +extern "C" { +#endif +/** + * @defgroup APR_Util_OPT_HOOK Optional Hook Functions + * @ingroup APR_Util_Hook + * @{ + */ +/** + * Function to implemnt the APR_OPTIONAL_HOOK Macro + * @internal + * @see APR_OPTIONAL_HOOK + * + * @param name The name of the hook + * @param pfn A pointer to a function that will be called + * @param aszPre a NULL-terminated array of strings that name modules whose hooks should precede this one + * @param aszSucc a NULL-terminated array of strings that name modules whose hooks should succeed this one + * @param nOrder an integer determining order before honouring aszPre and aszSucc (for example HOOK_MIDDLE) + */ + + +APU_DECLARE(void) apr_optional_hook_add(const char *szName,void (*pfn)(void), + const char * const *aszPre, + const char * const *aszSucc, + int nOrder); + +/** + * Hook to an optional hook. + * + * @param ns The namespace prefix of the hook functions + * @param name The name of the hook + * @param pfn A pointer to a function that will be called + * @param aszPre a NULL-terminated array of strings that name modules whose hooks should precede this one + * @param aszSucc a NULL-terminated array of strings that name modules whose hooks should succeed this one + * @param nOrder an integer determining order before honouring aszPre and aszSucc (for example HOOK_MIDDLE) + */ + +#define APR_OPTIONAL_HOOK(ns,name,pfn,aszPre,aszSucc,nOrder) do { \ + ns##_HOOK_##name##_t *apu__hook = pfn; \ + apr_optional_hook_add(#name,(void (*)(void))apu__hook,aszPre, aszSucc, nOrder); \ +} while (0) + +/** + * @internal + * @param szName - the name of the function + * @return the hook structure for a given hook + */ +APU_DECLARE(apr_array_header_t *) apr_optional_hook_get(const char *szName); + +/** + * Implement an optional hook that runs until one of the functions + * returns something other than OK or DECLINE. + * + * @param ns The namespace prefix of the hook functions + * @param link The linkage declaration prefix of the hook + * @param ret The type of the return value of the hook + * @param ret The type of the return value of the hook + * @param name The name of the hook + * @param args_decl The declaration of the arguments for the hook + * @param args_use The names for the arguments for the hook + * @param ok Success value + * @param decline Decline value + */ +#define APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \ +link##_DECLARE(ret) ns##_run_##name args_decl \ + { \ + ns##_LINK_##name##_t *pHook; \ + int n; \ + ret rv; \ + apr_array_header_t *pHookArray=apr_optional_hook_get(#name); \ +\ + if(!pHookArray) \ + return ok; \ +\ + pHook=(ns##_LINK_##name##_t *)pHookArray->elts; \ + for(n=0 ; n < pHookArray->nelts ; ++n) \ + { \ + rv=(pHook[n].pFunc)args_use; \ +\ + if(rv != ok && rv != decline) \ + return rv; \ + } \ + return ok; \ + } + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* APR_OPTIONAL_HOOK_H */ diff --git a/rubbos/app/apache2/include/apr_poll.h b/rubbos/app/apache2/include/apr_poll.h new file mode 100644 index 00000000..d71cc3a1 --- /dev/null +++ b/rubbos/app/apache2/include/apr_poll.h @@ -0,0 +1,253 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_POLL_H +#define APR_POLL_H +/** + * @file apr_poll.h + * @brief APR Poll interface + */ +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" +#include "apr_inherit.h" +#include "apr_file_io.h" +#include "apr_network_io.h" + +#if APR_HAVE_NETINET_IN_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_poll Poll Routines + * @ingroup APR + * @{ + */ + +/** + * @defgroup apr_poll_opt Poll options + * @{ + */ +#define APR_POLLIN 0x001 /**< Can read without blocking */ +#define APR_POLLPRI 0x002 /**< Priority data available */ +#define APR_POLLOUT 0x004 /**< Can write without blocking */ +#define APR_POLLERR 0x010 /**< Pending error */ +#define APR_POLLHUP 0x020 /**< Hangup occurred */ +#define APR_POLLNVAL 0x040 /**< Descriptior invalid */ +/** @} */ + +/** Used in apr_pollfd_t to determine what the apr_descriptor is */ +typedef enum { + APR_NO_DESC, /**< nothing here */ + APR_POLL_SOCKET, /**< descriptor refers to a socket */ + APR_POLL_FILE, /**< descriptor refers to a file */ + APR_POLL_LASTDESC /**< descriptor is the last one in the list */ +} apr_datatype_e ; + +/** Union of either an APR file or socket. */ +typedef union { + apr_file_t *f; /**< file */ + apr_socket_t *s; /**< socket */ +} apr_descriptor; + +/** @see apr_pollfd_t */ +typedef struct apr_pollfd_t apr_pollfd_t; + +/** Poll descriptor set. */ +struct apr_pollfd_t { + apr_pool_t *p; /**< associated pool */ + apr_datatype_e desc_type; /**< descriptor type */ + apr_int16_t reqevents; /**< requested events */ + apr_int16_t rtnevents; /**< returned events */ + apr_descriptor desc; /**< @see apr_descriptor */ + void *client_data; /**< allows app to associate context */ +}; + +/** + * Setup the memory required for poll to operate properly + * @param new_poll The poll structure to be used. + * @param num The number of socket descriptors to be polled. + * @param cont The pool to operate on. + * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + */ +APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new_poll, + apr_int32_t num, + apr_pool_t *cont); + +/** + * Poll the sockets in the poll structure + * @param aprset The poll structure we will be using. + * @param numsock The number of sockets we are polling + * @param nsds The number of sockets signalled. + * @param timeout The amount of time in microseconds to wait. This is + * a maximum, not a minimum. If a socket is signalled, we + * will wake up before this time. A negative number means + * wait until a socket is signalled. + * @remark + *
+ * The number of sockets signalled is returned in the second argument. 
+ *
+ *        This is a blocking call, and it will not return until either a 
+ *        socket has been signalled, or the timeout has expired. 
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t numsock, + apr_int32_t *nsds, + apr_interval_time_t timeout); + +/** + * Add a socket to the poll structure. + * @param aprset The poll structure we will be using. + * @param sock The socket to add to the current poll structure. + * @param event The events to look for when we do the poll. One of: + *
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if prioirty data is availble to be read
+ *            APR_POLLOUT      signal if write will not block
+ * 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + */ +APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset, + apr_socket_t *sock, + apr_int16_t event); + +/** + * Modify a socket in the poll structure with mask. + * @param aprset The poll structure we will be using. + * @param sock The socket to modify in poll structure. + * @param events The events to stop looking for during the poll. One of: + *
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if priority data is available to be read
+ *            APR_POLLOUT      signal if write will not block
+ * 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + */ +APR_DECLARE(apr_status_t) apr_poll_socket_mask(apr_pollfd_t *aprset, + apr_socket_t *sock, + apr_int16_t events); +/** + * Remove a socket from the poll structure. + * @param aprset The poll structure we will be using. + * @param sock The socket to remove from the current poll structure. + * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + */ +APR_DECLARE(apr_status_t) apr_poll_socket_remove(apr_pollfd_t *aprset, + apr_socket_t *sock); + +/** + * Clear all events in the poll structure. + * @param aprset The poll structure we will be using. + * @param events The events to clear from all sockets. One of: + *
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if priority data is available to be read
+ *            APR_POLLOUT      signal if write will not block
+ * 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + */ +APR_DECLARE(apr_status_t) apr_poll_socket_clear(apr_pollfd_t *aprset, + apr_int16_t events); + +/** + * Get the return events for the specified socket. + * @param event The returned events for the socket. One of: + *
+ *            APR_POLLIN       Data is available to be read 
+ *            APR_POLLPRI      Priority data is availble to be read
+ *            APR_POLLOUT      Write will succeed
+ *            APR_POLLERR      An error occurred on the socket
+ *            APR_POLLHUP      The connection has been terminated
+ *            APR_POLLNVAL     This is an invalid socket to poll on.
+ *                             Socket not open.
+ * 
+ * @param sock The socket we wish to get information about. + * @param aprset The poll structure we will be using. + * @deprecated This function is deprecated, APR applications should control the pollset memory themselves. + */ +APR_DECLARE(apr_status_t) apr_poll_revents_get(apr_int16_t *event, + apr_socket_t *sock, + apr_pollfd_t *aprset); + +/* General-purpose poll API for arbitrarily large numbers of + * file descriptors + */ + +/** Opaque structure used for pollset API */ +typedef struct apr_pollset_t apr_pollset_t; + +/** + * Setup a pollset object + * @param pollset The pointer in which to return the newly created object + * @param size The maximum number of descriptors that this pollset can hold + * @param p The pool from which to allocate the pollset + * @param flags Optional flags to modify the operation of the pollset + * (reserved for future expansion) + */ +APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset, + apr_uint32_t size, + apr_pool_t *p, + apr_uint32_t flags); + +/** + * Destroy a pollset object + * @param pollset The pollset to destroy + */ +APR_DECLARE(apr_status_t) apr_pollset_destroy(apr_pollset_t *pollset); + +/** + * Add a socket or file descriptor to a pollset + * @param pollset The pollset to which to add the descriptor + * @param descriptor The descriptor to add + * @remark If you set client_data in the descriptor, that value + * will be returned in the client_data field whenever this + * descriptor is signalled in apr_pollset_poll(). + */ +APR_DECLARE(apr_status_t) apr_pollset_add(apr_pollset_t *pollset, + const apr_pollfd_t *descriptor); + +/** + * Remove a descriptor from a pollset + * @param pollset The pollset from which to remove the descriptor + * @param descriptor The descriptor to remove + */ +APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset, + const apr_pollfd_t *descriptor); + +/** + * Block for activity on the descriptor(s) in a pollset + * @param pollset The pollset to use + * @param timeout Timeout in microseconds + * @param num Number of signalled descriptors (output parameter) + * @param descriptors Array of signalled descriptors (output parameter) + */ +APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset, + apr_interval_time_t timeout, + apr_int32_t *num, + const apr_pollfd_t **descriptors); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_POLL_H */ + diff --git a/rubbos/app/apache2/include/apr_pools.h b/rubbos/app/apache2/include/apr_pools.h new file mode 100644 index 00000000..2f4353f0 --- /dev/null +++ b/rubbos/app/apache2/include/apr_pools.h @@ -0,0 +1,664 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_POOLS_H +#define APR_POOLS_H + +/** + * @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 */ +#define APR_WANT_MEMFUNC /**< for no good reason? */ +#include "apr_want.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup apr_pools Memory Pool Functions + * @ingroup APR + * @{ + */ + +/** The fundamental pool type */ +typedef struct apr_pool_t apr_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. */ +typedef int (*apr_abortfunc_t)(int retcode); + +/* + * 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 + */ +APR_DECLARE(apr_status_t) apr_pool_initialize(void); + +/** + * 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 + */ +APR_DECLARE(void) apr_pool_terminate(void); + + +/* + * Pool creation/destruction + */ + +#include "apr_allocator.h" + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool, + apr_pool_t *parent, + apr_abortfunc_t abort_fn, + apr_allocator_t *allocator); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool, + apr_pool_t *parent, + apr_abortfunc_t abort_fn, + apr_allocator_t *allocator, + const char *file_line); + +#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. + */ +#if defined(DOXYGEN) +APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool, + apr_pool_t *parent); +#else +#if APR_POOL_DEBUG +#define apr_pool_create(newpool, parent) \ + apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \ + APR_POOL__FILE_LINE__) +#else +#define apr_pool_create(newpool, parent) \ + apr_pool_create_ex(newpool, parent, NULL, NULL) +#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 +#define apr_pool_sub_make(newpool, parent, abort_fn) \ + (void)apr_pool_create_ex(newpool, parent, abort_fn, NULL) +#endif + +/** + * Find the pools allocator + * @param pool The pool to get the allocator from. + */ +APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool); + +/** + * 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() + */ +APR_DECLARE(void) apr_pool_clear(apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p, + const char *file_line); + +#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 + */ +APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p, + const char *file_line); + +#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 + */ +APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size); + +/** + * 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 + */ +APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size, + const char *file_line); + +#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) +APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size); +#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. + */ +APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc, + apr_pool_t *pool); + +/** @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. + */ +APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool); + +/** @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. + */ +APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool); + +/** @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. + */ +APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b); + +/** + * Tag a pool (give it a name) + * @param pool The pool to tag + * @param tag The tag + */ +APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag); + + +/* + * 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. + */ +APR_DECLARE(apr_status_t) apr_pool_userdata_set( + const void *data, + const char *key, + apr_status_t (*cleanup)(void *), + apr_pool_t *pool); + +/** + * 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. + * + */ +APR_DECLARE(apr_status_t) apr_pool_userdata_setn( + const void *data, + const char *key, + apr_status_t (*cleanup)(void *), + apr_pool_t *pool); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key, + apr_pool_t *pool); + + +/* + * 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! + */ +APR_DECLARE(void) apr_pool_cleanup_register( + apr_pool_t *p, + const void *data, + apr_status_t (*plain_cleanup)(void *), + apr_status_t (*child_cleanup)(void *)); + +/** + * 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 + */ +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 + */ +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 + */ +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 + */ +APR_DECLARE(void) apr_pool_cleanup_for_exec(void); + + +/** + * @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 APR_POOL_DEBUG || defined(DOXYGEN) +/** + * Guarantee that a subpool has the same lifetime as the parent. + * @param p The parent pool + * @param sub The subpool + */ +APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub); + +/** + * Find a pool from something allocated in it. + * @param mem The thing allocated in the pool + * @return The pool it is allocated in + */ +APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem); + +/** + * 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 + */ +APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse); + +/** + * Lock a pool + * @param pool The pool to lock + * @param flag The flag + */ +APR_DECLARE(void) apr_pool_lock(apr_pool_t *pool, int flag); + +/* @} */ + +#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 */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APR_POOLS_H */ diff --git a/rubbos/app/apache2/include/apr_portable.h b/rubbos/app/apache2/include/apr_portable.h new file mode 100644 index 00000000..ffeff9b0 --- /dev/null +++ b/rubbos/app/apache2/include/apr_portable.h @@ -0,0 +1,505 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* 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 . + */ +#ifndef APR_PORTABLE_H +#define APR_PORTABLE_H +/** + * @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 +#endif +#if APR_HAVE_FCNTL_H +#include +#endif +#if APR_HAVE_PTHREAD_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_portabile Portability Routines + * @ingroup APR + * @{ + */ + +#ifdef WIN32 +/* The primitives for Windows types */ +typedef HANDLE apr_os_file_t; +typedef HANDLE apr_os_dir_t; +typedef SOCKET apr_os_sock_t; +typedef HANDLE apr_os_proc_mutex_t; +typedef HANDLE apr_os_thread_t; +typedef HANDLE apr_os_proc_t; +typedef DWORD apr_os_threadkey_t; +typedef FILETIME apr_os_imp_time_t; +typedef SYSTEMTIME apr_os_exp_time_t; +typedef HANDLE apr_os_dso_handle_t; +typedef HANDLE apr_os_shm_t; + +#elif defined(OS2) +typedef HFILE apr_os_file_t; +typedef HDIR apr_os_dir_t; +typedef int apr_os_sock_t; +typedef HMTX apr_os_proc_mutex_t; +typedef TID apr_os_thread_t; +typedef PID apr_os_proc_t; +typedef PULONG apr_os_threadkey_t; +typedef struct timeval apr_os_imp_time_t; +typedef struct tm apr_os_exp_time_t; +typedef HMODULE apr_os_dso_handle_t; +typedef void* apr_os_shm_t; + +#elif defined(__BEOS__) +#include +#include + +struct apr_os_proc_mutex_t { + sem_id sem; + int32 ben; +}; + +typedef int apr_os_file_t; +typedef DIR apr_os_dir_t; +typedef int apr_os_sock_t; +typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t; +typedef thread_id apr_os_thread_t; +typedef thread_id apr_os_proc_t; +typedef int apr_os_threadkey_t; +typedef struct timeval apr_os_imp_time_t; +typedef struct tm apr_os_exp_time_t; +typedef image_id apr_os_dso_handle_t; +typedef void* apr_os_shm_t; + +#elif defined(NETWARE) +typedef int apr_os_file_t; +typedef DIR apr_os_dir_t; +typedef int apr_os_sock_t; +typedef NXMutex_t apr_os_proc_mutex_t; +typedef NXThreadId_t apr_os_thread_t; +typedef long apr_os_proc_t; +typedef NXKey_t apr_os_threadkey_t; +typedef struct timeval apr_os_imp_time_t; +typedef struct tm apr_os_exp_time_t; +typedef void * apr_os_dso_handle_t; +typedef void* apr_os_shm_t; + +#else +/* Any other OS should go above this one. This is the lowest common + * denominator typedefs for all UNIX-like systems. :) + */ + +/** Basic OS process mutex structure. */ +struct apr_os_proc_mutex_t { +#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE + int crossproc; +#endif +#if APR_HAS_PROC_PTHREAD_SERIALIZE + pthread_mutex_t *pthread_interproc; +#endif +#if APR_HAS_THREADS + /* If no threads, no need for thread locks */ +#if APR_USE_PTHREAD_SERIALIZE + pthread_mutex_t *intraproc; +#endif +#endif +}; + +typedef int apr_os_file_t; /**< native file */ +typedef DIR apr_os_dir_t; /**< native dir */ +typedef int apr_os_sock_t; /**< native dir */ +typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t; /**< native proces + * mutex + */ +#if APR_HAS_THREADS && APR_HAVE_PTHREAD_H +typedef pthread_t apr_os_thread_t; /**< native thread */ +typedef pthread_key_t apr_os_threadkey_t; /**< native thread address + * space */ +#endif +typedef pid_t apr_os_proc_t; /**< native pid */ +typedef struct timeval apr_os_imp_time_t; /**< native timeval */ +typedef struct tm apr_os_exp_time_t; /**< native tm */ +/** @var apr_os_dso_handle_t + * native dso types + */ +#if defined(HPUX) || defined(HPUX10) || defined(HPUX11) +#include +typedef shl_t apr_os_dso_handle_t; +#elif defined(DARWIN) +#include +typedef NSModule apr_os_dso_handle_t; +#else +typedef void * apr_os_dso_handle_t; +#endif +typedef void* apr_os_shm_t; /**< native SHM */ + +#endif + +/** + * @typedef apr_os_sock_info_t + * @brief alias for local OS socket + */ +/** + * everything APR needs to know about an active socket to construct + * an APR socket from it; currently, this is platform-independent + */ +struct apr_os_sock_info_t { + apr_os_sock_t *os_sock; /**< always required */ + struct sockaddr *local; /**< NULL if not yet bound */ + struct sockaddr *remote; /**< NULL if not connected */ + int family; /**< always required (APR_INET, APR_INET6, etc.) */ + int type; /**< always required (SOCK_STREAM, SOCK_DGRAM, etc.) */ +#ifdef APR_ENABLE_FOR_1_0 /**< enable with APR 1.0 */ + int protocol; /**< 0 or actual protocol (APR_PROTO_SCTP, APR_PROTO_TCP, etc.) */ +#endif +}; + +typedef struct apr_os_sock_info_t apr_os_sock_info_t; + +#if APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN) +/** Opaque global mutex type */ +#define apr_os_global_mutex_t apr_os_proc_mutex_t +/** @return apr_os_global_mutex */ +#define apr_os_global_mutex_get apr_os_proc_mutex_get +#else + /** Thread and process mutex for those platforms where process mutexes + * are not held in threads. + */ + struct apr_os_global_mutex_t { + apr_pool_t *pool; + apr_proc_mutex_t *proc_mutex; +#if APR_HAS_THREADS + apr_thread_mutex_t *thread_mutex; +#endif /* APR_HAS_THREADS */ + }; + typedef struct apr_os_global_mutex_t apr_os_global_mutex_t; + +APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex, + apr_global_mutex_t *pmutex); +#endif + + +/** + * convert the file from apr type to os specific type. + * @param thefile The os specific file we are converting to + * @param file The apr file to convert. + * @remark On Unix, it is only possible to get a file descriptor from + * an apr file type. + */ +APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile, + apr_file_t *file); + +/** + * convert the dir from apr type to os specific type. + * @param thedir The os specific dir we are converting to + * @param dir The apr dir to convert. + */ +APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, + apr_dir_t *dir); + +/** + * Convert the socket from an apr type to an OS specific socket + * @param thesock The socket to convert. + * @param sock The os specifc equivelant of the apr socket.. + */ +APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, + apr_socket_t *sock); + +/** + * Convert the proc mutex from os specific type to apr type + * @param ospmutex The os specific proc mutex we are converting to. + * @param pmutex The apr proc mutex to convert. + */ +APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, + apr_proc_mutex_t *pmutex); + +/** + * Get the exploded time in the platforms native format. + * @param ostime the native time format + * @param aprtime the time to convert + */ +APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime, + apr_time_exp_t *aprtime); + +/** + * Get the imploded time in the platforms native format. + * @param ostime the native time format + * @param aprtime the time to convert + */ +APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, + apr_time_t *aprtime); + +/** + * convert the shm from apr type to os specific type. + * @param osshm The os specific shm representation + * @param shm The apr shm to convert. + */ +APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm, + apr_shm_t *shm); + +#if APR_HAS_THREADS || defined(DOXYGEN) +/** + * @defgroup apr_os_thread Thread portability Routines + * @{ + */ +/** + * convert the thread to os specific type from apr type. + * @param thethd The apr thread to convert + * @param thd The os specific thread we are converting to + */ +APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, + apr_thread_t *thd); + +/** + * convert the thread private memory key to os specific type from an apr type. + * @param thekey The apr handle we are converting from. + * @param key The os specific handle we are converting to. + */ +APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey, + apr_threadkey_t *key); + +/** + * convert the thread from os specific type to apr type. + * @param thd The apr thread we are converting to. + * @param thethd The os specific thread to convert + * @param cont The pool to use if it is needed. + */ +APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd, + apr_os_thread_t *thethd, + apr_pool_t *cont); + +/** + * convert the thread private memory key from os specific type to apr type. + * @param key The apr handle we are converting to. + * @param thekey The os specific handle to convert + * @param cont The pool to use if it is needed. + */ +APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key, + apr_os_threadkey_t *thekey, + apr_pool_t *cont); +/** + * Get the thread ID + */ +APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void); + +/** + * Compare two thread id's + * @param tid1 1st Thread ID to compare + * @param tid2 2nd Thread ID to compare + */ +APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, + apr_os_thread_t tid2); + +/** @} */ +#endif /* APR_HAS_THREADS */ + +/** + * convert the file from os specific type to apr type. + * @param file The apr file we are converting to. + * @param thefile The os specific file to convert + * @param flags The flags that were used to open this file. + * @param cont The pool to use if it is needed. + * @remark On Unix, it is only possible to put a file descriptor into + * an apr file type. + */ +APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file, + apr_os_file_t *thefile, + apr_int32_t flags, apr_pool_t *cont); + +/** + * convert the file from os specific type to apr type. + * @param file The apr file we are converting to. + * @param thefile The os specific pipe to convert + * @param cont The pool to use if it is needed. + * @remark On Unix, it is only possible to put a file descriptor into + * an apr file type. + */ +APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file, + apr_os_file_t *thefile, + apr_pool_t *cont); + +/** + * convert the file from os specific type to apr type. + * @param file The apr file we are converting to. + * @param thefile The os specific pipe to convert + * @param register_cleanup A cleanup will be registered on the apr_file_t + * to issue apr_file_close(). + * @param cont The pool to use if it is needed. + * @remark On Unix, it is only possible to put a file descriptor into + * an apr file type. + */ +APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file, + apr_os_file_t *thefile, + int register_cleanup, + apr_pool_t *cont); + +/** + * convert the dir from os specific type to apr type. + * @param dir The apr dir we are converting to. + * @param thedir The os specific dir to convert + * @param cont The pool to use when creating to apr directory. + */ +APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir, + apr_os_dir_t *thedir, + apr_pool_t *cont); + +/** + * Convert a socket from the os specific type to the apr type + * @param sock The pool to use. + * @param thesock The socket to convert to. + * @param cont The socket we are converting to an apr type. + * @remark If it is a true socket, it is best to call apr_os_sock_make() + * and provide APR with more information about the socket. + */ +APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, + apr_os_sock_t *thesock, + apr_pool_t *cont); + +/** + * Create a socket from an existing descriptor and local and remote + * socket addresses. + * @param apr_sock The new socket that has been set up + * @param os_sock_info The os representation of the socket handle and + * other characteristics of the socket + * @param cont The pool to use + * @remark If you only know the descriptor/handle or if it isn't really + * a true socket, use apr_os_sock_put() instead. + */ +APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock, + apr_os_sock_info_t *os_sock_info, + apr_pool_t *cont); + +/** + * Convert the proc mutex from os specific type to apr type + * @param pmutex The apr proc mutex we are converting to. + * @param ospmutex The os specific proc mutex to convert. + * @param cont The pool to use if it is needed. + */ +APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex, + apr_os_proc_mutex_t *ospmutex, + apr_pool_t *cont); + +/** + * Put the imploded time in the APR format. + * @param aprtime the APR time format + * @param ostime the time to convert + * @param cont the pool to use if necessary + */ +APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime, + apr_os_imp_time_t **ostime, + apr_pool_t *cont); + +/** + * Put the exploded time in the APR format. + * @param aprtime the APR time format + * @param ostime the time to convert + * @param cont the pool to use if necessary + */ +APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime, + apr_os_exp_time_t **ostime, + apr_pool_t *cont); + +/** + * convert the shared memory from os specific type to apr type. + * @param shm The apr shm representation of osshm + * @param osshm The os specific shm identity + * @param cont The pool to use if it is needed. + * @remark On fork()ed architectures, this is typically nothing more than + * the memory block mapped. On non-fork architectures, this is typically + * some internal handle to pass the mapping from process to process. + */ +APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **shm, + apr_os_shm_t *osshm, + apr_pool_t *cont); + + +#if APR_HAS_DSO || defined(DOXYGEN) +/** + * @defgroup apr_os_dso DSO (Dynamic Loading) Portabiliity Routines + * @{ + */ +/** + * convert the dso handle from os specific to apr + * @param dso The apr handle we are converting to + * @param thedso the os specific handle to convert + * @param pool the pool to use if it is needed + */ +APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **dso, + apr_os_dso_handle_t thedso, + apr_pool_t *pool); + +/** + * convert the apr dso handle into an os specific one + * @param aprdso The apr dso handle to convert + * @param dso The os specific dso to return + */ +APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *dso, + apr_dso_handle_t *aprdso); + +#if APR_HAS_OS_UUID +/** + * Private: apr-util's apr_uuid module when supported by the platform + */ +APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data); +#endif + +/** @} */ +#endif /* APR_HAS_DSO */ + + +/** + * Get the name of the system default characer set. + * @param pool the pool to allocate the name from, if needed + */ +APR_DECLARE(const char*) apr_os_default_encoding(apr_pool_t *pool); + + +/** + * Get the name of the current locale character set. + * @param pool the pool to allocate the name from, if needed + * @remark Defers to apr_os_default_encoding if the current locale's + * data can't be retreved on this system. + */ +APR_DECLARE(const char*) apr_os_locale_encoding(apr_pool_t *pool); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_PORTABLE_H */ diff --git a/rubbos/app/apache2/include/apr_proc_mutex.h b/rubbos/app/apache2/include/apr_proc_mutex.h new file mode 100644 index 00000000..ceb9c82a --- /dev/null +++ b/rubbos/app/apache2/include/apr_proc_mutex.h @@ -0,0 +1,166 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_PROC_MUTEX_H +#define APR_PROC_MUTEX_H + +/** + * @file apr_proc_mutex.h + * @brief APR Process Locking Routines + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_proc_mutex Process Locking Routines + * @ingroup APR + * @{ + */ + +/** + * Enumerated potential types for APR process locking methods + * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports + * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. + */ +typedef enum { + APR_LOCK_FCNTL, /**< fcntl() */ + APR_LOCK_FLOCK, /**< flock() */ + APR_LOCK_SYSVSEM, /**< System V Semaphores */ + APR_LOCK_PROC_PTHREAD, /**< POSIX pthread process-based locking */ + APR_LOCK_POSIXSEM, /**< POSIX semaphore process-based locking */ + APR_LOCK_DEFAULT /**< Use the default process lock */ +} apr_lockmech_e; + +/** Opaque structure representing a process mutex. */ +typedef struct apr_proc_mutex_t apr_proc_mutex_t; + +/* Function definitions */ + +/** + * Create and initialize a mutex that can be used to synchronize processes. + * @param mutex the memory address where the newly created mutex will be + * stored. + * @param fname A file name to use if the lock mechanism requires one. This + * argument should always be provided. The lock code itself will + * determine if it should be used. + * @param mech The mechanism to use for the interprocess lock, if any; one of + *
+ *            APR_LOCK_FCNTL
+ *            APR_LOCK_FLOCK
+ *            APR_LOCK_SYSVSEM
+ *            APR_LOCK_POSIXSEM
+ *            APR_LOCK_PROC_PTHREAD
+ *            APR_LOCK_DEFAULT     pick the default mechanism for the platform
+ * 
+ * @param pool the pool from which to allocate the mutex. + * @see apr_lockmech_e + * @warning Check APR_HAS_foo_SERIALIZE defines to see if the platform supports + * APR_LOCK_foo. Only APR_LOCK_DEFAULT is portable. + */ +APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex, + const char *fname, + apr_lockmech_e mech, + apr_pool_t *pool); + +/** + * Re-open a mutex in a child process. + * @param mutex The newly re-opened mutex structure. + * @param fname A file name to use if the mutex mechanism requires one. This + * argument should always be provided. The mutex code itself will + * determine if it should be used. This filename should be the + * same one that was passed to apr_proc_mutex_create(). + * @param pool The pool to operate on. + * @remark This function must be called to maintain portability, even + * if the underlying lock mechanism does not require it. + */ +APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex, + const char *fname, + apr_pool_t *pool); + +/** + * Acquire the lock for the given mutex. If the mutex is already locked, + * the current thread will be put to sleep until the lock becomes available. + * @param mutex the mutex on which to acquire the lock. + */ +APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex); + +/** + * Attempt to acquire the lock for the given mutex. If the mutex has already + * been acquired, the call returns immediately with APR_EBUSY. Note: it + * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine + * if the return value was APR_EBUSY, for portability reasons. + * @param mutex the mutex on which to attempt the lock acquiring. + */ +APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex); + +/** + * Release the lock for the given mutex. + * @param mutex the mutex from which to release the lock. + */ +APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex); + +/** + * Destroy the mutex and free the memory associated with the lock. + * @param mutex the mutex to destroy. + */ +APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex); + +/** + * Destroy the mutex and free the memory associated with the lock. + * @param mutex the mutex to destroy. + * @note This function is generally used to kill a cleanup on an already + * created mutex + */ +APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex); + +/** + * Return the name of the lockfile for the mutex, or NULL + * if the mutex doesn't use a lock file + */ + +APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex); + +/** + * Display the name of the mutex, as it relates to the actual method used. + * This matches the valid options for Apache's AcceptMutex directive + * @param mutex the name of the mutex + */ +APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex); + +/** + * Display the name of the default mutex: APR_LOCK_DEFAULT + */ +APR_DECLARE(const char *) apr_proc_mutex_defname(void); + +/** + * Get the pool used by this proc_mutex. + * @return apr_pool_t the pool + */ +APR_POOL_DECLARE_ACCESSOR(proc_mutex); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_PROC_MUTEX_H */ diff --git a/rubbos/app/apache2/include/apr_queue.h b/rubbos/app/apache2/include/apr_queue.h new file mode 100644 index 00000000..5a0181b2 --- /dev/null +++ b/rubbos/app/apache2/include/apr_queue.h @@ -0,0 +1,138 @@ +/* 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. + */ + +#ifndef APR_QUEUE_H +#define APR_QUEUE_H + +/** + * @file apr_queue.h + * @brief Thread Safe FIFO bounded queue + * @note Since most implementations of the queue are backed by a condition + * variable implementation, it isn't available on systems without threads. + * Although condition variables are some times available without threads. + */ + +#include "apu.h" +#include "apr_errno.h" +#include "apr_pools.h" + +#if APR_HAS_THREADS + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup APR_Util_FIFO Thread Safe FIFO bounded queue + * @ingroup APR_Util + * @{ + */ + +/** + * opaque structure + */ +typedef struct apr_queue_t apr_queue_t; + +/** + * create a FIFO queue + * @param queue The new queue + * @param queue_capacity maximum size of the queue + * @param a pool to allocate queue from + */ +APU_DECLARE(apr_status_t) apr_queue_create(apr_queue_t **queue, + unsigned int queue_capacity, + apr_pool_t *a); + +/** + * push/add a object to the queue, blocking if the queue is already full + * + * @param queue the queue + * @param data the data + * @returns APR_EINTR the blocking was interrupted (try again) + * @returns APR_EOF the queue has been terminated + * @returns APR_SUCCESS on a successfull push + */ +APU_DECLARE(apr_status_t) apr_queue_push(apr_queue_t *queue, void *data); + +/** + * pop/get an object from the queue, blocking if the queue is already empty + * + * @param queue the queue + * @param data the data + * @returns APR_EINTR the blocking was interrupted (try again) + * @returns APR_EOF if the queue has been terminated + * @returns APR_SUCCESS on a successfull pop + */ +APU_DECLARE(apr_status_t) apr_queue_pop(apr_queue_t *queue, void **data); + +/** + * push/add a object to the queue, returning immediatly if the queue is full + * + * @param queue the queue + * @param data the data + * @returns APR_EINTR the blocking operation was interrupted (try again) + * @returns APR_EAGAIN the queue is full + * @returns APR_EOF the queue has been terminated + * @returns APR_SUCCESS on a successfull push + */ +APU_DECLARE(apr_status_t) apr_queue_trypush(apr_queue_t *queue, void *data); + +/** + * pop/get an object to the queue, returning immediatly if the queue is empty + * + * @param queue the queue + * @param data the data + * @returns APR_EINTR the blocking operation was interrupted (try again) + * @returns APR_EAGAIN the queue is empty + * @returns APR_EOF the queue has been terminated + * @returns APR_SUCCESS on a successfull push + */ +APU_DECLARE(apr_status_t) apr_queue_trypop(apr_queue_t *queue, void **data); + +/** + * returns the size of the queue. + * + * @warning this is not threadsafe, and is intended for reporting/monitoring + * of the queue. + * @param queue the queue + * @returns the size of the queue + */ +APU_DECLARE(unsigned int) apr_queue_size(apr_queue_t *queue); + +/** + * interrupt all the threads blocking on this queue. + * + * @param queue the queue + */ +APU_DECLARE(apr_status_t) apr_queue_interrupt_all(apr_queue_t *queue); + +/** + * terminate all queue, sendinging a interupt to all the + * blocking threads + * + * @param queue the queue + */ +APU_DECLARE(apr_status_t) apr_queue_term(apr_queue_t *queue); + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif /* APR_HAS_THREADS */ + +#endif /* APRQUEUE_H */ diff --git a/rubbos/app/apache2/include/apr_reslist.h b/rubbos/app/apache2/include/apr_reslist.h new file mode 100644 index 00000000..1a18391d --- /dev/null +++ b/rubbos/app/apache2/include/apr_reslist.h @@ -0,0 +1,141 @@ +/* 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. + */ + +#ifndef APR_RESLIST_H +#define APR_RESLIST_H + +/** + * @file apr_reslist.h + * @brief APR-UTIL Resource List Routines + */ + +#include "apr.h" +#include "apu.h" +#include "apr_pools.h" +#include "apr_errno.h" +#include "apr_time.h" + +#if APR_HAS_THREADS + +/** + * @defgroup APR_Util_RL Resource List Routines + * @ingroup APR_Util + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Opaque resource list object */ +typedef struct apr_reslist_t apr_reslist_t; + +/* Generic constructor called by resource list when it needs to create a + * resource. + * @param resource opaque resource + * @param param flags + * @param pool Pool + */ +typedef apr_status_t (*apr_reslist_constructor)(void **resource, void *params, + apr_pool_t *pool); + +/* Generic destructor called by resource list when it needs to destroy a + * resource. + * @param resource opaque resource + * @param param flags + * @param pool Pool + */ +typedef apr_status_t (*apr_reslist_destructor)(void *resource, void *params, + apr_pool_t *pool); + +/** + * Create a new resource list with the following parameters: + * @param reslist An address where the pointer to the new resource + * list will be stored. + * @param pool The pool to use for local storage and management + * @param min Allowed minimum number of available resources. Zero + * creates new resources only when needed. + * @param smax Resources will be destroyed to meet this maximum + * restriction as they expire. + * @param hmax Absolute maximum limit on the number of total resources. + * @param ttl If non-zero, sets the maximum amount of time a resource + * may be available while exceeding the soft limit. + * @param con Constructor routine that is called to create a new resource. + * @param de Destructor routine that is called to destroy an expired resource. + * @param params Passed to constructor and deconstructor + * @param pool The pool from which to create this resoure list. Also the + * same pool that is passed to the constructor and destructor + * routines. + */ +APU_DECLARE(apr_status_t) apr_reslist_create(apr_reslist_t **reslist, + int min, int smax, int hmax, + apr_interval_time_t ttl, + apr_reslist_constructor con, + apr_reslist_destructor de, + void *params, + apr_pool_t *pool); + +/** + * Destroy the given resource list and all resources controlled by + * this list. + * FIXME: Should this block until all resources become available, + * or maybe just destroy all the free ones, or maybe destroy + * them even though they might be in use by something else? + * @param reslist The reslist to destroy + */ +APU_DECLARE(apr_status_t) apr_reslist_destroy(apr_reslist_t *reslist); + +/** + * Retrieve a resource from the list, creating a new one if necessary. + * If we have met our maximum number of resources, we will block + * until one becomes available. + */ +APU_DECLARE(apr_status_t) apr_reslist_acquire(apr_reslist_t *reslist, + void **resource); + +/** + * Return a resource back to the list of available resources. + */ +APU_DECLARE(apr_status_t) apr_reslist_release(apr_reslist_t *reslist, + void *resource); + +/** + * Set the timeout the acquire will wait for a free resource + * when the maximum number of resources is exceeded. + * @param reslist The resource list. + * @param timeout Timeout to wait. The zero waits forewer. + */ +APU_DECLARE(void) apr_reslist_timeout_set(apr_reslist_t *reslist, + apr_interval_time_t timeout); + +/** + * Invalidate a resource in the pool - e.g. a database connection + * that returns a "lost connection" error and can't be restored. + * Use this instead of apr_reslist_release if the resource is bad. + */ +APU_DECLARE(apr_status_t) apr_reslist_invalidate(apr_reslist_t *reslist, + void *resource); + + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif /* APR_HAS_THREADS */ + +#endif /* ! APR_RESLIST_H */ diff --git a/rubbos/app/apache2/include/apr_ring.h b/rubbos/app/apache2/include/apr_ring.h new file mode 100644 index 00000000..79efb436 --- /dev/null +++ b/rubbos/app/apache2/include/apr_ring.h @@ -0,0 +1,551 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This code draws heavily from the 4.4BSD macros + * and Dean Gaudet's "splim/ring.h". + * + * + * + * We'd use Dean's code directly if we could guarantee the + * availability of inline functions. + */ + +#ifndef APR_RING_H +#define APR_RING_H + +/** + * @file apr_ring.h + * @brief APR Rings + */ + +/* + * for offsetof() + */ +#include "apr_general.h" + +/** + * @defgroup apr_ring Ring Macro Implementations + * @ingroup APR + * A ring is a kind of doubly-linked list that can be manipulated + * without knowing where its head is. + * @{ + */ + +/** + * The Ring Element + * + * A ring element struct is linked to the other elements in the ring + * through its ring entry field, e.g. + *
+ *      struct my_element_t {
+ *          APR_RING_ENTRY(my_element_t) link;
+ *          int foo;
+ *          char *bar;
+ *      };
+ * 
+ * + * An element struct may be put on more than one ring if it has more + * than one APR_RING_ENTRY field. Each APR_RING_ENTRY has a corresponding + * APR_RING_HEAD declaration. + * + * @warning For strict C standards compliance you should put the APR_RING_ENTRY + * first in the element struct unless the head is always part of a larger + * object with enough earlier fields to accommodate the offsetof() used + * to compute the ring sentinel below. You can usually ignore this caveat. + */ +#define APR_RING_ENTRY(elem) \ + struct { \ + struct elem *next; \ + struct elem *prev; \ + } + +/** + * The Ring Head + * + * Each ring is managed via its head, which is a struct declared like this: + *
+ *      APR_RING_HEAD(my_ring_t, my_element_t);
+ *      struct my_ring_t ring, *ringp;
+ * 
+ * + * This struct looks just like the element link struct so that we can + * be sure that the typecasting games will work as expected. + * + * The first element in the ring is next after the head, and the last + * element is just before the head. + */ +#define APR_RING_HEAD(head, elem) \ + struct head { \ + struct elem * volatile next; \ + struct elem * volatile prev; \ + } + +/** + * The Ring Sentinel + * + * This is the magic pointer value that occurs before the first and + * after the last elements in the ring, computed from the address of + * the ring's head. The head itself isn't an element, but in order to + * get rid of all the special cases when dealing with the ends of the + * ring, we play typecasting games to make it look like one. + * + * Here is a diagram to illustrate the arrangements of the next and + * prev pointers of each element in a single ring. Note that they point + * to the start of each element, not to the APR_RING_ENTRY structure. + * + *
+ *     +->+------+<-+  +->+------+<-+  +->+------+<-+
+ *     |  |struct|  |  |  |struct|  |  |  |struct|  |
+ *    /   | elem |   \/   | elem |   \/   | elem |  \
+ * ...    |      |   /\   |      |   /\   |      |   ...
+ *        +------+  |  |  +------+  |  |  +------+
+ *   ...--|prev  |  |  +--|ring  |  |  +--|prev  |
+ *        |  next|--+     | entry|--+     |  next|--...
+ *        +------+        +------+        +------+
+ *        | etc. |        | etc. |        | etc. |
+ *        :      :        :      :        :      :
+ * 
+ * + * The APR_RING_HEAD is nothing but a bare APR_RING_ENTRY. The prev + * and next pointers in the first and last elements don't actually + * point to the head, they point to a phantom place called the + * sentinel. Its value is such that last->next->next == first because + * the offset from the sentinel to the head's next pointer is the same + * as the offset from the start of an element to its next pointer. + * This also works in the opposite direction. + * + *
+ *        last                            first
+ *     +->+------+<-+  +->sentinel<-+  +->+------+<-+
+ *     |  |struct|  |  |            |  |  |struct|  |
+ *    /   | elem |   \/              \/   | elem |  \
+ * ...    |      |   /\              /\   |      |   ...
+ *        +------+  |  |  +------+  |  |  +------+
+ *   ...--|prev  |  |  +--|ring  |  |  +--|prev  |
+ *        |  next|--+     |  head|--+     |  next|--...
+ *        +------+        +------+        +------+
+ *        | etc. |                        | etc. |
+ *        :      :                        :      :
+ * 
+ * + * Note that the offset mentioned above is different for each kind of + * ring that the element may be on, and each kind of ring has a unique + * name for its APR_RING_ENTRY in each element, and has its own type + * for its APR_RING_HEAD. + * + * Note also that if the offset is non-zero (which is required if an + * element has more than one APR_RING_ENTRY), the unreality of the + * sentinel may have bad implications on very perverse implementations + * of C -- see the warning in APR_RING_ENTRY. + * + * @param hp The head of the ring + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_SENTINEL(hp, elem, link) \ + (struct elem *)((char *)(hp) - APR_OFFSETOF(struct elem, link)) + +/** + * The first element of the ring + * @param hp The head of the ring + */ +#define APR_RING_FIRST(hp) (hp)->next +/** + * The last element of the ring + * @param hp The head of the ring + */ +#define APR_RING_LAST(hp) (hp)->prev +/** + * The next element in the ring + * @param ep The current element + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_NEXT(ep, link) (ep)->link.next +/** + * The previous element in the ring + * @param ep The current element + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_PREV(ep, link) (ep)->link.prev + + +/** + * Initialize a ring + * @param hp The head of the ring + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_INIT(hp, elem, link) do { \ + APR_RING_FIRST((hp)) = APR_RING_SENTINEL((hp), elem, link); \ + APR_RING_LAST((hp)) = APR_RING_SENTINEL((hp), elem, link); \ + } while (0) + +/** + * Determine if a ring is empty + * @param hp The head of the ring + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + * @return true or false + */ +#define APR_RING_EMPTY(hp, elem, link) \ + (APR_RING_FIRST((hp)) == APR_RING_SENTINEL((hp), elem, link)) + +/** + * Initialize a singleton element + * @param ep The element + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_ELEM_INIT(ep, link) do { \ + APR_RING_NEXT((ep), link) = (ep); \ + APR_RING_PREV((ep), link) = (ep); \ + } while (0) + + +/** + * Splice the sequence ep1..epN into the ring before element lep + * (..lep.. becomes ..ep1..epN..lep..) + * @warning This doesn't work for splicing before the first element or on + * empty rings... see APR_RING_SPLICE_HEAD for one that does + * @param lep Element in the ring to splice before + * @param ep1 First element in the sequence to splice in + * @param epN Last element in the sequence to splice in + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_SPLICE_BEFORE(lep, ep1, epN, link) do { \ + APR_RING_NEXT((epN), link) = (lep); \ + APR_RING_PREV((ep1), link) = APR_RING_PREV((lep), link); \ + APR_RING_NEXT(APR_RING_PREV((lep), link), link) = (ep1); \ + APR_RING_PREV((lep), link) = (epN); \ + } while (0) + +/** + * Splice the sequence ep1..epN into the ring after element lep + * (..lep.. becomes ..lep..ep1..epN..) + * @warning This doesn't work for splicing after the last element or on + * empty rings... see APR_RING_SPLICE_TAIL for one that does + * @param lep Element in the ring to splice after + * @param ep1 First element in the sequence to splice in + * @param epN Last element in the sequence to splice in + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_SPLICE_AFTER(lep, ep1, epN, link) do { \ + APR_RING_PREV((ep1), link) = (lep); \ + APR_RING_NEXT((epN), link) = APR_RING_NEXT((lep), link); \ + APR_RING_PREV(APR_RING_NEXT((lep), link), link) = (epN); \ + APR_RING_NEXT((lep), link) = (ep1); \ + } while (0) + +/** + * Insert the element nep into the ring before element lep + * (..lep.. becomes ..nep..lep..) + * @warning This doesn't work for inserting before the first element or on + * empty rings... see APR_RING_INSERT_HEAD for one that does + * @param lep Element in the ring to insert before + * @param nep Element to insert + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_INSERT_BEFORE(lep, nep, link) \ + APR_RING_SPLICE_BEFORE((lep), (nep), (nep), link) + +/** + * Insert the element nep into the ring after element lep + * (..lep.. becomes ..lep..nep..) + * @warning This doesn't work for inserting after the last element or on + * empty rings... see APR_RING_INSERT_TAIL for one that does + * @param lep Element in the ring to insert after + * @param nep Element to insert + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_INSERT_AFTER(lep, nep, link) \ + APR_RING_SPLICE_AFTER((lep), (nep), (nep), link) + + +/** + * Splice the sequence ep1..epN into the ring before the first element + * (..hp.. becomes ..hp..ep1..epN..) + * @param hp Head of the ring + * @param ep1 First element in the sequence to splice in + * @param epN Last element in the sequence to splice in + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_SPLICE_HEAD(hp, ep1, epN, elem, link) \ + APR_RING_SPLICE_AFTER(APR_RING_SENTINEL((hp), elem, link), \ + (ep1), (epN), link) + +/** + * Splice the sequence ep1..epN into the ring after the last element + * (..hp.. becomes ..ep1..epN..hp..) + * @param hp Head of the ring + * @param ep1 First element in the sequence to splice in + * @param epN Last element in the sequence to splice in + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_SPLICE_TAIL(hp, ep1, epN, elem, link) \ + APR_RING_SPLICE_BEFORE(APR_RING_SENTINEL((hp), elem, link), \ + (ep1), (epN), link) + +/** + * Insert the element nep into the ring before the first element + * (..hp.. becomes ..hp..nep..) + * @param hp Head of the ring + * @param nep Element to insert + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_INSERT_HEAD(hp, nep, elem, link) \ + APR_RING_SPLICE_HEAD((hp), (nep), (nep), elem, link) + +/** + * Insert the element nep into the ring after the last element + * (..hp.. becomes ..nep..hp..) + * @param hp Head of the ring + * @param nep Element to insert + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_INSERT_TAIL(hp, nep, elem, link) \ + APR_RING_SPLICE_TAIL((hp), (nep), (nep), elem, link) + +/** + * Concatenate ring h2 onto the end of ring h1, leaving h2 empty. + * @param h1 Head of the ring to concatenate onto + * @param h2 Head of the ring to concatenate + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_CONCAT(h1, h2, elem, link) do { \ + if (!APR_RING_EMPTY((h2), elem, link)) { \ + APR_RING_SPLICE_BEFORE(APR_RING_SENTINEL((h1), elem, link), \ + APR_RING_FIRST((h2)), \ + APR_RING_LAST((h2)), link); \ + APR_RING_INIT((h2), elem, link); \ + } \ + } while (0) + +/** + * Prepend ring h2 onto the beginning of ring h1, leaving h2 empty. + * @param h1 Head of the ring to prepend onto + * @param h2 Head of the ring to prepend + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_PREPEND(h1, h2, elem, link) do { \ + if (!APR_RING_EMPTY((h2), elem, link)) { \ + APR_RING_SPLICE_AFTER(APR_RING_SENTINEL((h1), elem, link), \ + APR_RING_FIRST((h2)), \ + APR_RING_LAST((h2)), link); \ + APR_RING_INIT((h2), elem, link); \ + } \ + } while (0) + +/** + * Unsplice a sequence of elements from a ring + * @warning The unspliced sequence is left with dangling pointers at either end + * @param ep1 First element in the sequence to unsplice + * @param epN Last element in the sequence to unsplice + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_UNSPLICE(ep1, epN, link) do { \ + APR_RING_NEXT(APR_RING_PREV((ep1), link), link) = \ + APR_RING_NEXT((epN), link); \ + APR_RING_PREV(APR_RING_NEXT((epN), link), link) = \ + APR_RING_PREV((ep1), link); \ + } while (0) + +/** + * Remove a single element from a ring + * @warning The unspliced element is left with dangling pointers at either end + * @param ep Element to remove + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_REMOVE(ep, link) \ + APR_RING_UNSPLICE((ep), (ep), link) + + +/** + * Iterate through a ring + * @param ep The current element + * @param hp The ring to iterate over + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + * @remark This is the same as either: + *
+ *	ep = APR_RING_FIRST(hp);
+ * 	while (ep != APR_RING_SENTINEL(hp, elem, link)) {
+ *	    ...
+ * 	    ep = APR_RING_NEXT(ep, link);
+ * 	}
+ *   OR
+ * 	for (ep = APR_RING_FIRST(hp);
+ *           ep != APR_RING_SENTINEL(hp, elem, link);
+ *           ep = APR_RING_NEXT(ep, link)) {
+ *	    ...
+ * 	}
+ * 
+ * @warning Be aware that you cannot change the value of ep within + * the foreach loop, nor can you destroy the ring element it points to. + * Modifying the prev and next pointers of the element is dangerous + * but can be done if you're careful. If you change ep's value or + * destroy the element it points to, then APR_RING_FOREACH + * will have no way to find out what element 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 ring one element + * at a time, APR_RING_FOREACH just won't work for you. Do it + * by hand, like so: + *
+ *      while (!APR_RING_EMPTY(hp, elem, link)) {
+ *          ep = APR_RING_FIRST(hp);
+ *          ...
+ *          APR_RING_REMOVE(ep, link);
+ *      }
+ * 
+ * @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_RING_FOREACH(ep, hp, elem, link) \ + for ((ep) = APR_RING_FIRST((hp)); \ + (ep) != APR_RING_SENTINEL((hp), elem, link); \ + (ep) = APR_RING_NEXT((ep), link)) + +/** + * Iterate through a ring backwards + * @param ep The current element + * @param hp The ring to iterate over + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + * @see APR_RING_FOREACH + */ +#define APR_RING_FOREACH_REVERSE(ep, hp, elem, link) \ + for ((ep) = APR_RING_LAST((hp)); \ + (ep) != APR_RING_SENTINEL((hp), elem, link); \ + (ep) = APR_RING_PREV((ep), link)) + + +/* Debugging tools: */ + +#ifdef APR_RING_DEBUG +#include +#include + +#define APR_RING_CHECK_ONE(msg, ptr) \ + fprintf(stderr, "*** %s %p\n", msg, ptr) + +#define APR_RING_CHECK(hp, elem, link, msg) \ + APR_RING_CHECK_ELEM(APR_RING_SENTINEL(hp, elem, link), elem, link, msg) + +#define APR_RING_CHECK_ELEM(ep, elem, link, msg) do { \ + struct elem *start = (ep); \ + struct elem *here = start; \ + fprintf(stderr, "*** ring check start -- %s\n", msg); \ + do { \ + fprintf(stderr, "\telem %p\n", here); \ + fprintf(stderr, "\telem->next %p\n", \ + APR_RING_NEXT(here, link)); \ + fprintf(stderr, "\telem->prev %p\n", \ + APR_RING_PREV(here, link)); \ + fprintf(stderr, "\telem->next->prev %p\n", \ + APR_RING_PREV(APR_RING_NEXT(here, link), link)); \ + fprintf(stderr, "\telem->prev->next %p\n", \ + APR_RING_NEXT(APR_RING_PREV(here, link), link)); \ + if (APR_RING_PREV(APR_RING_NEXT(here, link), link) != here) { \ + fprintf(stderr, "\t*** elem->next->prev != elem\n"); \ + break; \ + } \ + if (APR_RING_NEXT(APR_RING_PREV(here, link), link) != here) { \ + fprintf(stderr, "\t*** elem->prev->next != elem\n"); \ + break; \ + } \ + here = APR_RING_NEXT(here, link); \ + } while (here != start); \ + fprintf(stderr, "*** ring check end\n"); \ + } while (0) + +#define APR_RING_CHECK_CONSISTENCY(hp, elem, link) \ + APR_RING_CHECK_ELEM_CONSISTENCY(APR_RING_SENTINEL(hp, elem, link),\ + elem, link) + +#define APR_RING_CHECK_ELEM_CONSISTENCY(ep, elem, link) do { \ + struct elem *start = (ep); \ + struct elem *here = start; \ + do { \ + assert(APR_RING_PREV(APR_RING_NEXT(here, link), link) == here); \ + assert(APR_RING_NEXT(APR_RING_PREV(here, link), link) == here); \ + here = APR_RING_NEXT(here, link); \ + } while (here != start); \ + } while (0) + +#else +/** + * Print a single pointer value to STDERR + * (This is a no-op unless APR_RING_DEBUG is defined.) + * @param msg Descriptive message + * @param ptr Pointer value to print + */ +#define APR_RING_CHECK_ONE(msg, ptr) +/** + * Dump all ring pointers to STDERR, starting with the head and looping all + * the way around the ring back to the head. Aborts if an inconsistency + * is found. + * (This is a no-op unless APR_RING_DEBUG is defined.) + * @param hp Head of the ring + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + * @param msg Descriptive message + */ +#define APR_RING_CHECK(hp, elem, link, msg) +/** + * Loops around a ring and checks all the pointers for consistency. Pops + * an assertion if any inconsistency is found. Same idea as APR_RING_CHECK() + * except that it's silent if all is well. + * (This is a no-op unless APR_RING_DEBUG is defined.) + * @param hp Head of the ring + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_CHECK_CONSISTENCY(hp, elem, link) +/** + * Dump all ring pointers to STDERR, starting with the given element and + * looping all the way around the ring back to that element. Aborts if + * an inconsistency is found. + * (This is a no-op unless APR_RING_DEBUG is defined.) + * @param ep The element + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + * @param msg Descriptive message + */ +#define APR_RING_CHECK_ELEM(ep, elem, link, msg) +/** + * Loops around a ring, starting with the given element, and checks all + * the pointers for consistency. Pops an assertion if any inconsistency + * is found. Same idea as APR_RING_CHECK_ELEM() except that it's silent + * if all is well. + * (This is a no-op unless APR_RING_DEBUG is defined.) + * @param ep The element + * @param elem The name of the element struct + * @param link The name of the APR_RING_ENTRY in the element struct + */ +#define APR_RING_CHECK_ELEM_CONSISTENCY(ep, elem, link) +#endif + +/** @} */ + +#endif /* !APR_RING_H */ diff --git a/rubbos/app/apache2/include/apr_rmm.h b/rubbos/app/apache2/include/apr_rmm.h new file mode 100644 index 00000000..a1f0d676 --- /dev/null +++ b/rubbos/app/apache2/include/apr_rmm.h @@ -0,0 +1,137 @@ +/* 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. + */ + +#ifndef APR_RMM_H +#define APR_RMM_H +/** + * @file apr_rmm.h + * @brief APR-UTIL Relocatable Memory Management Routines + */ +/** + * @defgroup APR_Util_RMM Relocatable Memory Management Routines + * @ingroup APR_Util + * @{ + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" +#include "apu.h" +#include "apr_anylock.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Structure to access Relocatable, Managed Memory */ +typedef struct apr_rmm_t apr_rmm_t; + +/** Fundamental allocation unit, within a specific apr_rmm_t */ +typedef apr_size_t apr_rmm_off_t; + +/** + * Initialize a relocatable memory block to be managed by the apr_rmm API. + * @param rmm The relocatable memory block + * @param lock An apr_anylock_t of the appropriate type of lock, or NULL + * if no locking is required. + * @param membuf The block of relocatable memory to be managed + * @param memsize The size of relocatable memory block to be managed + * @param cont The pool to use for local storage and management + * @remark Both @param membuf and @param memsize must be aligned + * (for instance using APR_ALIGN_DEFAULT). + */ +APU_DECLARE(apr_status_t) apr_rmm_init(apr_rmm_t **rmm, apr_anylock_t *lock, + void *membuf, apr_size_t memsize, + apr_pool_t *cont); + +/** + * Destroy a managed memory block. + * @param rmm The relocatable memory block to destroy + */ +APU_DECLARE(apr_status_t) apr_rmm_destroy(apr_rmm_t *rmm); + +/** + * Attach to a relocatable memory block already managed by the apr_rmm API. + * @param rmm The relocatable memory block + * @param lock An apr_anylock_t of the appropriate type of lock + * @param membuf The block of relocatable memory already under management + * @param cont The pool to use for local storage and management + */ +APU_DECLARE(apr_status_t) apr_rmm_attach(apr_rmm_t **rmm, apr_anylock_t *lock, + void *membuf, apr_pool_t *cont); + +/** + * Detach from the managed block of memory. + * @param rmm The relocatable memory block to detach from + */ +APU_DECLARE(apr_status_t) apr_rmm_detach(apr_rmm_t *rmm); + +/** + * Allocate memory from the block of relocatable memory. + * @param rmm The relocatable memory block + * @param reqsize How much memory to allocate + */ +APU_DECLARE(apr_rmm_off_t) apr_rmm_malloc(apr_rmm_t *rmm, apr_size_t reqsize); + +/** + * Realloc memory from the block of relocatable memory. + * @param rmm The relocatable memory block + * @param entity The memory allocation to realloc + * @param reqsize The new size + */ +APU_DECLARE(apr_rmm_off_t) apr_rmm_realloc(apr_rmm_t *rmm, void *entity, apr_size_t reqsize); + +/** + * Allocate memory from the block of relocatable memory and initialize it to zero. + * @param rmm The relocatable memory block + * @param reqsize How much memory to allocate + */ +APU_DECLARE(apr_rmm_off_t) apr_rmm_calloc(apr_rmm_t *rmm, apr_size_t reqsize); + +/** + * Free allocation returned by apr_rmm_malloc or apr_rmm_calloc. + * @param rmm The relocatable memory block + * @param entity The memory allocation to free + */ +APU_DECLARE(apr_status_t) apr_rmm_free(apr_rmm_t *rmm, apr_rmm_off_t entity); + +/** + * Retrieve the physical address of a relocatable allocation of memory + * @param rmm The relocatable memory block + * @param entity The memory allocation to free + * @return address The address, aligned with APR_ALIGN_DEFAULT. + */ +APU_DECLARE(void *) apr_rmm_addr_get(apr_rmm_t *rmm, apr_rmm_off_t entity); + +/** + * Compute the offset of a relocatable allocation of memory + * @param rmm The relocatable memory block + * @param entity The physical address to convert to an offset + */ +APU_DECLARE(apr_rmm_off_t) apr_rmm_offset_get(apr_rmm_t *rmm, void *entity); + +/** + * Compute the required overallocation of memory needed to fit n allocs + * @param n The number of alloc/calloc regions desired + */ +APU_DECLARE(apr_size_t) apr_rmm_overhead_get(int n); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif /* ! APR_RMM_H */ + diff --git a/rubbos/app/apache2/include/apr_sdbm.h b/rubbos/app/apache2/include/apr_sdbm.h new file mode 100644 index 00000000..7fcf7f6e --- /dev/null +++ b/rubbos/app/apache2/include/apr_sdbm.h @@ -0,0 +1,175 @@ +/* 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. + */ + +/* + * sdbm - ndbm work-alike hashed database library + * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978). + * author: oz@nexus.yorku.ca + * status: ex-public domain + */ + +#ifndef APR_SDBM_H +#define APR_SDBM_H + +#include "apu.h" +#include "apr_errno.h" +#include "apr_file_io.h" /* for apr_fileperms_t */ + +/** + * @file apr_sdbm.h + * @brief apr-util SDBM library + */ +/** + * @defgroup APR_Util_DBM_SDBM SDBM library + * @ingroup APR_Util_DBM + * @{ + */ + +/** + * Structure for referencing an sdbm + */ +typedef struct apr_sdbm_t apr_sdbm_t; + +/** + * Structure for referencing the datum record within an sdbm + */ +typedef struct { + /** pointer to the data stored/retrieved */ + char *dptr; + /** size of data */ + int dsize; +} apr_sdbm_datum_t; + +/* The extensions used for the database files */ +/** SDBM Directory file extension */ +#define APR_SDBM_DIRFEXT ".dir" +/** SDBM page file extension */ +#define APR_SDBM_PAGFEXT ".pag" + +/* flags to sdbm_store */ +#define APR_SDBM_INSERT 0 /**< Insert */ +#define APR_SDBM_REPLACE 1 /**< Replace */ +#define APR_SDBM_INSERTDUP 2 /**< Insert with duplicates */ + +/** + * Open an sdbm database by file name + * @param db The newly opened database + * @param name The sdbm file to open + * @param mode The flag values (APR_READ and APR_BINARY flags are implicit) + *
+ *           APR_WRITE          open for read-write access
+ *           APR_CREATE         create the sdbm if it does not exist
+ *           APR_TRUNCATE       empty the contents of the sdbm
+ *           APR_EXCL           fail for APR_CREATE if the file exists
+ *           APR_DELONCLOSE     delete the sdbm when closed
+ *           APR_SHARELOCK      support locking across process/machines
+ * 
+ * @param perms Permissions to apply to if created + * @param p The pool to use when creating the sdbm + * @remark The sdbm name is not a true file name, as sdbm appends suffixes + * for seperate data and index files. + */ +APU_DECLARE(apr_status_t) apr_sdbm_open(apr_sdbm_t **db, const char *name, + apr_int32_t mode, + apr_fileperms_t perms, apr_pool_t *p); + +/** + * Close an sdbm file previously opened by apr_sdbm_open + * @param db The database to close + */ +APU_DECLARE(apr_status_t) apr_sdbm_close(apr_sdbm_t *db); + +/** + * Lock an sdbm database for concurency of multiple operations + * @param db The database to lock + * @param type The lock type + *
+ *           APR_FLOCK_SHARED
+ *           APR_FLOCK_EXCLUSIVE
+ * 
+ * @remark Calls to apr_sdbm_lock may be nested. All apr_sdbm functions + * perform implicit locking. Since an APR_FLOCK_SHARED lock cannot be + * portably promoted to an APR_FLOCK_EXCLUSIVE lock, apr_sdbm_store and + * apr_sdbm_delete calls will fail if an APR_FLOCK_SHARED lock is held. + * The apr_sdbm_lock call requires the database to be opened with the + * APR_SHARELOCK mode value. + */ +APU_DECLARE(apr_status_t) apr_sdbm_lock(apr_sdbm_t *db, int type); + +/** + * Release an sdbm lock previously aquired by apr_sdbm_lock + * @param db The database to unlock + */ +APU_DECLARE(apr_status_t) apr_sdbm_unlock(apr_sdbm_t *db); + +/** + * Fetch an sdbm record value by key + * @param db The database + * @param value The value datum retrieved for this record + * @param key The key datum to find this record + */ +APU_DECLARE(apr_status_t) apr_sdbm_fetch(apr_sdbm_t *db, + apr_sdbm_datum_t *value, + apr_sdbm_datum_t key); + +/** + * Store an sdbm record value by key + * @param db The database + * @param key The key datum to store this record by + * @param value The value datum to store in this record + * @param opt The method used to store the record + *
+ *           APR_SDBM_INSERT     return an error if the record exists
+ *           APR_SDBM_REPLACE    overwrite any existing record for key
+ * 
+ */ +APU_DECLARE(apr_status_t) apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key, + apr_sdbm_datum_t value, int opt); + +/** + * Delete an sdbm record value by key + * @param db The database + * @param key The key datum of the record to delete + * @remark It is not an error to delete a non-existent record. + */ +APU_DECLARE(apr_status_t) apr_sdbm_delete(apr_sdbm_t *db, + const apr_sdbm_datum_t key); + +/** + * Retrieve the first record key from a dbm + * @param db The database + * @param key The key datum of the first record + * @remark The keys returned are not ordered. To traverse the list of keys + * for an sdbm opened with APR_SHARELOCK, the caller must use apr_sdbm_lock + * prior to retrieving the first record, and hold the lock until after the + * last call to apr_sdbm_nextkey. + */ +APU_DECLARE(apr_status_t) apr_sdbm_firstkey(apr_sdbm_t *db, apr_sdbm_datum_t *key); + +/** + * Retrieve the next record key from an sdbm + * @param db The database + * @param key The key datum of the next record + */ +APU_DECLARE(apr_status_t) apr_sdbm_nextkey(apr_sdbm_t *db, apr_sdbm_datum_t *key); + +/** + * Returns true if the sdbm database opened for read-only access + * @param db The database to test + */ +APU_DECLARE(int) apr_sdbm_rdonly(apr_sdbm_t *db); +/** @} */ +#endif /* APR_SDBM_H */ diff --git a/rubbos/app/apache2/include/apr_sha1.h b/rubbos/app/apache2/include/apr_sha1.h new file mode 100644 index 00000000..1ad50655 --- /dev/null +++ b/rubbos/app/apache2/include/apr_sha1.h @@ -0,0 +1,121 @@ +/* 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. + */ +/* NIST Secure Hash Algorithm + * heavily modified by Uwe Hollerbach uh@alumni.caltech edu + * from Peter C. Gutmann's implementation as found in + * Applied Cryptography by Bruce Schneier + * This code is hereby placed in the public domain + */ + +#ifndef APR_SHA1_H +#define APR_SHA1_H + +#include "apu.h" +#include "apr_general.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file apr_sha1.h + * @brief APR-UTIL SHA1 library + */ + +/** size of the SHA1 DIGEST */ +#define APR_SHA1_DIGESTSIZE 20 + +/** + * Define the Magic String prefix that identifies a password as being + * hashed using our algorithm. + */ +#define APR_SHA1PW_ID "{SHA}" + +/** length of the SHA Password */ +#define APR_SHA1PW_IDLEN 5 + +/** @see apr_sha1_ctx_t */ +typedef struct apr_sha1_ctx_t apr_sha1_ctx_t; + +/** + * SHA1 context structure + */ +struct apr_sha1_ctx_t { + /** message digest */ + apr_uint32_t digest[5]; + /** 64-bit bit counts */ + apr_uint32_t count_lo, count_hi; + /** SHA data buffer */ + apr_uint32_t data[16]; + /** unprocessed amount in data */ + int local; +}; + +/** + * Provide a means to SHA1 crypt/encode a plaintext password in a way which + * makes password file compatible with those commonly use in netscape web + * and ldap installations. + * @param clear The plaintext password + * @param len The length of the plaintext password + * @param out The encrypted/encoded password + * @note SHA1 support is useful for migration purposes, but is less + * secure than Apache's password format, since Apache's (MD5) + * password format uses a random eight character salt to generate + * one of many possible hashes for the same password. Netscape + * uses plain SHA1 without a salt, so the same password + * will always generate the same hash, making it easier + * to break since the search space is smaller. + */ +APU_DECLARE(void) apr_sha1_base64(const char *clear, int len, char *out); + +/** + * Initialize the SHA digest + * @param context The SHA context to initialize + */ +APU_DECLARE(void) apr_sha1_init(apr_sha1_ctx_t *context); + +/** + * Update the SHA digest + * @param context The SHA1 context to update + * @param input The buffer to add to the SHA digest + * @param inputLen The length of the input buffer + */ +APU_DECLARE(void) apr_sha1_update(apr_sha1_ctx_t *context, const char *input, + unsigned int inputLen); + +/** + * Update the SHA digest with binary data + * @param context The SHA1 context to update + * @param input The buffer to add to the SHA digest + * @param inputLen The length of the input buffer + */ +APU_DECLARE(void) apr_sha1_update_binary(apr_sha1_ctx_t *context, + const unsigned char *input, + unsigned int inputLen); + +/** + * Finish computing the SHA digest + * @param digest the output buffer in which to store the digest + * @param context The context to finalize + */ +APU_DECLARE(void) apr_sha1_final(unsigned char digest[APR_SHA1_DIGESTSIZE], + apr_sha1_ctx_t *context); + +#ifdef __cplusplus +} +#endif + +#endif /* APR_SHA1_H */ diff --git a/rubbos/app/apache2/include/apr_shm.h b/rubbos/app/apache2/include/apr_shm.h new file mode 100644 index 00000000..5373f6a7 --- /dev/null +++ b/rubbos/app/apache2/include/apr_shm.h @@ -0,0 +1,127 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_SHM_H +#define APR_SHM_H + +/** + * @file apr_shm.h + * @brief APR Shared Memory Routines + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_shm Shared Memory Routines + * @ingroup APR + * @{ + */ + +/** + * Private, platform-specific data struture representing a shared memory + * segment. + */ +typedef struct apr_shm_t apr_shm_t; + +/** + * Create and make accessable a shared memory segment. + * @param m The shared memory structure to create. + * @param reqsize The desired size of the segment. + * @param filename The file to use for shared memory on platforms that + * require it. + * @param pool the pool from which to allocate the shared memory + * structure. + * @remark A note about Anonymous vs. Named shared memory segments: + * Not all plaforms support anonymous shared memory segments, but in + * some cases it is prefered over other types of shared memory + * implementations. Passing a NULL 'file' parameter to this function + * will cause the subsystem to use anonymous shared memory segments. + * If such a system is not available, APR_ENOTIMPL is returned. + * @remark A note about allocation sizes: + * On some platforms it is necessary to store some metainformation + * about the segment within the actual segment. In order to supply + * the caller with the requested size it may be necessary for the + * implementation to request a slightly greater segment length + * from the subsystem. In all cases, the apr_shm_baseaddr_get() + * function will return the first usable byte of memory. + * + */ +APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, + apr_size_t reqsize, + const char *filename, + apr_pool_t *pool); + +/** + * Destroy a shared memory segment and associated memory. + * @param m The shared memory segment structure to destroy. + */ +APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m); + +/** + * Attach to a shared memory segment that was created + * by another process. + * @param m The shared memory structure to create. + * @param filename The file used to create the original segment. + * (This MUST match the original filename.) + * @param pool the pool from which to allocate the shared memory + * structure for this process. + */ +APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, + const char *filename, + apr_pool_t *pool); + +/** + * Detach from a shared memory segment without destroying it. + * @param m The shared memory structure representing the segment + * to detach from. + */ +APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m); + +/** + * Retrieve the base address of the shared memory segment. + * NOTE: This address is only usable within the callers address + * space, since this API does not guarantee that other attaching + * processes will maintain the same address mapping. + * @param m The shared memory segment from which to retrieve + * the base address. + */ +APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m); + +/** + * Retrieve the length of a shared memory segment in bytes. + * @param m The shared memory segment from which to retrieve + * the segment length. + */ +APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m); + +/** + * Get the pool used by this shared memory segment. + */ +APR_POOL_DECLARE_ACCESSOR(shm); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* APR_SHM_T */ diff --git a/rubbos/app/apache2/include/apr_signal.h b/rubbos/app/apache2/include/apr_signal.h new file mode 100644 index 00000000..7f4940a0 --- /dev/null +++ b/rubbos/app/apache2/include/apr_signal.h @@ -0,0 +1,98 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_SIGNAL_H +#define APR_SIGNAL_H + +/** + * @file apr_signal.h + * @brief APR Signal Handling + */ + +#include "apr.h" +#include "apr_pools.h" + +#if APR_HAVE_SIGNAL_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_signal Handling + * @ingroup APR + * @{ + */ + +#if APR_HAVE_SIGACTION || defined(DOXYGEN) + +#if defined(DARWIN) && !defined(__cplusplus) && !defined(_ANSI_SOURCE) +/* work around Darwin header file bugs + * http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2657228.html + */ +#undef SIG_DFL +#undef SIG_IGN +#undef SIG_ERR +#define SIG_DFL (void (*)(int))0 +#define SIG_IGN (void (*)(int))1 +#define SIG_ERR (void (*)(int))-1 +#endif + +/** Function prototype for signal handlers */ +typedef void apr_sigfunc_t(int); + +/** + * Set the signal handler function for a given signal + * @param signo The signal (eg... SIGWINCH) + * @param func the function to get called + */ +APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func); + +#if defined(SIG_IGN) && !defined(SIG_ERR) +#define SIG_ERR ((apr_sigfunc_t *) -1) +#endif + +#else /* !APR_HAVE_SIGACTION */ +#define apr_signal(a, b) signal(a, b) +#endif + + +/** + * Get the description for a specific signal number + * @param signum The signal number + * @return The description of the signal + */ +APR_DECLARE(const char *) apr_signal_description_get(int signum); + +/** @deprecated @see apr_signal_description_get */ +APR_DECLARE(const char *) apr_signal_get_description(int signum); + +/** + * APR-private function for initializing the signal package + * @internal + * @param pglobal The internal, global pool + */ +void apr_signal_init(apr_pool_t *pglobal); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* APR_SIGNAL_H */ diff --git a/rubbos/app/apache2/include/apr_strings.h b/rubbos/app/apache2/include/apr_strings.h new file mode 100644 index 00000000..24cfbdf8 --- /dev/null +++ b/rubbos/app/apache2/include/apr_strings.h @@ -0,0 +1,337 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Portions of this file are covered by */ +/* -*- mode: c; c-file-style: "k&r" -*- + + strnatcmp.c -- Perform 'natural order' comparisons of strings in C. + Copyright (C) 2000 by Martin Pool + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef APR_STRINGS_H +#define APR_STRINGS_H + +/** + * @file apr_strings.h + * @brief APR Strings library + */ + +#include "apr.h" +#include "apr_errno.h" +#include "apr_pools.h" +#define APR_WANT_IOVEC +#include "apr_want.h" + +#if APR_HAVE_STDARG_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_strings String routines + * @ingroup APR + * @{ + */ + +/** + * Do a natural order comparison of two strings. + * @param a The first string to compare + * @param b The second string to compare + * @return Either <0, 0, or >0. If the first string is less than the second + * this returns <0, if they are equivalent it returns 0, and if the + * first string is greater than second string it retuns >0. + */ +APR_DECLARE(int) apr_strnatcmp(char const *a, char const *b); + +/** + * Do a natural order comparison of two strings ignoring the case of the + * strings. + * @param a The first string to compare + * @param b The second string to compare + * @return Either <0, 0, or >0. If the first string is less than the second + * this returns <0, if they are equivalent it returns 0, and if the + * first string is greater than second string it retuns >0. + */ +APR_DECLARE(int) apr_strnatcasecmp(char const *a, char const *b); + +/** + * duplicate a string into memory allocated out of a pool + * @param p The pool to allocate out of + * @param s The string to duplicate + * @return The new string + */ +APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s); + +/** + * Create a null-terminated string by making a copy of a sequence + * of characters and appending a null byte + * @param p The pool to allocate out of + * @param s The block of characters to duplicate + * @param n The number of characters to duplicate + * @return The new string + * @remark This is a faster alternative to apr_pstrndup, for use + * when you know that the string being duplicated really + * has 'n' or more characters. If the string might contain + * fewer characters, use apr_pstrndup. + */ +APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n); + +/** + * Duplicate at most n characters of a string into memory allocated + * out of a pool; the new string will be NUL-terminated + * @param p The pool to allocate out of + * @param s The string to duplicate + * @param n The maximum number of characters to duplicate + * @return The new string + * @remark The amount of memory allocated from the pool is the length + * of the returned string including the NUL terminator + */ +APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n); + +/** + * Duplicate a block of memory. + * + * @param p The pool to allocate from + * @param m The memory to duplicate + * @param n The number of bytes to duplicate + * @return The new block of memory + */ +APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n); + +/** + * Concatenate multiple strings, allocating memory out a pool + * @param p The pool to allocate out of + * @param ... The strings to concatenate. The final string must be NULL + * @return The new string + */ +APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *p, ...); + +/** + * Concatenate multiple strings specified in a writev-style vector + * @param p The pool from which to allocate + * @param vec The strings to concatenate + * @param nvec The number of strings to concatenate + * @param nbytes (output) strlen of new string (pass in NULL to omit) + * @return The new string + */ +APR_DECLARE(char *) apr_pstrcatv(apr_pool_t *p, const struct iovec *vec, + apr_size_t nvec, apr_size_t *nbytes); + +/** + * printf-style style printing routine. The data is output to a string + * allocated from a pool + * @param p The pool to allocate out of + * @param fmt The format of the string + * @param ap The arguments to use while printing the data + * @return The new string + */ +APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *p, const char *fmt, va_list ap); + +/** + * printf-style style printing routine. The data is output to a string + * allocated from a pool + * @param p The pool to allocate out of + * @param fmt The format of the string + * @param ... The arguments to use while printing the data + * @return The new string + */ +APR_DECLARE_NONSTD(char *) apr_psprintf(apr_pool_t *p, const char *fmt, ...) + __attribute__((format(printf,2,3))); + +/** + * copy n characters from src to dst + * @param dst The destination string + * @param src The source string + * @param dst_size The space available in dst; dst always receives + * null-termination, so if src is longer than + * dst_size, the actual number of characters copied is + * dst_size - 1. + * @remark + *
+ * 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.
+ * 
+ */ +APR_DECLARE(char *) apr_cpystrn(char *dst, const char *src, + apr_size_t dst_size); + +/** + * 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. + */ +APR_DECLARE(char *) apr_collapse_spaces(char *dest, const char *src); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str, + char ***argv_out, + apr_pool_t *token_context); + +/** + * 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 + */ +APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last); + +/** + * @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. + */ +APR_DECLARE_NONSTD(int) apr_snprintf(char *buf, apr_size_t len, + const char *format, ...) + __attribute__((format(printf,3,4))); + +/** + * 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. + */ +APR_DECLARE(int) apr_vsnprintf(char *buf, apr_size_t len, const char *format, + va_list ap); +/** @} */ + +/** + * 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 + */ +APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n); + +/** + * 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 + */ +APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n); + +/** + * 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 + */ +APR_DECLARE(char *) apr_off_t_toa(apr_pool_t *p, apr_off_t n); + +/** + * 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. + */ +APR_DECLARE(apr_int64_t) apr_strtoi64(const char *buf, char **end, int base); + +/** + * 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 + */ +APR_DECLARE(apr_int64_t) apr_atoi64(const char *buf); + +/** + * 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. + */ +APR_DECLARE(char *) apr_strfsize(apr_off_t size, char *buf); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APR_STRINGS_H */ diff --git a/rubbos/app/apache2/include/apr_strmatch.h b/rubbos/app/apache2/include/apr_strmatch.h new file mode 100644 index 00000000..4753318b --- /dev/null +++ b/rubbos/app/apache2/include/apr_strmatch.h @@ -0,0 +1,81 @@ +/* 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. + */ + +#ifndef APR_STRMATCH_H +#define APR_STRMATCH_H +/** + * @file apr_strmatch.h + * @brief APR-UTIL string matching routines + */ + +#include "apu.h" +#include "apr_pools.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup APR_Util_StrMatch String matching routines + * @ingroup APR_Util + * @{ + */ + +/** @see apr_strmatch_pattern */ +typedef struct apr_strmatch_pattern apr_strmatch_pattern; + +/** + * Precompiled search pattern + */ +struct apr_strmatch_pattern { + /** Function called to compare */ + const char *(*compare)(const apr_strmatch_pattern *this_pattern, + const char *s, apr_size_t slen); + const char *pattern; /**< Current pattern */ + apr_size_t length; /**< Current length */ + void *context; /**< hook to add precomputed metadata */ +}; + +#if defined(DOXYGEN) +/** + * Search for a precompiled pattern within a string + * @param pattern The pattern + * @param s The string in which to search for the pattern + * @param slen The length of s (excluding null terminator) + * @return A pointer to the first instance of the pattern in s, or + * NULL if not found + */ +APU_DECLARE(const char *) apr_strmatch(const apr_strmatch_pattern *pattern, + const char *s, apr_size_t slen); +#else +#define apr_strmatch(pattern, s, slen) (*((pattern)->compare))((pattern), (s), (slen)) +#endif + +/** + * Precompile a pattern for matching using the Boyer-Moore-Horspool algorithm + * @param p The pool from which to allocate the pattern + * @param s The pattern string + * @param case_sensitive Whether the matching should be case-sensitive + * @return a pointer to the compiled pattern, or NULL if compilation fails + */ +APU_DECLARE(const apr_strmatch_pattern *) apr_strmatch_precompile(apr_pool_t *p, const char *s, int case_sensitive); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* !APR_STRMATCH_H */ diff --git a/rubbos/app/apache2/include/apr_support.h b/rubbos/app/apache2/include/apr_support.h new file mode 100644 index 00000000..ee31860f --- /dev/null +++ b/rubbos/app/apache2/include/apr_support.h @@ -0,0 +1,51 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_SUPPORT_H +#define APR_SUPPORT_H + +/** + * @file apr_support.h + * @brief APR Support functions + */ + +#include "apr.h" +#include "apr_network_io.h" +#include "apr_file_io.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_support Internal APR support functions + * @ingroup APR + * @{ + */ + +/** + * Wait for IO to occur or timeout. + */ +apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s, + int for_read); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_SUPPORT_H */ diff --git a/rubbos/app/apache2/include/apr_tables.h b/rubbos/app/apache2/include/apr_tables.h new file mode 100644 index 00000000..f286b5c7 --- /dev/null +++ b/rubbos/app/apache2/include/apr_tables.h @@ -0,0 +1,422 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_TABLES_H +#define APR_TABLES_H + +/** + * @file apr_tables.h + * @brief APR Table library + */ + +#include "apr.h" +#include "apr_pools.h" + +#if APR_HAVE_STDARG_H +#include /* for va_list */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @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 */ +typedef struct apr_table_t apr_table_t; + +/** @see apr_array_header_t */ +typedef struct apr_array_header_t apr_array_header_t; + +/** An opaque array type */ +struct apr_array_header_t { + /** The pool the array is allocated out of */ + apr_pool_t *pool; + /** The amount of memory allocated for each element of the array */ + int elt_size; + /** The number of active elements in the array */ + int nelts; + /** The number of elements allocated in the array */ + int nalloc; + /** The elements in the array */ + char *elts; +}; + +/** + * The (opaque) structure for string-content tables. + */ +typedef struct apr_table_entry_t apr_table_entry_t; + +/** The type for each entry in a string-content table */ +struct apr_table_entry_t { + /** The key for the current table entry */ + char *key; /* maybe NULL in future; + * check when iterating thru table_elts + */ + /** The value for the current table entry */ + char *val; + + /** A checksum for the key, for use by the apr_table internals */ + apr_uint32_t key_checksum; +}; + +/** + * Get the elements from a table + * @param t The table + * @return An array containing the contents of the table + */ +APR_DECLARE(const apr_array_header_t *) apr_table_elts(const apr_table_t *t); + +/** + * Determine if the table is empty + * @param t The table to check + * @return True if empty, False otherwise + */ +APR_DECLARE(int) apr_is_empty_table(const apr_table_t *t); + +/** + * Determine if the array is empty + * @param a The array to check + * @return True if empty, False otherwise + */ +APR_DECLARE(int) apr_is_empty_array(const apr_array_header_t *a); + +/** + * 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 + */ +APR_DECLARE(apr_array_header_t *) apr_array_make(apr_pool_t *p, + int nelts, int elt_size); + +/** + * 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. + */ +APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr); + +/** + * 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. + */ +APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr); + +/** + * 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 + */ +APR_DECLARE(void) apr_array_cat(apr_array_header_t *dst, + const apr_array_header_t *src); + +/** + * 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. + */ +APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p, + const apr_array_header_t *arr); +/** + * 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. + */ +APR_DECLARE(apr_array_header_t *) apr_array_copy_hdr(apr_pool_t *p, + const apr_array_header_t *arr); + +/** + * 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. +*/ +APR_DECLARE(apr_array_header_t *) apr_array_append(apr_pool_t *p, + const apr_array_header_t *first, + const apr_array_header_t *second); + +/** + * 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. + */ +APR_DECLARE(char *) apr_array_pstrcat(apr_pool_t *p, + const apr_array_header_t *arr, + const char sep); + +/** + * 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 + */ +APR_DECLARE(apr_table_t *) apr_table_make(apr_pool_t *p, int nelts); + +/** + * 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 + */ +APR_DECLARE(apr_table_t *) apr_table_copy(apr_pool_t *p, + const apr_table_t *t); + +/** + * Delete all of the elements from a table + * @param t The table to clear + */ +APR_DECLARE(void) apr_table_clear(apr_table_t *t); + +/** + * 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 + */ +APR_DECLARE(const char *) apr_table_get(const apr_table_t *t, const char *key); + +/** + * 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. + */ +APR_DECLARE(void) apr_table_set(apr_table_t *t, const char *key, + const char *val); + +/** + * 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.. + */ +APR_DECLARE(void) apr_table_setn(apr_table_t *t, const char *key, + const char *val); + +/** + * Remove data from the table + * @param t The table to remove data from + * @param key The key of the data being removed + */ +APR_DECLARE(void) apr_table_unset(apr_table_t *t, const char *key); + +/** + * 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 + */ +APR_DECLARE(void) apr_table_merge(apr_table_t *t, const char *key, + const char *val); + +/** + * 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 + */ +APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key, + const char *val); + +/** + * 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. + */ +APR_DECLARE(void) apr_table_add(apr_table_t *t, const char *key, + const char *val); + +/** + * 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.. + */ +APR_DECLARE(void) apr_table_addn(apr_table_t *t, const char *key, + const char *val); + +/** + * 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 + */ +APR_DECLARE(apr_table_t *) apr_table_overlay(apr_pool_t *p, + const apr_table_t *overlay, + const apr_table_t *base); + +/** + * 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. + */ +typedef int (apr_table_do_callback_fn_t)(void *rec, const char *key, + const char *value); + +/** + * 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 + */ +APR_DECLARE(int) apr_table_vdo(apr_table_do_callback_fn_t *comp, + void *rec, const apr_table_t *t, va_list vp); + +/** flag for overlap to use apr_table_setn */ +#define APR_OVERLAP_TABLES_SET (0) +/** flag for overlap to use apr_table_mergen */ +#define 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.
+ * 
+ */ + +APR_DECLARE(void) apr_table_overlap(apr_table_t *a, const apr_table_t *b, + unsigned flags); + +/** + * 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 + */ +APR_DECLARE(void) apr_table_compress(apr_table_t *t, unsigned flags); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_TABLES_H */ diff --git a/rubbos/app/apache2/include/apr_thread_cond.h b/rubbos/app/apache2/include/apr_thread_cond.h new file mode 100644 index 00000000..520fb309 --- /dev/null +++ b/rubbos/app/apache2/include/apr_thread_cond.h @@ -0,0 +1,128 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_THREAD_COND_H +#define APR_THREAD_COND_H + +/** + * @file apr_thread_cond.h + * @brief APR Condition Variable Routines + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" +#include "apr_time.h" +#include "apr_thread_mutex.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if APR_HAS_THREADS || defined(DOXYGEN) + +/** + * @defgroup apr_thread_cond Condition Variable Routines + * @ingroup APR + * @{ + */ + +/** Opaque structure for thread condition variables */ +typedef struct apr_thread_cond_t apr_thread_cond_t; + +/** + * Create and initialize a condition variable that can be used to signal + * and schedule threads in a single process. + * @param cond the memory address where the newly created condition variable + * will be stored. + * @param pool the pool from which to allocate the mutex. + */ +APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond, + apr_pool_t *pool); + +/** + * Put the active calling thread to sleep until signaled to wake up. Each + * condition variable must be associated with a mutex, and that mutex must + * be locked before calling this function, or the behavior will be + * undefined. As the calling thread is put to sleep, the given mutex + * will be simultaneously released; and as this thread wakes up the lock + * is again simultaneously acquired. + * @param cond the condition variable on which to block. + * @param mutex the mutex that must be locked upon entering this function, + * is released while the thread is asleep, and is again acquired before + * returning from this function. + */ +APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond, + apr_thread_mutex_t *mutex); + +/** + * Put the active calling thread to sleep until signaled to wake up or + * the timeout is reached. Each condition variable must be associated + * with a mutex, and that mutex must be locked before calling this + * function, or the behavior will be undefined. As the calling thread + * is put to sleep, the given mutex will be simultaneously released; + * and as this thread wakes up the lock is again simultaneously acquired. + * @param cond the condition variable on which to block. + * @param mutex the mutex that must be locked upon entering this function, + * is released while the thread is asleep, and is again acquired before + * returning from this function. + * @param timeout The amount of time in microseconds to wait. This is + * a maximum, not a minimum. If the condition is signaled, we + * will wake up before this time, otherwise the error APR_TIMEUP + * is returned. + */ +APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond, + apr_thread_mutex_t *mutex, + apr_interval_time_t timeout); + +/** + * Signals a singla thread, if one exists, that is blocking on the given + * condition variable. That thread is then scheduled to wake up and acquire + * the associated mutex. Although it is not required, if predictible schedule + * is desired, that mutex must be locked while calling this function. + * @param cond the condition variable on which to produce the signal. + */ +APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond); + +/** + * Signals all threads blocking on the given condition variable. + * Each thread that was signaled is then schedule to wake up and acquire + * the associated mutex. This will happen in a serialized manner. + * @param cond the condition variable on which to produce the broadcast. + */ +APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond); + +/** + * Destroy the condition variable and free the associated memory. + * @param cond the condition variable to destroy. + */ +APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond); + +/** + * Get the pool used by this thread_cond. + * @return apr_pool_t the pool + */ +APR_POOL_DECLARE_ACCESSOR(thread_cond); + +#endif /* APR_HAS_THREADS */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_THREAD_COND_H */ diff --git a/rubbos/app/apache2/include/apr_thread_mutex.h b/rubbos/app/apache2/include/apr_thread_mutex.h new file mode 100644 index 00000000..4596dce5 --- /dev/null +++ b/rubbos/app/apache2/include/apr_thread_mutex.h @@ -0,0 +1,110 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_THREAD_MUTEX_H +#define APR_THREAD_MUTEX_H + +/** + * @file apr_thread_mutex.h + * @brief APR Thread Mutex Routines + */ + +#include "apr.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if APR_HAS_THREADS || defined(DOXYGEN) + +/** + * @defgroup apr_thread_mutex Thread Mutex Routines + * @ingroup APR + * @{ + */ + +/** Opaque thread-local mutex structure */ +typedef struct apr_thread_mutex_t apr_thread_mutex_t; + +#define APR_THREAD_MUTEX_DEFAULT 0x0 /**< platform-optimal lock behavior */ +#define APR_THREAD_MUTEX_NESTED 0x1 /**< enable nested (recursive) locks */ +#define APR_THREAD_MUTEX_UNNESTED 0x2 /**< disable nested locks */ + +/* Delayed the include to avoid a circular reference */ +#include "apr_pools.h" + +/** + * Create and initialize a mutex that can be used to synchronize threads. + * @param mutex the memory address where the newly created mutex will be + * stored. + * @param flags Or'ed value of: + *
+ *           APR_THREAD_MUTEX_DEFAULT   platform-optimal lock behavior.
+ *           APR_THREAD_MUTEX_NESTED    enable nested (recursive) locks.
+ *           APR_THREAD_MUTEX_UNNESTED  disable nested locks (non-recursive).
+ * 
+ * @param pool the pool from which to allocate the mutex. + * @warning Be cautious in using APR_THREAD_MUTEX_DEFAULT. While this is the + * most optimial mutex based on a given platform's performance charateristics, + * it will behave as either a nested or an unnested lock. + */ +APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex, + unsigned int flags, + apr_pool_t *pool); +/** + * Acquire the lock for the given mutex. If the mutex is already locked, + * the current thread will be put to sleep until the lock becomes available. + * @param mutex the mutex on which to acquire the lock. + */ +APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex); + +/** + * Attempt to acquire the lock for the given mutex. If the mutex has already + * been acquired, the call returns immediately with APR_EBUSY. Note: it + * is important that the APR_STATUS_IS_EBUSY(s) macro be used to determine + * if the return value was APR_EBUSY, for portability reasons. + * @param mutex the mutex on which to attempt the lock acquiring. + */ +APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex); + +/** + * Release the lock for the given mutex. + * @param mutex the mutex from which to release the lock. + */ +APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex); + +/** + * Destroy the mutex and free the memory associated with the lock. + * @param mutex the mutex to destroy. + */ +APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex); + +/** + * Get the pool used by this thread_mutex. + * @return apr_pool_t the pool + */ +APR_POOL_DECLARE_ACCESSOR(thread_mutex); + +#endif /* APR_HAS_THREADS */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_THREAD_MUTEX_H */ diff --git a/rubbos/app/apache2/include/apr_thread_proc.h b/rubbos/app/apache2/include/apr_thread_proc.h new file mode 100644 index 00000000..be586040 --- /dev/null +++ b/rubbos/app/apache2/include/apr_thread_proc.h @@ -0,0 +1,772 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_THREAD_PROC_H +#define APR_THREAD_PROC_H + +/** + * @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 +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_thread_proc Threads and Process Functions + * @ingroup APR + * @{ + */ + +typedef enum { + APR_SHELLCMD, /**< use the shell to invoke the program */ + APR_PROGRAM, /**< invoke the program directly, no copied env */ + APR_PROGRAM_ENV, /**< invoke the program, replicating our environment */ + APR_PROGRAM_PATH, /**< find program on PATH, use our environment */ + APR_SHELLCMD_ENV /**< use the shell to invoke the program, + * replicating our environment + */ +} apr_cmdtype_e; + +typedef enum { + APR_WAIT, /**< wait for the specified process to finish */ + APR_NOWAIT /**< do not wait -- just see if it has finished */ +} apr_wait_how_e; + +/* I am specifically calling out the values so that the macros below make + * more sense. Yes, I know I don't need to, but I am hoping this makes what + * I am doing more clear. If you want to add more reasons to exit, continue + * to use bitmasks. + */ +typedef enum { + APR_PROC_EXIT = 1, /**< process exited normally */ + APR_PROC_SIGNAL = 2, /**< process exited due to a signal */ + APR_PROC_SIGNAL_CORE = 4 /**< process exited and dumped a core file */ +} apr_exit_why_e; + +/** did we exit the process */ +#define APR_PROC_CHECK_EXIT(x) (x & APR_PROC_EXIT) +/** did we get a signal */ +#define APR_PROC_CHECK_SIGNALED(x) (x & APR_PROC_SIGNAL) +/** did we get core */ +#define APR_PROC_CHECK_CORE_DUMP(x) (x & APR_PROC_SIGNAL_CORE) + +/** @see apr_procattr_io_set */ +#define APR_NO_PIPE 0 + +/** @see apr_procattr_io_set */ +#define APR_FULL_BLOCK 1 +/** @see apr_procattr_io_set */ +#define APR_FULL_NONBLOCK 2 +/** @see apr_procattr_io_set */ +#define APR_PARENT_BLOCK 3 +/** @see apr_procattr_io_set */ +#define APR_CHILD_BLOCK 4 + +/** @see apr_procattr_limit_set */ +#define APR_LIMIT_CPU 0 +/** @see apr_procattr_limit_set */ +#define APR_LIMIT_MEM 1 +/** @see apr_procattr_limit_set */ +#define APR_LIMIT_NPROC 2 +/** @see apr_procattr_limit_set */ +#define APR_LIMIT_NOFILE 3 + +/** + * @defgroup APR_OC Other Child Flags + * @{ + */ +#define APR_OC_REASON_DEATH 0 /**< child has died, caller must call + * unregister still */ +#define APR_OC_REASON_UNWRITABLE 1 /**< write_fd is unwritable */ +#define APR_OC_REASON_RESTART 2 /**< a restart is occuring, perform + * any necessary cleanup (including + * sending a special signal to child) + */ +#define APR_OC_REASON_UNREGISTER 3 /**< unregister has been called, do + * whatever is necessary (including + * kill the child) */ +#define APR_OC_REASON_LOST 4 /**< somehow the child exited without + * us knowing ... buggy os? */ +#define APR_OC_REASON_RUNNING 5 /**< a health check is occuring, + * for most maintainence functions + * this is a no-op. + */ +/** @} */ + +/** The APR process type */ +typedef struct apr_proc_t { + /** The process ID */ + pid_t pid; + /** Parent's side of pipe to child's stdin */ + apr_file_t *in; + /** Parent's side of pipe to child's stdout */ + apr_file_t *out; + /** Parent's side of pipe to child's stdouterr */ + apr_file_t *err; +#if APR_HAS_PROC_INVOKED || defined(DOXYGEN) + /** Diagnositics/debugging string of the command invoked for + * this process [only present if APR_HAS_PROC_INVOKED is true] + * @remark Only enabled on Win32 by default. + * @bug This should either always or never be present in release + * builds - since it breaks binary compatibility. We may enable + * it always in APR 1.0 yet leave it undefined in most cases. + */ + char *invoked; +#endif +#if defined(WIN32) || defined(DOXYGEN) + /** (Win32 only) Creator's handle granting access to the process + * @remark This handle is closed and reset to NULL in every case + * corresponding to a waitpid() on Unix which returns the exit status. + * Therefore Win32 correspond's to Unix's zombie reaping characteristics + * and avoids potential handle leaks. + */ + HANDLE hproc; +#endif +} apr_proc_t; + +/** + * The prototype for APR child errfn functions. (See the description + * of apr_procattr_child_errfn_set() for more information.) + * It is passed the following parameters: + * @param pool Pool associated with the apr_proc_t. If your child + * error function needs user data, associate it with this + * pool. + * @param err APR error code describing the error + * @param description Text description of type of processing which failed + */ +typedef void (apr_child_errfn_t)(apr_pool_t *proc, apr_status_t err, + const char *description); + +/** Opaque Thread structure. */ +typedef struct apr_thread_t apr_thread_t; + +/** Opaque Thread attributes structure. */ +typedef struct apr_threadattr_t apr_threadattr_t; + +/** Opaque Process attributes structure. */ +typedef struct apr_procattr_t apr_procattr_t; + +/** Opaque control variable for one-time atomic variables. */ +typedef struct apr_thread_once_t apr_thread_once_t; + +/** Opaque thread private address space. */ +typedef struct apr_threadkey_t apr_threadkey_t; + +/** Opaque record of child process. */ +typedef struct apr_other_child_rec_t apr_other_child_rec_t; + +/** + * The prototype for any APR thread worker functions. + */ +typedef void *(APR_THREAD_FUNC *apr_thread_start_t)(apr_thread_t*, void*); + +typedef enum { + 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 */ +} apr_kill_conditions_e; + +/* Thread Function definitions */ + +#if APR_HAS_THREADS + +/** + * Create and initialize a new threadattr variable + * @param new_attr The newly created threadattr. + * @param cont The pool to use + */ +APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new_attr, + apr_pool_t *cont); + +/** + * Set if newly created threads should be created in detached state. + * @param attr The threadattr to affect + * @param on Thread detach state on or off + */ +APR_DECLARE(apr_status_t) apr_threadattr_detach_set(apr_threadattr_t *attr, + apr_int32_t on); + +/** + * Get the detach state for this threadattr. + * @param attr The threadattr to reference + */ +APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr); + +/** + * Set the stack size of newly created threads. + * @param attr The threadattr to affect + * @param stacksize The stack size in bytes + */ +APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, + apr_size_t stacksize); + +/** + * Create a new thread of execution + * @param new_thread The newly created thread handle. + * @param attr The threadattr to use to determine how to create the thread + * @param func The function to start the new thread in + * @param data Any data to be passed to the starting function + * @param cont The pool to use + */ +APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new_thread, + apr_threadattr_t *attr, + apr_thread_start_t func, + void *data, apr_pool_t *cont); + +/** + * stop the current thread + * @param thd The thread to stop + * @param retval The return value to pass back to any thread that cares + */ +APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, + apr_status_t retval); + +/** + * block until the desired thread stops executing. + * @param retval The return value from the dead thread. + * @param thd The thread to join + */ +APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, + apr_thread_t *thd); + +/** + * force the current thread to yield the processor + */ +APR_DECLARE(void) apr_thread_yield(void); + +/** + * Initialize the control variable for apr_thread_once. If this isn't + * called, apr_initialize won't work. + * @param control The control variable to initialize + * @param p The pool to allocate data from. + */ +APR_DECLARE(apr_status_t) apr_thread_once_init(apr_thread_once_t **control, + apr_pool_t *p); + +/** + * Run the specified function one time, regardless of how many threads + * call it. + * @param control The control variable. The same variable should + * be passed in each time the function is tried to be + * called. This is how the underlying functions determine + * if the function has ever been called before. + * @param func The function to call. + */ +APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control, + void (*func)(void)); + +/** + * detach a thread + * @param thd The thread to detach + */ +APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd); + +/** + * Return the pool associated with the current thread. + * @param data The user data associated with the thread. + * @param key The key to associate with the data + * @param thread The currently open thread. + */ +APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key, + apr_thread_t *thread); + +/** + * Return the pool associated with the current thread. + * @param data The user data to associate with the thread. + * @param key The key to use for associating the data with the thread + * @param cleanup The cleanup routine to use when the thread is destroyed. + * @param thread The currently open thread. + */ +APR_DECLARE(apr_status_t) apr_thread_data_set(void *data, const char *key, + apr_status_t (*cleanup) (void *), + apr_thread_t *thread); + +/** + * Create and initialize a new thread private address space + * @param key The thread private handle. + * @param dest The destructor to use when freeing the private memory. + * @param cont The pool to use + */ +APR_DECLARE(apr_status_t) apr_threadkey_private_create(apr_threadkey_t **key, + void (*dest)(void *), + apr_pool_t *cont); + +/** + * Get a pointer to the thread private memory + * @param new_mem The data stored in private memory + * @param key The handle for the desired thread private memory + */ +APR_DECLARE(apr_status_t) apr_threadkey_private_get(void **new_mem, + apr_threadkey_t *key); + +/** + * Set the data to be stored in thread private memory + * @param priv The data to be stored in private memory + * @param key The handle for the desired thread private memory + */ +APR_DECLARE(apr_status_t) apr_threadkey_private_set(void *priv, + apr_threadkey_t *key); + +/** + * Free the thread private memory + * @param key The handle for the desired thread private memory + */ +APR_DECLARE(apr_status_t) apr_threadkey_private_delete(apr_threadkey_t *key); + +/** + * Return the pool associated with the current threadkey. + * @param data The user data associated with the threadkey. + * @param key The key associated with the data + * @param threadkey The currently open threadkey. + */ +APR_DECLARE(apr_status_t) apr_threadkey_data_get(void **data, const char *key, + apr_threadkey_t *threadkey); + +/** + * Return the pool associated with the current threadkey. + * @param data The data to set. + * @param key The key to associate with the data. + * @param cleanup The cleanup routine to use when the file is destroyed. + * @param threadkey The currently open threadkey. + */ +APR_DECLARE(apr_status_t) apr_threadkey_data_set(void *data, const char *key, + apr_status_t (*cleanup) (void *), + apr_threadkey_t *threadkey); + +#endif + +/** + * Create and initialize a new procattr variable + * @param new_attr The newly created procattr. + * @param cont The pool to use + */ +APR_DECLARE(apr_status_t) apr_procattr_create(apr_procattr_t **new_attr, + apr_pool_t *cont); + +/** + * Determine if any of stdin, stdout, or stderr should be linked to pipes + * when starting a child process. + * @param attr The procattr we care about. + * @param in Should stdin be a pipe back to the parent? + * @param out Should stdout be a pipe back to the parent? + * @param err Should stderr be a pipe back to the parent? + */ +APR_DECLARE(apr_status_t) apr_procattr_io_set(apr_procattr_t *attr, + apr_int32_t in, apr_int32_t out, + apr_int32_t err); + +/** + * Set the child_in and/or parent_in values to existing apr_file_t values. + * @param attr The procattr we care about. + * @param child_in apr_file_t value to use as child_in. Must be a valid file. + * @param parent_in apr_file_t value to use as parent_in. Must be a valid file. + * @remark This is NOT a required initializer function. This is + * useful if you have already opened a pipe (or multiple files) + * that you wish to use, perhaps persistently across multiple + * process invocations - such as a log file. You can save some + * extra function calls by not creating your own pipe since this + * creates one in the process space for you. + */ +APR_DECLARE(apr_status_t) apr_procattr_child_in_set(struct apr_procattr_t *attr, + apr_file_t *child_in, + apr_file_t *parent_in); + +/** + * Set the child_out and parent_out values to existing apr_file_t values. + * @param attr The procattr we care about. + * @param child_out apr_file_t value to use as child_out. Must be a valid file. + * @param parent_out apr_file_t value to use as parent_out. Must be a valid file. + * @remark This is NOT a required initializer function. This is + * useful if you have already opened a pipe (or multiple files) + * that you wish to use, perhaps persistently across multiple + * process invocations - such as a log file. + */ +APR_DECLARE(apr_status_t) apr_procattr_child_out_set(struct apr_procattr_t *attr, + apr_file_t *child_out, + apr_file_t *parent_out); + +/** + * Set the child_err and parent_err values to existing apr_file_t values. + * @param attr The procattr we care about. + * @param child_err apr_file_t value to use as child_err. Must be a valid file. + * @param parent_err apr_file_t value to use as parent_err. Must be a valid file. + * @remark This is NOT a required initializer function. This is + * useful if you have already opened a pipe (or multiple files) + * that you wish to use, perhaps persistently across multiple + * process invocations - such as a log file. + */ +APR_DECLARE(apr_status_t) apr_procattr_child_err_set(struct apr_procattr_t *attr, + apr_file_t *child_err, + apr_file_t *parent_err); + +/** + * Set which directory the child process should start executing in. + * @param attr The procattr we care about. + * @param dir Which dir to start in. By default, this is the same dir as + * the parent currently resides in, when the createprocess call + * is made. + */ +APR_DECLARE(apr_status_t) apr_procattr_dir_set(apr_procattr_t *attr, + const char *dir); + +/** + * Set what type of command the child process will call. + * @param attr The procattr we care about. + * @param cmd The type of command. One of: + *
+ *            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
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_procattr_cmdtype_set(apr_procattr_t *attr, + apr_cmdtype_e cmd); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_procattr_detach_set(apr_procattr_t *attr, + apr_int32_t detach); + +#if 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. + */ +APR_DECLARE(apr_status_t) apr_procattr_limit_set(apr_procattr_t *attr, + apr_int32_t what, + struct rlimit *limit); +#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. + */ +APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr, + apr_child_errfn_t *errfn); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr, + apr_int32_t chk); + +/** + * 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. + */ +APR_DECLARE(apr_status_t) apr_procattr_addrspace_set(apr_procattr_t *attr, + apr_int32_t addrspace); + +#if 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. + */ +APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *cont); +#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. + */ +APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new_proc, + const char *progname, + const char * const *args, + const char * const *env, + apr_procattr_t *attr, + apr_pool_t *cont); + +/** + * 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.
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, + int *exitcode, apr_exit_why_e *exitwhy, + apr_wait_how_e waithow); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, + int *exitcode, + apr_exit_why_e *exitwhy, + apr_wait_how_e waithow, + apr_pool_t *p); + +#define APR_PROC_DETACH_FOREGROUND 0 /**< Do not detach */ +#define 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. + */ +APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize); + +/** + * 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. + */ +APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *proc, + void (*maintenance) (int reason, + void *, + int status), + void *data, apr_file_t *write_fd, + apr_pool_t *p); + +/** + * 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. + */ +APR_DECLARE(void) apr_proc_other_child_unregister(void *data); + +/** + * 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 ...]
+ * 
+ */ +APR_DECLARE(apr_status_t) apr_proc_other_child_alert(apr_proc_t *proc, + int reason, + int status); + +/** + * 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 + */ +APR_DECLARE(void) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr, + int reason); + +/** + * 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 + */ +APR_DECLARE(void) apr_proc_other_child_refresh_all(int reason); + +/** @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. + */ +APR_DECLARE(void) apr_proc_other_child_check(void); + +/** @deprecated @see apr_proc_other_child_alert + * @bug This function's name had nothing to do with it's purpose + */ +APR_DECLARE(apr_status_t) apr_proc_other_child_read(apr_proc_t *proc, int status); + + +/** + * Terminate a process. + * @param proc The process to terminate. + * @param sig How to kill the process. + */ +APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig); + +/** + * 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
+ * 
+ */ +APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *proc, + apr_kill_conditions_e how); + +#if APR_HAS_THREADS + +#if (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !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 + */ +APR_DECLARE(apr_status_t) apr_setup_signal_thread(void); + +/** + * 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)) + */ +APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum)); + +#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 */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_THREAD_PROC_H */ + diff --git a/rubbos/app/apache2/include/apr_thread_rwlock.h b/rubbos/app/apache2/include/apr_thread_rwlock.h new file mode 100644 index 00000000..0e69a2a4 --- /dev/null +++ b/rubbos/app/apache2/include/apr_thread_rwlock.h @@ -0,0 +1,120 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_THREAD_RWLOCK_H +#define APR_THREAD_RWLOCK_H + +/** + * @file apr_thread_rwlock.h + * @brief APR Reader/Writer Lock Routines + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if APR_HAS_THREADS + +/** + * @defgroup apr_thread_rwlock Reader/Writer Lock Routines + * @ingroup APR + * @{ + */ + +/** Opaque read-write thread-safe lock. */ +typedef struct apr_thread_rwlock_t apr_thread_rwlock_t; + +/** + * Create and initialize a read-write lock that can be used to synchronize + * threads. + * @param rwlock the memory address where the newly created readwrite lock + * will be stored. + * @param pool the pool from which to allocate the mutex. + */ +APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock, + apr_pool_t *pool); +/** + * Acquire a shared-read lock on the given read-write lock. This will allow + * multiple threads to enter the same critical section while they have acquired + * the read lock. + * @param rwlock the read-write lock on which to acquire the shared read. + */ +APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock); + +/** + * Attempt to acquire the shread-read lock on the given read-write lock. This + * is the same as apr_thread_rwlock_rdlock(), only that the funtion fails + * if there is another thread holding the write lock, or if there are any + * write threads blocking on the lock. If the function failes for this case, + * APR_EBUSY will be returned. Note: it is important that the + * APR_STATUS_IS_EBUSY(s) macro be used to determine if the return value was + * APR_EBUSY, for portability reasons. + * @param rwlock the rwlock on which to attempt the shared read. + */ +APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock); + +/** + * Acquire an exclusive-write lock on the given read-write lock. This will + * allow only one single thread to enter the critical sections. If there + * are any threads currently holding thee read-lock, this thread is put to + * sleep until it can have exclusive access to the lock. + * @param rwlock the read-write lock on which to acquire the exclusive write. + */ +APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock); + +/** + * Attempt to acquire the exclusive-write lock on the given read-write lock. + * This is the same as apr_thread_rwlock_wrlock(), only that the funtion fails + * if there is any other thread holding the lock (for reading or writing), + * in which case the function will return APR_EBUSY. Note: it is important + * that the APR_STATUS_IS_EBUSY(s) macro be used to determine if the return + * value was APR_EBUSY, for portability reasons. + * @param rwlock the rwlock on which to attempt the exclusive write. + */ +APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock); + +/** + * Release either the read or write lock currently held by the calling thread + * associated with the given read-write lock. + * @param rwlock the read-write lock to be released (unlocked). + */ +APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock); + +/** + * Destroy the read-write lock and free the associated memory. + * @param rwlock the rwlock to destroy. + */ +APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock); + +/** + * Get the pool used by this thread_rwlock. + * @return apr_pool_t the pool + */ +APR_POOL_DECLARE_ACCESSOR(thread_rwlock); + +#endif /* APR_HAS_THREADS */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_THREAD_RWLOCK_H */ diff --git a/rubbos/app/apache2/include/apr_time.h b/rubbos/app/apache2/include/apr_time.h new file mode 100644 index 00000000..d313910b --- /dev/null +++ b/rubbos/app/apache2/include/apr_time.h @@ -0,0 +1,245 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_TIME_H +#define APR_TIME_H + +/** + * @file apr_time.h + * @brief APR Time Library + */ + +#include "apr.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @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 */ +typedef apr_int64_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 */ +#define APR_TIME_T_FMT APR_INT64_T_FMT + +/** intervals for I/O timeouts, in microseconds */ +typedef apr_int64_t apr_interval_time_t; +/** short interval for I/O timeouts, in microseconds */ +typedef apr_int32_t apr_short_interval_time_t; + +/** number of microseconds per second */ +#define 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 + */ +APR_DECLARE(apr_time_t) apr_time_now(void); + +/** @see apr_time_exp_t */ +typedef struct apr_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) + */ +struct apr_time_exp_t { + /** microseconds past tm_sec */ + apr_int32_t tm_usec; + /** (0-61) seconds past tm_min */ + apr_int32_t tm_sec; + /** (0-59) minutes past tm_hour */ + apr_int32_t tm_min; + /** (0-23) hours past midnight */ + apr_int32_t tm_hour; + /** (1-31) day of the month */ + apr_int32_t tm_mday; + /** (0-11) month of the year */ + apr_int32_t tm_mon; + /** year since 1900 */ + apr_int32_t tm_year; + /** (0-6) days since sunday */ + apr_int32_t tm_wday; + /** (0-365) days since jan 1 */ + apr_int32_t tm_yday; + /** daylight saving time */ + apr_int32_t tm_isdst; + /** seconds east of UTC */ + apr_int32_t tm_gmtoff; +}; + +/** + * convert an ansi time_t to an apr_time_t + * @param result the resulting apr_time_t + * @param input the time_t to convert + */ +APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result, + time_t input); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result, + apr_time_t input, + apr_int32_t offs); + +/** @deprecated @see apr_time_exp_tz */ +APR_DECLARE(apr_status_t) apr_explode_time(apr_time_exp_t *result, + apr_time_t input, + apr_int32_t offs); + +/** + * convert a time to its human readable components in GMT timezone + * @param result the exploded time + * @param input the time to explode + */ +APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result, + apr_time_t input); + +/** + * convert a time to its human readable components in local timezone + * @param result the exploded time + * @param input the time to explode + */ +APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result, + apr_time_t input); + +/** @deprecated @see apr_time_exp_lt */ +APR_DECLARE(apr_status_t) apr_explode_localtime(apr_time_exp_t *result, + apr_time_t input); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *result, + apr_time_exp_t *input); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_time_exp_gmt_get(apr_time_t *result, + apr_time_exp_t *input); + +/** @deprecated @see apr_time_exp_gmt_get */ +APR_DECLARE(apr_status_t) apr_implode_gmt(apr_time_t *result, + apr_time_exp_t *input); + +/** + * 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. + */ +APR_DECLARE(void) apr_sleep(apr_interval_time_t t); + +/** length of a RFC822 Date */ +#define 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 + */ +APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t); + +/** length of a CTIME date */ +#define 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 + */ +APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t); + +/** + * 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 + */ +APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize, + apr_size_t max, const char *format, + apr_time_exp_t *tm); + +/** + * 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 + */ +APR_DECLARE(void) apr_time_clock_hires(apr_pool_t *p); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_TIME_H */ diff --git a/rubbos/app/apache2/include/apr_uri.h b/rubbos/app/apache2/include/apr_uri.h new file mode 100644 index 00000000..877e51a0 --- /dev/null +++ b/rubbos/app/apache2/include/apr_uri.h @@ -0,0 +1,181 @@ +/* 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. + */ + +/* + * apr_uri.h: External Interface of apr_uri.c + */ + +/** + * @file apr_uri.h + * @brief APR-UTIL URI Routines + */ + +#ifndef APR_URI_H +#define APR_URI_H + +#include "apu.h" + +#include "apr_network_io.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup APR_Util_URI URI + * @ingroup APR_Util + * @{ + */ + +#define APR_URI_FTP_DEFAULT_PORT 21 /**< default FTP port */ +#define APR_URI_SSH_DEFAULT_PORT 22 /**< default SSH port */ +#define APR_URI_TELNET_DEFAULT_PORT 23 /**< default telnet port */ +#define APR_URI_GOPHER_DEFAULT_PORT 70 /**< default Gopher port */ +#define APR_URI_HTTP_DEFAULT_PORT 80 /**< default HTTP port */ +#define APR_URI_POP_DEFAULT_PORT 110 /**< default POP port */ +#define APR_URI_NNTP_DEFAULT_PORT 119 /**< default NNTP port */ +#define APR_URI_IMAP_DEFAULT_PORT 143 /**< default IMAP port */ +#define APR_URI_PROSPERO_DEFAULT_PORT 191 /**< default Prospero port */ +#define APR_URI_WAIS_DEFAULT_PORT 210 /**< default WAIS port */ +#define APR_URI_LDAP_DEFAULT_PORT 389 /**< default LDAP port */ +#define APR_URI_HTTPS_DEFAULT_PORT 443 /**< default HTTPS port */ +#define APR_URI_RTSP_DEFAULT_PORT 554 /**< default RTSP port */ +#define APR_URI_SNEWS_DEFAULT_PORT 563 /**< default SNEWS port */ +#define APR_URI_ACAP_DEFAULT_PORT 674 /**< default ACAP port */ +#define APR_URI_NFS_DEFAULT_PORT 2049 /**< default NFS port */ +#define APR_URI_TIP_DEFAULT_PORT 3372 /**< default TIP port */ +#define APR_URI_SIP_DEFAULT_PORT 5060 /**< default SIP port */ + +/** Flags passed to unparse_uri_components(): */ +/** suppress "scheme://user\@site:port" */ +#define APR_URI_UNP_OMITSITEPART (1U<<0) +/** Just omit user */ +#define APR_URI_UNP_OMITUSER (1U<<1) +/** Just omit password */ +#define APR_URI_UNP_OMITPASSWORD (1U<<2) +/** omit "user:password\@" part */ +#define APR_URI_UNP_OMITUSERINFO (APR_URI_UNP_OMITUSER | \ + APR_URI_UNP_OMITPASSWORD) +/** Show plain text password (default: show XXXXXXXX) */ +#define APR_URI_UNP_REVEALPASSWORD (1U<<3) +/** Show "scheme://user\@site:port" only */ +#define APR_URI_UNP_OMITPATHINFO (1U<<4) +/** Omit the "?queryarg" from the path */ +#define APR_URI_UNP_OMITQUERY (1U<<5) + +/** @see apr_uri_t */ +typedef struct apr_uri_t apr_uri_t; + +/** + * A structure to encompass all of the fields in a uri + */ +struct apr_uri_t { + /** scheme ("http"/"ftp"/...) */ + char *scheme; + /** combined [user[:password]\@]host[:port] */ + char *hostinfo; + /** user name, as in http://user:passwd\@host:port/ */ + char *user; + /** password, as in http://user:passwd\@host:port/ */ + char *password; + /** hostname from URI (or from Host: header) */ + char *hostname; + /** port string (integer representation is in "port") */ + char *port_str; + /** the request path (or "/" if only scheme://host was given) */ + char *path; + /** Everything after a '?' in the path, if present */ + char *query; + /** Trailing "#fragment" string, if present */ + char *fragment; + + /** structure returned from gethostbyname() */ + struct hostent *hostent; + + /** The port number, numeric, valid only if port_str != NULL */ + apr_port_t port; + + /** has the structure been initialized */ + unsigned is_initialized:1; + + /** has the DNS been looked up yet */ + unsigned dns_looked_up:1; + /** has the dns been resolved yet */ + unsigned dns_resolved:1; +}; + +/* apr_uri.c */ +/** + * Return the default port for a given scheme. The schemes recognized are + * http, ftp, https, gopher, wais, nntp, snews, and prospero + * @param scheme_str The string that contains the current scheme + * @return The default port for this scheme + */ +APU_DECLARE(apr_port_t) apr_uri_port_of_scheme(const char *scheme_str); + +/** @deprecated @see apr_uri_port_of_scheme */ +APU_DECLARE(apr_port_t) apr_uri_default_port_for_scheme(const char *scheme_str); + +/** + * Unparse a apr_uri_t structure to an URI string. Optionally + * suppress the password for security reasons. + * @param p The pool to allocate out of + * @param uptr All of the parts of the uri + * @param flags How to unparse the uri. One of: + *
+ *    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 + */ +APU_DECLARE(char *) apr_uri_unparse(apr_pool_t *p, + const apr_uri_t *uptr, + unsigned flags); + +/** + * 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 + */ +APU_DECLARE(apr_status_t) apr_uri_parse(apr_pool_t *p, const char *uri, + apr_uri_t *uptr); + +/** + * 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 + */ +APU_DECLARE(apr_status_t) apr_uri_parse_hostinfo(apr_pool_t *p, + const char *hostinfo, + apr_uri_t *uptr); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* APR_URI_H */ diff --git a/rubbos/app/apache2/include/apr_user.h b/rubbos/app/apache2/include/apr_user.h new file mode 100644 index 00000000..d96d5407 --- /dev/null +++ b/rubbos/app/apache2/include/apr_user.h @@ -0,0 +1,195 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_USER_H +#define APR_USER_H + +/** + * @file apr_user.h + * @brief APR User ID Services + */ + +#include "apr.h" +#include "apr_errno.h" +#include "apr_pools.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup apr_user User and Group ID Services + * @ingroup APR + * @{ + */ + +/** + * Structure for determining user ownership. + */ +#ifdef WIN32 +typedef PSID apr_uid_t; +#else +typedef uid_t apr_uid_t; +#endif + +/** + * Structure for determining group ownership. + */ +#ifdef WIN32 +typedef PSID apr_gid_t; +#else +typedef gid_t apr_gid_t; +#endif + +#if 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. + */ +APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid, + apr_gid_t *groupid, + apr_pool_t *p); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, + apr_pool_t *p); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid, + const char *username, apr_pool_t *p); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, + const char *username, + apr_pool_t *p); + +/** @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. + */ +#if defined(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. + */ +APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, + apr_gid_t groupid, apr_pool_t *p); + +/** @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. + */ +APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, + const char *groupname, apr_pool_t *p); + +/** @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. + */ +#if defined(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 */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_USER_H */ diff --git a/rubbos/app/apache2/include/apr_uuid.h b/rubbos/app/apache2/include/apr_uuid.h new file mode 100644 index 00000000..820d7409 --- /dev/null +++ b/rubbos/app/apache2/include/apr_uuid.h @@ -0,0 +1,76 @@ +/* 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_uuid.h + * @brief APR UUID library + */ +#ifndef APR_UUID_H +#define APR_UUID_H + +#include "apu.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup APR_UUID UUID Handling + * @ingroup APR + * @{ + */ + +/** + * we represent a UUID as a block of 16 bytes. + */ + +typedef struct { + unsigned char data[16]; /**< the actual UUID */ +} apr_uuid_t; + +/** UUIDs are formatted as: 00112233-4455-6677-8899-AABBCCDDEEFF */ +#define APR_UUID_FORMATTED_LENGTH 36 + + +/** + * Generate and return a (new) UUID + * @param uuid The resulting UUID + */ +APU_DECLARE(void) apr_uuid_get(apr_uuid_t *uuid); + +/** + * Format a UUID into a string, following the standard format + * @param buffer The buffer to place the formatted UUID string into. It must + * be at least APR_UUID_FORMATTED_LENGTH + 1 bytes long to hold + * the formatted UUID and a null terminator + * @param uuid The UUID to format + */ +APU_DECLARE(void) apr_uuid_format(char *buffer, const apr_uuid_t *uuid); + +/** + * Parse a standard-format string into a UUID + * @param uuid The resulting UUID + * @param uuid_str The formatted UUID + */ +APU_DECLARE(apr_status_t) apr_uuid_parse(apr_uuid_t *uuid, const char *uuid_str); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* APR_UUID_H */ diff --git a/rubbos/app/apache2/include/apr_version.h b/rubbos/app/apache2/include/apr_version.h new file mode 100644 index 00000000..08bcd288 --- /dev/null +++ b/rubbos/app/apache2/include/apr_version.h @@ -0,0 +1,115 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APR_VERSION_H +#define APR_VERSION_H + +#include "apr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @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. + */ +#define APR_MAJOR_VERSION 0 + +/** + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading APR_MAJOR_VERSION + */ +#define APR_MINOR_VERSION 9 + +/** patch level */ +#define APR_PATCH_VERSION 19 + +/** + * This symbol is defined for internal, "development" copies of APR. This + * symbol will be #undef'd for releases. + */ +/* #define 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. + */ +typedef struct { + int major; /**< major number */ + int minor; /**< minor number */ + int patch; /**< patch number */ + int is_dev; /**< is development (1 or 0) */ +} 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. + */ +APR_DECLARE(void) apr_version(apr_version_t *pvsn); + +/** Return APR's version information as a string. */ +APR_DECLARE(const char *) apr_version_string(void); + + +/** Internal: string form of the "is dev" flag */ +#ifdef APR_IS_DEV_VERSION +#define APR_IS_DEV_STRING "-dev" +#else +#define APR_IS_DEV_STRING "" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* APR_VERSION_H */ diff --git a/rubbos/app/apache2/include/apr_want.h b/rubbos/app/apache2/include/apr_want.h new file mode 100644 index 00000000..39cc4fcb --- /dev/null +++ b/rubbos/app/apache2/include/apr_want.h @@ -0,0 +1,109 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "apr.h" /* configuration data */ +/** + * @file apr_want.h + * @brief APR Standard Headers Support + * + *
+ * Features:
+ *
+ *   APR_WANT_STRFUNC:  strcmp, strcat, strcpy, etc
+ *   APR_WANT_MEMFUNC:  memcmp, memcpy, etc
+ *   APR_WANT_STDIO:     and related bits
+ *   APR_WANT_IOVEC:    struct iovec
+ *   APR_WANT_BYTEFUNC: htons, htonl, ntohl, ntohs
+ *
+ * Typical usage:
+ *
+ *   #define APR_WANT_STRFUNC
+ *   #define APR_WANT_MEMFUNC
+ *   #include "apr_want.h"
+ *
+ * The appropriate headers will be included.
+ *
+ * Note: it is safe to use this in a header (it won't interfere with other
+ *       headers' or source files' use of apr_want.h)
+ * 
+ */ + +/* --------------------------------------------------------------------- */ + +#ifdef APR_WANT_STRFUNC + +#if APR_HAVE_STRING_H +#include +#endif +#if APR_HAVE_STRINGS_H +#include +#endif + +#undef APR_WANT_STRFUNC +#endif + +/* --------------------------------------------------------------------- */ + +#ifdef APR_WANT_MEMFUNC + +#if APR_HAVE_STRING_H +#include +#endif + +#undef APR_WANT_MEMFUNC +#endif + +/* --------------------------------------------------------------------- */ + +#ifdef APR_WANT_STDIO + +#if APR_HAVE_STDIO_H +#include +#endif + +#undef APR_WANT_STDIO +#endif + +/* --------------------------------------------------------------------- */ + +#ifdef APR_WANT_IOVEC + +#if APR_HAVE_SYS_UIO_H +#include +#endif + +#undef APR_WANT_IOVEC +#endif + +/* --------------------------------------------------------------------- */ + +#ifdef APR_WANT_BYTEFUNC + +/* Single Unix says they are in arpa/inet.h. Linux has them in + * netinet/in.h. FreeBSD has them in arpa/inet.h but requires that + * netinet/in.h be included first. + */ +#if APR_HAVE_NETINET_IN_H +#include +#endif +#if APR_HAVE_ARPA_INET_H +#include +#endif + +#undef APR_WANT_BYTEFUNC +#endif + +/* --------------------------------------------------------------------- */ diff --git a/rubbos/app/apache2/include/apr_xlate.h b/rubbos/app/apache2/include/apr_xlate.h new file mode 100644 index 00000000..92e77464 --- /dev/null +++ b/rubbos/app/apache2/include/apr_xlate.h @@ -0,0 +1,158 @@ +/* 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. + */ + +#ifndef APR_XLATE_H +#define APR_XLATE_H + +#include "apu.h" +#include "apr_pools.h" +#include "apr_errno.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file apr_xlate.h + * @brief APR I18N translation library + */ + +/** + * @defgroup APR_XLATE I18N translation library + * @ingroup APR + * @{ + */ +/** Opaque translation buffer */ +typedef struct apr_xlate_t apr_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). + */ +APU_DECLARE(apr_status_t) apr_xlate_open(apr_xlate_t **convset, + const char *topage, + const char *frompage, + apr_pool_t *pool); + +/** + * 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). + */ +APU_DECLARE(apr_status_t) apr_xlate_sb_get(apr_xlate_t *convset, int *onoff); + +/** @deprecated @see apr_xlate_sb_get */ +APU_DECLARE(apr_status_t) apr_xlate_get_sb(apr_xlate_t *convset, int *onoff); + +/** + * 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). + */ +APU_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset, + const char *inbuf, + apr_size_t *inbytes_left, + char *outbuf, + apr_size_t *outbytes_left); + +/* @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. + */ +APU_DECLARE(apr_int32_t) apr_xlate_conv_byte(apr_xlate_t *convset, + unsigned char inchar); + +/** + * 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). + */ +APU_DECLARE(apr_status_t) apr_xlate_close(apr_xlate_t *convset); + +/** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* ! APR_XLATE_H */ diff --git a/rubbos/app/apache2/include/apr_xml.h b/rubbos/app/apache2/include/apr_xml.h new file mode 100644 index 00000000..551283e6 --- /dev/null +++ b/rubbos/app/apache2/include/apr_xml.h @@ -0,0 +1,340 @@ +/* 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 + */ +#ifndef APR_XML_H +#define APR_XML_H + +/** + * @defgroup APR_Util_XML XML + * @ingroup APR_Util + * @{ + */ +#include "apr_pools.h" +#include "apr_tables.h" +#include "apr_file_io.h" + +#include "apu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Apache XML library + */ + +/* -------------------------------------------------------------------- */ + +/* ### these will need to move at some point to a more logical spot */ + +/** @see apr_text */ +typedef struct apr_text apr_text; + +/** Structure to keep a linked list of pieces of text */ +struct apr_text { + /** The current piece of text */ + const char *text; + /** a pointer to the next piece of text */ + struct apr_text *next; +}; + +/** @see apr_text_header */ +typedef struct apr_text_header apr_text_header; + +/** A list of pieces of text */ +struct apr_text_header { + /** The first piece of text in the list */ + apr_text *first; + /** The last piece of text in the list */ + apr_text *last; +}; + +/** + * 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 + */ +APU_DECLARE(void) apr_text_append(apr_pool_t *p, apr_text_header *hdr, + const char *text); + + +/* -------------------------------------------------------------------- +** +** 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. +*/ +#define APR_XML_NS_DAV_ID 0 /**< namespace ID for "DAV:" */ +#define APR_XML_NS_NONE -10 /**< no namespace for this elem/attr */ + +#define APR_XML_NS_ERROR_BASE -100 /**< used only during processing */ +/** Is this namespace an error? */ +#define APR_XML_NS_IS_ERROR(e) ((e) <= APR_XML_NS_ERROR_BASE) + +/** @see apr_xml_attr */ +typedef struct apr_xml_attr apr_xml_attr; +/** @see apr_xml_elem */ +typedef struct apr_xml_elem apr_xml_elem; +/** @see apr_xml_doc */ +typedef struct apr_xml_doc apr_xml_doc; + +/** apr_xml_attr: holds a parsed XML attribute */ +struct apr_xml_attr { + /** attribute name */ + const char *name; + /** index into namespace array */ + int ns; + + /** attribute value */ + const char *value; + + /** next attribute */ + struct apr_xml_attr *next; +}; + +/** apr_xml_elem: holds a parsed XML element */ +struct apr_xml_elem { + /** element name */ + const char *name; + /** index into namespace array */ + int ns; + /** xml:lang for attrs/contents */ + const char *lang; + + /** cdata right after start tag */ + apr_text_header first_cdata; + /** cdata after MY end tag */ + apr_text_header following_cdata; + + /** parent element */ + struct apr_xml_elem *parent; + /** next (sibling) element */ + struct apr_xml_elem *next; + /** first child element */ + struct apr_xml_elem *first_child; + /** first attribute */ + struct apr_xml_attr *attr; + + /* used only during parsing */ + /** last child element */ + struct apr_xml_elem *last_child; + /** namespaces scoped by this elem */ + struct apr_xml_ns_scope *ns_scope; + + /* used by modules during request processing */ + /** Place for modules to store private data */ + void *priv; +}; + +/** 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 */ +struct apr_xml_doc { + /** root element */ + apr_xml_elem *root; + /** array of namespaces used */ + apr_array_header_t *namespaces; +}; + +/** Opaque XML parser structure */ +typedef struct apr_xml_parser apr_xml_parser; + +/** + * Create an XML parser + * @param pool The pool for allocating the parser and the parse results. + * @return The new parser. + */ +APU_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool); + +/** + * 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. + */ +APU_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p, + apr_xml_parser **parser, + apr_xml_doc **ppdoc, + apr_file_t *xmlfd, + apr_size_t buffer_length); + + +/** + * 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. + */ +APU_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser, + const char *data, + apr_size_t len); + +/** + * 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. + */ +APU_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser, + apr_xml_doc **pdoc); + +/** + * 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 + */ +APU_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser, + char *errbuf, + apr_size_t errbufsize); + + +/** + * 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 + */ +APU_DECLARE(void) apr_xml_to_text(apr_pool_t *p, const apr_xml_elem *elem, + int style, apr_array_header_t *namespaces, + int *ns_map, const char **pbuf, + apr_size_t *psize); + +/* style argument values: */ +#define APR_XML_X2T_FULL 0 /**< start tag, contents, end tag */ +#define APR_XML_X2T_INNER 1 /**< contents only */ +#define APR_XML_X2T_LANG_INNER 2 /**< xml:lang + inner contents */ +#define 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 + */ +APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t *p, + const apr_xml_elem *elem); + +/** + * 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. + */ +APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s, + int quotes); + +/** + * Quote an XML element + * @param p The pool to allocate out of + * @param elem The element to quote + */ +APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem); + +/* 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 + */ +APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array, + const char *uri); + +/** Get the URI item for this XML element */ +#define APR_XML_GET_URI_ITEM(ary, i) (((const char * const *)(ary)->elts)[i]) + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif /* APR_XML_H */ diff --git a/rubbos/app/apache2/include/apu.h b/rubbos/app/apache2/include/apu.h new file mode 100644 index 00000000..42edff8d --- /dev/null +++ b/rubbos/app/apache2/include/apu.h @@ -0,0 +1,85 @@ +/* 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. + */ + +/* + * apu.h is generated from apu.h.in by configure -- do not edit apu.h + */ +/* @file apu.h + * @brief APR-Utility main file + */ +/** + * @defgroup APR_Util APR Utility Functions + * @{ + */ + + +#ifndef APU_H +#define APU_H + +/** + * APU_DECLARE_EXPORT is defined when building the APR-UTIL dynamic library, + * so that all public symbols are exported. + * + * APU_DECLARE_STATIC is defined when including the APR-UTIL public headers, + * to provide static linkage when the dynamic library may be unavailable. + * + * APU_DECLARE_STATIC and APU_DECLARE_EXPORT are left undefined when + * including the APR-UTIL public headers, to import and link the symbols from + * the dynamic APR-UTIL library and assure appropriate indirection and calling + * conventions at compile time. + */ + +/** + * The public APR-UTIL functions are declared with APU_DECLARE(), so they may + * use the most appropriate calling convention. Public APR functions with + * variable arguments must use APU_DECLARE_NONSTD(). + * + * @deffunc APU_DECLARE(rettype) apr_func(args); + */ +#define APU_DECLARE(type) type +/** + * The public APR-UTIL functions using variable arguments are declared with + * APU_DECLARE_NONSTD(), as they must use the C language calling convention. + * + * @deffunc APU_DECLARE_NONSTD(rettype) apr_func(args, ...); + */ +#define APU_DECLARE_NONSTD(type) type +/** + * The public APR-UTIL variables are declared with APU_DECLARE_DATA. + * This assures the appropriate indirection is invoked at compile time. + * + * @deffunc APU_DECLARE_DATA type apr_variable; + * @tip APU_DECLARE_DATA extern type apr_variable; syntax is required for + * declarations within headers to properly import the variable. + */ +#define APU_DECLARE_DATA +/* + * we always have SDBM (it's in our codebase) + */ +#define APU_HAVE_SDBM 1 +#define APU_HAVE_GDBM 0 +#define APU_HAVE_NDBM 0 +#define APU_HAVE_DB 0 + +#if APU_HAVE_DB +#define APU_HAVE_DB_VERSION 0 +#endif /* APU_HAVE_DB */ + +#define APU_HAVE_APR_ICONV 0 +#define APU_HAVE_ICONV 1 +#define APR_HAS_XLATE (APU_HAVE_APR_ICONV || APU_HAVE_ICONV) + +#endif /* APU_H */ +/** @} */ diff --git a/rubbos/app/apache2/include/apu_compat.h b/rubbos/app/apache2/include/apu_compat.h new file mode 100644 index 00000000..533f4945 --- /dev/null +++ b/rubbos/app/apache2/include/apu_compat.h @@ -0,0 +1,116 @@ +/* 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 apu_compat.h + * @brief APR-UTIL Compabitlity Functions + * @deprecated These functions are only present for historical purposes + */ +#ifndef APU_COMPAT_H +#define APU_COMPAT_H +/** + * @defgroup APR_Util_compat 1.3 Compatibility Functions + * @ingroup APR_Util + * @{ + */ + + +/* Include the apr compatibility changes, since apr-util users are + * always apr users. + */ +#include "apr_compat.h" + +/* -------------------------------------------------------------------- + * redefine 1.3.x symbols to those that now live in libapr-util + */ +/** @deprecated @see apr_base64_decode */ +#define ap_base64decode apr_base64_decode +/** @deprecated @see apr_base64_decode_binary */ +#define ap_base64decode_binary apr_base64_decode_binary +/** @deprecated @see apr_base64_decode_len */ +#define ap_base64decode_len apr_base64_decode_len +/** @deprecated @see apr_base64_encode */ +#define ap_base64encode apr_base64_encode +/** @deprecated @see apr_base64_encode_binary */ +#define ap_base64encode_binary apr_base64_encode_binary +/** @deprecated @see apr_base64_encode_len */ +#define ap_base64encode_len apr_base64_encode_len +/** @deprecated @see apr_hook_deregister_all */ +#define ap_hook_deregister_all apr_hook_deregister_all +/** @deprecated @see apr_hook_sort_register */ +#define ap_hook_sort_register apr_hook_sort_register +/** @deprecated @see apr_hook_debug_show */ +#define ap_show_hook apr_hook_debug_show + +/* -------------------------------------------------------------------- + * the following symbols were moved from httpd-2.0/.../util_date.[ch] + */ +/** @deprecated @see apr_date_parse_http */ +#define ap_parseHTTPdate apr_date_parse_http +/** @deprecated @see apr_date_checkmask */ +#define ap_checkmask apr_date_checkmask + +/* -------------------------------------------------------------------- + * the following symbols were moved from httpd-2.0/.../util_xml.[ch] + */ +/** @deprecated @see apr_text */ +#define ap_text apr_text +/** @deprecated @see apr_text_header */ +#define ap_text_header apr_text_header +/** @deprecated @see apr_text_append */ +#define ap_text_append apr_text_append + +/** @deprecated @see APR_XML_NS_DAV_ID */ +#define AP_XML_NS_DAV_ID APR_XML_NS_DAV_ID +/** @deprecated @see APR_XML_NS_NONE */ +#define AP_XML_NS_NONE APR_XML_NS_NONE +/** @deprecated @see APR_XML_NS_ERROR_BASE */ +#define AP_XML_NS_ERROR_BASE APR_XML_NS_ERROR_BASE +/** @deprecated @see APR_XML_NS_IS_ERROR */ +#define AP_XML_NS_IS_ERROR(e) APR_XML_NS_IS_ERROR(e) +/** @deprecated @see APR_XML_ELEM_IS_EMPTY */ +#define AP_XML_ELEM_IS_EMPTY(e) APR_XML_ELEM_IS_EMPTY(e) + +/** @deprecated @see apr_xml_attr */ +#define ap_xml_attr apr_xml_attr +/** @deprecated @see apr_xml_elem */ +#define ap_xml_elem apr_xml_elem +/** @deprecated @see apr_xml_doc */ +#define ap_xml_doc apr_xml_doc + +/** @deprecated @see apr_xml_to_text */ +#define ap_xml_to_text apr_xml_to_text +/** @deprecated @see APR_XML_X2T_FULL */ +#define AP_XML_X2T_FULL APR_XML_X2T_FULL +/** @deprecated @see APR_XML_X2T_INNER */ +#define AP_XML_X2T_INNER APR_XML_X2T_INNER +/** @deprecated @see APR_XML_X2T_LANG_INNER */ +#define AP_XML_X2T_LANG_INNER APR_XML_X2T_LANG_INNER +/** @deprecated @see APR_XML_X2T_FULL_NS_LANG */ +#define AP_XML_X2T_FULL_NS_LANG APR_XML_X2T_FULL_NS_LANG + +/** @deprecated @see apr_xml_empty_elem */ +#define ap_xml_empty_elem apr_xml_empty_elem +/** @deprecated @see apr_xml_quote_string */ +#define ap_xml_quote_string apr_xml_quote_string +/** @deprecated @see apr_xml_quote_elem */ +#define ap_xml_quote_elem apr_xml_quote_elem +/** @deprecated @see apr_xml_insert_uri */ +#define ap_xml_insert_uri apr_xml_insert_uri +/** @deprecated @see APR_XML_GET_URI_ITEM */ +#define AP_XML_GET_URI_ITEM(a,i) APR_XML_GET_URI_ITEM(a,i) +/** @} */ +#endif /* APU_COMPAT_H */ diff --git a/rubbos/app/apache2/include/apu_version.h b/rubbos/app/apache2/include/apu_version.h new file mode 100644 index 00000000..248e8ef5 --- /dev/null +++ b/rubbos/app/apache2/include/apu_version.h @@ -0,0 +1,105 @@ +/* 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. + */ + +#ifndef APU_VERSION_H +#define APU_VERSION_H + +#include "apr_version.h" + +#include "apu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file apu_version.h + * @brief + * + * APR-util'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 APU by use of the compile-time + * constants and the use of the run-time query function. + * + * APU 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 APU. + */ + +/** 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. + */ +#define APU_MAJOR_VERSION 0 + +/** + * Minor API changes that do not cause binary compatibility problems. + * Should be reset to 0 when upgrading APU_MAJOR_VERSION + */ +#define APU_MINOR_VERSION 9 + +/** patch level */ +#define APU_PATCH_VERSION 19 + +/** + * This symbol is defined for internal, "development" copies of APU. This + * symbol will be #undef'd for releases. + */ +/* #define APU_IS_DEV_VERSION */ + + +/** The formatted string of APU's version */ +#define APU_VERSION_STRING \ + APR_STRINGIFY(APU_MAJOR_VERSION) "." \ + APR_STRINGIFY(APU_MINOR_VERSION) "." \ + APR_STRINGIFY(APU_PATCH_VERSION) \ + APU_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. + */ +APU_DECLARE(void) apu_version(apr_version_t *pvsn); + +/** Return APU's version information as a string. */ +APU_DECLARE(const char *) apu_version_string(void); + + +/** Internal: string form of the "is dev" flag */ +#ifdef APU_IS_DEV_VERSION +#define APU_IS_DEV_STRING "-dev" +#else +#define APU_IS_DEV_STRING "" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* APU_VERSION_H */ diff --git a/rubbos/app/apache2/include/apu_want.h b/rubbos/app/apache2/include/apu_want.h new file mode 100644 index 00000000..facf6b31 --- /dev/null +++ b/rubbos/app/apache2/include/apu_want.h @@ -0,0 +1,50 @@ +/* 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 "apu.h" /* configuration data */ + +/** + * @file apu_want.h + * @brief APR Standard Headers Support + * + *
+ * Features:
+ *
+ *   APU_WANT_DB:       
+ *
+ * Typical usage:
+ *
+ *   #define APU_WANT_DB
+ *   #include "apu_want.h"
+ *
+ * The appropriate headers will be included.
+ *
+ * Note: it is safe to use this in a header (it won't interfere with other
+ *       headers' or source files' use of apu_want.h)
+ * 
+ */ + +/* --------------------------------------------------------------------- */ + +#ifdef APU_WANT_DB + +#if APU_HAVE_DB +#include +#endif + +#undef APU_WANT_DB +#endif + +/* --------------------------------------------------------------------- */ diff --git a/rubbos/app/apache2/include/expat.h b/rubbos/app/apache2/include/expat.h new file mode 100644 index 00000000..f3130d45 --- /dev/null +++ b/rubbos/app/apache2/include/expat.h @@ -0,0 +1,1001 @@ +/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd + See the file COPYING for copying permission. +*/ + +#ifndef XmlParse_INCLUDED +#define XmlParse_INCLUDED 1 + +#ifdef __VMS +/* 0 1 2 3 0 1 2 3 + 1234567890123456789012345678901 1234567890123456789012345678901 */ +#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler +#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler +#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler +#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg +#endif + +#include + +#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) +#define XML_USE_MSC_EXTENSIONS 1 +#endif + +/* Expat tries very hard to make the API boundary very specifically + defined. There are two macros defined to control this boundary; + each of these can be defined before including this header to + achieve some different behavior, but doing so it not recommended or + tested frequently. + + XMLCALL - The calling convention to use for all calls across the + "library boundary." This will default to cdecl, and + try really hard to tell the compiler that's what we + want. + + XMLIMPORT - Whatever magic is needed to note that a function is + to be imported from a dynamically loaded library + (.dll, .so, or .sl, depending on your platform). + + The XMLCALL macro was added in Expat 1.95.7. The only one which is + expected to be directly useful in client code is XMLCALL. + + Note that on at least some Unix versions, the Expat library must be + compiled with the cdecl calling convention as the default since + system headers may assume the cdecl convention. +*/ +#ifndef XMLCALL +#if defined(XML_USE_MSC_EXTENSIONS) +#define XMLCALL __cdecl +#elif defined(__GNUC__) && defined(__i386) +#define XMLCALL __attribute__((cdecl)) +#else +/* For any platform which uses this definition and supports more than + one calling convention, we need to extend this definition to + declare the convention used on that platform, if it's possible to + do so. + + If this is the case for your platform, please file a bug report + with information on how to identify your platform via the C + pre-processor and how to specify the same calling convention as the + platform's malloc() implementation. +*/ +#define XMLCALL +#endif +#endif /* not defined XMLCALL */ + + +#if !defined(XML_STATIC) && !defined(XMLIMPORT) +#ifndef XML_BUILDING_EXPAT +/* using Expat from an application */ + +#ifdef XML_USE_MSC_EXTENSIONS +#define XMLIMPORT __declspec(dllimport) +#endif + +#endif +#endif /* not defined XML_STATIC */ + +/* If we didn't define it above, define it away: */ +#ifndef XMLIMPORT +#define XMLIMPORT +#endif + + +#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef XML_UNICODE_WCHAR_T +#define XML_UNICODE +#endif + +struct XML_ParserStruct; +typedef struct XML_ParserStruct *XML_Parser; + +#ifdef XML_UNICODE /* Information is UTF-16 encoded. */ +#ifdef XML_UNICODE_WCHAR_T +typedef wchar_t XML_Char; +typedef wchar_t XML_LChar; +#else +typedef unsigned short XML_Char; +typedef char XML_LChar; +#endif /* XML_UNICODE_WCHAR_T */ +#else /* Information is UTF-8 encoded. */ +typedef char XML_Char; +typedef char XML_LChar; +#endif /* XML_UNICODE */ + +/* Should this be defined using stdbool.h when C99 is available? */ +typedef unsigned char XML_Bool; +#define XML_TRUE ((XML_Bool) 1) +#define XML_FALSE ((XML_Bool) 0) + +/* The XML_Status enum gives the possible return values for several + API functions. The preprocessor #defines are included so this + stanza can be added to code that still needs to support older + versions of Expat 1.95.x: + + #ifndef XML_STATUS_OK + #define XML_STATUS_OK 1 + #define XML_STATUS_ERROR 0 + #endif + + Otherwise, the #define hackery is quite ugly and would have been + dropped. +*/ +enum XML_Status { + XML_STATUS_ERROR = 0, +#define XML_STATUS_ERROR XML_STATUS_ERROR + XML_STATUS_OK = 1 +#define XML_STATUS_OK XML_STATUS_OK +}; + +enum XML_Error { + XML_ERROR_NONE, + XML_ERROR_NO_MEMORY, + XML_ERROR_SYNTAX, + XML_ERROR_NO_ELEMENTS, + XML_ERROR_INVALID_TOKEN, + XML_ERROR_UNCLOSED_TOKEN, + XML_ERROR_PARTIAL_CHAR, + XML_ERROR_TAG_MISMATCH, + XML_ERROR_DUPLICATE_ATTRIBUTE, + XML_ERROR_JUNK_AFTER_DOC_ELEMENT, + XML_ERROR_PARAM_ENTITY_REF, + XML_ERROR_UNDEFINED_ENTITY, + XML_ERROR_RECURSIVE_ENTITY_REF, + XML_ERROR_ASYNC_ENTITY, + XML_ERROR_BAD_CHAR_REF, + XML_ERROR_BINARY_ENTITY_REF, + XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, + XML_ERROR_MISPLACED_XML_PI, + XML_ERROR_UNKNOWN_ENCODING, + XML_ERROR_INCORRECT_ENCODING, + XML_ERROR_UNCLOSED_CDATA_SECTION, + XML_ERROR_EXTERNAL_ENTITY_HANDLING, + XML_ERROR_NOT_STANDALONE, + XML_ERROR_UNEXPECTED_STATE, + XML_ERROR_ENTITY_DECLARED_IN_PE, + XML_ERROR_FEATURE_REQUIRES_XML_DTD, + XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, + XML_ERROR_UNBOUND_PREFIX +}; + +enum XML_Content_Type { + XML_CTYPE_EMPTY = 1, + XML_CTYPE_ANY, + XML_CTYPE_MIXED, + XML_CTYPE_NAME, + XML_CTYPE_CHOICE, + XML_CTYPE_SEQ +}; + +enum XML_Content_Quant { + XML_CQUANT_NONE, + XML_CQUANT_OPT, + XML_CQUANT_REP, + XML_CQUANT_PLUS +}; + +/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be + XML_CQUANT_NONE, and the other fields will be zero or NULL. + If type == XML_CTYPE_MIXED, then quant will be NONE or REP and + numchildren will contain number of elements that may be mixed in + and children point to an array of XML_Content cells that will be + all of XML_CTYPE_NAME type with no quantification. + + If type == XML_CTYPE_NAME, then the name points to the name, and + the numchildren field will be zero and children will be NULL. The + quant fields indicates any quantifiers placed on the name. + + CHOICE and SEQ will have name NULL, the number of children in + numchildren and children will point, recursively, to an array + of XML_Content cells. + + The EMPTY, ANY, and MIXED types will only occur at top level. +*/ + +typedef struct XML_cp XML_Content; + +struct XML_cp { + enum XML_Content_Type type; + enum XML_Content_Quant quant; + XML_Char * name; + unsigned int numchildren; + XML_Content * children; +}; + + +/* This is called for an element declaration. See above for + description of the model argument. It's the caller's responsibility + to free model when finished with it. +*/ +typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData, + const XML_Char *name, + XML_Content *model); + +XMLPARSEAPI(void) +XML_SetElementDeclHandler(XML_Parser parser, + XML_ElementDeclHandler eldecl); + +/* The Attlist declaration handler is called for *each* attribute. So + a single Attlist declaration with multiple attributes declared will + generate multiple calls to this handler. The "default" parameter + may be NULL in the case of the "#IMPLIED" or "#REQUIRED" + keyword. The "isrequired" parameter will be true and the default + value will be NULL in the case of "#REQUIRED". If "isrequired" is + true and default is non-NULL, then this is a "#FIXED" default. +*/ +typedef void (XMLCALL *XML_AttlistDeclHandler) ( + void *userData, + const XML_Char *elname, + const XML_Char *attname, + const XML_Char *att_type, + const XML_Char *dflt, + int isrequired); + +XMLPARSEAPI(void) +XML_SetAttlistDeclHandler(XML_Parser parser, + XML_AttlistDeclHandler attdecl); + +/* The XML declaration handler is called for *both* XML declarations + and text declarations. The way to distinguish is that the version + parameter will be NULL for text declarations. The encoding + parameter may be NULL for XML declarations. The standalone + parameter will be -1, 0, or 1 indicating respectively that there + was no standalone parameter in the declaration, that it was given + as no, or that it was given as yes. +*/ +typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData, + const XML_Char *version, + const XML_Char *encoding, + int standalone); + +XMLPARSEAPI(void) +XML_SetXmlDeclHandler(XML_Parser parser, + XML_XmlDeclHandler xmldecl); + + +typedef struct { + void *(XMLCALL *malloc_fcn)(size_t size); + void *(XMLCALL *realloc_fcn)(void *ptr, size_t size); + void (XMLCALL *free_fcn)(void *ptr); +} XML_Memory_Handling_Suite; + +/* Constructs a new parser; encoding is the encoding specified by the + external protocol or NULL if there is none specified. +*/ +XMLPARSEAPI(XML_Parser) +XML_ParserCreate(const XML_Char *encoding); + +/* Constructs a new parser and namespace processor. Element type + names and attribute names that belong to a namespace will be + expanded; unprefixed attribute names are never expanded; unprefixed + element type names are expanded only if there is a default + namespace. The expanded name is the concatenation of the namespace + URI, the namespace separator character, and the local part of the + name. If the namespace separator is '\0' then the namespace URI + and the local part will be concatenated without any separator. + When a namespace is not declared, the name and prefix will be + passed through without expansion. +*/ +XMLPARSEAPI(XML_Parser) +XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); + + +/* Constructs a new parser using the memory management suite referred to + by memsuite. If memsuite is NULL, then use the standard library memory + suite. If namespaceSeparator is non-NULL it creates a parser with + namespace processing as described above. The character pointed at + will serve as the namespace separator. + + All further memory operations used for the created parser will come from + the given suite. +*/ +XMLPARSEAPI(XML_Parser) +XML_ParserCreate_MM(const XML_Char *encoding, + const XML_Memory_Handling_Suite *memsuite, + const XML_Char *namespaceSeparator); + +/* Prepare a parser object to be re-used. This is particularly + valuable when memory allocation overhead is disproportionatly high, + such as when a large number of small documnents need to be parsed. + All handlers are cleared from the parser, except for the + unknownEncodingHandler. The parser's external state is re-initialized + except for the values of ns and ns_triplets. + + Added in Expat 1.95.3. +*/ +XMLPARSEAPI(XML_Bool) +XML_ParserReset(XML_Parser parser, const XML_Char *encoding); + +/* atts is array of name/value pairs, terminated by 0; + names and values are 0 terminated. +*/ +typedef void (XMLCALL *XML_StartElementHandler) (void *userData, + const XML_Char *name, + const XML_Char **atts); + +typedef void (XMLCALL *XML_EndElementHandler) (void *userData, + const XML_Char *name); + + +/* s is not 0 terminated. */ +typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData, + const XML_Char *s, + int len); + +/* target and data are 0 terminated */ +typedef void (XMLCALL *XML_ProcessingInstructionHandler) ( + void *userData, + const XML_Char *target, + const XML_Char *data); + +/* data is 0 terminated */ +typedef void (XMLCALL *XML_CommentHandler) (void *userData, + const XML_Char *data); + +typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData); +typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData); + +/* This is called for any characters in the XML document for which + there is no applicable handler. This includes both characters that + are part of markup which is of a kind that is not reported + (comments, markup declarations), or characters that are part of a + construct which could be reported but for which no handler has been + supplied. The characters are passed exactly as they were in the XML + document except that they will be encoded in UTF-8 or UTF-16. + Line boundaries are not normalized. Note that a byte order mark + character is not passed to the default handler. There are no + guarantees about how characters are divided between calls to the + default handler: for example, a comment might be split between + multiple calls. +*/ +typedef void (XMLCALL *XML_DefaultHandler) (void *userData, + const XML_Char *s, + int len); + +/* This is called for the start of the DOCTYPE declaration, before + any DTD or internal subset is parsed. +*/ +typedef void (XMLCALL *XML_StartDoctypeDeclHandler) ( + void *userData, + const XML_Char *doctypeName, + const XML_Char *sysid, + const XML_Char *pubid, + int has_internal_subset); + +/* This is called for the start of the DOCTYPE declaration when the + closing > is encountered, but after processing any external + subset. +*/ +typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); + +/* This is called for entity declarations. The is_parameter_entity + argument will be non-zero if the entity is a parameter entity, zero + otherwise. + + For internal entities (), value will + be non-NULL and systemId, publicID, and notationName will be NULL. + The value string is NOT nul-terminated; the length is provided in + the value_length argument. Since it is legal to have zero-length + values, do not use this argument to test for internal entities. + + For external entities, value will be NULL and systemId will be + non-NULL. The publicId argument will be NULL unless a public + identifier was provided. The notationName argument will have a + non-NULL value only for unparsed entity declarations. + + Note that is_parameter_entity can't be changed to XML_Bool, since + that would break binary compatibility. +*/ +typedef void (XMLCALL *XML_EntityDeclHandler) ( + void *userData, + const XML_Char *entityName, + int is_parameter_entity, + const XML_Char *value, + int value_length, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId, + const XML_Char *notationName); + +XMLPARSEAPI(void) +XML_SetEntityDeclHandler(XML_Parser parser, + XML_EntityDeclHandler handler); + +/* OBSOLETE -- OBSOLETE -- OBSOLETE + This handler has been superceded by the EntityDeclHandler above. + It is provided here for backward compatibility. + + This is called for a declaration of an unparsed (NDATA) entity. + The base argument is whatever was set by XML_SetBase. The + entityName, systemId and notationName arguments will never be + NULL. The other arguments may be. +*/ +typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) ( + void *userData, + const XML_Char *entityName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId, + const XML_Char *notationName); + +/* This is called for a declaration of notation. The base argument is + whatever was set by XML_SetBase. The notationName will never be + NULL. The other arguments can be. +*/ +typedef void (XMLCALL *XML_NotationDeclHandler) ( + void *userData, + const XML_Char *notationName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); + +/* When namespace processing is enabled, these are called once for + each namespace declaration. The call to the start and end element + handlers occur between the calls to the start and end namespace + declaration handlers. For an xmlns attribute, prefix will be + NULL. For an xmlns="" attribute, uri will be NULL. +*/ +typedef void (XMLCALL *XML_StartNamespaceDeclHandler) ( + void *userData, + const XML_Char *prefix, + const XML_Char *uri); + +typedef void (XMLCALL *XML_EndNamespaceDeclHandler) ( + void *userData, + const XML_Char *prefix); + +/* This is called if the document is not standalone, that is, it has an + external subset or a reference to a parameter entity, but does not + have standalone="yes". If this handler returns XML_STATUS_ERROR, + then processing will not continue, and the parser will return a + XML_ERROR_NOT_STANDALONE error. + If parameter entity parsing is enabled, then in addition to the + conditions above this handler will only be called if the referenced + entity was actually read. +*/ +typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData); + +/* This is called for a reference to an external parsed general + entity. The referenced entity is not automatically parsed. The + application can parse it immediately or later using + XML_ExternalEntityParserCreate. + + The parser argument is the parser parsing the entity containing the + reference; it can be passed as the parser argument to + XML_ExternalEntityParserCreate. The systemId argument is the + system identifier as specified in the entity declaration; it will + not be NULL. + + The base argument is the system identifier that should be used as + the base for resolving systemId if systemId was relative; this is + set by XML_SetBase; it may be NULL. + + The publicId argument is the public identifier as specified in the + entity declaration, or NULL if none was specified; the whitespace + in the public identifier will have been normalized as required by + the XML spec. + + The context argument specifies the parsing context in the format + expected by the context argument to XML_ExternalEntityParserCreate; + context is valid only until the handler returns, so if the + referenced entity is to be parsed later, it must be copied. + context is NULL only when the entity is a parameter entity. + + The handler should return XML_STATUS_ERROR if processing should not + continue because of a fatal error in the handling of the external + entity. In this case the calling parser will return an + XML_ERROR_EXTERNAL_ENTITY_HANDLING error. + + Note that unlike other handlers the first argument is the parser, + not userData. +*/ +typedef int (XMLCALL *XML_ExternalEntityRefHandler) ( + XML_Parser parser, + const XML_Char *context, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); + +/* This is called in two situations: + 1) An entity reference is encountered for which no declaration + has been read *and* this is not an error. + 2) An internal entity reference is read, but not expanded, because + XML_SetDefaultHandler has been called. + Note: skipped parameter entities in declarations and skipped general + entities in attribute values cannot be reported, because + the event would be out of sync with the reporting of the + declarations or attribute values +*/ +typedef void (XMLCALL *XML_SkippedEntityHandler) ( + void *userData, + const XML_Char *entityName, + int is_parameter_entity); + +/* This structure is filled in by the XML_UnknownEncodingHandler to + provide information to the parser about encodings that are unknown + to the parser. + + The map[b] member gives information about byte sequences whose + first byte is b. + + If map[b] is c where c is >= 0, then b by itself encodes the + Unicode scalar value c. + + If map[b] is -1, then the byte sequence is malformed. + + If map[b] is -n, where n >= 2, then b is the first byte of an + n-byte sequence that encodes a single Unicode scalar value. + + The data member will be passed as the first argument to the convert + function. + + The convert function is used to convert multibyte sequences; s will + point to a n-byte sequence where map[(unsigned char)*s] == -n. The + convert function must return the Unicode scalar value represented + by this byte sequence or -1 if the byte sequence is malformed. + + The convert function may be NULL if the encoding is a single-byte + encoding, that is if map[b] >= -1 for all bytes b. + + When the parser is finished with the encoding, then if release is + not NULL, it will call release passing it the data member; once + release has been called, the convert function will not be called + again. + + Expat places certain restrictions on the encodings that are supported + using this mechanism. + + 1. Every ASCII character that can appear in a well-formed XML document, + other than the characters + + $@\^`{}~ + + must be represented by a single byte, and that byte must be the + same byte that represents that character in ASCII. + + 2. No character may require more than 4 bytes to encode. + + 3. All characters encoded must have Unicode scalar values <= + 0xFFFF, (i.e., characters that would be encoded by surrogates in + UTF-16 are not allowed). Note that this restriction doesn't + apply to the built-in support for UTF-8 and UTF-16. + + 4. No Unicode character may be encoded by more than one distinct + sequence of bytes. +*/ +typedef struct { + int map[256]; + void *data; + int (XMLCALL *convert)(void *data, const char *s); + void (XMLCALL *release)(void *data); +} XML_Encoding; + +/* This is called for an encoding that is unknown to the parser. + + The encodingHandlerData argument is that which was passed as the + second argument to XML_SetUnknownEncodingHandler. + + The name argument gives the name of the encoding as specified in + the encoding declaration. + + If the callback can provide information about the encoding, it must + fill in the XML_Encoding structure, and return XML_STATUS_OK. + Otherwise it must return XML_STATUS_ERROR. + + If info does not describe a suitable encoding, then the parser will + return an XML_UNKNOWN_ENCODING error. +*/ +typedef int (XMLCALL *XML_UnknownEncodingHandler) ( + void *encodingHandlerData, + const XML_Char *name, + XML_Encoding *info); + +XMLPARSEAPI(void) +XML_SetElementHandler(XML_Parser parser, + XML_StartElementHandler start, + XML_EndElementHandler end); + +XMLPARSEAPI(void) +XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); + +XMLPARSEAPI(void) +XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler); + +XMLPARSEAPI(void) +XML_SetCharacterDataHandler(XML_Parser parser, + XML_CharacterDataHandler handler); + +XMLPARSEAPI(void) +XML_SetProcessingInstructionHandler(XML_Parser parser, + XML_ProcessingInstructionHandler handler); +XMLPARSEAPI(void) +XML_SetCommentHandler(XML_Parser parser, + XML_CommentHandler handler); + +XMLPARSEAPI(void) +XML_SetCdataSectionHandler(XML_Parser parser, + XML_StartCdataSectionHandler start, + XML_EndCdataSectionHandler end); + +XMLPARSEAPI(void) +XML_SetStartCdataSectionHandler(XML_Parser parser, + XML_StartCdataSectionHandler start); + +XMLPARSEAPI(void) +XML_SetEndCdataSectionHandler(XML_Parser parser, + XML_EndCdataSectionHandler end); + +/* This sets the default handler and also inhibits expansion of + internal entities. These entity references will be passed to the + default handler, or to the skipped entity handler, if one is set. +*/ +XMLPARSEAPI(void) +XML_SetDefaultHandler(XML_Parser parser, + XML_DefaultHandler handler); + +/* This sets the default handler but does not inhibit expansion of + internal entities. The entity reference will not be passed to the + default handler. +*/ +XMLPARSEAPI(void) +XML_SetDefaultHandlerExpand(XML_Parser parser, + XML_DefaultHandler handler); + +XMLPARSEAPI(void) +XML_SetDoctypeDeclHandler(XML_Parser parser, + XML_StartDoctypeDeclHandler start, + XML_EndDoctypeDeclHandler end); + +XMLPARSEAPI(void) +XML_SetStartDoctypeDeclHandler(XML_Parser parser, + XML_StartDoctypeDeclHandler start); + +XMLPARSEAPI(void) +XML_SetEndDoctypeDeclHandler(XML_Parser parser, + XML_EndDoctypeDeclHandler end); + +XMLPARSEAPI(void) +XML_SetUnparsedEntityDeclHandler(XML_Parser parser, + XML_UnparsedEntityDeclHandler handler); + +XMLPARSEAPI(void) +XML_SetNotationDeclHandler(XML_Parser parser, + XML_NotationDeclHandler handler); + +XMLPARSEAPI(void) +XML_SetNamespaceDeclHandler(XML_Parser parser, + XML_StartNamespaceDeclHandler start, + XML_EndNamespaceDeclHandler end); + +XMLPARSEAPI(void) +XML_SetStartNamespaceDeclHandler(XML_Parser parser, + XML_StartNamespaceDeclHandler start); + +XMLPARSEAPI(void) +XML_SetEndNamespaceDeclHandler(XML_Parser parser, + XML_EndNamespaceDeclHandler end); + +XMLPARSEAPI(void) +XML_SetNotStandaloneHandler(XML_Parser parser, + XML_NotStandaloneHandler handler); + +XMLPARSEAPI(void) +XML_SetExternalEntityRefHandler(XML_Parser parser, + XML_ExternalEntityRefHandler handler); + +/* If a non-NULL value for arg is specified here, then it will be + passed as the first argument to the external entity ref handler + instead of the parser object. +*/ +XMLPARSEAPI(void) +XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); + +XMLPARSEAPI(void) +XML_SetSkippedEntityHandler(XML_Parser parser, + XML_SkippedEntityHandler handler); + +XMLPARSEAPI(void) +XML_SetUnknownEncodingHandler(XML_Parser parser, + XML_UnknownEncodingHandler handler, + void *encodingHandlerData); + +/* This can be called within a handler for a start element, end + element, processing instruction or character data. It causes the + corresponding markup to be passed to the default handler. +*/ +XMLPARSEAPI(void) +XML_DefaultCurrent(XML_Parser parser); + +/* If do_nst is non-zero, and namespace processing is in effect, and + a name has a prefix (i.e. an explicit namespace qualifier) then + that name is returned as a triplet in a single string separated by + the separator character specified when the parser was created: URI + + sep + local_name + sep + prefix. + + If do_nst is zero, then namespace information is returned in the + default manner (URI + sep + local_name) whether or not the name + has a prefix. + + Note: Calling XML_SetReturnNSTriplet after XML_Parse or + XML_ParseBuffer has no effect. +*/ + +XMLPARSEAPI(void) +XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); + +/* This value is passed as the userData argument to callbacks. */ +XMLPARSEAPI(void) +XML_SetUserData(XML_Parser parser, void *userData); + +/* Returns the last value set by XML_SetUserData or NULL. */ +#define XML_GetUserData(parser) (*(void **)(parser)) + +/* This is equivalent to supplying an encoding argument to + XML_ParserCreate. On success XML_SetEncoding returns non-zero, + zero otherwise. + Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer + has no effect and returns XML_STATUS_ERROR. +*/ +XMLPARSEAPI(enum XML_Status) +XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); + +/* If this function is called, then the parser will be passed as the + first argument to callbacks instead of userData. The userData will + still be accessible using XML_GetUserData. +*/ +XMLPARSEAPI(void) +XML_UseParserAsHandlerArg(XML_Parser parser); + +/* If useDTD == XML_TRUE is passed to this function, then the parser + will assume that there is an external subset, even if none is + specified in the document. In such a case the parser will call the + externalEntityRefHandler with a value of NULL for the systemId + argument (the publicId and context arguments will be NULL as well). + Note: If this function is called, then this must be done before + the first call to XML_Parse or XML_ParseBuffer, since it will + have no effect after that. Returns + XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. + Note: If the document does not have a DOCTYPE declaration at all, + then startDoctypeDeclHandler and endDoctypeDeclHandler will not + be called, despite an external subset being parsed. + Note: If XML_DTD is not defined when Expat is compiled, returns + XML_ERROR_FEATURE_REQUIRES_XML_DTD. +*/ +XMLPARSEAPI(enum XML_Error) +XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); + + +/* Sets the base to be used for resolving relative URIs in system + identifiers in declarations. Resolving relative identifiers is + left to the application: this value will be passed through as the + base argument to the XML_ExternalEntityRefHandler, + XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base + argument will be copied. Returns XML_STATUS_ERROR if out of memory, + XML_STATUS_OK otherwise. +*/ +XMLPARSEAPI(enum XML_Status) +XML_SetBase(XML_Parser parser, const XML_Char *base); + +XMLPARSEAPI(const XML_Char *) +XML_GetBase(XML_Parser parser); + +/* Returns the number of the attribute/value pairs passed in last call + to the XML_StartElementHandler that were specified in the start-tag + rather than defaulted. Each attribute/value pair counts as 2; thus + this correspondds to an index into the atts array passed to the + XML_StartElementHandler. +*/ +XMLPARSEAPI(int) +XML_GetSpecifiedAttributeCount(XML_Parser parser); + +/* Returns the index of the ID attribute passed in the last call to + XML_StartElementHandler, or -1 if there is no ID attribute. Each + attribute/value pair counts as 2; thus this correspondds to an + index into the atts array passed to the XML_StartElementHandler. +*/ +XMLPARSEAPI(int) +XML_GetIdAttributeIndex(XML_Parser parser); + +/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is + detected. The last call to XML_Parse must have isFinal true; len + may be zero for this call (or any other). + + Though the return values for these functions has always been + described as a Boolean value, the implementation, at least for the + 1.95.x series, has always returned exactly one of the XML_Status + values. +*/ +XMLPARSEAPI(enum XML_Status) +XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); + +XMLPARSEAPI(void *) +XML_GetBuffer(XML_Parser parser, int len); + +XMLPARSEAPI(enum XML_Status) +XML_ParseBuffer(XML_Parser parser, int len, int isFinal); + +/* Creates an XML_Parser object that can parse an external general + entity; context is a '\0'-terminated string specifying the parse + context; encoding is a '\0'-terminated string giving the name of + the externally specified encoding, or NULL if there is no + externally specified encoding. The context string consists of a + sequence of tokens separated by formfeeds (\f); a token consisting + of a name specifies that the general entity of the name is open; a + token of the form prefix=uri specifies the namespace for a + particular prefix; a token of the form =uri specifies the default + namespace. This can be called at any point after the first call to + an ExternalEntityRefHandler so longer as the parser has not yet + been freed. The new parser is completely independent and may + safely be used in a separate thread. The handlers and userData are + initialized from the parser argument. Returns NULL if out of memory. + Otherwise returns a new XML_Parser object. +*/ +XMLPARSEAPI(XML_Parser) +XML_ExternalEntityParserCreate(XML_Parser parser, + const XML_Char *context, + const XML_Char *encoding); + +enum XML_ParamEntityParsing { + XML_PARAM_ENTITY_PARSING_NEVER, + XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, + XML_PARAM_ENTITY_PARSING_ALWAYS +}; + +/* Controls parsing of parameter entities (including the external DTD + subset). If parsing of parameter entities is enabled, then + references to external parameter entities (including the external + DTD subset) will be passed to the handler set with + XML_SetExternalEntityRefHandler. The context passed will be 0. + + Unlike external general entities, external parameter entities can + only be parsed synchronously. If the external parameter entity is + to be parsed, it must be parsed during the call to the external + entity ref handler: the complete sequence of + XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and + XML_ParserFree calls must be made during this call. After + XML_ExternalEntityParserCreate has been called to create the parser + for the external parameter entity (context must be 0 for this + call), it is illegal to make any calls on the old parser until + XML_ParserFree has been called on the newly created parser. + If the library has been compiled without support for parameter + entity parsing (ie without XML_DTD being defined), then + XML_SetParamEntityParsing will return 0 if parsing of parameter + entities is requested; otherwise it will return non-zero. + Note: If XML_SetParamEntityParsing is called after XML_Parse or + XML_ParseBuffer, then it has no effect and will always return 0. +*/ +XMLPARSEAPI(int) +XML_SetParamEntityParsing(XML_Parser parser, + enum XML_ParamEntityParsing parsing); + +/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then + XML_GetErrorCode returns information about the error. +*/ +XMLPARSEAPI(enum XML_Error) +XML_GetErrorCode(XML_Parser parser); + +/* These functions return information about the current parse + location. They may be called from any callback called to report + some parse event; in this case the location is the location of the + first of the sequence of characters that generated the event. When + called from callbacks generated by declarations in the document + prologue, the location identified isn't as neatly defined, but will + be within the relevant markup. When called outside of the callback + functions, the position indicated will be just past the last parse + event (regardless of whether there was an associated callback). + + They may also be called after returning from a call to XML_Parse + or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then + the location is the location of the character at which the error + was detected; otherwise the location is the location of the last + parse event, as described above. +*/ +XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser); +XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser); +XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser); + +/* Return the number of bytes in the current event. + Returns 0 if the event is in an internal entity. +*/ +XMLPARSEAPI(int) +XML_GetCurrentByteCount(XML_Parser parser); + +/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets + the integer pointed to by offset to the offset within this buffer + of the current parse position, and sets the integer pointed to by size + to the size of this buffer (the number of input bytes). Otherwise + returns a NULL pointer. Also returns a NULL pointer if a parse isn't + active. + + NOTE: The character pointer returned should not be used outside + the handler that makes the call. +*/ +XMLPARSEAPI(const char *) +XML_GetInputContext(XML_Parser parser, + int *offset, + int *size); + +/* For backwards compatibility with previous versions. */ +#define XML_GetErrorLineNumber XML_GetCurrentLineNumber +#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber +#define XML_GetErrorByteIndex XML_GetCurrentByteIndex + +/* Frees the content model passed to the element declaration handler */ +XMLPARSEAPI(void) +XML_FreeContentModel(XML_Parser parser, XML_Content *model); + +/* Exposing the memory handling functions used in Expat */ +XMLPARSEAPI(void *) +XML_MemMalloc(XML_Parser parser, size_t size); + +XMLPARSEAPI(void *) +XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); + +XMLPARSEAPI(void) +XML_MemFree(XML_Parser parser, void *ptr); + +/* Frees memory used by the parser. */ +XMLPARSEAPI(void) +XML_ParserFree(XML_Parser parser); + +/* Returns a string describing the error. */ +XMLPARSEAPI(const XML_LChar *) +XML_ErrorString(enum XML_Error code); + +/* Return a string containing the version number of this expat */ +XMLPARSEAPI(const XML_LChar *) +XML_ExpatVersion(void); + +typedef struct { + int major; + int minor; + int micro; +} XML_Expat_Version; + +/* Return an XML_Expat_Version structure containing numeric version + number information for this version of expat. +*/ +XMLPARSEAPI(XML_Expat_Version) +XML_ExpatVersionInfo(void); + +/* Added in Expat 1.95.5. */ +enum XML_FeatureEnum { + XML_FEATURE_END = 0, + XML_FEATURE_UNICODE, + XML_FEATURE_UNICODE_WCHAR_T, + XML_FEATURE_DTD, + XML_FEATURE_CONTEXT_BYTES, + XML_FEATURE_MIN_SIZE, + XML_FEATURE_SIZEOF_XML_CHAR, + XML_FEATURE_SIZEOF_XML_LCHAR + /* Additional features must be added to the end of this enum. */ +}; + +typedef struct { + enum XML_FeatureEnum feature; + const XML_LChar *name; + long int value; +} XML_Feature; + +XMLPARSEAPI(const XML_Feature *) +XML_GetFeatureList(void); + + +/* Expat follows the GNU/Linux convention of odd number minor version for + beta/development releases and even number minor version for stable + releases. Micro is bumped with each release, and set to 0 with each + change to major or minor version. +*/ +#define XML_MAJOR_VERSION 1 +#define XML_MINOR_VERSION 95 +#define XML_MICRO_VERSION 7 + +#ifdef __cplusplus +} +#endif + +#endif /* not XmlParse_INCLUDED */ diff --git a/rubbos/app/apache2/include/fdqueue.h b/rubbos/app/apache2/include/fdqueue.h new file mode 100644 index 00000000..6dd55e03 --- /dev/null +++ b/rubbos/app/apache2/include/fdqueue.h @@ -0,0 +1,64 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FDQUEUE_H +#define FDQUEUE_H +#include "httpd.h" +#include +#if APR_HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#if APR_HAVE_SYS_SOCKET_H +#include +#endif +#include + +typedef struct fd_queue_info_t fd_queue_info_t; + +apr_status_t ap_queue_info_create(fd_queue_info_t **queue_info, + apr_pool_t *pool, int max_idlers); +apr_status_t ap_queue_info_set_idle(fd_queue_info_t *queue_info, + apr_pool_t *pool_to_recycle); +apr_status_t ap_queue_info_wait_for_idler(fd_queue_info_t *queue_info, + apr_pool_t **recycled_pool); +apr_status_t ap_queue_info_term(fd_queue_info_t *queue_info); + +struct fd_queue_elem_t { + apr_socket_t *sd; + apr_pool_t *p; +}; +typedef struct fd_queue_elem_t fd_queue_elem_t; + +struct fd_queue_t { + fd_queue_elem_t *data; + int nelts; + int bounds; + apr_thread_mutex_t *one_big_mutex; + apr_thread_cond_t *not_empty; + int terminated; +}; +typedef struct fd_queue_t fd_queue_t; + +apr_status_t ap_queue_init(fd_queue_t *queue, int queue_capacity, apr_pool_t *a); +apr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd, apr_pool_t *p); +apr_status_t ap_queue_pop(fd_queue_t *queue, apr_socket_t **sd, apr_pool_t **p); +apr_status_t ap_queue_interrupt_all(fd_queue_t *queue); +apr_status_t ap_queue_term(fd_queue_t *queue); + +#endif /* FDQUEUE_H */ diff --git a/rubbos/app/apache2/include/http_config.h b/rubbos/app/apache2/include/http_config.h new file mode 100644 index 00000000..783e44b4 --- /dev/null +++ b/rubbos/app/apache2/include/http_config.h @@ -0,0 +1,1018 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_CONFIG_H +#define APACHE_HTTP_CONFIG_H + +#include "apr_hooks.h" +#include "util_cfgtree.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file http_config.h + * @brief Apache Configuration + */ + +/* + * The central data structures around here... + */ + +/* Command dispatch structures... */ + +/** + * How the directives arguments should be parsed. + * @remark Note that for all of these except RAW_ARGS, the config routine is + * passed a freshly allocated string which can be modified or stored + * or whatever... + */ +enum cmd_how { + RAW_ARGS, /**< cmd_func parses command line itself */ + TAKE1, /**< one argument only */ + TAKE2, /**< two arguments only */ + ITERATE, /**< one argument, occuring multiple times + * (e.g., IndexIgnore) + */ + ITERATE2, /**< two arguments, 2nd occurs multiple times + * (e.g., AddIcon) + */ + FLAG, /**< One of 'On' or 'Off' */ + NO_ARGS, /**< No args at all, e.g. */ + TAKE12, /**< one or two arguments */ + TAKE3, /**< three arguments only */ + TAKE23, /**< two or three arguments */ + TAKE123, /**< one, two or three arguments */ + TAKE13 /**< one or three arguments */ +}; +/** + * This structure is passed to a command which is being invoked, + * to carry a large variety of miscellaneous data which is all of + * use to *somebody*... + */ +typedef struct cmd_parms_struct cmd_parms; + +#if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN) + +/** + * All the types of functions that can be used in directives + * @internal + */ +typedef union { + /** function to call for a no-args */ + const char *(*no_args) (cmd_parms *parms, void *mconfig); + /** function to call for a raw-args */ + const char *(*raw_args) (cmd_parms *parms, void *mconfig, + const char *args); + /** function to call for a take1 */ + const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w); + /** function to call for a take2 */ + const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w, + const char *w2); + /** function to call for a take3 */ + const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w, + const char *w2, const char *w3); + /** function to call for a flag */ + const char *(*flag) (cmd_parms *parms, void *mconfig, int on); +} cmd_func; + +/** This configuration directive does not take any arguments */ +# define AP_NO_ARGS func.no_args +/** This configuration directive will handle it's own parsing of arguments*/ +# define AP_RAW_ARGS func.raw_args +/** This configuration directive takes 1 argument*/ +# define AP_TAKE1 func.take1 +/** This configuration directive takes 2 arguments */ +# define AP_TAKE2 func.take2 +/** This configuration directive takes 3 arguments */ +# define AP_TAKE3 func.take3 +/** This configuration directive takes a flag (on/off) as a argument*/ +# define AP_FLAG func.flag + +/** method of declaring a directive with no arguments */ +# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \ + { directive, { .no_args=func }, mconfig, where, RAW_ARGS, help } +/** method of declaring a directive with raw argument parsing */ +# define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \ + { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help } +/** method of declaring a directive which takes 1 argument */ +# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \ + { directive, { .take1=func }, mconfig, where, TAKE1, help } +/** method of declaring a directive which takes multiple arguments */ +# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \ + { directive, { .take1=func }, mconfig, where, ITERATE, help } +/** method of declaring a directive which takes 2 arguments */ +# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \ + { directive, { .take2=func }, mconfig, where, TAKE2, help } +/** method of declaring a directive which takes 1 or 2 arguments */ +# define AP_INIT_TAKE12(directive, func, mconfig, where, help) \ + { directive, { .take2=func }, mconfig, where, TAKE12, help } +/** method of declaring a directive which takes multiple 2 arguments */ +# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \ + { directive, { .take2=func }, mconfig, where, ITERATE2, help } +/** method of declaring a directive which takes 1 or 3 arguments */ +# define AP_INIT_TAKE13(directive, func, mconfig, where, help) \ + { directive, { .take3=func }, mconfig, where, TAKE13, help } +/** method of declaring a directive which takes 2 or 3 arguments */ +# define AP_INIT_TAKE23(directive, func, mconfig, where, help) \ + { directive, { .take3=func }, mconfig, where, TAKE23, help } +/** method of declaring a directive which takes 1 to 3 arguments */ +# define AP_INIT_TAKE123(directive, func, mconfig, where, help) \ + { directive, { .take3=func }, mconfig, where, TAKE123, help } +/** method of declaring a directive which takes 3 arguments */ +# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \ + { directive, { .take3=func }, mconfig, where, TAKE3, help } +/** method of declaring a directive which takes a flag (on/off) as a argument*/ +# define AP_INIT_FLAG(directive, func, mconfig, where, help) \ + { directive, { .flag=func }, mconfig, where, FLAG, help } + +#else /* AP_HAVE_DESIGNATED_INITIALIZER */ + +typedef const char *(*cmd_func) (); + +# define AP_NO_ARGS func +# define AP_RAW_ARGS func +# define AP_TAKE1 func +# define AP_TAKE2 func +# define AP_TAKE3 func +# define AP_FLAG func + +# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, RAW_ARGS, help } +# define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, RAW_ARGS, help } +# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, TAKE1, help } +# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, ITERATE, help } +# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, TAKE2, help } +# define AP_INIT_TAKE12(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, TAKE12, help } +# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, ITERATE2, help } +# define AP_INIT_TAKE13(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, TAKE13, help } +# define AP_INIT_TAKE23(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, TAKE23, help } +# define AP_INIT_TAKE123(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, TAKE123, help } +# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, TAKE3, help } +# define AP_INIT_FLAG(directive, func, mconfig, where, help) \ + { directive, func, mconfig, where, FLAG, help } + +#endif /* AP_HAVE_DESIGNATED_INITIALIZER */ + +/** + * The command record structure. Each modules can define a table of these + * to define the directives it will implement. + */ +typedef struct command_struct command_rec; +struct command_struct { + /** Name of this command */ + const char *name; + /** The function to be called when this directive is parsed */ + cmd_func func; + /** Extra data, for functions which implement multiple commands... */ + void *cmd_data; + /** What overrides need to be allowed to enable this command. */ + int req_override; + /** What the command expects as arguments + * @defvar cmd_how args_how*/ + enum cmd_how args_how; + + /** 'usage' message, in case of syntax errors */ + const char *errmsg; +}; + +/** + * @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. + * + * @{ + */ +#define OR_NONE 0 /**< *.conf is not available anywhere in this override */ +#define OR_LIMIT 1 /**< *.conf inside or + and .htaccess when AllowOverride Limit */ +#define OR_OPTIONS 2 /**< *.conf anywhere + and .htaccess when AllowOverride Options */ +#define OR_FILEINFO 4 /**< *.conf anywhere + and .htaccess when AllowOverride FileInfo */ +#define OR_AUTHCFG 8 /**< *.conf inside or + and .htaccess when AllowOverride AuthConfig */ +#define OR_INDEXES 16 /**< *.conf anywhere + and .htaccess when AllowOverride Indexes */ +#define OR_UNSET 32 /**< unset a directive (in Allow) */ +#define ACCESS_CONF 64 /**< *.conf inside or */ +#define RSRC_CONF 128 /**< *.conf outside or */ +#define EXEC_ON_READ 256 /**< force directive to execute a command + which would modify the configuration (like including another + file, or IFModule */ +/** this directive can be placed anywhere */ +#define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES) + +/** @} */ + +/** + * This can be returned by a function if they don't wish to handle + * a command. Make it something not likely someone will actually use + * as an error code. + */ +#define DECLINE_CMD "\a\b" + +/** Common structure for reading of config files / passwd files etc. */ +typedef struct ap_configfile_t ap_configfile_t; +struct ap_configfile_t { + int (*getch) (void *param); /**< a getc()-like function */ + void *(*getstr) (void *buf, size_t bufsiz, void *param); + /**< a fgets()-like function */ + int (*close) (void *param); /**< a close handler function */ + void *param; /**< the argument passed to getch/getstr/close */ + const char *name; /**< the filename / description */ + unsigned line_number; /**< current line number, starting at 1 */ +}; + +/** + * This structure is passed to a command which is being invoked, + * to carry a large variety of miscellaneous data which is all of + * use to *somebody*... + */ +struct cmd_parms_struct { + /** Argument to command from cmd_table */ + void *info; + /** Which allow-override bits are set */ + int override; + /** Which methods are ed */ + apr_int64_t limited; + /** methods which are limited */ + apr_array_header_t *limited_xmethods; + /** methods which are xlimited */ + ap_method_list_t *xlimited; + + /** Config file structure. */ + ap_configfile_t *config_file; + /** the directive specifying this command */ + ap_directive_t *directive; + + /** Pool to allocate new storage in */ + apr_pool_t *pool; + /** Pool for scratch memory; persists during configuration, but + * wiped before the first request is served... */ + apr_pool_t *temp_pool; + /** Server_rec being configured for */ + server_rec *server; + /** If configuring for a directory, pathname of that directory. + * NOPE! That's what it meant previous to the existance of , + * and regex matching. Now the only usefulness that can be + * derived from this field is whether a command is being called in a + * server context (path == NULL) or being called in a dir context + * (path != NULL). */ + char *path; + /** configuration command */ + const command_rec *cmd; + + /** per_dir_config vector passed to handle_command */ + struct ap_conf_vector_t *context; + /** directive with syntax error */ + const ap_directive_t *err_directive; +}; + +/** + * Module structures. Just about everything is dispatched through + * these, directly or indirectly (through the command and handler + * tables). + */ +typedef struct module_struct module; +struct module_struct { + /** API version, *not* module version; check that module is + * compatible with this version of the server. + */ + int version; + /** API minor version. Provides API feature milestones. Not checked + * during module init */ + int minor_version; + /** Index to this modules structures in config vectors. */ + int module_index; + + /** The name of the module's C file */ + const char *name; + /** The handle for the DSO. Internal use only */ + void *dynamic_load_handle; + + /** A pointer to the next module in the list + * @defvar module_struct *next */ + struct module_struct *next; + + /** Magic Cookie to identify a module structure; It's mainly + * important for the DSO facility (see also mod_so). */ + unsigned long magic; + + /** Function to allow MPMs to re-write command line arguments. This + * hook is only available to MPMs. + * @param The process that the server is running in. + */ + void (*rewrite_args) (process_rec *process); + /** Function to allow all modules to create per directory configuration + * structures. + * @param p The pool to use for all allocations. + * @param dir The directory currently being processed. + * @return The per-directory structure created + */ + void *(*create_dir_config) (apr_pool_t *p, char *dir); + /** Function to allow all modules to merge the per directory configuration + * structures for two directories. + * @param p The pool to use for all allocations. + * @param base_conf The directory structure created for the parent directory. + * @param new_conf The directory structure currently being processed. + * @return The new per-directory structure created + */ + void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf); + /** Function to allow all modules to create per server configuration + * structures. + * @param p The pool to use for all allocations. + * @param s The server currently being processed. + * @return The per-server structure created + */ + void *(*create_server_config) (apr_pool_t *p, server_rec *s); + /** Function to allow all modules to merge the per server configuration + * structures for two servers. + * @param p The pool to use for all allocations. + * @param base_conf The directory structure created for the parent directory. + * @param new_conf The directory structure currently being processed. + * @return The new per-directory structure created + */ + void *(*merge_server_config) (apr_pool_t *p, void *base_conf, + void *new_conf); + + /** A command_rec table that describes all of the directives this module + * defines. */ + const command_rec *cmds; + + /** A hook to allow modules to hook other points in the request processing. + * In this function, modules should call the ap_hook_*() functions to + * register an interest in a specific step in processing the current + * request. + * @param p the pool to use for all allocations + */ + void (*register_hooks) (apr_pool_t *p); +}; + +/** + * @defgroup ModuleInit Module structure initializers + * + * Initializer for the first few module slots, which are only + * really set up once we start running. Note that the first two slots + * provide a version check; this should allow us to deal with changes to + * the API. The major number should reflect changes to the API handler table + * itself or removal of functionality. The minor number should reflect + * additions of functionality to the existing API. (the server can detect + * an old-format module, and either handle it back-compatibly, or at least + * signal an error). See src/include/ap_mmn.h for MMN version history. + * @{ + */ + +/** The one used in Apache 1.3, which will deliberately cause an error */ +#define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0 + +/** Use this in all standard modules */ +#define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \ + MODULE_MAGIC_NUMBER_MINOR, \ + -1, \ + __FILE__, \ + NULL, \ + NULL, \ + MODULE_MAGIC_COOKIE, \ + NULL /* rewrite args spot */ + +/** Use this only in MPMs */ +#define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \ + MODULE_MAGIC_NUMBER_MINOR, \ + -1, \ + __FILE__, \ + NULL, \ + NULL, \ + MODULE_MAGIC_COOKIE + +/** @} */ + +/* CONFIGURATION VECTOR FUNCTIONS */ + +/** configuration vector structure */ +typedef struct ap_conf_vector_t ap_conf_vector_t; + +/** + * Generic accessors for other modules to get at their own module-specific + * data + * @param conf_vector The vector in which the modules configuration is stored. + * usually r->per_dir_config or s->module_config + * @param m The module to get the data for. + * @return The module-specific data + */ +AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv, + const module *m); + +/** + * Generic accessors for other modules to set at their own module-specific + * data + * @param conf_vector The vector in which the modules configuration is stored. + * usually r->per_dir_config or s->module_config + * @param m The module to set the data for. + * @param val The module-specific data to set + */ +AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m, + void *val); + +#if !defined(AP_DEBUG) + +#define ap_get_module_config(v,m) \ + (((void **)(v))[(m)->module_index]) +#define ap_set_module_config(v,m,val) \ + ((((void **)(v))[(m)->module_index]) = (val)) + +#endif /* AP_DEBUG */ + + +/** + * Generic command handling function for strings + * @param cmd The command parameters for this directive + * @param struct_ptr pointer into a given type + * @param arg The argument to the directive + * @return An error string or NULL on success + */ +AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd, + void *struct_ptr, + const char *arg); + +/** + * Generic command handling function for integers + * @param cmd The command parameters for this directive + * @param struct_ptr pointer into a given type + * @param arg The argument to the directive + * @return An error string or NULL on success + */ +AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd, + void *struct_ptr, + const char *arg); + +/** + * Return true if the specified method is limited by being listed in + * a container, or by *not* being listed in a + * container. + * + * @param method Pointer to a string specifying the method to check. + * @param cmd Pointer to the cmd_parms structure passed to the + * directive handler. + * @return 0 if the method is not limited in the current scope + */ +AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method); + +/** + * Generic command handling function for strings, always sets the value + * to a lowercase string + * @param cmd The command parameters for this directive + * @param struct_ptr pointer into a given type + * @param arg The argument to the directive + * @return An error string or NULL on success + */ +AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd, + void *struct_ptr, + const char *arg); +/** + * Generic command handling function for flags + * @param cmd The command parameters for this directive + * @param struct_ptr pointer into a given type + * @param arg The argument to the directive (either 1 or 0) + * @return An error string or NULL on success + */ +AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd, + void *struct_ptr, + int arg); +/** + * Generic command handling function for files + * @param cmd The command parameters for this directive + * @param struct_ptr pointer into a given type + * @param arg The argument to the directive + * @return An error string or NULL on success + */ +AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, + void *struct_ptr, + const char *arg); +/** + * Generic command handling function to respond with cmd->help as an error + * @param cmd The command parameters for this directive + * @param struct_ptr pointer into a given type + * @param arg The argument to the directive + * @return The cmd->help value as the error string + * @tip This allows simple declarations such as; + *
+ *     AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, 
+ *         "The Foo directive is no longer supported, use Bar"),
+ * 
+ */ +AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd, + void *struct_ptr, + const char *arg); +/** + * 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 + */ +AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname); + +/* 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 + */ +AP_DECLARE(void) ap_add_module(module *m, apr_pool_t *p); + +/** + * 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 + */ +AP_DECLARE(void) ap_remove_module(module *m); +/** + * 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 + */ +AP_DECLARE(void) ap_add_loaded_module(module *mod, apr_pool_t *p); +/** + * Remove a module fromthe chained modules list and the list of loaded modules + * @param m the module structure of the module to remove + */ +AP_DECLARE(void) ap_remove_loaded_module(module *mod); +/** + * 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 + */ +AP_DECLARE(int) ap_add_named_module(const char *name, apr_pool_t *p); +/** + * Find the name of the specified module + * @param m The module to get the name for + * @return the name of the module + */ +AP_DECLARE(const char *) ap_find_module_name(module *m); +/** + * 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 + */ +AP_DECLARE(module *) ap_find_linked_module(const char *name); + +/** + * 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 + */ +AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, + apr_pool_t *p, const char *name); + +/** + * 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 + */ +AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p, + const char *descr, + void *param, + int(*getc_func)(void*), + void *(*gets_func) (void *buf, size_t bufsiz, void *param), + int(*close_func)(void *param)); + +/** + * 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 + */ +AP_DECLARE(int) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp); + +/** + * Read one char from open configfile_t, increase line number upon LF + * @param cfp The file to read from + * @return the character read + */ +AP_DECLARE(int) ap_cfg_getc(ap_configfile_t *cfp); + +/** + * Detach from open ap_configfile_t, calling the close handler + * @param cfp The file to close + * @return 1 on sucess, 0 on failure + */ +AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp); + +/** + * Read all data between the current and the matching . All + * of this data is forgotten immediately. + * @param cmd The cmd_parms to pass to the directives inside the container + * @param directive The directive name to read until + * @return Error string on failure, NULL on success + */ +AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive); + +/** + * Read all data between the current and the matching and build + * a config tree from it + * @param p pool to allocate from + * @param temp_pool Temporary pool to allocate from + * @param parms The cmd_parms to pass to all directives read + * @param current The current node in the tree + * @param curr_parent The current parent node + * @param orig_directive The directive to read until hit. + * @return Error string on failure, NULL on success +*/ +AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p, + apr_pool_t *temp_pool, + cmd_parms *parms, + ap_directive_t **current, + ap_directive_t **curr_parent, + char *orig_directive); + +/** + * Build a config tree from a config file + * @param parms The cmd_parms to pass to all of the directives in the file + * @param conf_pool The pconf pool + * @param temp_pool The temporary pool + * @param conftree Place to store the root node of the config tree + * @return Error string on erro, NULL otherwise + */ +AP_DECLARE(const char *) ap_build_config(cmd_parms *parms, + apr_pool_t *conf_pool, + apr_pool_t *temp_pool, + ap_directive_t **conftree); + +/** + * Walk a config tree and setup the server's internal structures + * @param conftree The config tree to walk + * @param parms The cmd_parms to pass to all functions + * @param section_vector The per-section config vector. + * @return Error string on error, NULL otherwise + */ +AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree, + cmd_parms *parms, + ap_conf_vector_t *section_vector); + +/** + * @defgroup ap_check_cmd_context ap_check_cmd_context + * @{ + */ +/** + * Check the context a command is used in. + * @param cmd The command to check + * @param forbidden Where the command is forbidden. + * @return Error string on error, NULL on success + */ +AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd, + unsigned forbidden); + +#define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in */ +#define NOT_IN_LIMIT 0x02 /**< Forbidden in */ +#define NOT_IN_DIRECTORY 0x04 /**< Forbidden in */ +#define NOT_IN_LOCATION 0x08 /**< Forbidden in */ +#define NOT_IN_FILES 0x10 /**< Forbidden in */ +/** Forbidden in //*/ +#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) +/** Forbidden in //// */ +#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE) + +/** @} */ + +#ifdef CORE_PRIVATE + +/** + * The topmost module in the list + * @defvar module *ap_top_module + */ +AP_DECLARE_DATA extern module *ap_top_module; + +/** + * Array of all statically linked modules + * @defvar module *ap_prelinked_modules[] + */ +AP_DECLARE_DATA extern module *ap_prelinked_modules[]; +/** + * Array of all preloaded modules + * @defvar module *ap_preloaded_modules[] + */ +AP_DECLARE_DATA extern module *ap_preloaded_modules[]; +/** + * Array of all loaded modules + * @defvar module **ap_loaded_modules + */ +AP_DECLARE_DATA extern module **ap_loaded_modules; + +/* For mod_so.c... */ +/** Run a single module's two create_config hooks + * @param p the pool to allocate from + * @param s The server to configure for. + * @param m The module to configure + */ +AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s, + module *m); + +/* For http_main.c... */ +/** + * Add all of the prelinked modules into the loaded module list + * @param process The process that is currently running the server + */ +AP_DECLARE(void) ap_setup_prelinked_modules(process_rec *process); + +/** + * Show the preloaded configuration directives, the help string explaining + * the directive arguments, in what module they are handled, and in + * what parts of the configuration they are allowed. Used for httpd -h. + */ +AP_DECLARE(void) ap_show_directives(void); + +/** + * Show the preloaded module names. Used for httpd -l. + */ +AP_DECLARE(void) ap_show_modules(void); + +/** + * Show the MPM name. Used in reporting modules such as mod_info to + * provide extra information to the user + */ +AP_DECLARE(const char *) ap_show_mpm(void); + +/** + * Read all config files and setup the server + * @param process The process running the server + * @param temp_pool A pool to allocate temporary data from. + * @param config_name The name of the config file + * @param conftree Place to store the root of the config tree + * @return The setup server_rec list. + */ +AP_DECLARE(server_rec *) ap_read_config(process_rec *process, + apr_pool_t *temp_pool, + const char *config_name, + ap_directive_t **conftree); + +/** + * Run all rewrite args hooks for loaded modules + * @param process The process currently running the server + */ +AP_DECLARE(void) ap_run_rewrite_args(process_rec *process); + +/** + * Run the register hooks function for a specified module + * @param m The module to run the register hooks function fo + * @param p The pool valid for the lifetime of the module + */ +AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p); + +/** + * Setup all virtual hosts + * @param p The pool to allocate from + * @param main_server The head of the server_rec list + */ +AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, + server_rec *main_server); + +/* For http_request.c... */ + +/** + * Setup the config vector for a request_rec + * @param p The pool to allocate the config vector from + * @return The config vector + */ +AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p); + +/** + * Setup the config vector for per dir module configs + * @param p The pool to allocate the config vector from + * @return The config vector + */ +AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p); + +/** + * Run all of the modules merge per dir config functions + * @param p The pool to pass to the merge functions + * @param base The base directory config structure + * @param new_conf The new directory config structure + */ +AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p, + ap_conf_vector_t *base, + ap_conf_vector_t *new_conf); + +/* For http_connection.c... */ +/** + * Setup the config vector for a connection_rec + * @param p The pool to allocate the config vector from + * @return The config vector + */ +AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p); + +/* For http_core.c... ( command and virtual hosts) */ + +/** + * parse an htaccess file + * @param resulting htaccess_result + * @param r The request currently being served + * @param override Which overrides are active + * @param path The path to the htaccess file + * @param access_name The list of possible names for .htaccess files + * int The status of the current request + */ +AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result, + request_rec *r, int override, + const char *path, + const char *access_name); + +/** + * Setup a virtual host + * @param p The pool to allocate all memory from + * @param hostname The hostname of the virtual hsot + * @param main_server The main server for this Apache configuration + * @param ps Place to store the new server_rec + * return Error string on error, NULL on success + */ +AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, + const char *hostname, + server_rec *main_server, + server_rec **); + +/** + * Process the config file for Apache + * @param s The server rec to use for the command parms + * @param fname The name of the config file + * @param conftree The root node of the created config tree + * @param p Pool for general allocation + * @param ptem Pool for temporary allocation + */ +AP_DECLARE(void) ap_process_resource_config(server_rec *s, const char *fname, + ap_directive_t **conftree, + apr_pool_t *p, apr_pool_t *ptemp); + +/** + * Process all directives in the config tree + * @param s The server rec to use in the command parms + * @param conftree The config tree to process + * @param p The pool for general allocation + * @param ptemp The pool for temporary allocations + */ +AP_DECLARE(void) ap_process_config_tree(server_rec *s, ap_directive_t *conftree, + apr_pool_t *p, apr_pool_t *ptemp); + +/* Module-method dispatchers, also for http_request.c */ +/** + * Run the handler phase of each module until a module accepts the + * responsibility of serving the request + * @param r The current request + * @return The status of the current request + */ +AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r); + +/* for mod_perl */ + +/** + * Find a given directive in a command_rec table + * @param name The directive to search for + * @param cmds The table to search + * @return The directive definition of the specified directive + */ +AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name, + const command_rec *cmds); + +/** + * Find a given directive in a list module + * @param cmd_name The directive to search for + * @param mod The module list to search + * @return The directive definition of the specified directive + */ +AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name, + module **mod); + +/** + * Ask a module to create per-server and per-section (dir/loc/file) configs + * (if it hasn't happened already). The results are stored in the server's + * config, and the specified per-section config vector. + * @param server The server to operate upon. + * @param section_vector The per-section config vector. + * @param section Which section to create a config for. + * @param mod The module which is defining the config data. + * @param pconf A pool for all configuration allocations. + * @return The (new) per-section config data. + */ +AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server, + ap_conf_vector_t *section_vector, + const char *section, + module *mod, apr_pool_t *pconf); + +#endif + + /* Hooks */ + +/** + * Run the header parser functions for each module + * @param r The current request + * @return OK or DECLINED + */ +AP_DECLARE_HOOK(int,header_parser,(request_rec *r)) + +/** + * Run the pre_config function for each module + * @param pconf The config pool + * @param plog The logging streams pool + * @param ptemp The temporary pool + * @return OK or DECLINED on success anything else is a error + */ +AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog, + apr_pool_t *ptemp)) + + +/** + * Run the post_config function for each module + * @param pconf The config pool + * @param plog The logging streams pool + * @param ptemp The temporary pool + * @param s The list of server_recs + * @return OK or DECLINED on success anything else is a error + */ +AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog, + apr_pool_t *ptemp,server_rec *s)) + +/** + * Run the open_logs functions for each module + * @param pconf The config pool + * @param plog The logging streams pool + * @param ptemp The temporary pool + * @param s The list of server_recs + * @return OK or DECLINED on success anything else is a error + */ +AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog, + apr_pool_t *ptemp,server_rec *s)) + +/** + * Run the child_init functions for each module + * @param pchild The child pool + * @param s The list of server_recs in this server + */ +AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s)) + +/** + * Run the handler functions for each module + * @param r The request_rec + * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST + */ +AP_DECLARE_HOOK(int,handler,(request_rec *r)) + +/** + * Run the quick handler functions for each module. The quick_handler + * is run before any other requests hooks are called (location_walk, + * directory_walk, access checking, et. al.). This hook was added + * to provide a quick way to serve content from a URI keyed cache. + * + * @param r The request_rec + * @param lookup_uri Controls whether the caller actually wants content or not. + * lookup is set when the quick_handler is called out of + * ap_sub_req_lookup_uri() + */ +AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri)) + +/** + * Retrieve the optional functions for each module. + * This is run immediately before the server starts. Optional functions should + * be registered during the hook registration phase. + */ +AP_DECLARE_HOOK(void,optional_fn_retrieve,(void)) + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_CONFIG_H */ diff --git a/rubbos/app/apache2/include/http_connection.h b/rubbos/app/apache2/include/http_connection.h new file mode 100644 index 00000000..2b7d379f --- /dev/null +++ b/rubbos/app/apache2/include/http_connection.h @@ -0,0 +1,139 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_CONNECTION_H +#define APACHE_HTTP_CONNECTION_H + +#include "apr_hooks.h" +#include "apr_network_io.h" +#include "apr_buckets.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Apache connection library + */ +#ifdef CORE_PRIVATE +/** + * This is the protocol module driver. This calls all of the + * pre-connection and connection hooks for all protocol modules. + * @param c The connection on which the request is read + * @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. + * @deffunc void ap_process_connection(conn_rec *c, void *csd) + */ +AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd); + +AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c); + +/** + * This function is responsible for the following cases: + *
+ * 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 + */ +AP_DECLARE(void) ap_lingering_close(conn_rec *c); +#endif + + /* 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. + */ +AP_DECLARE_HOOK(conn_rec *, create_connection, + (apr_pool_t *p, server_rec *server, apr_socket_t *csd, + long conn_id, void *sbh, apr_bucket_alloc_t *alloc)) + +/** + * 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) + */ +AP_DECLARE_HOOK(int,pre_connection,(conn_rec *c, void *csd)) + +/** + * 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) + */ +AP_DECLARE_HOOK(int,process_connection,(conn_rec *c)) + +/* 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) + */ +AP_DECLARE(apr_bucket *) ap_bucket_eoc_make(apr_bucket *b); + +/** + * 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) + */ +AP_DECLARE(apr_bucket *) ap_bucket_eoc_create(apr_bucket_alloc_t *list); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_REQUEST_H */ diff --git a/rubbos/app/apache2/include/http_core.h b/rubbos/app/apache2/include/http_core.h new file mode 100644 index 00000000..99b17a90 --- /dev/null +++ b/rubbos/app/apache2/include/http_core.h @@ -0,0 +1,640 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_CORE_H +#define APACHE_HTTP_CORE_H + +#include "apr.h" +#include "apr_hash.h" +#include "apr_optional.h" +#include "util_filter.h" + +#if APR_HAVE_STRUCT_RLIMIT +#include +#include +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package CORE HTTP Daemon + */ + +/* **************************************************************** + * + * The most basic server code is encapsulated in a single module + * known as the core, which is just *barely* functional enough to + * serve documents, though not terribly well. + * + * Largely for NCSA back-compatibility reasons, the core needs to + * make pieces of its config structures available to other modules. + * The accessors are declared here, along with the interpretation + * of one of them (allow_options). + */ + +#define OPT_NONE 0 +#define OPT_INDEXES 1 +#define OPT_INCLUDES 2 +#define OPT_SYM_LINKS 4 +#define OPT_EXECCGI 8 +#define OPT_UNSET 16 +#define OPT_INCNOEXEC 32 +#define OPT_SYM_OWNER 64 +#define OPT_MULTI 128 +#define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|OPT_EXECCGI) + +/* options for get_remote_host() */ +/* REMOTE_HOST returns the hostname, or NULL if the hostname + * lookup fails. It will force a DNS lookup according to the + * HostnameLookups setting. + */ +#define REMOTE_HOST (0) + +/* 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. + */ +#define REMOTE_NAME (1) + +/* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is + * never forced. + */ +#define REMOTE_NOLOOKUP (2) + +/* 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. + */ +#define REMOTE_DOUBLE_REV (3) + +#define SATISFY_ALL 0 +#define SATISFY_ANY 1 +#define SATISFY_NOSPEC 2 + +/* Make sure we don't write less than 8000 bytes at any one time. + */ +#define AP_MIN_BYTES_TO_WRITE 8000 + +/* default maximum of internal redirects */ +# define AP_DEFAULT_MAX_INTERNAL_REDIRECTS 10 + +/* default maximum subrequest nesting level */ +# define AP_DEFAULT_MAX_SUBREQ_DEPTH 10 + +/** + * Retrieve the value of Options for this request + * @param r The current request + * @return the Options bitmask + * @deffunc int ap_allow_options(request_rec *r) + */ +AP_DECLARE(int) ap_allow_options(request_rec *r); + +/** + * Retrieve the value of the AllowOverride for this request + * @param r The current request + * @return the overrides bitmask + * @deffunc int ap_allow_overrides(request_rec *r) + */ +AP_DECLARE(int) ap_allow_overrides(request_rec *r); + +/** + * Retrieve the value of the DefaultType directive, or text/plain if not set + * @param r The current request + * @return The default type + * @deffunc const char *ap_default_type(request_rec *r) + */ +AP_DECLARE(const char *) ap_default_type(request_rec *r); + +/** + * Retrieve the document root for this server + * @param r The current request + * @warning Don't use this! If your request went through a Userdir, or + * something like that, it'll screw you. But it's back-compatible... + * @return The document root + * @deffunc const char *ap_document_root(request_rec *r) + */ +AP_DECLARE(const char *) ap_document_root(request_rec *r); + +/** + * Lookup the remote client's DNS name or IP address + * @param conn The current connection + * @param dir_config The directory config vector from the request + * @param type The type of lookup to perform. One of: + *
+ *     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) + */ +AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip); + +/** + * 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) + */ +AP_DECLARE(const char *) ap_get_remote_logname(request_rec *r); + +/* 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) + */ +AP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r); + +/** + * 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) + */ +AP_DECLARE(const char *) ap_get_server_name(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r); + +/** + * 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) + */ +AP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r); + +/** + * 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) + */ +AP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r); + +/** + * 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 + */ +AP_DECLARE(void) ap_custom_response(request_rec *r, int status, const char *string); + +/** + * 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) + */ +AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r); + +/** + * 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) + */ +AP_DECLARE(int) ap_exists_config_define(const char *name); +/* FIXME! See STATUS about how */ +AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r); + +/* 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. + */ +typedef struct require_line require_line; + +/** A structure to keep track of authorization requirements */ +struct require_line { + /** Where the require line is in the config file. */ + apr_int64_t method_mask; + /** The complete string from the command line */ + char *requirement; +}; + +/** + * 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) + */ +AP_DECLARE(const char *) ap_auth_type(request_rec *r); + +/** + * Return the current Authorization realm + * @param r The current request + * @return The current authorization realm + * @deffunc const char *ap_auth_name(request_rec *r) + */ +AP_DECLARE(const char *) ap_auth_name(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(int) ap_satisfies(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(const apr_array_header_t *) ap_requires(request_rec *r); + +#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 */ + +typedef struct { + /* bucket brigade used by getline for look-ahead and + * ap_get_client_block for holding left-over request body */ + struct apr_bucket_brigade *bb; + + /* 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) + */ + void **notes; + + /* 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. + */ + int deliver_script; + + /* Custom response strings registered via ap_custom_response(), + * or NULL; check per-dir config if nothing found here + */ + char **response_code_strings; /* from ap_custom_response(), not from + * ErrorDocument + */ + /* Should addition of charset= be suppressed for this request? + */ + int suppress_charset; +} core_request_config; + +/* 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()) + */ +#define AP_NOTE_DIRECTORY_WALK 0 +#define AP_NOTE_LOCATION_WALK 1 +#define AP_NOTE_FILE_WALK 2 +#define 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. + */ +AP_DECLARE(apr_size_t) ap_register_request_note(void); + +/** + * 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. + */ +AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num); + +/* Per-directory configuration */ + +typedef unsigned char allow_options_t; +typedef unsigned char overrides_t; + +/* + * 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. + */ +typedef unsigned long etag_components_t; + +#define ETAG_UNSET 0 +#define ETAG_NONE (1 << 0) +#define ETAG_MTIME (1 << 1) +#define ETAG_INODE (1 << 2) +#define ETAG_SIZE (1 << 3) +#define ETAG_BACKWARD (ETAG_MTIME | ETAG_INODE | ETAG_SIZE) +#define ETAG_ALL (ETAG_MTIME | ETAG_INODE | ETAG_SIZE) + +typedef enum { + srv_sig_unset, + srv_sig_off, + srv_sig_on, + srv_sig_withmail +} server_signature_e; + +typedef struct { + /* path of the directory/regex/etc. see also d_is_fnmatch/absolute below */ + char *d; + /* the number of slashes in d */ + unsigned d_components; + + /* 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. + */ + allow_options_t opts; + allow_options_t opts_add; + allow_options_t opts_remove; + overrides_t override; + + /* 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... + */ + + char *ap_default_type; + + /* Authentication stuff. Groan... */ + + int *satisfy; /* for every method one */ + char *ap_auth_type; + char *ap_auth_name; + apr_array_header_t *ap_requires; + + /* 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(). + */ + + char **response_code_strings; /* from ErrorDocument, not from + * ap_custom_response() */ + + /* Hostname resolution etc */ +#define HOSTNAME_LOOKUP_OFF 0 +#define HOSTNAME_LOOKUP_ON 1 +#define HOSTNAME_LOOKUP_DOUBLE 2 +#define HOSTNAME_LOOKUP_UNSET 3 + 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? */ + +#define USE_CANONICAL_NAME_OFF (0) +#define USE_CANONICAL_NAME_ON (1) +#define USE_CANONICAL_NAME_DNS (2) +#define USE_CANONICAL_NAME_UNSET (3) + 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? + */ +#define ADD_DEFAULT_CHARSET_OFF (0) +#define ADD_DEFAULT_CHARSET_ON (1) +#define ADD_DEFAULT_CHARSET_UNSET (2) + unsigned add_default_charset : 2; + const char *add_default_charset_name; + + /* System Resource Control */ +#ifdef RLIMIT_CPU + struct rlimit *limit_cpu; +#endif +#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) + struct rlimit *limit_mem; +#endif +#ifdef RLIMIT_NPROC + struct rlimit *limit_nproc; +#endif + apr_off_t limit_req_body; /* limit on bytes in request msg body */ + long limit_xml_body; /* limit on bytes in XML request msg body */ + + /* logging options */ + + server_signature_e server_signature; + + int loglevel; + + /* Access control */ + apr_array_header_t *sec_file; + regex_t *r; + + const char *mime_type; /* forced with ForceType */ + const char *handler; /* forced with SetHandler */ + const char *output_filters; /* forced with SetOutputFilters */ + const char *input_filters; /* forced with SetInputFilters */ + int accept_path_info; /* forced with AcceptPathInfo */ + + apr_hash_t *ct_output_filters; /* added with AddOutputFilterByType */ + + /* + * What attributes/data should be included in ETag generation? + */ + etag_components_t etag_bits; + etag_components_t etag_add; + etag_components_t etag_remove; + + /* + * Run-time performance tuning + */ +#define ENABLE_MMAP_OFF (0) +#define ENABLE_MMAP_ON (1) +#define ENABLE_MMAP_UNSET (2) + unsigned int enable_mmap : 2; /* whether files in this dir can be mmap'ed */ + +#define ENABLE_SENDFILE_OFF (0) +#define ENABLE_SENDFILE_ON (1) +#define ENABLE_SENDFILE_UNSET (2) + 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 */ +} core_dir_config; + +/* Per-server core configuration */ + +typedef struct { + +#ifdef GPROF + char *gprof_dir; +#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: + */ + const char *ap_document_root; + + /* Access control */ + + char *access_name; + apr_array_header_t *sec_dir; + apr_array_header_t *sec_url; + + /* recursion backstopper */ + int redirect_limit; /* maximum number of internal redirects */ + int subreq_limit; /* maximum nesting level of subrequests */ + + /* TRACE control */ +#define AP_TRACE_UNSET -1 +#define AP_TRACE_DISABLE 0 +#define AP_TRACE_ENABLE 1 +#define AP_TRACE_EXTENDED 2 + int trace_enable; + +} core_server_config; + +/* 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 + + +/* ---------------------------------------------------------------------- + * + * Runtime status/management + */ + +typedef enum { + ap_mgmt_type_string, + ap_mgmt_type_long, + ap_mgmt_type_hash +} ap_mgmt_type_e; + +typedef union { + const char *s_value; + long i_value; + apr_hash_t *h_value; +} ap_mgmt_value; + +typedef struct { + const char *description; + const char *name; + ap_mgmt_type_e vtype; + ap_mgmt_value v; +} ap_mgmt_item_t; + +/* 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 + */ +AP_DECLARE_HOOK(int, get_mgmt_items, + (apr_pool_t *p, const char * val, apr_hash_t *ht)) + +/* ---------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + * + * I/O logging with mod_logio + */ + +APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out, + (conn_rec *c, apr_off_t bytes)); + +/* ---------------------------------------------------------------------- */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_CORE_H */ diff --git a/rubbos/app/apache2/include/http_log.h b/rubbos/app/apache2/include/http_log.h new file mode 100644 index 00000000..52880585 --- /dev/null +++ b/rubbos/app/apache2/include/http_log.h @@ -0,0 +1,334 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_LOG_H +#define APACHE_HTTP_LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "apr_thread_proc.h" + +/** + * @package Apache logging library + */ + +#ifdef HAVE_SYSLOG +#include + +#ifndef LOG_PRIMASK +#define LOG_PRIMASK 7 +#endif + +#define APLOG_EMERG LOG_EMERG /* system is unusable */ +#define APLOG_ALERT LOG_ALERT /* action must be taken immediately */ +#define APLOG_CRIT LOG_CRIT /* critical conditions */ +#define APLOG_ERR LOG_ERR /* error conditions */ +#define APLOG_WARNING LOG_WARNING /* warning conditions */ +#define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */ +#define APLOG_INFO LOG_INFO /* informational */ +#define APLOG_DEBUG LOG_DEBUG /* debug-level messages */ + +#define APLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */ + +#else + +#define APLOG_EMERG 0 /* system is unusable */ +#define APLOG_ALERT 1 /* action must be taken immediately */ +#define APLOG_CRIT 2 /* critical conditions */ +#define APLOG_ERR 3 /* error conditions */ +#define APLOG_WARNING 4 /* warning conditions */ +#define APLOG_NOTICE 5 /* normal but significant condition */ +#define APLOG_INFO 6 /* informational */ +#define APLOG_DEBUG 7 /* debug-level messages */ + +#define APLOG_LEVELMASK 7 /* mask off the level value */ + +#endif + +/* APLOG_NOERRNO is ignored and should not be used. It will be + * removed in a future release of Apache. + */ +#define APLOG_NOERRNO (APLOG_LEVELMASK + 1) + +/* Use APLOG_TOCLIENT on ap_log_rerror() to give content + * handlers the option of including the error text in the + * ErrorDocument sent back to the client. Setting APLOG_TOCLIENT + * will cause the error text to be saved in the request_rec->notes + * table, keyed to the string "error-notes", if and only if: + * - the severity level of the message is APLOG_WARNING or greater + * - there are no other "error-notes" set in request_rec->notes + * Once error-notes is set, it is up to the content handler to + * determine whether this text should be sent back to the client. + * Note: Client generated text streams sent back to the client MUST + * be escaped to prevent CSS attacks. + */ +#define APLOG_TOCLIENT ((APLOG_LEVELMASK + 1) * 2) + +/* normal but significant condition on startup, usually printed to stderr */ +#define APLOG_STARTUP ((APLOG_LEVELMASK + 1) * 4) + +#ifndef DEFAULT_LOGLEVEL +#define DEFAULT_LOGLEVEL APLOG_WARNING +#endif + +extern int AP_DECLARE_DATA ap_default_loglevel; + +#define APLOG_MARK __FILE__,__LINE__ + +/** + * Set up for logging to stderr. + * @param p The pool to allocate out of + */ +AP_DECLARE(void) ap_open_stderr_log(apr_pool_t *p); + +/** + * Replace logging to stderr with logging to the given file. + * @param p The pool to allocate out of + * @param file Name of the file to log stderr output + */ +AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p, + const char *file); + +/** + * Open the error log and replace stderr with it. + * @param pconf Not used + * @param plog The pool to allocate the logs from + * @param ptemp Pool used for temporary allocations + * @param s_main The main server + * @tip ap_open_logs isn't expected to be used by modules, it is + * an internal core function + */ +int ap_open_logs(apr_pool_t *pconf, apr_pool_t *plog, + apr_pool_t *ptemp, server_rec *s_main); + +#ifdef CORE_PRIVATE + +/** + * Perform special processing for piped loggers in MPM child + * processes. + * @param p Not used + * @param s Not used + * @tip ap_logs_child_init is not for use by modules; it is an + * internal core function + */ +void ap_logs_child_init(apr_pool_t *p, server_rec *s); + +#endif /* CORE_PRIVATE */ + +/* + * The primary logging functions, ap_log_error, ap_log_rerror, ap_log_cerror, + * and ap_log_perror use a printf style format string to build the log message. + * It is VERY IMPORTANT that you not include any raw data from the network, + * such as the request-URI or request header fields, within the format + * string. Doing so makes the server vulnerable to a denial-of-service + * attack and other messy behavior. Instead, use a simple format string + * like "%s", followed by the string containing the untrusted data. + */ + +/** + * ap_log_error() - log messages which are not related to a particular + * request or connection. This uses a printf-like format to log messages + * to the error_log. + * @param file The file in which this function is called + * @param line The line number on which this function is called + * @param level The level of this error message + * @param status The status code from the previous command + * @param s The server on which we are logging + * @param fmt The format string + * @param ... The arguments to use to fill out fmt. + * @tip Use APLOG_MARK to fill out file and line + * @tip If a request_rec is available, use that with ap_log_rerror() + * in preference to calling this function. Otherwise, if a conn_rec is + * available, use that with ap_log_cerror() in preference to calling + * this function. + * @warning It is VERY IMPORTANT that you not include any raw data from + * the network, such as the request-URI or request header fields, within + * the format string. Doing so makes the server vulnerable to a + * denial-of-service attack and other messy behavior. Instead, use a + * simple format string like "%s", followed by the string containing the + * untrusted data. + * @deffunc void ap_log_error(const char *file, int line, int level, apr_status_t status, const server_rec *s, const char *fmt, ...) + */ +AP_DECLARE(void) ap_log_error(const char *file, int line, int level, + apr_status_t status, const server_rec *s, + const char *fmt, ...) + __attribute__((format(printf,6,7))); + +/** + * ap_log_perror() - log messages which are not related to a particular + * request, connection, or virtual server. This uses a printf-like + * format to log messages to the error_log. + * @param file The file in which this function is called + * @param line The line number on which this function is called + * @param level The level of this error message + * @param status The status code from the previous command + * @param p The pool which we are logging for + * @param fmt The format string + * @param ... The arguments to use to fill out fmt. + * @tip Use APLOG_MARK to fill out file and line + * @warning It is VERY IMPORTANT that you not include any raw data from + * the network, such as the request-URI or request header fields, within + * the format string. Doing so makes the server vulnerable to a + * denial-of-service attack and other messy behavior. Instead, use a + * simple format string like "%s", followed by the string containing the + * untrusted data. + * @deffunc void ap_log_perror(const char *file, int line, int level, apr_status_t status, apr_pool_t *p, const char *fmt, ...) + */ +AP_DECLARE(void) ap_log_perror(const char *file, int line, int level, + apr_status_t status, apr_pool_t *p, + const char *fmt, ...) + __attribute__((format(printf,6,7))); + +/** + * ap_log_rerror() - log messages which are related to a particular + * request. This uses a a printf-like format to log messages to the + * error_log. + * @param file The file in which this function is called + * @param line The line number on which this function is called + * @param level The level of this error message + * @param status The status code from the previous command + * @param r The request which we are logging for + * @param fmt The format string + * @param ... The arguments to use to fill out fmt. + * @tip Use APLOG_MARK to fill out file and line + * @warning It is VERY IMPORTANT that you not include any raw data from + * the network, such as the request-URI or request header fields, within + * the format string. Doing so makes the server vulnerable to a + * denial-of-service attack and other messy behavior. Instead, use a + * simple format string like "%s", followed by the string containing the + * untrusted data. + * @deffunc void ap_log_rerror(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...) + */ +AP_DECLARE(void) ap_log_rerror(const char *file, int line, int level, + apr_status_t status, const request_rec *r, + const char *fmt, ...) + __attribute__((format(printf,6,7))); + +/** + * ap_log_cerror() - log messages which are related to a particular + * connection. This uses a a printf-like format to log messages to the + * error_log. + * @param file The file in which this function is called + * @param line The line number on which this function is called + * @param level The level of this error message + * @param status The status code from the previous command + * @param c The connection which we are logging for + * @param fmt The format string + * @param ... The arguments to use to fill out fmt. + * @tip Use APLOG_MARK to fill out file and line + * @tip If a request_rec is available, use that with ap_log_rerror() + * in preference to calling this function. + * @warning It is VERY IMPORTANT that you not include any raw data from + * the network, such as the request-URI or request header fields, within + * the format string. Doing so makes the server vulnerable to a + * denial-of-service attack and other messy behavior. Instead, use a + * simple format string like "%s", followed by the string containing the + * untrusted data. + * @note ap_log_cerror() is available starting with Apache 2.0.55. + * @deffunc void ap_log_cerror(const char *file, int line, int level, apr_status_t status, const conn_rec *c, const char *fmt, ...) + */ +AP_DECLARE(void) ap_log_cerror(const char *file, int line, int level, + apr_status_t status, const conn_rec *c, + const char *fmt, ...) + __attribute__((format(printf,6,7))); + +/** + * Convert stderr to the error log + * @param s The current server + * @deffunc void ap_error_log2stderr(server_rec *s) + */ +AP_DECLARE(void) ap_error_log2stderr(server_rec *s); + +/** + * Log the current pid of the parent process + * @param p The pool to use for logging + * @param fname The name of the file to log to + */ +AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *fname); + +/** + * Retrieve the pid from a pidfile. + * @param p The pool to use for logging + * @param filename The name of the file containing the pid + * @param mypid Pointer to pid_t (valid only if return APR_SUCCESS) + */ +AP_DECLARE(apr_status_t) ap_read_pid(apr_pool_t *p, const char *filename, pid_t *mypid); + +typedef struct piped_log piped_log; + +/** + * The piped logging structure. Piped logs are used to move functionality + * out of the main server. For example, log rotation is done with piped logs. + */ +struct piped_log { + /** The pool to use for the piped log */ + apr_pool_t *p; + /** The pipe between the server and the logging process */ + apr_file_t *fds[2]; + /* XXX - an #ifdef that needs to be eliminated from public view. Shouldn't + * be hard */ +#ifdef AP_HAVE_RELIABLE_PIPED_LOGS + /** The name of the program the logging process is running */ + char *program; + /** The pid of the logging process */ + apr_proc_t *pid; +#endif +}; + +/** + * Open the piped log process + * @param p The pool to allocate out of + * @param program The program to run in the logging process + * @return The piped log structure + * @deffunc piped_log *ap_open_piped_log(apr_pool_t *p, const char *program) + */ +AP_DECLARE(piped_log *) ap_open_piped_log(apr_pool_t *p, const char *program); + +/** + * Close the piped log and kill the logging process + * @param pl The piped log structure + * @deffunc void ap_close_piped_log(piped_log *pl) + */ +AP_DECLARE(void) ap_close_piped_log(piped_log *pl); + +/** + * A macro to access the read side of the piped log pipe + * @param pl The piped log structure + * @return The native file descriptor + * @deffunc ap_piped_log_read_fd(pl) + */ +#define ap_piped_log_read_fd(pl) ((pl)->fds[0]) + +/** + * A macro to access the write side of the piped log pipe + * @param pl The piped log structure + * @return The native file descriptor + * @deffunc ap_piped_log_read_fd(pl) + */ +#define ap_piped_log_write_fd(pl) ((pl)->fds[1]) + +AP_DECLARE_HOOK(void, error_log, (const char *file, int line, int level, + apr_status_t status, const server_rec *s, + const request_rec *r, apr_pool_t *pool, + const char *errstr)) + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_LOG_H */ diff --git a/rubbos/app/apache2/include/http_main.h b/rubbos/app/apache2/include/http_main.h new file mode 100644 index 00000000..cc4ce59d --- /dev/null +++ b/rubbos/app/apache2/include/http_main.h @@ -0,0 +1,58 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_MAIN_H +#define APACHE_HTTP_MAIN_H + +#include "apr_optional.h" + +/* AP_SERVER_BASEARGS is the command argument list parsed by http_main.c + * in apr_getopt() format. Use this for default'ing args that the MPM + * can safely ignore and pass on from its rewrite_args() handler. + */ +#define AP_SERVER_BASEARGS "C:c:D:d:E:e:f:vVlLtSh?X" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Command line options + */ + +/** The name of the Apache executable */ +AP_DECLARE_DATA extern const char *ap_server_argv0; +/** The global server's ServerRoot */ +AP_DECLARE_DATA extern const char *ap_server_root; + +/* for -C, -c and -D switches */ +/** An array of all -C directives. These are processed before the server's + * config file */ +AP_DECLARE_DATA extern apr_array_header_t *ap_server_pre_read_config; +/** An array of all -c directives. These are processed after the server's + * config file */ +AP_DECLARE_DATA extern apr_array_header_t *ap_server_post_read_config; +/** An array of all -D defines on the command line. This allows people to + * effect the server based on command line options */ +AP_DECLARE_DATA extern apr_array_header_t *ap_server_config_defines; + +APR_DECLARE_OPTIONAL_FN(int, ap_signal_server, (int *, apr_pool_t *)); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_MAIN_H */ diff --git a/rubbos/app/apache2/include/http_protocol.h b/rubbos/app/apache2/include/http_protocol.h new file mode 100644 index 00000000..6287589f --- /dev/null +++ b/rubbos/app/apache2/include/http_protocol.h @@ -0,0 +1,697 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_PROTOCOL_H +#define APACHE_HTTP_PROTOCOL_H + +#include "httpd.h" +#include "apr_hooks.h" +#include "apr_portable.h" +#include "apr_mmap.h" +#include "apr_buckets.h" +#include "util_filter.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package HTTP protocol handling + */ + +/** + * This hook allows modules to insert filters for the current error response + * @param r the current request + * @ingroup hooks + */ +AP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r)) + +/* This is an optimization. We keep a record of the filter_rec that + * stores the old_write filter, so that we can avoid strcmp's later. + */ +AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func; + +/* + * Prototypes for routines which either talk directly back to the user, + * or control the ones that eventually do. + */ + +/** + * Read a request and fill in the fields. + * @param c The current connection + * @return The new request_rec + */ +request_rec *ap_read_request(conn_rec *c); + +/** + * Read the mime-encoded headers. + * @param r The current request + */ +AP_DECLARE(void) ap_get_mime_headers(request_rec *r); + +/** + * Optimized version of ap_get_mime_headers() that requires a + * temporary brigade to work with + * @param r The current request + * @param bb temp brigade + */ +AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, + apr_bucket_brigade *bb); + +/* Finish up stuff after a request */ + +/** + * Called at completion of sending the response. It sends the terminating + * protocol information. + * @param r The current request + * @deffunc void ap_finalize_request_protocol(request_rec *r) + */ +AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r); + +/** + * Send error back to client. + * @param r The current request + * @param recursive_error last arg indicates error status in case we get + * an error in the process of trying to deal with an ErrorDocument + * to handle some other error. In that case, we print the default + * report for the first thing that went wrong, and more briefly report + * on the problem with the ErrorDocument. + * @deffunc void ap_send_error_response(request_rec *r, int recursive_error) + */ +AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error); + +/* Set last modified header line from the lastmod date of the associated file. + * Also, set content length. + * + * May return an error status, typically HTTP_NOT_MODIFIED (that when the + * permit_cache argument is set to one). + */ + +/** + * Set the content length for this request + * @param r The current request + * @param length The new content length + * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length) + */ +AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length); + +/** + * Set the keepalive status for this request + * @param r The current request + * @return 1 if keepalive can be set, 0 otherwise + * @deffunc int ap_set_keepalive(request_rec *r) + */ +AP_DECLARE(int) ap_set_keepalive(request_rec *r); + +/** + * Return the latest rational time from a request/mtime pair. Mtime is + * returned unless it's in the future, in which case we return the current time. + * @param r The current request + * @param mtime The last modified time + * @return the latest rational time. + * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime) + */ +AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime); + +/** + * Build the content-type that should be sent to the client from the + * content-type specified. The following rules are followed: + * - if type is NULL, type is set to ap_default_type(r) + * - if charset adding is disabled, stop processing and return type. + * - then, if there are no parameters on type, add the default charset + * - return type + * @param r The current request + * @return The content-type + * @deffunc const char *ap_make_content_type(request_rec *r, const char *type); + */ +AP_DECLARE(const char *) ap_make_content_type(request_rec *r, + const char *type); + +#ifdef CORE_PRIVATE +/** + * Precompile metadata structures used by ap_make_content_type() + * @param r The pool to use for allocations + * @deffunc void ap_setup_make_content_type(apr_pool_t *pool) + */ +AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool); +#endif /* CORE_PRIVATE */ + +/** + * Construct an entity tag from the resource information. If it's a real + * file, build in some of the file characteristics. + * @param r The current request + * @param force_weak Force the entity tag to be weak - it could be modified + * again in as short an interval. + * @return The entity tag + * @deffunc char *ap_make_etag(request_rec *r, int force_weak) + */ +AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak); + +/** + * Set the E-tag outgoing header + * @param The current request + * @deffunc void ap_set_etag(request_rec *r) + */ +AP_DECLARE(void) ap_set_etag(request_rec *r); + +/** + * Set the last modified time for the file being sent + * @param r The current request + * @deffunc void ap_set_last_modified(request_rec *r) + */ +AP_DECLARE(void) ap_set_last_modified(request_rec *r); + +/** + * Implements condition GET rules for HTTP/1.1 specification. This function + * inspects the client headers and determines if the response fulfills + * the requirements specified. + * @param r The current request + * @return OK if the response fulfills the condition GET rules, some + * other status code otherwise + * @deffunc int ap_meets_conditions(request_rec *r) + */ +AP_DECLARE(int) ap_meets_conditions(request_rec *r); + +/* Other ways to send stuff at the client. All of these keep track + * of bytes_sent automatically. This indirection is intended to make + * it a little more painless to slide things like HTTP-NG packetization + * underneath the main body of the code later. In the meantime, it lets + * us centralize a bit of accounting (bytes_sent). + * + * These also return the number of bytes written by the call. + * They should only be called with a timeout registered, for obvious reaasons. + * (Ditto the send_header stuff). + */ + +/** + * Send an entire file to the client, using sendfile if supported by the + * current platform + * @param fd The file to send. + * @param r The current request + * @param offset Offset into the file to start sending. + * @param length Amount of data to send + * @param nbytes Amount of data actually sent + * @deffunc apr_status_t ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, apr_size_t length, apr_size_t *nbytes); + */ +AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, + apr_size_t length, apr_size_t *nbytes); + +#if APR_HAS_MMAP +/** + * Send an MMAP'ed file to the client + * @param mm The MMAP'ed file to send + * @param r The current request + * @param offset The offset into the MMAP to start sending + * @param length The amount of data to send + * @return The number of bytes sent + * @deffunc size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length) + */ +AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, + size_t length); +#endif + + +/** + * Register a new request method, and return the offset that will be + * associated with that method. + * + * @param p The pool to create registered method numbers from. + * @param methname The name of the new method to register. + * @return Ab int value representing an offset into a bitmask. + */ +AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname); + +/** + * Initialize the method_registry and allocate memory for it. + * + * @param p Pool to allocate memory for the registry from. + */ +AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p); + +/* + * This is a convenience macro to ease with checking a mask + * against a method name. + */ +#define AP_METHOD_CHECK_ALLOWED(mask, methname) \ + ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname)))) + +/** + * Create a new method list with the specified number of preallocated + * slots for extension methods. + * + * @param p Pointer to a pool in which the structure should be + * allocated. + * @param nelts Number of preallocated extension slots + * @return Pointer to the newly created structure. + * @deffunc ap_method_list_t ap_make_method_list(apr_pool_t *p, int nelts) + */ +AP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts); +AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest, + ap_method_list_t *src); +AP_DECLARE_NONSTD(void) ap_method_list_do(int (*comp) (void *urec, const char *mname, + int mnum), + void *rec, + const ap_method_list_t *ml, ...); +AP_DECLARE(void) ap_method_list_vdo(int (*comp) (void *urec, const char *mname, + int mnum), + void *rec, const ap_method_list_t *ml, + va_list vp); +/** + * Search for an HTTP method name in an ap_method_list_t structure, and + * return true if found. + * + * @param method String containing the name of the method to check. + * @param l Pointer to a method list, such as cmd->methods_limited. + * @return 1 if method is in the list, otherwise 0 + * @deffunc int ap_method_in_list(const char *method, ap_method_list_t *l) + */ +AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method); + +/** + * Add an HTTP method name to an ap_method_list_t structure if it isn't + * already listed. + * + * @param method String containing the name of the method to check. + * @param l Pointer to a method list, such as cmd->methods_limited. + * @return None. + * @deffunc void ap_method_in_list(ap_method_list_t *l, const char *method) + */ +AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method); + +/** + * Remove an HTTP method name from an ap_method_list_t structure. + * + * @param l Pointer to a method list, such as cmd->methods_limited. + * @param method String containing the name of the method to remove. + * @return None. + * @deffunc void ap_method_list_remove(ap_method_list_t *l, const char *method) + */ +AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l, + const char *method); + +/** + * Reset a method list to be completely empty. + * + * @param l Pointer to a method list, such as cmd->methods_limited. + * @return None. + * @deffunc void ap_clear_method_list(ap_method_list_t *l) + */ +AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l); + +/** + * Set the content type for this request (r->content_type). + * @param r The current request + * @param ct The new content type + * @deffunc void ap_set_content_type(request_rec *r, const char* ct) + * @warning This function must be called to set r->content_type in order + * for the AddOutputFilterByType directive to work correctly. + */ +AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct); + +/* Hmmm... could macrofy these for now, and maybe forever, though the + * definitions of the macros would get a whole lot hairier. + */ + +/** + * Output one character for this request + * @param c the character to output + * @param r the current request + * @return The number of bytes sent + * @deffunc int ap_rputc(int c, request_rec *r) + */ +AP_DECLARE(int) ap_rputc(int c, request_rec *r); + +/** + * Output a string for the current request + * @param str The string to output + * @param r The current request + * @return The number of bytes sent + * @deffunc int ap_rputs(const char *str, request_rec *r) + */ +AP_DECLARE(int) ap_rputs(const char *str, request_rec *r); + +/** + * Write a buffer for the current request + * @param buf The buffer to write + * @param nbyte The number of bytes to send from the buffer + * @param r The current request + * @return The number of bytes sent + * @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r) + */ +AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); + +/** + * Write an unspecified number of strings to the request + * @param r The current request + * @param ... The strings to write + * @return The number of bytes sent + * @deffunc int ap_rvputs(request_rec *r, ...) + */ +AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...); + +/** + * Output data to the client in a printf format + * @param r The current request + * @param fmt The format string + * @param vlist The arguments to use to fill out the format string + * @return The number of bytes sent + * @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist) + */ +AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist); + +/** + * Output data to the client in a printf format + * @param r The current request + * @param fmt The format string + * @param ... The arguments to use to fill out the format string + * @return The number of bytes sent + * @deffunc int ap_rprintf(request_rec *r, const char *fmt, ...) + */ +AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...) + __attribute__((format(printf,2,3))); +/** + * Flush all of the data for the current request to the client + * @param r The current request + * @return The number of bytes sent + * @deffunc int ap_rflush(request_rec *r) + */ +AP_DECLARE(int) ap_rflush(request_rec *r); + +/** + * Index used in custom_responses array for a specific error code + * (only use outside protocol.c is in getting them configured). + * @param status HTTP status code + * @return The index of the response + * @deffunc int ap_index_of_response(int status) + */ +AP_DECLARE(int) ap_index_of_response(int status); + +/** + * Return the Status-Line for a given status code (excluding the + * HTTP-Version field). If an invalid or unknown status code is + * passed, "500 Internal Server Error" will be returned. + * @param status The HTTP status code + * @return The Status-Line + * @deffunc const char *ap_get_status_line(int status) + */ +AP_DECLARE(const char *) ap_get_status_line(int status); + +/* Reading a block of data from the client connection (e.g., POST arg) */ + +/** + * Setup the client to allow Apache to read the request body. + * @param r The current request + * @param read_policy How the server should interpret a chunked + * transfer-encoding. One of:
+ *    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) + */ +AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy); + +/** + * 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) + */ +AP_DECLARE(int) ap_should_client_block(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz); + +/** + * 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) + */ +AP_DECLARE(int) ap_discard_request_body(request_rec *r); + + +/** + * 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) + */ +AP_DECLARE(void) ap_note_auth_failure(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw); + +/** + * 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) + */ +AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri); + +/** + * 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) + */ +AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int fold); + +/** + * 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 + */ +AP_DECLARE(int) ap_method_number_of(const char *method); + +/** + * 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 + */ +AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum); + + + /* 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) + */ +AP_DECLARE_HOOK(int,post_read_request,(request_rec *r)) + +/** + * 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) + */ +AP_DECLARE_HOOK(int,log_transaction,(request_rec *r)) + +/** + * 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) + */ +AP_DECLARE_HOOK(const char *,http_method,(const request_rec *r)) + +/** + * 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) + */ +AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r)) + +typedef struct ap_bucket_error ap_bucket_error; + +/** + * 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. + */ +struct ap_bucket_error { + /** Number of buckets using this memory */ + apr_bucket_refcount refcount; + /** The error code */ + int status; + /** The error string */ + const char *data; +}; + +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) + */ +AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error, + const char *buf, apr_pool_t *p); + +/** + * 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) + */ +AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf, + apr_pool_t *p, + apr_bucket_alloc_t *list); + +AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b); +AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b); +AP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *, + apr_bucket_brigade *); +AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b); + +/* + * Setting up the protocol fields for subsidiary requests... + * Also, a wrapup function to keep the internal accounting straight. + */ +AP_DECLARE(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r); +AP_DECLARE(void) ap_finalize_sub_req_protocol(request_rec *sub_r); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_PROTOCOL_H */ diff --git a/rubbos/app/apache2/include/http_request.h b/rubbos/app/apache2/include/http_request.h new file mode 100644 index 00000000..c10e44db --- /dev/null +++ b/rubbos/app/apache2/include/http_request.h @@ -0,0 +1,373 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_REQUEST_H +#define APACHE_HTTP_REQUEST_H + +#include "apr_hooks.h" +#include "util_filter.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define AP_SUBREQ_NO_ARGS 0 +#define 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 + */ +AP_DECLARE(int) ap_process_request_internal(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(request_rec *) ap_sub_req_lookup_uri(const char *new_uri, + const request_rec *r, + ap_filter_t *next_filter); + +/** + * 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) + */ +AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file, + const request_rec *r, + ap_filter_t *next_filter); +/** + * 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. + */ +AP_DECLARE(request_rec *) ap_sub_req_lookup_dirent(const apr_finfo_t *finfo, + const request_rec *r, + int subtype, + ap_filter_t *next_filter); +/** + * 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) + */ +AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method, + const char *new_uri, + const request_rec *r, + ap_filter_t *next_filter); +/** + * 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) + */ +AP_CORE_DECLARE_NONSTD(apr_status_t) ap_sub_req_output_filter(ap_filter_t *f, + apr_bucket_brigade *bb); + +/** + * 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) + */ +AP_DECLARE(int) ap_run_sub_req(request_rec *r); + +/** + * Free the memory associated with a subrequest + * @param r The subrequest to finish + * @deffunc void ap_destroy_sub_req(request_rec *r) + */ +AP_DECLARE(void) ap_destroy_sub_req(request_rec *r); + +/* + * 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) + */ +AP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r); + +/** + * 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) + */ +AP_DECLARE(void) ap_internal_redirect_handler(const char *new_uri, request_rec *r); + +/** + * 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! + */ +AP_DECLARE(void) ap_internal_fast_redirect(request_rec *sub_req, request_rec *r); + +/** + * 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) + */ +AP_DECLARE(int) ap_some_auth_required(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(int) ap_is_initial_req(request_rec *r); + +/** + * 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) + */ +AP_DECLARE(void) ap_update_mtime(request_rec *r, apr_time_t dependency_mtime); + +/** + * 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, ...) + */ +AP_DECLARE(void) ap_allow_methods(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, ...) + */ +AP_DECLARE(void) ap_allow_standard_methods(request_rec *r, int reset, ...); + +#define MERGE_ALLOW 0 +#define 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) + */ +AP_DECLARE(void) ap_die(int type, request_rec *r); +#endif + +/* Hooks */ + +/** + * Gives modules a chance to create their request_config entry when the + * request is created. + * @param r The current request + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,create_request,(request_rec *r)) + +/** + * 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 + */ +AP_DECLARE_HOOK(int,translate_name,(request_rec *r)) + +/** + * This hook allow modules to set the per_dir_config based on their own + * context (such as sections) and responds to contextless requests + * such as TRACE that need no security or filesystem mapping. + * based on the filesystem. + * @param r The current request + * @return DONE (or HTTP_) if this contextless request was just fulfilled + * (such as TRACE), OK if this is not a file, and DECLINED if this is a file. + * The core map_to_storage (HOOK_RUN_REALLY_LAST) will directory_walk + * and file_walk the r->filename. + * + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,map_to_storage,(request_rec *r)) + +/** + * This hook is used to analyze the request headers, authenticate the user, + * and set the user information in the request record (r->user and + * r->ap_auth_type). This hook is only run when Apache determines that + * authentication/authorization is required for this resource (as determined + * by the 'Require' directive). It runs after the access_checker hook, and + * before the auth_checker hook. + * + * @param r The current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,check_user_id,(request_rec *r)) + +/** + * Allows modules to perform module-specific fixing of header fields. This + * is invoked just before any content-handler + * @param r The current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,fixups,(request_rec *r)) + +/** + * This routine is called to determine and/or set the various document type + * information bits, like Content-type (via r->content_type), language, et + * cetera. + * @param r the current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,type_checker,(request_rec *r)) + +/** + * This hook is used to apply additional access control to this resource. + * It runs *before* a user is authenticated, so this hook is really to + * apply additional restrictions independent of a user. It also runs + * independent of 'Require' directive usage. + * + * @param r the current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,access_checker,(request_rec *r)) + +/** + * This hook is used to check to see if the resource being requested + * is available for the authenticated user (r->user and r->ap_auth_type). + * It runs after the access_checker and check_user_id hooks. Note that + * it will *only* be called if Apache determines that access control has + * been applied to this resource (through a 'Require' directive). + * + * @param r the current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,auth_checker,(request_rec *r)) + +/** + * This hook allows modules to insert filters for the current request + * @param r the current request + * @ingroup hooks + */ +AP_DECLARE_HOOK(void,insert_filter,(request_rec *r)) + +AP_DECLARE(int) ap_location_walk(request_rec *r); +AP_DECLARE(int) ap_directory_walk(request_rec *r); +AP_DECLARE(int) ap_file_walk(request_rec *r); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_REQUEST_H */ diff --git a/rubbos/app/apache2/include/http_vhost.h b/rubbos/app/apache2/include/http_vhost.h new file mode 100644 index 00000000..1acfd95f --- /dev/null +++ b/rubbos/app/apache2/include/http_vhost.h @@ -0,0 +1,109 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTP_VHOST_H +#define APACHE_HTTP_VHOST_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Virtual Host package + */ + +/** + * called before any config is read + * @param p Pool to allocate out of + */ +AP_DECLARE(void) ap_init_vhost_config(apr_pool_t *p); + +/** + * called after the config has been read to compile the tables needed to do + * the run-time vhost lookups + * @param p The pool to allocate out of + * @param main_server The start of the virtual host list + * @deffunc ap_fini_vhost_config(apr_pool_t *p, server_rec *main_server) + */ +AP_DECLARE(void) ap_fini_vhost_config(apr_pool_t *p, server_rec *main_server); + +/** + * handle addresses in statement + * @param p The pool to allocate out of + * @param hostname The hostname in the VirtualHost statement + * @param s The list of Virtual Hosts. + */ +const char *ap_parse_vhost_addrs(apr_pool_t *p, const char *hostname, server_rec *s); + +/* handle NameVirtualHost directive */ +const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, + const char *arg); + +/** + * Callback function for every Name Based Virtual Host. + * @param baton Opaque user object + * @param conn The current Connection + * @param s The current Server + * @see ap_vhost_iterate_given_conn + * @return 0 on success, any non-zero return will stop the iteration. + */ +typedef int(*ap_vhost_iterate_conn_cb)(void* baton, conn_rec* conn, server_rec* s); + +/** + * For every virtual host on this connection, call func_cb. + * @param conn The current connection + * @param func_cb Function called for every Name Based Virtual Host for this + * connection. + * @param baton Opaque object passed to func_cb. + * @return The return value from func_cb. + * @note If func_cb returns non-zero, the function will return at this point, + * and not continue iterating the virtual hosts. + */ +AP_DECLARE(int) ap_vhost_iterate_given_conn(conn_rec *conn, + ap_vhost_iterate_conn_cb func_cb, + void* baton); + +/** + * given an ip address only, give our best guess as to what vhost it is + * @param conn The current connection + */ +AP_DECLARE(void) ap_update_vhost_given_ip(conn_rec *conn); + +/** + * ap_update_vhost_given_ip is never enough, and this is always called after + * the headers have been read. It may change r->server. + * @param r The current request + */ +AP_DECLARE(void) ap_update_vhost_from_headers(request_rec *r); + +/** + * Match the host in the header with the hostname of the server for this + * request. + * @param r The current request + * @param host The hostname in the headers + * @param port The port from the headers + * @return return 1 if the host:port matches any of the aliases of r->server, + * return 0 otherwise + * @deffunc int ap_matches_request_vhost(request_rec *r, const char *host, apr_port_t port) + */ +AP_DECLARE(int) ap_matches_request_vhost(request_rec *r, const char *host, + apr_port_t port); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTP_VHOST_H */ diff --git a/rubbos/app/apache2/include/httpd.h b/rubbos/app/apache2/include/httpd.h new file mode 100644 index 00000000..4ad2df22 --- /dev/null +++ b/rubbos/app/apache2/include/httpd.h @@ -0,0 +1,1760 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_HTTPD_H +#define APACHE_HTTPD_H + +/** + * @file httpd.h + * @brief HTTP Daemon routines + */ + +/* XXX - We need to push more stuff to other .h files, or even .c files, to + * make this file smaller + */ + +/* Headers in which EVERYONE has an interest... */ +#include "ap_config.h" +#include "ap_mmn.h" + +#include "ap_release.h" + +#include "apr_general.h" +#include "apr_tables.h" +#include "apr_pools.h" +#include "apr_time.h" +#include "apr_network_io.h" +#include "apr_buckets.h" + +#include "os.h" + +#include "pcreposix.h" + +/* Note: util_uri.h is also included, see below */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CORE_PRIVATE + +/* ----------------------------- config dir ------------------------------ */ + +/* Define this to be the default server home dir. Most things later in this + * file with a relative pathname will have this added. + */ +#ifndef HTTPD_ROOT +#ifdef OS2 +/* Set default for OS/2 file system */ +#define HTTPD_ROOT "/os2httpd" +#elif defined(WIN32) +/* Set default for Windows file system */ +#define HTTPD_ROOT "/apache" +#elif defined (BEOS) +/* Set the default for BeOS */ +#define HTTPD_ROOT "/boot/home/apache" +#elif defined (NETWARE) +/* Set the default for NetWare */ +#define HTTPD_ROOT "/apache" +#else +#define HTTPD_ROOT "/usr/local/apache" +#endif +#endif /* HTTPD_ROOT */ + +/* + * --------- You shouldn't have to edit anything below this line ---------- + * + * Any modifications to any defaults not defined above should be done in the + * respective configuration file. + * + */ + +/* Default location of documents. Can be overridden by the DocumentRoot + * directive. + */ +#ifndef DOCUMENT_LOCATION +#ifdef OS2 +/* Set default for OS/2 file system */ +#define DOCUMENT_LOCATION HTTPD_ROOT "/docs" +#else +#define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs" +#endif +#endif /* DOCUMENT_LOCATION */ + +/* Maximum number of dynamically loaded modules */ +#ifndef DYNAMIC_MODULE_LIMIT +#define DYNAMIC_MODULE_LIMIT 64 +#endif + +/* Default administrator's address */ +#define DEFAULT_ADMIN "[no address given]" + +/* The name of the log files */ +#ifndef DEFAULT_ERRORLOG +#if defined(OS2) || defined(WIN32) +#define DEFAULT_ERRORLOG "logs/error.log" +#else +#define DEFAULT_ERRORLOG "logs/error_log" +#endif +#endif /* DEFAULT_ERRORLOG */ + +/* Define this to be what your per-directory security files are called */ +#ifndef DEFAULT_ACCESS_FNAME +#ifdef OS2 +/* Set default for OS/2 file system */ +#define DEFAULT_ACCESS_FNAME "htaccess" +#else +#define DEFAULT_ACCESS_FNAME ".htaccess" +#endif +#endif /* DEFAULT_ACCESS_FNAME */ + +/* The name of the server config file */ +#ifndef SERVER_CONFIG_FILE +#define SERVER_CONFIG_FILE "conf/httpd.conf" +#endif + +/* Whether we should enable rfc1413 identity checking */ +#ifndef DEFAULT_RFC1413 +#define DEFAULT_RFC1413 0 +#endif + +/* The default path for CGI scripts if none is currently set */ +#ifndef DEFAULT_PATH +#define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin" +#endif + +/* The path to the suExec wrapper, can be overridden in Configuration */ +#ifndef SUEXEC_BIN +#define SUEXEC_BIN HTTPD_ROOT "/bin/suexec" +#endif + +/* The timeout for waiting for messages */ +#ifndef DEFAULT_TIMEOUT +#define DEFAULT_TIMEOUT 300 +#endif + +/* The timeout for waiting for keepalive timeout until next request */ +#ifndef DEFAULT_KEEPALIVE_TIMEOUT +#define DEFAULT_KEEPALIVE_TIMEOUT 15 +#endif + +/* The number of requests to entertain per connection */ +#ifndef DEFAULT_KEEPALIVE +#define DEFAULT_KEEPALIVE 100 +#endif + +/* Limits on the size of various request items. These limits primarily + * exist to prevent simple denial-of-service attacks on a server based + * on misuse of the protocol. The recommended values will depend on the + * nature of the server resources -- CGI scripts and database backends + * might require large values, but most servers could get by with much + * smaller limits than we use below. The request message body size can + * be limited by the per-dir config directive LimitRequestBody. + * + * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE + * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190. + * These two limits can be lowered (but not raised) by the server config + * directives LimitRequestLine and LimitRequestFieldsize, respectively. + * + * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by + * the server config directive LimitRequestFields. + */ +#ifndef DEFAULT_LIMIT_REQUEST_LINE +#define DEFAULT_LIMIT_REQUEST_LINE 8190 +#endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE +#define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190 +#endif /* default limit on bytes in any one header field */ +#ifndef DEFAULT_LIMIT_REQUEST_FIELDS +#define DEFAULT_LIMIT_REQUEST_FIELDS 100 +#endif /* default limit on number of request header fields */ + + +/** + * The default default character set name to add if AddDefaultCharset is + * enabled. Overridden with AddDefaultCharsetName. + */ +#define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1" + +#endif /* CORE_PRIVATE */ + +/** default HTTP Server protocol */ +#define AP_SERVER_PROTOCOL "HTTP/1.1" + + +/* ------------------ stuff that modules are allowed to look at ----------- */ + +/** Define this to be what your HTML directory content files are called */ +#ifndef AP_DEFAULT_INDEX +#define AP_DEFAULT_INDEX "index.html" +#endif + + +/** + * Define this to be what type you'd like returned for files with unknown + * suffixes. + * @warning MUST be all lower case. + */ +#ifndef DEFAULT_CONTENT_TYPE +#define DEFAULT_CONTENT_TYPE "text/plain" +#endif + +/** The name of the MIME types file */ +#ifndef AP_TYPES_CONFIG_FILE +#define AP_TYPES_CONFIG_FILE "conf/mime.types" +#endif + +/* + * Define the HTML doctype strings centrally. + */ +/** HTML 2.0 Doctype */ +#define DOCTYPE_HTML_2_0 "\n" +/** HTML 3.2 Doctype */ +#define DOCTYPE_HTML_3_2 "\n" +/** HTML 4.0 Strict Doctype */ +#define DOCTYPE_HTML_4_0S "\n" +/** HTML 4.0 Transitional Doctype */ +#define DOCTYPE_HTML_4_0T "\n" +/** HTML 4.0 Frameset Doctype */ +#define DOCTYPE_HTML_4_0F "\n" +/** XHTML 1.0 Strict Doctype */ +#define DOCTYPE_XHTML_1_0S "\n" +/** XHTML 1.0 Transitional Doctype */ +#define DOCTYPE_XHTML_1_0T "\n" +/** XHTML 1.0 Frameset Doctype */ +#define DOCTYPE_XHTML_1_0F "" + +/** Internal representation for a HTTP protocol number, e.g., HTTP/1.1 */ + +#define HTTP_VERSION(major,minor) (1000*(major)+(minor)) +/** Major part of HTTP protocol */ +#define HTTP_VERSION_MAJOR(number) ((number)/1000) +/** Minor part of HTTP protocol */ +#define HTTP_VERSION_MINOR(number) ((number)%1000) + +/* -------------- Port number for server running standalone --------------- */ + +/** default HTTP Port */ +#define DEFAULT_HTTP_PORT 80 +/** default HTTPS Port */ +#define DEFAULT_HTTPS_PORT 443 +/** + * Check whether @a port is the default port for the request @a r. + * @param port The port number + * @param r The request + * @see #ap_default_port + */ +#define ap_is_default_port(port,r) ((port) == ap_default_port(r)) +/** + * Get the default port for a request (which depends on the scheme). + * @param r The request + */ +#define ap_default_port(r) ap_run_default_port(r) +/** + * Get the scheme for a request. + * @param r The request + * @bug This should be called ap_http_scheme! + */ +#define ap_http_method(r) ap_run_http_method(r) + +/** The default string lengths */ +#define MAX_STRING_LEN HUGE_STRING_LEN +#define HUGE_STRING_LEN 8192 + +/** The size of the server's internal read-write buffers */ +#define AP_IOBUFSIZE 8192 + +/** The max number of regex captures that can be expanded by ap_pregsub */ +#define AP_MAX_REG_MATCH 10 + +/** + * APR_HAS_LARGE_FILES introduces the problem of spliting sendfile into + * mutiple buckets, no greater than MAX(apr_size_t), and more granular + * than that in case the brigade code/filters attempt to read it directly. + * ### 16mb is an invention, no idea if it is reasonable. + */ +#define AP_MAX_SENDFILE 16777216 /* 2^24 */ + +/** + * Special Apache error codes. These are basically used + * in http_main.c so we can keep track of various errors. + * + */ +/** a normal exit */ +#define APEXIT_OK 0x0 +/** A fatal error arising during the server's init sequence */ +#define APEXIT_INIT 0x2 +/** The child died during its init sequence */ +#define APEXIT_CHILDINIT 0x3 +/** + * The child exited due to a resource shortage. + * The parent should limit the rate of forking until + * the situation is resolved. + */ +#define APEXIT_CHILDSICK 0x7 +/** + * A fatal error, resulting in the whole server aborting. + * If a child exits with this error, the parent process + * considers this a server-wide fatal error and aborts. + */ +#define APEXIT_CHILDFATAL 0xf + +#ifndef AP_DECLARE +/** + * Stuff marked #AP_DECLARE is part of the API, and intended for use + * by modules. Its purpose is to allow us to add attributes that + * particular platforms or compilers require to every exported function. + */ +# define AP_DECLARE(type) type +#endif + +#ifndef AP_DECLARE_NONSTD +/** + * Stuff marked #AP_DECLARE_NONSTD is part of the API, and intended for + * use by modules. The difference between #AP_DECLARE and + * #AP_DECLARE_NONSTD is that the latter is required for any functions + * which use varargs or are used via indirect function call. This + * is to accomodate the two calling conventions in windows dlls. + */ +# define AP_DECLARE_NONSTD(type) type +#endif +#ifndef AP_DECLARE_DATA +# define AP_DECLARE_DATA +#endif + +#ifndef AP_MODULE_DECLARE +# define AP_MODULE_DECLARE(type) type +#endif +#ifndef AP_MODULE_DECLARE_NONSTD +# define AP_MODULE_DECLARE_NONSTD(type) type +#endif +#ifndef AP_MODULE_DECLARE_DATA +# define AP_MODULE_DECLARE_DATA +#endif + +/** + * @internal + * modules should not used functions marked AP_CORE_DECLARE + */ +#ifndef AP_CORE_DECLARE +# define AP_CORE_DECLARE AP_DECLARE +#endif +/** + * @internal + * modules should not used functions marked AP_CORE_DECLARE_NONSTD + */ + +#ifndef AP_CORE_DECLARE_NONSTD +# define AP_CORE_DECLARE_NONSTD AP_DECLARE_NONSTD +#endif + +/** + * The numeric version information is broken out into fields within this + * structure. + */ +typedef struct { + int major; /**< major number */ + int minor; /**< minor number */ + int patch; /**< patch number */ + const char *add_string; /**< additional string like "-dev" */ +} ap_version_t; + +/** + * Return httpd's version information in a numeric form. + * + * @param version Pointer to a version structure for returning the version + * information. + */ +AP_DECLARE(void) ap_get_server_revision(ap_version_t *version); + +/** + * Get the server version string + * @return The server version string + */ +AP_DECLARE(const char *) ap_get_server_version(void); + +/** + * Add a component to the version string + * @param pconf The pool to allocate the component from + * @param component The string to add + */ +AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component); + +/** + * Get the date a time that the server was built + * @return The server build time string + */ +AP_DECLARE(const char *) ap_get_server_built(void); + +#define DECLINED -1 /**< Module declines to handle */ +#define DONE -2 /**< Module has served the response completely + * - it's safe to die() with no more output + */ +#define OK 0 /**< Module has handled this stage. */ + + +/** + * @defgroup HTTP_Status HTTP Status Codes + * @{ + */ +/** + * The size of the static array in http_protocol.c for storing + * all of the potential response status-lines (a sparse table). + * A future version should dynamically generate the apr_table_t at startup. + */ +#define RESPONSE_CODES 57 + +#define HTTP_CONTINUE 100 +#define HTTP_SWITCHING_PROTOCOLS 101 +#define HTTP_PROCESSING 102 +#define HTTP_OK 200 +#define HTTP_CREATED 201 +#define HTTP_ACCEPTED 202 +#define HTTP_NON_AUTHORITATIVE 203 +#define HTTP_NO_CONTENT 204 +#define HTTP_RESET_CONTENT 205 +#define HTTP_PARTIAL_CONTENT 206 +#define HTTP_MULTI_STATUS 207 +#define HTTP_MULTIPLE_CHOICES 300 +#define HTTP_MOVED_PERMANENTLY 301 +#define HTTP_MOVED_TEMPORARILY 302 +#define HTTP_SEE_OTHER 303 +#define HTTP_NOT_MODIFIED 304 +#define HTTP_USE_PROXY 305 +#define HTTP_TEMPORARY_REDIRECT 307 +#define HTTP_BAD_REQUEST 400 +#define HTTP_UNAUTHORIZED 401 +#define HTTP_PAYMENT_REQUIRED 402 +#define HTTP_FORBIDDEN 403 +#define HTTP_NOT_FOUND 404 +#define HTTP_METHOD_NOT_ALLOWED 405 +#define HTTP_NOT_ACCEPTABLE 406 +#define HTTP_PROXY_AUTHENTICATION_REQUIRED 407 +#define HTTP_REQUEST_TIME_OUT 408 +#define HTTP_CONFLICT 409 +#define HTTP_GONE 410 +#define HTTP_LENGTH_REQUIRED 411 +#define HTTP_PRECONDITION_FAILED 412 +#define HTTP_REQUEST_ENTITY_TOO_LARGE 413 +#define HTTP_REQUEST_URI_TOO_LARGE 414 +#define HTTP_UNSUPPORTED_MEDIA_TYPE 415 +#define HTTP_RANGE_NOT_SATISFIABLE 416 +#define HTTP_EXPECTATION_FAILED 417 +#define HTTP_UNPROCESSABLE_ENTITY 422 +#define HTTP_LOCKED 423 +#define HTTP_FAILED_DEPENDENCY 424 +#define HTTP_UPGRADE_REQUIRED 426 +#define HTTP_INTERNAL_SERVER_ERROR 500 +#define HTTP_NOT_IMPLEMENTED 501 +#define HTTP_BAD_GATEWAY 502 +#define HTTP_SERVICE_UNAVAILABLE 503 +#define HTTP_GATEWAY_TIME_OUT 504 +#define HTTP_VERSION_NOT_SUPPORTED 505 +#define HTTP_VARIANT_ALSO_VARIES 506 +#define HTTP_INSUFFICIENT_STORAGE 507 +#define HTTP_NOT_EXTENDED 510 + +/** is the status code informational */ +#define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) +/** is the status code OK ?*/ +#define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) +/** is the status code a redirect */ +#define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) +/** is the status code a error (client or server) */ +#define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) +/** is the status code a client error */ +#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) +/** is the status code a server error */ +#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) + +/** should the status code drop the connection */ +#define ap_status_drops_connection(x) \ + (((x) == HTTP_BAD_REQUEST) || \ + ((x) == HTTP_REQUEST_TIME_OUT) || \ + ((x) == HTTP_LENGTH_REQUIRED) || \ + ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \ + ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \ + ((x) == HTTP_INTERNAL_SERVER_ERROR) || \ + ((x) == HTTP_SERVICE_UNAVAILABLE) || \ + ((x) == HTTP_NOT_IMPLEMENTED)) +/** @} */ +/** + * @defgroup Methods List of Methods recognized by the server + * @{ + */ +/** + * Methods recognized (but not necessarily handled) by the server. + * These constants are used in bit shifting masks of size int, so it is + * unsafe to have more methods than bits in an int. HEAD == M_GET. + * This list must be tracked by the list in http_protocol.c in routine + * ap_method_name_of(). + */ +#define M_GET 0 /* RFC 2616: HTTP */ +#define M_PUT 1 /* : */ +#define M_POST 2 +#define M_DELETE 3 +#define M_CONNECT 4 +#define M_OPTIONS 5 +#define M_TRACE 6 /* RFC 2616: HTTP */ +#define M_PATCH 7 /* no rfc(!) ### remove this one? */ +#define M_PROPFIND 8 /* RFC 2518: WebDAV */ +#define M_PROPPATCH 9 /* : */ +#define M_MKCOL 10 +#define M_COPY 11 +#define M_MOVE 12 +#define M_LOCK 13 +#define M_UNLOCK 14 /* RFC 2518: WebDAV */ +#define M_VERSION_CONTROL 15 /* RFC 3253: WebDAV Versioning */ +#define M_CHECKOUT 16 /* : */ +#define M_UNCHECKOUT 17 +#define M_CHECKIN 18 +#define M_UPDATE 19 +#define M_LABEL 20 +#define M_REPORT 21 +#define M_MKWORKSPACE 22 +#define M_MKACTIVITY 23 +#define M_BASELINE_CONTROL 24 +#define M_MERGE 25 +#define M_INVALID 26 /* RFC 3253: WebDAV Versioning */ + +/** + * METHODS needs to be equal to the number of bits + * we are using for limit masks. + */ +#define METHODS 64 + +/** + * The method mask bit to shift for anding with a bitmask. + */ +#define AP_METHOD_BIT ((apr_int64_t)1) +/** @} */ + + +/** + * Structure for handling HTTP methods. Methods known to the server are + * accessed via a bitmask shortcut; extension methods are handled by + * an array. + */ +typedef struct ap_method_list_t ap_method_list_t; +struct ap_method_list_t { + /* The bitmask used for known methods */ + apr_int64_t method_mask; + /* the array used for extension methods */ + apr_array_header_t *method_list; +}; +/** + * @defgroup module_magic Module Magic mime types + * @{ + */ +/** Magic for mod_cgi[d] */ +#define CGI_MAGIC_TYPE "application/x-httpd-cgi" +/** Magic for mod_include */ +#define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html" +/** Magic for mod_include */ +#define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3" +/** Magic for mod_dir */ +#define DIR_MAGIC_TYPE "httpd/unix-directory" + +/** @} */ +/* Just in case your linefeed isn't the one the other end is expecting. */ +#if !APR_CHARSET_EBCDIC +/** linefeed */ +#define LF 10 +/** carrige return */ +#define CR 13 +/** carrige return /Line Feed Combo */ +#define CRLF "\015\012" +#else /* APR_CHARSET_EBCDIC */ +/* For platforms using the EBCDIC charset, the transition ASCII->EBCDIC is done + * in the buff package (bread/bputs/bwrite). Everywhere else, we use + * "native EBCDIC" CR and NL characters. These are therefore + * defined as + * '\r' and '\n'. + */ +#define CR '\r' +#define LF '\n' +#define CRLF "\r\n" +#endif /* APR_CHARSET_EBCDIC */ + +/** + * @defgroup values_request_rec_body Possible values for request_rec.read_body + * @{ + * Possible values for request_rec.read_body (set by handling module): + */ + +/** Send 413 error if message has any body */ +#define REQUEST_NO_BODY 0 +/** Send 411 error if body without Content-Length */ +#define REQUEST_CHUNKED_ERROR 1 +/** If chunked, remove the chunks for me. */ +#define REQUEST_CHUNKED_DECHUNK 2 +/** @} */ + +/** + * @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info + * @{ + * Possible values for request_rec.used_path_info: + */ + +/** Accept the path_info from the request */ +#define AP_REQ_ACCEPT_PATH_INFO 0 +/** Return a 404 error if path_info was given */ +#define AP_REQ_REJECT_PATH_INFO 1 +/** Module may chose to use the given path_info */ +#define AP_REQ_DEFAULT_PATH_INFO 2 +/** @} */ + +/* + * Things which may vary per file-lookup WITHIN a request --- + * e.g., state of MIME config. Basically, the name of an object, info + * about the object, and any other info we may ahve which may need to + * change as we go poking around looking for it (e.g., overridden by + * .htaccess files). + * + * Note how the default state of almost all these things is properly + * zero, so that allocating it with pcalloc does the right thing without + * a whole lot of hairy initialization... so long as we are willing to + * make the (fairly) portable assumption that the bit pattern of a NULL + * pointer is, in fact, zero. + */ + +/** + * This represents the result of calling htaccess; these are cached for + * each request. + */ +struct htaccess_result { + /** the directory to which this applies */ + const char *dir; + /** the overrides allowed for the .htaccess file */ + int override; + /** the configuration directives */ + struct ap_conf_vector_t *htaccess; + /** the next one, or NULL if no more; N.B. never change this */ + const struct htaccess_result *next; +}; + +/* The following four types define a hierarchy of activities, so that + * given a request_rec r you can write r->connection->server->process + * to get to the process_rec. While this reduces substantially the + * number of arguments that various hooks require beware that in + * threaded versions of the server you must consider multiplexing + * issues. */ + + +/** A structure that represents one process */ +typedef struct process_rec process_rec; +/** A structure that represents a virtual server */ +typedef struct server_rec server_rec; +/** A structure that represents one connection */ +typedef struct conn_rec conn_rec; +/** A structure that represents the current request */ +typedef struct request_rec request_rec; + +/* ### would be nice to not include this from httpd.h ... */ +/* This comes after we have defined the request_rec type */ +#include "apr_uri.h" + +/** A structure that represents one process */ +struct process_rec { + /** Global pool. Cleared upon normal exit */ + apr_pool_t *pool; + /** Configuration pool. Cleared upon restart */ + apr_pool_t *pconf; + /** Number of command line arguments passed to the program */ + int argc; + /** The command line arguments */ + const char * const *argv; + /** The program name used to execute the program */ + const char *short_name; +}; + +/** A structure that represents the current request */ +struct request_rec { + /** The pool associated with the request */ + apr_pool_t *pool; + /** The connection to the client */ + conn_rec *connection; + /** The virtual host for this request */ + server_rec *server; + + /** Pointer to the redirected request if this is an external redirect */ + request_rec *next; + /** Pointer to the previous request if this is an internal redirect */ + request_rec *prev; + + /** Pointer to the main request if this is a sub-request + * (see http_request.h) */ + request_rec *main; + + /* Info about the request itself... we begin with stuff that only + * protocol.c should ever touch... + */ + /** First line of request */ + char *the_request; + /** HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers) */ + int assbackwards; + /** A proxy request (calculated during post_read_request/translate_name) + * possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE, + * PROXYREQ_RESPONSE + */ + int proxyreq; + /** HEAD request, as opposed to GET */ + int header_only; + /** Protocol string, as given to us, or HTTP/0.9 */ + char *protocol; + /** Protocol version number of protocol; 1.1 = 1001 */ + int proto_num; + /** Host, as set by full URI or Host: */ + const char *hostname; + + /** Time when the request started */ + apr_time_t request_time; + + /** Status line, if set by script */ + const char *status_line; + /** Status line */ + int status; + + /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, + * look, but don't touch. + */ + + /** Request method (eg. GET, HEAD, POST, etc.) */ + const char *method; + /** M_GET, M_POST, etc. */ + int method_number; + + /** + * 'allowed' is a bitvector of the allowed methods. + * + * A handler must ensure that the request method is one that + * it is capable of handling. Generally modules should DECLINE + * any request methods they do not handle. Prior to aborting the + * handler like this the handler should set r->allowed to the list + * of methods that it is willing to handle. This bitvector is used + * to construct the "Allow:" header required for OPTIONS requests, + * and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes. + * + * Since the default_handler deals with OPTIONS, all modules can + * usually decline to deal with OPTIONS. TRACE is always allowed, + * modules don't need to set it explicitly. + * + * Since the default_handler will always handle a GET, a + * module which does *not* implement GET should probably return + * HTTP_METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET + * handler can't be installed by mod_actions. + */ + apr_int64_t allowed; + /** Array of extension methods */ + apr_array_header_t *allowed_xmethods; + /** List of allowed methods */ + ap_method_list_t *allowed_methods; + + /** byte count in stream is for body */ + apr_off_t sent_bodyct; + /** body byte count, for easy access */ + apr_off_t bytes_sent; + /** Last modified time of the requested resource */ + apr_time_t mtime; + + /* HTTP/1.1 connection-level features */ + + /** sending chunked transfer-coding */ + int chunked; + /** The Range: header */ + const char *range; + /** The "real" content length */ + apr_off_t clength; + + /** Remaining bytes left to read from the request body */ + apr_off_t remaining; + /** Number of bytes that have been read from the request body */ + apr_off_t read_length; + /** Method for reading the request body + * (eg. REQUEST_CHUNKED_ERROR, REQUEST_NO_BODY, + * REQUEST_CHUNKED_DECHUNK, etc...) */ + int read_body; + /** reading chunked transfer-coding */ + int read_chunked; + /** is client waiting for a 100 response? */ + unsigned expecting_100; + + /* MIME header environments, in and out. Also, an array containing + * environment variables to be passed to subprocesses, so people can + * write modules to add to that environment. + * + * The difference between headers_out and err_headers_out is that the + * latter are printed even on error, and persist across internal redirects + * (so the headers printed for ErrorDocument handlers will have them). + * + * The 'notes' apr_table_t is for notes from one module to another, with no + * other set purpose in mind... + */ + + /** MIME header environment from the request */ + apr_table_t *headers_in; + /** MIME header environment for the response */ + apr_table_t *headers_out; + /** MIME header environment for the response, printed even on errors and + * persist across internal redirects */ + apr_table_t *err_headers_out; + /** Array of environment variables to be used for sub processes */ + apr_table_t *subprocess_env; + /** Notes from one module to another */ + apr_table_t *notes; + + /* content_type, handler, content_encoding, and all content_languages + * MUST be lowercased strings. They may be pointers to static strings; + * they should not be modified in place. + */ + /** The content-type for the current request */ + const char *content_type; /* Break these out --- we dispatch on 'em */ + /** The handler string that we use to call a handler function */ + const char *handler; /* What we *really* dispatch on */ + + /** How to encode the data */ + const char *content_encoding; + /** Array of strings representing the content languages */ + apr_array_header_t *content_languages; + + /** variant list validator (if negotiated) */ + char *vlist_validator; + + /** If an authentication check was made, this gets set to the user name. */ + char *user; + /** If an authentication check was made, this gets set to the auth type. */ + char *ap_auth_type; + + /** This response can not be cached */ + int no_cache; + /** There is no local copy of this response */ + int no_local_copy; + + /* What object is being requested (either directly, or via include + * or content-negotiation mapping). + */ + + /** The URI without any parsing performed */ + char *unparsed_uri; + /** The path portion of the URI, or "/" if no path provided */ + char *uri; + /** The filename on disk corresponding to this response */ + char *filename; + /* XXX: What does this mean? Please define "canonicalize" -aaron */ + /** The true filename, we canonicalize r->filename if these don't match */ + char *canonical_filename; + /** The PATH_INFO extracted from this request */ + char *path_info; + /** The QUERY_ARGS extracted from this request */ + char *args; + /** finfo.protection (st_mode) set to zero if no such file */ + apr_finfo_t finfo; + /** A struct containing the components of URI */ + apr_uri_t parsed_uri; + + /** + * Flag for the handler to accept or reject path_info on + * the current request. All modules should respect the + * AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO + * values, while AP_REQ_DEFAULT_PATH_INFO indicates they + * may follow existing conventions. This is set to the + * user's preference upon HOOK_VERY_FIRST of the fixups. + */ + int used_path_info; + + /* Various other config info which may change with .htaccess files + * These are config vectors, with one void* pointer for each module + * (the thing pointed to being the module's business). + */ + + /** Options set in config files, etc. */ + struct ap_conf_vector_t *per_dir_config; + /** Notes on *this* request */ + struct ap_conf_vector_t *request_config; + + /** + * A linked list of the .htaccess configuration directives + * accessed by this request. + * N.B. always add to the head of the list, _never_ to the end. + * that way, a sub request's list can (temporarily) point to a parent's list + */ + const struct htaccess_result *htaccess; + + /** A list of output filters to be used for this request */ + struct ap_filter_t *output_filters; + /** A list of input filters to be used for this request */ + struct ap_filter_t *input_filters; + + /** A list of protocol level output filters to be used for this + * request */ + struct ap_filter_t *proto_output_filters; + /** A list of protocol level input filters to be used for this + * request */ + struct ap_filter_t *proto_input_filters; + + /** A flag to determine if the eos bucket has been sent yet */ + int eos_sent; + +/* Things placed at the end of the record to avoid breaking binary + * compatibility. It would be nice to remember to reorder the entire + * record to improve 64bit alignment the next time we need to break + * binary compatibility for some other reason. + */ +}; + +/** + * @defgroup ProxyReq Proxy request types + * + * Possible values of request_rec->proxyreq. A request could be normal, + * proxied or reverse proxied. Normally proxied and reverse proxied are + * grouped together as just "proxied", but sometimes it's necessary to + * tell the difference between the two, such as for authentication. + * @{ + */ + +#define PROXYREQ_NONE 0 /**< No proxy */ +#define PROXYREQ_PROXY 1 /**< Standard proxy */ +#define PROXYREQ_REVERSE 2 /**< Reverse proxy */ +#define PROXYREQ_RESPONSE 3 /**< Origin response */ + +/* @} */ + +typedef enum { + AP_CONN_UNKNOWN, + AP_CONN_CLOSE, + AP_CONN_KEEPALIVE +} ap_conn_keepalive_e; + +/** Structure to store things which are per connection */ +struct conn_rec { + /** Pool associated with this connection */ + apr_pool_t *pool; + /** Physical vhost this conn came in on */ + server_rec *base_server; + /** used by http_vhost.c */ + void *vhost_lookup_data; + + /* Information about the connection itself */ + /** local address */ + apr_sockaddr_t *local_addr; + /** remote address */ + apr_sockaddr_t *remote_addr; + + /** Client's IP address */ + char *remote_ip; + /** Client's DNS name, if known. NULL if DNS hasn't been checked, + * "" if it has and no address was found. N.B. Only access this though + * get_remote_host() */ + char *remote_host; + /** Only ever set if doing rfc1413 lookups. N.B. Only access this through + * get_remote_logname() */ + char *remote_logname; + + /** Are we still talking? */ + unsigned aborted:1; + + /** Are we going to keep the connection alive for another request? + * @see ap_conn_keepalive_e */ + ap_conn_keepalive_e keepalive; + + /** have we done double-reverse DNS? -1 yes/failure, 0 not yet, + * 1 yes/success */ + signed int double_reverse:2; + + /** How many times have we used it? */ + int keepalives; + /** server IP address */ + char *local_ip; + /** used for ap_get_server_name when UseCanonicalName is set to DNS + * (ignores setting of HostnameLookups) */ + char *local_host; + + /** ID of this connection; unique at any point in time */ + long id; + /** Config vector containing pointers to connections per-server + * config structures. */ + struct ap_conf_vector_t *conn_config; + /** Notes on *this* connection: send note from one module to + * another. must remain valid for all requests on this conn */ + apr_table_t *notes; + /** A list of input filters to be used for this connection */ + struct ap_filter_t *input_filters; + /** A list of output filters to be used for this connection */ + struct ap_filter_t *output_filters; + /** handle to scoreboard information for this connection */ + void *sbh; + /** The bucket allocator to use for all bucket/brigade creations */ + struct apr_bucket_alloc_t *bucket_alloc; +}; + +/* Per-vhost config... */ + +/** + * The address 255.255.255.255, when used as a virtualhost address, + * will become the "default" server when the ip doesn't match other vhosts. + */ +#define DEFAULT_VHOST_ADDR 0xfffffffful + + +/** A structure to be used for Per-vhost config */ +typedef struct server_addr_rec server_addr_rec; +struct server_addr_rec { + /** The next server in the list */ + server_addr_rec *next; + /** The bound address, for this server */ + apr_sockaddr_t *host_addr; + /** The bound port, for this server */ + apr_port_t host_port; + /** The name given in */ + char *virthost; +}; + +/** A structure to store information for each virtual server */ +struct server_rec { + /** The process this server is running in */ + process_rec *process; + /** The next server in the list */ + server_rec *next; + + /** The name of the server */ + const char *defn_name; + /** The line of the config file that the server was defined on */ + unsigned defn_line_number; + + /* Contact information */ + + /** The admin's contact information */ + char *server_admin; + /** The server hostname */ + char *server_hostname; + /** for redirects, etc. */ + apr_port_t port; + + /* Log files --- note that transfer log is now in the modules... */ + + /** The name of the error log */ + char *error_fname; + /** A file descriptor that references the error log */ + apr_file_t *error_log; + /** The log level for this server */ + int loglevel; + + /* Module-specific configuration for server, and defaults... */ + + /** true if this is the virtual server */ + int is_virtual; + /** Config vector containing pointers to modules' per-server config + * structures. */ + struct ap_conf_vector_t *module_config; + /** MIME type info, etc., before we start checking per-directory info */ + struct ap_conf_vector_t *lookup_defaults; + + /* Transaction handling */ + + /** I haven't got a clue */ + server_addr_rec *addrs; + /** Timeout, as an apr interval, before we give up */ + apr_interval_time_t timeout; + /** The apr interval we will wait for another request */ + apr_interval_time_t keep_alive_timeout; + /** Maximum requests per connection */ + int keep_alive_max; + /** Use persistent connections? */ + int keep_alive; + + /** Pathname for ServerPath */ + const char *path; + /** Length of path */ + int pathlen; + + /** Normal names for ServerAlias servers */ + apr_array_header_t *names; + /** Wildcarded names for ServerAlias servers */ + apr_array_header_t *wild_names; + + /** limit on size of the HTTP request line */ + int limit_req_line; + /** limit on size of any request header field */ + int limit_req_fieldsize; + /** limit on number of request header fields */ + int limit_req_fields; +}; + +typedef struct core_output_filter_ctx { + apr_bucket_brigade *b; + apr_pool_t *deferred_write_pool; /* subpool of c->pool used for resources + * which may outlive the request + */ +} core_output_filter_ctx_t; + +typedef struct core_filter_ctx { + apr_bucket_brigade *b; + apr_bucket_brigade *tmpbb; +} core_ctx_t; + +typedef struct core_net_rec { + /** Connection to the client */ + apr_socket_t *client_socket; + + /** connection record */ + conn_rec *c; + + core_output_filter_ctx_t *out_ctx; + core_ctx_t *in_ctx; +} core_net_rec; + +/** + * Examine a field value (such as a media-/content-type) string and return + * it sans any parameters; e.g., strip off any ';charset=foo' and the like. + * @param p Pool to allocate memory from + * @param intype The field to examine + * @return A copy of the field minus any parameters + */ +AP_DECLARE(char *) ap_field_noparam(apr_pool_t *p, const char *intype); + +/** + * Convert a time from an integer into a string in a specified format + * @param p The pool to allocate memory from + * @param t The time to convert + * @param fmt The format to use for the conversion + * @param gmt Convert the time for GMT? + * @return The string that represents the specified time + */ +AP_DECLARE(char *) ap_ht_time(apr_pool_t *p, apr_time_t t, const char *fmt, int gmt); + +/* String handling. The *_nc variants allow you to use non-const char **s as + arguments (unfortunately C won't automatically convert a char ** to a const + char **) */ + +/** + * Get the characters until the first occurance of a specified character + * @param p The pool to allocate memory from + * @param line The string to get the characters from + * @param stop The character to stop at + * @return A copy of the characters up to the first stop character + */ +AP_DECLARE(char *) ap_getword(apr_pool_t *p, const char **line, char stop); +/** + * Get the characters until the first occurance of a specified character + * @param p The pool to allocate memory from + * @param line The string to get the characters from + * @param stop The character to stop at + * @return A copy of the characters up to the first stop character + * @note This is the same as ap_getword(), except it doesn't use const char **. + */ +AP_DECLARE(char *) ap_getword_nc(apr_pool_t *p, char **line, char stop); + +/** + * Get the first word from a given string. A word is defined as all characters + * up to the first whitespace. + * @param p The pool to allocate memory from + * @param line The string to traverse + * @return The first word in the line + */ +AP_DECLARE(char *) ap_getword_white(apr_pool_t *p, const char **line); +/** + * Get the first word from a given string. A word is defined as all characters + * up to the first whitespace. + * @param p The pool to allocate memory from + * @param line The string to traverse + * @return The first word in the line + * @note The same as ap_getword_white(), except it doesn't use const char **. + */ +AP_DECLARE(char *) ap_getword_white_nc(apr_pool_t *p, char **line); + +/** + * Get all characters from the first occurance of @a stop to the first '\0' + * @param p The pool to allocate memory from + * @param line The line to traverse + * @param stop The character to start at + * @return A copy of all caracters after the first occurance of the specified + * character + */ +AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *p, const char **line, + char stop); +/** + * Get all characters from the first occurance of @a stop to the first '\0' + * @param p The pool to allocate memory from + * @param line The line to traverse + * @param stop The character to start at + * @return A copy of all caracters after the first occurance of the specified + * character + * @note The same as ap_getword_nulls(), except it doesn't use const char **. + */ +AP_DECLARE(char *) ap_getword_nulls_nc(apr_pool_t *p, char **line, char stop); + +/** + * Get the second word in the string paying attention to quoting + * @param p The pool to allocate from + * @param line The line to traverse + * @return A copy of the string + */ +AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line); +/** + * Get the second word in the string paying attention to quoting + * @param p The pool to allocate from + * @param line The line to traverse + * @return A copy of the string + * @note The same as ap_getword_conf(), except it doesn't use const char **. + */ +AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line); + +/** + * Check a string for any ${ENV} environment variable construct and replace + * each them by the value of that environment variable, if it exists. If the + * environment value does not exist, leave the ${ENV} construct alone; it + * means something else. + * @param p The pool to allocate from + * @param word The string to check + * @return The string with the replaced environment variables + */ +AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word); + +/** + * Size an HTTP header field list item, as separated by a comma. + * @param field The field to size + * @param len The length of the field + * @return The return value is a pointer to the beginning of the non-empty + * list item within the original string (or NULL if there is none) and the + * address of field is shifted to the next non-comma, non-whitespace + * character. len is the length of the item excluding any beginning whitespace. + */ +AP_DECLARE(const char *) ap_size_list_item(const char **field, int *len); + +/** + * Retrieve an HTTP header field list item, as separated by a comma, + * while stripping insignificant whitespace and lowercasing anything not in + * a quoted string or comment. + * @param p The pool to allocate from + * @param field The field to retrieve + * @return The return value is a new string containing the converted list + * item (or NULL if none) and the address pointed to by field is + * shifted to the next non-comma, non-whitespace. + */ +AP_DECLARE(char *) ap_get_list_item(apr_pool_t *p, const char **field); + +/** + * Find an item in canonical form (lowercase, no extra spaces) within + * an HTTP field value list. + * @param p The pool to allocate from + * @param line The field value list to search + * @param tok The token to search for + * @return 1 if found, 0 if not found. + */ +AP_DECLARE(int) ap_find_list_item(apr_pool_t *p, const char *line, const char *tok); + +/** + * Retrieve a token, spacing over it and returning a pointer to + * the first non-white byte afterwards. Note that these tokens + * are delimited by semis and commas and can also be delimited + * by whitespace at the caller's option. + * @param p The pool to allocate from + * @param accept_line The line to retrieve the token from + * @param accept_white Is it delimited by whitespace + * @return the first non-white byte after the token + */ +AP_DECLARE(char *) ap_get_token(apr_pool_t *p, const char **accept_line, int accept_white); + +/** + * Find http tokens, see the definition of token from RFC2068 + * @param p The pool to allocate from + * @param line The line to find the token + * @param tok The token to find + * @return 1 if the token is found, 0 otherwise + */ +AP_DECLARE(int) ap_find_token(apr_pool_t *p, const char *line, const char *tok); + +/** + * find http tokens from the end of the line + * @param p The pool to allocate from + * @param line The line to find the token + * @param tok The token to find + * @return 1 if the token is found, 0 otherwise + */ +AP_DECLARE(int) ap_find_last_token(apr_pool_t *p, const char *line, const char *tok); + +/** + * Check for an Absolute URI syntax + * @param u The string to check + * @return 1 if URI, 0 otherwise + */ +AP_DECLARE(int) ap_is_url(const char *u); + +/** + * Unescape a URL + * @param url The url to unescape + * @return 0 on success, non-zero otherwise + */ +AP_DECLARE(int) ap_unescape_url(char *url); +/** + * Unescape a URL, but leaving %2f (slashes) escaped + * @param url The url to unescape + * @return 0 on success, non-zero otherwise + */ +AP_DECLARE(int) ap_unescape_url_keep2f(char *url); +/** + * Convert all double slashes to single slashes + * @param name The string to convert + */ +AP_DECLARE(void) ap_no2slash(char *name); + +/** + * Remove all ./ and xx/../ substrings from a file name. Also remove + * any leading ../ or /../ substrings. + * @param name the file name to parse + */ +AP_DECLARE(void) ap_getparents(char *name); + +/** + * Escape a path segment, as defined in RFC 1808 + * @param p The pool to allocate from + * @param s The path to convert + * @return The converted URL + */ +AP_DECLARE(char *) ap_escape_path_segment(apr_pool_t *p, const char *s); +/** + * convert an OS path to a URL in an OS dependant way. + * @param p The pool to allocate from + * @param path The path to convert + * @param partial if set, assume that the path will be appended to something + * with a '/' in it (and thus does not prefix "./") + * @return The converted URL + */ +AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial); +/** @see ap_os_escape_path */ +#define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) + +/** + * Escape an html string + * @param p The pool to allocate from + * @param s The html to escape + * @return The escaped string + */ +AP_DECLARE(char *) ap_escape_html(apr_pool_t *p, const char *s); + +/** + * Escape a string for logging + * @param p The pool to allocate from + * @param str The string to escape + * @return The escaped string + */ +AP_DECLARE(char *) ap_escape_logitem(apr_pool_t *p, const char *str); + +/** + * Escape a string for logging into the error log (without a pool) + * @param dest The buffer to write to + * @param source The string to escape + * @param buflen The buffer size for the escaped string (including \0) + * @return The len of the escaped string (always < maxlen) + */ +AP_DECLARE(apr_size_t) ap_escape_errorlog_item(char *dest, const char *source, + apr_size_t buflen); + +/** + * Construct a full hostname + * @param p The pool to allocate from + * @param hostname The hostname of the server + * @param port The port the server is running on + * @param r The current request + * @return The server's hostname + */ +AP_DECLARE(char *) ap_construct_server(apr_pool_t *p, const char *hostname, + apr_port_t port, const request_rec *r); +/** + * Escape a shell command + * @param p The pool to allocate from + * @param s The command to escape + * @return The escaped shell command + */ +AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *s); + +/** + * Count the number of directories in a path + * @param path The path to count + * @return The number of directories + */ +AP_DECLARE(int) ap_count_dirs(const char *path); + +/** + * Copy at most @a n leading directories of @a s into @a d. @a d + * should be at least as large as @a s plus 1 extra byte + * + * @param d The location to copy to + * @param s The location to copy from + * @param n The number of directories to copy + * @return value is the ever useful pointer to the trailing \0 of d + * @note on platforms with drive letters, n = 0 returns the "/" root, + * whereas n = 1 returns the "d:/" root. On all other platforms, n = 0 + * returns the empty string. */ +AP_DECLARE(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); + +/** + * Return the parent directory name (including trailing /) of the file + * @a s + * @param p The pool to allocate from + * @param s The file to get the parent of + * @return A copy of the file's parent directory + */ +AP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s); + +/** + * Given a directory and filename, create a single path from them. This + * function is smart enough to ensure that there is a sinlge '/' between the + * directory and file names + * @param a The pool to allocate from + * @param dir The directory name + * @param f The filename + * @return A copy of the full path + * @tip Never consider using this function if you are dealing with filesystem + * names that need to remain canonical, unless you are merging an apr_dir_read + * path and returned filename. Otherwise, the result is not canonical. + */ +AP_DECLARE(char *) ap_make_full_path(apr_pool_t *a, const char *dir, const char *f); + +/** + * Test if the given path has an an absolute path. + * @param p The pool to allocate from + * @param dir The directory name + * @tip The converse is not necessarily true, some OS's (Win32/OS2/Netware) have + * multiple forms of absolute paths. This only reports if the path is absolute + * in a canonical sense. + */ +AP_DECLARE(int) ap_os_is_path_absolute(apr_pool_t *p, const char *dir); + +/** + * Does the provided string contain wildcard characters? This is useful + * for determining if the string should be passed to strcmp_match or to strcmp. + * The only wildcard characters recognized are '?' and '*' + * @param str The string to check + * @return 1 if the string has wildcards, 0 otherwise + */ +AP_DECLARE(int) ap_is_matchexp(const char *str); + +/** + * Determine if a string matches a patterm containing the wildcards '?' or '*' + * @param str The string to check + * @param expected The pattern to match against + * @return 1 if the two strings match, 0 otherwise + */ +AP_DECLARE(int) ap_strcmp_match(const char *str, const char *expected); +/** + * Determine if a string matches a patterm containing the wildcards '?' or '*', + * ignoring case + * @param str The string to check + * @param expected The pattern to match against + * @return 1 if the two strings match, 0 otherwise + */ +AP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *expected); + +/** + * Find the first occurrence of the substring s2 in s1, regardless of case + * @param s1 The string to search + * @param s2 The substring to search for + * @return A pointer to the beginning of the substring + * @remark See apr_strmatch() for a faster alternative + */ +AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2); + +/** + * Return a pointer to the location inside of bigstring immediately after prefix + * @param bigstring The input string + * @param prefix The prefix to strip away + * @return A pointer relative to bigstring after prefix + */ +AP_DECLARE(const char *) ap_stripprefix(const char *bigstring, + const char *prefix); + +/** + * Decode a base64 encoded string into memory allocated from a pool + * @param p The pool to allocate from + * @param bufcoded The encoded string + * @return The decoded string + */ +AP_DECLARE(char *) ap_pbase64decode(apr_pool_t *p, const char *bufcoded); + +/** + * Encode a string into memory allocated from a pool in base 64 format + * @param p The pool to allocate from + * @param strin The plaintext string + * @return The encoded string + */ +AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string); + + +/** + * Compile a regular expression to be used later + * @param p The pool to allocate from + * @param pattern the regular expression to compile + * @param cflags The bitwise or of one or more of the following: + * @li #REG_EXTENDED - Use POSIX extended Regular Expressions + * @li #REG_ICASE - Ignore case + * @li #REG_NOSUB - Support for substring addressing of matches + * not required + * @li #REG_NEWLINE - Match-any-character operators don't match new-line + * @return The compiled regular expression + */ +AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern, + int cflags); + +/** + * Free the memory associated with a compiled regular expression + * @param p The pool the regex was allocated from + * @param reg The regular expression to free + */ +AP_DECLARE(void) ap_pregfree(apr_pool_t *p, regex_t *reg); + +/** + * Match a null-terminated string against a pre-compiled regex. + * @param preg The pre-compiled regex + * @param string The string to match + * @param nmatch Provide information regarding the location of any matches + * @param pmatch Provide information regarding the location of any matches + * @param eflags Bitwise or of any of: + * @li #REG_NOTBOL - match-beginning-of-line operator always + * fails to match + * @li #REG_NOTEOL - match-end-of-line operator always fails to match + * @return 0 for successful match, #REG_NOMATCH otherwise + */ +AP_DECLARE(int) ap_regexec(regex_t *preg, const char *string, + size_t nmatch, regmatch_t pmatch[], int eflags); + +/** + * Return the error code returned by regcomp or regexec into error messages + * @param errcode the error code returned by regexec or regcomp + * @param preg The precompiled regex + * @param errbuf A buffer to store the error in + * @param errbuf_size The size of the buffer + */ +AP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg, + char *errbuf, size_t errbuf_size); + +/** + * After performing a successful regex match, you may use this function to + * perform a series of string substitutions based on subexpressions that were + * matched during the call to ap_regexec + * @param p The pool to allocate from + * @param input An arbitrary string containing $1 through $9. These are + * replaced with the corresponding matched sub-expressions + * @param source The string that was originally matched to the regex + * @param nmatch the nmatch returned from ap_pregex + * @param pmatch the pmatch array returned from ap_pregex + */ +AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source, + size_t nmatch, regmatch_t pmatch[]); + +/** + * We want to downcase the type/subtype for comparison purposes + * but nothing else because ;parameter=foo values are case sensitive. + * @param s The content-type to convert to lowercase + */ +AP_DECLARE(void) ap_content_type_tolower(char *s); + +/** + * convert a string to all lowercase + * @param s The string to convert to lowercase + */ +AP_DECLARE(void) ap_str_tolower(char *s); + +/** + * Search a string from left to right for the first occurrence of a + * specific character + * @param str The string to search + * @param c The character to search for + * @return The index of the first occurrence of c in str + */ +AP_DECLARE(int) ap_ind(const char *str, char c); /* Sigh... */ + +/** + * Search a string from right to left for the first occurrence of a + * specific character + * @param str The string to search + * @param c The character to search for + * @return The index of the first occurrence of c in str + */ +AP_DECLARE(int) ap_rind(const char *str, char c); + +/** + * Given a string, replace any bare " with \" . + * @param p The pool to allocate memory from + * @param instring The string to search for " + * @return A copy of the string with escaped quotes + */ +AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring); + +/* Misc system hackery */ +/** + * Given the name of an object in the file system determine if it is a directory + * @param p The pool to allocate from + * @param name The name of the object to check + * @return 1 if it is a directory, 0 otherwise + */ +AP_DECLARE(int) ap_is_rdirectory(apr_pool_t *p, const char *name); + +/** + * Given the name of an object in the file system determine if it is a directory - this version is symlink aware + * @param p The pool to allocate from + * @param name The name of the object to check + * @return 1 if it is a directory, 0 otherwise + */ +AP_DECLARE(int) ap_is_directory(apr_pool_t *p, const char *name); + +#ifdef _OSD_POSIX +extern const char *os_set_account(apr_pool_t *p, const char *account); +extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process); +#endif /* _OSD_POSIX */ + +/** + * Determine the local host name for the current machine + * @param p The pool to allocate from + * @return A copy of the local host name + */ +char *ap_get_local_host(apr_pool_t *p); + +/** + * Log an assertion to the error log + * @param szExp The assertion that failed + * @param szFile The file the assertion is in + * @param nLine The line the assertion is defined on + */ +AP_DECLARE(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) + __attribute__((noreturn)); + +/** @internal */ +#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__)) + +/** + * Redefine assert() to something more useful for an Apache... + * + * Use ap_assert() if the condition should always be checked. + * Use AP_DEBUG_ASSERT() if the condition should only be checked when AP_DEBUG + * is defined. + */ + +#ifdef AP_DEBUG +#define AP_DEBUG_ASSERT(exp) ap_assert(exp) +#else +#define AP_DEBUG_ASSERT(exp) ((void)0) +#endif + +/** + * @defgroup stopsignal flags which indicate places where the sever should stop for debugging. + * @{ + * A set of flags which indicate places where the server should raise(SIGSTOP). + * This is useful for debugging, because you can then attach to that process + * with gdb and continue. This is important in cases where one_process + * debugging isn't possible. + */ +/** stop on a Detach */ +#define SIGSTOP_DETACH 1 +/** stop making a child process */ +#define SIGSTOP_MAKE_CHILD 2 +/** stop spawning a child process */ +#define SIGSTOP_SPAWN_CHILD 4 +/** stop spawning a child process with a piped log */ +#define SIGSTOP_PIPED_LOG_SPAWN 8 +/** stop spawning a CGI child process */ +#define SIGSTOP_CGI_CHILD 16 + +/** Macro to get GDB started */ +#ifdef DEBUG_SIGSTOP +extern int raise_sigstop_flags; +#define RAISE_SIGSTOP(x) do { \ + if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ + } while (0) +#else +#define RAISE_SIGSTOP(x) +#endif +/** @} */ +/** + * Get HTML describing the address and (optionally) admin of the server. + * @param prefix Text which is prepended to the return value + * @param r The request_rec + * @return HTML describing the server, allocated in @a r's pool. + */ +AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r); + +/** strtoul does not exist on sunos4. */ +#ifdef strtoul +#undef strtoul +#endif +#define strtoul strtoul_is_not_a_portable_function_use_strtol_instead + + /* The C library has functions that allow const to be silently dropped ... + these macros detect the drop in maintainer mode, but use the native + methods for normal builds + + Note that on some platforms (e.g., AIX with gcc, Solaris with gcc), string.h needs + to be included before the macros are defined or compilation will fail. + */ +#include + +AP_DECLARE(char *) ap_strchr(char *s, int c); +AP_DECLARE(const char *) ap_strchr_c(const char *s, int c); +AP_DECLARE(char *) ap_strrchr(char *s, int c); +AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c); +AP_DECLARE(char *) ap_strstr(char *s, const char *c); +AP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c); + +#ifdef AP_DEBUG + +#undef strchr +# define strchr(s, c) ap_strchr(s,c) +#undef strrchr +# define strrchr(s, c) ap_strrchr(s,c) +#undef strstr +# define strstr(s, c) ap_strstr(s,c) + +#else + +/** use this instead of strchr */ +# define ap_strchr(s, c) strchr(s, c) +/** use this instead of strchr */ +# define ap_strchr_c(s, c) strchr(s, c) +/** use this instead of strrchr */ +# define ap_strrchr(s, c) strrchr(s, c) +/** use this instead of strrchr */ +# define ap_strrchr_c(s, c) strrchr(s, c) +/** use this instead of strrstr*/ +# define ap_strstr(s, c) strstr(s, c) +/** use this instead of strrstr*/ +# define ap_strstr_c(s, c) strstr(s, c) + +#endif + +#define AP_NORESTART APR_OS_START_USEERR + 1 + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_HTTPD_H */ diff --git a/rubbos/app/apache2/include/mod_cgi.h b/rubbos/app/apache2/include/mod_cgi.h new file mode 100644 index 00000000..9a54895a --- /dev/null +++ b/rubbos/app/apache2/include/mod_cgi.h @@ -0,0 +1,62 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MOD_CGI_H +#define _MOD_CGI_H 1 + +#include "mod_include.h" + +#define AP_PROC_DETACHED 1 +#define AP_PROC_NEWADDRSPACE 2 + +typedef enum {RUN_AS_SSI, RUN_AS_CGI} prog_types; + +typedef struct { + apr_int32_t in_pipe; + apr_int32_t out_pipe; + apr_int32_t err_pipe; + int process_cgi; + apr_cmdtype_e cmd_type; + apr_int32_t detached; /* used as a bitfield for detached_ & addrspace_set, */ + /* when initializing apr_proc_attr structure */ + prog_types prog_type; + apr_bucket_brigade **bb; + include_ctx_t *ctx; + ap_filter_t *next; +} cgi_exec_info_t; + +/** + * Registerable optional function to override CGI behavior; + * Reprocess the command and arguments to execute the given CGI script. + * @param cmd Pointer to the command to execute (may be overridden) + * @param argv Pointer to the arguments to pass (may be overridden) + * @param r The current request + * @param p The pool to allocate correct cmd/argv elements within. + * @param process_cgi Set true if processing r->filename and r->args + * as a CGI invocation, otherwise false + * @param type Set to APR_SHELLCMD or APR_PROGRAM on entry, may be + * changed to invoke the program with alternate semantics. + * @param detach Should the child start in detached state? Default is no. + * @remark This callback may be registered by the os-specific module + * to correct the command and arguments for apr_proc_create invocation + * on a given os. mod_cgi will call the function if registered. + */ +APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cgi_build_command, + (const char **cmd, const char ***argv, + request_rec *r, apr_pool_t *p, + cgi_exec_info_t *e_info)); + +#endif /* _MOD_CGI_H */ diff --git a/rubbos/app/apache2/include/mod_core.h b/rubbos/app/apache2/include/mod_core.h new file mode 100644 index 00000000..093f38d1 --- /dev/null +++ b/rubbos/app/apache2/include/mod_core.h @@ -0,0 +1,80 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MOD_CORE_H +#define MOD_CORE_H + +#include "apr.h" +#include "apr_buckets.h" + +#include "httpd.h" +#include "util_filter.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package mod_core private header file + */ + +/* Handles for core filters */ +extern AP_DECLARE_DATA ap_filter_rec_t *ap_http_input_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_http_header_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_chunk_filter_handle; +extern AP_DECLARE_DATA ap_filter_rec_t *ap_byterange_filter_handle; + +/* + * These (input) filters are internal to the mod_core operation. + */ +apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, + ap_input_mode_t mode, apr_read_type_e block, + apr_off_t readbytes); + +char *ap_response_code_string(request_rec *r, int error_index); + +/** + * Send the minimal part of an HTTP response header. + * @param r The current request + * @param bb The brigade to add the header to. + * @warning Modules should be very careful about using this, and should + * the default behavior. Much of the HTTP/1.1 implementation + * correctness depends on the full headers. + * @deffunc void ap_basic_http_header(request_rec *r, apr_bucket_brigade *bb) + */ +AP_DECLARE(void) ap_basic_http_header(request_rec *r, apr_bucket_brigade *bb); + +/** + * Send an appropriate response to an http TRACE request. + * @param r The current request + * @tip returns DONE or the HTTP status error if it handles the TRACE, + * or DECLINED if the request was not for TRACE. + * request method was not TRACE. + */ +AP_DECLARE_NONSTD(int) ap_send_http_trace(request_rec *r); + +/** + * Send an appropriate response to an http OPTIONS request. + * @param r The current request + */ +AP_DECLARE(int) ap_send_http_options(request_rec *r); + +#ifdef __cplusplus +} +#endif + +#endif /* !MOD_CORE_H */ diff --git a/rubbos/app/apache2/include/mod_dav.h b/rubbos/app/apache2/include/mod_dav.h new file mode 100644 index 00000000..0fb9ac9b --- /dev/null +++ b/rubbos/app/apache2/include/mod_dav.h @@ -0,0 +1,2420 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +** DAV extension module for Apache 2.0.* +*/ + +#ifndef _MOD_DAV_H_ +#define _MOD_DAV_H_ + +#include "apr_hooks.h" +#include "apr_hash.h" +#include "apr_dbm.h" +#include "apr_tables.h" + +#include "httpd.h" +#include "util_filter.h" +#include "util_xml.h" + +#include /* for INT_MAX */ +#include /* for time_t */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#define DAV_VERSION AP_SERVER_BASEREVISION + +#define DAV_XML_HEADER "" +#define DAV_XML_CONTENT_TYPE "text/xml; charset=\"utf-8\"" + +#define DAV_READ_BLOCKSIZE 2048 /* used for reading input blocks */ + +#define DAV_RESPONSE_BODY_1 "\n\n" +#define DAV_RESPONSE_BODY_2 "\n\n

" +#define DAV_RESPONSE_BODY_3 "

\n

" +#define DAV_RESPONSE_BODY_4 "

\n" +#define DAV_RESPONSE_BODY_5 "\n" + +#define DAV_DO_COPY 0 +#define DAV_DO_MOVE 1 + + +#if 1 +#define DAV_DEBUG 1 +#define DEBUG_CR "\n" +#define DBG0(f) ap_log_error(APLOG_MARK, \ + APLOG_ERR, 0, NULL, (f)) +#define DBG1(f,a1) ap_log_error(APLOG_MARK, \ + APLOG_ERR, 0, NULL, f, a1) +#define DBG2(f,a1,a2) ap_log_error(APLOG_MARK, \ + APLOG_ERR, 0, NULL, f, a1, a2) +#define DBG3(f,a1,a2,a3) ap_log_error(APLOG_MARK, \ + APLOG_ERR, 0, NULL, f, a1, a2, a3) +#else +#undef DAV_DEBUG +#define DEBUG_CR "" +#endif + +#define DAV_INFINITY INT_MAX /* for the Depth: header */ + +/* Create a set of DAV_DECLARE(type), DAV_DECLARE_NONSTD(type) and + * DAV_DECLARE_DATA with appropriate export and import tags for the platform + */ +#if !defined(WIN32) +#define DAV_DECLARE(type) type +#define DAV_DECLARE_NONSTD(type) type +#define DAV_DECLARE_DATA +#elif defined(DAV_DECLARE_STATIC) +#define DAV_DECLARE(type) type __stdcall +#define DAV_DECLARE_NONSTD(type) type +#define DAV_DECLARE_DATA +#elif defined(DAV_DECLARE_EXPORT) +#define DAV_DECLARE(type) __declspec(dllexport) type __stdcall +#define DAV_DECLARE_NONSTD(type) __declspec(dllexport) type +#define DAV_DECLARE_DATA __declspec(dllexport) +#else +#define DAV_DECLARE(type) __declspec(dllimport) type __stdcall +#define DAV_DECLARE_NONSTD(type) __declspec(dllimport) type +#define DAV_DECLARE_DATA __declspec(dllimport) +#endif + +/* -------------------------------------------------------------------- +** +** ERROR MANAGEMENT +*/ + +/* +** dav_error structure. +** +** In most cases, mod_dav uses a pointer to a dav_error structure. If the +** pointer is NULL, then no error has occurred. +** +** In certain cases, a dav_error structure is directly used. In these cases, +** a status value of 0 means that an error has not occurred. +** +** Note: this implies that status != 0 whenever an error occurs. +** +** The desc field is optional (it may be NULL). When NULL, it typically +** implies that Apache has a proper description for the specified status. +*/ +typedef struct dav_error { + int status; /* suggested HTTP status (0 for no error) */ + int error_id; /* DAV-specific error ID */ + const char *desc; /* DAV:responsedescription and error log */ + + int save_errno; /* copy of errno causing the error */ + + const char *namespace; /* [optional] namespace of error */ + const char *tagname; /* name of error-tag */ + + struct dav_error *prev; /* previous error (in stack) */ + +} dav_error; + +/* +** Create a new error structure. save_errno will be filled with the current +** errno value. +*/ +DAV_DECLARE(dav_error*) dav_new_error(apr_pool_t *p, int status, + int error_id, const char *desc); + + +/* +** Create a new error structure with tagname and (optional) namespace; +** namespace may be NULL, which means "DAV:". save_errno will be +** filled with the current errno value. +*/ +DAV_DECLARE(dav_error*) dav_new_error_tag(apr_pool_t *p, int status, + int error_id, const char *desc, + const char *namespace, + const char *tagname); + + +/* +** Push a new error description onto the stack of errors. +** +** This function is used to provide an additional description to an existing +** error. +** +** should contain the caller's view of what the current status is, +** given the underlying error. If it doesn't have a better idea, then the +** caller should pass prev->status. +** +** can specify a new error_id since the topmost description has +** changed. +*/ +DAV_DECLARE(dav_error*) dav_push_error(apr_pool_t *p, int status, int error_id, + const char *desc, dav_error *prev); + + +/* error ID values... */ + +/* IF: header errors */ +#define DAV_ERR_IF_PARSE 100 /* general parsing error */ +#define DAV_ERR_IF_MULTIPLE_NOT 101 /* multiple "Not" found */ +#define DAV_ERR_IF_UNK_CHAR 102 /* unknown char in header */ +#define DAV_ERR_IF_ABSENT 103 /* no locktokens given */ +#define DAV_ERR_IF_TAGGED 104 /* in parsing tagged-list */ +#define DAV_ERR_IF_UNCLOSED_PAREN 105 /* in no-tagged-list */ + +/* Prop DB errors */ +#define DAV_ERR_PROP_BAD_MAJOR 200 /* major version was wrong */ +#define DAV_ERR_PROP_READONLY 201 /* prop is read-only */ +#define DAV_ERR_PROP_NO_DATABASE 202 /* writable db not avail */ +#define DAV_ERR_PROP_NOT_FOUND 203 /* prop not found */ +#define DAV_ERR_PROP_BAD_LOCKDB 204 /* could not open lockdb */ +#define DAV_ERR_PROP_OPENING 205 /* problem opening propdb */ +#define DAV_ERR_PROP_EXEC 206 /* problem exec'ing patch */ + +/* Predefined DB errors */ +/* ### any to define?? */ + +/* Predefined locking system errors */ +#define DAV_ERR_LOCK_OPENDB 400 /* could not open lockdb */ +#define DAV_ERR_LOCK_NO_DB 401 /* no database defined */ +#define DAV_ERR_LOCK_CORRUPT_DB 402 /* DB is corrupt */ +#define DAV_ERR_LOCK_UNK_STATE_TOKEN 403 /* unknown State-token */ +#define DAV_ERR_LOCK_PARSE_TOKEN 404 /* bad opaquelocktoken */ +#define DAV_ERR_LOCK_SAVE_LOCK 405 /* err saving locks */ + +/* +** Some comments on Error ID values: +** +** The numbers do not necessarily need to be unique. Uniqueness simply means +** that two errors that have not been predefined above can be distinguished +** from each other. At the moment, mod_dav does not use this distinguishing +** feature, but it could be used in the future to collapse elements +** into groups based on the error ID (and associated responsedescription). +** +** If a compute_desc is provided, then the error ID should be unique within +** the context of the compute_desc function (so the function can figure out +** what to filled into the desc). +** +** Basically, subsystems can ignore defining new error ID values if they want +** to. The subsystems *do* need to return the predefined errors when +** appropriate, so that mod_dav can figure out what to do. Subsystems can +** simply leave the error ID field unfilled (zero) if there isn't an error +** that must be placed there. +*/ + + +/* -------------------------------------------------------------------- +** +** HOOK STRUCTURES +** +** These are here for forward-declaration purposes. For more info, see +** the section title "HOOK HANDLING" for more information, plus each +** structure definition. +*/ + +/* forward-declare this structure */ +typedef struct dav_hooks_propdb dav_hooks_propdb; +typedef struct dav_hooks_locks dav_hooks_locks; +typedef struct dav_hooks_vsn dav_hooks_vsn; +typedef struct dav_hooks_repository dav_hooks_repository; +typedef struct dav_hooks_liveprop dav_hooks_liveprop; +typedef struct dav_hooks_binding dav_hooks_binding; +typedef struct dav_hooks_search dav_hooks_search; + +/* ### deprecated name */ +typedef dav_hooks_propdb dav_hooks_db; + + +/* -------------------------------------------------------------------- +** +** RESOURCE HANDLING +*/ + +/* +** Resource Types: +** The base protocol defines only file and collection resources. +** The versioning protocol defines several additional resource types +** to represent artifacts of a version control system. +** +** This enumeration identifies the type of URL used to identify the +** resource. Since the same resource may have more than one type of +** URL which can identify it, dav_resource_type cannot be used +** alone to determine the type of the resource; attributes of the +** dav_resource object must also be consulted. +*/ +typedef enum { + DAV_RESOURCE_TYPE_UNKNOWN, + + DAV_RESOURCE_TYPE_REGULAR, /* file or collection; could be + * unversioned, or version selector, + * or baseline selector */ + + DAV_RESOURCE_TYPE_VERSION, /* version or baseline URL */ + + DAV_RESOURCE_TYPE_HISTORY, /* version or baseline history URL */ + + DAV_RESOURCE_TYPE_WORKING, /* working resource URL */ + + DAV_RESOURCE_TYPE_WORKSPACE, /* workspace URL */ + + DAV_RESOURCE_TYPE_ACTIVITY, /* activity URL */ + + DAV_RESOURCE_TYPE_PRIVATE /* repository-private type */ + +} dav_resource_type; + +/* +** Opaque, repository-specific information for a resource. +*/ +typedef struct dav_resource_private dav_resource_private; + +/* +** Resource descriptor, generated by a repository provider. +** +** Note: the lock-null state is not explicitly represented here, +** since it may be expensive to compute. Use dav_get_resource_state() +** to determine whether a non-existent resource is a lock-null resource. +** +** A quick explanation of how the flags can apply to different resources: +** +** unversioned file or collection: +** type = DAV_RESOURCE_TYPE_REGULAR +** exists = ? (1 if exists) +** collection = ? (1 if collection) +** versioned = 0 +** baselined = 0 +** working = 0 +** +** version-controlled resource or configuration: +** type = DAV_RESOURCE_TYPE_REGULAR +** exists = 1 +** collection = ? (1 if collection) +** versioned = 1 +** baselined = ? (1 if configuration) +** working = ? (1 if checked out) +** +** version/baseline history: +** type = DAV_RESOURCE_TYPE_HISTORY +** exists = 1 +** collection = 0 +** versioned = 0 +** baselined = 0 +** working = 0 +** +** version/baseline: +** type = DAV_RESOURCE_TYPE_VERSION +** exists = 1 +** collection = ? (1 if collection) +** versioned = 1 +** baselined = ? (1 if baseline) +** working = 0 +** +** working resource: +** type = DAV_RESOURCE_TYPE_WORKING +** exists = 1 +** collection = ? (1 if collection) +** versioned = 1 +** baselined = 0 +** working = 1 +** +** workspace: +** type = DAV_RESOURCE_TYPE_WORKSPACE +** exists = ? (1 if exists) +** collection = 1 +** versioned = ? (1 if version-controlled) +** baselined = ? (1 if baseline-controlled) +** working = ? (1 if checked out) +** +** activity: +** type = DAV_RESOURCE_TYPE_ACTIVITY +** exists = ? (1 if exists) +** collection = 0 +** versioned = 0 +** baselined = 0 +** working = 0 +*/ +typedef struct dav_resource { + dav_resource_type type; + + int exists; /* 0 => null resource */ + + int collection; /* 0 => file; can be 1 for + * REGULAR, VERSION, and WORKING resources, + * and is always 1 for WORKSPACE */ + + int versioned; /* 0 => unversioned; can be 1 for + * REGULAR and WORKSPACE resources, + * and is always 1 for VERSION and WORKING */ + + int baselined; /* 0 => not baselined; can be 1 for + * REGULAR, VERSION, and WORKSPACE resources; + * versioned == 1 when baselined == 1 */ + + int working; /* 0 => not checked out; can be 1 for + * REGULAR and WORKSPACE resources, + * and is always 1 for WORKING */ + + const char *uri; /* the URI for this resource */ + + dav_resource_private *info; /* the provider's private info */ + + const dav_hooks_repository *hooks; /* hooks used for this resource */ + + /* When allocating items related specifically to this resource, the + following pool should be used. Its lifetime will be at least as + long as the dav_resource structure. */ + apr_pool_t *pool; + +} dav_resource; + +/* +** Lock token type. Lock providers define the details of a lock token. +** However, all providers are expected to at least be able to parse +** the "opaquelocktoken" scheme, which is represented by a uuid_t. +*/ +typedef struct dav_locktoken dav_locktoken; + + +/* -------------------------------------------------------------------- +** +** BUFFER HANDLING +** +** These buffers are used as a lightweight buffer reuse mechanism. Apache +** provides sub-pool creation and destruction to much the same effect, but +** the sub-pools are a bit more general and heavyweight than these buffers. +*/ + +/* buffer for reuse; can grow to accomodate needed size */ +typedef struct +{ + apr_size_t alloc_len; /* how much has been allocated */ + apr_size_t cur_len; /* how much is currently being used */ + char *buf; /* buffer contents */ +} dav_buffer; +#define DAV_BUFFER_MINSIZE 256 /* minimum size for buffer */ +#define DAV_BUFFER_PAD 64 /* amount of pad when growing */ + +/* set the cur_len to the given size and ensure space is available */ +DAV_DECLARE(void) dav_set_bufsize(apr_pool_t *p, dav_buffer *pbuf, + apr_size_t size); + +/* initialize a buffer and copy the specified (null-term'd) string into it */ +DAV_DECLARE(void) dav_buffer_init(apr_pool_t *p, dav_buffer *pbuf, + const char *str); + +/* check that the buffer can accomodate more bytes */ +DAV_DECLARE(void) dav_check_bufsize(apr_pool_t *p, dav_buffer *pbuf, + apr_size_t extra_needed); + +/* append a string to the end of the buffer, adjust length */ +DAV_DECLARE(void) dav_buffer_append(apr_pool_t *p, dav_buffer *pbuf, + const char *str); + +/* place a string on the end of the buffer, do NOT adjust length */ +DAV_DECLARE(void) dav_buffer_place(apr_pool_t *p, dav_buffer *pbuf, + const char *str); + +/* place some memory on the end of a buffer; do NOT adjust length */ +DAV_DECLARE(void) dav_buffer_place_mem(apr_pool_t *p, dav_buffer *pbuf, + const void *mem, apr_size_t amt, + apr_size_t pad); + + +/* -------------------------------------------------------------------- +** +** HANDY UTILITIES +*/ + +/* contains results from one of the getprop functions */ +typedef struct +{ + apr_text * propstats; /* element text */ + apr_text * xmlns; /* namespace decls for elem */ +} dav_get_props_result; + +/* holds the contents of a element */ +typedef struct dav_response +{ + const char *href; /* always */ + const char *desc; /* optional description at level */ + + /* use status if propresult.propstats is NULL. */ + dav_get_props_result propresult; + + int status; + + struct dav_response *next; +} dav_response; + +typedef struct +{ + request_rec *rnew; /* new subrequest */ + dav_error err; /* potential error response */ +} dav_lookup_result; + + +DAV_DECLARE(dav_lookup_result) dav_lookup_uri(const char *uri, request_rec *r, + int must_be_absolute); + +/* defines type of property info a provider is to return */ +typedef enum { + DAV_PROP_INSERT_NOTDEF, /* property is defined by this provider, + but nothing was inserted because the + (live) property is not defined for this + resource (it may be present as a dead + property). */ + DAV_PROP_INSERT_NOTSUPP, /* property is recognized by this provider, + but it is not supported, and cannot be + treated as a dead property */ + DAV_PROP_INSERT_NAME, /* a property name (empty elem) was + inserted into the text block */ + DAV_PROP_INSERT_VALUE, /* a property name/value pair was inserted + into the text block */ + DAV_PROP_INSERT_SUPPORTED /* a supported live property was added to + the text block as a + element */ +} dav_prop_insert; + +/* ### this stuff is private to dav/fs/repos.c; move it... */ +/* format a time string (buf must be at least DAV_TIMEBUF_SIZE chars) */ +#define DAV_STYLE_ISO8601 1 +#define DAV_STYLE_RFC822 2 +#define DAV_TIMEBUF_SIZE 30 + +DAV_DECLARE(int) dav_get_depth(request_rec *r, int def_depth); + +DAV_DECLARE(int) dav_validate_root(const apr_xml_doc *doc, + const char *tagname); +DAV_DECLARE(apr_xml_elem *) dav_find_child(const apr_xml_elem *elem, + const char *tagname); + +/* gather up all the CDATA into a single string */ +DAV_DECLARE(const char *) dav_xml_get_cdata(const apr_xml_elem *elem, apr_pool_t *pool, + int strip_white); + +/* +** XML namespace handling +** +** This structure tracks namespace declarations (xmlns:prefix="URI"). +** It maintains a one-to-many relationship of URIs-to-prefixes. In other +** words, one URI may be defined by many prefixes, but any specific +** prefix will specify only one URI. +** +** Prefixes using the "g###" pattern can be generated automatically if +** the caller does not have specific prefix requirements. +*/ +typedef struct { + apr_pool_t *pool; + apr_hash_t *uri_prefix; /* map URIs to an available prefix */ + apr_hash_t *prefix_uri; /* map all prefixes to their URIs */ + int count; /* counter for "g###" prefixes */ +} dav_xmlns_info; + +/* create an empty dav_xmlns_info structure */ +DAV_DECLARE(dav_xmlns_info *) dav_xmlns_create(apr_pool_t *pool); + +/* add a specific prefix/URI pair. the prefix/uri should have a lifetime + at least that of xmlns->pool */ +DAV_DECLARE(void) dav_xmlns_add(dav_xmlns_info *xi, + const char *prefix, const char *uri); + +/* add a URI (if not present); any prefix is acceptable and is returned. + the uri should have a lifetime at least that xmlns->pool */ +DAV_DECLARE(const char *) dav_xmlns_add_uri(dav_xmlns_info *xi, + const char *uri); + +/* return the URI for a specified prefix (or NULL if the prefix is unknown) */ +DAV_DECLARE(const char *) dav_xmlns_get_uri(dav_xmlns_info *xi, + const char *prefix); + +/* return an available prefix for a specified URI (or NULL if the URI + is unknown) */ +DAV_DECLARE(const char *) dav_xmlns_get_prefix(dav_xmlns_info *xi, + const char *uri); + +/* generate xmlns declarations (appending into the given text) */ +DAV_DECLARE(void) dav_xmlns_generate(dav_xmlns_info *xi, + apr_text_header *phdr); + +/* -------------------------------------------------------------------- +** +** DAV PLUGINS +*/ + +/* ### docco ... */ + +/* +** dav_provider +** +** This structure wraps up all of the hooks that a mod_dav provider can +** supply. The provider MUST supply and . The rest are +** optional and should contain NULL if that feature is not supplied. +** +** Note that a provider cannot pick and choose portions from various +** underlying implementations (which was theoretically possible in +** mod_dav 1.0). There are too many dependencies between a dav_resource +** (defined by ) and the other functionality. +** +** Live properties are not part of the dav_provider structure because they +** are handled through the APR_HOOK interface (to allow for multiple liveprop +** providers). The core always provides some properties, and then a given +** provider will add more properties. +** +** Some providers may need to associate a context with the dav_provider +** structure -- the ctx field is available for storing this context. Just +** leave it NULL if it isn't required. +*/ +typedef struct { + const dav_hooks_repository *repos; + const dav_hooks_propdb *propdb; + const dav_hooks_locks *locks; + const dav_hooks_vsn *vsn; + const dav_hooks_binding *binding; + const dav_hooks_search *search; + + void *ctx; +} dav_provider; + +/* +** gather_propsets: gather all live property propset-URIs +** +** The hook implementor should push one or more URIs into the specified +** array. These URIs are returned in the DAV: header to let clients know +** what sets of live properties are supported by the installation. mod_dav +** will place open/close angle brackets around each value (much like +** a Coded-URL); quotes and brackets should not be in the value. +** +** Example: http://apache.org/dav/props/ +** +** (of course, use your own domain to ensure a unique value) +*/ +APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, gather_propsets, + (apr_array_header_t *uris)) + +/* +** find_liveprop: find a live property, returning a non-zero, unique, +** opaque identifier. +** +** If the hook implementor determines the specified URI/name refers to +** one of its properties, then it should fill in HOOKS and return a +** non-zero value. The returned value is the "property ID" and will +** be passed to the various liveprop hook functions. +** +** Return 0 if the property is not defined by the hook implementor. +*/ +APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, find_liveprop, + (const dav_resource *resource, + const char *ns_uri, const char *name, + const dav_hooks_liveprop **hooks)) + +/* +** insert_all_liveprops: insert all (known) live property names/values. +** +** The hook implementor should append XML text to PHDR, containing liveprop +** names. If INSVALUE is true, then the property values should also be +** inserted into the output XML stream. +** +** The liveprop provider should insert *all* known and *defined* live +** properties on the specified resource. If a particular liveprop is +** not defined for this resource, then it should not be inserted. +*/ +APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, insert_all_liveprops, + (request_rec *r, const dav_resource *resource, + dav_prop_insert what, apr_text_header *phdr)) + +DAV_DECLARE(const dav_hooks_locks *) dav_get_lock_hooks(request_rec *r); +DAV_DECLARE(const dav_hooks_propdb *) dav_get_propdb_hooks(request_rec *r); +DAV_DECLARE(const dav_hooks_vsn *) dav_get_vsn_hooks(request_rec *r); +DAV_DECLARE(const dav_hooks_binding *) dav_get_binding_hooks(request_rec *r); +DAV_DECLARE(const dav_hooks_search *) dav_get_search_hooks(request_rec *r); + +DAV_DECLARE(void) dav_register_provider(apr_pool_t *p, const char *name, + const dav_provider *hooks); +DAV_DECLARE(const dav_provider *) dav_lookup_provider(const char *name); + + +/* ### deprecated */ +#define DAV_GET_HOOKS_PROPDB(r) dav_get_propdb_hooks(r) +#define DAV_GET_HOOKS_LOCKS(r) dav_get_lock_hooks(r) +#define DAV_GET_HOOKS_VSN(r) dav_get_vsn_hooks(r) +#define DAV_GET_HOOKS_BINDING(r) dav_get_binding_hooks(r) +#define DAV_GET_HOOKS_SEARCH(r) dav_get_search_hooks(r) + + +/* -------------------------------------------------------------------- +** +** IF HEADER PROCESSING +** +** Here is the definition of the If: header from RFC 2518, S9.4: +** +** If = "If" ":" (1*No-tag-list | 1*Tagged-list) +** No-tag-list = List +** Tagged-list = Resource 1*List +** Resource = Coded-URL +** List = "(" 1*(["Not"](State-token | "[" entity-tag "]")) ")" +** State-token = Coded-URL +** Coded-URL = "<" absoluteURI ">" ; absoluteURI from RFC 2616 +** +** List corresponds to dav_if_state_list. No-tag-list corresponds to +** dav_if_header with uri==NULL. Tagged-list corresponds to a sequence of +** dav_if_header structures with (duplicate) uri==Resource -- one +** dav_if_header per state_list. A second Tagged-list will start a new +** sequence of dav_if_header structures with the new URI. +** +** A summary of the semantics, mapped into our structures: +** - Chained dav_if_headers: OR +** - Chained dav_if_state_lists: AND +** - NULL uri matches all resources +*/ + +typedef enum +{ + dav_if_etag, + dav_if_opaquelock +} dav_if_state_type; + +typedef struct dav_if_state_list +{ + dav_if_state_type type; + + int condition; +#define DAV_IF_COND_NORMAL 0 +#define DAV_IF_COND_NOT 1 /* "Not" was applied */ + + const char *etag; + dav_locktoken *locktoken; + + struct dav_if_state_list *next; +} dav_if_state_list; + +typedef struct dav_if_header +{ + const char *uri; + apr_size_t uri_len; + struct dav_if_state_list *state; + struct dav_if_header *next; + + int dummy_header; /* used internally by the lock/etag validation */ +} dav_if_header; + +typedef struct dav_locktoken_list +{ + dav_locktoken *locktoken; + struct dav_locktoken_list *next; +} dav_locktoken_list; + +DAV_DECLARE(dav_error *) dav_get_locktoken_list(request_rec *r, + dav_locktoken_list **ltl); + + +/* -------------------------------------------------------------------- +** +** LIVE PROPERTY HANDLING +*/ + +/* opaque type for PROPPATCH rollback information */ +typedef struct dav_liveprop_rollback dav_liveprop_rollback; + +struct dav_hooks_liveprop +{ + /* + ** Insert property information into a text block. The property to + ** insert is identified by the propid value. The information to insert + ** is identified by the "what" argument, as follows: + ** DAV_PROP_INSERT_NAME + ** property name, as an empty XML element + ** DAV_PROP_INSERT_VALUE + ** property name/value, as an XML element + ** DAV_PROP_INSERT_SUPPORTED + ** if the property is defined on the resource, then + ** a DAV:supported-live-property element, as defined + ** by the DeltaV extensions to RFC2518. + ** + ** Providers should return DAV_PROP_INSERT_NOTDEF if the property is + ** known and not defined for this resource, so should be handled as a + ** dead property. If a provider recognizes, but does not support, a + ** property, and does not want it handled as a dead property, it should + ** return DAV_PROP_INSERT_NOTSUPP. + ** + ** Returns one of DAV_PROP_INSERT_* based on what happened. + ** + ** ### we may need more context... ie. the lock database + */ + dav_prop_insert (*insert_prop)(const dav_resource *resource, + int propid, dav_prop_insert what, + apr_text_header *phdr); + + /* + ** Determine whether a given property is writable. + ** + ** ### we may want a different semantic. i.e. maybe it should be + ** ### "can we write into this property?" + ** + ** Returns 1 if the live property can be written, 0 if read-only. + */ + int (*is_writable)(const dav_resource *resource, int propid); + + /* + ** This member defines the set of namespace URIs that the provider + ** uses for its properties. When insert_all is called, it will be + ** passed a list of integers that map from indices into this list + ** to namespace IDs for output generation. + ** + ** The last entry in this list should be a NULL value (sentinel). + */ + const char * const * namespace_uris; + + /* + ** ### this is not the final design. we want an open-ended way for + ** ### liveprop providers to attach *new* properties. To this end, + ** ### we'll have a "give me a list of the props you define", a way + ** ### to check for a prop's existence, a way to validate a set/remove + ** ### of a prop, and a way to execute/commit/rollback that change. + */ + + /* + ** Validate that the live property can be assigned a value, and that + ** the provided value is valid. + ** + ** elem will point to the XML element that names the property. For + ** example: + ** T + ** + ** The provider can access the cdata fields and the child elements + ** to extract the relevant pieces. + ** + ** operation is one of DAV_PROP_OP_SET or _DELETE. + ** + ** The provider may return a value in *context which will be passed + ** to each of the exec/commit/rollback functions. For example, this + ** may contain an internal value which has been processed from the + ** input element. + ** + ** The provider must set defer_to_dead to true (non-zero) or false. + ** If true, then the set/remove is deferred to the dead property + ** database. Note: it will be set to zero on entry. + */ + dav_error * (*patch_validate)(const dav_resource *resource, + const apr_xml_elem *elem, + int operation, + void **context, + int *defer_to_dead); + + /* ### doc... */ + dav_error * (*patch_exec)(const dav_resource *resource, + const apr_xml_elem *elem, + int operation, + void *context, + dav_liveprop_rollback **rollback_ctx); + + /* ### doc... */ + void (*patch_commit)(const dav_resource *resource, + int operation, + void *context, + dav_liveprop_rollback *rollback_ctx); + + /* ### doc... */ + dav_error * (*patch_rollback)(const dav_resource *resource, + int operation, + void *context, + dav_liveprop_rollback *rollback_ctx); + + /* + ** If a provider needs a context to associate with this hooks structure, + ** then this field may be used. In most cases, it will just be NULL. + */ + void *ctx; +}; + +/* +** dav_liveprop_spec: specify a live property +** +** This structure is used as a standard way to determine if a particular +** property is a live property. Its use is not part of the mandated liveprop +** interface, but can be used by liveprop providers in conjuction with the +** utility routines below. +** +** spec->name == NULL is the defined end-sentinel for a list of specs. +*/ +typedef struct { + int ns; /* provider-local namespace index */ + const char *name; /* name of the property */ + + int propid; /* provider-local property ID */ + + int is_writable; /* is the property writable? */ + +} dav_liveprop_spec; + +/* +** dav_liveprop_group: specify a group of liveprops +** +** This structure specifies a group of live properties, their namespaces, +** and how to handle them. +*/ +typedef struct { + const dav_liveprop_spec *specs; + const char * const *namespace_uris; + const dav_hooks_liveprop *hooks; + +} dav_liveprop_group; + +/* ### docco */ +DAV_DECLARE(int) dav_do_find_liveprop(const char *ns_uri, const char *name, + const dav_liveprop_group *group, + const dav_hooks_liveprop **hooks); + +/* ### docco */ +DAV_DECLARE(int) dav_get_liveprop_info(int propid, + const dav_liveprop_group *group, + const dav_liveprop_spec **info); + +/* ### docco */ +DAV_DECLARE(void) dav_register_liveprop_group(apr_pool_t *pool, + const dav_liveprop_group *group); + +/* ### docco */ +DAV_DECLARE(int) dav_get_liveprop_ns_index(const char *uri); + +/* ### docco */ +DAV_DECLARE(int) dav_get_liveprop_ns_count(void); + +/* ### docco */ +DAV_DECLARE(void) dav_add_all_liveprop_xmlns(apr_pool_t *p, + apr_text_header *phdr); + +/* +** The following three functions are part of mod_dav's internal handling +** for the core WebDAV properties. They are not part of mod_dav's API. +*/ +DAV_DECLARE_NONSTD(int) dav_core_find_liveprop( + const dav_resource *resource, + const char *ns_uri, + const char *name, + const dav_hooks_liveprop **hooks); +DAV_DECLARE_NONSTD(void) dav_core_insert_all_liveprops( + request_rec *r, + const dav_resource *resource, + dav_prop_insert what, + apr_text_header *phdr); +DAV_DECLARE_NONSTD(void) dav_core_register_uris(apr_pool_t *p); + + +/* +** Standard WebDAV Property Identifiers +** +** A live property provider does not need to use these; they are simply +** provided for convenience. +** +** Property identifiers need to be unique within a given provider, but not +** *across* providers (note: this uniqueness constraint was different in +** older versions of mod_dav). +** +** The identifiers start at 20000 to make it easier for providers to avoid +** conflicts with the standard properties. The properties are arranged +** alphabetically, and may be reordered from time to time (as properties +** are introduced). +** +** NOTE: there is no problem with reordering (e.g. binary compat) since the +** identifiers are only used within a given provider, which would pick up +** the entire set of changes upon a recompile. +*/ +enum { + DAV_PROPID_BEGIN = 20000, + + /* Standard WebDAV properties (RFC 2518) */ + DAV_PROPID_creationdate, + DAV_PROPID_displayname, + DAV_PROPID_getcontentlanguage, + DAV_PROPID_getcontentlength, + DAV_PROPID_getcontenttype, + DAV_PROPID_getetag, + DAV_PROPID_getlastmodified, + DAV_PROPID_lockdiscovery, + DAV_PROPID_resourcetype, + DAV_PROPID_source, + DAV_PROPID_supportedlock, + + /* DeltaV properties (from the I-D (#14)) */ + DAV_PROPID_activity_checkout_set, + DAV_PROPID_activity_set, + DAV_PROPID_activity_version_set, + DAV_PROPID_auto_merge_set, + DAV_PROPID_auto_version, + DAV_PROPID_baseline_collection, + DAV_PROPID_baseline_controlled_collection, + DAV_PROPID_baseline_controlled_collection_set, + DAV_PROPID_checked_in, + DAV_PROPID_checked_out, + DAV_PROPID_checkin_fork, + DAV_PROPID_checkout_fork, + DAV_PROPID_checkout_set, + DAV_PROPID_comment, + DAV_PROPID_creator_displayname, + DAV_PROPID_current_activity_set, + DAV_PROPID_current_workspace_set, + DAV_PROPID_default_variant, + DAV_PROPID_eclipsed_set, + DAV_PROPID_label_name_set, + DAV_PROPID_merge_set, + DAV_PROPID_precursor_set, + DAV_PROPID_predecessor_set, + DAV_PROPID_root_version, + DAV_PROPID_subactivity_set, + DAV_PROPID_subbaseline_set, + DAV_PROPID_successor_set, + DAV_PROPID_supported_method_set, + DAV_PROPID_supported_live_property_set, + DAV_PROPID_supported_report_set, + DAV_PROPID_unreserved, + DAV_PROPID_variant_set, + DAV_PROPID_version_controlled_binding_set, + DAV_PROPID_version_controlled_configuration, + DAV_PROPID_version_history, + DAV_PROPID_version_name, + DAV_PROPID_workspace, + DAV_PROPID_workspace_checkout_set, + + DAV_PROPID_END +}; + +/* +** Property Identifier Registration +** +** At the moment, mod_dav requires live property providers to ensure that +** each property returned has a unique value. For now, this is done through +** central registration (there are no known providers other than the default, +** so this remains manageable). +** +** WARNING: the TEST ranges should never be "shipped". +*/ +#define DAV_PROPID_CORE 10000 /* ..10099. defined by mod_dav */ +#define DAV_PROPID_FS 10100 /* ..10299. + mod_dav filesystem provider. */ +#define DAV_PROPID_TEST1 10300 /* ..10399 */ +#define DAV_PROPID_TEST2 10400 /* ..10499 */ +#define DAV_PROPID_TEST3 10500 /* ..10599 */ +/* Next: 10600 */ + + +/* -------------------------------------------------------------------- +** +** DATABASE FUNCTIONS +*/ + +typedef struct dav_db dav_db; +typedef struct dav_namespace_map dav_namespace_map; +typedef struct dav_deadprop_rollback dav_deadprop_rollback; + +typedef struct { + const char *ns; /* "" signals "no namespace" */ + const char *name; +} dav_prop_name; + +/* hook functions to enable pluggable databases */ +struct dav_hooks_propdb +{ + dav_error * (*open)(apr_pool_t *p, const dav_resource *resource, int ro, + dav_db **pdb); + void (*close)(dav_db *db); + + /* + ** In bulk, define any namespaces that the values and their name + ** elements may need. + ** + ** Note: sometimes mod_dav will defer calling this until output_value + ** returns found==1. If the output process needs the dav_xmlns_info + ** filled for its work, then it will need to fill it on demand rather + ** than depending upon this hook to fill in the structure. + ** + ** Note: this will *always* be called during an output sequence. Thus, + ** the provider may rely solely on using this to fill the xmlns info. + */ + dav_error * (*define_namespaces)(dav_db *db, dav_xmlns_info *xi); + + /* + ** Output the value from the database (i.e. add an element name and + ** the value into *phdr). Set *found based on whether the name/value + ** was found in the propdb. + ** + ** Note: it is NOT an error for the key/value pair to not exist. + ** + ** The dav_xmlns_info passed to define_namespaces() is also passed to + ** each output_value() call so that namespaces can be added on-demand. + ** It can also be used to look up prefixes or URIs during the output + ** process. + */ + dav_error * (*output_value)(dav_db *db, const dav_prop_name *name, + dav_xmlns_info *xi, + apr_text_header *phdr, int *found); + + /* + ** Build a mapping from "global" namespaces (stored in apr_xml_*) + ** into provider-local namespace identifiers. + ** + ** This mapping should be done once per set of namespaces, and the + ** resulting mapping should be passed into the store() hook function. + ** + ** Note: usually, there is just a single document/namespaces for all + ** elements passed. However, the generality of creating multiple + ** mappings and passing them to store() is provided here. + ** + ** Note: this is only in preparation for a series of store() calls. + ** As a result, the propdb must be open for read/write access when + ** this function is called. + */ + dav_error * (*map_namespaces)(dav_db *db, + const apr_array_header_t *namespaces, + dav_namespace_map **mapping); + + /* + ** Store a property value for a given name. The value->combined field + ** MUST be set for this call. + ** + ** ### WARNING: current providers will quote the text within ELEM. + ** ### this implies you can call this function only once with a given + ** ### element structure (a second time will quote it again). + */ + dav_error * (*store)(dav_db *db, const dav_prop_name *name, + const apr_xml_elem *elem, + dav_namespace_map *mapping); + + /* remove a given property */ + dav_error * (*remove)(dav_db *db, const dav_prop_name *name); + + /* returns 1 if the record specified by "key" exists; 0 otherwise */ + int (*exists)(dav_db *db, const dav_prop_name *name); + + /* + ** Iterate over the property names in the database. + ** + ** iter->name.ns == iter->name.name == NULL when there are no more names. + ** + ** Note: only one iteration may occur over the propdb at a time. + */ + dav_error * (*first_name)(dav_db *db, dav_prop_name *pname); + dav_error * (*next_name)(dav_db *db, dav_prop_name *pname); + + /* + ** Rollback support: get rollback context, and apply it. + ** + ** struct dav_deadprop_rollback is a provider-private structure; it + ** should remember the name, and the name's old value (or the fact that + ** the value was not present, and should be deleted if a rollback occurs). + */ + dav_error * (*get_rollback)(dav_db *db, const dav_prop_name *name, + dav_deadprop_rollback **prollback); + dav_error * (*apply_rollback)(dav_db *db, + dav_deadprop_rollback *rollback); + + /* + ** If a provider needs a context to associate with this hooks structure, + ** then this field may be used. In most cases, it will just be NULL. + */ + void *ctx; +}; + + +/* -------------------------------------------------------------------- +** +** LOCK FUNCTIONS +*/ + +/* Used to represent a Timeout header of "Infinity" */ +#define DAV_TIMEOUT_INFINITE 0 + +DAV_DECLARE(time_t) dav_get_timeout(request_rec *r); + +/* +** Opaque, provider-specific information for a lock database. +*/ +typedef struct dav_lockdb_private dav_lockdb_private; + +/* +** Opaque, provider-specific information for a lock record. +*/ +typedef struct dav_lock_private dav_lock_private; + +/* +** Lock database type. Lock providers are urged to implement a "lazy" open, so +** doing an "open" is cheap until something is actually needed from the DB. +*/ +typedef struct +{ + const dav_hooks_locks *hooks; /* the hooks used for this lockdb */ + int ro; /* was it opened readonly? */ + + dav_lockdb_private *info; + +} dav_lockdb; + +typedef enum { + DAV_LOCKSCOPE_UNKNOWN, + DAV_LOCKSCOPE_EXCLUSIVE, + DAV_LOCKSCOPE_SHARED +} dav_lock_scope; + +typedef enum { + DAV_LOCKTYPE_UNKNOWN, + DAV_LOCKTYPE_WRITE +} dav_lock_type; + +typedef enum { + DAV_LOCKREC_DIRECT, /* lock asserted on this resource */ + DAV_LOCKREC_INDIRECT, /* lock inherited from a parent */ + DAV_LOCKREC_INDIRECT_PARTIAL /* most info is not filled in */ +} dav_lock_rectype; + +/* +** dav_lock: hold information about a lock on a resource. +** +** This structure is used for both direct and indirect locks. A direct lock +** is a lock applied to a specific resource by the client. An indirect lock +** is one that is inherited from a parent resource by virtue of a non-zero +** Depth: header when the lock was applied. +** +** mod_dav records both types of locks in the lock database, managing their +** addition/removal as resources are moved about the namespace. +** +** Note that the lockdb is free to marshal this structure in any form that +** it likes. +** +** For a "partial" lock, the and fields must be filled +** in. All other (user) fields should be zeroed. The lock provider will +** usually fill in the field, and the field may be used to +** construct a list of partial locks. +** +** The lock provider MUST use the info field to store a value such that a +** dav_lock structure can locate itself in the underlying lock database. +** This requirement is needed for refreshing: when an indirect dav_lock is +** refreshed, its reference to the direct lock does not specify the direct's +** resource, so the only way to locate the (refreshed, direct) lock in the +** database is to use the info field. +** +** Note that only refers to the resource where this lock was +** found. +** ### hrm. that says the abstraction is wrong. is_locknull may disappear. +*/ +typedef struct dav_lock +{ + dav_lock_rectype rectype; /* type of lock record */ + int is_locknull; /* lock establishes a locknull resource */ + + /* ### put the resource in here? */ + + dav_lock_scope scope; /* scope of the lock */ + dav_lock_type type; /* type of lock */ + int depth; /* depth of the lock */ + time_t timeout; /* when the lock will timeout */ + + const dav_locktoken *locktoken; /* the token that was issued */ + + const char *owner; /* (XML) owner of the lock */ + const char *auth_user; /* auth'd username owning lock */ + + dav_lock_private *info; /* private to the lockdb */ + + struct dav_lock *next; /* for managing a list of locks */ +} dav_lock; + +/* Property-related public lock functions */ +DAV_DECLARE(const char *)dav_lock_get_activelock(request_rec *r, + dav_lock *locks, + dav_buffer *pbuf); + +/* LockDB-related public lock functions */ +DAV_DECLARE(dav_error *) dav_lock_parse_lockinfo(request_rec *r, + const dav_resource *resrouce, + dav_lockdb *lockdb, + const apr_xml_doc *doc, + dav_lock **lock_request); +DAV_DECLARE(int) dav_unlock(request_rec *r, + const dav_resource *resource, + const dav_locktoken *locktoken); +DAV_DECLARE(dav_error *) dav_add_lock(request_rec *r, + const dav_resource *resource, + dav_lockdb *lockdb, dav_lock *request, + dav_response **response); +DAV_DECLARE(dav_error *) dav_notify_created(request_rec *r, + dav_lockdb *lockdb, + const dav_resource *resource, + int resource_state, + int depth); + +DAV_DECLARE(dav_error*) dav_lock_query(dav_lockdb *lockdb, + const dav_resource *resource, + dav_lock **locks); + +DAV_DECLARE(dav_error *) dav_validate_request(request_rec *r, + dav_resource *resource, + int depth, + dav_locktoken *locktoken, + dav_response **response, + int flags, + dav_lockdb *lockdb); +/* +** flags: +** 0x0F -- reserved for values +** +** other flags, detailed below +*/ +#define DAV_VALIDATE_RESOURCE 0x0010 /* validate just the resource */ +#define DAV_VALIDATE_PARENT 0x0020 /* validate resource AND its parent */ +#define DAV_VALIDATE_ADD_LD 0x0040 /* add DAV:lockdiscovery into + the 424 DAV:response */ +#define DAV_VALIDATE_USE_424 0x0080 /* return 424 status, not 207 */ +#define DAV_VALIDATE_IS_PARENT 0x0100 /* for internal use */ + +/* Lock-null related public lock functions */ +DAV_DECLARE(int) dav_get_resource_state(request_rec *r, + const dav_resource *resource); + +/* Lock provider hooks. Locking is optional, so there may be no + * lock provider for a given repository. + */ +struct dav_hooks_locks +{ + /* Return the supportedlock property for a resource */ + const char * (*get_supportedlock)( + const dav_resource *resource + ); + + /* Parse a lock token URI, returning a lock token object allocated + * in the given pool. + */ + dav_error * (*parse_locktoken)( + apr_pool_t *p, + const char *char_token, + dav_locktoken **locktoken_p + ); + + /* Format a lock token object into a URI string, allocated in + * the given pool. + * + * Always returns non-NULL. + */ + const char * (*format_locktoken)( + apr_pool_t *p, + const dav_locktoken *locktoken + ); + + /* Compare two lock tokens. + * + * Result < 0 => lt1 < lt2 + * Result == 0 => lt1 == lt2 + * Result > 0 => lt1 > lt2 + */ + int (*compare_locktoken)( + const dav_locktoken *lt1, + const dav_locktoken *lt2 + ); + + /* Open the provider's lock database. + * + * The provider may or may not use a "real" database for locks + * (a lock could be an attribute on a resource, for example). + * + * The provider may choose to use the value of the DAVLockDB directive + * (as returned by dav_get_lockdb_path()) to decide where to place + * any storage it may need. + * + * The request storage pool should be associated with the lockdb, + * so it can be used in subsequent operations. + * + * If ro != 0, only readonly operations will be performed. + * If force == 0, the open can be "lazy"; no subsequent locking operations + * may occur. + * If force != 0, locking operations will definitely occur. + */ + dav_error * (*open_lockdb)( + request_rec *r, + int ro, + int force, + dav_lockdb **lockdb + ); + + /* Indicates completion of locking operations */ + void (*close_lockdb)( + dav_lockdb *lockdb + ); + + /* Take a resource out of the lock-null state. */ + dav_error * (*remove_locknull_state)( + dav_lockdb *lockdb, + const dav_resource *resource + ); + + /* + ** Create a (direct) lock structure for the given resource. A locktoken + ** will be created. + ** + ** The lock provider may store private information into lock->info. + */ + dav_error * (*create_lock)(dav_lockdb *lockdb, + const dav_resource *resource, + dav_lock **lock); + + /* + ** Get the locks associated with the specified resource. + ** + ** If resolve_locks is true (non-zero), then any indirect locks are + ** resolved to their actual, direct lock (i.e. the reference to followed + ** to the original lock). + ** + ** The locks, if any, are returned as a linked list in no particular + ** order. If no locks are present, then *locks will be NULL. + */ + dav_error * (*get_locks)(dav_lockdb *lockdb, + const dav_resource *resource, + int calltype, + dav_lock **locks); + +#define DAV_GETLOCKS_RESOLVED 0 /* resolve indirects to directs */ +#define DAV_GETLOCKS_PARTIAL 1 /* leave indirects partially filled */ +#define DAV_GETLOCKS_COMPLETE 2 /* fill out indirect locks */ + + /* + ** Find a particular lock on a resource (specified by its locktoken). + ** + ** *lock will be set to NULL if the lock is not found. + ** + ** Note that the provider can optimize the unmarshalling -- only one + ** lock (or none) must be constructed and returned. + ** + ** If partial_ok is true (non-zero), then an indirect lock can be + ** partially filled in. Otherwise, another lookup is done and the + ** lock structure will be filled out as a DAV_LOCKREC_INDIRECT. + */ + dav_error * (*find_lock)(dav_lockdb *lockdb, + const dav_resource *resource, + const dav_locktoken *locktoken, + int partial_ok, + dav_lock **lock); + + /* + ** Quick test to see if the resource has *any* locks on it. + ** + ** This is typically used to determine if a non-existent resource + ** has a lock and is (therefore) a locknull resource. + ** + ** WARNING: this function may return TRUE even when timed-out locks + ** exist (i.e. it may not perform timeout checks). + */ + dav_error * (*has_locks)(dav_lockdb *lockdb, + const dav_resource *resource, + int *locks_present); + + /* + ** Append the specified lock(s) to the set of locks on this resource. + ** + ** If "make_indirect" is true (non-zero), then the specified lock(s) + ** should be converted to an indirect lock (if it is a direct lock) + ** before appending. Note that the conversion to an indirect lock does + ** not alter the passed-in lock -- the change is internal the + ** append_locks function. + ** + ** Multiple locks are specified using the lock->next links. + */ + dav_error * (*append_locks)(dav_lockdb *lockdb, + const dav_resource *resource, + int make_indirect, + const dav_lock *lock); + + /* + ** Remove any lock that has the specified locktoken. + ** + ** If locktoken == NULL, then ALL locks are removed. + */ + dav_error * (*remove_lock)(dav_lockdb *lockdb, + const dav_resource *resource, + const dav_locktoken *locktoken); + + /* + ** Refresh all locks, found on the specified resource, which has a + ** locktoken in the provided list. + ** + ** If the lock is indirect, then the direct lock is referenced and + ** refreshed. + ** + ** Each lock that is updated is returned in the argument. + ** Note that the locks will be fully resolved. + */ + dav_error * (*refresh_locks)(dav_lockdb *lockdb, + const dav_resource *resource, + const dav_locktoken_list *ltl, + time_t new_time, + dav_lock **locks); + + /* + ** Look up the resource associated with a particular locktoken. + ** + ** The search begins at the specified and the lock + ** specified by . + ** + ** If the resource/token specifies an indirect lock, then the direct + ** lock will be looked up, and THAT resource will be returned. In other + ** words, this function always returns the resource where a particular + ** lock (token) was asserted. + ** + ** NOTE: this function pointer is allowed to be NULL, indicating that + ** the provider does not support this type of functionality. The + ** caller should then traverse up the repository hierarchy looking + ** for the resource defining a lock with this locktoken. + */ + dav_error * (*lookup_resource)(dav_lockdb *lockdb, + const dav_locktoken *locktoken, + const dav_resource *start_resource, + const dav_resource **resource); + + /* + ** If a provider needs a context to associate with this hooks structure, + ** then this field may be used. In most cases, it will just be NULL. + */ + void *ctx; +}; + +/* what types of resources can be discovered by dav_get_resource_state() */ +#define DAV_RESOURCE_LOCK_NULL 10 /* resource lock-null */ +#define DAV_RESOURCE_NULL 11 /* resource null */ +#define DAV_RESOURCE_EXISTS 12 /* resource exists */ +#define DAV_RESOURCE_ERROR 13 /* an error occurred */ + + +/* -------------------------------------------------------------------- +** +** PROPERTY HANDLING +*/ + +typedef struct dav_propdb dav_propdb; + + +DAV_DECLARE(dav_error *) dav_open_propdb( + request_rec *r, + dav_lockdb *lockdb, + const dav_resource *resource, + int ro, + apr_array_header_t *ns_xlate, + dav_propdb **propdb); + +DAV_DECLARE(void) dav_close_propdb(dav_propdb *db); + +DAV_DECLARE(dav_get_props_result) dav_get_props( + dav_propdb *db, + apr_xml_doc *doc); + +DAV_DECLARE(dav_get_props_result) dav_get_allprops( + dav_propdb *db, + dav_prop_insert what); + +DAV_DECLARE(void) dav_get_liveprop_supported( + dav_propdb *propdb, + const char *ns_uri, + const char *propname, + apr_text_header *body); + +/* +** 3-phase property modification. +** +** 1) validate props. readable? unlocked? ACLs allow access? +** 2) execute operation (set/delete) +** 3) commit or rollback +** +** ### eventually, auth must be available. a ref to the request_rec (which +** ### contains the auth info) should be in the shared context struct. +** +** Each function may alter the error values and information contained within +** the context record. This should be done as an "increasing" level of +** error, rather than overwriting any previous error. +** +** Note that commit() cannot generate errors. It should simply free the +** rollback information. +** +** rollback() may generate additional errors because the rollback operation +** can sometimes fail(!). +** +** The caller should allocate an array of these, one per operation. It should +** be zero-initialized, then the db, operation, and prop fields should be +** filled in before calling dav_prop_validate. Note that the set/delete +** operations are order-dependent. For a given (logical) context, the same +** pointer must be passed to each phase. +** +** error_type is an internal value, but will have the same numeric value +** for each possible "desc" value. This allows the caller to group the +** descriptions via the error_type variable, rather than through string +** comparisons. Note that "status" does not provide enough granularity to +** differentiate/group the "desc" values. +** +** Note that the propdb will maintain some (global) context across all +** of the property change contexts. This implies that you can have only +** one open transaction per propdb. +*/ +typedef struct dav_prop_ctx +{ + dav_propdb *propdb; + + int operation; +#define DAV_PROP_OP_SET 1 /* set a property value */ +#define DAV_PROP_OP_DELETE 2 /* delete a prop value */ +/* ### add a GET? */ + + apr_xml_elem *prop; /* property to affect */ + + dav_error *err; /* error (if any) */ + + /* private items to the propdb */ + int is_liveprop; + void *liveprop_ctx; + struct dav_rollback_item *rollback; /* optional rollback info */ + + /* private to mod_dav.c */ + request_rec *r; + +} dav_prop_ctx; + +DAV_DECLARE_NONSTD(void) dav_prop_validate(dav_prop_ctx *ctx); +DAV_DECLARE_NONSTD(void) dav_prop_exec(dav_prop_ctx *ctx); +DAV_DECLARE_NONSTD(void) dav_prop_commit(dav_prop_ctx *ctx); +DAV_DECLARE_NONSTD(void) dav_prop_rollback(dav_prop_ctx *ctx); + +#define DAV_PROP_CTX_HAS_ERR(dpc) ((dpc).err && (dpc).err->status >= 300) + + +/* -------------------------------------------------------------------- +** +** WALKER STRUCTURE +*/ + +enum { + DAV_CALLTYPE_MEMBER = 1, /* called for a member resource */ + DAV_CALLTYPE_COLLECTION, /* called for a collection */ + DAV_CALLTYPE_LOCKNULL /* called for a locknull resource */ +}; + +typedef struct +{ + /* the client-provided context */ + void *walk_ctx; + + /* pool to use for allocations in the callback */ + apr_pool_t *pool; + + /* the current resource */ + const dav_resource *resource; + + /* OUTPUT: add responses to this */ + dav_response *response; + +} dav_walk_resource; + +typedef struct +{ + int walk_type; +#define DAV_WALKTYPE_AUTH 0x0001 /* limit to authorized files */ +#define DAV_WALKTYPE_NORMAL 0x0002 /* walk normal files */ +#define DAV_WALKTYPE_LOCKNULL 0x0004 /* walk locknull resources */ + + /* callback function and a client context for the walk */ + dav_error * (*func)(dav_walk_resource *wres, int calltype); + void *walk_ctx; + + /* what pool to use for allocations needed by walk logic */ + apr_pool_t *pool; + + /* beginning root of the walk */ + const dav_resource *root; + + /* lock database to enable walking LOCKNULL resources */ + dav_lockdb *lockdb; + +} dav_walk_params; + +/* directory tree walking context */ +typedef struct dav_walker_ctx +{ + /* input: */ + dav_walk_params w; + + + /* ### client data... phasing out this big glom */ + + /* this brigade buffers data being sent to r->output_filters */ + apr_bucket_brigade *bb; + + /* a scratch pool, used to stream responses and iteratively cleared. */ + apr_pool_t *scratchpool; + + request_rec *r; /* original request */ + + /* for PROPFIND operations */ + apr_xml_doc *doc; + int propfind_type; +#define DAV_PROPFIND_IS_ALLPROP 1 +#define DAV_PROPFIND_IS_PROPNAME 2 +#define DAV_PROPFIND_IS_PROP 3 + + apr_text *propstat_404; /* (cached) propstat giving a 404 error */ + + const dav_if_header *if_header; /* for validation */ + const dav_locktoken *locktoken; /* for UNLOCK */ + const dav_lock *lock; /* for LOCK */ + int skip_root; /* for dav_inherit_locks() */ + + int flags; + + dav_buffer work_buf; /* for dav_validate_request() */ + +} dav_walker_ctx; + +DAV_DECLARE(void) dav_add_response(dav_walk_resource *wres, + int status, + dav_get_props_result *propstats); + + +/* -------------------------------------------------------------------- +** +** "STREAM" STRUCTURE +** +** mod_dav uses this abstraction for interacting with the repository +** while fetching/storing resources. mod_dav views resources as a stream +** of bytes. +** +** Note that the structure is opaque -- it is private to the repository +** that created the stream in the repository's "open" function. +** +** ### THIS STUFF IS GOING AWAY ... GET/read requests are handled by +** ### having the provider jam stuff straight into the filter stack. +** ### this is only left for handling PUT/write requests. +*/ + +typedef struct dav_stream dav_stream; + +typedef enum { + DAV_MODE_WRITE_TRUNC, /* truncate and open for writing */ + DAV_MODE_WRITE_SEEKABLE /* open for writing; random access */ +} dav_stream_mode; + + +/* -------------------------------------------------------------------- +** +** REPOSITORY FUNCTIONS +*/ + +/* Repository provider hooks */ +struct dav_hooks_repository +{ + /* Flag for whether repository requires special GET handling. + * If resources in the repository are not visible in the + * filesystem location which URLs map to, then special handling + * is required to first fetch a resource from the repository, + * respond to the GET request, then free the resource copy. + */ + int handle_get; + + /* Get a resource descriptor for the URI in a request. A descriptor + * should always be returned even if the resource does not exist. This + * repository has been identified as handling the resource given by + * the URI, so an answer must be given. If there is a problem with the + * URI or accessing the resource or whatever, then an error should be + * returned. + * + * root_dir: + * the root of the directory for which this repository is configured. + * + * label: + * if a Label: header is present (and allowed), this is the label + * to use to identify a version resource from the resource's + * corresponding version history. Otherwise, it will be NULL. + * + * use_checked_in: + * use the DAV:checked-in property of the resource identified by the + * Request-URI to identify and return a version resource + * + * The provider may associate the request storage pool with the resource + * (in the resource->pool field), to use in other operations on that + * resource. + */ + dav_error * (*get_resource)( + request_rec *r, + const char *root_dir, + const char *label, + int use_checked_in, + dav_resource **resource + ); + + /* Get a resource descriptor for the parent of the given resource. + * The resources need not exist. NULL is returned if the resource + * is the root collection. + * + * An error should be returned only if there is a fatal error in + * fetching information about the parent resource. + */ + dav_error * (*get_parent_resource)( + const dav_resource *resource, + dav_resource **parent_resource + ); + + /* Determine whether two resource descriptors refer to the same resource. + * + * Result != 0 => the resources are the same. + */ + int (*is_same_resource)( + const dav_resource *res1, + const dav_resource *res2 + ); + + /* Determine whether one resource is a parent (immediate or otherwise) + * of another. + * + * Result != 0 => res1 is a parent of res2. + */ + int (*is_parent_resource)( + const dav_resource *res1, + const dav_resource *res2 + ); + + /* + ** Open a stream for this resource, using the specified mode. The + ** stream will be returned in *stream. + */ + dav_error * (*open_stream)(const dav_resource *resource, + dav_stream_mode mode, + dav_stream **stream); + + /* + ** Close the specified stream. + ** + ** mod_dav will (ideally) make sure to call this. For safety purposes, + ** a provider should (ideally) register a cleanup function with the + ** request pool to get this closed and cleaned up. + ** + ** Note the possibility of an error from the close -- it is entirely + ** feasible that the close does a "commit" of some kind, which can + ** produce an error. + ** + ** commit should be TRUE (non-zero) or FALSE (0) if the stream was + ** opened for writing. This flag states whether to retain the file + ** or not. + ** Note: the commit flag is ignored for streams opened for reading. + */ + dav_error * (*close_stream)(dav_stream *stream, int commit); + + /* + ** Write data to the stream. + ** + ** All of the bytes must be written, or an error should be returned. + */ + dav_error * (*write_stream)(dav_stream *stream, + const void *buf, apr_size_t bufsize); + + /* + ** Seek to an absolute position in the stream. This is used to support + ** Content-Range in a GET/PUT. + ** + ** NOTE: if this function is NULL (which is allowed), then any + ** operations using Content-Range will be refused. + */ + dav_error * (*seek_stream)(dav_stream *stream, apr_off_t abs_position); + + /* + ** If a GET is processed using a stream (open_stream, read_stream) + ** rather than via a sub-request (on get_pathname), then this function + ** is used to provide the repository with a way to set the headers + ** in the response. + ** + ** This function may be called without a following deliver(), to + ** handle a HEAD request. + ** + ** This may be NULL if handle_get is FALSE. + */ + dav_error * (*set_headers)(request_rec *r, + const dav_resource *resource); + + /* + ** The provider should deliver the resource into the specified filter. + ** Basically, this is the response to the GET method. + ** + ** Note that this is called for all resources, including collections. + ** The provider should determine what has content to deliver or not. + ** + ** set_headers will be called prior to this function, allowing the + ** provider to set the appropriate response headers. + ** + ** This may be NULL if handle_get is FALSE. + ** ### maybe toss handle_get and just use this function as the marker + */ + dav_error * (*deliver)(const dav_resource *resource, + ap_filter_t *output); + + /* Create a collection resource. The resource must not already exist. + * + * Result == NULL if the collection was created successfully. Also, the + * resource object is updated to reflect that the resource exists, and + * is a collection. + */ + dav_error * (*create_collection)( + dav_resource *resource + ); + + /* Copy one resource to another. The destination may exist, if it is + * versioned. + * Handles both files and collections. Properties are copied as well. + * If the destination exists and is versioned, the provider must update + * the destination to have identical content to the source, + * recursively for collections. + * The depth argument is ignored for a file, and can be either 0 or + * DAV_INFINITY for a collection. + * If an error occurs in a child resource, then the return value is + * non-NULL, and *response is set to a multistatus response. + * If the copy is successful, the dst resource object is + * updated to reflect that the resource exists. + */ + dav_error * (*copy_resource)( + const dav_resource *src, + dav_resource *dst, + int depth, + dav_response **response + ); + + /* Move one resource to another. The destination must not exist. + * Handles both files and collections. Properties are moved as well. + * If an error occurs in a child resource, then the return value is + * non-NULL, and *response is set to a multistatus response. + * If the move is successful, the src and dst resource objects are + * updated to reflect that the source no longer exists, and the + * destination does. + */ + dav_error * (*move_resource)( + dav_resource *src, + dav_resource *dst, + dav_response **response + ); + + /* Remove a resource. Handles both files and collections. + * Removes any associated properties as well. + * If an error occurs in a child resource, then the return value is + * non-NULL, and *response is set to a multistatus response. + * If the delete is successful, the resource object is updated to + * reflect that the resource no longer exists. + */ + dav_error * (*remove_resource)( + dav_resource *resource, + dav_response **response + ); + + /* Walk a resource hierarchy. + * + * Iterates over the resource hierarchy specified by params->root. + * Control of the walk and the callback are specified by 'params'. + * + * An error may be returned. *response will contain multistatus + * responses (if any) suitable for the body of the error. It is also + * possible to return NULL, yet still have multistatus responses. + * In this case, typically the caller should return a 207 (Multistatus) + * and the responses (in the body) as the HTTP response. + */ + dav_error * (*walk)(const dav_walk_params *params, int depth, + dav_response **response); + + /* Get the entity tag for a resource */ + const char * (*getetag)(const dav_resource *resource); + + /* + ** If a provider needs a context to associate with this hooks structure, + ** then this field may be used. In most cases, it will just be NULL. + */ + void *ctx; +}; + + +/* -------------------------------------------------------------------- +** +** VERSIONING FUNCTIONS +*/ + + +/* dav_add_vary_header + * + * If there were any headers in the request which require a Vary header + * in the response, add it. + */ +DAV_DECLARE(void) dav_add_vary_header(request_rec *in_req, + request_rec *out_req, + const dav_resource *resource); + +/* +** Flags specifying auto-versioning behavior, returned by +** the auto_versionable hook. The value returned depends +** on both the state of the resource and the value of the +** DAV:auto-versioning property for the resource. +** +** If the resource does not exist (null or lock-null), +** DAV_AUTO_VERSION_ALWAYS causes creation of a new version-controlled resource +** +** If the resource is checked in, +** DAV_AUTO_VERSION_ALWAYS causes it to be checked out always, +** DAV_AUTO_VERSION_LOCKED causes it to be checked out only when locked +** +** If the resource is checked out, +** DAV_AUTO_VERSION_ALWAYS causes it to be checked in always, +** DAV_AUTO_VERSION_LOCKED causes it to be checked in when unlocked +** (note: a provider should allow auto-checkin only for resources which +** were automatically checked out) +** +** In all cases, DAV_AUTO_VERSION_NEVER results in no auto-versioning behavior. +*/ +typedef enum { + DAV_AUTO_VERSION_NEVER, + DAV_AUTO_VERSION_ALWAYS, + DAV_AUTO_VERSION_LOCKED +} dav_auto_version; + +/* +** This structure is used to record what auto-versioning operations +** were done to make a resource writable, so that they can be undone +** at the end of a request. +*/ +typedef struct { + int resource_versioned; /* 1 => resource was auto-version-controlled */ + int resource_checkedout; /* 1 => resource was auto-checked-out */ + int parent_checkedout; /* 1 => parent was auto-checked-out */ + dav_resource *parent_resource; /* parent resource, if it was needed */ +} dav_auto_version_info; + +/* Ensure that a resource is writable. If there is no versioning + * provider, then this is essentially a no-op. Versioning repositories + * require explicit resource creation and checkout before they can + * be written to. If a new resource is to be created, or an existing + * resource deleted, the parent collection must be checked out as well. + * + * Set the parent_only flag to only make the parent collection writable. + * Otherwise, both parent and child are made writable as needed. If the + * child does not exist, then a new versioned resource is created and + * checked out. + * + * If auto-versioning is not enabled for a versioned resource, then an error is + * returned, since the resource cannot be modified. + * + * The dav_auto_version_info structure is filled in with enough information + * to restore both parent and child resources to the state they were in + * before the auto-versioning operations occurred. + */ +DAV_DECLARE(dav_error *) dav_auto_checkout( + request_rec *r, + dav_resource *resource, + int parent_only, + dav_auto_version_info *av_info); + +/* Revert the writability of resources back to what they were + * before they were modified. If undo == 0, then the resource + * modifications are maintained (i.e. they are checked in). + * If undo != 0, then resource modifications are discarded + * (i.e. they are unchecked out). + * + * Set the unlock flag to indicate that the resource is about + * to be unlocked; it will be checked in if the resource + * auto-versioning property indicates it should be. In this case, + * av_info is ignored, so it can be NULL. + * + * The resource argument may be NULL if only the parent resource + * was checked out (i.e. the parent_only was != 0 in the + * dav_auto_checkout call). + */ +DAV_DECLARE(dav_error *) dav_auto_checkin( + request_rec *r, + dav_resource *resource, + int undo, + int unlock, + dav_auto_version_info *av_info); + +/* +** This structure is used to describe available reports +** +** "nmspace" should be valid XML and URL-quoted. mod_dav will place +** double-quotes around it and use it in an xmlns declaration. +*/ +typedef struct { + const char *nmspace; /* namespace of the XML report element */ + const char *name; /* element name for the XML report */ +} dav_report_elem; + + +/* Versioning provider hooks */ +struct dav_hooks_vsn +{ + /* + ** MANDATORY HOOKS + ** The following hooks are mandatory for all versioning providers; + ** they define the functionality needed to implement "core" versioning. + */ + + /* Return supported versioning options. + * Each dav_text item in the list will be returned as a separate + * DAV header. Providers are advised to limit the length of an + * individual text item to 63 characters, to conform to the limit + * used by MS Web Folders. + */ + void (*get_vsn_options)(apr_pool_t *p, apr_text_header *phdr); + + /* Get the value of a specific option for an OPTIONS request. + * The option being requested is given by the parsed XML + * element object "elem". The value of the option should be + * appended to the "option" text object. + */ + dav_error * (*get_option)(const dav_resource *resource, + const apr_xml_elem *elem, + apr_text_header *option); + + /* Determine whether a non-versioned (or non-existent) resource + * is versionable. Returns != 0 if resource can be versioned. + */ + int (*versionable)(const dav_resource *resource); + + /* Determine whether auto-versioning is enabled for a resource + * (which may not exist, or may not be versioned). If the resource + * is a checked-out resource, the provider must only enable + * auto-checkin if the resource was automatically checked out. + * + * The value returned depends on both the state of the resource + * and the value of its DAV:auto-version property. See the description + * of the dav_auto_version enumeration above for the details. + */ + dav_auto_version (*auto_versionable)(const dav_resource *resource); + + /* Put a resource under version control. If the resource already + * exists unversioned, then it becomes the initial version of the + * new version history, and it is replaced by a version selector + * which targets the new version. + * + * If the resource does not exist, then a new version-controlled + * resource is created which either targets an existing version (if the + * "target" argument is not NULL), or the initial, empty version + * in a new history resource (if the "target" argument is NULL). + * + * If successful, the resource object state is updated appropriately + * (that is, changed to refer to the new version-controlled resource). + */ + dav_error * (*vsn_control)(dav_resource *resource, + const char *target); + + /* Checkout a resource. If successful, the resource + * object state is updated appropriately. + * + * The auto_checkout flag will be set if this checkout is being + * done automatically, as part of some method which modifies + * the resource. The provider must remember that the resource + * was automatically checked out, so it can determine whether it + * can be automatically checked in. (Auto-checkin should only be + * enabled for resources which were automatically checked out.) + * + * If the working resource has a different URL from the + * target resource, a dav_resource descriptor is returned + * for the new working resource. Otherwise, the original + * resource descriptor will refer to the working resource. + * The working_resource argument can be NULL if the caller + * is not interested in the working resource. + * + * If the client has specified DAV:unreserved or DAV:fork-ok in the + * checkout request, then the corresponding flags are set. If + * DAV:activity-set has been specified, then create_activity is set + * if DAV:new was specified; otherwise, the DAV:href elements' CDATA + * (the actual href text) is passed in the "activities" array (each + * element of the array is a const char *). activities will be NULL + * no DAV:activity-set was provided or when create_activity is set. + */ + dav_error * (*checkout)(dav_resource *resource, + int auto_checkout, + int is_unreserved, int is_fork_ok, + int create_activity, + apr_array_header_t *activities, + dav_resource **working_resource); + + /* Uncheckout a checked-out resource. If successful, the resource + * object state is updated appropriately. + */ + dav_error * (*uncheckout)(dav_resource *resource); + + /* Checkin a checked-out resource. If successful, the resource + * object state is updated appropriately, and the + * version_resource descriptor will refer to the new version. + * The version_resource argument can be NULL if the caller + * is not interested in the new version resource. + * + * If the client has specified DAV:keep-checked-out in the checkin + * request, then the keep_checked_out flag is set. The provider + * should create a new version, but keep the resource in the + * checked-out state. + */ + dav_error * (*checkin)(dav_resource *resource, + int keep_checked_out, + dav_resource **version_resource); + + /* + ** Return the set of reports available at this resource. + ** + ** An array of report elements should be returned, with an end-marker + ** element containing namespace==NULL. The value of the + ** DAV:supported-report-set property will be constructed and + ** returned. + */ + dav_error * (*avail_reports)(const dav_resource *resource, + const dav_report_elem **reports); + + /* + ** Determine whether a Label header can be used + ** with a particular report. The dav_xml_doc structure + ** contains the parsed report request body. + ** Returns 0 if the Label header is not allowed. + */ + int (*report_label_header_allowed)(const apr_xml_doc *doc); + + /* + ** Generate a report on a resource. Since a provider is free + ** to define its own reports, and the value of request headers + ** may affect the interpretation of a report, the request record + ** must be passed to this routine. + ** + ** The dav_xml_doc structure contains the parsed report request + ** body. The report response should be generated into the specified + ** output filter. + ** + ** If an error occurs, and a response has not yet been generated, + ** then an error can be returned from this function. mod_dav will + ** construct an appropriate error response. Once some output has + ** been placed into the filter, however, the provider should not + ** return an error -- there is no way that mod_dav can deliver it + ** properly. + ** + ** ### maybe we need a way to signal an error anyways, and then + ** ### apache can abort the connection? + */ + dav_error * (*deliver_report)(request_rec *r, + const dav_resource *resource, + const apr_xml_doc *doc, + ap_filter_t *output); + + /* + ** OPTIONAL HOOKS + ** The following hooks are optional; if not defined, then the + ** corresponding protocol methods will be unsupported. + */ + + /* + ** Set the state of a checked-in version-controlled resource. + ** + ** If the request specified a version, the version resource + ** represents that version. If the request specified a label, + ** then "version" is NULL, and "label" is the label. + ** + ** The depth argument is ignored for a file, and can be 0, 1, or + ** DAV_INFINITY for a collection. The depth argument only applies + ** with a label, not a version. + ** + ** If an error occurs in a child resource, then the return value is + ** non-NULL, and *response is set to a multistatus response. + ** + ** This hook is optional; if not defined, then the UPDATE method + ** will not be supported. + */ + dav_error * (*update)(const dav_resource *resource, + const dav_resource *version, + const char *label, + int depth, + dav_response **response); + + /* + ** Add a label to a version. The resource is either a specific + ** version, or a version selector, in which case the label should + ** be added to the current target of the version selector. The + ** version selector cannot be checked out. + ** + ** If replace != 0, any existing label by the same name is + ** effectively deleted first. Otherwise, it is an error to + ** attempt to add a label which already exists on some version + ** of the same history resource. + ** + ** This hook is optional; if not defined, then the LABEL method + ** will not be supported. If it is defined, then the remove_label + ** hook must be defined also. + */ + dav_error * (*add_label)(const dav_resource *resource, + const char *label, + int replace); + + /* + ** Remove a label from a version. The resource is either a specific + ** version, or a version selector, in which case the label should + ** be added to the current target of the version selector. The + ** version selector cannot be checked out. + ** + ** It is an error if no such label exists on the specified version. + ** + ** This hook is optional, but if defined, the add_label hook + ** must be defined also. + */ + dav_error * (*remove_label)(const dav_resource *resource, + const char *label); + + /* + ** Determine whether a null resource can be created as a workspace. + ** The provider may restrict workspaces to certain locations. + ** Returns 0 if the resource cannot be a workspace. + ** + ** This hook is optional; if the provider does not support workspaces, + ** it should be set to NULL. + */ + int (*can_be_workspace)(const dav_resource *resource); + + /* + ** Create a workspace resource. The resource must not already + ** exist. Any element is passed to the provider + ** in the "doc" structure; it may be empty. + ** + ** If workspace creation is succesful, the state of the resource + ** object is updated appropriately. + ** + ** This hook is optional; if the provider does not support workspaces, + ** it should be set to NULL. + */ + dav_error * (*make_workspace)(dav_resource *resource, + apr_xml_doc *doc); + + /* + ** Determine whether a null resource can be created as an activity. + ** The provider may restrict activities to certain locations. + ** Returns 0 if the resource cannot be an activity. + ** + ** This hook is optional; if the provider does not support activities, + ** it should be set to NULL. + */ + int (*can_be_activity)(const dav_resource *resource); + + /* + ** Create an activity resource. The resource must not already + ** exist. + ** + ** If activity creation is succesful, the state of the resource + ** object is updated appropriately. + ** + ** This hook is optional; if the provider does not support activities, + ** it should be set to NULL. + */ + dav_error * (*make_activity)(dav_resource *resource); + + /* + ** Merge a resource (tree) into target resource (tree). + ** + ** ### more doc... + ** + ** This hook is optional; if the provider does not support merging, + ** then this should be set to NULL. + */ + dav_error * (*merge)(dav_resource *target, dav_resource *source, + int no_auto_merge, int no_checkout, + apr_xml_elem *prop_elem, + ap_filter_t *output); + + /* + ** If a provider needs a context to associate with this hooks structure, + ** then this field may be used. In most cases, it will just be NULL. + */ + void *ctx; +}; + + +/* -------------------------------------------------------------------- +** +** BINDING FUNCTIONS +*/ + +/* binding provider hooks */ +struct dav_hooks_binding { + + /* Determine whether a resource can be the target of a binding. + * Returns 0 if the resource cannot be a binding target. + */ + int (*is_bindable)(const dav_resource *resource); + + /* Create a binding to a resource. + * The resource argument is the target of the binding; + * the binding argument must be a resource which does not already + * exist. + */ + dav_error * (*bind_resource)(const dav_resource *resource, + dav_resource *binding); + + /* + ** If a provider needs a context to associate with this hooks structure, + ** then this field may be used. In most cases, it will just be NULL. + */ + void *ctx; + +}; + + +/* -------------------------------------------------------------------- +** +** SEARCH(DASL) FUNCTIONS +*/ + +/* search provider hooks */ +struct dav_hooks_search { + /* Set header for a OPTION method + * An error may be returned. + * To set a hadder, this function might call + * apr_table_setn(r->headers_out, "DASL", dasl_optin1); + * + * Examples: + * DASL: + * DASL: + * DASL: + */ + dav_error * (*set_option_head)(request_rec *r); + + /* Search resources + * An error may be returned. *response will contain multistatus + * responses (if any) suitable for the body of the error. It is also + * possible to return NULL, yet still have multistatus responses. + * In this case, typically the caller should return a 207 (Multistatus) + * and the responses (in the body) as the HTTP response. + */ + dav_error * (*search_resource)(request_rec *r, + dav_response **response); + + /* + ** If a provider needs a context to associate with this hooks structure, + ** then this field may be used. In most cases, it will just be NULL. + */ + void *ctx; + +}; + + +/* -------------------------------------------------------------------- +** +** MISCELLANEOUS STUFF +*/ + +/* fetch the "LimitXMLRequestBody" in force for this resource */ +DAV_DECLARE(apr_size_t) dav_get_limit_xml_body(const request_rec *r); + +typedef struct { + int propid; /* live property ID */ + const dav_hooks_liveprop *provider; /* the provider defining this prop */ +} dav_elem_private; + +#ifdef __cplusplus +} +#endif + +#endif /* _MOD_DAV_H_ */ diff --git a/rubbos/app/apache2/include/mod_include.h b/rubbos/app/apache2/include/mod_include.h new file mode 100644 index 00000000..6264b888 --- /dev/null +++ b/rubbos/app/apache2/include/mod_include.h @@ -0,0 +1,206 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MOD_INCLUDE_H +#define _MOD_INCLUDE_H 1 + +#include "apr_pools.h" +#include "apr_optional.h" + +#define STARTING_SEQUENCE "" + +#define DEFAULT_ERROR_MSG "[an error occurred while processing this directive]" +#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z" +#define SIZEFMT_BYTES 0 +#define SIZEFMT_KMG 1 +#define TMP_BUF_SIZE 1024 +#if APR_CHARSET_EBCDIC +#define RAW_ASCII_CHAR(ch) apr_xlate_conv_byte(ap_hdrs_from_ascii, (unsigned char)ch) +#else /*APR_CHARSET_EBCDIC*/ +#define RAW_ASCII_CHAR(ch) (ch) +#endif /*APR_CHARSET_EBCDIC*/ + +/**************************************************************************** + * Used to keep context information during parsing of a request for SSI tags. + * This is especially useful if the tag stretches across multiple buckets or + * brigades. This keeps track of which buckets need to be replaced with the + * content generated by the SSI tag. + * + * state: PRE_HEAD - State prior to finding the first character of the + * STARTING_SEQUENCE. Next state is PARSE_HEAD. + * PARSE_HEAD - State entered once the first character of the + * STARTING_SEQUENCE is found and exited when the + * the full STARTING_SEQUENCE has been matched or + * a match failure occurs. Next state is PRE_HEAD + * or PARSE_TAG. + * PARSE_TAG - State entered once the STARTING sequence has been + * matched. It is exited when the first character in + * ENDING_SEQUENCE is found. Next state is PARSE_TAIL. + * PARSE_TAIL - State entered from PARSE_TAG state when the first + * character in ENDING_SEQUENCE is encountered. This + * state is exited when the ENDING_SEQUENCE has been + * completely matched, or when a match failure occurs. + * Next state is PARSE_TAG or PARSED. + * PARSED - State entered from PARSE_TAIL once the complete + * ENDING_SEQUENCE has been matched. The SSI tag is + * processed and the SSI buckets are replaced with the + * SSI content during this state. + * parse_pos: Current matched position within the STARTING_SEQUENCE or + * ENDING_SEQUENCE during the PARSE_HEAD and PARSE_TAIL states. + * This is especially useful when the sequence spans brigades. + * X_start_bucket: These point to the buckets containing the first character + * of the STARTING_SEQUENCE, the first non-whitespace + * character of the tag, and the first character in the + * ENDING_SEQUENCE (head_, tag_, and tail_ respectively). + * The buckets are kept intact until the PARSED state is + * reached, at which time the tag is consolidated and the + * buckets are released. The buckets that these point to + * have all been set aside in the ssi_tag_brigade (along + * with all of the intervening buckets). + * X_start_index: The index points within the specified bucket contents + * where the first character of the STARTING_SEQUENCE, + * the first non-whitespace character of the tag, and the + * first character in the ENDING_SEQUENCE can be found + * (head_, tag_, and tail_ respectively). + * combined_tag: Once the PARSED state is reached the tag is collected from + * the bucket(s) in the ssi_tag_brigade into this contiguous + * buffer. The buckets in the ssi_tag_brigade are released + * and the tag is processed. + * curr_tag_pos: Ptr to the combined_tag buffer indicating the current + * parse position. + * tag_length: The number of bytes in the actual tag (excluding the + * STARTING_SEQUENCE, leading and trailing whitespace, + * and ENDING_SEQUENCE). This length is computed as the + * buckets are parsed and set aside during the PARSE_TAG state. + * ssi_tag_brigade: The temporary brigade used by this filter to set aside + * the buckets containing parts of the ssi tag and headers. + */ + +/* I keep this stuff here, because of binary compat. It probably doesn't care, + * but who knows ...? + */ +#ifdef MOD_INCLUDE_REDESIGN +typedef enum {PRE_HEAD, BLOW_PARSE_HEAD, BLOW_PARSE_DIRECTIVE, PARSE_TAG, + BLOW_PARSE_TAIL, PARSED} states; +#else +typedef enum {PRE_HEAD, PARSE_HEAD, PARSE_DIRECTIVE, PARSE_TAG, PARSE_TAIL, + PARSED} states; +#endif + +/** forward referenced as it needs to be held on the context */ +typedef struct bndm_t bndm_t; + +typedef struct include_filter_ctx { + states state; + long flags; /* See the FLAG_XXXXX definitions. */ + int if_nesting_level; + apr_size_t parse_pos; + int bytes_parsed; + apr_status_t status; + int output_now; + int output_flush; + + apr_bucket *head_start_bucket; + apr_size_t head_start_index; + + apr_bucket *tag_start_bucket; + apr_size_t tag_start_index; + + apr_bucket *tail_start_bucket; + apr_size_t tail_start_index; + + char *combined_tag; + char *curr_tag_pos; + apr_size_t directive_length; + apr_size_t tag_length; + + char *error_str; + char *error_str_override; + char *time_str; + char *time_str_override; + apr_pool_t *pool; + + apr_bucket_brigade *ssi_tag_brigade; + bndm_t *start_seq_pat; + char *start_seq; + int start_seq_len; + char *end_seq; + char *re_string; + regmatch_t (*re_result)[10]; +} include_ctx_t; + +/* These flags are used to set flag bits. */ +#define FLAG_PRINTING 0x00000001 /* Printing conditional lines. */ +#define FLAG_COND_TRUE 0x00000002 /* Conditional eval'd to true. */ +#define FLAG_SIZE_IN_BYTES 0x00000004 /* Sizes displayed in bytes. */ +#define FLAG_NO_EXEC 0x00000008 /* No Exec in current context. */ + +/* These flags are used to clear flag bits. */ +#define FLAG_SIZE_ABBREV 0xFFFFFFFB /* Reset SIZE_IN_BYTES bit. */ +#define FLAG_CLEAR_PRINT_COND 0xFFFFFFFC /* Reset PRINTING and COND_TRUE*/ +#define FLAG_CLEAR_PRINTING 0xFFFFFFFE /* Reset just PRINTING bit. */ + +#define CREATE_ERROR_BUCKET(cntx, t_buck, h_ptr, ins_head) \ +{ \ + /* XXX: it'd probably be nice to use a pool bucket here */ \ + t_buck = apr_bucket_heap_create(cntx->error_str, \ + strlen(cntx->error_str), \ + NULL, h_ptr->list); \ + APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \ + \ + if (ins_head == NULL) { \ + ins_head = t_buck; \ + } \ +} + +/* Make sure to check the return code rc. If it is anything other + * than APR_SUCCESS, then you should return this value up the + * call chain. + */ +#define SPLIT_AND_PASS_PRETAG_BUCKETS(brgd, cntxt, next, rc) \ +if ((APR_BRIGADE_EMPTY((cntxt)->ssi_tag_brigade)) && \ + ((cntxt)->head_start_bucket != NULL)) { \ + apr_bucket_brigade *tag_plus; \ + \ + tag_plus = apr_brigade_split((brgd), (cntxt)->head_start_bucket); \ + if ((cntxt)->output_flush) { \ + APR_BRIGADE_INSERT_TAIL((brgd), apr_bucket_flush_create((brgd)->bucket_alloc)); \ + } \ + (rc) = ap_pass_brigade((next), (brgd)); \ + (cntxt)->bytes_parsed = 0; \ + (brgd) = tag_plus; \ +} + + +typedef int (include_handler_fn_t)(include_ctx_t *ctx, apr_bucket_brigade **bb, + request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, + apr_bucket **inserted_head); + +APR_DECLARE_OPTIONAL_FN(void, ap_ssi_get_tag_and_value, (include_ctx_t *ctx, + char **tag, + char **tag_val, + int dodecode)); +APR_DECLARE_OPTIONAL_FN(char*, ap_ssi_parse_string, (request_rec *r, + include_ctx_t *ctx, + const char *in, + char *out, + apr_size_t length, + int leave_name)); +APR_DECLARE_OPTIONAL_FN(void, ap_register_include_handler, + (char *tag, include_handler_fn_t *func)); + +#endif /* MOD_INCLUDE */ diff --git a/rubbos/app/apache2/include/mod_log_config.h b/rubbos/app/apache2/include/mod_log_config.h new file mode 100644 index 00000000..00e79014 --- /dev/null +++ b/rubbos/app/apache2/include/mod_log_config.h @@ -0,0 +1,63 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "apr_optional.h" +#include "httpd.h" +#include "scoreboard.h" + +#ifndef _MOD_LOG_CONFIG_H +#define _MOD_LOG_CONFIG_H 1 + +/** + * callback function prototype for a external log handler + */ +typedef const char *ap_log_handler_fn_t(request_rec *r, char *a); + +/** + * callback function prototype for external writer initialization. + */ +typedef void *ap_log_writer_init(apr_pool_t *p, server_rec *s, + const char *name); +/** + * callback which gets called where there is a log line to write. + */ +typedef apr_status_t ap_log_writer( + request_rec *r, + void *handle, + const char **portions, + int *lengths, + int nelts, + apr_size_t len); + +typedef struct ap_log_handler { + ap_log_handler_fn_t *func; + int want_orig_default; +} ap_log_handler; + +APR_DECLARE_OPTIONAL_FN(void, ap_register_log_handler, + (apr_pool_t *p, char *tag, ap_log_handler_fn_t *func, + int def)); +/** + * you will need to set your init handler *BEFORE* the open_logs + * in mod_log_config gets executed + */ +APR_DECLARE_OPTIONAL_FN(void, ap_log_set_writer_init,(ap_log_writer_init *func)); +/** + * you should probably set the writer at the same time (ie..before open_logs) + */ +APR_DECLARE_OPTIONAL_FN(void, ap_log_set_writer, (ap_log_writer* func)); + +#endif /* MOD_LOG_CONFIG */ diff --git a/rubbos/app/apache2/include/mod_proxy.h b/rubbos/app/apache2/include/mod_proxy.h new file mode 100644 index 00000000..d1ed7d46 --- /dev/null +++ b/rubbos/app/apache2/include/mod_proxy.h @@ -0,0 +1,255 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MOD_PROXY_H +#define MOD_PROXY_H + +/* + * Main include file for the Apache proxy + */ + +/* + + Also note numerous FIXMEs and CHECKMEs which should be eliminated. + + This code is once again experimental! + + Things to do: + + 1. Make it completely work (for FTP too) + + 2. HTTP/1.1 + + Chuck Murcko 02-06-01 + + */ + +#define CORE_PRIVATE + +#include "apr_hooks.h" +#include "apr.h" +#include "apr_lib.h" +#include "apr_strings.h" +#include "apr_buckets.h" +#include "apr_md5.h" +#include "apr_network_io.h" +#include "apr_pools.h" +#include "apr_strings.h" +#include "apr_uri.h" +#include "apr_date.h" +#include "apr_fnmatch.h" +#define APR_WANT_STRFUNC +#include "apr_want.h" + +#include "httpd.h" +#include "http_config.h" +#include "ap_config.h" +#include "http_core.h" +#include "http_protocol.h" +#include "http_request.h" +#include "http_vhost.h" +#include "http_main.h" +#include "http_log.h" +#include "http_connection.h" +#include "util_filter.h" +#include "util_ebcdic.h" + +#if APR_HAVE_NETINET_IN_H +#include +#endif +#if APR_HAVE_ARPA_INET_H +#include +#endif + +/* for proxy_canonenc() */ +enum enctype { + enc_path, enc_search, enc_user, enc_fpath, enc_parm +}; + +#if APR_CHARSET_EBCDIC +#define CRLF "\r\n" +#else /*APR_CHARSET_EBCDIC*/ +#define CRLF "\015\012" +#endif /*APR_CHARSET_EBCDIC*/ + +/* default Max-Forwards header setting */ +#define DEFAULT_MAX_FORWARDS 10 + +/* static information about a remote proxy */ +struct proxy_remote { + const char *scheme; /* the schemes handled by this proxy, or '*' */ + const char *protocol; /* the scheme used to talk to this proxy */ + const char *hostname; /* the hostname of this proxy */ + apr_port_t port; /* the port for this proxy */ + regex_t *regexp; /* compiled regex (if any) for the remote */ + int use_regex; /* simple boolean. True if we have a regex pattern */ +}; + +struct proxy_alias { + const char *real; + const char *fake; +}; + +struct dirconn_entry { + char *name; + struct in_addr addr, mask; + struct apr_sockaddr_t *hostaddr; + int (*matcher) (struct dirconn_entry * This, request_rec *r); +}; + +struct noproxy_entry { + const char *name; + struct apr_sockaddr_t *addr; +}; + +typedef struct { + apr_array_header_t *proxies; + apr_array_header_t *sec_proxy; + apr_array_header_t *aliases; + apr_array_header_t *raliases; + apr_array_header_t *noproxies; + apr_array_header_t *dirconn; + apr_array_header_t *allowed_connect_ports; + const char *domain; /* domain name to use in absence of a domain name in the request */ + int req; /* true if proxy requests are enabled */ + char req_set; + enum { + via_off, + via_on, + via_block, + via_full + } viaopt; /* how to deal with proxy Via: headers */ + char viaopt_set; + apr_size_t recv_buffer_size; + char recv_buffer_size_set; + apr_size_t io_buffer_size; + char io_buffer_size_set; + long maxfwd; + char maxfwd_set; + /** + * the following setting masks the error page + * returned from the 'proxied server' and just + * forwards the status code upwards. + * This allows the main server (us) to generate + * the error page, (so it will look like a error + * returned from the rest of the system + */ + int error_override; + int error_override_set; + int preserve_host; + int preserve_host_set; + apr_interval_time_t timeout; + apr_interval_time_t timeout_set; + enum { + bad_error, + bad_ignore, + bad_body + } badopt; /* how to deal with bad headers */ + char badopt_set; + +} proxy_server_conf; + +typedef struct { + const char *p; /* The path */ + int p_is_fnmatch; /* Is this path an fnmatch candidate? */ + regex_t *r; /* Is this a regex? */ + const char *ftp_directory_charset; +} proxy_dir_conf; + +typedef struct { + conn_rec *connection; + char *hostname; + apr_port_t port; + int is_ssl; +} proxy_conn_rec; + +typedef struct { + float cache_completion; /* completion percentage */ + int content_length; /* length of the content */ +} proxy_completion; + + +/* hooks */ + +/* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and + * PROXY_DECLARE_DATA with appropriate export and import tags for the platform + */ +#if !defined(WIN32) +#define PROXY_DECLARE(type) type +#define PROXY_DECLARE_NONSTD(type) type +#define PROXY_DECLARE_DATA +#elif defined(PROXY_DECLARE_STATIC) +#define PROXY_DECLARE(type) type __stdcall +#define PROXY_DECLARE_NONSTD(type) type +#define PROXY_DECLARE_DATA +#elif defined(PROXY_DECLARE_EXPORT) +#define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall +#define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type +#define PROXY_DECLARE_DATA __declspec(dllexport) +#else +#define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall +#define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type +#define PROXY_DECLARE_DATA __declspec(dllimport) +#endif + +/** + * Hook an optional proxy hook. Unlike static hooks, this uses a macro + * instead of a function. + */ +#define PROXY_OPTIONAL_HOOK(name,fn,pre,succ,order) \ + APR_OPTIONAL_HOOK(proxy,name,fn,pre,succ,order) + +APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r, + proxy_server_conf *conf, char *url, + const char *proxyhost, apr_port_t proxyport)) +APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r, + char *url)) + +APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr)) +APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r)) + +/* proxy_util.c */ + +PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r); +PROXY_DECLARE(int) ap_proxy_hex2c(const char *x); +PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x); +PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t, + int isenc); +PROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp, + char **passwordp, char **hostp, apr_port_t *port); +PROXY_DECLARE(const char *)ap_proxy_date_canon(apr_pool_t *p, const char *x); +PROXY_DECLARE(apr_table_t *)ap_proxy_read_headers(request_rec *r, request_rec *rp, char *buffer, int size, conn_rec *c); +PROXY_DECLARE(int) ap_proxy_liststr(const char *list, const char *val); +PROXY_DECLARE(char *)ap_proxy_removestr(apr_pool_t *pool, const char *list, const char *val); +PROXY_DECLARE(int) ap_proxy_hex2sec(const char *x); +PROXY_DECLARE(void) ap_proxy_sec2hex(int t, char *y); +PROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message); +PROXY_DECLARE(int) ap_proxy_is_ipaddr(struct dirconn_entry *This, apr_pool_t *p); +PROXY_DECLARE(int) ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p); +PROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p); +PROXY_DECLARE(int) ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p); +PROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr); +PROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r); +PROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen, int *eos); +PROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key); +PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **, const char *, apr_sockaddr_t *, const char *, proxy_server_conf *, server_rec *, apr_pool_t *); +PROXY_DECLARE(int) ap_proxy_ssl_enable(conn_rec *c); +PROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c); + +/* For proxy_util */ +extern module AP_MODULE_DECLARE_DATA proxy_module; + +#endif /*MOD_PROXY_H*/ diff --git a/rubbos/app/apache2/include/mod_ssl.h b/rubbos/app/apache2/include/mod_ssl.h new file mode 100644 index 00000000..6f69c26f --- /dev/null +++ b/rubbos/app/apache2/include/mod_ssl.h @@ -0,0 +1,724 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* _ _ + * _ __ ___ ___ __| | ___ ___| | mod_ssl + * | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL + * | | | | | | (_) | (_| | \__ \__ \ | + * |_| |_| |_|\___/ \__,_|___|___/___/_| + * |_____| + * mod_ssl.h + * Global header + */ + /* ``The Apache Group: a collection + of talented individuals who are + trying to perfect the art of + never finishing something.'' + -- Rob Hartill */ +#ifndef __MOD_SSL_H__ +#define __MOD_SSL_H__ + +/* + * Optionally enable the experimental stuff, but allow the user to + * override the decision which experimental parts are included by using + * CFLAGS="-DSSL_EXPERIMENTAL_xxxx_IGNORE". + */ +#ifdef SSL_EXPERIMENTAL +#ifdef SSL_ENGINE +#ifndef SSL_EXPERIMENTAL_ENGINE_IGNORE +#define SSL_EXPERIMENTAL_ENGINE +#endif +#endif +#endif /* SSL_EXPERIMENTAL */ + +/* + * Power up our brain... + */ + +/* Apache headers */ +#include "httpd.h" +#include "http_config.h" +#include "http_core.h" +#include "http_log.h" +#include "http_main.h" +#include "http_connection.h" +#include "http_request.h" +#include "http_protocol.h" +#include "util_script.h" +#include "util_filter.h" +#include "mpm.h" +#include "apr.h" +#include "apr_strings.h" +#define APR_WANT_STRFUNC +#include "apr_want.h" +#include "apr_tables.h" +#include "apr_lib.h" +#include "apr_fnmatch.h" +#include "apr_strings.h" +#include "apr_dbm.h" +#include "apr_rmm.h" +#include "apr_shm.h" +#include "apr_global_mutex.h" +#include "apr_optional.h" + +#define MOD_SSL_VERSION AP_SERVER_BASEREVISION + +#ifdef HAVE_SSLC + +#include +#include +#include +#include +#include +#include +#include +#include + +#else /* !HAVE_SSLC (implicit HAVE_OPENSSL) */ + +#include +#include +#include +#include +#include +#include +#include +#ifdef SSL_EXPERIMENTAL_ENGINE +#include +#endif +#ifdef HAVE_SSL_X509V3_H +#include +#endif + +#endif /* !HAVE_SSLC (implicit HAVE_OPENSSL) */ + + +/* mod_ssl headers */ +#include "ssl_toolkit_compat.h" +#include "ssl_expr.h" +#include "ssl_util_ssl.h" +#include "ssl_util_table.h" + +/* The #ifdef macros are only defined AFTER including the above + * therefore we cannot include these system files at the top :-( + */ +#if APR_HAVE_SYS_TIME_H +#include +#endif +#if APR_HAVE_UNISTD_H +#include /* needed for STDIN_FILENO et.al., at least on FreeBSD */ +#endif + +/* + * Provide reasonable default for some defines + */ +#ifndef FALSE +#define FALSE (0) +#endif +#ifndef TRUE +#define TRUE (!FALSE) +#endif +#ifndef PFALSE +#define PFALSE ((void *)FALSE) +#endif +#ifndef PTRUE +#define PTRUE ((void *)TRUE) +#endif +#ifndef UNSET +#define UNSET (-1) +#endif +#ifndef NUL +#define NUL '\0' +#endif +#ifndef RAND_MAX +#include +#define RAND_MAX INT_MAX +#endif + +/* + * Provide reasonable defines for some types + */ +#ifndef BOOL +#define BOOL unsigned int +#endif +#ifndef UCHAR +#define UCHAR unsigned char +#endif + +/* + * Provide useful shorthands + */ +#define strEQ(s1,s2) (strcmp(s1,s2) == 0) +#define strNE(s1,s2) (strcmp(s1,s2) != 0) +#define strEQn(s1,s2,n) (strncmp(s1,s2,n) == 0) +#define strNEn(s1,s2,n) (strncmp(s1,s2,n) != 0) + +#define strcEQ(s1,s2) (strcasecmp(s1,s2) == 0) +#define strcNE(s1,s2) (strcasecmp(s1,s2) != 0) +#define strcEQn(s1,s2,n) (strncasecmp(s1,s2,n) == 0) +#define strcNEn(s1,s2,n) (strncasecmp(s1,s2,n) != 0) + +#define strIsEmpty(s) (s == NULL || s[0] == NUL) + +#define myConnConfig(c) \ +(SSLConnRec *)ap_get_module_config(c->conn_config, &ssl_module) +#define myCtxConfig(sslconn, sc) (sslconn->is_proxy ? sc->proxy : sc->server) +#define myConnConfigSet(c, val) \ +ap_set_module_config(c->conn_config, &ssl_module, val) +#define mySrvConfig(srv) (SSLSrvConfigRec *)ap_get_module_config(srv->module_config, &ssl_module) +#define myDirConfig(req) (SSLDirConfigRec *)ap_get_module_config(req->per_dir_config, &ssl_module) +#define myModConfig(srv) (mySrvConfig((srv)))->mc + +#define myCtxVarSet(mc,num,val) mc->rCtx.pV##num = val +#define myCtxVarGet(mc,num,type) (type)(mc->rCtx.pV##num) + +/* + * Defaults for the configuration + */ +#ifndef SSL_SESSION_CACHE_TIMEOUT +#define SSL_SESSION_CACHE_TIMEOUT 300 +#endif + +/* + * Support for MM library + */ +#define SSL_MM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD ) + +/* + * Support for DBM library + */ +#define SSL_DBM_FILE_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD ) + +#if !defined(SSL_DBM_FILE_SUFFIX_DIR) && !defined(SSL_DBM_FILE_SUFFIX_PAG) +#if defined(DBM_SUFFIX) +#define SSL_DBM_FILE_SUFFIX_DIR DBM_SUFFIX +#define SSL_DBM_FILE_SUFFIX_PAG DBM_SUFFIX +#elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM)) +#define SSL_DBM_FILE_SUFFIX_DIR ".db" +#define SSL_DBM_FILE_SUFFIX_PAG ".db" +#else +#define SSL_DBM_FILE_SUFFIX_DIR ".dir" +#define SSL_DBM_FILE_SUFFIX_PAG ".pag" +#endif +#endif + +/* + * Define the certificate algorithm types + */ + +typedef int ssl_algo_t; + +#define SSL_ALGO_UNKNOWN (0) +#define SSL_ALGO_RSA (1<<0) +#define SSL_ALGO_DSA (1<<1) +#define SSL_ALGO_ALL (SSL_ALGO_RSA|SSL_ALGO_DSA) + +#define SSL_AIDX_RSA (0) +#define SSL_AIDX_DSA (1) +#define SSL_AIDX_MAX (2) + + +/* + * Define IDs for the temporary RSA keys and DH params + */ + +#define SSL_TMP_KEY_RSA_512 (0) +#define SSL_TMP_KEY_RSA_1024 (1) +#define SSL_TMP_KEY_DH_512 (2) +#define SSL_TMP_KEY_DH_1024 (3) +#define SSL_TMP_KEY_MAX (4) + +/* + * Define the SSL options + */ +#define SSL_OPT_NONE (0) +#define SSL_OPT_RELSET (1<<0) +#define SSL_OPT_STDENVVARS (1<<1) +#define SSL_OPT_COMPATENVVARS (1<<2) +#define SSL_OPT_EXPORTCERTDATA (1<<3) +#define SSL_OPT_FAKEBASICAUTH (1<<4) +#define SSL_OPT_STRICTREQUIRE (1<<5) +#define SSL_OPT_OPTRENEGOTIATE (1<<6) +#define SSL_OPT_ALL (SSL_OPT_STDENVVARS|SSL_OPT_COMPATENVVAR|SSL_OPT_EXPORTCERTDATA|SSL_OPT_FAKEBASICAUTH|SSL_OPT_STRICTREQUIRE|SSL_OPT_OPTRENEGOTIATE) +typedef int ssl_opt_t; + +/* + * Define the SSL Protocol options + */ +#define SSL_PROTOCOL_NONE (0) +#define SSL_PROTOCOL_SSLV2 (1<<0) +#define SSL_PROTOCOL_SSLV3 (1<<1) +#define SSL_PROTOCOL_TLSV1 (1<<2) +#define SSL_PROTOCOL_ALL (SSL_PROTOCOL_SSLV2|SSL_PROTOCOL_SSLV3|SSL_PROTOCOL_TLSV1) +typedef int ssl_proto_t; + +/* + * Define the SSL verify levels + */ +typedef enum { + SSL_CVERIFY_UNSET = UNSET, + SSL_CVERIFY_NONE = 0, + SSL_CVERIFY_OPTIONAL = 1, + SSL_CVERIFY_REQUIRE = 2, + SSL_CVERIFY_OPTIONAL_NO_CA = 3 +} ssl_verify_t; + +#define SSL_VERIFY_PEER_STRICT \ + (SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT) + +#ifndef X509_V_ERR_CERT_UNTRUSTED +#define X509_V_ERR_CERT_UNTRUSTED 27 +#endif + +#define ssl_verify_error_is_optional(errnum) \ + ((errnum == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) \ + || (errnum == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) \ + || (errnum == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY) \ + || (errnum == X509_V_ERR_CERT_UNTRUSTED) \ + || (errnum == X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE)) + +/* + * Define the SSL pass phrase dialog types + */ +typedef enum { + SSL_PPTYPE_UNSET = UNSET, + SSL_PPTYPE_BUILTIN = 0, + SSL_PPTYPE_FILTER = 1, + SSL_PPTYPE_PIPE = 2 +} ssl_pphrase_t; + +/* + * Define the Path Checking modes + */ +#define SSL_PCM_EXISTS 1 +#define SSL_PCM_ISREG 2 +#define SSL_PCM_ISDIR 4 +#define SSL_PCM_ISNONZERO 8 +typedef unsigned int ssl_pathcheck_t; + +/* + * Define the SSL session cache modes and structures + */ +typedef enum { + SSL_SCMODE_UNSET = UNSET, + SSL_SCMODE_NONE = 0, + SSL_SCMODE_DBM = 1, + SSL_SCMODE_SHMHT = 2, + SSL_SCMODE_SHMCB = 3 +} ssl_scmode_t; + +/* + * Define the SSL mutex modes + */ +typedef enum { + SSL_MUTEXMODE_UNSET = UNSET, + SSL_MUTEXMODE_NONE = 0, + SSL_MUTEXMODE_USED = 1 +} ssl_mutexmode_t; + +/* + * Define the SSL requirement structure + */ +typedef struct { + char *cpExpr; + ssl_expr *mpExpr; +} ssl_require_t; + +/* + * Define the SSL random number generator seeding source + */ +typedef enum { + SSL_RSCTX_STARTUP = 1, + SSL_RSCTX_CONNECT = 2 +} ssl_rsctx_t; +typedef enum { + SSL_RSSRC_BUILTIN = 1, + SSL_RSSRC_FILE = 2, + SSL_RSSRC_EXEC = 3, + SSL_RSSRC_EGD = 4 +} ssl_rssrc_t; +typedef struct { + ssl_rsctx_t nCtx; + ssl_rssrc_t nSrc; + char *cpPath; + int nBytes; +} ssl_randseed_t; + +/* + * Define the structure of an ASN.1 anything + */ +typedef struct { + long int nData; + unsigned char *cpData; + apr_time_t source_mtime; +} ssl_asn1_t; + +/* + * Define the mod_ssl per-module configuration structure + * (i.e. the global configuration for each httpd process) + */ + +typedef enum { + SSL_SHUTDOWN_TYPE_UNSET, + SSL_SHUTDOWN_TYPE_STANDARD, + SSL_SHUTDOWN_TYPE_UNCLEAN, + SSL_SHUTDOWN_TYPE_ACCURATE +} ssl_shutdown_type_e; + +typedef struct { + SSL *ssl; + const char *client_dn; + X509 *client_cert; + ssl_shutdown_type_e shutdown_type; + const char *verify_info; + const char *verify_error; + int verify_depth; + int is_proxy; + int disabled; + int non_ssl_request; + + /* Track the handshake/renegotiation state for the connection so + * that all client-initiated renegotiations can be rejected, as a + * partial fix for CVE-2009-3555. */ + enum { + RENEG_INIT = 0, /* Before initial handshake */ + RENEG_REJECT, /* After initial handshake; any client-initiated + * renegotiation should be rejected */ + RENEG_ALLOW, /* A server-initated renegotiation is taking + * place (as dictated by configuration) */ + RENEG_ABORT /* Renegotiation initiated by client, abort the + * connection */ + } reneg_state; +} SSLConnRec; + +typedef struct { + pid_t pid; + apr_pool_t *pPool; + BOOL bFixed; + int nSessionCacheMode; + char *szSessionCacheDataFile; + int nSessionCacheDataSize; + apr_shm_t *pSessionCacheDataMM; + apr_rmm_t *pSessionCacheDataRMM; + apr_table_t *tSessionCacheDataTable; + ssl_mutexmode_t nMutexMode; + apr_lockmech_e nMutexMech; + const char *szMutexFile; + apr_global_mutex_t *pMutex; + apr_array_header_t *aRandSeed; + apr_hash_t *tVHostKeys; + void *pTmpKeys[SSL_TMP_KEY_MAX]; + apr_hash_t *tPublicCert; + apr_hash_t *tPrivateKey; +#ifdef SSL_EXPERIMENTAL_ENGINE + char *szCryptoDevice; +#endif + struct { + void *pV1, *pV2, *pV3, *pV4, *pV5, *pV6, *pV7, *pV8, *pV9, *pV10; + } rCtx; +} SSLModConfigRec; + +/* public cert/private key */ +typedef struct { + /* + * server only has 1-2 certs/keys + * 1 RSA and/or 1 DSA + */ + const char *cert_files[SSL_AIDX_MAX]; + const char *key_files[SSL_AIDX_MAX]; + X509 *certs[SSL_AIDX_MAX]; + EVP_PKEY *keys[SSL_AIDX_MAX]; +} modssl_pk_server_t; + +typedef struct { + /* proxy can have any number of cert/key pairs */ + const char *cert_file; + const char *cert_path; + STACK_OF(X509_INFO) *certs; +} modssl_pk_proxy_t; + +/* stuff related to authentication that can also be per-dir */ +typedef struct { + /* known/trusted CAs */ + const char *ca_cert_path; + const char *ca_cert_file; + + const char *cipher_suite; + + /* for client or downstream server authentication */ + int verify_depth; + ssl_verify_t verify_mode; +} modssl_auth_ctx_t; + +typedef struct SSLSrvConfigRec SSLSrvConfigRec; + +typedef struct { + SSLSrvConfigRec *sc; /* pointer back to server config */ + SSL_CTX *ssl_ctx; + + /* we are one or the other */ + modssl_pk_server_t *pks; + modssl_pk_proxy_t *pkp; + + ssl_proto_t protocol; + + /* config for handling encrypted keys */ + ssl_pphrase_t pphrase_dialog_type; + const char *pphrase_dialog_path; + + const char *cert_chain; + + /* certificate revocation list */ + const char *crl_path; + const char *crl_file; + X509_STORE *crl; + + modssl_auth_ctx_t auth; +} modssl_ctx_t; + +struct SSLSrvConfigRec { + SSLModConfigRec *mc; + BOOL enabled; + BOOL proxy_enabled; + const char *vhost_id; + int vhost_id_len; + int session_cache_timeout; + BOOL insecure_reneg; + modssl_ctx_t *server; + modssl_ctx_t *proxy; +}; + +/* + * Define the mod_ssl per-directory configuration structure + * (i.e. the local configuration for all + * and .htaccess contexts) + */ +typedef struct { + BOOL bSSLRequired; + apr_array_header_t *aRequirement; + ssl_opt_t nOptions; + ssl_opt_t nOptionsAdd; + ssl_opt_t nOptionsDel; + const char *szCipherSuite; + ssl_verify_t nVerifyClient; + int nVerifyDepth; + const char *szCACertificatePath; + const char *szCACertificateFile; + const char *szUserName; +} SSLDirConfigRec; + +/* + * function prototypes + */ + +/* API glue structures */ +extern module AP_MODULE_DECLARE_DATA ssl_module; + +/* "global" stuff */ +extern const char ssl_valid_ssl_mutex_string[]; + +/* configuration handling */ +SSLModConfigRec *ssl_config_global_create(server_rec *); +void ssl_config_global_fix(SSLModConfigRec *); +BOOL ssl_config_global_isfixed(SSLModConfigRec *); +void *ssl_config_server_create(apr_pool_t *, server_rec *); +void *ssl_config_server_merge(apr_pool_t *, void *, void *); +void *ssl_config_perdir_create(apr_pool_t *, char *); +void *ssl_config_perdir_merge(apr_pool_t *, void *, void *); +const char *ssl_cmd_SSLMutex(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLPassPhraseDialog(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCryptoDevice(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLRandomSeed(cmd_parms *, void *, const char *, const char *, const char *); +const char *ssl_cmd_SSLEngine(cmd_parms *, void *, int); +const char *ssl_cmd_SSLCipherSuite(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCertificateFile(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCertificateKeyFile(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCertificateChainFile(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCACertificatePath(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCACertificateFile(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCARevocationPath(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLCARevocationFile(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLVerifyClient(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLVerifyDepth(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLSessionCache(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLSessionCacheTimeout(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProtocol(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLOptions(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLRequireSSL(cmd_parms *, void *); +const char *ssl_cmd_SSLRequire(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLUserName(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLInsecureRenegotiation(cmd_parms *cmd, void *dcfg, int flag); + +const char *ssl_cmd_SSLProxyEngine(cmd_parms *cmd, void *dcfg, int flag); +const char *ssl_cmd_SSLProxyProtocol(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyCipherSuite(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyVerify(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyVerifyDepth(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyCACertificatePath(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyCACertificateFile(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyCARevocationPath(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyCARevocationFile(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyMachineCertificatePath(cmd_parms *, void *, const char *); +const char *ssl_cmd_SSLProxyMachineCertificateFile(cmd_parms *, void *, const char *); + +/* module initialization */ +int ssl_init_Module(apr_pool_t *, apr_pool_t *, apr_pool_t *, server_rec *); +void ssl_init_Engine(server_rec *, apr_pool_t *); +void ssl_init_ConfigureServer(server_rec *, apr_pool_t *, apr_pool_t *, SSLSrvConfigRec *); +void ssl_init_CheckServers(server_rec *, apr_pool_t *); +STACK_OF(X509_NAME) + *ssl_init_FindCAList(server_rec *, apr_pool_t *, const char *, const char *); +void ssl_init_Child(apr_pool_t *, server_rec *); +apr_status_t ssl_init_ModuleKill(void *data); + +/* Apache API hooks */ +int ssl_hook_Auth(request_rec *); +int ssl_hook_UserCheck(request_rec *); +int ssl_hook_Access(request_rec *); +int ssl_hook_Fixup(request_rec *); +int ssl_hook_ReadReq(request_rec *); + +/* OpenSSL callbacks */ +RSA *ssl_callback_TmpRSA(SSL *, int, int); +DH *ssl_callback_TmpDH(SSL *, int, int); +int ssl_callback_SSLVerify(int, X509_STORE_CTX *); +int ssl_callback_SSLVerify_CRL(int, X509_STORE_CTX *, conn_rec *); +int ssl_callback_proxy_cert(SSL *ssl, MODSSL_CLIENT_CERT_CB_ARG_TYPE **x509, EVP_PKEY **pkey); +int ssl_callback_NewSessionCacheEntry(SSL *, SSL_SESSION *); +SSL_SESSION *ssl_callback_GetSessionCacheEntry(SSL *, unsigned char *, int, int *); +void ssl_callback_DelSessionCacheEntry(SSL_CTX *, SSL_SESSION *); +void ssl_callback_Info(MODSSL_INFO_CB_ARG_TYPE, int, int); + +/* Session Cache Support */ +void ssl_scache_init(server_rec *, apr_pool_t *); +#if 0 /* XXX */ +void ssl_scache_status_register(apr_pool_t *p); +#endif +void ssl_scache_kill(server_rec *); +BOOL ssl_scache_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *); +SSL_SESSION *ssl_scache_retrieve(server_rec *, UCHAR *, int); +void ssl_scache_remove(server_rec *, UCHAR *, int); +void ssl_scache_expire(server_rec *); +void ssl_scache_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *); +char *ssl_scache_id2sz(UCHAR *, int); +void ssl_scache_dbm_init(server_rec *, apr_pool_t *); +void ssl_scache_dbm_kill(server_rec *); +BOOL ssl_scache_dbm_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *); +SSL_SESSION *ssl_scache_dbm_retrieve(server_rec *, UCHAR *, int); +void ssl_scache_dbm_remove(server_rec *, UCHAR *, int); +void ssl_scache_dbm_expire(server_rec *); +void ssl_scache_dbm_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *); + +void ssl_scache_shmht_init(server_rec *, apr_pool_t *); +void ssl_scache_shmht_kill(server_rec *); +BOOL ssl_scache_shmht_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *); +SSL_SESSION *ssl_scache_shmht_retrieve(server_rec *, UCHAR *, int); +void ssl_scache_shmht_remove(server_rec *, UCHAR *, int); +void ssl_scache_shmht_expire(server_rec *); +void ssl_scache_shmht_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *); + +void ssl_scache_shmcb_init(server_rec *, apr_pool_t *); +void ssl_scache_shmcb_kill(server_rec *); +BOOL ssl_scache_shmcb_store(server_rec *, UCHAR *, int, time_t, SSL_SESSION *); +SSL_SESSION *ssl_scache_shmcb_retrieve(server_rec *, UCHAR *, int); +void ssl_scache_shmcb_remove(server_rec *, UCHAR *, int); +void ssl_scache_shmcb_expire(server_rec *); +void ssl_scache_shmcb_status(server_rec *, apr_pool_t *, void (*)(char *, void *), void *); + +/* Pass Phrase Support */ +void ssl_pphrase_Handle(server_rec *, apr_pool_t *); + +/* Diffie-Hellman Parameter Support */ +DH *ssl_dh_GetTmpParam(int); +DH *ssl_dh_GetParamFromFile(char *); + +unsigned char *ssl_asn1_table_set(apr_hash_t *table, + const char *key, + long int length); + +ssl_asn1_t *ssl_asn1_table_get(apr_hash_t *table, + const char *key); + +void ssl_asn1_table_unset(apr_hash_t *table, + const char *key); + +const char *ssl_asn1_keystr(int keytype); + +const char *ssl_asn1_table_keyfmt(apr_pool_t *p, + const char *id, + int keytype); +/* Mutex Support */ +int ssl_mutex_init(server_rec *, apr_pool_t *); +int ssl_mutex_reinit(server_rec *, apr_pool_t *); +int ssl_mutex_on(server_rec *); +int ssl_mutex_off(server_rec *); + +/* Logfile Support */ +void ssl_die(void); +void ssl_log_ssl_error(const char *, int, int, server_rec *); + +/* Variables */ +void ssl_var_register(void); +char *ssl_var_lookup(apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *); +void ssl_var_log_config_register(apr_pool_t *p); + +APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup, + (apr_pool_t *, server_rec *, + conn_rec *, request_rec *, + char *)); + +/* An optional function which returns non-zero if the given connection + * is using SSL/TLS. */ +APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *)); + +/* Proxy Support */ +int ssl_proxy_enable(conn_rec *c); +int ssl_engine_disable(conn_rec *c); + +APR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *)); + +APR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *)); + +/* I/O */ +void ssl_io_filter_init(conn_rec *, SSL *); +void ssl_io_filter_register(apr_pool_t *); +long ssl_io_data_cb(BIO *, int, MODSSL_BIO_CB_ARG_TYPE *, int, long, long); + +/* ssl_io_buffer_fill fills the setaside buffering of the HTTP request + * to allow an SSL renegotiation to take place. */ +int ssl_io_buffer_fill(request_rec *r); + +/* PRNG */ +int ssl_rand_seed(server_rec *, apr_pool_t *, ssl_rsctx_t, char *); + +/* Utility Functions */ +char *ssl_util_vhostid(apr_pool_t *, server_rec *); +void ssl_util_strupper(char *); +void ssl_util_uuencode(char *, const char *, BOOL); +void ssl_util_uuencode_binary(unsigned char *, const unsigned char *, int, BOOL); +apr_file_t *ssl_util_ppopen(server_rec *, apr_pool_t *, const char *, + const char * const *); +void ssl_util_ppclose(server_rec *, apr_pool_t *, apr_file_t *); +char *ssl_util_readfilter(server_rec *, apr_pool_t *, const char *, + const char * const *); +BOOL ssl_util_path_check(ssl_pathcheck_t, const char *, apr_pool_t *); +ssl_algo_t ssl_util_algotypeof(X509 *, EVP_PKEY *); +char *ssl_util_algotypestr(ssl_algo_t); +char *ssl_util_ptxtsub(apr_pool_t *, const char *, const char *, char *); +void ssl_util_thread_setup(apr_pool_t *); + +#define APR_SHM_MAXSIZE (64 * 1024 * 1024) +#endif /* __MOD_SSL_H__ */ diff --git a/rubbos/app/apache2/include/mod_status.h b/rubbos/app/apache2/include/mod_status.h new file mode 100644 index 00000000..03911a02 --- /dev/null +++ b/rubbos/app/apache2/include/mod_status.h @@ -0,0 +1,54 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MOD_STATUS_H +#define MOD_STATUS_H + +#include "ap_config.h" +#include "httpd.h" + +#define AP_STATUS_SHORT (0x1) /* short, non-HTML report requested */ +#define AP_STATUS_NOTABLE (0x2) /* HTML report without tables */ +#define AP_STATUS_EXTENDED (0x4) /* detailed report */ + +#if !defined(WIN32) +#define STATUS_DECLARE(type) type +#define STATUS_DECLARE_NONSTD(type) type +#define STATUS_DECLARE_DATA +#elif defined(STATUS_DECLARE_STATIC) +#define STATUS_DECLARE(type) type __stdcall +#define STATUS_DECLARE_NONSTD(type) type +#define STATUS_DECLARE_DATA +#elif defined(STATUS_DECLARE_EXPORT) +#define STATUS_DECLARE(type) __declspec(dllexport) type __stdcall +#define STATUS_DECLARE_NONSTD(type) __declspec(dllexport) type +#define STATUS_DECLARE_DATA __declspec(dllexport) +#else +#define STATUS_DECLARE(type) __declspec(dllimport) type __stdcall +#define STATUS_DECLARE_NONSTD(type) __declspec(dllimport) type +#define STATUS_DECLARE_DATA __declspec(dllimport) +#endif + +/* Optional hooks which can insert extra content into the mod_status + * output. FLAGS will be set to the bitwise OR of any of the + * AP_STATUS_* flags. + * + * Implementations of this hook should generate content using + * functions in the ap_rputs/ap_rprintf family; each hook should + * return OK or DECLINED. */ +APR_DECLARE_EXTERNAL_HOOK(ap, STATUS, int, status_hook, + (request_rec *r, int flags)) +#endif diff --git a/rubbos/app/apache2/include/mpm.h b/rubbos/app/apache2/include/mpm.h new file mode 100644 index 00000000..31830c6c --- /dev/null +++ b/rubbos/app/apache2/include/mpm.h @@ -0,0 +1,50 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "scoreboard.h" +#include "unixd.h" + +#ifndef APACHE_MPM_WORKER_H +#define APACHE_MPM_WORKER_H + +#define WORKER_MPM + +#define MPM_NAME "Worker" + +#define AP_MPM_WANT_RECLAIM_CHILD_PROCESSES +#define AP_MPM_WANT_WAIT_OR_TIMEOUT +#define AP_MPM_WANT_PROCESS_CHILD_STATUS +#define AP_MPM_WANT_SET_PIDFILE +#define AP_MPM_WANT_SET_SCOREBOARD +#define AP_MPM_WANT_SET_LOCKFILE +#define AP_MPM_WANT_SET_MAX_REQUESTS +#define AP_MPM_WANT_SET_COREDUMPDIR +#define AP_MPM_WANT_SET_ACCEPT_LOCK_MECH +#define AP_MPM_WANT_SIGNAL_SERVER +#define AP_MPM_WANT_SET_MAX_MEM_FREE +#define AP_MPM_WANT_FATAL_SIGNAL_HANDLER +#define AP_MPM_DISABLE_NAGLE_ACCEPTED_SOCK + +#define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) +#define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0) +#define MPM_ACCEPT_FUNC unixd_accept + +extern int ap_threads_per_child; +extern int ap_max_daemons_limit; +extern server_rec *ap_server_conf; +extern char ap_coredump_dir[MAX_STRING_LEN]; + +#endif /* APACHE_MPM_WORKER_H */ diff --git a/rubbos/app/apache2/include/mpm_common.h b/rubbos/app/apache2/include/mpm_common.h new file mode 100644 index 00000000..68ead5f7 --- /dev/null +++ b/rubbos/app/apache2/include/mpm_common.h @@ -0,0 +1,298 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* The purpose of this file is to store the code that MOST mpm's will need + * this does not mean a function only goes into this file if every MPM needs + * it. It means that if a function is needed by more than one MPM, and + * future maintenance would be served by making the code common, then the + * function belongs here. + * + * This is going in src/main because it is not platform specific, it is + * specific to multi-process servers, but NOT to Unix. Which is why it + * does not belong in src/os/unix + */ + +#ifndef APACHE_MPM_COMMON_H +#define APACHE_MPM_COMMON_H + +#include "ap_config.h" + +#if APR_HAVE_NETINET_TCP_H +#include /* for TCP_NODELAY */ +#endif + +#include "mpm.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Multi-Processing Modules functions + */ + +/* The maximum length of the queue of pending connections, as defined + * by listen(2). Under some systems, it should be increased if you + * are experiencing a heavy TCP SYN flood attack. + * + * It defaults to 511 instead of 512 because some systems store it + * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is + * 255 when truncated. + */ +#ifndef DEFAULT_LISTENBACKLOG +#define DEFAULT_LISTENBACKLOG 511 +#endif + +/** + * Make sure all child processes that have been spawned by the parent process + * have died. This includes process registered as "other_children". + * @warning This is only defined if the MPM defines + * AP_MPM_WANT_RECLAIM_CHILD_PROCESSES + * @param terminate Either 1 or 0. If 1, send the child processes SIGTERM + * each time through the loop. If 0, give the process time to die + * on its own before signalling it. + * @tip This function requires that some macros are defined by the MPM:
+ *  MPM_CHILD_PID -- Get the pid from the specified spot in the scoreboard
+ *  MPM_NOTE_CHILD_KILLED -- Note the child died in the scoreboard
+ * 
+ * @tip The MPM child processes which are reclaimed are those listed + * in the scoreboard as well as those currently registered via + * ap_register_extra_mpm_process(). + */ +#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES +void ap_reclaim_child_processes(int terminate); +#endif + +/** + * Tell ap_reclaim_child_processes() about an MPM child process which has no + * entry in the scoreboard. + * @warning This is only defined if the MPM defines + * AP_MPM_WANT_RECLAIM_CHILD_PROCESSES + * @param pid The process id of an MPM child process which should be + * reclaimed when ap_reclaim_child_processes() is called. + * @tip If an extra MPM child process terminates prior to calling + * ap_reclaim_child_processes(), remove it from the list of such processes + * by calling ap_unregister_extra_mpm_process(). + */ +#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES +void ap_register_extra_mpm_process(pid_t pid); +#endif + +/** + * Unregister an MPM child process which was previously registered by a + * call to ap_register_extra_mpm_process(). + * @warning This is only defined if the MPM defines + * AP_MPM_WANT_RECLAIM_CHILD_PROCESSES + * @param pid The process id of an MPM child process which no longer needs to + * be reclaimed. + * @return 1 if the process was found and removed, 0 otherwise + */ +#ifdef AP_MPM_WANT_RECLAIM_CHILD_PROCESSES +int ap_unregister_extra_mpm_process(pid_t pid); +#endif + +/** + * Determine if any child process has died. If no child process died, then + * this process sleeps for the amount of time specified by the MPM defined + * macro SCOREBOARD_MAINTENANCE_INTERVAL. + * @param status The return code if a process has died + * @param ret The process id of the process that died + * @param p The pool to allocate out of + */ +#ifdef AP_MPM_WANT_WAIT_OR_TIMEOUT +void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret, + apr_pool_t *p); +#endif + +/** + * Log why a child died to the error log, if the child died without the + * parent signalling it. + * @param pid The child that has died + * @param status The status returned from ap_wait_or_timeout + * @return 0 on success, APEXIT_CHILDFATAL if MPM should terminate + */ +#ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS +int ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status); +#endif + +#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF) +/** + * Turn off the nagle algorithm for the specified socket. The nagle algorithm + * says that we should delay sending partial packets in the hopes of getting + * more data. There are bad interactions between persistent connections and + * Nagle's algorithm that have severe performance penalties. + * @param s The socket to disable nagle for. + */ +void ap_sock_disable_nagle(apr_socket_t *s); +#else +#define ap_sock_disable_nagle(s) /* NOOP */ +#endif + +#ifdef HAVE_GETPWNAM +/** + * Convert a username to a numeric ID + * @param name The name to convert + * @return The user id corresponding to a name + * @deffunc uid_t ap_uname2id(const char *name) + */ +AP_DECLARE(uid_t) ap_uname2id(const char *name); +#endif + +#ifdef HAVE_GETGRNAM +/** + * Convert a group name to a numeric ID + * @param name The name to convert + * @return The group id corresponding to a name + * @deffunc gid_t ap_gname2id(const char *name) + */ +AP_DECLARE(gid_t) ap_gname2id(const char *name); +#endif + +#define AP_MPM_HARD_LIMITS_FILE APACHE_MPM_DIR "/mpm_default.h" + +#ifdef AP_MPM_USES_POD + +typedef struct ap_pod_t ap_pod_t; + +struct ap_pod_t { + apr_file_t *pod_in; + apr_file_t *pod_out; + apr_pool_t *p; + apr_sockaddr_t *sa; +}; + +/** + * Open the pipe-of-death. The pipe of death is used to tell all child + * processes that it is time to die gracefully. + * @param p The pool to use for allocating the pipe + */ +AP_DECLARE(apr_status_t) ap_mpm_pod_open(apr_pool_t *p, ap_pod_t **pod); + +/** + * Check the pipe to determine if the process has been signalled to die. + */ +AP_DECLARE(apr_status_t) ap_mpm_pod_check(ap_pod_t *pod); + +/** + * Close the pipe-of-death + */ +AP_DECLARE(apr_status_t) ap_mpm_pod_close(ap_pod_t *pod); + +/** + * Write data to the pipe-of-death, signalling that one child process + * should die. + * @param p The pool to use when allocating any required structures. + */ +AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod); + +/** + * Write data to the pipe-of-death, signalling that all child process + * should die. + * @param p The pool to use when allocating any required structures. + * @param num The number of child processes to kill + */ +AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num); +#endif + +/* + * These data members are common to all mpms. Each new mpm + * should either use the appropriate ap_mpm_set_* function + * in their command table or create their own for custom or + * OS specific needs. These should work for most. + */ + +/** + * The maximum number of requests each child thread or + * process handles before dying off + */ +#ifdef AP_MPM_WANT_SET_MAX_REQUESTS +extern int ap_max_requests_per_child; +const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +/** + * The filename used to store the process id. + */ +#ifdef AP_MPM_WANT_SET_PIDFILE +extern const char *ap_pid_fname; +const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +/** + * The name of lockfile used when Apache needs to lock the accept() call. + */ +#ifdef AP_MPM_WANT_SET_LOCKFILE +extern const char *ap_lock_fname; +const char *ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +/** + * The system mutex implementation to use for the accept mutex. + */ +#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH +extern apr_lockmech_e ap_accept_lock_mech; +extern const char ap_valid_accept_mutex_string[]; +const char *ap_mpm_set_accept_lock_mech(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +/* + * Set the scorboard file. + */ +#ifdef AP_MPM_WANT_SET_SCOREBOARD +const char *ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +/* + * The directory that the server changes directory to dump core. + */ +#ifdef AP_MPM_WANT_SET_COREDUMPDIR +extern char ap_coredump_dir[MAX_STRING_LEN]; +extern int ap_coredumpdir_configured; +const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +#ifdef AP_MPM_WANT_SIGNAL_SERVER +int ap_signal_server(int *, apr_pool_t *); +void ap_mpm_rewrite_args(process_rec *); +#endif + +#ifdef AP_MPM_WANT_SET_MAX_MEM_FREE +extern apr_uint32_t ap_max_mem_free; +extern const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +#ifdef AP_MPM_WANT_FATAL_SIGNAL_HANDLER +extern apr_status_t ap_fatal_signal_setup(server_rec *s, apr_pool_t *pconf); +extern apr_status_t ap_fatal_signal_child_setup(server_rec *s); +#endif + +#if AP_ENABLE_EXCEPTION_HOOK +extern const char *ap_mpm_set_exception_hook(cmd_parms *cmd, void *dummy, + const char *arg); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_MPM_COMMON_H */ diff --git a/rubbos/app/apache2/include/mpm_default.h b/rubbos/app/apache2/include/mpm_default.h new file mode 100644 index 00000000..d5a33989 --- /dev/null +++ b/rubbos/app/apache2/include/mpm_default.h @@ -0,0 +1,69 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_MPM_DEFAULT_H +#define APACHE_MPM_DEFAULT_H + +/* Number of servers to spawn off by default --- also, if fewer than + * this free when the caretaker checks, it will spawn more. + */ +#ifndef DEFAULT_START_DAEMON +#define DEFAULT_START_DAEMON 3 +#endif + +/* Maximum number of *free* server processes --- more than this, and + * they will die off. + */ + +#ifndef DEFAULT_MAX_FREE_DAEMON +#define DEFAULT_MAX_FREE_DAEMON 10 +#endif + +/* Minimum --- fewer than this, and more will be created */ + +#ifndef DEFAULT_MIN_FREE_DAEMON +#define DEFAULT_MIN_FREE_DAEMON 3 +#endif + +#ifndef DEFAULT_THREADS_PER_CHILD +#define DEFAULT_THREADS_PER_CHILD 25 +#endif + +/* File used for accept locking, when we use a file */ +#ifndef DEFAULT_LOCKFILE +#define DEFAULT_LOCKFILE DEFAULT_REL_RUNTIMEDIR "/accept.lock" +#endif + +/* Where the main/parent process's pid is logged */ +#ifndef DEFAULT_PIDLOG +#define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid" +#endif + +/* + * Interval, in microseconds, between scoreboard maintenance. + */ +#ifndef SCOREBOARD_MAINTENANCE_INTERVAL +#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000 +#endif + +/* Number of requests to try to handle in a single process. If <= 0, + * the children don't die off. + */ +#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD +#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000 +#endif + +#endif /* AP_MPM_DEFAULT_H */ diff --git a/rubbos/app/apache2/include/os.h b/rubbos/app/apache2/include/os.h new file mode 100644 index 00000000..59f1a439 --- /dev/null +++ b/rubbos/app/apache2/include/os.h @@ -0,0 +1,27 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_OS_H +#define APACHE_OS_H + +#include "apr.h" +#include "ap_config.h" + +#ifndef PLATFORM +#define PLATFORM "Unix" +#endif + +#endif /* !APACHE_OS_H */ diff --git a/rubbos/app/apache2/include/pcre.h b/rubbos/app/apache2/include/pcre.h new file mode 100644 index 00000000..d6c23939 --- /dev/null +++ b/rubbos/app/apache2/include/pcre.h @@ -0,0 +1,113 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* Copyright (c) 1997-2001 University of Cambridge */ + +#ifndef _PCRE_H +#define _PCRE_H + +/* The file pcre.h is build by "configure". Do not edit it; instead +make changes to pcre.in. */ + +#define PCRE_MAJOR 3 +#define PCRE_MINOR 9 +#define PCRE_DATE 02-Jan-2002 + +/* Win32 uses DLL by default */ + +#ifdef _WIN32 +# ifdef STATIC +# define PCRE_DL_IMPORT +# else +# define PCRE_DL_IMPORT __declspec(dllimport) +# endif +#else +# define PCRE_DL_IMPORT +#endif + +/* Have to include stdlib.h in order to ensure that size_t is defined; +it is needed here for malloc. */ + +#include + +/* Allow for C++ users */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Options */ + +#define PCRE_CASELESS 0x0001 +#define PCRE_MULTILINE 0x0002 +#define PCRE_DOTALL 0x0004 +#define PCRE_EXTENDED 0x0008 +#define PCRE_ANCHORED 0x0010 +#define PCRE_DOLLAR_ENDONLY 0x0020 +#define PCRE_EXTRA 0x0040 +#define PCRE_NOTBOL 0x0080 +#define PCRE_NOTEOL 0x0100 +#define PCRE_UNGREEDY 0x0200 +#define PCRE_NOTEMPTY 0x0400 +#define PCRE_UTF8 0x0800 + +/* Exec-time and get-time error codes */ + +#define PCRE_ERROR_NOMATCH (-1) +#define PCRE_ERROR_NULL (-2) +#define PCRE_ERROR_BADOPTION (-3) +#define PCRE_ERROR_BADMAGIC (-4) +#define PCRE_ERROR_UNKNOWN_NODE (-5) +#define PCRE_ERROR_NOMEMORY (-6) +#define PCRE_ERROR_NOSUBSTRING (-7) + +/* Request types for pcre_fullinfo() */ + +#define PCRE_INFO_OPTIONS 0 +#define PCRE_INFO_SIZE 1 +#define PCRE_INFO_CAPTURECOUNT 2 +#define PCRE_INFO_BACKREFMAX 3 +#define PCRE_INFO_FIRSTCHAR 4 +#define PCRE_INFO_FIRSTTABLE 5 +#define PCRE_INFO_LASTLITERAL 6 + +/* Types */ + +struct real_pcre; /* declaration; the definition is private */ +struct real_pcre_extra; /* declaration; the definition is private */ + +typedef struct real_pcre pcre; +typedef struct real_pcre_extra pcre_extra; + +/* Store get and free functions. These can be set to alternative malloc/free +functions if required. Some magic is required for Win32 DLL; it is null on +other OS. */ + +PCRE_DL_IMPORT extern void *(*pcre_malloc)(size_t); +PCRE_DL_IMPORT extern void (*pcre_free)(void *); + +#undef PCRE_DL_IMPORT + +/* Functions */ + +extern pcre *pcre_compile(const char *, int, const char **, int *, + const unsigned char *); +extern int pcre_copy_substring(const char *, int *, int, int, char *, int); +extern int pcre_exec(const pcre *, const pcre_extra *, const char *, + int, int, int, int *, int); +extern void pcre_free_substring(const char *); +extern void pcre_free_substring_list(const char **); +extern int pcre_get_substring(const char *, int *, int, int, const char **); +extern int pcre_get_substring_list(const char *, int *, int, const char ***); +extern int pcre_info(const pcre *, int *, int *); +extern int pcre_fullinfo(const pcre *, const pcre_extra *, int, void *); +extern const unsigned char *pcre_maketables(void); +extern pcre_extra *pcre_study(const pcre *, int, const char **); +extern const char *pcre_version(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* End of pcre.h */ diff --git a/rubbos/app/apache2/include/pcreposix.h b/rubbos/app/apache2/include/pcreposix.h new file mode 100644 index 00000000..e70af2de --- /dev/null +++ b/rubbos/app/apache2/include/pcreposix.h @@ -0,0 +1,88 @@ +/************************************************* +* Perl-Compatible Regular Expressions * +*************************************************/ + +/* Copyright (c) 1997-2001 University of Cambridge */ + +#ifndef _PCREPOSIX_H +#define _PCREPOSIX_H + +/* This is the header for the POSIX wrapper interface to the PCRE Perl- +Compatible Regular Expression library. It defines the things POSIX says should +be there. I hope. */ + +/* Have to include stdlib.h in order to ensure that size_t is defined. */ + +#include + +/* Allow for C++ users */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Options defined by POSIX. */ + +#define REG_ICASE 0x01 +#define REG_NEWLINE 0x02 +#define REG_NOTBOL 0x04 +#define REG_NOTEOL 0x08 + +/* These are not used by PCRE, but by defining them we make it easier +to slot PCRE into existing programs that make POSIX calls. */ + +#define REG_EXTENDED 0 +#define REG_NOSUB 0 + +/* Error values. Not all these are relevant or used by the wrapper. */ + +enum { + REG_ASSERT = 1, /* internal error ? */ + REG_BADBR, /* invalid repeat counts in {} */ + REG_BADPAT, /* pattern error */ + REG_BADRPT, /* ? * + invalid */ + REG_EBRACE, /* unbalanced {} */ + REG_EBRACK, /* unbalanced [] */ + REG_ECOLLATE, /* collation error - not relevant */ + REG_ECTYPE, /* bad class */ + REG_EESCAPE, /* bad escape sequence */ + REG_EMPTY, /* empty expression */ + REG_EPAREN, /* unbalanced () */ + REG_ERANGE, /* bad range inside [] */ + REG_ESIZE, /* expression too big */ + REG_ESPACE, /* failed to get memory */ + REG_ESUBREG, /* bad back reference */ + REG_INVARG, /* bad argument */ + REG_NOMATCH /* match failed */ +}; + + +/* The structure representing a compiled regular expression. */ + +typedef struct { + void *re_pcre; + size_t re_nsub; + size_t re_erroffset; +} regex_t; + +/* The structure in which a captured offset is returned. */ + +typedef int regoff_t; + +typedef struct { + regoff_t rm_so; + regoff_t rm_eo; +} regmatch_t; + +/* The functions */ + +extern int regcomp(regex_t *, const char *, int); +extern int regexec(regex_t *, const char *, size_t, regmatch_t *, int); +extern size_t regerror(int, const regex_t *, char *, size_t); +extern void regfree(regex_t *); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* End of pcreposix.h */ diff --git a/rubbos/app/apache2/include/pod.h b/rubbos/app/apache2/include/pod.h new file mode 100644 index 00000000..21651e6f --- /dev/null +++ b/rubbos/app/apache2/include/pod.h @@ -0,0 +1,50 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "apr.h" +#include "apr_strings.h" +#define APR_WANT_STRFUNC +#include "apr_want.h" + +#include "httpd.h" +#include "http_config.h" +#include "http_log.h" +#include "http_main.h" +#include "mpm.h" +#include "mpm_common.h" +#include "ap_mpm.h" +#include "ap_listen.h" +#include "mpm_default.h" + +#define RESTART_CHAR '$' +#define GRACEFUL_CHAR '!' + +#define AP_RESTART 0 +#define AP_GRACEFUL 1 + +typedef struct ap_pod_t ap_pod_t; + +struct ap_pod_t { + apr_file_t *pod_in; + apr_file_t *pod_out; + apr_pool_t *p; +}; + +AP_DECLARE(apr_status_t) ap_mpm_pod_open(apr_pool_t *p, ap_pod_t **pod); +AP_DECLARE(int) ap_mpm_pod_check(ap_pod_t *pod); +AP_DECLARE(apr_status_t) ap_mpm_pod_close(ap_pod_t *pod); +AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod, int graceful); +AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num, int graceful); diff --git a/rubbos/app/apache2/include/rfc1413.h b/rubbos/app/apache2/include/rfc1413.h new file mode 100644 index 00000000..a4ffdf11 --- /dev/null +++ b/rubbos/app/apache2/include/rfc1413.h @@ -0,0 +1,42 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_RFC1413_H +#define APACHE_RFC1413_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package RFC1413 package + */ + +/** + * Retrieve the remote user name, given socket structures. This implements + * RFC1413, which involves querying the client's identd or auth daemon. + * @param conn The current connection + * @param srv The current server + * @return The remote user name + * @deffunc char *ap_rfc1413(conn_rec *conn, server_rec *srv) + */ +extern char *ap_rfc1413(conn_rec *conn, server_rec *srv); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_RFC1413_H */ diff --git a/rubbos/app/apache2/include/scoreboard.h b/rubbos/app/apache2/include/scoreboard.h new file mode 100644 index 00000000..6ca18582 --- /dev/null +++ b/rubbos/app/apache2/include/scoreboard.h @@ -0,0 +1,197 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_SCOREBOARD_H +#define APACHE_SCOREBOARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_SYS_TIMES_H +#include +#include +#elif defined(TPF) +#include +#endif + +#include "ap_config.h" +#include "apr_hooks.h" +#include "apr_thread_proc.h" +#include "apr_portable.h" +#include "apr_shm.h" + +/* Scoreboard file, if there is one */ +#ifndef DEFAULT_SCOREBOARD +#define DEFAULT_SCOREBOARD "logs/apache_runtime_status" +#endif + +/* Scoreboard info on a process is, for now, kept very brief --- + * just status value and pid (the latter so that the caretaker process + * can properly update the scoreboard when a process dies). We may want + * to eventually add a separate set of long_score structures which would + * give, for each process, the number of requests serviced, and info on + * the current, or most recent, request. + * + * Status values: + */ + +#define SERVER_DEAD 0 +#define SERVER_STARTING 1 /* Server Starting up */ +#define SERVER_READY 2 /* Waiting for connection (or accept() lock) */ +#define SERVER_BUSY_READ 3 /* Reading a client request */ +#define SERVER_BUSY_WRITE 4 /* Processing a client request */ +#define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */ +#define SERVER_BUSY_LOG 6 /* Logging the request */ +#define SERVER_BUSY_DNS 7 /* Looking up a hostname */ +#define SERVER_CLOSING 8 /* Closing the connection */ +#define SERVER_GRACEFUL 9 /* server is gracefully finishing request */ +#define SERVER_IDLE_KILL 10 /* Server is cleaning up idle children. */ +#define SERVER_NUM_STATUS 11 /* number of status settings */ + +/* Type used for generation indicies. Startup and every restart cause a + * new generation of children to be spawned. Children within the same + * generation share the same configuration information -- pointers to stuff + * created at config time in the parent are valid across children. However, + * this can't work effectively with non-forked architectures. So while the + * arrays in the scoreboard never change between the parent and forked + * children, so they do not require shm storage, the contents of the shm + * may contain no pointers. + */ +typedef int ap_generation_t; + +/* Is the scoreboard shared between processes or not? + * Set by the MPM when the scoreboard is created. + */ +typedef enum { + SB_NOT_SHARED = 1, + SB_SHARED = 2 +} ap_scoreboard_e; + +#define SB_WORKING 0 /* The server is busy and the child is useful. */ +#define SB_IDLE_DIE 1 /* The server is idle and the child is superfluous. */ + /* The child should check for this and exit gracefully. */ + +/* stuff which is worker specific */ +/***********************WARNING***************************************/ +/* These are things that are used by mod_status. Do not put anything */ +/* in here that you cannot live without. This structure will not */ +/* be available if mod_status is not loaded. */ +/*********************************************************************/ +typedef struct worker_score worker_score; + +struct worker_score { + int thread_num; +#if APR_HAS_THREADS + apr_os_thread_t tid; +#endif + unsigned char status; + unsigned long access_count; + apr_off_t bytes_served; + unsigned long my_access_count; + apr_off_t my_bytes_served; + apr_off_t conn_bytes; + unsigned short conn_count; + apr_time_t start_time; + apr_time_t stop_time; +#ifdef HAVE_TIMES + struct tms times; +#endif + apr_time_t last_used; + char client[32]; /* Keep 'em small... */ + char request[64]; /* We just want an idea... */ + char vhost[32]; /* What virtual host is being accessed? */ +}; + +typedef struct { + int server_limit; + int thread_limit; + ap_scoreboard_e sb_type; + ap_generation_t running_generation; /* the generation of children which + * should still be serving requests. */ + apr_time_t restart_time; +} global_score; + +/* stuff which the parent generally writes and the children rarely read */ +typedef struct process_score process_score; +struct process_score{ + pid_t pid; + ap_generation_t generation; /* generation of this child */ + ap_scoreboard_e sb_type; + int quiescing; /* the process whose pid is stored above is + * going down gracefully + */ +}; + +/* Scoreboard is now in 'local' memory, since it isn't updated once created, + * even in forked architectures. Child created-processes (non-fork) will + * set up these indicies into the (possibly relocated) shmem records. + */ +typedef struct { + global_score *global; + process_score *parent; + worker_score **servers; +} scoreboard; + +typedef struct ap_sb_handle_t ap_sb_handle_t; + +AP_DECLARE(int) ap_exists_scoreboard_image(void); +AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sbh, request_rec *r); + +int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e t); +apr_status_t ap_reopen_scoreboard(apr_pool_t *p, apr_shm_t **shm, int detached); +void ap_init_scoreboard(void *shared_score); +AP_DECLARE(int) ap_calc_scoreboard_size(void); +apr_status_t ap_cleanup_scoreboard(void *d); + +AP_DECLARE(void) ap_create_sb_handle(ap_sb_handle_t **new_sbh, apr_pool_t *p, + int child_num, int thread_num); + +AP_DECLARE(int) find_child_by_pid(apr_proc_t *pid); +AP_DECLARE(int) ap_update_child_status(ap_sb_handle_t *sbh, int status, request_rec *r); +AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num, int thread_num, + int status, request_rec *r); +void ap_time_process_request(ap_sb_handle_t *sbh, int status); + +AP_DECLARE(worker_score *) ap_get_scoreboard_worker(int x, int y); +AP_DECLARE(process_score *) ap_get_scoreboard_process(int x); +AP_DECLARE(global_score *) ap_get_scoreboard_global(void); + +AP_DECLARE_DATA extern scoreboard *ap_scoreboard_image; +AP_DECLARE_DATA extern const char *ap_scoreboard_fname; +AP_DECLARE_DATA extern int ap_extended_status; + +AP_DECLARE_DATA extern ap_generation_t volatile ap_my_generation; + +/* Hooks */ +/** + * Hook for post scoreboard creation, pre mpm. + * @param p Apache pool to allocate from. + * @param sb_type + * @ingroup hooks + * @return OK or DECLINE on success; anything else is a error + */ +AP_DECLARE_HOOK(int, pre_mpm, (apr_pool_t *p, ap_scoreboard_e sb_type)) + +/* for time_process_request() in http_main.c */ +#define START_PREQUEST 1 +#define STOP_PREQUEST 2 + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_SCOREBOARD_H */ diff --git a/rubbos/app/apache2/include/ssl_expr.h b/rubbos/app/apache2/include/ssl_expr.h new file mode 100644 index 00000000..20b9fbdb --- /dev/null +++ b/rubbos/app/apache2/include/ssl_expr.h @@ -0,0 +1,104 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* _ _ + * _ __ ___ ___ __| | ___ ___| | mod_ssl + * | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL + * | | | | | | (_) | (_| | \__ \__ \ | + * |_| |_| |_|\___/ \__,_|___|___/___/_| + * |_____| + * ssl_expr.h + * Expression Handling (Header) + */ + /* ``May all your PUSHes be POPed.'' */ + +#ifndef __SSL_EXPR_H__ +#define __SSL_EXPR_H__ + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE !FALSE +#endif + +#ifndef YY_NULL +#define YY_NULL 0 +#endif + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#ifndef BOOL +#define BOOL unsigned int +#endif + +#ifndef NULL +#define NULL (void *)0 +#endif + +#ifndef NUL +#define NUL '\0' +#endif + +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif + +typedef enum { + op_NOP, op_ListElement, + op_True, op_False, op_Not, op_Or, op_And, op_Comp, + op_EQ, op_NE, op_LT, op_LE, op_GT, op_GE, op_IN, op_REG, op_NRE, + op_Digit, op_String, op_Regex, op_Var, op_Func +} ssl_expr_node_op; + +typedef struct { + ssl_expr_node_op node_op; + void *node_arg1; + void *node_arg2; + apr_pool_t *p; +} ssl_expr_node; + +typedef ssl_expr_node ssl_expr; + +typedef struct { + apr_pool_t *pool; + char *inputbuf; + int inputlen; + char *inputptr; + ssl_expr *expr; +} ssl_expr_info_type; + +extern ssl_expr_info_type ssl_expr_info; +extern char *ssl_expr_error; + +#define yylval ssl_expr_yylval +#define yyerror ssl_expr_yyerror +#define yyinput ssl_expr_yyinput + +extern int ssl_expr_yyparse(void); +extern int ssl_expr_yyerror(char *); +extern int ssl_expr_yylex(void); + +extern ssl_expr *ssl_expr_comp(apr_pool_t *, char *); +extern int ssl_expr_exec(request_rec *, ssl_expr *); +extern char *ssl_expr_get_error(void); +extern ssl_expr *ssl_expr_make(ssl_expr_node_op, void *, void *); +extern BOOL ssl_expr_eval(request_rec *, ssl_expr *); + +#endif /* __SSL_EXPR_H__ */ diff --git a/rubbos/app/apache2/include/ssl_expr_parse.h b/rubbos/app/apache2/include/ssl_expr_parse.h new file mode 100644 index 00000000..5378e287 --- /dev/null +++ b/rubbos/app/apache2/include/ssl_expr_parse.h @@ -0,0 +1,27 @@ +typedef union { + char *cpVal; + ssl_expr *exVal; +} YYSTYPE; +#define T_TRUE 257 +#define T_FALSE 258 +#define T_DIGIT 259 +#define T_ID 260 +#define T_STRING 261 +#define T_REGEX 262 +#define T_REGEX_I 263 +#define T_FUNC_FILE 264 +#define T_OP_EQ 265 +#define T_OP_NE 266 +#define T_OP_LT 267 +#define T_OP_LE 268 +#define T_OP_GT 269 +#define T_OP_GE 270 +#define T_OP_REG 271 +#define T_OP_NRE 272 +#define T_OP_IN 273 +#define T_OP_OR 274 +#define T_OP_AND 275 +#define T_OP_NOT 276 + + +extern YYSTYPE ssl_expr_yylval; diff --git a/rubbos/app/apache2/include/ssl_toolkit_compat.h b/rubbos/app/apache2/include/ssl_toolkit_compat.h new file mode 100644 index 00000000..72772150 --- /dev/null +++ b/rubbos/app/apache2/include/ssl_toolkit_compat.h @@ -0,0 +1,239 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SSL_TOOLKIT_COMPAT_H +#define SSL_TOOLKIT_COMPAT_H + +/* + * this header file provides a compatiblity layer + * between OpenSSL and RSA sslc + */ + +#ifdef OPENSSL_VERSION_NUMBER + +/* + * rsa sslc uses incomplete types for most structures + * so we macroize for OpenSSL those which cannot be dereferenced + * using the same sames as the sslc functions + */ + +#define EVP_PKEY_key_type(k) (EVP_PKEY_type(k->type)) + +#define X509_NAME_get_entries(xs) (xs->entries) +#define X509_REVOKED_get_serialNumber(xs) (xs->serialNumber) + +#define X509_get_signature_algorithm(xs) (xs->cert_info->signature->algorithm) +#define X509_get_key_algorithm(xs) (xs->cert_info->key->algor->algorithm) + +#define X509_NAME_ENTRY_get_data_ptr(xs) (xs->value->data) +#define X509_NAME_ENTRY_get_data_len(xs) (xs->value->length) + +#define SSL_CTX_get_extra_certs(ctx) (ctx->extra_certs) +#define SSL_CTX_set_extra_certs(ctx,value) {ctx->extra_certs = value;} + +#define SSL_CIPHER_get_name(s) (s->name) +#define SSL_CIPHER_get_valid(s) (s->valid) + +#define SSL_SESSION_get_session_id(s) (s->session_id) +#define SSL_SESSION_get_session_id_length(s) (s->session_id_length) + +/* + * Support for retrieving/overriding states + */ +#ifndef SSL_get_state +#define SSL_get_state(ssl) SSL_state(ssl) +#endif + +#define SSL_set_state(ssl,val) (ssl)->state = val + +#define MODSSL_BIO_CB_ARG_TYPE const char +#define MODSSL_CRYPTO_CB_ARG_TYPE const char +#if (OPENSSL_VERSION_NUMBER < 0x00907000) +#define MODSSL_INFO_CB_ARG_TYPE SSL* +#else +#define MODSSL_INFO_CB_ARG_TYPE const SSL* +#endif +#define MODSSL_CLIENT_CERT_CB_ARG_TYPE X509 +#define MODSSL_PCHAR_CAST + +/* ...shifting sands of openssl... */ +#if (OPENSSL_VERSION_NUMBER >= 0x0090707f) +# define MODSSL_D2I_SSL_SESSION_CONST const +#else +# define MODSSL_D2I_SSL_SESSION_CONST +#endif + +#if (OPENSSL_VERSION_NUMBER >= 0x00908000) +# define MODSSL_D2I_PrivateKey_CONST const +# define MODSSL_D2I_X509_CONST const +#else +# define MODSSL_D2I_PrivateKey_CONST +# define MODSSL_D2I_X509_CONST +#endif + +#define modssl_X509_verify_cert X509_verify_cert + +typedef int (modssl_read_bio_cb_fn)(char*,int,int,void*); + +#if (OPENSSL_VERSION_NUMBER < 0x00904000) +#define modssl_PEM_read_bio_X509(b, x, cb, arg) PEM_read_bio_X509(b, x, cb) +#else +#define modssl_PEM_read_bio_X509(b, x, cb, arg) PEM_read_bio_X509(b, x, cb, arg) +#endif + +#define modssl_PEM_X509_INFO_read_bio PEM_X509_INFO_read_bio + +#define modssl_PEM_read_bio_PrivateKey PEM_read_bio_PrivateKey + +#define modssl_set_cipher_list SSL_set_cipher_list + +#define modssl_free OPENSSL_free + +#define EVP_PKEY_reference_inc(pkey) \ + CRYPTO_add(&((pkey)->references), +1, CRYPTO_LOCK_X509_PKEY) + +#define X509_reference_inc(cert) \ + CRYPTO_add(&((cert)->references), +1, CRYPTO_LOCK_X509) + +#define HAVE_SSL_RAND_EGD /* since 9.5.1 */ + +#ifdef HAVE_SSL_X509V3_H +#define HAVE_SSL_X509V3_EXT_d2i +#endif + +#ifndef PEM_F_DEF_CALLBACK +#ifdef PEM_F_PEM_DEF_CALLBACK +/* In OpenSSL 0.9.8 PEM_F_DEF_CALLBACK was renamed */ +#define PEM_F_DEF_CALLBACK PEM_F_PEM_DEF_CALLBACK +#endif +#endif + +#elif defined (SSLC_VERSION_NUMBER) /* RSA */ + +/* sslc does not support this function, OpenSSL has since 9.5.1 */ +#define RAND_status() 1 + +/* sslc names this function a bit differently */ +#define CRYPTO_num_locks() CRYPTO_get_num_locks() + +#ifndef STACK_OF +#define STACK_OF(type) STACK +#endif + +#define MODSSL_BIO_CB_ARG_TYPE char +#define MODSSL_CRYPTO_CB_ARG_TYPE char +#define MODSSL_INFO_CB_ARG_TYPE SSL* +#define MODSSL_CLIENT_CERT_CB_ARG_TYPE void +#define MODSSL_PCHAR_CAST (char *) +#define MODSSL_D2I_SSL_SESSION_CONST +#define MODSSL_D2I_PrivateKey_CONST +#define MODSSL_D2I_X509_CONST + +typedef int (modssl_read_bio_cb_fn)(char*,int,int); + +#define modssl_X509_verify_cert(c) X509_verify_cert(c, NULL) + +#define modssl_PEM_read_bio_X509(b, x, cb, arg) \ + PEM_read_bio_X509(b, x, cb) + +#define modssl_PEM_X509_INFO_read_bio(b, x, cb, arg)\ + PEM_X509_INFO_read_bio(b, x, cb) + +#define modssl_PEM_read_bio_PrivateKey(b, k, cb, arg) \ + PEM_read_bio_PrivateKey(b, k, cb) + +#ifndef HAVE_SSL_SET_STATE +#define SSL_set_state(ssl, state) /* XXX: should throw an error */ +#endif + +#define modssl_set_cipher_list(ssl, l) \ + SSL_set_cipher_list(ssl, (char *)l) + +#define modssl_free free + +#ifndef PEM_F_DEF_CALLBACK +#define PEM_F_DEF_CALLBACK PEM_F_DEF_CB +#endif + +#if SSLC_VERSION_NUMBER < 0x2000 + +#define X509_STORE_CTX_set_depth(st, d) +#define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate) +#define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate) +#define X509_CRL_get_REVOKED(x) ((x)->crl->revoked) +#define X509_REVOKED_get_serialNumber(xs) (xs->serialNumber) + +#define modssl_set_verify(ssl, verify, cb) \ + SSL_set_verify(ssl, verify) + +#define NO_SSL_X509V3_H + +#else /* SSLC_VERSION_NUMBER >= 0x2000 */ + +#define CRYPTO_malloc_init R_malloc_init + +#define EVP_cleanup() + +#endif /* SSLC_VERSION_NUMBER >= 0x2000 */ + +typedef void (*modssl_popfree_fn)(char *data); + +#define sk_SSL_CIPHER_dup sk_dup +#define sk_SSL_CIPHER_find(st, data) sk_find(st, (void *)data) +#define sk_SSL_CIPHER_free sk_free +#define sk_SSL_CIPHER_num sk_num +#define sk_SSL_CIPHER_value (SSL_CIPHER *)sk_value +#define sk_X509_num sk_num +#define sk_X509_push sk_push +#define sk_X509_pop_free(st, free) sk_pop_free((STACK*)(st), (modssl_popfree_fn)(free)) +#define sk_X509_value (X509 *)sk_value +#define sk_X509_INFO_free sk_free +#define sk_X509_INFO_pop_free(st, free) sk_pop_free((STACK*)(st), (modssl_popfree_fn)(free)) +#define sk_X509_INFO_num sk_num +#define sk_X509_INFO_new_null sk_new_null +#define sk_X509_INFO_value (X509_INFO *)sk_value +#define sk_X509_NAME_find(st, data) sk_find(st, (void *)data) +#define sk_X509_NAME_free sk_free +#define sk_X509_NAME_new sk_new +#define sk_X509_NAME_num sk_num +#define sk_X509_NAME_push(st, data) sk_push(st, (void *)data) +#define sk_X509_NAME_value (X509_NAME *)sk_value +#define sk_X509_NAME_ENTRY_num sk_num +#define sk_X509_NAME_ENTRY_value (X509_NAME_ENTRY *)sk_value +#define sk_X509_NAME_set_cmp_func sk_set_cmp_func +#define sk_X509_REVOKED_num sk_num +#define sk_X509_REVOKED_value (X509_REVOKED *)sk_value + +#else /* ! OPENSSL_VERSION_NUMBER && ! SSLC_VERSION_NUMBER */ + +#error "Unrecognized SSL Toolkit!" + +#endif /* ! OPENSSL_VERSION_NUMBER && ! SSLC_VERSION_NUMBER */ + +#ifndef modssl_set_verify +#define modssl_set_verify(ssl, verify, cb) \ + SSL_set_verify(ssl, verify, cb) +#endif + +#ifndef NO_SSL_X509V3_H +#define HAVE_SSL_X509V3_H +#endif + +#ifndef SSL_SESS_CACHE_NO_INTERNAL +#define SSL_SESS_CACHE_NO_INTERNAL SSL_SESS_CACHE_NO_INTERNAL_LOOKUP +#endif + +#endif /* SSL_TOOLKIT_COMPAT_H */ diff --git a/rubbos/app/apache2/include/ssl_util_ssl.h b/rubbos/app/apache2/include/ssl_util_ssl.h new file mode 100644 index 00000000..d5c48f16 --- /dev/null +++ b/rubbos/app/apache2/include/ssl_util_ssl.h @@ -0,0 +1,93 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* _ _ + * _ __ ___ ___ __| | ___ ___| | mod_ssl + * | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL + * | | | | | | (_) | (_| | \__ \__ \ | + * |_| |_| |_|\___/ \__,_|___|___/___/_| + * |_____| + * ssl_util_ssl.h + * Additional Utility Functions for OpenSSL + */ + +#ifndef __SSL_UTIL_SSL_H__ +#define __SSL_UTIL_SSL_H__ + +/* + * Determine SSL library version number + */ +#define SSL_NIBBLE(x,n) ((x >> (n * 4)) & 0xF) + +#ifdef OPENSSL_VERSION_NUMBER +#define SSL_LIBRARY_VERSION OPENSSL_VERSION_NUMBER +#define SSL_LIBRARY_NAME "OpenSSL" +#define SSL_LIBRARY_TEXT OPENSSL_VERSION_TEXT +#define SSL_LIBRARY_DYNTEXT SSLeay_version(SSLEAY_VERSION) +#elif defined(SSLC_VERSION_NUMBER) +#define SSL_LIBRARY_VERSION SSLC_VERSION_NUMBER +#define SSL_LIBRARY_NAME "SSL-C" +#define SSL_LIBRARY_TEXT { 'S', 'S', 'L', '-', 'C', ' ', \ + '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,3), '.', \ + '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,2), '.', \ + '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,1), '.', \ + '0' + SSL_NIBBLE(SSLC_VERSION_NUMBER,0), 0 } +#define SSL_LIBRARY_DYNTEXT SSLC_library_info(SSLC_INFO_VERSION) +#elif !defined(SSL_LIBRARY_VERSION) +#define SSL_LIBRARY_VERSION 0x0000 +#define SSL_LIBRARY_NAME "OtherSSL" +#define SSL_LIBRARY_TEXT "OtherSSL 0.0.0 00 XXX 0000" +#define SSL_LIBRARY_DYNTEXT "OtherSSL 0.0.0 00 XXX 0000" +#endif + +/* + * Maximum length of a DER encoded session. + * FIXME: There is no define in OpenSSL, but OpenSSL uses 1024*10, + * so this value should be ok. Although we have no warm feeling. + */ +#define SSL_SESSION_MAX_DER 1024*10 + +/* max length for SSL_SESSION_id2sz */ +#define SSL_SESSION_ID_STRING_LEN \ + ((SSL_MAX_SSL_SESSION_ID_LENGTH + 1) * 2) + +/* + * Additional Functions + */ +void SSL_init_app_data2_idx(void); +void *SSL_get_app_data2(SSL *); +void SSL_set_app_data2(SSL *, void *); +X509 *SSL_read_X509(char *, X509 **, modssl_read_bio_cb_fn *); +EVP_PKEY *SSL_read_PrivateKey(char *, EVP_PKEY **, modssl_read_bio_cb_fn *, void *); +int SSL_smart_shutdown(SSL *ssl); +X509_STORE *SSL_X509_STORE_create(char *, char *); +int SSL_X509_STORE_lookup(X509_STORE *, int, X509_NAME *, X509_OBJECT *); +char *SSL_make_ciphersuite(apr_pool_t *, SSL *); +BOOL SSL_X509_isSGC(X509 *); +BOOL SSL_X509_getBC(X509 *, int *, int *); +BOOL SSL_X509_getCN(apr_pool_t *, X509 *, char **); +BOOL SSL_X509_INFO_load_file(apr_pool_t *, STACK_OF(X509_INFO) *, const char *); +BOOL SSL_X509_INFO_load_path(apr_pool_t *, STACK_OF(X509_INFO) *, const char *); +int SSL_CTX_use_certificate_chain(SSL_CTX *, char *, int, modssl_read_bio_cb_fn *); +char *SSL_SESSION_id2sz(unsigned char *, int, char *, int); + +/* util functions for OpenSSL+sslc compat */ +int modssl_session_get_time(SSL_SESSION *session); + +DH *modssl_dh_configure(unsigned char *p, int plen, + unsigned char *g, int glen); + +#endif /* __SSL_UTIL_SSL_H__ */ diff --git a/rubbos/app/apache2/include/ssl_util_table.h b/rubbos/app/apache2/include/ssl_util_table.h new file mode 100644 index 00000000..33438b2f --- /dev/null +++ b/rubbos/app/apache2/include/ssl_util_table.h @@ -0,0 +1,152 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* _ _ + * _ __ ___ ___ __| | ___ ___| | mod_ssl + * | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL + * | | | | | | (_) | (_| | \__ \__ \ | + * |_| |_| |_|\___/ \__,_|___|___/___/_| + * |_____| + * ssl_util_table.h + * High Performance Hash Table Header + */ + +/* + * Generic hash table defines + * Table 4.1.0 July-28-1998 + * + * This library is a generic open hash table with buckets and + * linked lists. It is pretty high performance. Each element + * has a key and a data. The user indexes on the key to find the + * data. + * + * Copyright 1998 by Gray Watson + * + * Permission to use, copy, modify, and distribute this software for any + * purpose and without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, + * and that the name of Gray Watson not be used in advertising or + * publicity pertaining to distribution of the document or software + * without specific, written prior permission. + * + * Gray Watson makes no representations about the suitability of the + * software described herein for any purpose. It is provided "as is" + * without express or implied warranty. + */ + +#ifndef __SSL_UTIL_TABLE_H__ +#define __SSL_UTIL_TABLE_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * To build a "key" in any of the below routines, pass in a pointer to + * the key and its size [i.e. sizeof(int), etc]. With any of the + * "key" or "data" arguments, if their size is < 0, it will do an + * internal strlen of the item and add 1 for the \0. + * + * If you are using firstkey() and nextkey() functions, be careful if, + * after starting your firstkey loop, you use delete or insert, it + * will not crash but may produce interesting results. If you are + * deleting from firstkey to NULL it will work fine. + */ + +/* return types for table functions */ +#define TABLE_ERROR_NONE 1 /* no error from function */ +#define TABLE_ERROR_PNT 2 /* bad table pointer */ +#define TABLE_ERROR_ARG_NULL 3 /* buffer args were null */ +#define TABLE_ERROR_SIZE 4 /* size of data was bad */ +#define TABLE_ERROR_OVERWRITE 5 /* key exists and we cant overwrite */ +#define TABLE_ERROR_NOT_FOUND 6 /* key does not exist */ +#define TABLE_ERROR_ALLOC 7 /* memory allocation error */ +#define TABLE_ERROR_LINEAR 8 /* no linear access started */ +#define TABLE_ERROR_OPEN 9 /* could not open file */ +#define TABLE_ERROR_SEEK 10 /* could not seek to pos in file */ +#define TABLE_ERROR_READ 11 /* could not read from file */ +#define TABLE_ERROR_WRITE 12 /* could not write to file */ +#define TABLE_ERROR_EMPTY 13 /* table is empty */ +#define TABLE_ERROR_NOT_EMPTY 14 /* table contains data */ +#define TABLE_ERROR_ALIGNMENT 15 /* invalid alignment value */ + +/* + * Table flags set with table_attr. + */ + +/* + * Automatically adjust the number of table buckets on the fly. + * Whenever the number of entries gets above some threshold, the + * number of buckets is realloced to a new size and each entry is + * re-hashed. Although this may take some time when it re-hashes, the + * table will perform better over time. + */ +#define TABLE_FLAG_AUTO_ADJUST (1<<0) + +/* + * If the above auto-adjust flag is set, also adjust the number of + * table buckets down as we delete entries. + */ +#define TABLE_FLAG_ADJUST_DOWN (1<<1) + +/* structure to walk through the fields in a linear order */ +typedef struct { + unsigned int tl_magic; /* magic structure to ensure correct init */ + unsigned int tl_bucket_c; /* where in the table buck array we are */ + unsigned int tl_entry_c; /* in the bucket, which entry we are on */ +} table_linear_t; + +typedef int (*table_compare_t)(const void *key1, const int key1_size, + const void *data1, const int data1_size, + const void *key2, const int key2_size, + const void *data2, const int data2_size); + +#ifndef TABLE_PRIVATE +typedef void table_t; +typedef void table_entry_t; +#endif + +/* + * Prototypes + */ +extern table_t *table_alloc(const unsigned int bucket_n, int *error_p, void *(*malloc_f)(void *opt_param, size_t size), void *(*calloc_f)(void *opt_param, size_t number, size_t size), void *(*realloc_f)(void *opt_param, void *ptr, size_t size), void (*free_f)(void *opt_param, void *ptr), void *opt_param); +extern int table_attr(table_t *table_p, const int attr); +extern int table_set_data_alignment(table_t *table_p, const int alignment); +extern int table_clear(table_t *table_p); +extern int table_free(table_t *table_p); +extern int table_insert_kd(table_t *table_p, const void *key_buf, const int key_size, const void *data_buf, const int data_size, void **key_buf_p, void **data_buf_p, const char overwrite_b); +extern int table_insert(table_t *table_p, const void *key_buf, const int key_size, const void *data_buf, const int data_size, void **data_buf_p, const char overwrite_b); +extern int table_retrieve(table_t *table_p, const void *key_buf, const int key_size, void **data_buf_p, int *data_size_p); +extern int table_delete(table_t *table_p, const void *key_buf, const int key_size, void **data_buf_p, int *data_size_p); +extern int table_delete_first(table_t *table_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); +extern int table_info(table_t *table_p, int *num_buckets_p, int *num_entries_p); +extern int table_adjust(table_t *table_p, const int bucket_n); +extern const char *table_strerror(const int error); +extern int table_type_size(void); +extern int table_first(table_t *table_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); +extern int table_next(table_t *table_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); +extern int table_this(table_t *table_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); +extern int table_first_r(table_t *table_p, table_linear_t *linear_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); +extern int table_next_r(table_t *table_p, table_linear_t *linear_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); +extern int table_this_r(table_t *table_p, table_linear_t *linear_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); +extern table_entry_t **table_order(table_t *table_p, table_compare_t compare, int *num_entries_p, int *error_p); +extern int table_entry_info(table_t *table_p, table_entry_t *entry_p, void **key_buf_p, int *key_size_p, void **data_buf_p, int *data_size_p); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __SSL_UTIL_TABLE_H__ */ diff --git a/rubbos/app/apache2/include/unixd.h b/rubbos/app/apache2/include/unixd.h new file mode 100644 index 00000000..c6bec924 --- /dev/null +++ b/rubbos/app/apache2/include/unixd.h @@ -0,0 +1,109 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIXD_H +#define UNIXD_H + +#include "httpd.h" +#include "http_config.h" +#include "ap_listen.h" +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif +#include "apr_hooks.h" +#include "apr_thread_proc.h" +#include "apr_proc_mutex.h" +#include "apr_global_mutex.h" + +#include +#include +#ifdef APR_HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_IPC_H +#include +#endif + +typedef struct { + uid_t uid; + gid_t gid; + int userdir; +} ap_unix_identity_t; + +AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r)) + +/* common stuff that unix MPMs will want */ + +/* Default user name and group name. These may be specified as numbers by + * placing a # before a number */ + +#ifndef DEFAULT_USER +#define DEFAULT_USER "#-1" +#endif +#ifndef DEFAULT_GROUP +#define DEFAULT_GROUP "#-1" +#endif + +typedef struct { + const char *user_name; + uid_t user_id; + gid_t group_id; + int suexec_enabled; +} unixd_config_rec; +AP_DECLARE_DATA extern unixd_config_rec unixd_config; + +AP_DECLARE(int) unixd_setup_child(void); +AP_DECLARE(void) unixd_pre_config(apr_pool_t *ptemp); +AP_DECLARE(const char *) unixd_set_user(cmd_parms *cmd, void *dummy, + const char *arg); +AP_DECLARE(const char *) unixd_set_group(cmd_parms *cmd, void *dummy, + const char *arg); +#if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS) +AP_DECLARE(void) unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit, + const char *arg, const char * arg2, int type); +#endif + +/** + * One of the functions to set mutex permissions should be called in + * the parent process on platforms that switch identity when the + * server is started as root. + * If the child init logic is performed before switching identity + * (e.g., MPM setup for an accept mutex), it should only be called + * for SysV semaphores. Otherwise, it is safe to call it for all + * mutex types. + */ +AP_DECLARE(apr_status_t) unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex); +AP_DECLARE(apr_status_t) unixd_set_global_mutex_perms(apr_global_mutex_t *gmutex); +AP_DECLARE(apr_status_t) unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans); + +#ifdef HAVE_KILLPG +#define unixd_killpg(x, y) (killpg ((x), (y))) +#define ap_os_killpg(x, y) (killpg ((x), (y))) +#else /* HAVE_KILLPG */ +#define unixd_killpg(x, y) (kill (-(x), (y))) +#define ap_os_killpg(x, y) (kill (-(x), (y))) +#endif /* HAVE_KILLPG */ + +#define UNIX_DAEMON_COMMANDS \ +AP_INIT_TAKE1("User", unixd_set_user, NULL, RSRC_CONF, \ + "Effective user id for this server"), \ +AP_INIT_TAKE1("Group", unixd_set_group, NULL, RSRC_CONF, \ + "Effective group id for this server") + +#endif diff --git a/rubbos/app/apache2/include/util_cfgtree.h b/rubbos/app/apache2/include/util_cfgtree.h new file mode 100644 index 00000000..a23330bc --- /dev/null +++ b/rubbos/app/apache2/include/util_cfgtree.h @@ -0,0 +1,79 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_CONFTREE_H +#define AP_CONFTREE_H + +#include "ap_config.h" + +/** + * @package Config Tree Package + */ + +typedef struct ap_directive_t ap_directive_t; + +/** + * Structure used to build the config tree. The config tree only stores + * the directives that will be active in the running server. Directives + * that contain other directions, such as cause a sub-level + * to be created, where the included directives are stored. The closing + * directive () is not stored in the tree. + */ +struct ap_directive_t { + /** The current directive */ + const char *directive; + /** The arguments for the current directive, stored as a space + * separated list */ + const char *args; + /** The next directive node in the tree + * @defvar ap_directive_t *next */ + struct ap_directive_t *next; + /** The first child node of this directive + * @defvar ap_directive_t *first_child */ + struct ap_directive_t *first_child; + /** The parent node of this directive + * @defvar ap_directive_t *parent */ + struct ap_directive_t *parent; + + /** directive's module can store add'l data here */ + void *data; + + /* ### these may go away in the future, but are needed for now */ + /** The name of the file this directive was found in */ + const char *filename; + /** The line number the directive was on */ + int line_num; +}; + +/** + * The root of the configuration tree + * @defvar ap_directive_t *conftree + */ +AP_DECLARE_DATA extern ap_directive_t *ap_conftree; + +/** + * Add a node to the configuration tree. + * @param parent The current parent node. If the added node is a first_child, + then this is changed to the current node + * @param current The current node + * @param toadd The node to add to the tree + * @param child Is the node to add a child node + * @return the added node + */ +ap_directive_t *ap_add_node(ap_directive_t **parent, ap_directive_t *current, + ap_directive_t *toadd, int child); + +#endif diff --git a/rubbos/app/apache2/include/util_charset.h b/rubbos/app/apache2/include/util_charset.h new file mode 100644 index 00000000..449a8700 --- /dev/null +++ b/rubbos/app/apache2/include/util_charset.h @@ -0,0 +1,54 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_CHARSET_H +#define APACHE_UTIL_CHARSET_H + +#ifdef APACHE_XLATE + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package charset conversion + */ +#include "apr_xlate.h" + +/** On EBCDIC machine this is a translation handle used to translate the + * headers from the local machine format to ASCII for network transmission. + * On an ASCII machine this is NULL */ +extern apr_xlate_t *ap_hdrs_to_ascii; +/** On EBCDIC machine this is a translation handle used to translate the + * headers from ASCII to the local machine format after network transmission. + * On an ASCII machine this is NULL */ +extern apr_xlate_t *ap_hdrs_from_ascii; +/** On EBCDIC machine this is a translation handle used to translate the + * content from the local machine format to ASCII for network transmission. + * On an ASCII machine this is NULL */ +extern apr_xlate_t *ap_locale_to_ascii; +/** On EBCDIC machine this is a translation handle used to translate the + * content from ASCII to the local machine format after network transmission. + * On an ASCII machine this is NULL */ +extern apr_xlate_t *ap_locale_from_ascii; + +#ifdef __cplusplus +} +#endif + +#endif /* APACHE_XLATE */ + +#endif /* !APACHE_UTIL_CHARSET_H */ diff --git a/rubbos/app/apache2/include/util_ebcdic.h b/rubbos/app/apache2/include/util_ebcdic.h new file mode 100644 index 00000000..0cd54cee --- /dev/null +++ b/rubbos/app/apache2/include/util_ebcdic.h @@ -0,0 +1,78 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_EBCDIC_H +#define APACHE_UTIL_EBCDIC_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "apr_xlate.h" +#include "httpd.h" +#include "util_charset.h" + +/** + * @package Utilities for EBCDIC conversion + */ + +#if APR_CHARSET_EBCDIC + +/** + * Setup all of the global translation handlers + * @param pool pool to allocate out of + */ +apr_status_t ap_init_ebcdic(apr_pool_t *pool); + +/** + * Convert protocol data from the implementation character + * set to ASCII. + * @param buffer buffer to translate + * @param len number of bytes to translate + */ +void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len); + +/** + * Convert protocol data to the implementation character + * set from ASCII. + * @param buffer buffer to translate + * @param len number of bytes to translate + */ +void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len); + +/** + * Convert protocol data from the implementation charater + * set to ASCII, then send it. + * @param r the current request + * @param ... the strings to write, followed by a NULL pointer + */ +int ap_rvputs_proto_in_ascii(request_rec *r, ...); + +#else /* APR_CHARSET_EBCDIC */ + +#define ap_xlate_proto_to_ascii(x,y) /* NOOP */ +#define ap_xlate_proto_from_ascii(x,y) /* NOOP */ + +#define ap_rvputs_proto_in_ascii ap_rvputs + +#endif /* APR_CHARSET_EBCDIC */ + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_UTIL_EBCDIC_H */ diff --git a/rubbos/app/apache2/include/util_filter.h b/rubbos/app/apache2/include/util_filter.h new file mode 100644 index 00000000..a5c9802a --- /dev/null +++ b/rubbos/app/apache2/include/util_filter.h @@ -0,0 +1,516 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AP_FILTER_H +#define AP_FILTER_H + +#include "apr.h" +#include "apr_buckets.h" + +#include "httpd.h" + +#if APR_HAVE_STDARG_H +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file util_filter.h + * @brief Apache filter library + */ + +/** Returned by the bottom-most filter if no data was written. + * @see ap_pass_brigade(). */ +#define AP_NOBODY_WROTE -1 +/** Returned by the bottom-most filter if no data was read. + * @see ap_get_brigade(). */ +#define AP_NOBODY_READ -2 +/** Returned when?? @bug find out when! */ +#define AP_FILTER_ERROR -3 + +/** + * input filtering modes + */ +typedef enum { + /** The filter should return at most readbytes data. */ + AP_MODE_READBYTES, + /** The filter should return at most one line of CRLF data. + * (If a potential line is too long or no CRLF is found, the + * filter may return partial data). + */ + AP_MODE_GETLINE, + /** The filter should implicitly eat any CRLF pairs that it sees. */ + AP_MODE_EATCRLF, + /** The filter read should be treated as speculative and any returned + * data should be stored for later retrieval in another mode. */ + AP_MODE_SPECULATIVE, + /** The filter read should be exhaustive and read until it can not + * read any more. + * Use this mode with extreme caution. + */ + AP_MODE_EXHAUSTIVE, + /** The filter should initialize the connection if needed, + * NNTP or FTP over SSL for example. + */ + AP_MODE_INIT +} ap_input_mode_t; + +/** + * @defgroup filter FILTER CHAIN + * + * Filters operate using a "chaining" mechanism. The filters are chained + * together into a sequence. When output is generated, it is passed through + * each of the filters on this chain, until it reaches the end (or "bottom") + * and is placed onto the network. + * + * The top of the chain, the code generating the output, is typically called + * a "content generator." The content generator's output is fed into the + * filter chain using the standard Apache output mechanisms: ap_rputs(), + * ap_rprintf(), ap_rwrite(), etc. + * + * Each filter is defined by a callback. This callback takes the output from + * the previous filter (or the content generator if there is no previous + * filter), operates on it, and passes the result to the next filter in the + * chain. This pass-off is performed using the ap_fc_* functions, such as + * ap_fc_puts(), ap_fc_printf(), ap_fc_write(), etc. + * + * When content generation is complete, the system will pass an "end of + * stream" marker into the filter chain. The filters will use this to flush + * out any internal state and to detect incomplete syntax (for example, an + * unterminated SSI directive). + */ + +/* forward declare the filter type */ +typedef struct ap_filter_t ap_filter_t; + +/** + * @name Filter callbacks + * + * This function type is used for filter callbacks. It will be passed a + * pointer to "this" filter, and a "bucket" containing the content to be + * filtered. + * + * In filter->ctx, the callback will find its context. This context is + * provided here, so that a filter may be installed multiple times, each + * receiving its own per-install context pointer. + * + * Callbacks are associated with a filter definition, which is specified + * by name. See ap_register_input_filter() and ap_register_output_filter() + * for setting the association between a name for a filter and its + * associated callback (and other information). + * + * If the initialization function argument passed to the registration + * functions is non-NULL, it will be called iff the filter is in the input + * or output filter chains and before any data is generated to allow the + * filter to prepare for processing. + * + * The *bucket structure (and all those referenced by ->next and ->prev) + * should be considered "const". The filter is allowed to modify the + * next/prev to insert/remove/replace elements in the bucket list, but + * the types and values of the individual buckets should not be altered. + * + * For the input and output filters, the return value of a filter should be + * an APR status value. For the init function, the return value should + * be an HTTP error code or OK if it was successful. + * + * @ingroup filter + * @{ + */ +typedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f, + apr_bucket_brigade *b); +typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f, + apr_bucket_brigade *b, + ap_input_mode_t mode, + apr_read_type_e block, + apr_off_t readbytes); +typedef int (*ap_init_filter_func)(ap_filter_t *f); + +typedef union ap_filter_func { + ap_out_filter_func out_func; + ap_in_filter_func in_func; +} ap_filter_func; + +/** @} */ + +/** + * Filters have different types/classifications. These are used to group + * and sort the filters to properly sequence their operation. + * + * The types have a particular sort order, which allows us to insert them + * into the filter chain in a determistic order. Within a particular grouping, + * the ordering is equivalent to the order of calls to ap_add_*_filter(). + */ +typedef enum { + /** These filters are used to alter the content that is passed through + * them. Examples are SSI or PHP. */ + AP_FTYPE_RESOURCE = 10, + /** These filters are used to alter the content as a whole, but after all + * AP_FTYPE_RESOURCE filters are executed. These filters should not + * change the content-type. An example is deflate. */ + AP_FTYPE_CONTENT_SET = 20, + /** These filters are used to handle the protocol between server and + * client. Examples are HTTP and POP. */ + AP_FTYPE_PROTOCOL = 30, + /** These filters implement transport encodings (e.g., chunking). */ + AP_FTYPE_TRANSCODE = 40, + /** These filters will alter the content, but in ways that are + * more strongly associated with the connection. Examples are + * splitting an HTTP connection into multiple requests and + * buffering HTTP responses across multiple requests. + * + * It is important to note that these types of filters are not + * allowed in a sub-request. A sub-request's output can certainly + * be filtered by ::AP_FTYPE_RESOURCE filters, but all of the "final + * processing" is determined by the main request. */ + AP_FTYPE_CONNECTION = 50, + /** These filters don't alter the content. They are responsible for + * sending/receiving data to/from the client. */ + AP_FTYPE_NETWORK = 60 +} ap_filter_type; + +/** + * This is the request-time context structure for an installed filter (in + * the output filter chain). It provides the callback to use for filtering, + * the request this filter is associated with (which is important when + * an output chain also includes sub-request filters), the context for this + * installed filter, and the filter ordering/chaining fields. + * + * Filter callbacks are free to use ->ctx as they please, to store context + * during the filter process. Generally, this is superior over associating + * the state directly with the request. A callback should not change any of + * the other fields. + */ + +typedef struct ap_filter_rec_t ap_filter_rec_t; + +/** + * This structure is used for recording information about the + * registered filters. It associates a name with the filter's callback + * and filter type. + * + * At the moment, these are simply linked in a chain, so a ->next pointer + * is available. + */ +struct ap_filter_rec_t { + /** The registered name for this filter */ + const char *name; + /** The function to call when this filter is invoked. */ + ap_filter_func filter_func; + /** The function to call before the handlers are invoked. Notice + * that this function is called only for filters participating in + * the http protocol. Filters for other protocols are to be + * initiliazed by the protocols themselves. */ + ap_init_filter_func filter_init_func; + /** The type of filter, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION. + * An AP_FTYPE_CONTENT filter modifies the data based on information + * found in the content. An AP_FTYPE_CONNECTION filter modifies the + * data based on the type of connection. + */ + ap_filter_type ftype; + + /** The next filter_rec in the list */ + struct ap_filter_rec_t *next; +}; + +/** + * The representation of a filter chain. Each request has a list + * of these structures which are called in turn to filter the data. Sub + * requests get an exact copy of the main requests filter chain. + */ +struct ap_filter_t { + /** The internal representation of this filter. This includes + * the filter's name, type, and the actual function pointer. + */ + ap_filter_rec_t *frec; + + /** A place to store any data associated with the current filter */ + void *ctx; + + /** The next filter in the chain */ + ap_filter_t *next; + + /** The request_rec associated with the current filter. If a sub-request + * adds filters, then the sub-request is the request associated with the + * filter. + */ + request_rec *r; + + /** The conn_rec associated with the current filter. This is analogous + * to the request_rec, except that it is used for input filtering. + */ + conn_rec *c; +}; + +/** + * Get the current bucket brigade from the next filter on the filter + * stack. The filter returns an apr_status_t value. If the bottom-most + * filter doesn't read from the network, then ::AP_NOBODY_READ is returned. + * The bucket brigade will be empty when there is nothing left to get. + * @param filter The next filter in the chain + * @param bucket The current bucket brigade. The original brigade passed + * to ap_get_brigade() must be empty. + * @param mode The way in which the data should be read + * @param block How the operations should be performed + * ::APR_BLOCK_READ, ::APR_NONBLOCK_READ + * @param readbytes How many bytes to read from the next filter. + */ +AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter, + apr_bucket_brigade *bucket, + ap_input_mode_t mode, + apr_read_type_e block, + apr_off_t readbytes); + +/** + * Pass the current bucket brigade down to the next filter on the filter + * stack. The filter returns an apr_status_t value. If the bottom-most + * filter doesn't write to the network, then ::AP_NOBODY_WROTE is returned. + * The caller relinquishes ownership of the brigade. + * @param filter The next filter in the chain + * @param bucket The current bucket brigade + */ +AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter, + apr_bucket_brigade *bucket); + +/** + * This function is used to register an input filter with the system. + * After this registration is performed, then a filter may be added + * into the filter chain by using ap_add_input_filter() and simply + * specifying the name. + * + * @param name The name to attach to the filter function + * @param filter_func The filter function to name + * @param filter_init The function to call before the filter handlers + are invoked + * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT or + * ::AP_FTYPE_CONNECTION + * @see add_input_filter() + */ +AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name, + ap_in_filter_func filter_func, + ap_init_filter_func filter_init, + ap_filter_type ftype); +/** + * This function is used to register an output filter with the system. + * After this registration is performed, then a filter may be added + * into the filter chain by using ap_add_output_filter() and simply + * specifying the name. + * + * @param name The name to attach to the filter function + * @param filter_func The filter function to name + * @param filter_init The function to call before the filter handlers + * are invoked + * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT or + * ::AP_FTYPE_CONNECTION + * @see ap_add_output_filter() + */ +AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter(const char *name, + ap_out_filter_func filter_func, + ap_init_filter_func filter_init, + ap_filter_type ftype); + +/** + * Adds a named filter into the filter chain on the specified request record. + * The filter will be installed with the specified context pointer. + * + * Filters added in this way will always be placed at the end of the filters + * that have the same type (thus, the filters have the same order as the + * calls to ap_add_filter). If the current filter chain contains filters + * from another request, then this filter will be added before those other + * filters. + * + * To re-iterate that last comment. This function is building a FIFO + * list of filters. Take note of that when adding your filter to the chain. + * + * @param name The name of the filter to add + * @param ctx Context data to provide to the filter + * @param r The request to add this filter for (or NULL if it isn't associated with a request) + * @param c The connection to add the fillter for + */ +AP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx, + request_rec *r, conn_rec *c); + +/** + * Variant of ap_add_input_filter() that accepts a registered filter handle + * (as returned by ap_register_input_filter()) rather than a filter name + * + * @param f The filter handle to add + * @param ctx Context data to provide to the filter + * @param r The request to add this filter for (or NULL if it isn't associated with a request) + * @param c The connection to add the fillter for + */ +AP_DECLARE(ap_filter_t *) ap_add_input_filter_handle(ap_filter_rec_t *f, + void *ctx, + request_rec *r, + conn_rec *c); + +/** + * Returns the filter handle for use with ap_add_input_filter_handle. + * + * @param name The filter name to look up + */ +AP_DECLARE(ap_filter_rec_t *) ap_get_input_filter_handle(const char *name); + +/** + * Add a filter to the current request. Filters are added in a FIFO manner. + * The first filter added will be the first filter called. + * @param name The name of the filter to add + * @param ctx Context data to set in the filter + * @param r The request to add this filter for (or NULL if it isn't associated with a request) + * @param c The connection to add this filter for + */ +AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx, + request_rec *r, conn_rec *c); + +/** + * Variant of ap_add_output_filter() that accepts a registered filter handle + * (as returned by ap_register_output_filter()) rather than a filter name + * + * @param f The filter handle to add + * @param r The request to add this filter for (or NULL if it isn't associated with a request) + * @param c The connection to add the fillter for + */ +AP_DECLARE(ap_filter_t *) ap_add_output_filter_handle(ap_filter_rec_t *f, + void *ctx, + request_rec *r, + conn_rec *c); + +/** + * Returns the filter handle for use with ap_add_output_filter_handle. + * + * @param name The filter name to look up + */ +AP_DECLARE(ap_filter_rec_t *) ap_get_output_filter_handle(const char *name); + +/** + * Remove an input filter from either the request or connection stack + * it is associated with. + * @param f The filter to remove + */ + +AP_DECLARE(void) ap_remove_input_filter(ap_filter_t *f); + +/** + * Remove an output filter from either the request or connection stack + * it is associated with. + * @param f The filter to remove + */ + +AP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f); + +/* The next two filters are for abstraction purposes only. They could be + * done away with, but that would require that we break modules if we ever + * want to change our filter registration method. The basic idea, is that + * all filters have a place to store data, the ctx pointer. These functions + * fill out that pointer with a bucket brigade, and retrieve that data on + * the next call. The nice thing about these functions, is that they + * automatically concatenate the bucket brigades together for you. This means + * that if you have already stored a brigade in the filters ctx pointer, then + * when you add more it will be tacked onto the end of that brigade. When + * you retrieve data, if you pass in a bucket brigade to the get function, + * it will append the current brigade onto the one that you are retrieving. + */ + +/** + * prepare a bucket brigade to be setaside. If a different brigade was + * set-aside earlier, then the two brigades are concatenated together. + * @param f The current filter + * @param save_to The brigade that was previously set-aside. Regardless, the + * new bucket brigade is returned in this location. + * @param b The bucket brigade to save aside. This brigade is always empty + * on return + * @param p Ensure that all data in the brigade lives as long as this pool + */ +AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f, + apr_bucket_brigade **save_to, + apr_bucket_brigade **b, apr_pool_t *p); + +/** + * Flush function for apr_brigade_* calls. This calls ap_pass_brigade + * to flush the brigade if the brigade buffer overflows. + * @param bb The brigade to flush + * @param ctx The filter to pass the brigade to + * @note this function has nothing to do with FLUSH buckets. It is simply + * a way to flush content out of a brigade and down a filter stack. + */ +AP_DECLARE_NONSTD(apr_status_t) ap_filter_flush(apr_bucket_brigade *bb, + void *ctx); + +/** + * Flush the current brigade down the filter stack. + * @param f The current filter + * @param bb The brigade to flush + */ +AP_DECLARE(apr_status_t) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb); + +/** + * Write a buffer for the current filter, buffering if possible. + * @param f the filter doing the writing + * @param bb The brigade to buffer into + * @param data The data to write + * @param nbyte The number of bytes in the data + */ +#define ap_fwrite(f, bb, data, nbyte) \ + apr_brigade_write(bb, ap_filter_flush, f, data, nbyte) + +/** + * Write a buffer for the current filter, buffering if possible. + * @param f the filter doing the writing + * @param bb The brigade to buffer into + * @param str The string to write + */ +#define ap_fputs(f, bb, str) \ + apr_brigade_puts(bb, ap_filter_flush, f, str) + +/** + * Write a character for the current filter, buffering if possible. + * @param f the filter doing the writing + * @param bb The brigade to buffer into + * @param c The character to write + */ +#define ap_fputc(f, bb, c) \ + apr_brigade_putc(bb, ap_filter_flush, f, c) + +/** + * Write an unspecified number of strings to the current filter + * @param f the filter doing the writing + * @param bb The brigade to buffer into + * @param ... The strings to write + */ +AP_DECLARE_NONSTD(apr_status_t) ap_fputstrs(ap_filter_t *f, + apr_bucket_brigade *bb, + ...); + +/** + * Output data to the filter in printf format + * @param f the filter doing the writing + * @param bb The brigade to buffer into + * @param fmt The format string + * @param ... The argumets to use to fill out the format string + */ +AP_DECLARE_NONSTD(apr_status_t) ap_fprintf(ap_filter_t *f, + apr_bucket_brigade *bb, + const char *fmt, + ...) + __attribute__((format(printf,3,4))); + +#ifdef __cplusplus +} +#endif + +#endif /* !AP_FILTER_H */ diff --git a/rubbos/app/apache2/include/util_ldap.h b/rubbos/app/apache2/include/util_ldap.h new file mode 100644 index 00000000..605f3b72 --- /dev/null +++ b/rubbos/app/apache2/include/util_ldap.h @@ -0,0 +1,318 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UTIL_LDAP_H +#define UTIL_LDAP_H + +#include + +/* this whole thing disappears if LDAP is not enabled */ +#ifdef APU_HAS_LDAP + +/* APR header files */ +#include +#include +#include +#include + +/* Apache header files */ +#include "ap_config.h" +#include "httpd.h" +#include "http_config.h" +#include "http_core.h" +#include "http_log.h" +#include "http_protocol.h" +#include "http_request.h" + +#if APR_HAS_SHARED_MEMORY +#include "apr_rmm.h" +#include "apr_shm.h" +#endif + +/* Create a set of LDAP_DECLARE(type), LDLDAP_DECLARE(type) and + * LDAP_DECLARE_DATA with appropriate export and import tags for the platform + */ +#if !defined(WIN32) +#define LDAP_DECLARE(type) type +#define LDAP_DECLARE_NONSTD(type) type +#define LDAP_DECLARE_DATA +#elif defined(LDAP_DECLARE_STATIC) +#define LDAP_DECLARE(type) type __stdcall +#define LDAP_DECLARE_NONSTD(type) type +#define LDAP_DECLARE_DATA +#elif defined(LDAP_DECLARE_EXPORT) +#define LDAP_DECLARE(type) __declspec(dllexport) type __stdcall +#define LDAP_DECLARE_NONSTD(type) __declspec(dllexport) type +#define LDAP_DECLARE_DATA __declspec(dllexport) +#else +#define LDAP_DECLARE(type) __declspec(dllimport) type __stdcall +#define LDAP_DECLARE_NONSTD(type) __declspec(dllimport) type +#define LDAP_DECLARE_DATA __declspec(dllimport) +#endif + +/* + * LDAP Connections + */ + +/* Values that the deref member can have */ +typedef enum { + never=LDAP_DEREF_NEVER, + searching=LDAP_DEREF_SEARCHING, + finding=LDAP_DEREF_FINDING, + always=LDAP_DEREF_ALWAYS +} deref_options; + +/* Structure representing an LDAP connection */ +typedef struct util_ldap_connection_t { + LDAP *ldap; + apr_pool_t *pool; /* Pool from which this connection is created */ +#if APR_HAS_THREADS + apr_thread_mutex_t *lock; /* Lock to indicate this connection is in use */ +#endif + int bound; /* Flag to indicate whether this connection is bound yet */ + + const char *host; /* Name of the LDAP server (or space separated list) */ + int port; /* Port of the LDAP server */ + deref_options deref; /* how to handle alias dereferening */ + + const char *binddn; /* DN to bind to server (can be NULL) */ + const char *bindpw; /* Password to bind to server (can be NULL) */ + + int secure; /* True if use SSL connection */ + + const char *reason; /* Reason for an error failure */ + + struct util_ldap_connection_t *next; +} util_ldap_connection_t; + +/* LDAP cache state information */ +typedef struct util_ldap_state_t { + apr_pool_t *pool; /* pool from which this state is allocated */ +#if APR_HAS_THREADS + apr_thread_mutex_t *mutex; /* mutex lock for the connection list */ +#endif + apr_global_mutex_t *util_ldap_cache_lock; + + apr_size_t cache_bytes; /* Size (in bytes) of shared memory cache */ + char *cache_file; /* filename for shm */ + long search_cache_ttl; /* TTL for search cache */ + long search_cache_size; /* Size (in entries) of search cache */ + long compare_cache_ttl; /* TTL for compare cache */ + long compare_cache_size; /* Size (in entries) of compare cache */ + + struct util_ldap_connection_t *connections; + char *cert_auth_file; + int cert_file_type; + int ssl_support; + +#if APR_HAS_SHARED_MEMORY + apr_shm_t *cache_shm; + apr_rmm_t *cache_rmm; +#endif + + /* cache ald */ + void *util_ldap_cache; + char *lock_file; /* filename for shm lock mutex */ + int connectionTimeout; + +} util_ldap_state_t; + + +/** + * Open a connection to an LDAP server + * @param ldc A structure containing the expanded details of the server + * to connect to. The handle to the LDAP connection is returned + * as ldc->ldap. + * @tip This function connects to the LDAP server and binds. It does not + * connect if already connected (ldc->ldap != NULL). Does not bind + * if already bound. + * @return If successful LDAP_SUCCESS is returned. + * @deffunc int util_ldap_connection_open(request_rec *r, + * util_ldap_connection_t *ldc) + */ +LDAP_DECLARE(int) util_ldap_connection_open(request_rec *r, + util_ldap_connection_t *ldc); + +/** + * Close a connection to an LDAP server + * @param ldc A structure containing the expanded details of the server + * that was connected. + * @tip This function unbinds from the LDAP server, and clears ldc->ldap. + * It is possible to rebind to this server again using the same ldc + * structure, using apr_ldap_open_connection(). + * @deffunc util_ldap_close_connection(util_ldap_connection_t *ldc) + */ +LDAP_DECLARE(void) util_ldap_connection_close(util_ldap_connection_t *ldc); + +/** + * Unbind a connection to an LDAP server + * @param ldc A structure containing the expanded details of the server + * that was connected. + * @tip This function unbinds the LDAP connection, and disconnects from + * the server. It is used during error conditions, to bring the LDAP + * connection back to a known state. + * @deffunc apr_status_t util_ldap_connection_unbind(util_ldap_connection_t *ldc) + */ +LDAP_DECLARE_NONSTD(apr_status_t) util_ldap_connection_unbind(void *param); + +/** + * Cleanup a connection to an LDAP server + * @param ldc A structure containing the expanded details of the server + * that was connected. + * @tip This function is registered with the pool cleanup to close down the + * LDAP connections when the server is finished with them. + * @deffunc apr_status_t util_ldap_connection_cleanup(util_ldap_connection_t *ldc) + */ +LDAP_DECLARE_NONSTD(apr_status_t) util_ldap_connection_cleanup(void *param); + +/** + * Find a connection in a list of connections + * @param r The request record + * @param host The hostname to connect to (multiple hosts space separated) + * @param port The port to connect to + * @param binddn The DN to bind with + * @param bindpw The password to bind with + * @param deref The dereferencing behavior + * @param secure use SSL on the connection + * @tip Once a connection is found and returned, a lock will be acquired to + * lock that particular connection, so that another thread does not try and + * use this connection while it is busy. Once you are finished with a connection, + * apr_ldap_connection_close() must be called to release this connection. + * @deffunc util_ldap_connection_t *util_ldap_connection_find(request_rec *r, const char *host, int port, + * const char *binddn, const char *bindpw, deref_options deref, + * int netscapessl, int starttls) + */ +LDAP_DECLARE(util_ldap_connection_t *) util_ldap_connection_find(request_rec *r, const char *host, int port, + const char *binddn, const char *bindpw, deref_options deref, + int secure); + + +/** + * Compare two DNs for sameness + * @param r The request record + * @param ldc The LDAP connection being used. + * @param url The URL of the LDAP connection - used for deciding which cache to use. + * @param dn The first DN to compare. + * @param reqdn The DN to compare the first DN to. + * @param compare_dn_on_server Flag to determine whether the DNs should be checked using + * LDAP calls or with a direct string comparision. A direct + * string comparison is faster, but not as accurate - false + * negative comparisons are possible. + * @tip Two DNs can be equal and still fail a string comparison. Eg "dc=example,dc=com" + * and "dc=example, dc=com". Use the compare_dn_on_server unless there are serious + * performance issues. + * @deffunc int util_ldap_cache_comparedn(request_rec *r, util_ldap_connection_t *ldc, + * const char *url, const char *dn, const char *reqdn, + * int compare_dn_on_server) + */ +LDAP_DECLARE(int) util_ldap_cache_comparedn(request_rec *r, util_ldap_connection_t *ldc, + const char *url, const char *dn, const char *reqdn, + int compare_dn_on_server); + +/** + * A generic LDAP compare function + * @param r The request record + * @param ldc The LDAP connection being used. + * @param url The URL of the LDAP connection - used for deciding which cache to use. + * @param dn The DN of the object in which we do the compare. + * @param attrib The attribute within the object we are comparing for. + * @param value The value of the attribute we are trying to compare for. + * @tip Use this function to determine whether an attribute/value pair exists within an + * object. Typically this would be used to determine LDAP group membership. + * @deffunc int util_ldap_cache_compare(request_rec *r, util_ldap_connection_t *ldc, + * const char *url, const char *dn, const char *attrib, const char *value) + */ +LDAP_DECLARE(int) util_ldap_cache_compare(request_rec *r, util_ldap_connection_t *ldc, + const char *url, const char *dn, const char *attrib, const char *value); + +/** + * Checks a username/password combination by binding to the LDAP server + * @param r The request record + * @param ldc The LDAP connection being used. + * @param url The URL of the LDAP connection - used for deciding which cache to use. + * @param basedn The Base DN to search for the user in. + * @param scope LDAP scope of the search. + * @param attrs LDAP attributes to return in search. + * @param filter The user to search for in the form of an LDAP filter. This filter must return + * exactly one user for the check to be successful. + * @param bindpw The user password to bind as. + * @param binddn The DN of the user will be returned in this variable. + * @param retvals The values corresponding to the attributes requested in the attrs array. + * @tip The filter supplied will be searched for. If a single entry is returned, an attempt + * is made to bind as that user. If this bind succeeds, the user is not validated. + * @deffunc int util_ldap_cache_checkuserid(request_rec *r, util_ldap_connection_t *ldc, + * char *url, const char *basedn, int scope, char **attrs, + * char *filter, char *bindpw, char **binddn, char ***retvals) + */ +LDAP_DECLARE(int) util_ldap_cache_checkuserid(request_rec *r, util_ldap_connection_t *ldc, + const char *url, const char *basedn, int scope, char **attrs, + const char *filter, const char *bindpw, const char **binddn, const char ***retvals); + +/** + * Retrieves the LDAP DN of the user without the need to know user password + * @param r The request record + * @param ldc The LDAP connection being used. + * @param url The URL of the LDAP connection - used for deciding which cache to use. + * @param basedn The Base DN to search for the user in. + * @param scope LDAP scope of the search. + * @param attrs LDAP attributes to return in search. + * @param filter The user to search for in the form of an LDAP filter. This filter must return + * exactly one user for the check to be successful. + * @param binddn The DN of the user will be returned in this variable. + * @param retvals The values corresponding to the attributes requested in the attrs array. + * @tip The filter supplied will be searched for. A single entry matching the search is returned. + * @deffunc int util_ldap_cache_getuserdn(request_rec *r, util_ldap_connection_t *ldc, + * char *url, const char *basedn, int scope, char **attrs, + * char *filter, char **binddn, char ***retvals) + */ +LDAP_DECLARE(int) util_ldap_cache_getuserdn(request_rec *r, util_ldap_connection_t *ldc, + const char *url, const char *basedn, int scope, char **attrs, + const char *filter, const char **binddn, const char ***retvals); + +/** + * Checks if SSL support is available in mod_ldap + * @deffunc int util_ldap_ssl_supported(request_rec *r) + */ +LDAP_DECLARE(int) util_ldap_ssl_supported(request_rec *r); + +/* from apr_ldap_cache.c */ + +/** + * Init the LDAP cache + * @param pool The pool to use to initialise the cache + * @param reqsize The size of the shared memory segement to request. A size + * of zero requests the max size possible from + * apr_shmem_init() + * @deffunc void util_ldap_cache_init(apr_pool_t *p, util_ldap_state_t *st) + * @return The status code returned is the status code of the + * apr_smmem_init() call. Regardless of the status, the cache + * will be set up at least for in-process or in-thread operation. + */ +apr_status_t util_ldap_cache_init(apr_pool_t *pool, util_ldap_state_t *st); + +/* from apr_ldap_cache_mgr.c */ + +/** + * Display formatted stats for cache + * @param The pool to allocate the returned string from + * @tip This function returns a string allocated from the provided pool that describes + * various stats about the cache. + * @deffunc char *util_ald_cache_display(apr_pool_t *pool, util_ldap_state_t *st) + */ +char *util_ald_cache_display(request_rec *r, util_ldap_state_t *st); + +#endif /* APU_HAS_LDAP */ +#endif /* UTIL_LDAP_H */ diff --git a/rubbos/app/apache2/include/util_md5.h b/rubbos/app/apache2/include/util_md5.h new file mode 100644 index 00000000..6c5299de --- /dev/null +++ b/rubbos/app/apache2/include/util_md5.h @@ -0,0 +1,70 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_MD5_H +#define APACHE_UTIL_MD5_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Apache MD5 library + */ + +#include "apr_md5.h" + +/** + * Create an MD5 checksum of a given string + * @param a Pool to allocate out of + * @param string String to get the checksum of + * @return The checksum + * @deffunc char *ap_md5(apr_pool_t *a, const unsigned char *string) + */ +AP_DECLARE(char *) ap_md5(apr_pool_t *a, const unsigned char *string); + +/** + * Create an MD5 checksum of a string of binary data + * @param a Pool to allocate out of + * @param buf Buffer to generate checksum for + * @param len The length of the buffer + * @return The checksum + * @deffunc char *ap_md5_binary(apr_pool_t *a, const unsigned char *buf, int len) + */ +AP_DECLARE(char *) ap_md5_binary(apr_pool_t *a, const unsigned char *buf, int len); + +/** + * Convert an MD5 checksum into a base64 encoding + * @param p The pool to allocate out of + * @param context The context to convert + * @return The converted encoding + * @deffunc char *ap_md5contextTo64(apr_pool_t *p, apr_md5_ctx_t *context) + */ +AP_DECLARE(char *) ap_md5contextTo64(apr_pool_t *p, apr_md5_ctx_t *context); + +/** + * Create an MD5 Digest for a given file + * @param p The pool to allocate out of + * @param infile The file to create the digest for + * @deffunc char *ap_md5digest(apr_pool_t *p, apr_file_t *infile) + */ +AP_DECLARE(char *) ap_md5digest(apr_pool_t *p, apr_file_t *infile); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_UTIL_MD5_H */ diff --git a/rubbos/app/apache2/include/util_script.h b/rubbos/app/apache2/include/util_script.h new file mode 100644 index 00000000..c68b81d9 --- /dev/null +++ b/rubbos/app/apache2/include/util_script.h @@ -0,0 +1,142 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_SCRIPT_H +#define APACHE_UTIL_SCRIPT_H + +#include "apr_buckets.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Apache script tools + */ + +#ifndef APACHE_ARG_MAX +#ifdef _POSIX_ARG_MAX +#define APACHE_ARG_MAX _POSIX_ARG_MAX +#else +#define APACHE_ARG_MAX 512 +#endif +#endif + +/** + * Create an environment variable out of an Apache table of key-value pairs + * @param p pool to allocate out of + * @param t Apache table of key-value pairs + * @return An array containing the same key-value pairs suitable for + * use with an exec call. + * @deffunc char **ap_create_environment(apr_pool_t *p, apr_table_t *t) + */ +AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t); + +/** + * This "cute" little function comes about because the path info on + * filenames and URLs aren't always the same. So we take the two, + * and find as much of the two that match as possible. + * @param uri The uri we are currently parsing + * @param path_info The current path info + * @return The length of the path info + * @deffunc int ap_find_path_info(const char *uri, const char *path_info) + */ +AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info); + +/** + * Add CGI environment variables required by HTTP/1.1 to the request's + * environment table + * @param r the current request + * @deffunc void ap_add_cgi_vars(request_rec *r) + */ +AP_DECLARE(void) ap_add_cgi_vars(request_rec *r); + +/** + * Add common CGI environment variables to the requests environment table + * @param r The current request + * @deffunc void ap_add_common_vars(request_rec *r) + */ +AP_DECLARE(void) ap_add_common_vars(request_rec *r); + +/** + * Read headers output from a script, ensuring that the output is valid. If + * the output is valid, then the headers are added to the headers out of the + * current request + * @param r The current request + * @param f The file to read from + * @param buffer Empty when calling the function. On output, if there was an + * error, the string that cause the error is stored here. + * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise + * @deffunc int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer) + */ +AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer); + +/** + * Read headers output from a script, ensuring that the output is valid. If + * the output is valid, then the headers are added to the headers out of the + * current request + * @param r The current request + * @param bb The brigade from which to read + * @param buffer Empty when calling the function. On output, if there was an + * error, the string that cause the error is stored here. + * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise + * @deffunc int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer) + */ +AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r, + apr_bucket_brigade *bb, + char *buffer); + +/** + * Read headers strings from a script, ensuring that the output is valid. If + * the output is valid, then the headers are added to the headers out of the + * current request + * @param r The current request + * @param buffer Empty when calling the function. On output, if there was an + * error, the string that cause the error is stored here. + * @param termch Pointer to the last character parsed. + * @param termarg Pointer to an int to capture the last argument parsed. + * @param args String arguments to parse consecutively for headers, + * a NULL argument terminates the list. + * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise + * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data) + */ +AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r, + char *buffer, + const char **termch, + int *termarg, ...); + +/** + * Read headers output from a script, ensuring that the output is valid. If + * the output is valid, then the headers are added to the headers out of the + * current request + * @param r The current request + * @param buffer Empty when calling the function. On output, if there was an + * error, the string that cause the error is stored here. + * @param getsfunc Function to read the headers from. This function should + act like gets() + * @param getsfunc_data The place to read from + * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise + * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data) + */ +AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer, + int (*getsfunc) (char *, int, void *), + void *getsfunc_data); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_UTIL_SCRIPT_H */ diff --git a/rubbos/app/apache2/include/util_time.h b/rubbos/app/apache2/include/util_time.h new file mode 100644 index 00000000..5e8e394f --- /dev/null +++ b/rubbos/app/apache2/include/util_time.h @@ -0,0 +1,85 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_UTIL_TIME_H +#define APACHE_UTIL_TIME_H + +#include "apr.h" +#include "apr_time.h" +#include "httpd.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Apache date-time handling functions + */ + +/* Maximum delta from the current time, in seconds, for a past time + * to qualify as "recent" for use in the ap_explode_recent_*() functions: + * (Must be a power of two minus one!) + */ +#define AP_TIME_RECENT_THRESHOLD 15 + +/** + * convert a recent time to its human readable components in local timezone + * @param tm the exploded time + * @param t the time to explode: MUST be within the last + * AP_TIME_RECENT_THRESHOLD seconds + * @note This is a faster alternative to apr_explode_localtime that uses + * a cache of pre-exploded time structures. It is useful for things + * that need to explode the current time multiple times per second, + * like loggers. + * @return APR_SUCCESS iff successful + */ +AP_DECLARE(apr_status_t) ap_explode_recent_localtime(apr_time_exp_t *tm, + apr_time_t t); + +/** + * convert a recent time to its human readable components in GMT timezone + * @param tm the exploded time + * @param t the time to explode: MUST be within the last + * AP_TIME_RECENT_THRESHOLD seconds + * @note This is a faster alternative to apr_time_exp_gmt that uses + * a cache of pre-exploded time structures. It is useful for things + * that need to explode the current time multiple times per second, + * like loggers. + * @return APR_SUCCESS iff successful + */ +AP_DECLARE(apr_status_t) ap_explode_recent_gmt(apr_time_exp_t *tm, + apr_time_t t); + + +/** + * format a recent timestamp in the ctime() format. + * @param date_str String to write to. + * @param t the time to convert + */ +AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t); + +/** + * format a recent timestamp in the RFC822 format + * @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN) + * @param t the time to convert + */ +AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t); + +#ifdef __cplusplus +} +#endif + +#endif /* !APACHE_UTIL_TIME_H */ diff --git a/rubbos/app/apache2/include/util_xml.h b/rubbos/app/apache2/include/util_xml.h new file mode 100644 index 00000000..4965b14e --- /dev/null +++ b/rubbos/app/apache2/include/util_xml.h @@ -0,0 +1,46 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UTIL_XML_H +#define UTIL_XML_H + +#include "apr_xml.h" + +#include "httpd.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @package Apache XML library + */ + +/** + * Get XML post data and parse it + * @param r The current request + * @param pdoc The XML post data + * @return HTTP status code + * @deffunc int ap_xml_parse_input(request_rec *r, apr_xml_doc **pdoc) + */ +AP_DECLARE(int) ap_xml_parse_input(request_rec *r, apr_xml_doc **pdoc); + + +#ifdef __cplusplus +} +#endif + +#endif /* UTIL_XML_H */ -- cgit 1.2.3-korg