Blame include/http_core.h

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @file  http_core.h
Packit 90a5c9
 * @brief CORE HTTP Daemon
Packit 90a5c9
 *
Packit 90a5c9
 * @defgroup APACHE_CORE_HTTPD Core HTTP Daemon
Packit 90a5c9
 * @ingroup  APACHE_CORE
Packit 90a5c9
 * @{
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#ifndef APACHE_HTTP_CORE_H
Packit 90a5c9
#define APACHE_HTTP_CORE_H
Packit 90a5c9
Packit 90a5c9
#include "apr.h"
Packit 90a5c9
#include "apr_hash.h"
Packit 90a5c9
#include "apr_optional.h"
Packit 90a5c9
#include "util_filter.h"
Packit 90a5c9
#include "ap_expr.h"
Packit 90a5c9
#include "apr_tables.h"
Packit 90a5c9
Packit 90a5c9
#include "http_config.h"
Packit 90a5c9
Packit 90a5c9
#if APR_HAVE_STRUCT_RLIMIT
Packit 90a5c9
#include <sys/time.h>
Packit 90a5c9
#include <sys/resource.h>
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
extern "C" {
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/* ****************************************************************
Packit 90a5c9
 *
Packit 90a5c9
 * The most basic server code is encapsulated in a single module
Packit 90a5c9
 * known as the core, which is just *barely* functional enough to
Packit 90a5c9
 * serve documents, though not terribly well.
Packit 90a5c9
 *
Packit 90a5c9
 * Largely for NCSA back-compatibility reasons, the core needs to
Packit 90a5c9
 * make pieces of its config structures available to other modules.
Packit 90a5c9
 * The accessors are declared here, along with the interpretation
Packit 90a5c9
 * of one of them (allow_options).
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @defgroup APACHE_CORE_HTTPD_ACESSORS Acessors
Packit 90a5c9
 *
Packit 90a5c9
 * @brief File/Directory Accessor directives
Packit 90a5c9
 *
Packit 90a5c9
 * @{
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/** No directives */
Packit 90a5c9
#define OPT_NONE 0
Packit 90a5c9
/** Indexes directive */
Packit 90a5c9
#define OPT_INDEXES 1
Packit 90a5c9
/** SSI is enabled without exec= permission  */
Packit 90a5c9
#define OPT_INCLUDES 2
Packit 90a5c9
/**  FollowSymLinks directive */
Packit 90a5c9
#define OPT_SYM_LINKS 4
Packit 90a5c9
/**  ExecCGI directive */
Packit 90a5c9
#define OPT_EXECCGI 8
Packit 90a5c9
/**  directive unset */
Packit 90a5c9
#define OPT_UNSET 16
Packit 90a5c9
/**  SSI exec= permission is permitted, iff OPT_INCLUDES is also set */
Packit 90a5c9
#define OPT_INC_WITH_EXEC 32
Packit 90a5c9
/** SymLinksIfOwnerMatch directive */
Packit 90a5c9
#define OPT_SYM_OWNER 64
Packit 90a5c9
/** MultiViews directive */
Packit 90a5c9
#define OPT_MULTI 128
Packit 90a5c9
/**  All directives */
Packit 90a5c9
#define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_INC_WITH_EXEC|OPT_SYM_LINKS|OPT_EXECCGI)
Packit 90a5c9
/** @} */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @defgroup get_remote_host Remote Host Resolution
Packit 90a5c9
 * @ingroup APACHE_CORE_HTTPD
Packit 90a5c9
 * @{
Packit 90a5c9
 */
Packit 90a5c9
/** REMOTE_HOST returns the hostname, or NULL if the hostname
Packit 90a5c9
 * lookup fails.  It will force a DNS lookup according to the
Packit 90a5c9
 * HostnameLookups setting.
Packit 90a5c9
 */
Packit 90a5c9
#define REMOTE_HOST (0)
Packit 90a5c9
Packit 90a5c9
/** REMOTE_NAME returns the hostname, or the dotted quad if the
Packit 90a5c9
 * hostname lookup fails.  It will force a DNS lookup according
Packit 90a5c9
 * to the HostnameLookups setting.
Packit 90a5c9
 */
Packit 90a5c9
#define REMOTE_NAME (1)
Packit 90a5c9
Packit 90a5c9
/** REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
Packit 90a5c9
 * never forced.
Packit 90a5c9
 */
Packit 90a5c9
#define REMOTE_NOLOOKUP (2)
Packit 90a5c9
Packit 90a5c9
/** REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
Packit 90a5c9
 * a double reverse lookup, regardless of the HostnameLookups
Packit 90a5c9
 * setting.  The result is the (double reverse checked) hostname,
Packit 90a5c9
 * or NULL if any of the lookups fail.
Packit 90a5c9
 */
Packit 90a5c9
#define REMOTE_DOUBLE_REV (3)
Packit 90a5c9
Packit 90a5c9
/** @} // get_remote_host */
Packit 90a5c9
Packit 90a5c9
/** all of the requirements must be met */
Packit 90a5c9
#define SATISFY_ALL 0
Packit 90a5c9
/**  any of the requirements must be met */
Packit 90a5c9
#define SATISFY_ANY 1
Packit 90a5c9
/** There are no applicable satisfy lines */
Packit 90a5c9
#define SATISFY_NOSPEC 2
Packit 90a5c9
Packit 90a5c9
/** Make sure we don't write less than 8000 bytes at any one time.
Packit 90a5c9
 */
Packit 90a5c9
#define AP_MIN_BYTES_TO_WRITE  8000
Packit 90a5c9
Packit 90a5c9
/** default maximum of internal redirects */
Packit 90a5c9
# define AP_DEFAULT_MAX_INTERNAL_REDIRECTS 10
Packit 90a5c9
Packit 90a5c9
/** default maximum subrequest nesting level */
Packit 90a5c9
# define AP_DEFAULT_MAX_SUBREQ_DEPTH 10
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Retrieve the value of Options for this request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return the Options bitmask
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_allow_options(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Retrieve the value of the AllowOverride for this request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return the overrides bitmask
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_allow_overrides(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Retrieve the document root for this server
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @warning Don't use this!  If your request went through a Userdir, or
Packit 90a5c9
 * something like that, it'll screw you.  But it's back-compatible...
Packit 90a5c9
 * @return The document root
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_document_root(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Lookup the remote user agent's DNS name or IP address
Packit 90a5c9
 * @ingroup get_remote_hostname
Packit 90a5c9
 * @param req The current request
Packit 90a5c9
 * @param type The type of lookup to perform.  One of:
Packit 90a5c9
 * 
Packit 90a5c9
 *     REMOTE_HOST returns the hostname, or NULL if the hostname
Packit 90a5c9
 *                 lookup fails.  It will force a DNS lookup according to the
Packit 90a5c9
 *                 HostnameLookups setting.
Packit 90a5c9
 *     REMOTE_NAME returns the hostname, or the dotted quad if the
Packit 90a5c9
 *                 hostname lookup fails.  It will force a DNS lookup according
Packit 90a5c9
 *                 to the HostnameLookups setting.
Packit 90a5c9
 *     REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
Packit 90a5c9
 *                     never forced.
Packit 90a5c9
 *     REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
Packit 90a5c9
 *                   a double reverse lookup, regardless of the HostnameLookups
Packit 90a5c9
 *                   setting.  The result is the (double reverse checked)
Packit 90a5c9
 *                   hostname, or NULL if any of the lookups fail.
Packit 90a5c9
 * 
Packit 90a5c9
 * @param str_is_ip unless NULL is passed, this will be set to non-zero on
Packit 90a5c9
 *        output when an IP address string is returned
Packit 90a5c9
 * @return The remote hostname (based on the request useragent_ip)
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_get_useragent_host(request_rec *req, int type,
Packit 90a5c9
                                               int *str_is_ip);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Lookup the remote client's DNS name or IP address
Packit 90a5c9
 * @ingroup get_remote_host
Packit 90a5c9
 * @param conn The current connection
Packit 90a5c9
 * @param dir_config The directory config vector from the request
Packit 90a5c9
 * @param type The type of lookup to perform.  One of:
Packit 90a5c9
 * 
Packit 90a5c9
 *     REMOTE_HOST returns the hostname, or NULL if the hostname
Packit 90a5c9
 *                 lookup fails.  It will force a DNS lookup according to the
Packit 90a5c9
 *                 HostnameLookups setting.
Packit 90a5c9
 *     REMOTE_NAME returns the hostname, or the dotted quad if the
Packit 90a5c9
 *                 hostname lookup fails.  It will force a DNS lookup according
Packit 90a5c9
 *                 to the HostnameLookups setting.
Packit 90a5c9
 *     REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
Packit 90a5c9
 *                     never forced.
Packit 90a5c9
 *     REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
Packit 90a5c9
 *                   a double reverse lookup, regardless of the HostnameLookups
Packit 90a5c9
 *                   setting.  The result is the (double reverse checked)
Packit 90a5c9
 *                   hostname, or NULL if any of the lookups fail.
Packit 90a5c9
 * 
Packit 90a5c9
 * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address
Packit 90a5c9
 *        string is returned
Packit 90a5c9
 * @return The remote hostname (based on the connection client_ip)
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Retrieve the login name of the remote user.  Undef if it could not be
Packit 90a5c9
 * determined
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The user logged in to the client machine
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_get_remote_logname(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/* Used for constructing self-referencing URLs, and things like SERVER_PORT,
Packit 90a5c9
 * and SERVER_NAME.
Packit 90a5c9
 */
Packit 90a5c9
/**
Packit 90a5c9
 * build a fully qualified URL from the uri and information in the request rec
Packit 90a5c9
 * @param p The pool to allocate the URL from
Packit 90a5c9
 * @param uri The path to the requested file
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return A fully qualified URL
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the current server name from the request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return the server name
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_get_server_name(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the current server name from the request for the purposes
Packit 90a5c9
 * of using in a URL.  If the server name is an IPv6 literal
Packit 90a5c9
 * address, it will be returned in URL format (e.g., "[fe80::1]").
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return the server name
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Get the current server port
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The server's port
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the limit on bytes in request msg body
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return the maximum number of bytes in the request msg body
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the limit on bytes in XML request msg body
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return the maximum number of bytes in XML request msg body
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_size_t) ap_get_limit_xml_body(const request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Install a custom response handler for a given status
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @param status The status for which the custom response should be used
Packit 90a5c9
 * @param string The custom response.  This can be a static string, a file
Packit 90a5c9
 *               or a URL
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_custom_response(request_rec *r, int status, const char *string);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Check if the current request is beyond the configured max. number of redirects or subrequests
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return true (is exceeded) or false
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Check for a definition from the server command line
Packit 90a5c9
 * @param name The define to check for
Packit 90a5c9
 * @return 1 if defined, 0 otherwise
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_exists_config_define(const char *name);
Packit 90a5c9
/* FIXME! See STATUS about how */
Packit 90a5c9
AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/* Authentication stuff.  This is one of the places where compatibility
Packit 90a5c9
 * with the old config files *really* hurts; they don't discriminate at
Packit 90a5c9
 * all between different authentication schemes, meaning that we need
Packit 90a5c9
 * to maintain common state for all of them in the core, and make it
Packit 90a5c9
 * available to the other modules through interfaces.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/** @see require_line */
Packit 90a5c9
typedef struct require_line require_line;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @brief A structure to keep track of authorization requirements
Packit 90a5c9
*/
Packit 90a5c9
struct require_line {
Packit 90a5c9
    /** Where the require line is in the config file. */
Packit 90a5c9
    apr_int64_t method_mask;
Packit 90a5c9
    /** The complete string from the command line */
Packit 90a5c9
    char *requirement;
Packit 90a5c9
};
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the type of authorization required for this request
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The authorization required
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_auth_type(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Return the current Authorization realm
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return The current authorization realm
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const char *) ap_auth_name(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * How the requires lines must be met.
Packit 90a5c9
 * @param r The current request
Packit 90a5c9
 * @return How the requirements must be met.  One of:
Packit 90a5c9
 * 
Packit 90a5c9
 *      SATISFY_ANY    -- any of the requirements must be met.
Packit 90a5c9
 *      SATISFY_ALL    -- all of the requirements must be met.
Packit 90a5c9
 *      SATISFY_NOSPEC -- There are no applicable satisfy lines
Packit 90a5c9
 * 
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_satisfies(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Core is also unlike other modules in being implemented in more than
Packit 90a5c9
 * one file... so, data structures are declared here, even though most of
Packit 90a5c9
 * the code that cares really is in http_core.c.  Also, another accessor.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_DATA extern module core_module;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Accessor for core_module's specific data. Equivalent to
Packit 90a5c9
 * ap_get_module_config(cv, &core_module) but more efficient.
Packit 90a5c9
 * @param cv The vector in which the modules configuration is stored.
Packit 90a5c9
 *        usually r->per_dir_config or s->module_config
Packit 90a5c9
 * @return The module-specific data
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Accessor to set core_module's specific data. Equivalent to
Packit 90a5c9
 * ap_set_module_config(cv, &core_module, val) but more efficient.
Packit 90a5c9
 * @param cv The vector in which the modules configuration is stored.
Packit 90a5c9
 *        usually r->per_dir_config or s->module_config
Packit 90a5c9
 * @param val The module-specific data to set
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val);
Packit 90a5c9
Packit 90a5c9
/** Get the socket from the core network filter. This should be used instead of
Packit 90a5c9
 * accessing the core connection config directly.
Packit 90a5c9
 * @param c The connection record
Packit 90a5c9
 * @return The socket
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_socket_t *) ap_get_conn_socket(conn_rec *c);
Packit 90a5c9
Packit 90a5c9
#ifndef AP_DEBUG
Packit 90a5c9
#define AP_CORE_MODULE_INDEX  0
Packit 90a5c9
#define ap_get_core_module_config(v) \
Packit 90a5c9
    (((void **)(v))[AP_CORE_MODULE_INDEX])
Packit 90a5c9
#define ap_set_core_module_config(v, val) \
Packit 90a5c9
    ((((void **)(v))[AP_CORE_MODULE_INDEX]) = (val))
Packit 90a5c9
#else
Packit 90a5c9
#define AP_CORE_MODULE_INDEX  (AP_DEBUG_ASSERT(core_module.module_index == 0), 0)
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @brief  Per-request configuration
Packit 90a5c9
*/
Packit 90a5c9
typedef struct {
Packit 90a5c9
    /** bucket brigade used by getline for look-ahead and
Packit 90a5c9
     * ap_get_client_block for holding left-over request body */
Packit 90a5c9
    struct apr_bucket_brigade *bb;
Packit 90a5c9
Packit 90a5c9
    /** an array of per-request working data elements, accessed
Packit 90a5c9
     * by ID using ap_get_request_note()
Packit 90a5c9
     * (Use ap_register_request_note() during initialization
Packit 90a5c9
     * to add elements)
Packit 90a5c9
     */
Packit 90a5c9
    void **notes;
Packit 90a5c9
Packit 90a5c9
    /** Custom response strings registered via ap_custom_response(),
Packit 90a5c9
     * or NULL; check per-dir config if nothing found here
Packit 90a5c9
     */
Packit 90a5c9
    char **response_code_strings; /* from ap_custom_response(), not from
Packit 90a5c9
                                   * ErrorDocument
Packit 90a5c9
                                   */
Packit 90a5c9
Packit 90a5c9
    /** per-request document root of the server. This allows mass vhosting
Packit 90a5c9
     * modules better compatibility with some scripts. Normally the
Packit 90a5c9
     * context_* info should be used instead */
Packit 90a5c9
    const char *document_root;
Packit 90a5c9
Packit 90a5c9
    /*
Packit 90a5c9
     * more fine-grained context information which is set by modules like
Packit 90a5c9
     * mod_alias and mod_userdir
Packit 90a5c9
     */
Packit 90a5c9
    /** the context root directory on disk for the current resource,
Packit 90a5c9
     *  without trailing slash
Packit 90a5c9
     */
Packit 90a5c9
    const char *context_document_root;
Packit 90a5c9
    /** the URI prefix that corresponds to the context_document_root directory,
Packit 90a5c9
     *  without trailing slash
Packit 90a5c9
     */
Packit 90a5c9
    const char *context_prefix;
Packit 90a5c9
Packit 90a5c9
    /** There is a script processor installed on the output filter chain,
Packit 90a5c9
     * so it needs the default_handler to deliver a (script) file into
Packit 90a5c9
     * the chain so it can process it. Normally, default_handler only
Packit 90a5c9
     * serves files on a GET request (assuming the file is actual content),
Packit 90a5c9
     * since other methods are not content-retrieval. This flag overrides
Packit 90a5c9
     * that behavior, stating that the "content" is actually a script and
Packit 90a5c9
     * won't actually be delivered as the response for the non-GET method.
Packit 90a5c9
     */
Packit 90a5c9
    int deliver_script;
Packit 90a5c9
Packit 90a5c9
    /** Should addition of charset= be suppressed for this request?
Packit 90a5c9
     */
Packit 90a5c9
    int suppress_charset;
Packit 90a5c9
} core_request_config;
Packit 90a5c9
Packit 90a5c9
/* Standard entries that are guaranteed to be accessible via
Packit 90a5c9
 * ap_get_request_note() for each request (additional entries
Packit 90a5c9
 * can be added with ap_register_request_note())
Packit 90a5c9
 */
Packit 90a5c9
#define AP_NOTE_DIRECTORY_WALK 0
Packit 90a5c9
#define AP_NOTE_LOCATION_WALK  1
Packit 90a5c9
#define AP_NOTE_FILE_WALK      2
Packit 90a5c9
#define AP_NOTE_IF_WALK        3
Packit 90a5c9
#define AP_NUM_STD_NOTES       4
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Reserve an element in the core_request_config->notes array
Packit 90a5c9
 * for some application-specific data
Packit 90a5c9
 * @return An integer key that can be passed to ap_get_request_note()
Packit 90a5c9
 *         during request processing to access this element for the
Packit 90a5c9
 *         current request.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_size_t) ap_register_request_note(void);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Retrieve a pointer to an element in the core_request_config->notes array
Packit 90a5c9
 * @param r The request
Packit 90a5c9
 * @param note_num  A key for the element: either a value obtained from
Packit 90a5c9
 *        ap_register_request_note() or one of the predefined AP_NOTE_*
Packit 90a5c9
 *        values.
Packit 90a5c9
 * @return NULL if the note_num is invalid, otherwise a pointer to the
Packit 90a5c9
 *         requested note element.
Packit 90a5c9
 * @remark At the start of a request, each note element is NULL.  The
Packit 90a5c9
 *         handle provided by ap_get_request_note() is a pointer-to-pointer
Packit 90a5c9
 *         so that the caller can point the element to some app-specific
Packit 90a5c9
 *         data structure.  The caller should guarantee that any such
Packit 90a5c9
 *         structure will last as long as the request itself.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num);
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
typedef unsigned char allow_options_t;
Packit 90a5c9
typedef unsigned int overrides_t;
Packit 90a5c9
Packit 90a5c9
/*
Packit 90a5c9
 * Bits of info that go into making an ETag for a file
Packit 90a5c9
 * document.  Why a long?  Because char historically
Packit 90a5c9
 * proved too short for Options, and int can be different
Packit 90a5c9
 * sizes on different platforms.
Packit 90a5c9
 */
Packit 90a5c9
typedef unsigned long etag_components_t;
Packit 90a5c9
Packit 90a5c9
#define ETAG_UNSET 0
Packit 90a5c9
#define ETAG_NONE  (1 << 0)
Packit 90a5c9
#define ETAG_MTIME (1 << 1)
Packit 90a5c9
#define ETAG_INODE (1 << 2)
Packit 90a5c9
#define ETAG_SIZE  (1 << 3)
Packit 90a5c9
#define ETAG_ALL   (ETAG_MTIME | ETAG_INODE | ETAG_SIZE)
Packit 90a5c9
/* This is the default value used */
Packit 90a5c9
#define ETAG_BACKWARD (ETAG_MTIME | ETAG_SIZE)
Packit 90a5c9
Packit 90a5c9
/* Generic ON/OFF/UNSET for unsigned int foo :2 */
Packit 90a5c9
#define AP_CORE_CONFIG_OFF   (0)
Packit 90a5c9
#define AP_CORE_CONFIG_ON    (1)
Packit 90a5c9
#define AP_CORE_CONFIG_UNSET (2)
Packit 90a5c9
Packit 90a5c9
/* Generic merge of flag */
Packit 90a5c9
#define AP_CORE_MERGE_FLAG(field, to, base, over) to->field = \
Packit 90a5c9
               over->field != AP_CORE_CONFIG_UNSET            \
Packit 90a5c9
               ? over->field                                  \
Packit 90a5c9
               : base->field                                   
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @brief Server Signature Enumeration
Packit 90a5c9
 */
Packit 90a5c9
typedef enum {
Packit 90a5c9
    srv_sig_unset,
Packit 90a5c9
    srv_sig_off,
Packit 90a5c9
    srv_sig_on,
Packit 90a5c9
    srv_sig_withmail
Packit 90a5c9
} server_signature_e;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @brief Per-directory configuration
Packit 90a5c9
 */
Packit 90a5c9
typedef struct {
Packit 90a5c9
    /** path of the directory/regex/etc. see also d_is_fnmatch/absolute below */
Packit 90a5c9
    char *d;
Packit 90a5c9
    /** the number of slashes in d */
Packit 90a5c9
    unsigned d_components;
Packit 90a5c9
Packit 90a5c9
    /** If (opts & OPT_UNSET) then no absolute assignment to options has
Packit 90a5c9
     * been made.
Packit 90a5c9
     * invariant: (opts_add & opts_remove) == 0
Packit 90a5c9
     * Which said another way means that the last relative (options + or -)
Packit 90a5c9
     * assignment made to each bit is recorded in exactly one of opts_add
Packit 90a5c9
     * or opts_remove.
Packit 90a5c9
     */
Packit 90a5c9
    allow_options_t opts;
Packit 90a5c9
    allow_options_t opts_add;
Packit 90a5c9
    allow_options_t opts_remove;
Packit 90a5c9
    overrides_t override;
Packit 90a5c9
    allow_options_t override_opts;
Packit 90a5c9
Packit 90a5c9
    /* Used to be the custom response config. No longer used. */
Packit 90a5c9
    char **response_code_strings; /* from ErrorDocument, not from
Packit 90a5c9
                                   * ap_custom_response() */
Packit 90a5c9
Packit 90a5c9
    /* Hostname resolution etc */
Packit 90a5c9
#define HOSTNAME_LOOKUP_OFF     0
Packit 90a5c9
#define HOSTNAME_LOOKUP_ON      1
Packit 90a5c9
#define HOSTNAME_LOOKUP_DOUBLE  2
Packit 90a5c9
#define HOSTNAME_LOOKUP_UNSET   3
Packit 90a5c9
    unsigned int hostname_lookups : 4;
Packit 90a5c9
Packit 90a5c9
    unsigned int content_md5 : 2;  /* calculate Content-MD5? */
Packit 90a5c9
Packit 90a5c9
#define USE_CANONICAL_NAME_OFF   (0)
Packit 90a5c9
#define USE_CANONICAL_NAME_ON    (1)
Packit 90a5c9
#define USE_CANONICAL_NAME_DNS   (2)
Packit 90a5c9
#define USE_CANONICAL_NAME_UNSET (3)
Packit 90a5c9
    unsigned use_canonical_name : 2;
Packit 90a5c9
Packit 90a5c9
    /* since is_fnmatch(conf->d) was being called so frequently in
Packit 90a5c9
     * directory_walk() and its relatives, this field was created and
Packit 90a5c9
     * is set to the result of that call.
Packit 90a5c9
     */
Packit 90a5c9
    unsigned d_is_fnmatch : 1;
Packit 90a5c9
Packit 90a5c9
    /* should we force a charset on any outgoing parameterless content-type?
Packit 90a5c9
     * if so, which charset?
Packit 90a5c9
     */
Packit 90a5c9
#define ADD_DEFAULT_CHARSET_OFF   (0)
Packit 90a5c9
#define ADD_DEFAULT_CHARSET_ON    (1)
Packit 90a5c9
#define ADD_DEFAULT_CHARSET_UNSET (2)
Packit 90a5c9
    unsigned add_default_charset : 2;
Packit 90a5c9
    const char *add_default_charset_name;
Packit 90a5c9
Packit 90a5c9
    /* System Resource Control */
Packit 90a5c9
#ifdef RLIMIT_CPU
Packit 90a5c9
    struct rlimit *limit_cpu;
Packit 90a5c9
#endif
Packit 90a5c9
#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
Packit 90a5c9
    struct rlimit *limit_mem;
Packit 90a5c9
#endif
Packit 90a5c9
#ifdef RLIMIT_NPROC
Packit 90a5c9
    struct rlimit *limit_nproc;
Packit 90a5c9
#endif
Packit 90a5c9
    apr_off_t limit_req_body;      /* limit on bytes in request msg body */
Packit 90a5c9
    long limit_xml_body;           /* limit on bytes in XML request msg body */
Packit 90a5c9
Packit 90a5c9
    /* logging options */
Packit 90a5c9
Packit 90a5c9
    server_signature_e server_signature;
Packit 90a5c9
Packit 90a5c9
    /* Access control */
Packit 90a5c9
    apr_array_header_t *sec_file;
Packit 90a5c9
    apr_array_header_t *sec_if;
Packit 90a5c9
    ap_regex_t *r;
Packit 90a5c9
Packit 90a5c9
    const char *mime_type;       /* forced with ForceType  */
Packit 90a5c9
    const char *handler;         /* forced by something other than SetHandler */
Packit 90a5c9
    const char *output_filters;  /* forced with SetOutputFilters */
Packit 90a5c9
    const char *input_filters;   /* forced with SetInputFilters */
Packit 90a5c9
    int accept_path_info;        /* forced with AcceptPathInfo */
Packit 90a5c9
Packit 90a5c9
    /*
Packit 90a5c9
     * What attributes/data should be included in ETag generation?
Packit 90a5c9
     */
Packit 90a5c9
    etag_components_t etag_bits;
Packit 90a5c9
    etag_components_t etag_add;
Packit 90a5c9
    etag_components_t etag_remove;
Packit 90a5c9
Packit 90a5c9
    /*
Packit 90a5c9
     * Run-time performance tuning
Packit 90a5c9
     */
Packit 90a5c9
#define ENABLE_MMAP_OFF    (0)
Packit 90a5c9
#define ENABLE_MMAP_ON     (1)
Packit 90a5c9
#define ENABLE_MMAP_UNSET  (2)
Packit 90a5c9
    unsigned int enable_mmap : 2;  /* whether files in this dir can be mmap'ed */
Packit 90a5c9
Packit 90a5c9
#define ENABLE_SENDFILE_OFF    (0)
Packit 90a5c9
#define ENABLE_SENDFILE_ON     (1)
Packit 90a5c9
#define ENABLE_SENDFILE_UNSET  (2)
Packit 90a5c9
    unsigned int enable_sendfile : 2;  /* files in this dir can be sendfile'ed */
Packit 90a5c9
Packit 90a5c9
#define USE_CANONICAL_PHYS_PORT_OFF   (0)
Packit 90a5c9
#define USE_CANONICAL_PHYS_PORT_ON    (1)
Packit 90a5c9
#define USE_CANONICAL_PHYS_PORT_UNSET (2)
Packit 90a5c9
    unsigned int use_canonical_phys_port : 2;
Packit 90a5c9
Packit 90a5c9
    unsigned int allow_encoded_slashes : 1; /* URLs may contain %2f w/o being
Packit 90a5c9
                                             * pitched indiscriminately */
Packit 90a5c9
    unsigned int decode_encoded_slashes : 1; /* whether to decode encoded slashes in URLs */
Packit 90a5c9
Packit 90a5c9
#define AP_CONDITION_IF        1
Packit 90a5c9
#define AP_CONDITION_ELSE      2
Packit 90a5c9
#define AP_CONDITION_ELSEIF    (AP_CONDITION_ELSE|AP_CONDITION_IF)
Packit 90a5c9
    unsigned int condition_ifelse : 2; /* is this an <If>, <ElseIf>, or <Else> */
Packit 90a5c9
Packit 90a5c9
    ap_expr_info_t *condition;   /* Conditionally merge <If> sections */
Packit 90a5c9
Packit 90a5c9
    /** per-dir log config */
Packit 90a5c9
    struct ap_logconf *log;
Packit 90a5c9
Packit 90a5c9
    /** Table of directives allowed per AllowOverrideList */
Packit 90a5c9
    apr_table_t *override_list;
Packit 90a5c9
Packit 90a5c9
#define AP_MAXRANGES_UNSET     -1
Packit 90a5c9
#define AP_MAXRANGES_DEFAULT   -2
Packit 90a5c9
#define AP_MAXRANGES_UNLIMITED -3
Packit 90a5c9
#define AP_MAXRANGES_NORANGES   0
Packit 90a5c9
    /** Number of Ranges before returning HTTP_OK. **/
Packit 90a5c9
    int max_ranges;
Packit 90a5c9
    /** Max number of Range overlaps (merges) allowed **/
Packit 90a5c9
    int max_overlaps;
Packit 90a5c9
    /** Max number of Range reversals (eg: 200-300, 100-125) allowed **/
Packit 90a5c9
    int max_reversals;
Packit 90a5c9
Packit 90a5c9
    /** Named back references */
Packit 90a5c9
    apr_array_header_t *refs;
Packit 90a5c9
Packit 90a5c9
    /** Custom response config with expression support. The hash table
Packit 90a5c9
     * contains compiled expressions keyed against the custom response
Packit 90a5c9
     * code.
Packit 90a5c9
     */
Packit 90a5c9
    apr_hash_t *response_code_exprs;
Packit 90a5c9
Packit 90a5c9
#define AP_CGI_PASS_AUTH_OFF     (0)
Packit 90a5c9
#define AP_CGI_PASS_AUTH_ON      (1)
Packit 90a5c9
#define AP_CGI_PASS_AUTH_UNSET   (2)
Packit 90a5c9
    /** CGIPassAuth: Whether HTTP authorization headers will be passed to
Packit 90a5c9
     * scripts as CGI variables; affects all modules calling
Packit 90a5c9
     * ap_add_common_vars(), as well as any others using this field as 
Packit 90a5c9
     * advice
Packit 90a5c9
     */
Packit 90a5c9
    unsigned int cgi_pass_auth : 2;
Packit 90a5c9
    unsigned int qualify_redirect_url :2;
Packit 90a5c9
    ap_expr_info_t  *expr_handler;         /* forced with SetHandler */
Packit 90a5c9
Packit 90a5c9
    /** Table of rules for building CGI variables, NULL if none configured */
Packit 90a5c9
    apr_hash_t *cgi_var_rules;
Packit 90a5c9
} core_dir_config;
Packit 90a5c9
Packit 90a5c9
/* macro to implement off by default behaviour */
Packit 90a5c9
#define AP_SENDFILE_ENABLED(x) \
Packit 90a5c9
    ((x) == ENABLE_SENDFILE_ON ? APR_SENDFILE_ENABLED : 0)
Packit 90a5c9
Packit 90a5c9
/* Per-server core configuration */
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
Packit 90a5c9
    char *gprof_dir;
Packit 90a5c9
Packit 90a5c9
    /* Name translations --- we want the core to be able to do *something*
Packit 90a5c9
     * so it's at least a minimally functional web server on its own (and
Packit 90a5c9
     * can be tested that way).  But let's keep it to the bare minimum:
Packit 90a5c9
     */
Packit 90a5c9
    const char *ap_document_root;
Packit 90a5c9
Packit 90a5c9
    /* Access control */
Packit 90a5c9
Packit 90a5c9
    char *access_name;
Packit 90a5c9
    apr_array_header_t *sec_dir;
Packit 90a5c9
    apr_array_header_t *sec_url;
Packit 90a5c9
Packit 90a5c9
    /* recursion backstopper */
Packit 90a5c9
    int redirect_limit; /* maximum number of internal redirects */
Packit 90a5c9
    int subreq_limit;   /* maximum nesting level of subrequests */
Packit 90a5c9
Packit 90a5c9
    const char *protocol;
Packit 90a5c9
    apr_table_t *accf_map;
Packit 90a5c9
Packit 90a5c9
    /* array of ap_errorlog_format_item for error log format string */
Packit 90a5c9
    apr_array_header_t *error_log_format;
Packit 90a5c9
    /*
Packit 90a5c9
     * two arrays of arrays of ap_errorlog_format_item for additional information
Packit 90a5c9
     * logged to the error log once per connection/request
Packit 90a5c9
     */
Packit 90a5c9
    apr_array_header_t *error_log_conn;
Packit 90a5c9
    apr_array_header_t *error_log_req;
Packit 90a5c9
Packit 90a5c9
    /* TRACE control */
Packit 90a5c9
#define AP_TRACE_UNSET    -1
Packit 90a5c9
#define AP_TRACE_DISABLE   0
Packit 90a5c9
#define AP_TRACE_ENABLE    1
Packit 90a5c9
#define AP_TRACE_EXTENDED  2
Packit 90a5c9
    int trace_enable;
Packit 90a5c9
#define AP_MERGE_TRAILERS_UNSET    0
Packit 90a5c9
#define AP_MERGE_TRAILERS_ENABLE   1
Packit 90a5c9
#define AP_MERGE_TRAILERS_DISABLE  2
Packit 90a5c9
    int merge_trailers;
Packit 90a5c9
Packit 90a5c9
    apr_array_header_t *protocols;
Packit 90a5c9
    int protocols_honor_order;
Packit 90a5c9
Packit 90a5c9
#define AP_HTTP09_UNSET   0
Packit 90a5c9
#define AP_HTTP09_ENABLE  1
Packit 90a5c9
#define AP_HTTP09_DISABLE 2
Packit 90a5c9
    char http09_enable;
Packit 90a5c9
Packit 90a5c9
#define AP_HTTP_CONFORMANCE_UNSET     0
Packit 90a5c9
#define AP_HTTP_CONFORMANCE_UNSAFE    1
Packit 90a5c9
#define AP_HTTP_CONFORMANCE_STRICT    2
Packit 90a5c9
    char http_conformance;
Packit 90a5c9
Packit 90a5c9
#define AP_HTTP_METHODS_UNSET         0
Packit 90a5c9
#define AP_HTTP_METHODS_LENIENT       1
Packit 90a5c9
#define AP_HTTP_METHODS_REGISTERED    2
Packit 90a5c9
    char http_methods;
Packit 90a5c9
Packit 90a5c9
} core_server_config;
Packit 90a5c9
Packit 90a5c9
/* for AddOutputFiltersByType in core.c */
Packit 90a5c9
void ap_add_output_filters_by_type(request_rec *r);
Packit 90a5c9
Packit 90a5c9
/* for http_config.c */
Packit 90a5c9
void ap_core_reorder_directories(apr_pool_t *, server_rec *);
Packit 90a5c9
Packit 90a5c9
/* for mod_perl */
Packit 90a5c9
AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config);
Packit 90a5c9
AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config);
Packit 90a5c9
AP_CORE_DECLARE(void) ap_add_file_conf(apr_pool_t *p, core_dir_config *conf, void *url_config);
Packit 90a5c9
AP_CORE_DECLARE(const char *) ap_add_if_conf(apr_pool_t *p, core_dir_config *conf, void *url_config);
Packit 90a5c9
AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);
Packit 90a5c9
Packit 90a5c9
/* Core filters; not exported. */
Packit 90a5c9
apr_status_t ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
Packit 90a5c9
                                  ap_input_mode_t mode, apr_read_type_e block,
Packit 90a5c9
                                  apr_off_t readbytes);
Packit 90a5c9
apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *b);
Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s);
Packit 90a5c9
AP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto);
Packit 90a5c9
Packit 90a5c9
typedef struct core_output_filter_ctx core_output_filter_ctx_t;
Packit 90a5c9
typedef struct core_filter_ctx        core_ctx_t;
Packit 90a5c9
Packit 90a5c9
typedef struct core_net_rec {
Packit 90a5c9
    /** Connection to the client */
Packit 90a5c9
    apr_socket_t *client_socket;
Packit 90a5c9
Packit 90a5c9
    /** connection record */
Packit 90a5c9
    conn_rec *c;
Packit 90a5c9
Packit 90a5c9
    core_output_filter_ctx_t *out_ctx;
Packit 90a5c9
    core_ctx_t *in_ctx;
Packit 90a5c9
} core_net_rec;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Insert the network bucket into the core input filter's input brigade.
Packit 90a5c9
 * This hook is intended for MPMs or protocol modules that need to do special
