http_core.h revision d0d4515ee39dfff34bae489b5390af964c5d4cfc
2N/A/* ====================================================================
2N/A * The Apache Software License, Version 1.1
2N/A *
2N/A * Copyright (c) 2000 The Apache Software Foundation. All rights
2N/A * reserved.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions
2N/A * are met:
2N/A *
2N/A * 1. Redistributions of source code must retain the above copyright
2N/A * notice, this list of conditions and the following disclaimer.
2N/A *
2N/A * 2. Redistributions in binary form must reproduce the above copyright
2N/A * notice, this list of conditions and the following disclaimer in
2N/A * the documentation and/or other materials provided with the
2N/A * distribution.
2N/A *
2N/A * 3. The end-user documentation included with the redistribution,
2N/A * if any, must include the following acknowledgment:
2515N/A * "This product includes software developed by the
2N/A * Apache Software Foundation (http://www.apache.org/)."
2N/A * Alternately, this acknowledgment may appear in the software itself,
2N/A * if and wherever such third-party acknowledgments normally appear.
2N/A *
2N/A * 4. The names "Apache" and "Apache Software Foundation" must
2N/A * not be used to endorse or promote products derived from this
2N/A * software without prior written permission. For written
2N/A * permission, please contact apache@apache.org.
2N/A *
2N/A * 5. Products derived from this software may not be called "Apache",
59N/A * nor may "Apache" appear in their name, without prior written
59N/A * permission of the Apache Software Foundation.
2N/A *
2N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
2N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
26N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1470N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1470N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1470N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1470N/A * SUCH DAMAGE.
181N/A * ====================================================================
26N/A *
26N/A * This software consists of voluntary contributions made by many
26N/A * individuals on behalf of the Apache Software Foundation. For more
26N/A * information on the Apache Software Foundation, please see
26N/A * <http://www.apache.org/>.
26N/A *
26N/A * Portions of this software are based upon public domain software
26N/A * originally written at the National Center for Supercomputing Applications,
700N/A * University of Illinois, Urbana-Champaign.
700N/A */
26N/A
26N/A#ifndef APACHE_HTTP_CORE_H
26N/A#define APACHE_HTTP_CORE_H
1498N/A
1498N/A#ifdef __cplusplus
26N/Aextern "C" {
1498N/A#endif
151N/A
206N/A#include "apr_lib.h"
26N/A
26N/A/**
26N/A * @package CORE HTTP Daemon
26N/A */
26N/A
26N/A/* ****************************************************************
26N/A *
2N/A * The most basic server code is encapsulated in a single module
26N/A * known as the core, which is just *barely* functional enough to
26N/A * serve documents, though not terribly well.
26N/A *
26N/A * Largely for NCSA back-compatibility reasons, the core needs to
883N/A * make pieces of its config structures available to other modules.
26N/A * The accessors are declared here, along with the interpretation
26N/A * of one of them (allow_options).
26N/A */
26N/A
1043N/A#define OPT_NONE 0
586N/A#define OPT_INDEXES 1
26N/A#define OPT_INCLUDES 2
93N/A#define OPT_SYM_LINKS 4
166N/A#define OPT_EXECCGI 8
26N/A#define OPT_UNSET 16
379N/A#define OPT_INCNOEXEC 32
379N/A#define OPT_SYM_OWNER 64
1498N/A#define OPT_MULTI 128
1498N/A#define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|OPT_EXECCGI)
2236N/A
2236N/A/* options for get_remote_host() */
2N/A/* REMOTE_HOST returns the hostname, or NULL if the hostname
26N/A * lookup fails. It will force a DNS lookup according to the
26N/A * HostnameLookups setting.
181N/A */
181N/A#define REMOTE_HOST (0)
181N/A
99N/A/* REMOTE_NAME returns the hostname, or the dotted quad if the
59N/A * hostname lookup fails. It will force a DNS lookup according
12N/A * to the HostnameLookups setting.
30N/A */
1256N/A#define REMOTE_NAME (1)
1256N/A
1256N/A/* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
1256N/A * never forced.
1256N/A */
1256N/A#define REMOTE_NOLOOKUP (2)
1256N/A
1256N/A/* REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
1256N/A * a double reverse lookup, regardless of the HostnameLookups
1256N/A * setting. The result is the (double reverse checked) hostname,
1256N/A * or NULL if any of the lookups fail.
1256N/A */
1256N/A#define REMOTE_DOUBLE_REV (3)
1256N/A
1256N/A#define SATISFY_ALL 0
1256N/A#define SATISFY_ANY 1
1256N/A#define SATISFY_NOSPEC 2
1256N/A
1256N/A/**
1256N/A * Retrieve the value of Options for this request
1256N/A * @param r The current request
1256N/A * @return the Options bitmask
1256N/A * @deffunc int ap_allow_options(request_rec *r)
1256N/A */
1413N/AAP_DECLARE(int) ap_allow_options (request_rec *);
1256N/A/**
26N/A * Retrieve the value of the AllowOverride for this request
26N/A * @param r The current request
1256N/A * @return the overrides bitmask
2N/A * @deffunc int ap_allow_overrides(request_rec *r)
26N/A */
1256N/AAP_DECLARE(int) ap_allow_overrides (request_rec *);
1256N/A/**
185N/A * Retrieve the value of the DefaultType directive, or text/plain if not set
2N/A * @param r The current request
255N/A * @return The default type
145N/A * @deffunc const char *ap_default_type(request_rec *r)
7N/A */
26N/AAP_DECLARE(const char *) ap_default_type (request_rec *);
26N/A/**
38N/A * Retrieve the document root for this server
26N/A * @param r The current request
197N/A * @warning Don't use this! If your request went through a Userdir, or
197N/A * something like that, it'll screw you. But it's back-compatible...
197N/A * @return The document root
197N/A * @deffunc const char *ap_document_root(request_rec *r)
197N/A */
26N/AAP_DECLARE(const char *) ap_document_root (request_rec *);
30N/A/**
26N/A * Lookup the remote client's DNS name or IP address
46N/A * @param conn The current connection
46N/A * @param dir_config The directory config vector from the request
46N/A * @param type The type of lookup to perform. One of:
64N/A * <PRE>
64N/A * REMOTE_HOST returns the hostname, or NULL if the hostname
26N/A * lookup fails. It will force a DNS lookup according to the
46N/A * HostnameLookups setting.
46N/A * REMOTE_NAME returns the hostname, or the dotted quad if the
46N/A * hostname lookup fails. It will force a DNS lookup according
2N/A * to the HostnameLookups setting.
1256N/A * REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
1256N/A * never forced.
1256N/A * REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
1256N/A * a double reverse lookup, regardless of the HostnameLookups
1256N/A * setting. The result is the (double reverse checked)
1256N/A * hostname, or NULL if any of the lookups fail.
1256N/A * </PRE>
1256N/A * @return The remote hostname
1256N/A * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type)
1256N/A */
1256N/AAP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type);
1256N/A/**
2236N/A * Retrieve the login name of the remote user. Undef if it could not be
2236N/A * determined
1256N/A * @param r The current request
1256N/A * @return The user logged in to the client machine
1256N/A * @deffunc const char *ap_get_remote_logname(request_rec *r)
1256N/A */
1256N/AAP_DECLARE(const char *) ap_get_remote_logname(request_rec *r);
1256N/A
1256N/A/* Used for constructing self-referencing URLs, and things like SERVER_PORT,
1256N/A * and SERVER_NAME.
1256N/A */
1934N/A/**
1256N/A * build a fully qualified URL from the uri and information in the request rec
1256N/A * @param p The pool to allocate the URL from
1256N/A * @param uri The path to the requested file
1256N/A * @param r The current request
1256N/A * @return A fully qualified URL
1934N/A * @deffunc char *ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r)
1934N/A */
1256N/AAP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r);
1256N/A/**
1256N/A * Get the current server name from the request
1413N/A * @param r The current request
1413N/A * @return the server name
1413N/A * @deffunc const char *ap_get_server_name(request_rec *r)
1413N/A */
1413N/AAP_DECLARE(const char *) ap_get_server_name(request_rec *r);
1413N/A/**
1413N/A * Get the current server port
1413N/A * @param The current request
1413N/A * @return The server's port
1256N/A * @deffunc unsigned ap_get_server_port(const request_rec *r)
1256N/A */
1256N/AAP_DECLARE(unsigned) ap_get_server_port(const request_rec *r);
1256N/A/**
1934N/A * Return the limit on bytes in request msg body
1256N/A * @param r The current request
1256N/A * @return the maximum number of bytes in the request msg body
1256N/A * @deffunc unsigned long ap_get_limit_req_body(const request_rec *r)
1256N/A */
1256N/AAP_DECLARE(unsigned long) ap_get_limit_req_body(const request_rec *r);
1934N/A/**
1934N/A * Return the limit on bytes in XML request msg body
1256N/A * @param r The current request
1256N/A * @return the maximum number of bytes in XML request msg body
1256N/A * @deffunc size_t ap_get_limit_xml_body(const request_rec *r)
1256N/A */
1256N/AAP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r);
1256N/A/**
1256N/A * Install a custom response handler for a given status
1256N/A * @param r The current request
1256N/A * @param status The status for which the custom response should be used
1256N/A * @param string The custom response. This can be a static string, a file
1256N/A * or a URL
53N/A * @deffunc void ap_custom_response(request_rec *r, int status, char *string)
46N/A */
46N/AAP_DECLARE(void) ap_custom_response(request_rec *r, int status, char *string);
26N/A/**
181N/A * Check for a definition from the server command line
369N/A * @param name The define to check for
181N/A * @return 1 if defined, 0 otherwise
181N/A * @deffunc int ap_exists_config_define(const char *name)
181N/A */
181N/AAP_DECLARE(int) ap_exists_config_define(const char *name);
181N/A/* FIXME! See STATUS about how */
181N/AAP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r);
76N/A
99N/A/* Authentication stuff. This is one of the places where compatibility
181N/A * with the old config files *really* hurts; they don't discriminate at
99N/A * all between different authentication schemes, meaning that we need
26N/A * to maintain common state for all of them in the core, and make it
1549N/A * available to the other modules through interfaces.
1549N/A */
1549N/Atypedef struct require_line require_line;
1929N/A
1929N/A/** A structure to keep track of authorization requirements */
1929N/Astruct require_line {
1929N/A /** Where the require line is in the config file. */
1929N/A int method_mask;
1929N/A /** The complete string from the command line */
1929N/A char *requirement;
1929N/A};
1549N/A
1549N/A/**
1549N/A * Return the type of authorization required for this request
1549N/A * @param r The current request
1555N/A * @return The authorization required
1549N/A * @deffunc const char *ap_auth_type(request_rec *r)
1555N/A */
1555N/AAP_DECLARE(const char *) ap_auth_type (request_rec *);
1549N/A/**
1555N/A * Return the current Authorization realm
1549N/A * @param r The current request
1549N/A * @return The current authorization realm
1549N/A * @deffunc const char *ap_auth_name(request_rec *r)
1549N/A */
1549N/AAP_DECLARE(const char *) ap_auth_name (request_rec *);
1549N/A/**
1549N/A * How the requires lines must be met.
185N/A * @param r The current request
185N/A * @return How the requirements must be met. One of:
1936N/A * <PRE>
1929N/A * SATISFY_ANY -- any of the requirements must be met.
1929N/A * SATISFY_ALL -- all of the requirements must be met.
1549N/A * SATISFY_NOSPEC -- There are no applicable satisfy lines
145N/A * </PRE>
145N/A * @deffunc int ap_satisfies(request_rec *r)
145N/A */
145N/AAP_DECLARE(int) ap_satisfies (request_rec *r);
145N/A/**
117N/A * Retrieve information about all of the requires directives for this request
2515N/A * @param r The current request
84N/A * @return An array of all requires directives for this request
145N/A * @deffunc const apr_array_header_t *ap_requires(request_rec *r)
145N/A */
145N/AAP_DECLARE(const apr_array_header_t *) ap_requires (request_rec *);
1392N/A
1392N/A#ifdef WIN32
1392N/A/*
2515N/A * CGI Script stuff for Win32...
1392N/A */
1392N/Atypedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32,
1392N/A eFileTypeSCRIPT } file_type_e;
1392N/Atypedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY_STRICT,
1392N/A INTERPRETER_SOURCE_REGISTRY, INTERPRETER_SOURCE_SHEBANG
38N/A } interpreter_source_e;
46N/AAP_DECLARE(file_type_e) ap_get_win32_interpreter(const request_rec *,
1899N/A char **interpreter,
1899N/A char **arguments);
99N/A#endif
196N/A
1899N/A#ifdef CORE_PRIVATE
185N/A
99N/A/*
46N/A * Core is also unlike other modules in being implemented in more than
2N/A * one file... so, data structures are declared here, even though most of
145N/A * the code that cares really is in http_core.c. Also, another accessor.
1899N/A */
1899N/A
1899N/Achar *ap_response_code_string (request_rec *r, int error_index);
26N/A
2N/Aextern AP_DECLARE_DATA module core_module;
32N/A
1256N/A/* Per-directory configuration */
32N/A
32N/Atypedef unsigned char allow_options_t;
32N/Atypedef unsigned char overrides_t;
32N/A
1256N/Atypedef struct {
32N/A /* path of the directory/regex/etc. see also d_is_fnmatch below */
32N/A char *d;
32N/A /* the number of slashes in d */
38N/A unsigned d_components;
38N/A
1256N/A /* If (opts & OPT_UNSET) then no absolute assignment to options has
38N/A * been made.
38N/A * invariant: (opts_add & opts_remove) == 0
38N/A * Which said another way means that the last relative (options + or -)
38N/A * assignment made to each bit is recorded in exactly one of opts_add
38N/A * or opts_remove.
38N/A */
38N/A allow_options_t opts;
145N/A allow_options_t opts_add;
38N/A allow_options_t opts_remove;
38N/A overrides_t override;
26N/A
26N/A /* MIME typing --- the core doesn't do anything at all with this,
26N/A * but it does know what to slap on a request for a document which
26N/A * goes untyped by other mechanisms before it slips out the door...
26N/A */
26N/A
26N/A char *ap_default_type;
26N/A
26N/A /* Authentication stuff. Groan... */
32N/A
32N/A int satisfy;
32N/A char *ap_auth_type;
32N/A char *ap_auth_name;
32N/A apr_array_header_t *ap_requires;
32N/A
32N/A /* Custom response config. These can contain text or a URL to redirect to.
32N/A * if response_code_strings is NULL then there are none in the config,
38N/A * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
38N/A * This lets us do quick merges in merge_core_dir_configs().
38N/A */
32N/A
char **response_code_strings;
/* Hostname resolution etc */
#define HOSTNAME_LOOKUP_OFF 0
#define HOSTNAME_LOOKUP_ON 1
#define HOSTNAME_LOOKUP_DOUBLE 2
#define HOSTNAME_LOOKUP_UNSET 3
unsigned int hostname_lookups : 4;
signed int do_rfc1413 : 2; /* See if client is advertising a username? */
signed int content_md5 : 2; /* calculate Content-MD5? */
#define USE_CANONICAL_NAME_OFF (0)
#define USE_CANONICAL_NAME_ON (1)
#define USE_CANONICAL_NAME_DNS (2)
#define USE_CANONICAL_NAME_UNSET (3)
unsigned use_canonical_name : 2;
/* since is_fnmatch(conf->d) was being called so frequently in
* directory_walk() and its relatives, this field was created and
* is set to the result of that call.
*/
unsigned d_is_fnmatch : 1;
/* should we force a charset on any outgoing parameterless content-type?
* if so, which charset?
*/
#define ADD_DEFAULT_CHARSET_OFF (0)
#define ADD_DEFAULT_CHARSET_ON (1)
#define ADD_DEFAULT_CHARSET_UNSET (2)
unsigned add_default_charset : 2;
const char *add_default_charset_name;
/* System Resource Control */
#ifdef RLIMIT_CPU
struct rlimit *limit_cpu;
#endif
#if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
struct rlimit *limit_mem;
#endif
#ifdef RLIMIT_NPROC
struct rlimit *limit_nproc;
#endif
unsigned long limit_req_body; /* limit on bytes in request msg body */
long limit_xml_body; /* limit on bytes in XML request msg body */
/* logging options */
enum { srv_sig_unset, srv_sig_off, srv_sig_on,
srv_sig_withmail } server_signature;
int loglevel;
/* Access control */
apr_array_header_t *sec;
regex_t *r;
#ifdef WIN32
/* Where to find interpreter to run scripts */
interpreter_source_e script_interpreter_source;
#endif
apr_array_header_t *output_filters;
apr_array_header_t *input_filters;
/* bucket brigade held by ap_get_client_block() between calls */
struct ap_bucket_brigade *bb;
} core_dir_config;
/* Per-server core configuration */
typedef struct {
#ifdef GPROF
char *gprof_dir;
#endif
/* Name translations --- we want the core to be able to do *something*
* so it's at least a minimally functional web server on its own (and
* can be tested that way). But let's keep it to the bare minimum:
*/
const char *ap_document_root;
/* Access control */
char *access_name;
apr_array_header_t *sec;
apr_array_header_t *sec_url;
} core_server_config;
/* for http_config.c */
void ap_core_reorder_directories(apr_pool_t *, server_rec *);
/* for mod_perl */
AP_CORE_DECLARE(void) ap_add_per_dir_conf (server_rec *s, void *dir_config);
AP_CORE_DECLARE(void) ap_add_per_url_conf (server_rec *s, void *url_config);
AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_HTTP_CORE_H */