/home/lnzliplg/public_html/apache2.zip
PK �c�\��RX| | httpd.hnu �[��� /* 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.
*/
/**
* @file httpd.h
* @brief HTTP Daemon routines
*
* @defgroup APACHE Apache HTTP Server
*
* Top level group of which all other groups are a member
* @{
*
* @defgroup APACHE_MODS Loadable modules
* Top level group for modules
* @defgroup APACHE_OS Operating System Specific
* @defgroup APACHE_INTERNAL Internal interfaces
* @defgroup APACHE_CORE Core routines
* @{
* @defgroup APACHE_CORE_DAEMON HTTP Daemon Routine
* @{
*/
#ifndef APACHE_HTTPD_H
#define APACHE_HTTPD_H
/* 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.h"
#include "apr_version.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 "apr_poll.h"
#include "apr_thread_proc.h"
#include "os.h"
#include "ap_regex.h"
#if APR_HAVE_STDLIB_H
#include <stdlib.h>
#endif
/* Note: apr_uri.h is also included, see below */
#ifdef __cplusplus
extern "C" {
#endif
/* ----------------------------- 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 (NETWARE)
/** Set the default for NetWare */
#define HTTPD_ROOT "/apache"
#else
/** Set for all other OSs */
#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
/* Set default for non OS/2 file system */
#define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs"
#endif
#endif /* DOCUMENT_LOCATION */
/** Maximum number of dynamically loaded modules */
#ifndef DYNAMIC_MODULE_LIMIT
#define DYNAMIC_MODULE_LIMIT 256
#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
/** 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 60
#endif
/** The timeout for waiting for keepalive timeout until next request */
#ifndef DEFAULT_KEEPALIVE_TIMEOUT
#define DEFAULT_KEEPALIVE_TIMEOUT 5
#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 or 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.
*/
/** default limit on bytes in Request-Line (Method+URI+HTTP-version) */
#ifndef DEFAULT_LIMIT_REQUEST_LINE
#define DEFAULT_LIMIT_REQUEST_LINE 8190
#endif
/** default limit on bytes in any one header field */
#ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
#define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
#endif
/** default limit on number of request header fields */
#ifndef DEFAULT_LIMIT_REQUEST_FIELDS
#define DEFAULT_LIMIT_REQUEST_FIELDS 100
#endif
/** default/hard limit on number of leading/trailing empty lines */
#ifndef DEFAULT_LIMIT_BLANK_LINES
#define DEFAULT_LIMIT_BLANK_LINES 10
#endif
/**
* The default default character set name to add if AddDefaultCharset is
* enabled. Overridden with AddDefaultCharsetName.
*/
#define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1"
/** 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
/** 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 "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
"DTD HTML 2.0//EN\">\n"
/** HTML 3.2 Doctype */
#define DOCTYPE_HTML_3_2 "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
"DTD HTML 3.2 Final//EN\">\n"
/** HTML 4.0 Strict Doctype */
#define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
"DTD HTML 4.0//EN\"\n" \
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
/** HTML 4.0 Transitional Doctype */
#define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
"DTD HTML 4.0 Transitional//EN\"\n" \
"\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
/** HTML 4.0 Frameset Doctype */
#define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
"DTD HTML 4.0 Frameset//EN\"\n" \
"\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
/** HTML 4.01 Doctype */
#define DOCTYPE_HTML_4_01 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
/** HTML 5 Doctype */
#define DOCTYPE_HTML_5 "<!DOCTYPE html>\n"
/** XHTML 1.0 Strict Doctype */
#define DOCTYPE_XHTML_1_0S "<!DOCTYPE html PUBLIC \"-//W3C//" \
"DTD XHTML 1.0 Strict//EN\"\n" \
"\"http://www.w3.org/TR/xhtml1/DTD/" \
"xhtml1-strict.dtd\">\n"
/** XHTML 1.0 Transitional Doctype */
#define DOCTYPE_XHTML_1_0T "<!DOCTYPE html PUBLIC \"-//W3C//" \
"DTD XHTML 1.0 Transitional//EN\"\n" \
"\"http://www.w3.org/TR/xhtml1/DTD/" \
"xhtml1-transitional.dtd\">\n"
/** XHTML 1.0 Frameset Doctype */
#define DOCTYPE_XHTML_1_0F "<!DOCTYPE html PUBLIC \"-//W3C//" \
"DTD XHTML 1.0 Frameset//EN\"\n" \
"\"http://www.w3.org/TR/xhtml1/DTD/" \
"xhtml1-frameset.dtd\">"
/** 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
*/
#define ap_http_scheme(r) ap_run_http_scheme(r)
/** The default string length */
#define MAX_STRING_LEN HUGE_STRING_LEN
/** The length of a Huge string */
#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 splitting sendfile into
* multiple 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 */
/**
* MPM child process exit status values
* The MPM parent process may check the status to see if special
* error handling is required.
*/
/** 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 accommodate 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 use functions marked AP_CORE_DECLARE
*/
#ifndef AP_CORE_DECLARE
# define AP_CORE_DECLARE AP_DECLARE
#endif
/**
* @internal
* modules should not use functions marked AP_CORE_DECLARE_NONSTD
*/
#ifndef AP_CORE_DECLARE_NONSTD
# define AP_CORE_DECLARE_NONSTD AP_DECLARE_NONSTD
#endif
/**
* @defgroup APACHE_APR_STATUS_T HTTPD specific values of apr_status_t
* @{
*/
#define AP_START_USERERR (APR_OS_START_USERERR + 2000)
#define AP_USERERR_LEN 1000
/** The function declines to handle the request */
#define AP_DECLINED (AP_START_USERERR + 0)
/** @} */
/**
* @brief 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 banner in a form suitable for sending over the
* network, with the level of information controlled by the
* ServerTokens directive.
* @return The server banner
*/
AP_DECLARE(const char *) ap_get_server_banner(void);
/**
* Get the server description in a form suitable for local displays,
* status reports, or logging. This includes the detailed server
* version and information about some modules. It is not affected
* by the ServerTokens directive.
* @return The server description
*/
AP_DECLARE(const char *) ap_get_server_description(void);
/**
* Add a component to the server description and banner strings
* @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);
/* non-HTTP status codes returned by hooks */
#define OK 0 /**< Module has handled this stage. */
#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 SUSPENDED -3 /**< Module will handle the remainder of the request.
* The core will never invoke the request again */
/** Returned by the bottom-most filter if no data was written.
* @see ap_pass_brigade(). */
#define AP_NOBODY_WROTE -100
/** Returned by the bottom-most filter if no data was read.
* @see ap_get_brigade(). */
#define AP_NOBODY_READ -101
/** Returned by any filter if the filter chain encounters an error
* and has already dealt with the error response.
*/
#define AP_FILTER_ERROR -102
/**
* @defgroup HTTP_Status HTTP Status Codes
* @{
*/
/**
* The size of the static status_lines array in http_protocol.c for
* storing all of the potential response status-lines (a sparse table).
* When adding a new code here add it to status_lines as well.
* A future version should dynamically generate the apr_table_t at startup.
*/
#define RESPONSE_CODES 103
#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_ALREADY_REPORTED 208
#define HTTP_IM_USED 226
#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_PERMANENT_REDIRECT 308
#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_MISDIRECTED_REQUEST 421
#define HTTP_UNPROCESSABLE_ENTITY 422
#define HTTP_LOCKED 423
#define HTTP_FAILED_DEPENDENCY 424
#define HTTP_UPGRADE_REQUIRED 426
#define HTTP_PRECONDITION_REQUIRED 428
#define HTTP_TOO_MANY_REQUESTS 429
#define HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE 431
#define HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451
#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_LOOP_DETECTED 508
#define HTTP_NOT_EXTENDED 510
#define HTTP_NETWORK_AUTHENTICATION_REQUIRED 511
/** 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))
/** is the status code a (potentially) valid response code? */
#define ap_is_HTTP_VALID_RESPONSE(x) (((x) >= 100)&&((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))
/** does the status imply header only response (i.e. never w/ a body)? */
#define AP_STATUS_IS_HEADER_ONLY(x) ((x) == HTTP_NO_CONTENT || \
(x) == HTTP_NOT_MODIFIED)
/** @} */
/**
* @defgroup Methods List of Methods recognized by the server
* @ingroup APACHE_CORE_DAEMON
* @{
*
* @brief 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 /** RFC 5789: PATCH Method for HTTP */
#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 /** no valid method */
/**
* 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)
/** @} */
/** @see ap_method_list_t */
typedef struct ap_method_list_t ap_method_list_t;
/**
* @struct ap_method_list_t
* @brief Structure for handling HTTP methods.
*
* Methods known to the server are accessed via a bitmask shortcut;
* extension methods are handled by an array.
*/
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 bnotes Binary notes recognized by the server
* @ingroup APACHE_CORE_DAEMON
* @{
*
* @brief Binary notes recognized by the server.
*/
/**
* The type used for request binary notes.
*/
typedef apr_uint64_t ap_request_bnotes_t;
/**
* These constants represent bitmasks for notes associated with this
* request. There are space for 64 bits in the apr_uint64_t.
*
*/
#define AP_REQUEST_STRONG_ETAG 1 >> 0
#define AP_REQUEST_TRUSTED_CT 1 << 1
/**
* This is a convenience macro to ease with getting specific request
* binary notes.
*/
#define AP_REQUEST_GET_BNOTE(r, mask) \
((mask) & ((r)->bnotes))
/**
* This is a convenience macro to ease with setting specific request
* binary notes.
*/
#define AP_REQUEST_SET_BNOTE(r, mask, val) \
(r)->bnotes = (((r)->bnotes & ~(mask)) | (val))
/**
* Returns true if the strong etag flag is set for this request.
*/
#define AP_REQUEST_IS_STRONG_ETAG(r) \
AP_REQUEST_GET_BNOTE((r), AP_REQUEST_STRONG_ETAG)
/** @} */
/**
* Returns true if the content-type field is from a trusted source
*/
#define AP_REQUEST_IS_TRUSTED_CT(r) \
(!!AP_REQUEST_GET_BNOTE((r), AP_REQUEST_TRUSTED_CT))
/** @} */
/**
* @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"
/** Default for r->handler if no content-type set by type_checker */
#define AP_DEFAULT_HANDLER_NAME ""
#define AP_IS_DEFAULT_HANDLER_NAME(x) (*x == '\0')
/** @} */
/* Just in case your linefeed isn't the one the other end is expecting. */
#if !APR_CHARSET_EBCDIC
/** linefeed */
#define LF 10
/** carriage return */
#define CR 13
/** carriage 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 */
/** Useful for common code with either platform charset. */
#define CRLF_ASCII "\015\012"
/**
* @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
/** @} // values_request_rec_body */
/**
* @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info
* @ingroup APACHE_CORE_DAEMON
* @{
* 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
/** @} // values_request_rec_used_path_info */
/*
* 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 have 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.
*/
/**
* @brief 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 override options allowed for the .htaccess file */
int override_opts;
/** Table of allowed directives for override */
apr_table_t *override_list;
/** 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;
/** A structure that represents the status of the current connection */
typedef struct conn_state_t conn_state_t;
/* ### would be nice to not include this from httpd.h ... */
/* This comes after we have defined the request_rec type */
#include "apr_uri.h"
/**
* @brief 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;
/** The program name used to execute the program */
const char *short_name;
/** The command line arguments */
const char * const *argv;
/** Number of command line arguments passed to the program */
int argc;
};
/**
* @brief 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 version number of protocol; 1.1 = 1001 */
int proto_num;
/** Protocol string, as given to us, or HTTP/0.9 */
char *protocol;
/** Host, as set by full URI or Host: header.
* For literal IPv6 addresses, this does NOT include the surrounding [ ]
*/
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.
*/
/** M_GET, M_POST, etc. */
int method_number;
/** Request method (eg. GET, HEAD, POST, etc.) */
const char *method;
/**
* '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 */
/** The Range: header */
const char *range;
/** The "real" content length */
apr_off_t clength;
/** sending chunked transfer-coding */
int chunked;
/** 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;
/** The optional kept body of the request. */
apr_bucket_brigade *kept_body;
/** For ap_body_to_table(): parsed body */
/* XXX: ap_body_to_table has been removed. Remove body_table too or
* XXX: keep it to reintroduce ap_body_to_table without major bump? */
apr_table_t *body_table;
/** 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;
/* 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;
/* 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;
/** The true filename stored in the filesystem, as in the true alpha case
* and alias correction, e.g. "Image.jpeg" not "IMAGE$1.JPE" on Windows.
* The core map_to_storage canonicalizes r->filename when they mismatch */
char *canonical_filename;
/** The PATH_INFO extracted from this request */
char *path_info;
/** The QUERY_ARGS extracted from this request */
char *args;
/**
* 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;
/** A flag to determine if the eos bucket has been sent yet */
int eos_sent;
/* 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;
/** Optional request log level configuration. Will usually point
* to a server or per_dir config, i.e. must be copied before
* modifying */
const struct ap_logconf *log;
/** Id to identify request in access and error log. Set when the first
* error log entry for this request is generated.
*/
const char *log_id;
/**
* 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;
/** This response can not be cached */
int no_cache;
/** There is no local copy of this response */
int no_local_copy;
/** Mutex protect callbacks registered with ap_mpm_register_timed_callback
* from being run before the original handler finishes running
*/
apr_thread_mutex_t *invoke_mtx;
/** A struct containing the components of URI */
apr_uri_t parsed_uri;
/** finfo.protection (st_mode) set to zero if no such file */
apr_finfo_t finfo;
/** remote address information from conn_rec, can be overridden if
* necessary by a module.
* This is the address that originated the request.
*/
apr_sockaddr_t *useragent_addr;
char *useragent_ip;
/** MIME trailer environment from the request */
apr_table_t *trailers_in;
/** MIME trailer environment from the response */
apr_table_t *trailers_out;
/** Originator'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
* ap_get_useragent_host() */
char *useragent_host;
/** have we done double-reverse DNS? -1 yes/failure, 0 not yet,
* 1 yes/success
*/
int double_reverse;
/** Request flags associated with this request. Use
* AP_REQUEST_GET_BNOTE() and AP_REQUEST_SET_BNOTE() to access
* the elements of this field.
*/
ap_request_bnotes_t bnotes;
};
/**
* @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 */
/* @} */
/**
* @brief Enumeration of connection keepalive options
*/
typedef enum {
AP_CONN_UNKNOWN,
AP_CONN_CLOSE,
AP_CONN_KEEPALIVE
} ap_conn_keepalive_e;
/**
* @brief 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; this is the end-point of the next hop, for the address
* of the request creator, see useragent_addr in request_rec
*/
apr_sockaddr_t *client_addr;
/** Client's IP address; this is the end-point of the next hop, for the
* IP of the request creator, see useragent_ip in request_rec
*/
char *client_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;
/** 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;
/** The current state of this connection; may be NULL if not used by MPM */
conn_state_t *cs;
/** Is there data pending in the input filters? */
int data_in_input_filters;
/** Is there data pending in the output filters? */
int data_in_output_filters;
/** Are there any filters that clogg/buffer the input stream, breaking
* the event mpm.
*/
unsigned int clogging_input_filters:1;
/** have we done double-reverse DNS? -1 yes/failure, 0 not yet,
* 1 yes/success */
signed int double_reverse:2;
/** Are we still talking? */
unsigned aborted;
/** Are we going to keep the connection alive for another request?
* @see ap_conn_keepalive_e */
ap_conn_keepalive_e keepalive;
/** How many times have we used it? */
int keepalives;
/** Optional connection log level configuration. May point to a server or
* per_dir config, i.e. must be copied before modifying */
const struct ap_logconf *log;
/** Id to identify this connection in error log. Set when the first
* error log entry for this connection is generated.
*/
const char *log_id;
/** This points to the current thread being used to process this request,
* over the lifetime of a request, the value may change. Users of the connection
* record should not rely upon it staying the same between calls that involve
* the MPM.
*/
#if APR_HAS_THREADS
apr_thread_t *current_thread;
#endif
/** The "real" master connection. NULL if I am the master. */
conn_rec *master;
int outgoing;
};
/**
* Enumeration of connection states
* The two states CONN_STATE_LINGER_NORMAL and CONN_STATE_LINGER_SHORT may
* only be set by the MPM. Use CONN_STATE_LINGER outside of the MPM.
*/
typedef enum {
CONN_STATE_KEEPALIVE, /* Kept alive in the MPM (using KeepAliveTimeout) */
CONN_STATE_PROCESSING, /* Processed by process_connection hooks */
CONN_STATE_HANDLER, /* Processed by the modules handlers */
CONN_STATE_WRITE_COMPLETION, /* Flushed by the MPM before entering CONN_STATE_KEEPALIVE */
CONN_STATE_SUSPENDED, /* Suspended in the MPM until ap_run_resume_suspended() */
CONN_STATE_LINGER, /* MPM flushes then closes the connection with lingering */
CONN_STATE_LINGER_NORMAL, /* MPM has started lingering close with normal timeout */
CONN_STATE_LINGER_SHORT, /* MPM has started lingering close with short timeout */
CONN_STATE_ASYNC_WAITIO, /* Returning this state to the MPM will make it wait for
* the connection to be readable or writable according to
* c->cs->sense (resp. CONN_SENSE_WANT_READ or _WRITE),
* using the configured Timeout */
CONN_STATE_NUM, /* Number of states (keep here before aliases) */
/* Aliases (legacy) */
CONN_STATE_CHECK_REQUEST_LINE_READABLE = CONN_STATE_KEEPALIVE,
CONN_STATE_READ_REQUEST_LINE = CONN_STATE_PROCESSING,
} conn_state_e;
typedef enum {
CONN_SENSE_DEFAULT,
CONN_SENSE_WANT_READ, /* next event must be read */
CONN_SENSE_WANT_WRITE /* next event must be write */
} conn_sense_e;
/**
* @brief A structure to contain connection state information
*/
struct conn_state_t {
/** Current state of the connection */
conn_state_e state;
/** Whether to read instead of write, or write instead of read */
conn_sense_e sense;
};
/* 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
/**
* @struct server_addr_rec
* @brief 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 name given in "<VirtualHost>" */
char *virthost;
/** The bound address, for this server */
apr_sockaddr_t *host_addr;
/** The bound port, for this server */
apr_port_t host_port;
};
struct ap_logconf {
/** The per-module log levels */
signed char *module_levels;
/** The log level for this server */
int level;
};
/**
* @brief 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;
/* 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 configuration */
struct ap_logconf log;
/* Module-specific configuration for server, and defaults... */
/** 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;
/** The path to the config file that the server was defined in */
const char *defn_name;
/** The line of the config file that the server was defined on */
unsigned defn_line_number;
/** true if this is the virtual server */
char is_virtual;
/* Information for redirects */
/** for redirects, etc. */
apr_port_t port;
/** The server request scheme for redirect responses */
const char *server_scheme;
/* Contact information */
/** The admin's contact information */
char *server_admin;
/** The server hostname */
char *server_hostname;
/* 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;
/** Normal names for ServerAlias servers */
apr_array_header_t *names;
/** Wildcarded names for ServerAlias servers */
apr_array_header_t *wild_names;
/** Pathname for ServerPath */
const char *path;
/** Length of path */
int pathlen;
/** 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;
/** Opaque storage location */
void *context;
/** Whether the keepalive timeout is explicit (1) or
* inherited (0) from the base server (either first
* server on the same IP:port or main server) */
unsigned int keep_alive_timeout_set:1;
};
/**
* @struct ap_sload_t
* @brief A structure to hold server load params
*/
typedef struct ap_sload_t ap_sload_t;
struct ap_sload_t {
/* percentage of process/threads ready/idle (0->100)*/
int idle;
/* percentage of process/threads busy (0->100) */
int busy;
/* total bytes served */
apr_off_t bytes_served;
/* total access count */
unsigned long access_count;
};
/**
* @struct ap_loadavg_t
* @brief A structure to hold various server loadavg
*/
typedef struct ap_loadavg_t ap_loadavg_t;
struct ap_loadavg_t {
/* current loadavg, ala getloadavg() */
float loadavg;
/* 5 min loadavg */
float loadavg5;
/* 15 min loadavg */
float loadavg15;
};
/**
* Get the context_document_root for a request. This is a generalization of
* the document root, which is too limited in the presence of mappers like
* mod_userdir and mod_alias. The context_document_root is the directory
* on disk that maps to the context_prefix URI prefix.
* @param r The request
* @note For resources that do not map to the file system or for very complex
* mappings, this information may still be wrong.
*/
AP_DECLARE(const char *) ap_context_document_root(request_rec *r);
/**
* Get the context_prefix for a request. The context_prefix URI prefix
* maps to the context_document_root on disk.
* @param r The request
*/
AP_DECLARE(const char *) ap_context_prefix(request_rec *r);
/** Set context_prefix and context_document_root for a request.
* @param r The request
* @param prefix the URI prefix, without trailing slash
* @param document_root the corresponding directory on disk, without trailing
* slash
* @note If one of prefix of document_root is NULL, the corrsponding
* property will not be changed.
*/
AP_DECLARE(void) ap_set_context_info(request_rec *r, const char *prefix,
const char *document_root);
/** Set per-request document root. This is for mass virtual hosting modules
* that want to provide the correct DOCUMENT_ROOT value to scripts.
* @param r The request
* @param document_root the document root for the request.
*/
AP_DECLARE(void) ap_set_document_root(request_rec *r, const char *document_root);
/**
* 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 occurrence 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 occurrence 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 occurrence 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 characters after the first occurrence 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 occurrence 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 characters after the first occurrence 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);
/**
* Get the second word in the string paying attention to quoting,
* with {...} supported as well as "..." and '...'
* @param p The pool to allocate from
* @param line The line to traverse
* @return A copy of the string
*/
AP_DECLARE(char *) ap_getword_conf2(apr_pool_t *p, const char **line);
/**
* Get the second word in the string paying attention to quoting,
* with {...} supported as well as "..." and '...'
* @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_conf2(), except it doesn't use const char **.
*/
AP_DECLARE(char *) ap_getword_conf2_nc(apr_pool_t *p, char **line);
/**
* Check a string for any config define or environment variable construct
* and replace each of them by the value of that variable, if it exists.
* The default syntax of the constructs is ${ENV} but can be changed by
* setting the define::* config defines. If the variable does not exist,
* leave the ${ENV} construct alone but print a warning.
* @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);
/**
* Do a weak ETag comparison 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_etag_weak(apr_pool_t *p, const char *line, const char *tok);
/**
* Do a strong ETag comparison 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_etag_strong(apr_pool_t *p, const char *line, const char *tok);
/* Scan a string for field content chars, as defined by RFC7230 section 3.2
* including VCHAR/obs-text, as well as HT and SP
* @param ptr The string to scan
* @return A pointer to the first (non-HT) ASCII ctrl character.
* @note lws and trailing whitespace are scanned, the caller is responsible
* for trimming leading and trailing whitespace
*/
AP_DECLARE(const char *) ap_scan_http_field_content(const char *ptr);
/* Scan a string for token characters, as defined by RFC7230 section 3.2.6
* @param ptr The string to scan
* @return A pointer to the first non-token character.
*/
AP_DECLARE(const char *) ap_scan_http_token(const char *ptr);
/* Scan a string for visible ASCII (0x21-0x7E) or obstext (0x80+)
* and return a pointer to the first SP/CTL/NUL character encountered.
* @param ptr The string to scan
* @return A pointer to the first SP/CTL character.
*/
AP_DECLARE(const char *) ap_scan_vchar_obstext(const char *ptr);
/**
* Retrieve an array of tokens in the format "1#token" defined in RFC2616. Only
* accepts ',' as a delimiter, does not accept quoted strings, and errors on
* any separator.
* @param p The pool to allocate from
* @param tok The line to read tokens from
* @param tokens Pointer to an array of tokens. If not NULL, must be an array
* of char*, otherwise it will be allocated on @a p when a token is found
* @param skip_invalid If true, when an invalid separator is encountered, it
* will be ignored.
* @return NULL on success, an error string otherwise.
* @remark *tokens may be NULL on output if NULL in input and no token is found
*/
AP_DECLARE(const char *) ap_parse_token_list_strict(apr_pool_t *p, const char *tok,
apr_array_header_t **tokens,
int skip_invalid);
/**
* Retrieve a token, spacing over it and adjusting the 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 (adjusted afterwards)
* @param accept_white Is it delimited by whitespace
* @return 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 string
* @param url The string to unescape
* @return 0 on success, non-zero otherwise
*/
AP_DECLARE(int) ap_unescape_all(char *url);
/**
* 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
* @param decode_slashes Whether or not slashes should be decoded
* @return 0 on success, non-zero otherwise
*/
AP_DECLARE(int) ap_unescape_url_keep2f(char *url, int decode_slashes);
#define AP_UNESCAPE_URL_KEEP_UNRESERVED (1u << 0)
#define AP_UNESCAPE_URL_FORBID_SLASHES (1u << 1)
#define AP_UNESCAPE_URL_KEEP_SLASHES (1u << 2)
/**
* Unescape a URL, with options
* @param url The url to unescape
* @param flags Bitmask of AP_UNESCAPE_URL_* flags
* @return 0 on success, non-zero otherwise
*/
AP_DECLARE(int) ap_unescape_url_ex(char *url, unsigned int flags);
/**
* Unescape an application/x-www-form-urlencoded string
* @param query The query to unescape
* @return 0 on success, non-zero otherwise
*/
AP_DECLARE(int) ap_unescape_urlencoded(char *query);
/**
* Convert all double slashes to single slashes, except where significant
* to the filesystem on the current platform.
* @param name The string to convert, assumed to be a filesystem path
*/
AP_DECLARE(void) ap_no2slash(char *name);
/**
* Convert all double slashes to single slashes, except where significant
* to the filesystem on the current platform.
* @param name The string to convert
* @param is_fs_path if set to 0, the significance of any double-slashes is
* ignored.
*/
AP_DECLARE(void) ap_no2slash_ex(char *name, int is_fs_path);
#define AP_NORMALIZE_ALLOW_RELATIVE (1u << 0)
#define AP_NORMALIZE_NOT_ABOVE_ROOT (1u << 1)
#define AP_NORMALIZE_DECODE_UNRESERVED (1u << 2)
#define AP_NORMALIZE_MERGE_SLASHES (1u << 3)
#define AP_NORMALIZE_DROP_PARAMETERS (0) /* deprecated */
/**
* Remove all ////, /./ and /xx/../ substrings from a path, and more
* depending on passed in flags.
* @param path The path to normalize
* @param flags bitmask of AP_NORMALIZE_* flags
* @return non-zero on success
*/
AP_DECLARE(int) ap_normalize_path(char *path, unsigned int flags);
/**
* 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);
/**
* Escape a path segment, as defined in RFC 1808, to a preallocated buffer.
* @param c The preallocated buffer to write to
* @param s The path to convert
* @return The converted URL (c)
*/
AP_DECLARE(char *) ap_escape_path_segment_buffer(char *c, const char *s);
/**
* convert an OS path to a URL in an OS dependent 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 a string as application/x-www-form-urlencoded
* @param p The pool to allocate from
* @param s The path to convert
* @return The converted URL
*/
AP_DECLARE(char *) ap_escape_urlencoded(apr_pool_t *p, const char *s);
/**
* Escape a string as application/x-www-form-urlencoded, to a preallocated buffer
* @param c The preallocated buffer to write to
* @param s The path to convert
* @return The converted URL (c)
*/
AP_DECLARE(char *) ap_escape_urlencoded_buffer(char *c, const char *s);
/**
* Escape an html string
* @param p The pool to allocate from
* @param s The html to escape
* @return The escaped string
*/
#define ap_escape_html(p,s) ap_escape_html2(p,s,0)
/**
* Escape an html string
* @param p The pool to allocate from
* @param s The html to escape
* @param toasc Whether to escape all non-ASCII chars to \&\#nnn;
* @return The escaped string
*/
AP_DECLARE(char *) ap_escape_html2(apr_pool_t *p, const char *s, int toasc);
/**
* 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 single '/' 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
* @note 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 absolute path.
* @param p The pool to allocate from
* @param dir The directory name
* @note 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 pattern containing the wildcards '?' or '*'
* @param str The string to check
* @param expected The pattern to match against
* @return 0 if the two strings match, 1 otherwise
*/
AP_DECLARE(int) ap_strcmp_match(const char *str, const char *expected);
/**
* Determine if a string matches a pattern containing the wildcards '?' or '*',
* ignoring case
* @param str The string to check
* @param expected The pattern to match against
* @return 0 if the two strings match, 1 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 string 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. The regex is freed when
* the pool is destroyed.
* @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(ap_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
* @note This function is only necessary if the regex should be cleaned
* up before the pool
*/
AP_DECLARE(void) ap_pregfree(apr_pool_t *p, ap_regex_t *reg);
/**
* 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. This function is limited to
* result strings of 64K. Consider using ap_pregsub_ex() instead.
* @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
* @return The substituted string, or NULL on error
*/
AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
const char *source, apr_size_t nmatch,
ap_regmatch_t pmatch[]);
/**
* 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 result where to store the result, will be set to NULL on error
* @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
* @param maxlen the maximum string length to return, 0 for unlimited
* @return APR_SUCCESS if successful, APR_ENOMEM or other error code otherwise.
*/
AP_DECLARE(apr_status_t) ap_pregsub_ex(apr_pool_t *p, char **result,
const char *input, const char *source,
apr_size_t nmatch,
ap_regmatch_t pmatch[],
apr_size_t maxlen);
/**
* 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);
/**
* convert a string to all uppercase
* @param s The string to convert to uppercase
*/
AP_DECLARE(void) ap_str_toupper(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);
/**
* Given a string, append the PID deliminated by delim.
* Usually used to create a pid-appended filepath name
* (eg: /a/b/foo -> /a/b/foo.6726). A function, and not
* a macro, to avoid unistd.h dependency
* @param p The pool to allocate memory from
* @param string The string to append the PID to
* @param delim The string to use to deliminate the string from the PID
* @return A copy of the string with the PID appended
*/
AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
const char *delim);
/**
* Parse a length string with decimal characters only, no leading sign nor
* trailing character, like Content-Length or (Content-)Range headers.
* @param len The parsed length (apr_off_t)
* @param str The string to parse
* @return 1 (success), 0 (failure)
*/
AP_DECLARE(int) ap_parse_strict_length(apr_off_t *len, const char *str);
/**
* Parse a given timeout parameter string into an apr_interval_time_t value.
* The unit of the time interval is given as postfix string to the numeric
* string. Currently the following units are understood:
*
* ms : milliseconds
* s : seconds
* mi[n] : minutes
* h : hours
*
* If no unit is contained in the given timeout parameter the default_time_unit
* will be used instead.
* @param timeout_parameter The string containing the timeout parameter.
* @param timeout The timeout value to be returned.
* @param default_time_unit The default time unit to use if none is specified
* in timeout_parameter.
* @return Status value indicating whether the parsing was successful or not.
*/
AP_DECLARE(apr_status_t) ap_timeout_parameter_parse(
const char *timeout_parameter,
apr_interval_time_t *timeout,
const char *default_time_unit);
/**
* Determine if a request has a request body or not.
*
* @param r the request_rec of the request
* @return truth value
*/
AP_DECLARE(int) ap_request_has_body(request_rec *r);
/**
* Cleanup a string (mainly to be filesystem safe)
* We only allow '_' and alphanumeric chars. Non-printable
* map to 'x' and all others map to '_'
*
* @param p pool to use to allocate dest
* @param src string to clean up
* @param dest cleaned up, allocated string
* @return Status value indicating whether the cleaning was successful or not.
*/
AP_DECLARE(apr_status_t) ap_pstr2_alnum(apr_pool_t *p, const char *src,
const char **dest);
/**
* Cleanup a string (mainly to be filesystem safe)
* We only allow '_' and alphanumeric chars. Non-printable
* map to 'x' and all others map to '_'
*
* @param src string to clean up
* @param dest cleaned up, pre-allocated string
* @return Status value indicating whether the cleaning was successful or not.
*/
AP_DECLARE(apr_status_t) ap_str2_alnum(const char *src, char *dest);
/**
* Structure to store the contents of an HTTP form of the type
* application/x-www-form-urlencoded.
*
* Currently it contains the name as a char* of maximum length
* HUGE_STRING_LEN, and a value in the form of a bucket brigade
* of arbitrary length.
*/
typedef struct {
const char *name;
apr_bucket_brigade *value;
} ap_form_pair_t;
/**
* Read the body and parse any form found, which must be of the
* type application/x-www-form-urlencoded.
* @param r request containing POSTed form data
* @param f filter
* @param ptr returned array of ap_form_pair_t
* @param num max num of params or -1 for unlimited
* @param size max size allowed for parsed data
* @return OK or HTTP error
*/
AP_DECLARE(int) ap_parse_form_data(request_rec *r, struct ap_filter_t *f,
apr_array_header_t **ptr,
apr_size_t num, apr_size_t size);
/* 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 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 Internal Assert function
*/
#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 server 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);
/* 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 <string.h>
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
/**
* Generate pseudo random bytes.
* This is a convenience interface to apr_random. It is cheaper but less
* secure than apr_generate_random_bytes().
* @param buf where to store the bytes
* @param size number of bytes to generate
* @note ap_random_insecure_bytes() is thread-safe, it uses a mutex on
* threaded MPMs.
*/
AP_DECLARE(void) ap_random_insecure_bytes(void *buf, apr_size_t size);
/**
* Get a pseudo random number in a range.
* @param min low end of range
* @param max high end of range
* @return a number in the range
*/
AP_DECLARE(apr_uint32_t) ap_random_pick(apr_uint32_t min, apr_uint32_t max);
/**
* Abort with a error message signifying out of memory
*/
AP_DECLARE(void) ap_abort_on_oom(void) __attribute__((noreturn));
/**
* Wrapper for malloc() that calls ap_abort_on_oom() if out of memory
* @param size size of the memory block
* @return pointer to the allocated memory
* @note ap_malloc may be implemented as a macro
*/
AP_DECLARE(void *) ap_malloc(size_t size)
__attribute__((malloc))
AP_FN_ATTR_ALLOC_SIZE(1);
/**
* Wrapper for calloc() that calls ap_abort_on_oom() if out of memory
* @param nelem number of elements to allocate memory for
* @param size size of a single element
* @return pointer to the allocated memory
* @note ap_calloc may be implemented as a macro
*/
AP_DECLARE(void *) ap_calloc(size_t nelem, size_t size)
__attribute__((malloc))
AP_FN_ATTR_ALLOC_SIZE2(1,2);
/**
* Wrapper for realloc() that calls ap_abort_on_oom() if out of memory
* @param ptr pointer to the old memory block (or NULL)
* @param size new size of the memory block
* @return pointer to the reallocated memory
* @note ap_realloc may be implemented as a macro
*/
AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
AP_FN_ATTR_WARN_UNUSED_RESULT
AP_FN_ATTR_ALLOC_SIZE(2);
#if APR_HAS_THREADS
#if APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL)
/**
* APR 1.8+ implement those already.
*/
#if APR_HAS_THREAD_LOCAL
#define AP_HAS_THREAD_LOCAL 1
#define AP_THREAD_LOCAL APR_THREAD_LOCAL
#else
#define AP_HAS_THREAD_LOCAL 0
#endif
#define ap_thread_create apr_thread_create
#define ap_thread_current apr_thread_current
#define ap_thread_current_create apr_thread_current_create
#define ap_thread_current_after_fork apr_thread_current_after_fork
#else /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
#ifndef AP_NO_THREAD_LOCAL
/**
* AP_THREAD_LOCAL keyword mapping the compiler's.
*/
#if defined(__cplusplus) && __cplusplus >= 201103L
#define AP_THREAD_LOCAL thread_local
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 && \
(!defined(__GNUC__) || \
__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9))
#define AP_THREAD_LOCAL _Thread_local
#elif defined(__GNUC__) /* works for clang too */
#define AP_THREAD_LOCAL __thread
#elif defined(WIN32) && defined(_MSC_VER)
#define AP_THREAD_LOCAL __declspec(thread)
#endif
#endif /* ndef AP_NO_THREAD_LOCAL */
#ifndef AP_THREAD_LOCAL
#define AP_HAS_THREAD_LOCAL 0
#define ap_thread_create apr_thread_create
#else /* AP_THREAD_LOCAL */
#define AP_HAS_THREAD_LOCAL 1
AP_DECLARE(apr_status_t) ap_thread_create(apr_thread_t **thread,
apr_threadattr_t *attr,
apr_thread_start_t func,
void *data, apr_pool_t *pool);
#endif /* AP_THREAD_LOCAL */
AP_DECLARE(apr_status_t) ap_thread_current_create(apr_thread_t **current,
apr_threadattr_t *attr,
apr_pool_t *pool);
AP_DECLARE(void) ap_thread_current_after_fork(void);
AP_DECLARE(apr_thread_t *) ap_thread_current(void);
#endif /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
AP_DECLARE(apr_status_t) ap_thread_main_create(apr_thread_t **thread,
apr_pool_t *pool);
#else /* APR_HAS_THREADS */
#define AP_HAS_THREAD_LOCAL 0
#endif /* APR_HAS_THREADS */
/**
* Get server load params
* @param ld struct to populate: -1 in fields means error
*/
AP_DECLARE(void) ap_get_sload(ap_sload_t *ld);
/**
* Get server load averages (ala getloadavg)
* @param ld struct to populate: -1 in fields means error
*/
AP_DECLARE(void) ap_get_loadavg(ap_loadavg_t *ld);
/**
* Convert binary data into a hex string
* @param src pointer to the data
* @param srclen length of the data
* @param dest pointer to buffer of length (2 * srclen + 1). The resulting
* string will be NUL-terminated.
*/
AP_DECLARE(void) ap_bin2hex(const void *src, apr_size_t srclen, char *dest);
/**
* Short function to execute a command and return the first line of
* output minus \\r \\n. Useful for "obscuring" passwords via exec calls
* @param p the pool to allocate from
* @param cmd the command to execute
* @param argv the arguments to pass to the cmd
* @return ptr to characters or NULL on any error
*/
AP_DECLARE(char *) ap_get_exec_line(apr_pool_t *p,
const char *cmd,
const char * const *argv);
#define AP_NORESTART APR_OS_START_USEERR + 1
/**
* Get the first index of the string in the array or -1 if not found. Start
* searching a start.
* @param array The array the check
* @param s The string to find
* @param start Start index for search. If start is out of bounds (negative or
equal to array length or greater), -1 will be returned.
* @return index of string in array or -1
*/
AP_DECLARE(int) ap_array_str_index(const apr_array_header_t *array,
const char *s,
int start);
/**
* Check if the string is member of the given array by strcmp.
* @param array The array the check
* @param s The string to find
* @return !=0 iff string is member of array (via strcmp)
*/
AP_DECLARE(int) ap_array_str_contains(const apr_array_header_t *array,
const char *s);
/**
* Perform a case-insensitive comparison of two strings @a str1 and @a str2,
* treating upper and lower case values of the 26 standard C/POSIX alphabetic
* characters as equivalent. Extended latin characters outside of this set
* are treated as unique octets, irrespective of the current locale.
*
* Returns in integer greater than, equal to, or less than 0,
* according to whether @a str1 is considered greater than, equal to,
* or less than @a str2.
*
* @note Same code as apr_cstr_casecmp, which arrives in APR 1.6
*/
AP_DECLARE(int) ap_cstr_casecmp(const char *s1, const char *s2);
/**
* Perform a case-insensitive comparison of two strings @a str1 and @a str2,
* treating upper and lower case values of the 26 standard C/POSIX alphabetic
* characters as equivalent. Extended latin characters outside of this set
* are treated as unique octets, irrespective of the current locale.
*
* Returns in integer greater than, equal to, or less than 0,
* according to whether @a str1 is considered greater than, equal to,
* or less than @a str2.
*
* @note Same code as apr_cstr_casecmpn, which arrives in APR 1.6
*/
AP_DECLARE(int) ap_cstr_casecmpn(const char *s1, const char *s2, apr_size_t n);
/**
* Default flags for ap_dir_*fnmatch().
*/
#define AP_DIR_FLAG_NONE 0
/**
* If set, wildcards that match no files or directories will be ignored, otherwise
* an error is triggered.
*/
#define AP_DIR_FLAG_OPTIONAL 1
/**
* If set, and the wildcard resolves to a directory, recursively find all files
* below that directory, otherwise return the directory.
*/
#define AP_DIR_FLAG_RECURSIVE 2
/**
* Structure to provide the state of a directory match.
*/
typedef struct ap_dir_match_t ap_dir_match_t;
/**
* Concrete structure to provide the state of a directory match.
*/
struct ap_dir_match_t {
/** Pool to use for allocating the result */
apr_pool_t *p;
/** Temporary pool used for directory traversal */
apr_pool_t *ptemp;
/** Prefix for log messages */
const char *prefix;
/** Callback for each file found that matches the wildcard. Return NULL on success, an error string on error. */
const char *(*cb)(ap_dir_match_t *w, const char *fname);
/** Context for the callback */
void *ctx;
/** Flags to indicate whether optional or recursive */
int flags;
/** Recursion depth safety check */
unsigned int depth;
};
/**
* Search for files given a non wildcard filename with non native separators.
*
* If the provided filename points at a file, the callback within ap_dir_match_t is
* triggered for that file, and this function returns the result of the callback.
*
* If the provided filename points at a directory, and recursive within ap_dir_match_t
* is true, the callback will be triggered for every file found recursively beneath
* that directory, otherwise the callback is triggered once for the directory itself.
* This function returns the result of the callback.
*
* If the provided path points to neither a file nor a directory, and optional within
* ap_dir_match_t is true, this function returns NULL. If optional within ap_dir_match_t
* is false, this function will return an error string indicating that the path does not
* exist.
*
* @param w Directory match structure containing callback and context.
* @param fname The name of the file or directory, with non native separators.
* @return NULL on success, or a string describing the error.
*/
AP_DECLARE(const char *)ap_dir_nofnmatch(ap_dir_match_t *w, const char *fname)
__attribute__((nonnull(1,2)));
/**
* Search for files given a wildcard filename with non native separators.
*
* If the filename contains a wildcard, all files and directories that match the wildcard
* will be returned.
*
* ap_dir_nofnmatch() is called for each directory and file found, and the callback
* within ap_dir_match_t triggered as described above.
*
* Wildcards may appear in both directory and file components in the path, and
* wildcards may appear more than once.
*
* @param w Directory match structure containing callback and context.
* @param path Path prefix for search, with non native separators and no wildcards.
* @param fname The name of the file or directory, with non native separators and
* optional wildcards.
* @return NULL on success, or a string describing the error.
*/
AP_DECLARE(const char *)ap_dir_fnmatch(ap_dir_match_t *w, const char *path,
const char *fname) __attribute__((nonnull(1,3)));
/**
* Determine if the final Transfer-Encoding is "chunked".
*
* @param p The pool to allocate from
* @param line the header field-value to scan
* @return 1 if the last Transfer-Encoding is "chunked", else 0
*/
AP_DECLARE(int) ap_is_chunked(apr_pool_t *p, const char *line);
/**
* apr_filepath_merge with an allow-list
* 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.
*/
AP_DECLARE(apr_status_t) ap_filepath_merge(char **newpath,
const char *rootpath,
const char *addpath,
apr_int32_t flags,
apr_pool_t *p);
#ifdef WIN32
#define apr_filepath_merge ap_filepath_merge
#endif
/* Win32/NetWare/OS2 need to check for both forward and back slashes
* in ap_normalize_path() and ap_escape_url().
*/
#ifdef CASE_BLIND_FILESYSTEM
#define AP_IS_SLASH(s) ((s == '/') || (s == '\\'))
#define AP_SLASHES "/\\"
#else
#define AP_IS_SLASH(s) (s == '/')
#define AP_SLASHES "/"
#endif
/**
* Validates the path parameter is safe to pass to stat-like calls.
* @param path The filesystem path to cehck
* @param p a pool for temporary allocations
* @return APR_SUCCESS if the stat-like call should be allowed
*/
AP_DECLARE(apr_status_t) ap_stat_check(const char *path, apr_pool_t *pool);
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_HTTPD_H */
/** @} //APACHE Daemon */
/** @} //APACHE Core */
/** @} //APACHE super group */
PK �c�\Ѷ�a* * ap_mpm.hnu �[��� /* 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.
*/
/**
* @file ap_mpm.h
* @brief Apache Multi-Processing Module library
*
* @defgroup APACHE_CORE_MPM Multi-Processing Module library
* @ingroup APACHE_CORE
* @{
*/
#ifndef AP_MPM_H
#define AP_MPM_H
#include "apr_thread_proc.h"
#include "httpd.h"
#include "scoreboard.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
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
*/
/**
* Pass control to the MPM for steady-state processing. It 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 DONE for shutdown OK otherwise.
* @ingroup hooks
*/
AP_DECLARE_HOOK(int, mpm, (apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf))
/**
* 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 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);
/** @defgroup mpmq MPM query
* @{
*/
/** @defgroup thrdfrk Subtypes/Values returned for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED
* @ingroup mpmq
* @{
*/
#define AP_MPMQ_NOT_SUPPORTED 0 /**< This value specifies that an
* MPM is not capable of
* threading or forking. */
#define AP_MPMQ_STATIC 1 /**< This value specifies that
* an MPM is using a static
* number of threads or daemons */
#define AP_MPMQ_DYNAMIC 2 /**< This value specifies that
* an MPM is using a dynamic
* number of threads or daemons */
/** @} */
/** @defgroup qstate Values returned for AP_MPMQ_MPM_STATE
* @ingroup mpmq
* @{
*/
#define AP_MPMQ_STARTING 0
#define AP_MPMQ_RUNNING 1
#define AP_MPMQ_STOPPING 2
/** @} */
/** @defgroup qcodes Query codes for ap_mpm_query()
* @ingroup mpmq
* @{
*/
/** Max # of daemons used so far */
#define AP_MPMQ_MAX_DAEMON_USED 1
/** MPM can do threading */
#define AP_MPMQ_IS_THREADED 2
/** MPM can do forking */
#define AP_MPMQ_IS_FORKED 3
/** The compiled max # daemons */
#define AP_MPMQ_HARD_LIMIT_DAEMONS 4
/** The compiled max # threads */
#define AP_MPMQ_HARD_LIMIT_THREADS 5
/** \# of threads/child by config */
#define AP_MPMQ_MAX_THREADS 6
/** Min # of spare daemons */
#define AP_MPMQ_MIN_SPARE_DAEMONS 7
/** Min # of spare threads */
#define AP_MPMQ_MIN_SPARE_THREADS 8
/** Max # of spare daemons */
#define AP_MPMQ_MAX_SPARE_DAEMONS 9
/** Max # of spare threads */
#define AP_MPMQ_MAX_SPARE_THREADS 10
/** Max # of requests per daemon */
#define AP_MPMQ_MAX_REQUESTS_DAEMON 11
/** Max # of daemons by config */
#define AP_MPMQ_MAX_DAEMONS 12
/** starting, running, stopping */
#define AP_MPMQ_MPM_STATE 13
/** MPM can process async connections */
#define AP_MPMQ_IS_ASYNC 14
/** MPM generation */
#define AP_MPMQ_GENERATION 15
/** MPM can drive serf internally */
#define AP_MPMQ_HAS_SERF 16
/* 17-18 are trunk only */
/** MPM supports CONN_STATE_ASYNC_WAITIO */
#define AP_MPMQ_CAN_WAITIO 19
/** @} */
/**
* Query a property of the current MPM.
* @param query_code One of AP_MPMQ_*
* @param result A location to place the result of the query
* @return APR_EGENERAL if an mpm-query hook has not been registered;
* APR_SUCCESS or APR_ENOTIMPL otherwise
* @remark The MPM doesn't register the implementing hook until the
* register_hooks hook is called, so modules cannot use ap_mpm_query()
* until after that point.
* @fn int ap_mpm_query(int query_code, int *result)
*/
AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result);
/** @} */
typedef void (ap_mpm_callback_fn_t)(void *baton);
/* only added support in the Event MPM.... check for APR_ENOTIMPL */
AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t,
ap_mpm_callback_fn_t *cbfn,
void *baton);
typedef enum mpm_child_status {
MPM_CHILD_STARTED,
MPM_CHILD_EXITED,
MPM_CHILD_LOST_SLOT
} mpm_child_status;
/**
* Allow a module to remain aware of MPM child process state changes,
* along with the generation and scoreboard slot of the process changing
* state.
*
* With some MPMs (event and worker), an active MPM child process may lose
* its scoreboard slot if the child process is exiting and the scoreboard
* slot is needed by other processes. When this occurs, the hook will be
* called with the MPM_CHILD_LOST_SLOT state.
*
* @param s The main server_rec.
* @param pid The id of the MPM child process.
* @param gen The server generation of that child process.
* @param slot The scoreboard slot number, or -1. It will be -1 when an
* MPM child process exits, and that child had previously lost its
* scoreboard slot.
* @param state One of the mpm_child_status values. Modules should ignore
* unrecognized values.
* @ingroup hooks
*/
AP_DECLARE_HOOK(void,child_status,(server_rec *s, pid_t pid, ap_generation_t gen,
int slot, mpm_child_status state))
/**
* Allow a module to be notified when the last child process of a generation
* exits.
*
* @param s The main server_rec.
* @param gen The server generation which is now completely finished.
* @ingroup hooks
*/
AP_DECLARE_HOOK(void,end_generation,(server_rec *s, ap_generation_t gen))
/* Defining GPROF when compiling uses the moncontrol() function to
* disable gprof profiling in the parent, and enable it only for
* request processing in children (or in one_process mode). It's
* absolutely required to get useful gprof results under linux
* because the profile itimers and such are disabled across a
* fork(). It's probably useful elsewhere as well.
*/
#ifdef GPROF
extern void moncontrol(int);
#define AP_MONCONTROL(x) moncontrol(x)
#else
#define AP_MONCONTROL(x)
#endif
#ifdef AP_ENABLE_EXCEPTION_HOOK
typedef struct ap_exception_info_t {
int sig;
pid_t pid;
} ap_exception_info_t;
/**
* Run the fatal_exception hook for each module; this hook is run
* from some MPMs in the event of a child process crash, if the
* server was built with --enable-exception-hook and the
* EnableExceptionHook directive is On.
* @param ei information about the exception
* @ingroup hooks
*/
AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei))
#endif /*AP_ENABLE_EXCEPTION_HOOK*/
#ifdef __cplusplus
}
#endif
#endif
/** @} */
PK �c�\>�4v� v�
http_config.hnu �[��� /* 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.
*/
/**
* @file http_config.h
* @brief Apache Configuration
*
* @defgroup APACHE_CORE_CONFIG Configuration
* @ingroup APACHE_CORE
* @{
*/
#ifndef APACHE_HTTP_CONFIG_H
#define APACHE_HTTP_CONFIG_H
#include "util_cfgtree.h"
#include "ap_config.h"
#include "apr_tables.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* 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, occurring 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. </Directory> */
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 */
TAKE_ARGV /**< an argc and argv are passed */
};
/**
* 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 argv/argc */
const char *(*take_argv) (cmd_parms *parms, void *mconfig,
int argc, char *const argv[]);
/** 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 its own parsing of arguments*/
# define AP_RAW_ARGS func.raw_args
/** This configuration directive will handle its own parsing of arguments*/
# define AP_TAKE_ARGV func.take_argv
/** 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
/** mechanism for 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 }
/** mechanism for 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 }
/** mechanism for declaring a directive with raw argument parsing */
# define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \
{ directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help }
/** mechanism for declaring a directive which takes 1 argument */
# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
{ directive, { .take1=func }, mconfig, where, TAKE1, help }
/** mechanism for declaring a directive which takes multiple arguments */
# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
{ directive, { .take1=func }, mconfig, where, ITERATE, help }
/** mechanism for declaring a directive which takes 2 arguments */
# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
{ directive, { .take2=func }, mconfig, where, TAKE2, help }
/** mechanism for 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 }
/** mechanism for declaring a directive which takes multiple 2 arguments */
# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
{ directive, { .take2=func }, mconfig, where, ITERATE2, help }
/** mechanism for 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 }
/** mechanism for 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 }
/** mechanism for 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 }
/** mechanism for declaring a directive which takes 3 arguments */
# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
{ directive, { .take3=func }, mconfig, where, TAKE3, help }
/** mechanism for declaring a directive which takes a flag (on/off) 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_TAKE_ARGV 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_TAKE_ARGV(directive, func, mconfig, where, help) \
{ directive, func, mconfig, where, TAKE_ARGV, 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. 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 */
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 <Directory> or <Location>
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 <Directory> or <Location>
and .htaccess when AllowOverride AuthConfig */
#define OR_INDEXES 16 /**< *.conf anywhere
and .htaccess when AllowOverride Indexes */
#define OR_UNSET 32 /**< bit to indicate that AllowOverride has not been set */
#define ACCESS_CONF 64 /**< *.conf inside <Directory> or <Location> */
#define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */
#define EXEC_ON_READ 256 /**< force directive to execute a command
which would modify the configuration (like including another
file, or IFModule */
/* Flags to determine whether syntax errors in .htaccess should be
* treated as nonfatal (log and ignore errors)
*/
#define NONFATAL_OVERRIDE 512 /* Violation of AllowOverride rule */
#define NONFATAL_UNKNOWN 1024 /* Unrecognised directive */
#define NONFATAL_ALL (NONFATAL_OVERRIDE|NONFATAL_UNKNOWN)
#define PROXY_CONF 2048 /**< *.conf inside <Proxy> only */
/** 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 {
/**< an apr_file_getc()-like function */
apr_status_t (*getch) (char *ch, void *param);
/**< an apr_file_gets()-like function */
apr_status_t (*getstr) (void *buf, apr_size_t bufsiz, void *param);
/**< a close handler function */
apr_status_t (*close) (void *param);
/**< the argument passed to getch/getstr/close */
void *param;
/**< the filename / description */
const char *name;
/**< current line number, starting at 1 */
unsigned line_number;
};
/**
* 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 allow-override-opts bits are set */
int override_opts;
/** Table of directives allowed per AllowOverrideList */
apr_table_t *override_list;
/** Which methods are <Limit>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 existence of <Files>,
* <Location> 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;
};
/**
* Flags associated with a module.
*/
#define AP_MODULE_FLAG_NONE (0)
#define AP_MODULE_FLAG_ALWAYS_MERGE (1 << 0)
/**
* 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
* @var 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);
/** A bitmask of AP_MODULE_FLAG_* */
int flags;
};
/**
* The AP_MAYBE_UNUSED macro is used for variable declarations that
* might potentially exhibit "unused var" warnings on some compilers if
* left untreated.
* Since static intializers are not part of the C language (C89), making
* (void) usage is not possible. However many compiler have proprietary
* mechanism to suppress those warnings.
*/
#ifdef AP_MAYBE_UNUSED
#elif defined(__GNUC__)
# define AP_MAYBE_UNUSED(x) x __attribute__((unused))
#elif defined(__LCLINT__)
# define AP_MAYBE_UNUSED(x) /*@unused@*/ x
#else
# define AP_MAYBE_UNUSED(x) x
#endif
/**
* The APLOG_USE_MODULE macro is used choose which module a file belongs to.
* This is necessary to allow per-module loglevel configuration.
*
* APLOG_USE_MODULE indirectly sets APLOG_MODULE_INDEX and APLOG_MARK.
*
* If a module should be backward compatible with versions before 2.3.6,
* APLOG_USE_MODULE needs to be enclosed in a ifdef APLOG_USE_MODULE block.
*
* @param foo name of the module symbol of the current module, without the
* trailing "_module" part
* @see APLOG_MARK
*/
#define APLOG_USE_MODULE(foo) \
extern module AP_MODULE_DECLARE_DATA foo##_module; \
AP_MAYBE_UNUSED(static int * const aplog_module_index) = &(foo##_module.module_index)
/**
* AP_DECLARE_MODULE is a convenience macro that combines a call of
* APLOG_USE_MODULE with the definition of the module symbol.
*
* If a module should be backward compatible with versions before 2.3.6,
* APLOG_USE_MODULE should be used explicitly instead of AP_DECLARE_MODULE.
*/
#define AP_DECLARE_MODULE(foo) \
APLOG_USE_MODULE(foo); \
module AP_MODULE_DECLARE_DATA foo##_module
/**
* @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 cv 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 their own module-specific
* data
* @param cv 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);
/**
* When module flags have been introduced, and a way to check this.
*/
#define AP_MODULE_FLAGS_MMN_MAJOR 20120211
#define AP_MODULE_FLAGS_MMN_MINOR 70
#define AP_MODULE_HAS_FLAGS(m) \
AP_MODULE_MAGIC_AT_LEAST(AP_MODULE_FLAGS_MMN_MAJOR, \
AP_MODULE_FLAGS_MMN_MINOR)
/**
* Generic accessor for the module's flags
* @param m The module to get the flags from.
* @return The module-specific flags
*/
AP_DECLARE(int) ap_get_module_flags(const module *m);
#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 accessor for modules to get the module-specific loglevel
* @param s The server from which to get the loglevel.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index);
/**
* Generic accessor for modules the module-specific loglevel
* @param c The connection from which to get the loglevel.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index);
/**
* Generic accessor for modules the module-specific loglevel
* @param c The connection from which to get the loglevel.
* @param s The server from which to get the loglevel if c does not have a
* specific loglevel configuration.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c,
const server_rec *s,
int index);
/**
* Generic accessor for modules to get the module-specific loglevel
* @param r The request from which to get the loglevel.
* @param index The module_index of the module to get the loglevel for.
* @return The module-specific loglevel
*/
AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index);
/**
* Accessor to set module-specific loglevel
* @param p A pool
* @param l The ap_logconf struct to modify.
* @param index The module_index of the module to set the loglevel for.
* @param level The new log level
*/
AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l,
int index, int level);
#if !defined(AP_DEBUG)
#define ap_get_conn_logconf(c) \
((c)->log ? (c)->log : \
&(c)->base_server->log)
#define ap_get_conn_server_logconf(c,s) \
( ( (c)->log != &(c)->base_server->log && (c)->log != NULL ) ? \
(c)->log : \
&(s)->log )
#define ap_get_request_logconf(r) \
((r)->log ? (r)->log : \
(r)->connection->log ? (r)->connection->log : \
&(r)->server->log)
#define ap_get_module_loglevel(l,i) \
(((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ? \
(l)->level : \
(l)->module_levels[i])
#define ap_get_server_module_loglevel(s,i) \
(ap_get_module_loglevel(&(s)->log,i))
#define ap_get_conn_module_loglevel(c,i) \
(ap_get_module_loglevel(ap_get_conn_logconf(c),i))
#define ap_get_conn_server_module_loglevel(c,s,i) \
(ap_get_module_loglevel(ap_get_conn_server_logconf(c,s),i))
#define ap_get_request_module_loglevel(r,i) \
(ap_get_module_loglevel(ap_get_request_logconf(r),i))
#endif /* AP_DEBUG */
/**
* Set all module-specific loglevels to val
* @param l The log config for which to set the loglevels.
* @param val the value to set all loglevels to
*/
AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val);
/**
* 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);
/**
* Parsing function for log level
* @param str The string to parse
* @param val The parsed log level
* @return An error string or NULL on success
*/
AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val);
/**
* Return true if the specified method is limited by being listed in
* a <Limit> container, or by *not* being listed in a <LimitExcept>
* 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 stored in an int
* @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 flags stored in a char
* @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_char(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
* @note This allows simple declarations such as:
* @code
* AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL,
* "The Foo directive is no longer supported, use Bar"),
* @endcode
*/
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);
/**
* Compute the name of a run-time file (e.g., shared memory "file") relative
* to the appropriate run-time directory. Absolute paths are returned as-is.
* The run-time directory is configured via the DefaultRuntimeDir directive or
* at build time.
*/
AP_DECLARE(char *) ap_runtime_dir_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
* @param s The module's symbol name (used for logging)
*/
AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p,
const char *s);
/**
* 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 mod The module structure of the module to add
* @param p The pool with the same lifetime as the module
* @param s The module's symbol name (used for logging)
*/
AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p,
const char *s);
/**
* Remove a module from the chained modules list and the list of loaded modules
* @param mod the module structure of the module to remove
*/
AP_DECLARE(void) ap_remove_loaded_module(module *mod);
/**
* 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 the short name of the module identified by the specified module index
* @param module_index The module index to get the name for
* @return the name of the module, NULL if not found
*/
AP_DECLARE(const char *) ap_find_module_short_name(int module_index);
/**
* 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,
apr_status_t (*getc_func) (char *ch, void *param),
apr_status_t (*gets_func) (void *buf, apr_size_t bufsiz, void *param),
apr_status_t (*close_func) (void *param));
/**
* Read one line from open ap_configfile_t, strip leading and trailing
* whitespace, increase line number
* @param buf place to store the line read
* @param bufsize size of the buffer
* @param cfp File to read from
* @return error status, APR_ENOSPC if bufsize is too small for the line
*/
AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize, ap_configfile_t *cfp);
/**
* Read one char from open configfile_t, increase line number upon LF
* @param ch place to store the char read
* @param cfp The file to read from
* @return error status
*/
AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp);
/**
* Detach from open ap_configfile_t, calling the close handler
* @param cfp The file to close
* @return 1 on success, 0 on failure
*/
AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp);
/**
* Convert a return value from ap_cfg_getline or ap_cfg_getc to a user friendly
* string.
* @param p The pool to allocate the string from
* @param cfp The config file
* @param rc The return value to convert
* @return The error string, NULL if rc == APR_SUCCESS
*/
AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
apr_status_t rc);
/**
* Read all data between the current <foo> and the matching </foo>. 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
* @note If cmd->pool == cmd->temp_pool, ap_soak_end_container() will assume
* .htaccess context and use a lower maximum line length.
*/
AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive);
/**
* Read all data between the current <foo> and the matching </foo> 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
* @note If p == temp_pool, ap_build_cont_config() will assume .htaccess
* context and use a lower maximum line length.
*/
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 error, NULL otherwise
* @note If conf_pool == temp_pool, ap_build_config() will assume .htaccess
* context and use a lower maximum line length.
*/
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);
/**
* Convenience function to create a ap_dir_match_t structure from a cmd_parms.
*
* @param cmd The command.
* @param flags Flags to indicate whether optional or recursive.
* @param cb Callback for each file found that matches the wildcard. Return NULL on
* success, an error string on error.
* @param ctx Context for the callback.
* @return Structure ap_dir_match_t with fields populated, allocated from the
* cmd->temp_pool.
*/
AP_DECLARE(ap_dir_match_t *)ap_dir_cfgmatch(cmd_parms *cmd, int flags,
const char *(*cb)(ap_dir_match_t *w, const char *fname), void *ctx)
__attribute__((nonnull(1,3)));
/**
* @defgroup ap_check_cmd_context Check command 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 <VirtualHost> */
#define NOT_IN_LIMIT 0x02 /**< Forbidden in <Limit> */
#define NOT_IN_DIRECTORY 0x04 /**< Forbidden in <Directory> */
#define NOT_IN_LOCATION 0x08 /**< Forbidden in <Location> */
#define NOT_IN_FILES 0x10 /**< Forbidden in <Files> or <If>*/
#define NOT_IN_HTACCESS 0x20 /**< Forbidden in .htaccess files */
#define NOT_IN_PROXY 0x40 /**< Forbidden in <Proxy> */
/** Forbidden in <Directory>/<Location>/<Files><If>*/
#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES)
/** Forbidden in <Directory>/<Location>/<Files><If><Proxy>*/
#define NOT_IN_DIR_CONTEXT (NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE|NOT_IN_PROXY)
/** Forbidden in <VirtualHost>/<Limit>/<Directory>/<Location>/<Files>/<If><Proxy>*/
#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_DIR_CONTEXT)
/** @} */
/**
* @brief This structure is used to assign symbol names to module pointers
*/
typedef struct {
const char *name;
module *modp;
} ap_module_symbol_t;
/**
* The topmost module in the list
* @var module *ap_top_module
*/
AP_DECLARE_DATA extern module *ap_top_module;
/**
* Array of all statically linked modules
* @var module *ap_prelinked_modules[]
*/
AP_DECLARE_DATA extern module *ap_prelinked_modules[];
/**
* Array of all statically linked modulenames (symbols)
* @var ap_module_symbol_t ap_prelinked_module_symbols[]
*/
AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[];
/**
* Array of all preloaded modules
* @var module *ap_preloaded_modules[]
*/
AP_DECLARE_DATA extern module *ap_preloaded_modules[];
/**
* Array of all loaded modules
* @var 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(const char *) 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);
/**
* Returns non-zero if a configuration directive of the given name has
* been registered by a module at the time of calling.
* @param p Pool for temporary allocations
* @param name Directive name
*/
AP_DECLARE(int) ap_exists_directive(apr_pool_t *p, const char *name);
/**
* 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 from
* @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);
/**
* Reserve some modules slots for modules loaded by other means than
* EXEC_ON_READ directives.
* Relevant modules should call this in the pre_config stage.
* @param count The number of slots to reserve.
*/
AP_DECLARE(void) ap_reserve_module_slots(int count);
/**
* Reserve some modules slots for modules loaded by a specific
* non-EXEC_ON_READ config directive.
* This counts how often the given directive is used in the config and calls
* ap_reserve_module_slots() accordingly.
* @param directive The name of the directive
*/
AP_DECLARE(void) ap_reserve_module_slots_directive(const char *directive);
/* 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_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);
/**
* Allocate new ap_logconf and make (deep) copy of old ap_logconf
* @param p The pool to alloc from
* @param old The ap_logconf to copy (may be NULL)
* @return The new ap_logconf struct
*/
AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p,
const struct ap_logconf *old);
/**
* Merge old ap_logconf into new ap_logconf.
* old and new must have the same life time.
* @param old_conf The ap_logconf to merge from
* @param new_conf The ap_logconf to merge into
*/
AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old_conf,
struct ap_logconf *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... (<Directory> command and virtual hosts) */
/**
* parse an htaccess file
* @param result htaccess_result
* @param r The request currently being served
* @param override Which overrides are active
* @param override_opts Which allow-override-opts bits are set
* @param override_list Table of directives allowed for override
* @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,
int override_opts,
apr_table_t *override_list,
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 **ps);
/**
* Process a 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 ptemp Pool for temporary allocation
*/
AP_DECLARE(const char *) ap_process_resource_config(server_rec *s,
const char *fname,
ap_directive_t **conftree,
apr_pool_t *p,
apr_pool_t *ptemp);
/**
* Process all matching files as Apache configs
* @param s The server rec to use for the command parms
* @param fname The filename pattern of the config file
* @param conftree The root node of the created config tree
* @param p Pool for general allocation
* @param ptemp Pool for temporary allocation
* @param optional Whether a no-match wildcard is allowed
* @see apr_fnmatch for pattern handling
*/
AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s,
const char *fname,
ap_directive_t **conftree,
apr_pool_t *p,
apr_pool_t *ptemp,
int optional);
/**
* 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
* @return OK if no problems
*/
AP_DECLARE(int) ap_process_config_tree(server_rec *s,
ap_directive_t *conftree,
apr_pool_t *p,
apr_pool_t *ptemp);
/**
* Store data which will be retained across unload/load of modules
* @param key The unique key associated with this module's retained data
* @param size in bytes of the retained data (to be allocated)
* @return Address of new retained data structure, initially cleared
*/
AP_DECLARE(void *) ap_retained_data_create(const char *key, apr_size_t size);
/**
* Retrieve data which was stored by ap_retained_data_create()
* @param key The unique key associated with this module's retained data
* @return Address of previously retained data structure, or NULL if not yet saved
*/
AP_DECLARE(void *) ap_retained_data_get(const char *key);
/* 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 of modules.
* @param cmd_name The directive to search for
* @param mod Pointer to the first module in the linked list; will be set to
* the module providing cmd_name
* @return The directive definition of the specified directive.
* *mod will be changed to point to the module containing the
* 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);
/* Hooks */
/**
* Run the header parser functions for each module
* @param r The current request
* @return OK or DECLINED
* @ingroup hooks
*/
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
* @ingroup hooks
*/
AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog,
apr_pool_t *ptemp))
/**
* Run the check_config function for each module
* @param pconf The config pool
* @param plog The logging streams pool
* @param ptemp The temporary pool
* @param s the server to operate upon
* @return OK or DECLINED on success anything else is a error
* @ingroup hooks
*/
AP_DECLARE_HOOK(int,check_config,(apr_pool_t *pconf, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s))
/**
* Run the test_config function for each module; this hook is run
* only if the server was invoked to test the configuration syntax.
* @param pconf The config pool
* @param s The list of server_recs
* @note To avoid reordering problems due to different buffering, hook
* functions should only apr_file_*() to print to stdout/stderr and
* not simple printf()/fprintf().
* @ingroup hooks
*/
AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s))
/**
* Run the post_config function for each module
*
* The function might be called multiple times. @a pconf, @a plog, and
* @a ptemp may be cleared and/or destroyed between calls.
*
* The function will be called zero or one times with the server's state being
* #AP_SQ_MS_CREATE_PRE_CONFIG, and will be called one or more times with
* the server's state being #AP_SQ_MS_CREATE_CONFIG.
*
* @see ap_state_query(), #AP_SQ_MAIN_STATE
*
* @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
* @ingroup hooks
*/
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
* @ingroup hooks
*/
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
* @ingroup hooks
*/
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
* @ingroup hooks
*/
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()
* @ingroup hooks
*/
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.
* @ingroup hooks
*/
AP_DECLARE_HOOK(void,optional_fn_retrieve,(void))
/**
* Allow modules to open htaccess files or perform operations before doing so
* @param r The current request
* @param dir_name The directory for which the htaccess file should be opened
* @param access_name The filename for which the htaccess file should be opened
* @param conffile Where the pointer to the opened ap_configfile_t must be
* stored
* @param full_name Where the full file name of the htaccess file must be
* stored.
* @return APR_SUCCESS on success,
* APR_ENOENT or APR_ENOTDIR if no htaccess file exists,
* AP_DECLINED to let later modules do the opening,
* any other error code on error.
* @ingroup hooks
*/
AP_DECLARE_HOOK(apr_status_t,open_htaccess,
(request_rec *r, const char *dir_name, const char *access_name,
ap_configfile_t **conffile, const char **full_name))
/**
* Core internal function, use ap_run_open_htaccess() instead.
*/
apr_status_t ap_open_htaccess(request_rec *r, const char *dir_name,
const char *access_name, ap_configfile_t **conffile,
const char **full_name);
/**
* A generic pool cleanup that will reset a pointer to NULL. For use with
* apr_pool_cleanup_register.
* @param data The address of the pointer
* @return APR_SUCCESS
*/
AP_DECLARE_NONSTD(apr_status_t) ap_pool_cleanup_set_null(void *data);
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_HTTP_CONFIG_H */
/** @} */
PK �c�\��F�w w
util_md5.hnu �[��� /* 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.
*/
/**
* @file util_md5.h
* @brief Apache MD5 library
*
* @defgroup APACHE_CORE_MD5 MD5 Package Library
* @ingroup APACHE_CORE
* @{
*/
#ifndef APACHE_UTIL_MD5_H
#define APACHE_UTIL_MD5_H
#ifdef __cplusplus
extern "C" {
#endif
#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
*/
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
*/
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
*/
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
*/
AP_DECLARE(char *) ap_md5digest(apr_pool_t *p, apr_file_t *infile);
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_UTIL_MD5_H */
/** @} */
PK �c�\�Q��j� j� mod_dav.hnu �[��� /* 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.
*/
/**
* @file mod_dav.h
* @brief DAV extension module for Apache 2.0.*
*
* @defgroup MOD_DAV mod_dav
* @ingroup APACHE_MODS
* @{
*/
#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 <limits.h> /* for INT_MAX */
#include <time.h> /* for time_t */
#ifdef __cplusplus
extern "C" {
#endif
#define DAV_VERSION AP_SERVER_BASEREVISION
#define DAV_XML_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
#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 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n<title>"
#define DAV_RESPONSE_BODY_2 "</title>\n</head><body>\n<h1>"
#define DAV_RESPONSE_BODY_3 "</h1>\n<p>"
#define DAV_RESPONSE_BODY_4 "</p>\n"
#define DAV_RESPONSE_BODY_5 "</body></html>\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 */
apr_status_t aprerr; /* APR error if any, or 0/APR_SUCCESS */
const char *namespace; /* [optional] namespace of error */
const char *tagname; /* name of error-tag */
struct dav_error *prev; /* previous error (in stack) */
const char *childtags; /* error-tag may have children */
} 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, apr_status_t aprerr,
const char *desc);
/*
** Create a new error structure with tagname and (optional) namespace;
** namespace may be NULL, which means "DAV:".
*/
DAV_DECLARE(dav_error*) dav_new_error_tag(apr_pool_t *p, int status,
int error_id, apr_status_t aprerr,
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.
**
** <status> 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.
**
** <error_id> 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);
/*
** Join two errors together.
**
** This function is used to add a new error stack onto an existing error so
** that subsequent errors can be reported after the first error. It returns
** the correct error stack to use so that the caller can blindly call it
** without checking that both dest and src are not NULL.
**
** <dest> is the error stack that the error will be added to.
**
** <src> is the error stack that will be appended.
*/
DAV_DECLARE(dav_error*) dav_join_error(dav_error* dest, dav_error* src);
typedef struct dav_response dav_response;
/*
** dav_handle_err()
**
** Handle the standard error processing. <err> must be non-NULL.
**
** <response> is set by the following:
** - dav_validate_request()
** - dav_add_lock()
** - repos_hooks->remove_resource
** - repos_hooks->move_resource
** - repos_hooks->copy_resource
** - vsn_hooks->update
*/
DAV_DECLARE(int) dav_handle_err(request_rec *r, dav_error *err,
dav_response *response);
/* 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 <response> 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;
* currently has an ABI flaw where sometimes it is
* assumed to be encoded and sometimes not */
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;
DAV_DECLARE(dav_error *) dav_get_resource(request_rec *r, int label_allowed,
int use_checked_in, dav_resource **res_p);
/*
** If DavBasePath is configured for the request location, return the
** configured path, otherwise NULL.
*/
DAV_DECLARE(const char *) dav_get_base_path(request_rec *r);
/* --------------------------------------------------------------------
**
** 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 accommodate 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 accommodate <extra_needed> 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; /* <propstat> element text */
apr_text * xmlns; /* namespace decls for <response> elem */
} dav_get_props_result;
/* holds the contents of a <response> element */
struct dav_response
{
const char *href; /* always */
const char *desc; /* optional description at <response> level */
/* use status if propresult.propstats is NULL. */
dav_get_props_result propresult;
int status;
struct dav_response *next;
};
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
<DAV:supported-live-property> 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
/* Write a complete RESPONSE object out as a <DAV:response> xml
* element. Data is sent into brigade BB, which is auto-flushed into
* the output filter stack for request R. Use POOL for any temporary
* allocations.
*
* [Presumably the <multistatus> tag has already been written; this
* routine is shared by dav_send_multistatus and dav_stream_response.]
*/
DAV_DECLARE(void) dav_send_one_response(dav_response *response,
apr_bucket_brigade *bb,
request_rec *r,
apr_pool_t *pool);
/* Factorized helper function: prep request_rec R for a multistatus
* response and write <multistatus> tag into BB, destined for
* R->output_filters. Use xml NAMESPACES in initial tag, if
* non-NULL.
*/
DAV_DECLARE(void) dav_begin_multistatus(apr_bucket_brigade *bb,
request_rec *r, int status,
apr_array_header_t *namespaces);
/* Finish a multistatus response started by dav_begin_multistatus: */
DAV_DECLARE(apr_status_t) dav_finish_multistatus(request_rec *r,
apr_bucket_brigade *bb);
/* Send a multistatus response */
DAV_DECLARE(void) dav_send_multistatus(request_rec *r, int status,
dav_response *first,
apr_array_header_t *namespaces);
DAV_DECLARE(apr_text *) dav_failed_proppatch(apr_pool_t *p,
apr_array_header_t *prop_ctx);
DAV_DECLARE(apr_text *) dav_success_proppatch(apr_pool_t *p,
apr_array_header_t *prop_ctx);
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(int) dav_validate_root_ns(const apr_xml_doc *doc,
int ns, const char *tagname);
DAV_DECLARE(apr_xml_elem *) dav_find_child(const apr_xml_elem *elem,
const char *tagname);
DAV_DECLARE(apr_xml_elem *) dav_find_child_ns(const apr_xml_elem *elem,
int ns, const char *tagname);
DAV_DECLARE(apr_xml_elem *) dav_find_next_ns(const apr_xml_elem *elem,
int ns, const char *tagname);
/* find and return the attribute with a name in the given namespace */
DAV_DECLARE(apr_xml_attr *) dav_find_attr_ns(const apr_xml_elem *elem,
int ns, const char *attrname);
/* find and return the attribute with a given DAV: tagname */
DAV_DECLARE(apr_xml_attr *) dav_find_attr(const apr_xml_elem *elem,
const char *attrname);
/* 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 <repos> and <propdb>. 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 <repos>) and the other functionality.
**
** Live properties and report extensions are not part of the dav_provider
** structure because they are handled through the APR_HOOK interface (to
** allow for multiple 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))
/*
** deliver_report: given a parsed report request, process the request
** an deliver the resulting report.
**
** The hook implementer should decide whether it should handle the given
** report, and if so, write the response to the output filter. If the
** report is not relevant, return DECLINED.
*/
APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, deliver_report,
(request_rec *r,
const dav_resource *resource,
const apr_xml_doc *doc,
ap_filter_t *output, dav_error **err))
/*
** gather_reports: get all reports.
**
** The hook implementor should push one or more dav_report_elem structures
** containing report names into the specified array. These names are returned
** in the DAV:supported-reports-set property to let clients know
** what reports are supported by the installation.
**
*/
APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, gather_reports,
(request_rec *r, const dav_resource *resource,
apr_array_header_t *reports, dav_error **err))
/*
** method_precondition: check method preconditions.
**
** If a WebDAV extension needs to set any preconditions on a method, this
** hook is where to do it. If the precondition fails, return an error
** response with the tagname set to the value of the failed precondition.
**
** If the method requires an XML body, this will be read and provided as
** the doc value. If not, doc is NULL. An extension that needs to verify
** the non-XML body of a request should register an input filter to do so
** within this hook.
**
** Methods like PUT will supply a single src resource, and the dst will
** be NULL.
**
** Methods like COPY or MOVE will trigger this hook twice. The first
** invocation will supply just the source resource. The second invocation
** will supply a source and destination. This allows preconditions on the
** source resource to be verified before making an attempt to get the
** destination resource.
**
** Methods like PROPFIND and LABEL will trigger this hook initially for
** the src resource, and then subsequently for each resource that has
** been walked during processing, with the walked resource passed in dst,
** and NULL passed in src.
**
** As a rule, the src resource originates from a request that has passed
** through httpd's authn/authz hooks, while the dst resource has not.
*/
APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, method_precondition,
(request_rec *r,
dav_resource *src, const dav_resource *dst,
const apr_xml_doc *doc, dav_error **err))
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);
DAV_DECLARE(const char *) dav_get_provider_name(request_rec *r);
DAV_DECLARE(const dav_provider *) dav_get_provider(request_rec *r);
/* ### 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_unknown /* the "unknown" state type; always matches false. */
} 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.
**
** Some DAV extensions, like CalDAV, specify both document elements
** and property elements that need to be taken into account when
** generating a property. The document element and property element
** are made available in the dav_liveprop_elem structure under the
** resource, accessible as follows:
**
** dav_get_liveprop_element(resource);
**
** 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 <value> 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:
** <lp1:executable>T</lp1:executable>
**
** 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 conjunction 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(long) 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(long) dav_get_liveprop_ns_index(const char *uri);
/* ### docco */
DAV_DECLARE(long) dav_get_liveprop_ns_count(void);
/* ### docco */
DAV_DECLARE(void) dav_add_all_liveprop_xmlns(apr_pool_t *p,
apr_text_header *phdr);
typedef struct {
const apr_xml_doc *doc;
const apr_xml_elem *elem;
} dav_liveprop_elem;
/*
** When calling insert_prop(), the associated request element and
** document is accessible using the following call.
*/
DAV_DECLARE(dav_liveprop_elem *) dav_get_liveprop_element(const dav_resource
*resource);
/*
** 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 <rectype> and <locktoken> fields must be filled
** in. All other (user) fields should be zeroed. The lock provider will
** usually fill in the <info> field, and the <next> 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 <is_locknull> 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_open_lockdb(request_rec *r,
int ro,
dav_lockdb **lockdb);
DAV_DECLARE(void) dav_close_lockdb(dav_lockdb *lockdb);
DAV_DECLARE(dav_error *) dav_lock_parse_lockinfo(request_rec *r,
const dav_resource *resource,
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 <dav_lock_scope> 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 */
#define DAV_VALIDATE_NO_MODIFY 0x0200 /* resource is not being modified
so allow even if lock token
is not provided */
/* 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 <locks> 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 <start_resource> and the lock
** specified by <locktoken>.
**
** 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;
#define DAV_PROPDB_NONE 0
#define DAV_PROPDB_RO 1
#define DAV_PROPDB_DISABLE_LOCKDISCOVERY 2
DAV_DECLARE(dav_error *) dav_open_propdb(
request_rec *r,
dav_lockdb *lockdb,
const dav_resource *resource,
int flags,
apr_array_header_t *ns_xlate,
dav_propdb **propdb);
DAV_DECLARE(dav_error *) dav_popen_propdb(
apr_pool_t *p,
request_rec *r,
dav_lockdb *lockdb,
const dav_resource *resource,
int flags,
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;
apr_xml_elem *prop; /* property to affect */
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? */
/* private items to the propdb */
int is_liveprop;
void *liveprop_ctx;
struct dav_rollback_item *rollback; /* optional rollback info */
dav_error *err; /* error (if any) */
/* 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 */
#define DAV_WALKTYPE_TOLERANT 0x0008 /* tolerate non-fatal errors */
/* 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;
/* Get the request rec for a resource */
request_rec * (*get_request_rec)(const dav_resource *resource);
/* Get the pathname for a resource */
const char * (*get_pathname)(const dav_resource *resource);
};
/* --------------------------------------------------------------------
**
** 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 <DAV:mkworkspace> element is passed to the provider
** in the "doc" structure; it may be empty.
**
** If workspace creation is successful, 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 successful, 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: <DAV:basicsearch>
* DASL: <http://foo.bar.com/syntax1>
* DASL: <http://akuma.com/syntax2>
*/
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
*/
typedef struct {
int propid; /* live property ID */
const dav_hooks_liveprop *provider; /* the provider defining this prop */
} dav_elem_private;
/* --------------------------------------------------------------------
**
** DAV OPTIONS
*/
#define DAV_OPTIONS_EXTENSION_GROUP "dav_options"
typedef struct dav_options_provider
{
dav_error* (*dav_header)(request_rec *r,
const dav_resource *resource,
apr_text_header *phdr);
dav_error* (*dav_method)(request_rec *r,
const dav_resource *resource,
apr_text_header *phdr);
void *ctx;
} dav_options_provider;
extern DAV_DECLARE(const dav_options_provider *) dav_get_options_providers(const char *name);
extern DAV_DECLARE(void) dav_options_provider_register(apr_pool_t *p,
const char *name,
const dav_options_provider *provider);
/* --------------------------------------------------------------------
**
** DAV RESOURCE TYPE HOOKS
*/
typedef struct dav_resource_type_provider
{
int (*get_resource_type)(const dav_resource *resource,
const char **name,
const char **uri);
} dav_resource_type_provider;
#define DAV_RESOURCE_TYPE_GROUP "dav_resource_type"
DAV_DECLARE(void) dav_resource_type_provider_register(apr_pool_t *p,
const char *name,
const dav_resource_type_provider *provider);
DAV_DECLARE(const dav_resource_type_provider *) dav_get_resource_type_providers(const char *name);
#ifdef __cplusplus
}
#endif
#endif /* _MOD_DAV_H_ */
/** @} */
PK �c�\�yP�� � cache_common.hnu �[��� /* 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.
*/
/**
* @file cache_common.h
* @brief Common Cache structs
*
* @defgroup Cache_cache Cache Functions
* @ingroup MOD_CACHE
* @{
*/
#ifndef CACHE_COMMON_H
#define CACHE_COMMON_H
/* a cache control header breakdown */
typedef struct cache_control {
unsigned int parsed:1;
unsigned int cache_control:1;
unsigned int pragma:1;
unsigned int no_cache:1;
unsigned int no_cache_header:1; /* no cache by header match */
unsigned int no_store:1;
unsigned int max_age:1;
unsigned int max_stale:1;
unsigned int min_fresh:1;
unsigned int no_transform:1;
unsigned int only_if_cached:1;
unsigned int public:1;
unsigned int private:1;
unsigned int private_header:1; /* private by header match */
unsigned int must_revalidate:1;
unsigned int proxy_revalidate:1;
unsigned int s_maxage:1;
unsigned int invalidated:1; /* has this entity been invalidated? */
apr_int64_t max_age_value; /* if positive, then set */
apr_int64_t max_stale_value; /* if positive, then set */
apr_int64_t min_fresh_value; /* if positive, then set */
apr_int64_t s_maxage_value; /* if positive, then set */
} cache_control_t;
#endif /* CACHE_COMMON_H */
/** @} */
PK �c�\eXf�� � mod_status.hnu �[��� /* 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.
*/
/**
* @file mod_status.h
* @brief Status Report Extension Module to Apache
*
* @defgroup MOD_STATUS mod_status
* @ingroup APACHE_MODS
* @{
*/
#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
/** @} */
PK �c�\LU��C C ap_slotmem.hnu �[��� /* 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 SLOTMEM_H
#define SLOTMEM_H
/* Memory handler for a shared memory divided in slot.
*/
/**
* @file ap_slotmem.h
* @brief Memory Slot Extension Storage Module for Apache
*
* @defgroup MEM mem
* @ingroup APACHE_MODS
* @{
*/
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "ap_provider.h"
#include "apr.h"
#include "apr_strings.h"
#include "apr_pools.h"
#include "apr_shm.h"
#include "apr_global_mutex.h"
#include "apr_file_io.h"
#include "apr_md5.h"
#if APR_HAVE_UNISTD_H
#include <unistd.h> /* for getpid() */
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define AP_SLOTMEM_PROVIDER_GROUP "slotmem"
#define AP_SLOTMEM_PROVIDER_VERSION "0"
typedef unsigned int ap_slotmem_type_t;
/*
* Values for ap_slotmem_type_t::
*
* AP_SLOTMEM_TYPE_PERSIST: For transitory providers, persist
* the data on the file-system
*
* AP_SLOTMEM_TYPE_NOTMPSAFE:
*
* AP_SLOTMEM_TYPE_PREALLOC: Access to slots require they be grabbed 1st
*
* AP_SLOTMEM_TYPE_CLEARINUSE: If persisting, clear 'inuse' array before
* storing
*/
#define AP_SLOTMEM_TYPE_PERSIST (1 << 0)
#define AP_SLOTMEM_TYPE_NOTMPSAFE (1 << 1)
#define AP_SLOTMEM_TYPE_PREGRAB (1 << 2)
#define AP_SLOTMEM_TYPE_CLEARINUSE (1 << 3)
typedef struct ap_slotmem_instance_t ap_slotmem_instance_t;
/**
* callback function used for slotmem doall.
* @param mem is the memory associated with a worker.
* @param data is what is passed to slotmem.
* @param pool is pool used
* @return APR_SUCCESS if all went well
*/
typedef apr_status_t ap_slotmem_callback_fn_t(void* mem, void *data, apr_pool_t *pool);
struct ap_slotmem_provider_t {
/*
* Name of the provider method
*/
const char *name;
/**
* call the callback on all worker slots
* @param s ap_slotmem_instance_t to use.
* @param funct callback function to call for each element.
* @param data parameter for the callback function.
* @param pool is pool used
* @return APR_SUCCESS if all went well
*/
apr_status_t (* doall)(ap_slotmem_instance_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool);
/**
* create a new slotmem with each item size is item_size.
* This would create shared memory, basically.
* @param inst where to store pointer to slotmem
* @param name a key used for debugging and in mod_status output or allow another process to share this space.
* @param item_size size of each item
* @param item_num number of item to create.
* @param type type of slotmem.
* @param pool is pool used
* @return APR_SUCCESS if all went well
*/
apr_status_t (* create)(ap_slotmem_instance_t **inst, const char *name, apr_size_t item_size, unsigned int item_num, ap_slotmem_type_t type, apr_pool_t *pool);
/**
* attach to an existing slotmem.
* This would attach to shared memory, basically.
* @param inst where to store pointer to slotmem
* @param name a key used for debugging and in mod_status output or allow another process to share this space.
* @param item_size size of each item
* @param item_num max number of item.
* @param pool is pool to memory allocate.
* @return APR_SUCCESS if all went well
*/
apr_status_t (* attach)(ap_slotmem_instance_t **inst, const char *name, apr_size_t *item_size, unsigned int *item_num, apr_pool_t *pool);
/**
* get the memory ptr associated with this worker slot.
* @param s ap_slotmem_instance_t to use.
* @param item_id item to return for 0 to item_num
* @param mem address to store the pointer to the slot
* @return APR_SUCCESS if all went well
*/
apr_status_t (* dptr)(ap_slotmem_instance_t *s, unsigned int item_id, void**mem);
/**
* get/read the data associated with this worker slot.
* @param s ap_slotmem_instance_t to use.
* @param item_id item to return for 0 to item_num
* @param dest address to store the data
* @param dest_len length of dataset to retrieve
* @return APR_SUCCESS if all went well
*/
apr_status_t (* get)(ap_slotmem_instance_t *s, unsigned int item_id, unsigned char *dest, apr_size_t dest_len);
/**
* put/write the data associated with this worker slot.
* @param s ap_slotmem_instance_t to use.
* @param item_id item to return for 0 to item_num
* @param src address of the data to store in the slot
* @param src_len length of dataset to store in the slot
* @return APR_SUCCESS if all went well
*/
apr_status_t (* put)(ap_slotmem_instance_t *slot, unsigned int item_id, unsigned char *src, apr_size_t src_len);
/**
* return number of slots allocated for this entry.
* @param s ap_slotmem_instance_t to use.
* @return number of slots
*/
unsigned int (* num_slots)(ap_slotmem_instance_t *s);
/**
* return number of free (not used) slots allocated for this entry.
* Valid for slots which are AP_SLOTMEM_TYPE_PREGRAB as well as
* any which use get/release.
* @param s ap_slotmem_instance_t to use.
* @return number of slots
*/
unsigned int (* num_free_slots)(ap_slotmem_instance_t *s);
/**
* return slot size allocated for this entry.
* @param s ap_slotmem_instance_t to use.
* @return size of slot
*/
apr_size_t (* slot_size)(ap_slotmem_instance_t *s);
/**
* grab (or alloc) a free slot
* @param s ap_slotmem_instance_t to use.
* @param item_id ptr to the available slot id and marked as in-use
* @return APR_SUCCESS if all went well
*/
apr_status_t (* grab)(ap_slotmem_instance_t *s, unsigned int *item_id);
/**
* release (or free) the slot associated with this item_id
* @param s ap_slotmem_instance_t to use.
* @param item_id slot id to free and mark as no longer in-use
* @return APR_SUCCESS if all went well
*/
apr_status_t (* release)(ap_slotmem_instance_t *s, unsigned int item_id);
/**
* forced grab (or alloc) a slot associated with this item_id
* @param s ap_slotmem_instance_t to use.
* @param item_id to the specified slot id and marked as in-use
* @return APR_SUCCESS if all went well
*/
apr_status_t (* fgrab)(ap_slotmem_instance_t *s, unsigned int item_id);
};
typedef struct ap_slotmem_provider_t ap_slotmem_provider_t;
#ifdef __cplusplus
}
#endif
#endif
/** @} */
PK �c�\���d d
ap_hooks.hnu �[��� /* 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.
*/
/**
* @file ap_hooks.h
* @brief ap hook functions and macros
*/
#ifndef AP_HOOKS_H
#define AP_HOOKS_H
/* Although this file doesn't declare any hooks, declare the hook group here */
/**
* @defgroup hooks Apache Hooks
* @ingroup APACHE_CORE
*/
#if defined(AP_HOOK_PROBES_ENABLED) && !defined(APR_HOOK_PROBES_ENABLED)
#define APR_HOOK_PROBES_ENABLED 1
#endif
#ifdef APR_HOOK_PROBES_ENABLED
#include "ap_hook_probes.h"
#endif
#include "apr.h"
#include "apr_hooks.h"
#include "apr_optional_hooks.h"
#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 */
/**
* 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_<i>name</i>.
*
* @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_<i>name</i>.
*
* @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_<i>name</i>.
*
* @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)
#endif /* AP_HOOKS_H */
PK �c�\�zi��, �,
ap_regex.hnu �[��� /* 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 is based on pcreposix.h from the PCRE Library distribution,
* as originally written by Philip Hazel <ph10@cam.ac.uk>, and forked by
* the Apache HTTP Server project to provide POSIX-style regex function
* wrappers around underlying PCRE library functions for httpd.
*
* The original source file pcreposix.h is copyright and licensed as follows;
Copyright (c) 1997-2004 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* 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.
* Neither the name of the University of Cambridge 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
-----------------------------------------------------------------------------
*/
/**
* @file ap_regex.h
* @brief Apache Regex defines
*/
#ifndef AP_REGEX_H
#define AP_REGEX_H
#include "apr.h"
/* Allow for C++ users */
#ifdef __cplusplus
extern "C" {
#endif
/* Options for ap_regcomp, ap_regexec, and ap_rxplus versions: */
#define AP_REG_ICASE 0x01 /** use a case-insensitive match */
#define AP_REG_NEWLINE 0x02 /** don't match newlines against '.' etc */
#define AP_REG_NOTBOL 0x04 /** ^ will not match against start-of-string */
#define AP_REG_NOTEOL 0x08 /** $ will not match against end-of-string */
#define AP_REG_EXTENDED (0) /** unused */
#define AP_REG_NOSUB (0) /** unused */
#define AP_REG_MULTI 0x10 /* perl's /g (needs fixing) */
#define AP_REG_NOMEM 0x20 /* nomem in our code */
#define AP_REG_DOTALL 0x40 /* perl's /s flag */
#define AP_REG_DOLLAR_ENDONLY 0x200 /* '$' matches at end of subject string only */
#define AP_REG_NO_DEFAULT 0x400 /**< Don't implicitely add AP_REG_DEFAULT options */
#define AP_REG_MATCH "MATCH_" /**< suggested prefix for ap_regname */
#define AP_REG_DEFAULT (AP_REG_DOTALL|AP_REG_DOLLAR_ENDONLY)
/* Arguments for ap_pcre_version_string */
enum {
AP_REG_PCRE_COMPILED = 0, /** PCRE version used during program compilation */
AP_REG_PCRE_LOADED /** PCRE version loaded at runtime */
};
/* Error values: */
enum {
AP_REG_ASSERT = 1, /** internal error ? */
AP_REG_ESPACE, /** failed to get memory */
AP_REG_INVARG, /** invalid argument */
AP_REG_NOMATCH /** match failed */
};
/* The structure representing a compiled regular expression. */
typedef struct {
void *re_pcre;
int re_nsub;
apr_size_t re_erroffset;
} ap_regex_t;
/* The structure in which a captured offset is returned. */
typedef struct {
int rm_so;
int rm_eo;
} ap_regmatch_t;
/* The functions */
/**
* Return PCRE version string.
* @param which Either AP_REG_PCRE_COMPILED (PCRE version used
* during program compilation) or AP_REG_PCRE_LOADED
* (PCRE version used at runtime)
* @return The PCRE version string
*/
AP_DECLARE(const char *) ap_pcre_version_string(int which);
/**
* Get default compile flags
* @return Bitwise OR of AP_REG_* flags
*/
AP_DECLARE(int) ap_regcomp_get_default_cflags(void);
/**
* Set default compile flags
* @param cflags Bitwise OR of AP_REG_* flags
*/
AP_DECLARE(void) ap_regcomp_set_default_cflags(int cflags);
/**
* Get the AP_REG_* corresponding to the string.
* @param name The name (i.e. AP_REG_<name>)
* @return The AP_REG_*, or zero if the string is unknown
*
*/
AP_DECLARE(int) ap_regcomp_default_cflag_by_name(const char *name);
/**
* Compile a regular expression.
* @param preg Returned compiled regex
* @param regex The regular expression string
* @param cflags Bitwise OR of AP_REG_* flags (ICASE and NEWLINE supported,
* other flags are ignored)
* @return Zero on success or non-zero on error
*/
AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags);
/**
* Match a NUL-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 AP_REG_* flags (NOTBOL and NOTEOL supported,
* other flags are ignored)
* @return 0 for successful match, \p AP_REG_NOMATCH otherwise
*/
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags);
/**
* Match a string with given length against a pre-compiled regex. The string
* does not need to be NUL-terminated.
* @param preg The pre-compiled regex
* @param buff The string to match
* @param len Length of 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 AP_REG_* flags (NOTBOL and NOTEOL supported,
* other flags are ignored)
* @return 0 for successful match, AP_REG_NOMATCH otherwise
*/
AP_DECLARE(int) ap_regexec_len(const ap_regex_t *preg, const char *buff,
apr_size_t len, apr_size_t nmatch,
ap_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(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg,
char *errbuf, apr_size_t errbuf_size);
/**
* Return an array of named regex backreferences
* @param preg The precompiled regex
* @param names The array to which the names will be added
* @param prefix An optional prefix to add to the returned names. AP_REG_MATCH
* is the recommended prefix.
* @param upper If non zero, uppercase the names
*/
AP_DECLARE(int) ap_regname(const ap_regex_t *preg,
apr_array_header_t *names, const char *prefix,
int upper);
/** Destroy a pre-compiled regex.
* @param preg The pre-compiled regex to free.
*/
AP_DECLARE(void) ap_regfree(ap_regex_t *preg);
/* ap_rxplus: higher-level regexps */
typedef struct {
ap_regex_t rx;
apr_uint32_t flags;
const char *subs;
const char *match;
apr_size_t nmatch;
ap_regmatch_t *pmatch;
} ap_rxplus_t;
/**
* Compile a pattern into a regexp.
* supports perl-like formats
* match-string
* /match-string/flags
* s/match-string/replacement-string/flags
* Intended to support more perl-like stuff as and when round tuits happen
* match-string is anything supported by ap_regcomp
* replacement-string is a substitution string as supported in ap_pregsub
* flags should correspond with perl syntax: treat failure to do so as a bug
* (documentation TBD)
* @param pool Pool to allocate from
* @param pattern Pattern to compile
* @return Compiled regexp, or NULL in case of compile/syntax error
*/
AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool, const char *pattern);
/**
* Apply a regexp operation to a string.
* @param pool Pool to allocate from
* @param rx The regex match to apply
* @param pattern The string to apply it to
* NOTE: This MUST be kept in scope to use regexp memory
* @param newpattern The modified string (ignored if the operation doesn't
* modify the string)
* @return Number of times a match happens. Normally 0 (no match) or 1
* (match found), but may be greater if a transforming pattern
* is applied with the 'g' flag.
*/
AP_DECLARE(int) ap_rxplus_exec(apr_pool_t *pool, ap_rxplus_t *rx,
const char *pattern, char **newpattern);
#ifdef DOXYGEN
/**
* Number of matches in the regexp operation's memory
* This may be 0 if no match is in memory, or up to nmatch from compilation
* @param rx The regexp
* @return Number of matches in memory
*/
AP_DECLARE(int) ap_rxplus_nmatch(ap_rxplus_t *rx);
#else
#define ap_rxplus_nmatch(rx) (((rx)->match != NULL) ? (rx)->nmatch : 0)
#endif
/**
* Get a pointer to a match from regex memory
* NOTE: this relies on the match pattern from the last call to
* ap_rxplus_exec still being valid (i.e. not freed or out-of-scope)
* @param rx The regexp
* @param n The match number to retrieve (must be between 0 and nmatch)
* @param len Returns the length of the match.
* @param match Returns the match pattern
*/
AP_DECLARE(void) ap_rxplus_match(ap_rxplus_t *rx, int n, int *len,
const char **match);
/**
* Get a match from regex memory in a string copy
* NOTE: this relies on the match pattern from the last call to
* ap_rxplus_exec still being valid (i.e. not freed or out-of-scope)
* @param pool Pool to allocate from
* @param rx The regexp
* @param n The match number to retrieve (must be between 0 and nmatch)
* @return The matched string
*/
AP_DECLARE(char*) ap_rxplus_pmatch(apr_pool_t *pool, ap_rxplus_t *rx, int n);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* AP_REGEX_T */
PK �c�\iʕ{�'