Packit 90a5c9
 * socket setup.
Packit 90a5c9
 * @param c The connection
Packit 90a5c9
 * @param bb The brigade to insert the bucket into
Packit 90a5c9
 * @param socket The socket to put into a bucket
Packit 90a5c9
 * @return AP_DECLINED if the current function does not handle this connection,
Packit 90a5c9
 *         APR_SUCCESS or an error otherwise.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(apr_status_t, insert_network_bucket,
Packit 90a5c9
                (conn_rec *c, apr_bucket_brigade *bb, apr_socket_t *socket))
Packit 90a5c9
Packit 90a5c9
/* ----------------------------------------------------------------------
Packit 90a5c9
 *
Packit 90a5c9
 * Runtime status/management
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
typedef enum {
Packit 90a5c9
    ap_mgmt_type_string,
Packit 90a5c9
    ap_mgmt_type_long,
Packit 90a5c9
    ap_mgmt_type_hash
Packit 90a5c9
} ap_mgmt_type_e;
Packit 90a5c9
Packit 90a5c9
typedef union {
Packit 90a5c9
    const char *s_value;
Packit 90a5c9
    long i_value;
Packit 90a5c9
    apr_hash_t *h_value;
Packit 90a5c9
} ap_mgmt_value;
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    const char *description;
Packit 90a5c9
    const char *name;
Packit 90a5c9
    ap_mgmt_type_e vtype;
Packit 90a5c9
    ap_mgmt_value v;
Packit 90a5c9
} ap_mgmt_item_t;
Packit 90a5c9
Packit 90a5c9
/* Handles for core filters */
Packit 90a5c9
AP_DECLARE_DATA extern ap_filter_rec_t *ap_subreq_core_filter_handle;
Packit 90a5c9
AP_DECLARE_DATA extern ap_filter_rec_t *ap_core_output_filter_handle;
Packit 90a5c9
AP_DECLARE_DATA extern ap_filter_rec_t *ap_content_length_filter_handle;
Packit 90a5c9
AP_DECLARE_DATA extern ap_filter_rec_t *ap_core_input_filter_handle;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * This hook provdes a way for modules to provide metrics/statistics about
Packit 90a5c9
 * their operational status.
