1 /* ====================================================================
2 * The Apache Software License, Version 1.1
4 * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
19 * 3. The end-user documentation included with the redistribution,
20 * if any, must include the following acknowledgment:
21 * "This product includes software developed by the
22 * Apache Software Foundation (http://www.apache.org/)."
23 * Alternately, this acknowledgment may appear in the software itself,
24 * if and wherever such third-party acknowledgments normally appear.
26 * 4. The names "Apache" and "Apache Software Foundation" must
27 * not be used to endorse or promote products derived from this
28 * software without prior written permission. For written
29 * permission, please contact apache@apache.org.
31 * 5. Products derived from this software may not be called "Apache",
32 * nor may "Apache" appear in their name, without prior written
33 * permission of the Apache Software Foundation.
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * ====================================================================
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation. For more
51 * information on the Apache Software Foundation, please see
52 * <http://www.apache.org/>.
54 * Portions of this software are based upon public domain software
55 * originally written at the National Center for Supercomputing Applications,
56 * University of Illinois, Urbana-Champaign.
59 #ifndef APACHE_HTTPD_H
60 #define APACHE_HTTPD_H
63 * httpd.h: header for simple (ha! not anymore) http daemon
66 /* XXX - We need to push more stuff to other .h files, or even .c files, to
67 * make this file smaller
71 * @package HTTP Daemon routines
74 /* Headers in which EVERYONE has an interest... */
75 #include "ap_config.h"
78 #include "ap_release.h"
81 #include "apr_tables.h"
82 #include "apr_pools.h"
84 #include "apr_network_io.h"
86 #include "pcreposix.h"
88 /* Note: util_uri.h is also included, see below */
96 /* ----------------------------- config dir ------------------------------ */
98 /* Define this to be the default server home dir. Most things later in this
99 * file with a relative pathname will have this added.
103 /* Set default for OS/2 file system */
104 #define HTTPD_ROOT "/os2httpd"
106 /* Set default for Windows file system */
107 #define HTTPD_ROOT "/apache"
109 /* Set the default for BeOS */
110 #define HTTPD_ROOT "/boot/home/apache"
112 #define HTTPD_ROOT "/usr/local/apache"
114 #endif /* HTTPD_ROOT */
117 * --------- You shouldn't have to edit anything below this line ----------
119 * Any modifications to any defaults not defined above should be done in the
120 * respective configuration file.
124 /* Default location of documents. Can be overridden by the DocumentRoot
127 #ifndef DOCUMENT_LOCATION
129 /* Set default for OS/2 file system */
130 #define DOCUMENT_LOCATION HTTPD_ROOT "/docs"
132 #define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs"
134 #endif /* DOCUMENT_LOCATION */
136 /* Maximum number of dynamically loaded modules */
137 #ifndef DYNAMIC_MODULE_LIMIT
138 #define DYNAMIC_MODULE_LIMIT 64
141 /* Default administrator's address */
142 #define DEFAULT_ADMIN "[no address given]"
144 /* The name of the log files */
145 #ifndef DEFAULT_ERRORLOG
146 #if defined(OS2) || defined(WIN32)
147 #define DEFAULT_ERRORLOG "logs/error.log"
149 #define DEFAULT_ERRORLOG "logs/error_log"
151 #endif /* DEFAULT_ERRORLOG */
153 /* Define this to be what your per-directory security files are called */
154 #ifndef DEFAULT_ACCESS_FNAME
156 /* Set default for OS/2 file system */
157 #define DEFAULT_ACCESS_FNAME "htaccess"
159 #define DEFAULT_ACCESS_FNAME ".htaccess"
161 #endif /* DEFAULT_ACCESS_FNAME */
163 /* The name of the server config file */
164 #ifndef SERVER_CONFIG_FILE
165 #define SERVER_CONFIG_FILE "conf/httpd.conf"
168 /* Whether we should enable rfc1413 identity checking */
169 #ifndef DEFAULT_RFC1413
170 #define DEFAULT_RFC1413 0
173 /* The default path for CGI scripts if none is currently set */
175 #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
178 /* The path to the suExec wrapper, can be overridden in Configuration */
180 #define SUEXEC_BIN HTTPD_ROOT "/sbin/suexec"
183 /* The timeout for waiting for messages */
184 #ifndef DEFAULT_TIMEOUT
185 #define DEFAULT_TIMEOUT 300
188 /* The timeout for waiting for keepalive timeout until next request */
189 #ifndef DEFAULT_KEEPALIVE_TIMEOUT
190 #define DEFAULT_KEEPALIVE_TIMEOUT 15
193 /* The number of requests to entertain per connection */
194 #ifndef DEFAULT_KEEPALIVE
195 #define DEFAULT_KEEPALIVE 100
198 /* Limits on the size of various request items. These limits primarily
199 * exist to prevent simple denial-of-service attacks on a server based
200 * on misuse of the protocol. The recommended values will depend on the
201 * nature of the server resources -- CGI scripts and database backends
202 * might require large values, but most servers could get by with much
203 * smaller limits than we use below. The request message body size can
204 * be limited by the per-dir config directive LimitRequestBody.
206 * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
207 * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
208 * These two limits can be lowered (but not raised) by the server config
209 * directives LimitRequestLine and LimitRequestFieldsize, respectively.
211 * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
212 * the server config directive LimitRequestFields.
214 #ifndef DEFAULT_LIMIT_REQUEST_LINE
215 #define DEFAULT_LIMIT_REQUEST_LINE 8190
216 #endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */
217 #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
218 #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
219 #endif /* default limit on bytes in any one header field */
220 #ifndef DEFAULT_LIMIT_REQUEST_FIELDS
221 #define DEFAULT_LIMIT_REQUEST_FIELDS 100
222 #endif /* default limit on number of request header fields */
226 * The default default character set name to add if AddDefaultCharset is
227 * enabled. Overridden with AddDefaultCharsetName.
229 #define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1"
231 #endif /* CORE_PRIVATE */
233 #define AP_SERVER_PROTOCOL "HTTP/1.1"
236 /* ------------------ stuff that modules are allowed to look at ----------- */
238 /* Define this to be what your HTML directory content files are called */
239 #ifndef AP_DEFAULT_INDEX
240 #define AP_DEFAULT_INDEX "index.html"
244 /* Define this to be what type you'd like returned for files with unknown */
245 /* suffixes. MUST be all lower case. */
246 #ifndef DEFAULT_CONTENT_TYPE
247 #define DEFAULT_CONTENT_TYPE "text/plain"
250 /* The name of the MIME types file */
251 #ifndef AP_TYPES_CONFIG_FILE
252 #define AP_TYPES_CONFIG_FILE "conf/mime.types"
256 * Define the HTML doctype strings centrally.
258 #define DOCTYPE_HTML_2_0 "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
259 "DTD HTML 2.0//EN\">\n"
260 #define DOCTYPE_HTML_3_2 "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
261 "DTD HTML 3.2 Final//EN\">\n"
262 #define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
263 "DTD HTML 4.0//EN\"\n" \
264 "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
265 #define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
266 "DTD HTML 4.0 Transitional//EN\"\n" \
267 "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
268 #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
269 "DTD HTML 4.0 Frameset//EN\"\n" \
270 "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
272 /* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */
274 #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
275 #define HTTP_VERSION_MAJOR(number) ((number)/1000)
276 #define HTTP_VERSION_MINOR(number) ((number)%1000)
278 /* -------------- Port number for server running standalone --------------- */
280 #define DEFAULT_HTTP_PORT 80
281 #define DEFAULT_HTTPS_PORT 443
282 #define ap_is_default_port(port,r) ((port) == ap_default_port(r))
283 #define ap_http_method(r) ap_run_http_method(r)
284 #define ap_default_port(r) ap_run_default_port(r)
286 /* The default string lengths */
287 #define MAX_STRING_LEN HUGE_STRING_LEN
288 #define HUGE_STRING_LEN 8192
290 /* The size of the server's internal read-write buffers */
291 #define AP_IOBUFSIZE 8192
294 * Special Apache error codes. These are basically used
295 * in http_main.c so we can keep track of various errors.
300 * A fatal error arising during the server's init sequence
302 * The child died during it's init sequence
304 * A fatal error, resulting in the whole server aborting.
305 * If a child exits with this error, the parent process
306 * considers this a server-wide fatal error and aborts.
309 #define APEXIT_OK 0x0
310 #define APEXIT_INIT 0x2
311 #define APEXIT_CHILDINIT 0x3
312 #define APEXIT_CHILDFATAL 0xf
315 * Get the server version string
316 * @return The server version string
317 * @deffunc const char *ap_get_server_version(void)
319 AP_DECLARE(const char *) ap_get_server_version(void);
322 * Add a component to the version string
323 * @param pconf The pool to allocate the component out of
324 * @param component The string to add
325 * @deffunc void ap_add_version_component(apr_pool_t *pconf, const char *component)
327 AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component);
330 * Get the date a time that the server was built
331 * @return The server build time string
333 AP_DECLARE(const char *) ap_get_server_built(void);
335 #define DECLINED -1 /* Module declines to handle */
336 #define DONE -2 /* Module has served the response completely
337 * - it's safe to die() with no more output
339 #define OK 0 /* Module has handled this stage. */
342 /* ----------------------- HTTP Status Codes ------------------------- */
344 /* The size of the static array in http_protocol.c for storing
345 * all of the potential response status-lines (a sparse table).
346 * A future version should dynamically generate the apr_table_t at startup.
348 #define RESPONSE_CODES 55
350 #define HTTP_CONTINUE 100
351 #define HTTP_SWITCHING_PROTOCOLS 101
352 #define HTTP_PROCESSING 102
354 #define HTTP_CREATED 201
355 #define HTTP_ACCEPTED 202
356 #define HTTP_NON_AUTHORITATIVE 203
357 #define HTTP_NO_CONTENT 204
358 #define HTTP_RESET_CONTENT 205
359 #define HTTP_PARTIAL_CONTENT 206
360 #define HTTP_MULTI_STATUS 207
361 #define HTTP_MULTIPLE_CHOICES 300
362 #define HTTP_MOVED_PERMANENTLY 301
363 #define HTTP_MOVED_TEMPORARILY 302
364 #define HTTP_SEE_OTHER 303
365 #define HTTP_NOT_MODIFIED 304
366 #define HTTP_USE_PROXY 305
367 #define HTTP_TEMPORARY_REDIRECT 307
368 #define HTTP_BAD_REQUEST 400
369 #define HTTP_UNAUTHORIZED 401
370 #define HTTP_PAYMENT_REQUIRED 402
371 #define HTTP_FORBIDDEN 403
372 #define HTTP_NOT_FOUND 404
373 #define HTTP_METHOD_NOT_ALLOWED 405
374 #define HTTP_NOT_ACCEPTABLE 406
375 #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
376 #define HTTP_REQUEST_TIME_OUT 408
377 #define HTTP_CONFLICT 409
378 #define HTTP_GONE 410
379 #define HTTP_LENGTH_REQUIRED 411
380 #define HTTP_PRECONDITION_FAILED 412
381 #define HTTP_REQUEST_ENTITY_TOO_LARGE 413
382 #define HTTP_REQUEST_URI_TOO_LARGE 414
383 #define HTTP_UNSUPPORTED_MEDIA_TYPE 415
384 #define HTTP_RANGE_NOT_SATISFIABLE 416
385 #define HTTP_EXPECTATION_FAILED 417
386 #define HTTP_UNPROCESSABLE_ENTITY 422
387 #define HTTP_LOCKED 423
388 #define HTTP_FAILED_DEPENDENCY 424
389 #define HTTP_INTERNAL_SERVER_ERROR 500
390 #define HTTP_NOT_IMPLEMENTED 501
391 #define HTTP_BAD_GATEWAY 502
392 #define HTTP_SERVICE_UNAVAILABLE 503
393 #define HTTP_GATEWAY_TIME_OUT 504
394 #define HTTP_VERSION_NOT_SUPPORTED 505
395 #define HTTP_VARIANT_ALSO_VARIES 506
396 #define HTTP_INSUFFICIENT_STORAGE 507
397 #define HTTP_NOT_EXTENDED 510
399 #define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200))
400 #define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300))
401 #define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400))
402 #define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600))
403 #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
404 #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
406 #define ap_status_drops_connection(x) \
407 (((x) == HTTP_BAD_REQUEST) || \
408 ((x) == HTTP_REQUEST_TIME_OUT) || \
409 ((x) == HTTP_LENGTH_REQUIRED) || \
410 ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
411 ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
412 ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
413 ((x) == HTTP_SERVICE_UNAVAILABLE) || \
414 ((x) == HTTP_NOT_IMPLEMENTED))
416 /* Methods recognized (but not necessarily handled) by the server.
417 * These constants are used in bit shifting masks of size int, so it is
418 * unsafe to have more methods than bits in an int. HEAD == M_GET.
419 * This list must be tracked by the list in http_protocol.c in routine
420 * ap_method_name_of().
431 #define M_PROPPATCH 9
441 typedef struct ap_method_list_t ap_method_list_t;
443 * Structure for handling HTTP methods. Methods known to the server are
444 * accessed via a bitmask shortcut; extension methods are handled by
447 struct ap_method_list_t {
448 /* The bitmask used for known methods */
450 /* The array used for extension methods */
451 apr_array_header_t *method_list;
454 #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
455 #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
456 #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
457 #define DIR_MAGIC_TYPE "httpd/unix-directory"
459 /* Just in case your linefeed isn't the one the other end is expecting. */
460 #if !APR_CHARSET_EBCDIC
463 #define CRLF "\015\012"
464 #else /* APR_CHARSET_EBCDIC */
465 /* For platforms using the EBCDIC charset, the transition ASCII->EBCDIC is done
466 * in the buff package (bread/bputs/bwrite). Everywhere else, we use
467 * "native EBCDIC" CR and NL characters. These are therefore
474 #endif /* APR_CHARSET_EBCDIC */
476 /* Possible values for request_rec.read_body (set by handling module):
477 * REQUEST_NO_BODY Send 413 error if message has any body
478 * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length
479 * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me.
481 #define REQUEST_NO_BODY 0
482 #define REQUEST_CHUNKED_ERROR 1
483 #define REQUEST_CHUNKED_DECHUNK 2
485 /* Things which may vary per file-lookup WITHIN a request ---
486 * e.g., state of MIME config. Basically, the name of an object, info
487 * about the object, and any other info we may ahve which may need to
488 * change as we go poking around looking for it (e.g., overridden by
491 * Note how the default state of almost all these things is properly
492 * zero, so that allocating it with pcalloc does the right thing without
493 * a whole lot of hairy initialization... so long as we are willing to
494 * make the (fairly) portable assumption that the bit pattern of a NULL
495 * pointer is, in fact, zero.
499 * This represents the result of calling htaccess; these are cached for
502 struct htaccess_result {
503 /** the directory to which this applies */
505 /** the overrides allowed for the .htaccess file */
507 /** the configuration directives */
508 struct ap_conf_vector_t *htaccess;
509 /** the next one, or NULL if no more; N.B. never change this */
510 const struct htaccess_result *next;
513 /* The following four types define a hierarchy of activities, so that
514 * given a request_rec r you can write r->connection->server->process
515 * to get to the process_rec. While this reduces substantially the
516 * number of arguments that various hooks require beware that in
517 * threaded versions of the server you must consider multiplexing
520 typedef struct process_rec process_rec;
521 typedef struct server_rec server_rec;
522 typedef struct conn_rec conn_rec;
523 typedef struct request_rec request_rec;
525 /* ### would be nice to not include this from httpd.h ... */
526 /* This comes after we have defined the request_rec type */
527 #include "util_uri.h"
529 /** A structure that represents one process */
531 /** Global pool. Please try to cleared on _all_ exits */
533 /** aka configuration pool, cleared on restarts */
535 /** How many command line arguments were pass to the program */
537 /** The command line arguments */
538 const char * const *argv;
539 /** The program name used to execute the program */
540 const char *short_name;
543 /** A structure that represents the current request */
545 /** The pool associated with the request */
547 /** The connection over which this connection has been read */
548 conn_rec *connection;
549 /** The virtual host this request is for */
552 /** If we wind up getting redirected, pointer to the request we
555 /** If this is an internal redirect, pointer to where we redirected
559 /** If this is a sub_request (see request.h) pointer back to the
563 /* Info about the request itself... we begin with stuff that only
564 * protocol.c should ever touch...
566 /** First line of request, so we can log it */
568 /** HTTP/0.9, "simple" request */
570 /** A proxy request (calculated during post_read_request/translate_name) */
572 /** HEAD request, as opposed to GET */
574 /** Protocol, as given to us, or HTTP/0.9 */
576 /** Number version of protocol; 1.1 = 1001 */
578 /** Host, as set by full URI or Host: */
579 const char *hostname;
581 /** When the request started */
582 apr_time_t request_time;
584 /** Status line, if set by script */
585 const char *status_line;
589 /* Request method, two ways; also, protocol, etc.. Outside of protocol.c,
590 * look, but don't touch.
593 /** GET, HEAD, POST, etc. */
595 /** M_GET, M_POST, etc. */
599 * allowed is a bitvector of the allowed methods.
601 * A handler must ensure that the request method is one that
602 * it is capable of handling. Generally modules should DECLINE
603 * any request methods they do not handle. Prior to aborting the
604 * handler like this the handler should set r->allowed to the list
605 * of methods that it is willing to handle. This bitvector is used
606 * to construct the "Allow:" header required for OPTIONS requests,
607 * and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes.
609 * Since the default_handler deals with OPTIONS, all modules can
610 * usually decline to deal with OPTIONS. TRACE is always allowed,
611 * modules don't need to set it explicitly.
613 * Since the default_handler will always handle a GET, a
614 * module which does *not* implement GET should probably return
615 * HTTP_METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET
616 * handler can't be installed by mod_actions. </PRE>
618 /** Allowed methods - for 405, OPTIONS, etc */
620 /** Array of extension methods */
621 apr_array_header_t *allowed_xmethods;
622 /** List of allowed methods */
623 ap_method_list_t *allowed_methods;
625 /** byte count in stream is for body */
627 /** body byte count, for easy access */
629 /** Time the resource was last modified */
632 /* HTTP/1.1 connection-level features */
634 /** sending chunked transfer-coding */
636 /** multipart/byteranges boundary */
637 const char *boundary;
638 /** The Range: header */
640 /** The "real" content length */
643 /** bytes left to read */
645 /** bytes that have been read */
647 /** how the request body should be read */
649 /** reading chunked transfer-coding */
651 /** is client waiting for a 100 response? */
652 unsigned expecting_100;
654 /* MIME header environments, in and out. Also, an array containing
655 * environment variables to be passed to subprocesses, so people can
656 * write modules to add to that environment.
658 * The difference between headers_out and err_headers_out is that the
659 * latter are printed even on error, and persist across internal redirects
660 * (so the headers printed for ErrorDocument handlers will have them).
662 * The 'notes' apr_table_t is for notes from one module to another, with no
663 * other set purpose in mind...
666 /** MIME header environment from the request */
667 apr_table_t *headers_in;
668 /** MIME header environment for the response */
669 apr_table_t *headers_out;
670 /** MIME header environment for the response, printed even on errors and
671 * persist across internal redirects */
672 apr_table_t *err_headers_out;
673 /** Array of environment variables to be used for sub processes */
674 apr_table_t *subprocess_env;
675 /** Notes from one module to another */
678 /* content_type, handler, content_encoding, content_language, and all
679 * content_languages MUST be lowercased strings. They may be pointers
680 * to static strings; they should not be modified in place.
682 /** The content-type for the current request */
683 const char *content_type; /* Break these out --- we dispatch on 'em */
684 /** The handler string that we use to call a handler function */
685 const char *handler; /* What we *really* dispatch on */
687 /** How to encode the data */
688 const char *content_encoding;
689 /** for back-compat. only -- do not use */
690 const char *content_language;
691 /** array of (char*) representing the content languages */
692 apr_array_header_t *content_languages;
694 /** variant list validator (if negotiated) */
695 char *vlist_validator;
697 /** If an authentication check was made, this gets set to the user name. */
699 /** If an authentication check was made, this gets set to the auth type. */
702 /** This response is non-cache-able */
704 /** There is no local copy of this response */
707 /* What object is being requested (either directly, or via include
708 * or content-negotiation mapping).
711 /** the uri without any parsing performed */
713 /** the path portion of the URI */
715 /** The filename on disk that this response corresponds to */
717 /** The path_info for this request if there is any. */
719 /** QUERY_ARGS, if any */
721 /** ST_MODE set to zero if no such file */
723 /** components of uri, dismantled */
724 uri_components parsed_uri;
726 /* Various other config info which may change with .htaccess files
727 * These are config vectors, with one void* pointer for each module
728 * (the thing pointed to being the module's business).
731 /** Options set in config files, etc. */
732 struct ap_conf_vector_t *per_dir_config;
733 /** Notes on *this* request */
734 struct ap_conf_vector_t *request_config;
737 * a linked list of the configuration directives in the .htaccess files
738 * accessed by this request.
739 * N.B. always add to the head of the list, _never_ to the end.
740 * that way, a sub request's list can (temporarily) point to a parent's list
741 * @defvar const htaccess_result *htaccess
743 const struct htaccess_result *htaccess;
745 /** A list of output filters to be used for this request
746 * @defvar ap_filter_t *output_filters */
747 struct ap_filter_t *output_filters;
748 /** A list of input filters to be used for this request
749 * @defvar ap_filter_t *input_filters */
750 struct ap_filter_t *input_filters;
751 /** A flag to determine if the eos bucket has been sent yet
752 * @defvar int eos_sent */
755 /* Things placed at the end of the record to avoid breaking binary
756 * compatibility. It would be nice to remember to reorder the entire
757 * record to improve 64bit alignment the next time we need to break
758 * binary compatibility for some other reason.
763 /** Structure to store things which are per connection */
765 /** Pool associated with this connection */
767 /** Physical vhost this conn come in on */
768 server_rec *base_server;
769 /** used by http_vhost.c */
770 void *vhost_lookup_data;
772 /* Information about the connection itself */
774 /** Connection to the client */
775 apr_socket_t *client_socket;
777 /* Who is the client? */
780 apr_sockaddr_t *local_addr;
781 /** remote address */
782 apr_sockaddr_t *remote_addr;
783 /** Client's IP address */
785 /** Client's DNS name, if known. NULL if DNS hasn't been checked,
786 * "" if it has and no address was found. N.B. Only access this though
787 * get_remote_host() */
789 /** Only ever set if doing rfc1413 lookups. N.B. Only access this through
790 * get_remote_logname() */
791 char *remote_logname;
793 /** Are we still talking? */
795 /** Are we using HTTP Keep-Alive? -1 fatal error, 0 undecided, 1 yes */
796 signed int keepalive:2;
797 /** Did we use HTTP Keep-Alive? */
798 unsigned keptalive:1;
799 /** have we done double-reverse DNS? -1 yes/failure, 0 not yet,
801 signed int double_reverse:2;
803 /** How many times have we used it? */
805 /** server IP address */
807 /** used for ap_get_server_name when UseCanonicalName is set to DNS
808 * (ignores setting of HostnameLookups) */
811 /** ID of this connection; unique at any point in time */
813 /** Notes on *this* connection */
814 struct ap_conf_vector_t *conn_config;
815 /** send note from one module to another, must remain valid for all
816 * requests on this conn */
818 /** A list of input filters to be used for this connection
819 * @defvar ap_filter_t *input_filters */
820 struct ap_filter_t *input_filters;
821 /** A list of output filters to be used for this connection
822 * @defvar ap_filter_t *filters */
823 struct ap_filter_t *output_filters;
824 /** The length of the current request body
825 * @defvar long remain */
829 /* Per-vhost config... */
831 /* The address 255.255.255.255, when used as a virtualhost address,
832 * will become the "default" server when the ip doesn't match other vhosts.
834 #define DEFAULT_VHOST_ADDR 0xfffffffful
836 typedef struct server_addr_rec server_addr_rec;
838 /** A structure to be used for Per-vhost config */
839 struct server_addr_rec {
840 /** The next server in the list */
841 server_addr_rec *next;
842 /** The bound address, for this server */
843 apr_sockaddr_t *host_addr;
844 /** The bound port, for this server */
845 apr_port_t host_port;
846 /** The name given in <VirtualHost> */
850 /** A structure to store information for each virtual server */
852 /** The process this server is running in */
853 process_rec *process;
854 /** The next server in the list */
857 /** The name of the server */
858 const char *defn_name;
859 /** The line of the config file that the server was defined on */
860 unsigned defn_line_number;
862 /* Contact information */
864 /** The admin's contact information */
866 /** The server hostname */
867 char *server_hostname;
868 /** for redirects, etc. */
871 /* Log files --- note that transfer log is now in the modules... */
873 /** The name of the error log */
875 /** A file descriptor that references the error log */
876 apr_file_t *error_log;
877 /** The log level for this server */
880 /* Module-specific configuration for server, and defaults... */
882 /** true if this is the virtual server */
884 /** Config vector containing pointers to modules' per-server config
886 struct ap_conf_vector_t *module_config;
887 /** MIME type info, etc., before we start checking per-directory info */
888 struct ap_conf_vector_t *lookup_defaults;
890 /* Transaction handling */
892 /** I haven't got a clue */
893 server_addr_rec *addrs;
894 /** Timeout, in seconds, before we give up */
896 /** Seconds we'll wait for another request */
897 int keep_alive_timeout;
898 /** Maximum requests per connection */
900 /** Use persistent connections? */
903 /** Pathname for ServerPath */
905 /** Length of path */
908 /** Normal names for ServerAlias servers */
909 apr_array_header_t *names;
910 /** Wildcarded names for ServerAlias servers */
911 apr_array_header_t *wild_names;
913 /** limit on size of the HTTP request line */
915 /** limit on size of any request header field */
916 int limit_req_fieldsize;
917 /** limit on number of request header fields */
918 int limit_req_fields;
921 /* stuff marked AP_DECLARE is part of the API, and intended for use
925 #define AP_DECLARE(type) type
928 /* Stuff marked AP_DECLARE_NONSTD is part of the API, and intended for
929 * use by modules. The difference between AP_DECLARE and
930 * AP_DECLARE_NONSTD is that the latter is required for any functions
931 * which use varargs or are used via indirect function call. This
932 * is to accomodate the two calling conventions in windows dlls.
934 #ifndef AP_DECLARE_NONSTD
935 #define AP_DECLARE_NONSTD(type) type
938 #ifndef AP_MODULE_DECLARE_DATA
939 #define AP_MODULE_DECLARE_DATA
941 #ifndef AP_DECLARE_DATA
942 #define AP_DECLARE_DATA
945 /* modules should not used functions marked AP_CORE_DECLARE
946 * or AP_CORE_DECLARE_NONSTD */
947 #ifndef AP_CORE_DECLARE
948 #define AP_CORE_DECLARE AP_DECLARE
950 #ifndef AP_CORE_DECLARE_NONSTD
951 #define AP_CORE_DECLARE_NONSTD AP_DECLARE_NONSTD
955 * Examine a field value (such as a media-/content-type) string and return
956 * it sans any parameters; e.g., strip off any ';charset=foo' and the like.
957 * @param p Pool to allocate memory out of
958 * @param intype The field to examine
959 * @return the field minus any parameters
960 * @deffunc char *ap_field_noparam(apr_pool_t *p, const char *intype);
962 AP_DECLARE(char *) ap_field_noparam(apr_pool_t *p, const char *intype);
965 * Convert a time from an integer into a string in a specified format
966 * @param p The pool to allocate memory out of
967 * @param t The time to convert
968 * @param fmt The format to use for the conversion
969 * @param gmt Convert the time for GMT?
970 * @return The string that represents the specified time
971 * @deffunc char *ap_ht_time(apr_pool_t *p, apr_time_t t, const char *fmt, int gmt)
973 AP_DECLARE(char *) ap_ht_time(apr_pool_t *p, apr_time_t t, const char *fmt, int gmt);
975 /* String handling. The *_nc variants allow you to use non-const char **s as
976 arguments (unfortunately C won't automatically convert a char ** to a const
980 * Get the characters until the first occurance of a specified character
981 * @param p The pool to allocate memory out of
982 * @param line The string to get the characters from
983 * @param stop The character to stop at
984 * @return A copy of the characters up to the first stop character
985 * @deffunc char *ap_getword(apr_pool_t *p, const char **line, char stop);
987 AP_DECLARE(char *) ap_getword(apr_pool_t *p, const char **line, char stop);
989 * Get the characters until the first occurance of a specified character
990 * @param p The pool to allocate memory out of
991 * @param line The string to get the characters from
992 * @param stop The character to stop at
993 * @return A copy of the characters up to the first stop character
994 * @tip This is the same as ap_getword, except it doesn't use const char **.
995 * @deffunc char *ap_getword_nc(apr_pool_t *p, char **line, char stop);
997 AP_DECLARE(char *) ap_getword_nc(apr_pool_t *p, char **line, char stop);
1000 * Get the first word from a given string. A word is defined as all characters
1001 * up to the first whitespace.
1002 * @param p The pool to allocate memory from
1003 * @param line The string to traverse
1004 * @retrn The first word in the line
1005 * @deffunc char *ap_getword_white(apr_pool_t *p, const char **line)
1007 AP_DECLARE(char *) ap_getword_white(apr_pool_t *p, const char **line);
1009 * Get the first word from a given string. A word is defined as all characters
1010 * up to the first whitespace.
1011 * @param p The pool to allocate memory from
1012 * @param line The string to traverse
1013 * @retrn The first word in the line
1014 * @tip The same as ap_getword_white, except it doesn't use const char **.
1015 * @deffunc char *ap_getword_white_nc(apr_pool_t *p, const char **line)
1017 AP_DECLARE(char *) ap_getword_white_nc(apr_pool_t *p, char **line);
1020 * Get all characters from the first occurance of stop to the first '\0'
1021 * @param p The pool to allocate memory out of
1022 * @param line The line to traverse
1023 * @param stop The character to start at
1024 * @return A copy of all caracters after the first occurance of the specified
1026 * @deffunc char *ap_getword_nulls(apr_pool_t *p, const char **line, char stop)
1028 AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *p, const char **line, char stop);
1030 * Get all characters from the first occurance of stop to the first '\0'
1031 * @param p The pool to allocate memory out of
1032 * @param line The line to traverse
1033 * @param stop The character to start at
1034 * @return A copy of all caracters after the first occurance of the specified
1036 * @tip The same as ap_getword_nulls, except it doesn't use const char **.
1037 * @deffunc char *ap_getword_nulls_nc(apr_pool_t *p, char **line, char stop)
1039 AP_DECLARE(char *) ap_getword_nulls_nc(apr_pool_t *p, char **line, char stop);
1042 * Get the second word in the string paying attention to quoting
1043 * @param p The pool to allocate out of
1044 * @param line The line to traverse
1045 * @return A copy of the string
1046 * @deffunc char *ap_getword_conf(apr_pool_t *p, const char **line)
1048 AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line);
1050 * Get the second word in the string paying attention to quoting
1051 * @param p The pool to allocate out of
1052 * @param line The line to traverse
1053 * @return A copy of the string
1054 * @tip The same as ap_getword_conf, except it doesn't use const char **.
1055 * @deffunc char *ap_getword_conf_nc(apr_pool_t *p, char **line)
1057 AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line);
1060 * Check a string for any ${ENV} environment variable construct and replace
1061 * each them by the value of that environment variable, if it exists. If the
1062 * environment value does not exist, leave the ${ENV} construct alone; it
1063 * means something else.
1064 * @param p The pool to allocate out of
1065 * @param word The string to check
1066 * @return The string with the replaced environment variables
1067 * @deffunc const char *ap_resolve_env(apr_pool_t *p, const char *word)
1069 AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word);
1072 * Size an HTTP header field list item, as separated by a comma.
1073 * @param field The field to size
1074 * @param len The length of the field
1075 * @return The return value is a pointer to the beginning of the non-empty
1076 * list item within the original string (or NULL if there is none) and the
1077 * address of field is shifted to the next non-comma, non-whitespace
1078 * character. len is the length of the item excluding any beginning whitespace.
1079 * @deffunc const char *ap_size_list_item(const char **field, int *len)
1081 AP_DECLARE(const char *) ap_size_list_item(const char **field, int *len);
1084 * Retrieve an HTTP header field list item, as separated by a comma,
1085 * while stripping insignificant whitespace and lowercasing anything not in
1086 * a quoted string or comment.
1087 * @param p The pool to allocate out of
1088 * @param field The field to retrieve
1089 * @return The return value is a new string containing the converted list
1090 * item (or NULL if none) and the address pointed to by field is
1091 * shifted to the next non-comma, non-whitespace.
1092 * @deffunc char *ap_get_list_item(apr_pool_t *p, const char **field)
1094 AP_DECLARE(char *) ap_get_list_item(apr_pool_t *p, const char **field);
1097 * Find an item in canonical form (lowercase, no extra spaces) within
1098 * an HTTP field value list.
1099 * @param p The pool to allocate out of
1100 * @param line The field value list to search
1101 * @param tok The token to search for
1102 * @return 1 if found, 0 if not found.
1103 * @deffunc int ap_find_list_item(apr_pool_t *p, const char *line, const char *tok)
1105 AP_DECLARE(int) ap_find_list_item(apr_pool_t *p, const char *line, const char *tok);
1108 * Retrieve a token, spacing over it and returning a pointer to
1109 * the first non-white byte afterwards. Note that these tokens
1110 * are delimited by semis and commas; and can also be delimited
1111 * by whitespace at the caller's option.
1112 * @param p The pool to allocate out of
1113 * @param accept_line The line to retrieve the token from
1114 * @param accept_white Is it delimited by whitespace
1115 * @return the first non-white byte after the token
1116 * @deffunc char *ap_get_token(apr_pool_t *p, const char **accept_line, int accept_white)
1118 AP_DECLARE(char *) ap_get_token(apr_pool_t *p, const char **accept_line, int accept_white);
1121 * find http tokens, see the definition of token from RFC2068
1122 * @param p The pool to allocate out of
1123 * @param line The line to find the token
1124 * @param tok The token to find
1125 * @return 1 if the token is found, 0 otherwise
1126 * @deffunc int ap_find_token(apr_pool_t *p, const char *line, const char *tok)
1128 AP_DECLARE(int) ap_find_token(apr_pool_t *p, const char *line, const char *tok);
1131 * find http tokens from the end of the line
1132 * @param p The pool to allocate out of
1133 * @param line The line to find the token
1134 * @param tok The token to find
1135 * @return 1 if the token is found, 0 otherwise
1136 * @deffunc int ap_find_last_token(apr_pool_t *p, const char *line, const char *tok)
1138 AP_DECLARE(int) ap_find_last_token(apr_pool_t *p, const char *line, const char *tok);
1141 * Check for an Absolute URI syntax
1142 * @param u The string to check
1143 * @return 1 if URI, 0 otherwise
1144 * @deffunc int ap_is_url(const char *u)
1146 AP_DECLARE(int) ap_is_url(const char *u);
1150 * @param url The url to unescapte
1151 * @return 0 on success, non-zero otherwise
1152 * @deffunc int ap_unescape_url(char *url)
1154 AP_DECLARE(int) ap_unescape_url(char *url);
1156 * Remove all double slashes from a string
1157 * @param name The string to parse
1158 * @deffunc void ap_no2slash(char *name)
1160 AP_DECLARE(void) ap_no2slash(char *name);
1163 * Remove all ./ and ../ substrings from a file name
1164 * @param name the file name to parse
1165 * @deffunc void ap_getparents(char *name)
1167 AP_DECLARE(void) ap_getparents(char *name);
1170 * Escape a path segment, as defined in RFC 1808
1171 * @param p The pool to allocate out of
1172 * @param s The path to convert
1173 * @return The converted URL
1174 * @deffunc char *ap_escape_path_segment(apr_pool_t *p, const char *s)
1176 AP_DECLARE(char *) ap_escape_path_segment(apr_pool_t *p, const char *s);
1178 * convert an OS path to a URL in an OS dependant way.
1179 * @param p The pool to allocate out of
1180 * @param path The path to convert
1181 * @param partial if set, assume that the path will be appended to something
1182 * with a '/' in it (and thus does not prefix "./")
1183 * @return The converted URL
1184 * @deffunc char *ap_os_escape_path(apr_pool_t *p, const char *path, int partial)
1186 AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial);
1187 #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
1190 * Escape an html string
1191 * @param p The pool to allocate out of
1192 * @param s The html to escape
1193 * @return The escaped string
1194 * @deffunc char *ap_escape_html(apr_pool_t *p, const char *s)
1196 AP_DECLARE(char *) ap_escape_html(apr_pool_t *p, const char *s);
1199 * Construct a full hostname
1200 * @param p The pool to allocate out of
1201 * @param hostname The hostname of the server
1202 * @param port The port the server is running on
1203 * @param r The current request
1204 * @return The server's hostname
1205 * @deffunc char *ap_construct_server(apr_pool_t *p, const char *hostname, apr_port_t port, const request_rec *r)
1207 AP_DECLARE(char *) ap_construct_server(apr_pool_t *p, const char *hostname,
1208 apr_port_t port, const request_rec *r);
1210 * Escape a shell command
1211 * @param p The pool to allocate out of
1212 * @param s The command to escape
1213 * @return The escaped hostname
1214 * @deffunc char *ap_escape_shell_cmd(apr_pool_t *p, const char *s)
1216 AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *s);
1219 * Count the number of directories in a path
1220 * @param The path to count
1221 * @return The number of directories
1222 * @deffunc int ap_count_dirs(const char *path)
1224 AP_DECLARE(int) ap_count_dirs(const char *path);
1227 * Copy at most n leading directories of s into d d should be at least as
1228 * large as s plus 1 extra byte
1229 * @param d The location to copy to
1230 * @param s The location to copy from
1231 * @param n The number of directories to copy
1232 * @return value is the ever useful pointer to the trailing \0 of d
1233 * @deffunc char *ap_make_dirstr_prefix(char *d, const char *s, int n)
1234 * @tip on platforms with drive letters, n = 0 returns the "/" root,
1235 * whereas n = 1 returns the "d:/" root. On all other platforms, n = 0
1236 * returns the empty string.
1238 AP_DECLARE(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
1241 * return the parent directory name including trailing / of the file s
1242 * @param p The pool to allocate out of
1243 * @param s The file to get the parent of
1244 * @return A copy of the file's parent directory
1245 * @deffunc char *ap_make_dirstr_parent(apr_pool_t *p, const char *s)
1247 AP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s);
1250 * Given a directory and filename, create a single path out of them. This
1251 * function is smart enough to ensure that there is a sinlge '/' between the
1252 * directory and file names
1253 * @param a The pool to allocate out of
1254 * @param dir The directory name
1255 * @param f The filename
1256 * @return A copy of the full path
1257 * @deffunc char *ap_make_full_path(apr_pool_t *a, const char *dir, const char *f)
1259 AP_DECLARE(char *) ap_make_full_path(apr_pool_t *a, const char *dir, const char *f);
1262 * Does the provided string contain wildcard characters? This is useful
1263 * for determining if the string should be passed to strcmp_match or to strcmp.
1264 * The only wildcard characters recognized are '?' and '*'
1265 * @param str The string to check
1266 * @return 1 if the string has wildcards, 0 otherwise
1267 * @deffunc int ap_is_matchexp(const char *str)
1269 AP_DECLARE(int) ap_is_matchexp(const char *str);
1272 * Determine if a string matches a patterm containing the wildcards '?' or '*'
1273 * @param str The string to check
1274 * @param exp The pattern to match against
1275 * @return 1 if the two strings match, 0 otherwise
1276 * @deffunc int ap_strcmp_match(const char *str, const char *exp)
1278 AP_DECLARE(int) ap_strcmp_match(const char *str, const char *exp);
1280 * Determine if a string matches a patterm containing the wildcards '?' or '*',
1282 * @param str The string to check
1283 * @param exp The pattern to match against
1284 * @return 1 if the two strings match, 0 otherwise
1285 * @deffunc int ap_strcasecmp_match(const char *str, const char *exp)
1287 AP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *exp);
1290 * Find the first occurrence of the substring s2 in s1, regardless of case
1291 * @param s1 The string to search
1292 * @param s2 The substring to search for
1293 * @return A pointer to the beginning of the substring
1294 * @deffunc char *ap_strcasestr(const char *s1, const char *s2)
1296 AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2);
1299 * Return a pointer to the location inside of bigstring immediately after prefix
1300 * @param bigstring The input string
1301 * @param prefix The prefix to strip away
1302 * @return A pointer relative to bigstring after prefix
1303 * deffunc const char *ap_stripprefix(const char *bigstring, const char *prefix);
1305 AP_DECLARE(const char *) ap_stripprefix(const char *bigstring,
1306 const char *prefix);
1309 * Decode a base64 encoded string into memory allocated out of a pool
1310 * @param p The pool to allocate out of
1311 * @param bufcoded The encoded string
1312 * @return The decoded string
1313 * @deffunc char *ap_pbase64decode(apr_pool_t *p, const char *bufcoded)
1315 AP_DECLARE(char *) ap_pbase64decode(apr_pool_t *p, const char *bufcoded);
1318 * Encode a string into memory allocated out of a pool in base 64 format
1319 * @param p The pool to allocate out of
1320 * @param strin The plaintext string
1321 * @return The encoded string
1322 * @deffunc char *ap_pbase64encode(apr_pool_t *p, char *string)
1324 AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string);
1328 * Compile a regular expression to be used later
1329 * @param p The pool to allocate out of
1330 * @param pattern the regular expression to compile
1331 * @param cflags The bitwise or of one or more of the following:
1333 * REG_EXTENDED - Use POSIX extended Regular Expressions
1334 * REG_ICASE - Ignore case
1335 * REG_NOSUB - Support for substring addressing of matches not required
1336 * REG_NEWLINE - Match-any-character operators don't match new-line
1338 * @return The compiled regular expression
1339 * @deffunc regex_t *ap_pregcomp(apr_pool_t *p, const char *pattern, int cflags)
1341 AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
1345 * Free the memory associated with a compiled regular expression
1346 * @param p The pool the regex was allocated out of
1347 * @param reg The regular expression to free
1348 * @deffunc void ap_pregfree(apr_pool_t *p, regex_t *reg)
1350 AP_DECLARE(void) ap_pregfree(apr_pool_t *p, regex_t *reg);
1353 * Match a null-terminated string against a pre-compiled regex.
1354 * @param preg The pre-compiled regex
1355 * @param string The string to match
1356 * @param nmatch Provide information regarding the location of any matches
1357 * @param pmatch Provide information regarding the location of any matches
1358 * @param eflags Bitwise or of one or both of:
1360 * REG_NOTBOL - match-beginning-of-line operator always fails to match
1361 * REG_NOTEOL - match-end-of-line operator always fails to match
1363 * @return 0 for successful match, REG_NOMATCH otherwise
1364 * @deffunc int ap_regexec(regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)
1366 AP_DECLARE(int) ap_regexec(regex_t *preg, const char *string,
1367 size_t nmatch, regmatch_t pmatch[], int eflags);
1370 * Return the error code returned by regcomp or regexec into error messages
1371 * @param errocode the error code returned by regexec or regcomp
1372 * @param preg The precompiled regex
1373 * @param errbuf A buffer to store the error in
1374 * @param errbuf_size The size of the buffer
1375 * @deffunc size_t ap_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
1377 AP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg,
1378 char *errbuf, size_t errbuf_size);
1381 * After performing a successful regex match, you may use this function to
1382 * perform a series of string substitutions based on subexpressions that were
1383 * matched during the call to ap_regexec
1384 * @param p The pool to allocate out of
1385 * @param input An arbitrary string containing $1 through $9. These are
1386 * replaced with the corresponding matched sub-expressions
1387 * @param source The string that was originally matched to the regex
1388 * @param nmatch the nmatch returned from ap_pregex
1389 * @param pmatch the pmatch array returned from ap_pregex
1390 * @deffunc char *ap_pregsub(apr_pool_t *p, const char *input, const char *source, size_t nmatch, regmatch_t pmatch[])
1392 AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source,
1393 size_t nmatch, regmatch_t pmatch[]);
1396 * we want to downcase the type/subtype for comparison purposes
1397 * but nothing else because ;parameter=foo values are case sensitive.
1398 * @param s The content-type to convert to lowercase
1399 * @deffunc void ap_content_type_tolower(char *s)
1401 AP_DECLARE(void) ap_content_type_tolower(char *s);
1404 * convert a string to all lowercase
1405 * @param s The string to convert to lowercase
1406 * @deffunc void ap_str_tolower(char *s)
1408 AP_DECLARE(void) ap_str_tolower(char *s);
1411 * Search a string from left to right for the first occurrence of a
1412 * specific character
1413 * @param str The string to search
1414 * @param c The character to search for
1415 * @return The index of the first occurrence of c in str
1416 * @deffunc int ap_ind(const char *str, char c)
1418 AP_DECLARE(int) ap_ind(const char *str, char c); /* Sigh... */
1421 * Search a string from right to left for the first occurrence of a
1422 * specific character
1423 * @param str The string to search
1424 * @param c The character to search for
1425 * @return The index of the first occurrence of c in str
1426 * @deffunc int ap_rind(const char *str, char c)
1428 AP_DECLARE(int) ap_rind(const char *str, char c);
1431 * Given a string, replace any bare " with \" .
1432 * @param p The pool to allocate memory out of
1433 * @param instring The string to search for "
1434 * @return A copy of the string with escaped quotes
1435 * @deffunc char * ap_escape_quotes(apr_pool_t *p, const char *instring)
1437 AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring);
1439 /* Misc system hackery */
1441 * Given the name of an object in the file system determine if it is a directory
1442 * @param p The pool to allocate out of
1443 * @param name The name of the object to check
1444 * @return 1 if it is a directory, 0 otherwise
1445 * @deffunc int ap_is_rdirectory(apr_pool_t *p, const char *name)
1447 AP_DECLARE(int) ap_is_rdirectory(apr_pool_t *p, const char *name);
1450 * Given the name of an object in the file system determine if it is a directory - this version is symlink aware
1451 * @param p The pool to allocate out of
1452 * @param name The name of the object to check
1453 * @return 1 if it is a directory, 0 otherwise
1454 * @deffunc int ap_is_directory(apr_pool_t *p, const char *name)
1456 AP_DECLARE(int) ap_is_directory(apr_pool_t *p, const char *name);
1459 extern const char *os_set_account(apr_pool_t *p, const char *account);
1460 extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
1461 #endif /* _OSD_POSIX */
1464 * determine the local host name for the current machine
1465 * @param p The pool to allocate out of
1466 * @return A copy of the local host name
1467 * @deffunc char *ap_get_local_host(apr_pool_t *p)
1469 char *ap_get_local_host(apr_pool_t *p);
1472 * Redefine assert() to something more useful for an Apache...
1474 * Use ap_assert() if the condition should always be checked.
1475 * Use AP_DEBUG_ASSERT() if the condition should only be checked when AP_DEBUG
1479 * Log an assertion to the error log
1480 * @param szExp The assertion that failed
1481 * @param szFile The file the assertion is in
1482 * @param nLine The line the assertion is defined on
1483 * @deffunc void ap_log_assert(const char *szExp, const char *szFile, int nLine)
1485 AP_DECLARE(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
1486 __attribute__((noreturn));
1487 #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
1490 #define AP_DEBUG_ASSERT(exp) ap_assert(exp)
1492 #define AP_DEBUG_ASSERT(exp) ((void)0)
1495 /* A set of flags which indicate places where the server should raise(SIGSTOP).
1496 * This is useful for debugging, because you can then attach to that process
1497 * with gdb and continue. This is important in cases where one_process
1498 * debugging isn't possible.
1500 #define SIGSTOP_DETACH 1
1501 #define SIGSTOP_MAKE_CHILD 2
1502 #define SIGSTOP_SPAWN_CHILD 4
1503 #define SIGSTOP_PIPED_LOG_SPAWN 8
1504 #define SIGSTOP_CGI_CHILD 16
1506 #ifdef DEBUG_SIGSTOP
1507 extern int raise_sigstop_flags;
1508 #define RAISE_SIGSTOP(x) do { \
1509 if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
1512 #define RAISE_SIGSTOP(x)
1515 AP_DECLARE(extern const char *) ap_psignature(const char *prefix, request_rec *r);
1517 /* strtoul does not exist on sunos4. */
1521 #define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
1523 /* The C library has functions that allow const to be silently dropped ...
1524 these macros detect the drop in maintainer mode, but use the native
1525 methods for normal builds
1527 Note that on some platforms (e.g., AIX with gcc, Solaris with gcc), string.h needs
1528 to be included before the macros are defined or compilation will fail.
1535 # define strchr(s, c) ap_strchr(s,c)
1537 # define strrchr(s, c) ap_strrchr(s,c)
1539 # define strstr(s, c) ap_strstr(s,c)
1541 char *ap_strchr(char *s, int c);
1542 const char *ap_strchr_c(const char *s, int c);
1543 char *ap_strrchr(char *s, int c);
1544 const char *ap_strrchr_c(const char *s, int c);
1545 char *ap_strstr(char *s, char *c);
1546 const char *ap_strstr_c(const char *s, const char *c);
1550 # define ap_strchr(s, c) strchr(s, c)
1551 # define ap_strchr_c(s, c) strchr(s, c)
1552 # define ap_strrchr(s, c) strrchr(s, c)
1553 # define ap_strrchr_c(s, c) strrchr(s, c)
1554 # define ap_strstr(s, c) strstr(s, c)
1555 # define ap_strstr_c(s, c) strstr(s, c)
1563 #endif /* !APACHE_HTTPD_H */