Packit 90a5c9
 *
Packit 90a5c9
 * @param p A pool to use to create entries in the hash table
Packit 90a5c9
 * @param val The name of the parameter(s) that is wanted. This is
Packit 90a5c9
 *            tree-structured would be in the form ('*' is all the tree,
Packit 90a5c9
 *            'module.*' all of the module , 'module.foo.*', or
Packit 90a5c9
 *            'module.foo.bar' )
Packit 90a5c9
 * @param ht The hash table to store the results. Keys are item names, and
Packit 90a5c9
 *           the values point to ap_mgmt_item_t structures.
Packit 90a5c9
 * @ingroup hooks
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(int, get_mgmt_items,
Packit 90a5c9
                (apr_pool_t *p, const char * val, apr_hash_t *ht))
Packit 90a5c9
Packit 90a5c9
/* ---------------------------------------------------------------------- */
Packit 90a5c9
Packit 90a5c9
/* ----------------------------------------------------------------------
Packit 90a5c9
 *
Packit 90a5c9
 * I/O logging with mod_logio
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out,
Packit 90a5c9
                        (conn_rec *c, apr_off_t bytes));
Packit 90a5c9
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_in,
Packit 90a5c9
                        (conn_rec *c, apr_off_t bytes));
Packit 90a5c9
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(apr_off_t, ap_logio_get_last_bytes, (conn_rec *c));
Packit 90a5c9
Packit 90a5c9
/* ----------------------------------------------------------------------
Packit 90a5c9
 *
Packit 90a5c9
 * Error log formats
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * The info structure passed to callback functions of errorlog handlers.
Packit 90a5c9
 * Not all information is available in all contexts. In particular, all
Packit 90a5c9
 * pointers may be NULL.
Packit 90a5c9
 */
Packit 90a5c9
typedef struct ap_errorlog_info {
Packit 90a5c9
    /** current server_rec.
Packit 90a5c9
     *  Should be preferred over c->base_server and r->server
Packit 90a5c9
     */
Packit 90a5c9
    const server_rec *s;
Packit 90a5c9
Packit 90a5c9
    /** current conn_rec.
Packit 90a5c9
     *  Should be preferred over r->connection
Packit 90a5c9
     */
Packit 90a5c9
    const conn_rec *c;
Packit 90a5c9
Packit 90a5c9
    /** current request_rec. */
Packit 90a5c9
    const request_rec *r;
Packit 90a5c9
    /** r->main if r is a subrequest, otherwise equal to r */
Packit 90a5c9
    const request_rec *rmain;
Packit 90a5c9
Packit 90a5c9
    /** pool passed to ap_log_perror, NULL otherwise */
Packit 90a5c9
    apr_pool_t *pool;
Packit 90a5c9
Packit 90a5c9
    /** name of source file where the log message was produced, NULL if N/A. */
Packit 90a5c9
    const char *file;
Packit 90a5c9
    /** line number in the source file, 0 if N/A */
Packit 90a5c9
    int line;
Packit 90a5c9
Packit 90a5c9
    /** module index of module that produced the log message, APLOG_NO_MODULE if N/A. */
Packit 90a5c9
    int module_index;
Packit 90a5c9
    /** log level of error message (flags like APLOG_STARTUP have been removed), -1 if N/A */
Packit 90a5c9
    int level;
Packit 90a5c9
Packit 90a5c9
    /** apr error status related to the log message, 0 if no error */
Packit 90a5c9
    apr_status_t status;
Packit 90a5c9
Packit 90a5c9
    /** 1 if logging to syslog, 0 otherwise */
Packit 90a5c9
    int using_syslog;
Packit 90a5c9
    /** 1 if APLOG_STARTUP was set for the log message, 0 otherwise */
Packit 90a5c9
    int startup;
Packit 90a5c9
Packit 90a5c9
    /** message format */
Packit 90a5c9
    const char *format;
Packit 90a5c9
} ap_errorlog_info;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * callback function prototype for a external errorlog handler
Packit 90a5c9
 * @note To avoid unbounded memory usage, these functions must not allocate
Packit 90a5c9
 * memory from the server, connection, or request pools. If an errorlog
Packit 90a5c9
 * handler absolutely needs a pool to pass to other functions, it must create
Packit 90a5c9
 * and destroy a sub-pool.
Packit 90a5c9
 */
Packit 90a5c9
typedef int ap_errorlog_handler_fn_t(const ap_errorlog_info *info,
Packit 90a5c9
                                     const char *arg, char *buf, int buflen);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Register external errorlog handler
Packit 90a5c9
 * @param p config pool to use
Packit 90a5c9
 * @param tag the new format specifier (i.e. the letter after the %)
Packit 90a5c9
 * @param handler the handler function
Packit 90a5c9
 * @param flags flags (reserved, set to 0)
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(void) ap_register_errorlog_handler(apr_pool_t *p, char *tag,
Packit 90a5c9
                                              ap_errorlog_handler_fn_t *handler,
Packit 90a5c9
                                              int flags);
Packit 90a5c9
Packit 90a5c9
typedef struct ap_errorlog_handler {
Packit 90a5c9
    ap_errorlog_handler_fn_t *func;
Packit 90a5c9
    int flags; /* for future extensions */
Packit 90a5c9
} ap_errorlog_handler;
Packit 90a5c9
Packit 90a5c9
  /** item starts a new field */
Packit 90a5c9
#define AP_ERRORLOG_FLAG_FIELD_SEP       1
Packit 90a5c9
  /** item is the actual error message */
Packit 90a5c9
#define AP_ERRORLOG_FLAG_MESSAGE         2
Packit 90a5c9
  /** skip whole line if item is zero-length */
Packit 90a5c9
#define AP_ERRORLOG_FLAG_REQUIRED        4
Packit 90a5c9
  /** log zero-length item as '-' */
Packit 90a5c9
#define AP_ERRORLOG_FLAG_NULL_AS_HYPHEN  8
Packit 90a5c9
Packit 90a5c9
typedef struct {
Packit 90a5c9
    /** ap_errorlog_handler function */
Packit 90a5c9
    ap_errorlog_handler_fn_t *func;
Packit 90a5c9
    /** argument passed to item in {} */
Packit 90a5c9
    const char *arg;
Packit 90a5c9
    /** a combination of the AP_ERRORLOG_* flags */
Packit 90a5c9
    unsigned int flags;
Packit 90a5c9
    /** only log item if the message's log level is higher than this */
Packit 90a5c9
    unsigned int min_loglevel;
Packit 90a5c9
} ap_errorlog_format_item;
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * hook method to log error messages
Packit 90a5c9
 * @ingroup hooks
Packit 90a5c9
 * @param info pointer to ap_errorlog_info struct which contains all
Packit 90a5c9
 *        the details
Packit 90a5c9
 * @param errstr the (unformatted) message to log
Packit 90a5c9
 * @warning Allocating from the usual pools (pool, info->c->pool, info->p->pool)
Packit 90a5c9
 *          must be avoided because it can cause memory leaks.
Packit 90a5c9
 *          Use a subpool if necessary.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE_HOOK(void, error_log, (const ap_errorlog_info *info,
Packit 90a5c9
                                  const char *errstr))
Packit 90a5c9
Packit 90a5c9
AP_CORE_DECLARE(void) ap_register_log_hooks(apr_pool_t *p);
Packit 90a5c9
AP_CORE_DECLARE(void) ap_register_config_hooks(apr_pool_t *p);
Packit 90a5c9
Packit 90a5c9
/* ----------------------------------------------------------------------
Packit 90a5c9
 *
Packit 90a5c9
 * ident lookups with mod_ident
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(const char *, ap_ident_lookup,
Packit 90a5c9
                        (request_rec *r));
Packit 90a5c9
Packit 90a5c9
/* ----------------------------------------------------------------------
Packit 90a5c9
 *
Packit 90a5c9
 * authorization values with mod_authz_core
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(int, authz_some_auth_required, (request_rec *r));
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_type, (request_rec *r));
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_name, (request_rec *r));
Packit 90a5c9
Packit 90a5c9
/* ----------------------------------------------------------------------
Packit 90a5c9
 *
Packit 90a5c9
 * authorization values with mod_access_compat
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
APR_DECLARE_OPTIONAL_FN(int, access_compat_ap_satisfies, (request_rec *r));
Packit 90a5c9
Packit 90a5c9
/* ---------------------------------------------------------------------- */
Packit 90a5c9
Packit 90a5c9
/** Query the server for some state information
Packit 90a5c9
 * @param query_code Which information is requested
Packit 90a5c9
 * @return the requested state information
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(int) ap_state_query(int query_code);
Packit 90a5c9
Packit 90a5c9
/*
Packit 90a5c9
 * possible values for query_code in ap_state_query()
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
  /** current status of the server */
Packit 90a5c9
#define AP_SQ_MAIN_STATE        0
Packit 90a5c9
  /** are we going to serve requests or are we just testing/dumping config */
Packit 90a5c9
#define AP_SQ_RUN_MODE          1
Packit 90a5c9
    /** generation of the top-level apache parent */
Packit 90a5c9
#define AP_SQ_CONFIG_GEN        2
Packit 90a5c9
Packit 90a5c9
/*
Packit 90a5c9
 * return values for ap_state_query()
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
  /** return value for unknown query_code */
Packit 90a5c9
#define AP_SQ_NOT_SUPPORTED       -1
Packit 90a5c9
Packit 90a5c9
/* values returned for AP_SQ_MAIN_STATE */
Packit 90a5c9
  /** before the config preflight */
Packit 90a5c9
#define AP_SQ_MS_INITIAL_STARTUP   1
Packit 90a5c9
  /** initial configuration run for setting up log config, etc. */
Packit 90a5c9
#define AP_SQ_MS_CREATE_PRE_CONFIG 2
Packit 90a5c9
  /** tearing down configuration */
Packit 90a5c9
#define AP_SQ_MS_DESTROY_CONFIG    3
Packit 90a5c9
  /** normal configuration run */
Packit 90a5c9
#define AP_SQ_MS_CREATE_CONFIG     4
Packit 90a5c9
  /** running the MPM */
Packit 90a5c9
#define AP_SQ_MS_RUN_MPM           5
Packit 90a5c9
  /** cleaning up for exit */
Packit 90a5c9
#define AP_SQ_MS_EXITING           6
Packit 90a5c9
Packit 90a5c9
/* values returned for AP_SQ_RUN_MODE */
Packit 90a5c9
  /** command line not yet parsed */
Packit 90a5c9
#define AP_SQ_RM_UNKNOWN           1
Packit 90a5c9
  /** normal operation (server requests or signal server) */
Packit 90a5c9
#define AP_SQ_RM_NORMAL            2
Packit 90a5c9
  /** config test only */
Packit 90a5c9
#define AP_SQ_RM_CONFIG_TEST       3
Packit 90a5c9
  /** only dump some parts of the config */
Packit 90a5c9
#define AP_SQ_RM_CONFIG_DUMP       4
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
}
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#endif  /* !APACHE_HTTP_CORE_H */
Packit 90a5c9
/** @} */