1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @brief HTTP Daemon routines
21 * @defgroup APACHE Apache HTTP Server
23 * Top level group of which all other groups are a member
26 * @defgroup APACHE_MODS Loadable modules
27 * Top level group for modules
28 * @defgroup APACHE_OS Operating System Specific
29 * @defgroup APACHE_INTERNAL Internal interfaces
30 * @defgroup APACHE_CORE Core routines
32 * @defgroup APACHE_CORE_DAEMON HTTP Daemon Routine
36 #ifndef APACHE_HTTPD_H
37 #define APACHE_HTTPD_H
39 /* XXX - We need to push more stuff to other .h files, or even .c files, to
40 * make this file smaller
43 /* Headers in which EVERYONE has an interest... */
44 #include "ap_config.h"
47 #include "ap_release.h"
50 #include "apr_general.h"
51 #include "apr_tables.h"
52 #include "apr_pools.h"
54 #include "apr_network_io.h"
55 #include "apr_buckets.h"
57 #include "apr_thread_proc.h"
68 /* Note: apr_uri.h is also included, see below */
74 /* ----------------------------- config dir ------------------------------ */
76 /** Define this to be the default server home dir. Most things later in this
77 * file with a relative pathname will have this added.
81 /** Set default for OS/2 file system */
82 #define HTTPD_ROOT "/os2httpd"
84 /** Set default for Windows file system */
85 #define HTTPD_ROOT "/apache"
86 #elif defined (NETWARE)
87 /** Set the default for NetWare */
88 #define HTTPD_ROOT "/apache"
90 /** Set for all other OSs */
91 #define HTTPD_ROOT "/usr/local/apache"
93 #endif /* HTTPD_ROOT */
96 * --------- You shouldn't have to edit anything below this line ----------
98 * Any modifications to any defaults not defined above should be done in the
99 * respective configuration file.
104 * Default location of documents. Can be overridden by the DocumentRoot
107 #ifndef DOCUMENT_LOCATION
109 /* Set default for OS/2 file system */
110 #define DOCUMENT_LOCATION HTTPD_ROOT "/docs"
112 /* Set default for non OS/2 file system */
113 #define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs"
115 #endif /* DOCUMENT_LOCATION */
117 /** Maximum number of dynamically loaded modules */
118 #ifndef DYNAMIC_MODULE_LIMIT
119 #define DYNAMIC_MODULE_LIMIT 256
122 /** Default administrator's address */
123 #define DEFAULT_ADMIN "[no address given]"
125 /** The name of the log files */
126 #ifndef DEFAULT_ERRORLOG
127 #if defined(OS2) || defined(WIN32)
128 #define DEFAULT_ERRORLOG "logs/error.log"
130 #define DEFAULT_ERRORLOG "logs/error_log"
132 #endif /* DEFAULT_ERRORLOG */
134 /** Define this to be what your per-directory security files are called */
135 #ifndef DEFAULT_ACCESS_FNAME
137 /* Set default for OS/2 file system */
138 #define DEFAULT_ACCESS_FNAME "htaccess"
140 #define DEFAULT_ACCESS_FNAME ".htaccess"
142 #endif /* DEFAULT_ACCESS_FNAME */
144 /** The name of the server config file */
145 #ifndef SERVER_CONFIG_FILE
146 #define SERVER_CONFIG_FILE "conf/httpd.conf"
149 /** The default path for CGI scripts if none is currently set */
151 #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
154 /** The path to the suExec wrapper, can be overridden in Configuration */
156 #define SUEXEC_BIN HTTPD_ROOT "/bin/suexec"
159 /** The timeout for waiting for messages */
160 #ifndef DEFAULT_TIMEOUT
161 #define DEFAULT_TIMEOUT 60
164 /** The timeout for waiting for keepalive timeout until next request */
165 #ifndef DEFAULT_KEEPALIVE_TIMEOUT
166 #define DEFAULT_KEEPALIVE_TIMEOUT 5
169 /** The number of requests to entertain per connection */
170 #ifndef DEFAULT_KEEPALIVE
171 #define DEFAULT_KEEPALIVE 100
175 * Limits on the size of various request items. These limits primarily
176 * exist to prevent simple denial-of-service attacks on a server based
177 * on misuse of the protocol. The recommended values will depend on the
178 * nature of the server resources -- CGI scripts and database backends
179 * might require large values, but most servers could get by with much
180 * smaller limits than we use below. The request message body size can
181 * be limited by the per-dir config directive LimitRequestBody.
183 * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
184 * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
185 * These two limits can be lowered or raised by the server config
186 * directives LimitRequestLine and LimitRequestFieldsize, respectively.
188 * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
189 * the server config directive LimitRequestFields.
192 /** default limit on bytes in Request-Line (Method+URI+HTTP-version) */
193 #ifndef DEFAULT_LIMIT_REQUEST_LINE
194 #define DEFAULT_LIMIT_REQUEST_LINE 8190
196 /** default limit on bytes in any one header field */
197 #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
198 #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
200 /** default limit on number of request header fields */
201 #ifndef DEFAULT_LIMIT_REQUEST_FIELDS
202 #define DEFAULT_LIMIT_REQUEST_FIELDS 100
206 * The default default character set name to add if AddDefaultCharset is
207 * enabled. Overridden with AddDefaultCharsetName.
209 #define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1"
211 /** default HTTP Server protocol */
212 #define AP_SERVER_PROTOCOL "HTTP/1.1"
215 /* ------------------ stuff that modules are allowed to look at ----------- */
217 /** Define this to be what your HTML directory content files are called */
218 #ifndef AP_DEFAULT_INDEX
219 #define AP_DEFAULT_INDEX "index.html"
222 /** The name of the MIME types file */
223 #ifndef AP_TYPES_CONFIG_FILE
224 #define AP_TYPES_CONFIG_FILE "conf/mime.types"
228 * Define the HTML doctype strings centrally.
230 /** HTML 2.0 Doctype */
231 #define DOCTYPE_HTML_2_0 "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
232 "DTD HTML 2.0//EN\">\n"
233 /** HTML 3.2 Doctype */
234 #define DOCTYPE_HTML_3_2 "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
235 "DTD HTML 3.2 Final//EN\">\n"
236 /** HTML 4.0 Strict Doctype */
237 #define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
238 "DTD HTML 4.0//EN\"\n" \
239 "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
240 /** HTML 4.0 Transitional Doctype */
241 #define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
242 "DTD HTML 4.0 Transitional//EN\"\n" \
243 "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
244 /** HTML 4.0 Frameset Doctype */
245 #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
246 "DTD HTML 4.0 Frameset//EN\"\n" \
247 "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
248 /** XHTML 1.0 Strict Doctype */
249 #define DOCTYPE_XHTML_1_0S "<!DOCTYPE html PUBLIC \"-//W3C//" \
250 "DTD XHTML 1.0 Strict//EN\"\n" \
251 "\"http://www.w3.org/TR/xhtml1/DTD/" \
252 "xhtml1-strict.dtd\">\n"
253 /** XHTML 1.0 Transitional Doctype */
254 #define DOCTYPE_XHTML_1_0T "<!DOCTYPE html PUBLIC \"-//W3C//" \
255 "DTD XHTML 1.0 Transitional//EN\"\n" \
256 "\"http://www.w3.org/TR/xhtml1/DTD/" \
257 "xhtml1-transitional.dtd\">\n"
258 /** XHTML 1.0 Frameset Doctype */
259 #define DOCTYPE_XHTML_1_0F "<!DOCTYPE html PUBLIC \"-//W3C//" \
260 "DTD XHTML 1.0 Frameset//EN\"\n" \
261 "\"http://www.w3.org/TR/xhtml1/DTD/" \
262 "xhtml1-frameset.dtd\">"
264 /** Internal representation for a HTTP protocol number, e.g., HTTP/1.1 */
265 #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
266 /** Major part of HTTP protocol */
267 #define HTTP_VERSION_MAJOR(number) ((number)/1000)
268 /** Minor part of HTTP protocol */
269 #define HTTP_VERSION_MINOR(number) ((number)%1000)
271 /* -------------- Port number for server running standalone --------------- */
273 /** default HTTP Port */
274 #define DEFAULT_HTTP_PORT 80
275 /** default HTTPS Port */
276 #define DEFAULT_HTTPS_PORT 443
278 * Check whether @a port is the default port for the request @a r.
279 * @param port The port number
280 * @param r The request
281 * @see #ap_default_port
283 #define ap_is_default_port(port,r) ((port) == ap_default_port(r))
285 * Get the default port for a request (which depends on the scheme).
286 * @param r The request
288 #define ap_default_port(r) ap_run_default_port(r)
290 * Get the scheme for a request.
291 * @param r The request
293 #define ap_http_scheme(r) ap_run_http_scheme(r)
295 /** The default string length */
296 #define MAX_STRING_LEN HUGE_STRING_LEN
298 /** The length of a Huge string */
299 #define HUGE_STRING_LEN 8192
301 /** The size of the server's internal read-write buffers */
302 #define AP_IOBUFSIZE 8192
304 /** The max number of regex captures that can be expanded by ap_pregsub */
305 #define AP_MAX_REG_MATCH 10
308 * APR_HAS_LARGE_FILES introduces the problem of spliting sendfile into
309 * mutiple buckets, no greater than MAX(apr_size_t), and more granular
310 * than that in case the brigade code/filters attempt to read it directly.
311 * ### 16mb is an invention, no idea if it is reasonable.
313 #define AP_MAX_SENDFILE 16777216 /* 2^24 */
316 * MPM child process exit status values
317 * The MPM parent process may check the status to see if special
318 * error handling is required.
321 #define APEXIT_OK 0x0
322 /** A fatal error arising during the server's init sequence */
323 #define APEXIT_INIT 0x2
324 /** The child died during its init sequence */
325 #define APEXIT_CHILDINIT 0x3
327 * The child exited due to a resource shortage.
328 * The parent should limit the rate of forking until
329 * the situation is resolved.
331 #define APEXIT_CHILDSICK 0x7
333 * A fatal error, resulting in the whole server aborting.
334 * If a child exits with this error, the parent process
335 * considers this a server-wide fatal error and aborts.
337 #define APEXIT_CHILDFATAL 0xf
341 * Stuff marked #AP_DECLARE is part of the API, and intended for use
342 * by modules. Its purpose is to allow us to add attributes that
343 * particular platforms or compilers require to every exported function.
345 # define AP_DECLARE(type) type
348 #ifndef AP_DECLARE_NONSTD
350 * Stuff marked #AP_DECLARE_NONSTD is part of the API, and intended for
351 * use by modules. The difference between #AP_DECLARE and
352 * #AP_DECLARE_NONSTD is that the latter is required for any functions
353 * which use varargs or are used via indirect function call. This
354 * is to accomodate the two calling conventions in windows dlls.
356 # define AP_DECLARE_NONSTD(type) type
358 #ifndef AP_DECLARE_DATA
359 # define AP_DECLARE_DATA
362 #ifndef AP_MODULE_DECLARE
363 # define AP_MODULE_DECLARE(type) type
365 #ifndef AP_MODULE_DECLARE_NONSTD
366 # define AP_MODULE_DECLARE_NONSTD(type) type
368 #ifndef AP_MODULE_DECLARE_DATA
369 # define AP_MODULE_DECLARE_DATA
374 * modules should not use functions marked AP_CORE_DECLARE
376 #ifndef AP_CORE_DECLARE
377 # define AP_CORE_DECLARE AP_DECLARE
382 * modules should not use functions marked AP_CORE_DECLARE_NONSTD
385 #ifndef AP_CORE_DECLARE_NONSTD
386 # define AP_CORE_DECLARE_NONSTD AP_DECLARE_NONSTD
390 * @defgroup APACHE_APR_STATUS_T HTTPD specific values of apr_status_t
393 #define AP_START_USERERR (APR_OS_START_USERERR + 2000)
394 #define AP_USERERR_LEN 1000
396 /** The function declines to handle the request */
397 #define AP_DECLINED (AP_START_USERERR + 0)
402 * @brief The numeric version information is broken out into fields within this
406 int major; /**< major number */
407 int minor; /**< minor number */
408 int patch; /**< patch number */
409 const char *add_string; /**< additional string like "-dev" */
413 * Return httpd's version information in a numeric form.
415 * @param version Pointer to a version structure for returning the version
418 AP_DECLARE(void) ap_get_server_revision(ap_version_t *version);
421 * Get the server banner in a form suitable for sending over the
422 * network, with the level of information controlled by the
423 * ServerTokens directive.
424 * @return The server banner
426 AP_DECLARE(const char *) ap_get_server_banner(void);
429 * Get the server description in a form suitable for local displays,
430 * status reports, or logging. This includes the detailed server
431 * version and information about some modules. It is not affected
432 * by the ServerTokens directive.
433 * @return The server description
435 AP_DECLARE(const char *) ap_get_server_description(void);
438 * Add a component to the server description and banner strings
439 * @param pconf The pool to allocate the component from
440 * @param component The string to add
442 AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component);
445 * Get the date a time that the server was built
446 * @return The server build time string
448 AP_DECLARE(const char *) ap_get_server_built(void);
450 /* non-HTTP status codes returned by hooks */
452 #define OK 0 /**< Module has handled this stage. */
453 #define DECLINED -1 /**< Module declines to handle */
454 #define DONE -2 /**< Module has served the response completely
455 * - it's safe to die() with no more output
457 #define SUSPENDED -3 /**< Module will handle the remainder of the request.
458 * The core will never invoke the request again, */
460 /** Returned by the bottom-most filter if no data was written.
461 * @see ap_pass_brigade(). */
462 #define AP_NOBODY_WROTE -100
463 /** Returned by the bottom-most filter if no data was read.
464 * @see ap_get_brigade(). */
465 #define AP_NOBODY_READ -101
466 /** Returned by any filter if the filter chain encounters an error
467 * and has already dealt with the error response.
469 #define AP_FILTER_ERROR -102
472 * @defgroup HTTP_Status HTTP Status Codes
476 * The size of the static status_lines array in http_protocol.c for
477 * storing all of the potential response status-lines (a sparse table).
478 * When adding a new code here add it to status_lines as well.
479 * A future version should dynamically generate the apr_table_t at startup.
481 #define RESPONSE_CODES 83
483 #define HTTP_CONTINUE 100
484 #define HTTP_SWITCHING_PROTOCOLS 101
485 #define HTTP_PROCESSING 102
487 #define HTTP_CREATED 201
488 #define HTTP_ACCEPTED 202
489 #define HTTP_NON_AUTHORITATIVE 203
490 #define HTTP_NO_CONTENT 204
491 #define HTTP_RESET_CONTENT 205
492 #define HTTP_PARTIAL_CONTENT 206
493 #define HTTP_MULTI_STATUS 207
494 #define HTTP_ALREADY_REPORTED 208
495 #define HTTP_IM_USED 226
496 #define HTTP_MULTIPLE_CHOICES 300
497 #define HTTP_MOVED_PERMANENTLY 301
498 #define HTTP_MOVED_TEMPORARILY 302
499 #define HTTP_SEE_OTHER 303
500 #define HTTP_NOT_MODIFIED 304
501 #define HTTP_USE_PROXY 305
502 #define HTTP_TEMPORARY_REDIRECT 307
503 #define HTTP_PERMANENT_REDIRECT 308
504 #define HTTP_BAD_REQUEST 400
505 #define HTTP_UNAUTHORIZED 401
506 #define HTTP_PAYMENT_REQUIRED 402
507 #define HTTP_FORBIDDEN 403
508 #define HTTP_NOT_FOUND 404
509 #define HTTP_METHOD_NOT_ALLOWED 405
510 #define HTTP_NOT_ACCEPTABLE 406
511 #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
512 #define HTTP_REQUEST_TIME_OUT 408
513 #define HTTP_CONFLICT 409
514 #define HTTP_GONE 410
515 #define HTTP_LENGTH_REQUIRED 411
516 #define HTTP_PRECONDITION_FAILED 412
517 #define HTTP_REQUEST_ENTITY_TOO_LARGE 413
518 #define HTTP_REQUEST_URI_TOO_LARGE 414
519 #define HTTP_UNSUPPORTED_MEDIA_TYPE 415
520 #define HTTP_RANGE_NOT_SATISFIABLE 416
521 #define HTTP_EXPECTATION_FAILED 417
522 #define HTTP_IM_A_TEAPOT 418
523 #define HTTP_MISDIRECTED_REQUEST 421
524 #define HTTP_UNPROCESSABLE_ENTITY 422
525 #define HTTP_LOCKED 423
526 #define HTTP_FAILED_DEPENDENCY 424
527 #define HTTP_UPGRADE_REQUIRED 426
528 #define HTTP_PRECONDITION_REQUIRED 428
529 #define HTTP_TOO_MANY_REQUESTS 429
530 #define HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE 431
531 #define HTTP_INTERNAL_SERVER_ERROR 500
532 #define HTTP_NOT_IMPLEMENTED 501
533 #define HTTP_BAD_GATEWAY 502
534 #define HTTP_SERVICE_UNAVAILABLE 503
535 #define HTTP_GATEWAY_TIME_OUT 504
536 #define HTTP_VERSION_NOT_SUPPORTED 505
537 #define HTTP_VARIANT_ALSO_VARIES 506
538 #define HTTP_INSUFFICIENT_STORAGE 507
539 #define HTTP_LOOP_DETECTED 508
540 #define HTTP_NOT_EXTENDED 510
541 #define HTTP_NETWORK_AUTHENTICATION_REQUIRED 511
543 /** is the status code informational */
544 #define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200))
545 /** is the status code OK ?*/
546 #define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300))
547 /** is the status code a redirect */
548 #define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400))
549 /** is the status code a error (client or server) */
550 #define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600))
551 /** is the status code a client error */
552 #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
553 /** is the status code a server error */
554 #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
555 /** is the status code a (potentially) valid response code? */
556 #define ap_is_HTTP_VALID_RESPONSE(x) (((x) >= 100)&&((x) < 600))
558 /** should the status code drop the connection */
559 #define ap_status_drops_connection(x) \
560 (((x) == HTTP_BAD_REQUEST) || \
561 ((x) == HTTP_REQUEST_TIME_OUT) || \
562 ((x) == HTTP_LENGTH_REQUIRED) || \
563 ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
564 ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
565 ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
566 ((x) == HTTP_SERVICE_UNAVAILABLE) || \
567 ((x) == HTTP_NOT_IMPLEMENTED))
571 * @defgroup Methods List of Methods recognized by the server
572 * @ingroup APACHE_CORE_DAEMON
575 * @brief Methods recognized (but not necessarily handled) by the server.
577 * These constants are used in bit shifting masks of size int, so it is
578 * unsafe to have more methods than bits in an int. HEAD == M_GET.
579 * This list must be tracked by the list in http_protocol.c in routine
580 * ap_method_name_of().
584 #define M_GET 0 /** RFC 2616: HTTP */
585 #define M_PUT 1 /* : */
590 #define M_TRACE 6 /** RFC 2616: HTTP */
591 #define M_PATCH 7 /** no rfc(!) ### remove this one? */
592 #define M_PROPFIND 8 /** RFC 2518: WebDAV */
593 #define M_PROPPATCH 9 /* : */
598 #define M_UNLOCK 14 /** RFC 2518: WebDAV */
599 #define M_VERSION_CONTROL 15 /** RFC 3253: WebDAV Versioning */
600 #define M_CHECKOUT 16 /* : */
601 #define M_UNCHECKOUT 17
606 #define M_MKWORKSPACE 22
607 #define M_MKACTIVITY 23
608 #define M_BASELINE_CONTROL 24
610 #define M_INVALID 26 /** no valid method */
611 #define M_BREW 27 /** RFC 2324: HTCPCP/1.0 */
612 #define M_WHEN 28 /** RFC 2324: HTCPCP/1.0 */
615 * METHODS needs to be equal to the number of bits
616 * we are using for limit masks.
621 * The method mask bit to shift for anding with a bitmask.
623 #define AP_METHOD_BIT ((apr_int64_t)1)
627 /** @see ap_method_list_t */
628 typedef struct ap_method_list_t ap_method_list_t;
631 * @struct ap_method_list_t
632 * @brief Structure for handling HTTP methods.
634 * Methods known to the server are accessed via a bitmask shortcut;
635 * extension methods are handled by an array.
637 struct ap_method_list_t {
638 /** The bitmask used for known methods */
639 apr_int64_t method_mask;
640 /** the array used for extension methods */
641 apr_array_header_t *method_list;
645 * @defgroup module_magic Module Magic mime types
648 /** Magic for mod_cgi[d] */
649 #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
650 /** Magic for mod_include */
651 #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
652 /** Magic for mod_include */
653 #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
654 /** Magic for mod_dir */
655 #define DIR_MAGIC_TYPE "httpd/unix-directory"
656 /** Default for r->handler if no content-type set by type_checker */
657 #define AP_DEFAULT_HANDLER_NAME ""
658 #define AP_IS_DEFAULT_HANDLER_NAME(x) (*x == '\0')
661 /* Just in case your linefeed isn't the one the other end is expecting. */
662 #if !APR_CHARSET_EBCDIC
665 /** carrige return */
667 /** carrige return /Line Feed Combo */
668 #define CRLF "\015\012"
669 #else /* APR_CHARSET_EBCDIC */
670 /* For platforms using the EBCDIC charset, the transition ASCII->EBCDIC is done
671 * in the buff package (bread/bputs/bwrite). Everywhere else, we use
672 * "native EBCDIC" CR and NL characters. These are therefore
679 #endif /* APR_CHARSET_EBCDIC */
680 /** Useful for common code with either platform charset. */
681 #define CRLF_ASCII "\015\012"
684 * @defgroup values_request_rec_body Possible values for request_rec.read_body
686 * Possible values for request_rec.read_body (set by handling module):
689 /** Send 413 error if message has any body */
690 #define REQUEST_NO_BODY 0
691 /** Send 411 error if body without Content-Length */
692 #define REQUEST_CHUNKED_ERROR 1
693 /** If chunked, remove the chunks for me. */
694 #define REQUEST_CHUNKED_DECHUNK 2
695 /** @} // values_request_rec_body */
698 * @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info
699 * @ingroup APACHE_CORE_DAEMON
701 * Possible values for request_rec.used_path_info:
704 /** Accept the path_info from the request */
705 #define AP_REQ_ACCEPT_PATH_INFO 0
706 /** Return a 404 error if path_info was given */
707 #define AP_REQ_REJECT_PATH_INFO 1
708 /** Module may chose to use the given path_info */
709 #define AP_REQ_DEFAULT_PATH_INFO 2
711 /** @} // values_request_rec_used_path_info */
715 * Things which may vary per file-lookup WITHIN a request ---
716 * e.g., state of MIME config. Basically, the name of an object, info
717 * about the object, and any other info we may ahve which may need to
718 * change as we go poking around looking for it (e.g., overridden by
721 * Note how the default state of almost all these things is properly
722 * zero, so that allocating it with pcalloc does the right thing without
723 * a whole lot of hairy initialization... so long as we are willing to
724 * make the (fairly) portable assumption that the bit pattern of a NULL
725 * pointer is, in fact, zero.
729 * @brief This represents the result of calling htaccess; these are cached for
732 struct htaccess_result {
733 /** the directory to which this applies */
735 /** the overrides allowed for the .htaccess file */
737 /** the override options allowed for the .htaccess file */
739 /** Table of allowed directives for override */
740 apr_table_t *override_list;
741 /** the configuration directives */
742 struct ap_conf_vector_t *htaccess;
743 /** the next one, or NULL if no more; N.B. never change this */
744 const struct htaccess_result *next;
747 /* The following four types define a hierarchy of activities, so that
748 * given a request_rec r you can write r->connection->server->process
749 * to get to the process_rec. While this reduces substantially the
750 * number of arguments that various hooks require beware that in
751 * threaded versions of the server you must consider multiplexing
755 /** A structure that represents one process */
756 typedef struct process_rec process_rec;
757 /** A structure that represents a virtual server */
758 typedef struct server_rec server_rec;
759 /** A structure that represents one connection */
760 typedef struct conn_rec conn_rec;
761 /** A structure that represents one slave connection */
762 typedef struct conn_slave_rec conn_slave_rec;
763 /** A structure that represents the current request */
764 typedef struct request_rec request_rec;
765 /** A structure that represents the status of the current connection */
766 typedef struct conn_state_t conn_state_t;
768 /* ### would be nice to not include this from httpd.h ... */
769 /* This comes after we have defined the request_rec type */
773 * @brief A structure that represents one process
776 /** Global pool. Cleared upon normal exit */
778 /** Configuration pool. Cleared upon restart */
780 /** The program name used to execute the program */
781 const char *short_name;
782 /** The command line arguments */
783 const char * const *argv;
784 /** Number of command line arguments passed to the program */
789 * @brief A structure that represents the current request
792 /** The pool associated with the request */
794 /** The connection to the client */
795 conn_rec *connection;
796 /** The virtual host for this request */
799 /** Pointer to the redirected request if this is an external redirect */
801 /** Pointer to the previous request if this is an internal redirect */
804 /** Pointer to the main request if this is a sub-request
805 * (see http_request.h) */
808 /* Info about the request itself... we begin with stuff that only
809 * protocol.c should ever touch...
811 /** First line of request */
813 /** HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers) */
815 /** A proxy request (calculated during post_read_request/translate_name)
816 * possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE,
820 /** HEAD request, as opposed to GET */
822 /** Protocol version number of protocol; 1.1 = 1001 */
824 /** Protocol string, as given to us, or HTTP/0.9 */
826 /** Host, as set by full URI or Host: header.
827 * For literal IPv6 addresses, this does NOT include the surrounding [ ]
829 const char *hostname;
831 /** Time when the request started */
832 apr_time_t request_time;
834 /** Status line, if set by script */
835 const char *status_line;
839 /* Request method, two ways; also, protocol, etc.. Outside of protocol.c,
840 * look, but don't touch.
843 /** M_GET, M_POST, etc. */
845 /** Request method (eg. GET, HEAD, POST, etc.) */
849 * 'allowed' is a bitvector of the allowed methods.
851 * A handler must ensure that the request method is one that
852 * it is capable of handling. Generally modules should DECLINE
853 * any request methods they do not handle. Prior to aborting the
854 * handler like this the handler should set r->allowed to the list
855 * of methods that it is willing to handle. This bitvector is used
856 * to construct the "Allow:" header required for OPTIONS requests,
857 * and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes.
859 * Since the default_handler deals with OPTIONS, all modules can
860 * usually decline to deal with OPTIONS. TRACE is always allowed,
861 * modules don't need to set it explicitly.
863 * Since the default_handler will always handle a GET, a
864 * module which does *not* implement GET should probably return
865 * HTTP_METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET
866 * handler can't be installed by mod_actions.
869 /** Array of extension methods */
870 apr_array_header_t *allowed_xmethods;
871 /** List of allowed methods */
872 ap_method_list_t *allowed_methods;
874 /** byte count in stream is for body */
875 apr_off_t sent_bodyct;
876 /** body byte count, for easy access */
877 apr_off_t bytes_sent;
878 /** Last modified time of the requested resource */
881 /* HTTP/1.1 connection-level features */
883 /** The Range: header */
885 /** The "real" content length */
887 /** sending chunked transfer-coding */
890 /** Method for reading the request body
891 * (eg. REQUEST_CHUNKED_ERROR, REQUEST_NO_BODY,
892 * REQUEST_CHUNKED_DECHUNK, etc...) */
894 /** reading chunked transfer-coding */
896 /** is client waiting for a 100 response? */
897 unsigned expecting_100;
898 /** The optional kept body of the request. */
899 apr_bucket_brigade *kept_body;
900 /** For ap_body_to_table(): parsed body */
901 /* XXX: ap_body_to_table has been removed. Remove body_table too or
902 * XXX: keep it to reintroduce ap_body_to_table without major bump? */
903 apr_table_t *body_table;
904 /** Remaining bytes left to read from the request body */
906 /** Number of bytes that have been read from the request body */
907 apr_off_t read_length;
909 /* MIME header environments, in and out. Also, an array containing
910 * environment variables to be passed to subprocesses, so people can
911 * write modules to add to that environment.
913 * The difference between headers_out and err_headers_out is that the
914 * latter are printed even on error, and persist across internal redirects
915 * (so the headers printed for ErrorDocument handlers will have them).
917 * The 'notes' apr_table_t is for notes from one module to another, with no
918 * other set purpose in mind...
921 /** MIME header environment from the request */
922 apr_table_t *headers_in;
923 /** MIME header environment for the response */
924 apr_table_t *headers_out;
925 /** MIME header environment for the response, printed even on errors and
926 * persist across internal redirects */
927 apr_table_t *err_headers_out;
928 /** Array of environment variables to be used for sub processes */
929 apr_table_t *subprocess_env;
930 /** Notes from one module to another */
933 /* content_type, handler, content_encoding, and all content_languages
934 * MUST be lowercased strings. They may be pointers to static strings;
935 * they should not be modified in place.
937 /** The content-type for the current request */
938 const char *content_type; /* Break these out --- we dispatch on 'em */
939 /** The handler string that we use to call a handler function */
940 const char *handler; /* What we *really* dispatch on */
942 /** How to encode the data */
943 const char *content_encoding;
944 /** Array of strings representing the content languages */
945 apr_array_header_t *content_languages;
947 /** variant list validator (if negotiated) */
948 char *vlist_validator;
950 /** If an authentication check was made, this gets set to the user name. */
952 /** If an authentication check was made, this gets set to the auth type. */
955 /* What object is being requested (either directly, or via include
956 * or content-negotiation mapping).
959 /** The URI without any parsing performed */
961 /** The path portion of the URI, or "/" if no path provided */
963 /** The filename on disk corresponding to this response */
965 /** The true filename stored in the filesystem, as in the true alpha case
966 * and alias correction, e.g. "Image.jpeg" not "IMAGE$1.JPE" on Windows.
967 * The core map_to_storage canonicalizes r->filename when they mismatch */
968 char *canonical_filename;
969 /** The PATH_INFO extracted from this request */
971 /** The QUERY_ARGS extracted from this request */
975 * Flag for the handler to accept or reject path_info on
976 * the current request. All modules should respect the
977 * AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO
978 * values, while AP_REQ_DEFAULT_PATH_INFO indicates they
979 * may follow existing conventions. This is set to the
980 * user's preference upon HOOK_VERY_FIRST of the fixups.
984 /** A flag to determine if the eos bucket has been sent yet */
987 /* Various other config info which may change with .htaccess files
988 * These are config vectors, with one void* pointer for each module
989 * (the thing pointed to being the module's business).
992 /** Options set in config files, etc. */
993 struct ap_conf_vector_t *per_dir_config;
994 /** Notes on *this* request */
995 struct ap_conf_vector_t *request_config;
997 /** Optional request log level configuration. Will usually point
998 * to a server or per_dir config, i.e. must be copied before
1000 const struct ap_logconf *log;
1002 /** Id to identify request in access and error log. Set when the first
1003 * error log entry for this request is generated.
1008 * A linked list of the .htaccess configuration directives
1009 * accessed by this request.
1010 * N.B. always add to the head of the list, _never_ to the end.
1011 * that way, a sub request's list can (temporarily) point to a parent's list
1013 const struct htaccess_result *htaccess;
1015 /** A list of output filters to be used for this request */
1016 struct ap_filter_t *output_filters;
1017 /** A list of input filters to be used for this request */
1018 struct ap_filter_t *input_filters;
1020 /** A list of protocol level output filters to be used for this
1022 struct ap_filter_t *proto_output_filters;
1023 /** A list of protocol level input filters to be used for this
1025 struct ap_filter_t *proto_input_filters;
1027 /** This response can not be cached */
1029 /** There is no local copy of this response */
1032 /** Mutex protect callbacks registered with ap_mpm_register_timed_callback
1033 * from being run before the original handler finishes running
1036 apr_thread_mutex_t *invoke_mtx;
1039 /** A struct containing the components of URI */
1040 apr_uri_t parsed_uri;
1041 /** finfo.protection (st_mode) set to zero if no such file */
1044 /** remote address information from conn_rec, can be overridden if
1045 * necessary by a module.
1046 * This is the address that originated the request.
1048 apr_sockaddr_t *useragent_addr;
1051 /** MIME trailer environment from the request */
1052 apr_table_t *trailers_in;
1053 /** MIME trailer environment from the response */
1054 apr_table_t *trailers_out;
1058 * @defgroup ProxyReq Proxy request types
1060 * Possible values of request_rec->proxyreq. A request could be normal,
1061 * proxied or reverse proxied. Normally proxied and reverse proxied are
1062 * grouped together as just "proxied", but sometimes it's necessary to
1063 * tell the difference between the two, such as for authentication.
1067 #define PROXYREQ_NONE 0 /**< No proxy */
1068 #define PROXYREQ_PROXY 1 /**< Standard proxy */
1069 #define PROXYREQ_REVERSE 2 /**< Reverse proxy */
1070 #define PROXYREQ_RESPONSE 3 /**< Origin response */
1075 * @brief Enumeration of connection keepalive options
1081 } ap_conn_keepalive_e;
1084 * @brief Structure to store things which are per connection
1087 /** Pool associated with this connection */
1089 /** Physical vhost this conn came in on */
1090 server_rec *base_server;
1091 /** used by http_vhost.c */
1092 void *vhost_lookup_data;
1094 /* Information about the connection itself */
1095 /** local address */
1096 apr_sockaddr_t *local_addr;
1097 /** remote address; this is the end-point of the next hop, for the address
1098 * of the request creator, see useragent_addr in request_rec
1100 apr_sockaddr_t *client_addr;
1102 /** Client's IP address; this is the end-point of the next hop, for the
1103 * IP of the request creator, see useragent_ip in request_rec
1106 /** Client's DNS name, if known. NULL if DNS hasn't been checked,
1107 * "" if it has and no address was found. N.B. Only access this though
1108 * get_remote_host() */
1110 /** Only ever set if doing rfc1413 lookups. N.B. Only access this through
1111 * get_remote_logname() */
1112 char *remote_logname;
1114 /** server IP address */
1116 /** used for ap_get_server_name when UseCanonicalName is set to DNS
1117 * (ignores setting of HostnameLookups) */
1120 /** ID of this connection; unique at any point in time */
1122 /** Config vector containing pointers to connections per-server
1123 * config structures. */
1124 struct ap_conf_vector_t *conn_config;
1125 /** Notes on *this* connection: send note from one module to
1126 * another. must remain valid for all requests on this conn */
1128 /** A list of input filters to be used for this connection */
1129 struct ap_filter_t *input_filters;
1130 /** A list of output filters to be used for this connection */
1131 struct ap_filter_t *output_filters;
1132 /** handle to scoreboard information for this connection */
1134 /** The bucket allocator to use for all bucket/brigade creations */
1135 struct apr_bucket_alloc_t *bucket_alloc;
1136 /** The current state of this connection; may be NULL if not used by MPM */
1138 /** Is there data pending in the input filters? */
1139 int data_in_input_filters;
1140 /** No longer used, replaced with ap_filter_should_yield() */
1141 int data_in_output_filters;
1143 /** Are there any filters that clogg/buffer the input stream, breaking
1146 unsigned int clogging_input_filters:1;
1148 /** have we done double-reverse DNS? -1 yes/failure, 0 not yet,
1150 signed int double_reverse:2;
1152 /** Are we still talking? */
1155 /** Are we going to keep the connection alive for another request?
1156 * @see ap_conn_keepalive_e */
1157 ap_conn_keepalive_e keepalive;
1159 /** How many times have we used it? */
1162 /** Optional connection log level configuration. May point to a server or
1163 * per_dir config, i.e. must be copied before modifying */
1164 const struct ap_logconf *log;
1166 /** Id to identify this connection in error log. Set when the first
1167 * error log entry for this connection is generated.
1172 /** This points to the current thread being used to process this request,
1173 * over the lifetime of a request, the value may change. Users of the connection
1174 * record should not rely upon it staying the same between calls that involve
1178 apr_thread_t *current_thread;
1181 /** Array of slave connections (conn_slave_rec *) for this connection. */
1182 apr_array_header_t *slaves;
1184 /** The "real" master connection. NULL if I am the master. */
1187 /** context of this connection */
1190 /** Context under which this connection was suspended */
1191 void *suspended_baton;
1193 /** Array of requests being handled under this connection. */
1194 apr_array_header_t *requests;
1196 /** Empty bucket brigade */
1197 apr_bucket_brigade *empty;
1199 /** Hashtable of filters with setaside buckets for write completion */
1200 apr_hash_t *filters;
1203 struct conn_slave_rec {
1208 * Enumeration of connection states
1209 * The two states CONN_STATE_LINGER_NORMAL and CONN_STATE_LINGER_SHORT may
1210 * only be set by the MPM. Use CONN_STATE_LINGER outside of the MPM.
1213 CONN_STATE_CHECK_REQUEST_LINE_READABLE,
1214 CONN_STATE_READ_REQUEST_LINE,
1216 CONN_STATE_WRITE_COMPLETION,
1217 CONN_STATE_SUSPENDED,
1218 CONN_STATE_LINGER, /* connection may be closed with lingering */
1219 CONN_STATE_LINGER_NORMAL, /* MPM has started lingering close with normal timeout */
1220 CONN_STATE_LINGER_SHORT /* MPM has started lingering close with short timeout */
1225 CONN_SENSE_WANT_READ, /* next event must be read */
1226 CONN_SENSE_WANT_WRITE /* next event must be write */
1230 * @brief A structure to contain connection state information
1232 struct conn_state_t {
1233 /** Current state of the connection */
1235 /** Whether to read instead of write, or write instead of read */
1239 /* Per-vhost config... */
1242 * The address 255.255.255.255, when used as a virtualhost address,
1243 * will become the "default" server when the ip doesn't match other vhosts.
1245 #define DEFAULT_VHOST_ADDR 0xfffffffful
1249 * @struct server_addr_rec
1250 * @brief A structure to be used for Per-vhost config
1252 typedef struct server_addr_rec server_addr_rec;
1253 struct server_addr_rec {
1254 /** The next server in the list */
1255 server_addr_rec *next;
1256 /** The name given in "<VirtualHost>" */
1258 /** The bound address, for this server */
1259 apr_sockaddr_t *host_addr;
1260 /** The bound port, for this server */
1261 apr_port_t host_port;
1265 /** The per-module log levels */
1266 signed char *module_levels;
1268 /** The log level for this server */
1272 * @brief A structure to store information for each virtual server
1275 /** The process this server is running in */
1276 process_rec *process;
1277 /** The next server in the list */
1280 /* Log files --- note that transfer log is now in the modules... */
1282 /** The name of the error log */
1284 /** A file descriptor that references the error log */
1285 apr_file_t *error_log;
1286 /** The log level configuration */
1287 struct ap_logconf log;
1288 /** External error log writer provider */
1289 struct ap_errorlog_provider *errorlog_provider;
1290 /** Handle to be passed to external log provider's logging method */
1291 void *errorlog_provider_handle;
1293 /* Module-specific configuration for server, and defaults... */
1295 /** Config vector containing pointers to modules' per-server config
1297 struct ap_conf_vector_t *module_config;
1298 /** MIME type info, etc., before we start checking per-directory info */
1299 struct ap_conf_vector_t *lookup_defaults;
1301 /** The name of the server */
1302 const char *defn_name;
1303 /** The line of the config file that the server was defined on */
1304 unsigned defn_line_number;
1305 /** true if this is the virtual server */
1309 /* Information for redirects */
1311 /** for redirects, etc. */
1313 /** The server request scheme for redirect responses */
1314 const char *server_scheme;
1316 /* Contact information */
1318 /** The admin's contact information */
1320 /** The server hostname */
1321 char *server_hostname;
1323 /* Transaction handling */
1325 /** I haven't got a clue */
1326 server_addr_rec *addrs;
1327 /** Timeout, as an apr interval, before we give up */
1328 apr_interval_time_t timeout;
1329 /** The apr interval we will wait for another request */
1330 apr_interval_time_t keep_alive_timeout;
1331 /** Maximum requests per connection */
1333 /** Use persistent connections? */
1336 /** Normal names for ServerAlias servers */
1337 apr_array_header_t *names;
1338 /** Wildcarded names for ServerAlias servers */
1339 apr_array_header_t *wild_names;
1341 /** Pathname for ServerPath */
1343 /** Length of path */
1346 /** limit on size of the HTTP request line */
1348 /** limit on size of any request header field */
1349 int limit_req_fieldsize;
1350 /** limit on number of request header fields */
1351 int limit_req_fields;
1353 /** Opaque storage location */
1356 /** Whether the keepalive timeout is explicit (1) or
1357 * inherited (0) from the base server (either first
1358 * server on the same IP:port or main server) */
1359 unsigned int keep_alive_timeout_set:1;
1363 * @struct ap_sload_t
1364 * @brief A structure to hold server load params
1366 typedef struct ap_sload_t ap_sload_t;
1368 /* percentage of process/threads ready/idle (0->100)*/
1370 /* percentage of process/threads busy (0->100) */
1372 /* total bytes served */
1373 apr_off_t bytes_served;
1374 /* total access count */
1375 unsigned long access_count;
1379 * @struct ap_loadavg_t
1380 * @brief A structure to hold various server loadavg
1382 typedef struct ap_loadavg_t ap_loadavg_t;
1383 struct ap_loadavg_t {
1384 /* current loadavg, ala getloadavg() */
1388 /* 15 min loadavg */
1393 * Get the context_document_root for a request. This is a generalization of
1394 * the document root, which is too limited in the presence of mappers like
1395 * mod_userdir and mod_alias. The context_document_root is the directory
1396 * on disk that maps to the context_prefix URI prefix.
1397 * @param r The request
1398 * @note For resources that do not map to the file system or for very complex
1399 * mappings, this information may still be wrong.
1401 AP_DECLARE(const char *) ap_context_document_root(request_rec *r);
1404 * Get the context_prefix for a request. The context_prefix URI prefix
1405 * maps to the context_document_root on disk.
1406 * @param r The request
1408 AP_DECLARE(const char *) ap_context_prefix(request_rec *r);
1410 /** Set context_prefix and context_document_root for a request.
1411 * @param r The request
1412 * @param prefix the URI prefix, without trailing slash
1413 * @param document_root the corresponding directory on disk, without trailing
1415 * @note If one of prefix of document_root is NULL, the corrsponding
1416 * property will not be changed.
1418 AP_DECLARE(void) ap_set_context_info(request_rec *r, const char *prefix,
1419 const char *document_root);
1421 /** Set per-request document root. This is for mass virtual hosting modules
1422 * that want to provide the correct DOCUMENT_ROOT value to scripts.
1423 * @param r The request
1424 * @param document_root the document root for the request.
1426 AP_DECLARE(void) ap_set_document_root(request_rec *r, const char *document_root);
1429 * Examine a field value (such as a media-/content-type) string and return
1430 * it sans any parameters; e.g., strip off any ';charset=foo' and the like.
1431 * @param p Pool to allocate memory from
1432 * @param intype The field to examine
1433 * @return A copy of the field minus any parameters
1435 AP_DECLARE(char *) ap_field_noparam(apr_pool_t *p, const char *intype);
1438 * Convert a time from an integer into a string in a specified format
1439 * @param p The pool to allocate memory from
1440 * @param t The time to convert
1441 * @param fmt The format to use for the conversion
1442 * @param gmt Convert the time for GMT?
1443 * @return The string that represents the specified time
1445 AP_DECLARE(char *) ap_ht_time(apr_pool_t *p, apr_time_t t, const char *fmt, int gmt);
1447 /* String handling. The *_nc variants allow you to use non-const char **s as
1448 arguments (unfortunately C won't automatically convert a char ** to a const
1452 * Get the characters until the first occurrence of a specified character
1453 * @param p The pool to allocate memory from
1454 * @param line The string to get the characters from
1455 * @param stop The character to stop at
1456 * @return A copy of the characters up to the first stop character
1458 AP_DECLARE(char *) ap_getword(apr_pool_t *p, const char **line, char stop);
1461 * Get the characters until the first occurrence of a specified character
1462 * @param p The pool to allocate memory from
1463 * @param line The string to get the characters from
1464 * @param stop The character to stop at
1465 * @return A copy of the characters up to the first stop character
1466 * @note This is the same as ap_getword(), except it doesn't use const char **.
1468 AP_DECLARE(char *) ap_getword_nc(apr_pool_t *p, char **line, char stop);
1471 * Get the first word from a given string. A word is defined as all characters
1472 * up to the first whitespace.
1473 * @param p The pool to allocate memory from
1474 * @param line The string to traverse
1475 * @return The first word in the line
1477 AP_DECLARE(char *) ap_getword_white(apr_pool_t *p, const char **line);
1480 * Get the first word from a given string. A word is defined as all characters
1481 * up to the first whitespace.
1482 * @param p The pool to allocate memory from
1483 * @param line The string to traverse
1484 * @return The first word in the line
1485 * @note The same as ap_getword_white(), except it doesn't use const char**
1487 AP_DECLARE(char *) ap_getword_white_nc(apr_pool_t *p, char **line);
1490 * Get all characters from the first occurrence of @a stop to the first "\0"
1491 * @param p The pool to allocate memory from
1492 * @param line The line to traverse
1493 * @param stop The character to start at
1494 * @return A copy of all characters after the first occurrence of the specified
1497 AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *p, const char **line,
1501 * Get all characters from the first occurrence of @a stop to the first "\0"
1502 * @param p The pool to allocate memory from
1503 * @param line The line to traverse
1504 * @param stop The character to start at
1505 * @return A copy of all characters after the first occurrence of the specified
1507 * @note The same as ap_getword_nulls(), except it doesn't use const char **.
1509 AP_DECLARE(char *) ap_getword_nulls_nc(apr_pool_t *p, char **line, char stop);
1512 * Get the second word in the string paying attention to quoting
1513 * @param p The pool to allocate from
1514 * @param line The line to traverse
1515 * @return A copy of the string
1517 AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line);
1520 * Get the second word in the string paying attention to quoting
1521 * @param p The pool to allocate from
1522 * @param line The line to traverse
1523 * @return A copy of the string
1524 * @note The same as ap_getword_conf(), except it doesn't use const char **.
1526 AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line);
1529 * Check a string for any config define or environment variable construct
1530 * and replace each of them by the value of that variable, if it exists.
1531 * The default syntax of the constructs is ${ENV} but can be changed by
1532 * setting the define::* config defines. If the variable does not exist,
1533 * leave the ${ENV} construct alone but print a warning.
1534 * @param p The pool to allocate from
1535 * @param word The string to check
1536 * @return The string with the replaced environment variables
1538 AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word);
1541 * Size an HTTP header field list item, as separated by a comma.
1542 * @param field The field to size
1543 * @param len The length of the field
1544 * @return The return value is a pointer to the beginning of the non-empty
1545 * list item within the original string (or NULL if there is none) and the
1546 * address of field is shifted to the next non-comma, non-whitespace
1547 * character. len is the length of the item excluding any beginning whitespace.
1549 AP_DECLARE(const char *) ap_size_list_item(const char **field, int *len);
1552 * Retrieve an HTTP header field list item, as separated by a comma,
1553 * while stripping insignificant whitespace and lowercasing anything not in
1554 * a quoted string or comment.
1555 * @param p The pool to allocate from
1556 * @param field The field to retrieve
1557 * @return The return value is a new string containing the converted list
1558 * item (or NULL if none) and the address pointed to by field is
1559 * shifted to the next non-comma, non-whitespace.
1561 AP_DECLARE(char *) ap_get_list_item(apr_pool_t *p, const char **field);
1564 * Find an item in canonical form (lowercase, no extra spaces) within
1565 * an HTTP field value list.
1566 * @param p The pool to allocate from
1567 * @param line The field value list to search
1568 * @param tok The token to search for
1569 * @return 1 if found, 0 if not found.
1571 AP_DECLARE(int) ap_find_list_item(apr_pool_t *p, const char *line, const char *tok);
1574 * Do a weak ETag comparison within an HTTP field value list.
1575 * @param p The pool to allocate from
1576 * @param line The field value list to search
1577 * @param tok The token to search for
1578 * @return 1 if found, 0 if not found.
1580 AP_DECLARE(int) ap_find_etag_weak(apr_pool_t *p, const char *line, const char *tok);
1583 * Do a strong ETag comparison within an HTTP field value list.
1584 * @param p The pool to allocate from
1585 * @param line The field value list to search
1586 * @param tok The token to search for
1587 * @return 1 if found, 0 if not found.
1589 AP_DECLARE(int) ap_find_etag_strong(apr_pool_t *p, const char *line, const char *tok);
1592 * Retrieve an array of tokens in the format "1#token" defined in RFC2616. Only
1593 * accepts ',' as a delimiter, does not accept quoted strings, and errors on
1595 * @param p The pool to allocate from
1596 * @param tok The line to read tokens from
1597 * @param tokens Pointer to an array of tokens. If not NULL, must be an array
1598 * of char*, otherwise it will be allocated on @a p when a token is found
1599 * @param skip_invalid If true, when an invalid separator is encountered, it
1601 * @return NULL on success, an error string otherwise.
1602 * @remark *tokens may be NULL on output if NULL in input and no token is found
1604 AP_DECLARE(const char *) ap_parse_token_list_strict(apr_pool_t *p, const char *tok,
1605 apr_array_header_t **tokens,
1609 * Retrieve a token, spacing over it and adjusting the pointer to
1610 * the first non-white byte afterwards. Note that these tokens
1611 * are delimited by semis and commas and can also be delimited
1612 * by whitespace at the caller's option.
1613 * @param p The pool to allocate from
1614 * @param accept_line The line to retrieve the token from (adjusted afterwards)
1615 * @param accept_white Is it delimited by whitespace
1618 AP_DECLARE(char *) ap_get_token(apr_pool_t *p, const char **accept_line, int accept_white);
1621 * Find http tokens, see the definition of token from RFC2068
1622 * @param p The pool to allocate from
1623 * @param line The line to find the token
1624 * @param tok The token to find
1625 * @return 1 if the token is found, 0 otherwise
1627 AP_DECLARE(int) ap_find_token(apr_pool_t *p, const char *line, const char *tok);
1630 * find http tokens from the end of the line
1631 * @param p The pool to allocate from
1632 * @param line The line to find the token
1633 * @param tok The token to find
1634 * @return 1 if the token is found, 0 otherwise
1636 AP_DECLARE(int) ap_find_last_token(apr_pool_t *p, const char *line, const char *tok);
1639 * Check for an Absolute URI syntax
1640 * @param u The string to check
1641 * @return 1 if URI, 0 otherwise
1643 AP_DECLARE(int) ap_is_url(const char *u);
1647 * @param url The string to unescape
1648 * @return 0 on success, non-zero otherwise
1650 AP_DECLARE(int) ap_unescape_all(char *url);
1654 * @param url The url to unescape
1655 * @return 0 on success, non-zero otherwise
1656 * @deprecated Replaced by apr_unescape_url() in APR
1658 AP_DECLARE(int) ap_unescape_url(char *url);
1661 * Unescape a URL, but leaving %2f (slashes) escaped
1662 * @param url The url to unescape
1663 * @param decode_slashes Whether or not slashes should be decoded
1664 * @return 0 on success, non-zero otherwise
1665 * @deprecated Replaced by apr_unescape_url() in APR
1667 AP_DECLARE(int) ap_unescape_url_keep2f(char *url, int decode_slashes);
1670 * Unescape an application/x-www-form-urlencoded string
1671 * @param query The query to unescape
1672 * @return 0 on success, non-zero otherwise
1673 * @deprecated Replaced by apr_unescape_url() in APR
1675 AP_DECLARE(int) ap_unescape_urlencoded(char *query);
1678 * Convert all double slashes to single slashes
1679 * @param name The string to convert
1681 AP_DECLARE(void) ap_no2slash(char *name)
1682 AP_FN_ATTR_NONNULL_ALL;
1685 * Remove all ./ and xx/../ substrings from a file name. Also remove
1686 * any leading ../ or /../ substrings.
1687 * @param name the file name to parse
1689 AP_DECLARE(void) ap_getparents(char *name)
1690 AP_FN_ATTR_NONNULL_ALL;
1693 * Escape a path segment, as defined in RFC 1808
1694 * @param p The pool to allocate from
1695 * @param s The path to convert
1696 * @return The converted URL
1697 * @deprecated Replaced by apr_pescape_path_segment() in APR
1699 AP_DECLARE(char *) ap_escape_path_segment(apr_pool_t *p, const char *s)
1700 AP_FN_ATTR_NONNULL_ALL;
1703 * Escape a path segment, as defined in RFC 1808, to a preallocated buffer.
1704 * @param c The preallocated buffer to write to
1705 * @param s The path to convert
1706 * @return The converted URL (c)
1707 * @deprecated Replaced by apr_escape_path_segment() in APR
1709 AP_DECLARE(char *) ap_escape_path_segment_buffer(char *c, const char *s)
1710 AP_FN_ATTR_NONNULL_ALL;
1713 * convert an OS path to a URL in an OS dependent way.
1714 * @param p The pool to allocate from
1715 * @param path The path to convert
1716 * @param partial if set, assume that the path will be appended to something
1717 * with a '/' in it (and thus does not prefix "./").
1718 * @return The converted URL, with one byte of extra space after the NUL
1719 * to allow the caller to add a trailing '/'.
1720 * @deprecated Replaced by apr_pescape_path() in APR
1722 AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial)
1723 AP_FN_ATTR_NONNULL_ALL;
1725 /** @see ap_os_escape_path */
1726 #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
1729 * Escape a string as application/x-www-form-urlencoded
1730 * @param p The pool to allocate from
1731 * @param s The path to convert
1732 * @return The converted URL
1733 * @deprecated Replaced by apr_pescape_url() in APR
1735 AP_DECLARE(char *) ap_escape_urlencoded(apr_pool_t *p, const char *s)
1736 AP_FN_ATTR_NONNULL_ALL;
1739 * Escape a string as application/x-www-form-urlencoded, to a preallocated buffer
1740 * @param c The preallocated buffer to write to
1741 * @param s The path to convert
1742 * @return The converted URL (c)
1743 * @deprecated Replaced by apr_escape_url() in APR
1745 AP_DECLARE(char *) ap_escape_urlencoded_buffer(char *c, const char *s)
1746 AP_FN_ATTR_NONNULL_ALL;
1749 * Escape an html string
1750 * @param p The pool to allocate from
1751 * @param s The html to escape
1752 * @return The escaped string
1753 * @deprecated Replaced by apr_pescape_entity() in APR
1755 #define ap_escape_html(p,s) ap_escape_html2(p,s,0)
1757 * Escape an html string
1758 * @param p The pool to allocate from
1759 * @param s The html to escape
1760 * @param toasc Whether to escape all non-ASCII chars to \&\#nnn;
1761 * @return The escaped string
1762 * @deprecated Replaced by apr_pescape_entity() in APR
1764 AP_DECLARE(char *) ap_escape_html2(apr_pool_t *p, const char *s, int toasc)
1765 AP_FN_ATTR_NONNULL_ALL;
1768 * Escape a string for logging
1769 * @param p The pool to allocate from
1770 * @param str The string to escape
1771 * @return The escaped string
1772 * @deprecated Replaced by apr_pescape_echo() in APR
1774 AP_DECLARE(char *) ap_escape_logitem(apr_pool_t *p, const char *str)
1775 AP_FN_ATTR_NONNULL((1));
1778 * Escape a string for logging into the error log (without a pool)
1779 * @param dest The buffer to write to
1780 * @param source The string to escape
1781 * @param buflen The buffer size for the escaped string (including "\0")
1782 * @return The len of the escaped string (always < maxlen)
1783 * @deprecated Replaced by apr_escape_echo() in APR
1785 AP_DECLARE(apr_size_t) ap_escape_errorlog_item(char *dest, const char *source,
1787 AP_FN_ATTR_NONNULL((1));
1790 * Construct a full hostname
1791 * @param p The pool to allocate from
1792 * @param hostname The hostname of the server
1793 * @param port The port the server is running on
1794 * @param r The current request
1795 * @return The server's hostname
1797 AP_DECLARE(char *) ap_construct_server(apr_pool_t *p, const char *hostname,
1798 apr_port_t port, const request_rec *r)
1799 AP_FN_ATTR_NONNULL((1,4));
1802 * Escape a shell command
1803 * @param p The pool to allocate from
1804 * @param s The command to escape
1805 * @return The escaped shell command
1806 * @deprecated Replaced with apr_escape_shell() in APR
1808 AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *s)
1809 AP_FN_ATTR_NONNULL_ALL;
1812 * Count the number of directories in a path
1813 * @param path The path to count
1814 * @return The number of directories
1816 AP_DECLARE(int) ap_count_dirs(const char *path)
1817 AP_FN_ATTR_NONNULL_ALL;
1820 * Copy at most @a n leading directories of @a s into @a d. @a d
1821 * should be at least as large as @a s plus 1 extra byte
1823 * @param d The location to copy to
1824 * @param s The location to copy from
1825 * @param n The number of directories to copy
1826 * @return value is the ever useful pointer to the trailing "\0" of d
1827 * @note on platforms with drive letters, n = 0 returns the "/" root,
1828 * whereas n = 1 returns the "d:/" root. On all other platforms, n = 0
1829 * returns the empty string. */
1830 AP_DECLARE(char *) ap_make_dirstr_prefix(char *d, const char *s, int n)
1831 AP_FN_ATTR_NONNULL_ALL;
1834 * Return the parent directory name (including trailing /) of the file
1836 * @param p The pool to allocate from
1837 * @param s The file to get the parent of
1838 * @return A copy of the file's parent directory
1840 AP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s)
1841 AP_FN_ATTR_NONNULL_ALL;
1844 * Given a directory and filename, create a single path from them. This
1845 * function is smart enough to ensure that there is a single '/' between the
1846 * directory and file names
1847 * @param a The pool to allocate from
1848 * @param dir The directory name
1849 * @param f The filename
1850 * @return A copy of the full path, with one byte of extra space after the NUL
1851 * to allow the caller to add a trailing '/'.
1852 * @note Never consider using this function if you are dealing with filesystem
1853 * names that need to remain canonical, unless you are merging an apr_dir_read
1854 * path and returned filename. Otherwise, the result is not canonical.
1856 AP_DECLARE(char *) ap_make_full_path(apr_pool_t *a, const char *dir, const char *f)
1857 AP_FN_ATTR_NONNULL_ALL;
1860 * Test if the given path has an absolute path.
1861 * @param p The pool to allocate from
1862 * @param dir The directory name
1863 * @note The converse is not necessarily true, some OS's (Win32/OS2/Netware) have
1864 * multiple forms of absolute paths. This only reports if the path is absolute
1865 * in a canonical sense.
1867 AP_DECLARE(int) ap_os_is_path_absolute(apr_pool_t *p, const char *dir)
1868 AP_FN_ATTR_NONNULL_ALL;
1871 * Does the provided string contain wildcard characters? This is useful
1872 * for determining if the string should be passed to strcmp_match or to strcmp.
1873 * The only wildcard characters recognized are '?' and '*'
1874 * @param str The string to check
1875 * @return 1 if the string has wildcards, 0 otherwise
1877 AP_DECLARE(int) ap_is_matchexp(const char *str)
1878 AP_FN_ATTR_NONNULL_ALL;
1881 * Determine if a string matches a patterm containing the wildcards '?' or '*'
1882 * @param str The string to check
1883 * @param expected The pattern to match against
1884 * @return 0 if the two strings match, 1 otherwise
1886 AP_DECLARE(int) ap_strcmp_match(const char *str, const char *expected)
1887 AP_FN_ATTR_NONNULL_ALL;
1890 * Determine if a string matches a patterm containing the wildcards '?' or '*',
1892 * @param str The string to check
1893 * @param expected The pattern to match against
1894 * @return 0 if the two strings match, 1 otherwise
1896 AP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *expected)
1897 AP_FN_ATTR_NONNULL_ALL;
1900 * Find the first occurrence of the substring s2 in s1, regardless of case
1901 * @param s1 The string to search
1902 * @param s2 The substring to search for
1903 * @return A pointer to the beginning of the substring
1904 * @remark See apr_strmatch() for a faster alternative
1906 AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2)
1907 AP_FN_ATTR_NONNULL_ALL;
1910 * Return a pointer to the location inside of bigstring immediately after prefix
1911 * @param bigstring The input string
1912 * @param prefix The prefix to strip away
1913 * @return A pointer relative to bigstring after prefix
1915 AP_DECLARE(const char *) ap_stripprefix(const char *bigstring,
1917 AP_FN_ATTR_NONNULL_ALL;
1920 * Decode a base64 encoded string into memory allocated from a pool
1921 * @param p The pool to allocate from
1922 * @param bufcoded The encoded string
1923 * @return The decoded string
1924 * @deprecated Replaced by apr_pbase64_decode() in APR.
1926 AP_DECLARE(char *) ap_pbase64decode(apr_pool_t *p, const char *bufcoded);
1929 * Encode a string into memory allocated from a pool in base 64 format
1930 * @param p The pool to allocate from
1931 * @param string The plaintext string
1932 * @return The encoded string
1933 * @deprecated Replaced by apr_pbase64_encode() in APR.
1935 AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string);
1938 * Compile a regular expression to be used later. The regex is freed when
1939 * the pool is destroyed.
1940 * @param p The pool to allocate from
1941 * @param pattern the regular expression to compile
1942 * @param cflags The bitwise or of one or more of the following:
1943 * @li REG_EXTENDED - Use POSIX extended Regular Expressions
1944 * @li REG_ICASE - Ignore case
1945 * @li REG_NOSUB - Support for substring addressing of matches
1947 * @li REG_NEWLINE - Match-any-character operators don't match new-line
1948 * @return The compiled regular expression
1950 AP_DECLARE(ap_regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
1954 * Free the memory associated with a compiled regular expression
1955 * @param p The pool the regex was allocated from
1956 * @param reg The regular expression to free
1957 * @note This function is only necessary if the regex should be cleaned
1958 * up before the pool
1960 AP_DECLARE(void) ap_pregfree(apr_pool_t *p, ap_regex_t *reg);
1963 * After performing a successful regex match, you may use this function to
1964 * perform a series of string substitutions based on subexpressions that were
1965 * matched during the call to ap_regexec. This function is limited to
1966 * result strings of 64K. Consider using ap_pregsub_ex() instead.
1967 * @param p The pool to allocate from
1968 * @param input An arbitrary string containing $1 through $9. These are
1969 * replaced with the corresponding matched sub-expressions
1970 * @param source The string that was originally matched to the regex
1971 * @param nmatch the nmatch returned from ap_pregex
1972 * @param pmatch the pmatch array returned from ap_pregex
1973 * @return The substituted string, or NULL on error
1975 AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
1976 const char *source, apr_size_t nmatch,
1977 ap_regmatch_t pmatch[]);
1980 * After performing a successful regex match, you may use this function to
1981 * perform a series of string substitutions based on subexpressions that were
1982 * matched during the call to ap_regexec
1983 * @param p The pool to allocate from
1984 * @param result where to store the result, will be set to NULL on error
1985 * @param input An arbitrary string containing $1 through $9. These are
1986 * replaced with the corresponding matched sub-expressions
1987 * @param source The string that was originally matched to the regex
1988 * @param nmatch the nmatch returned from ap_pregex
1989 * @param pmatch the pmatch array returned from ap_pregex
1990 * @param maxlen the maximum string length to return, 0 for unlimited
1991 * @return APR_SUCCESS if successful, APR_ENOMEM or other error code otherwise.
1993 AP_DECLARE(apr_status_t) ap_pregsub_ex(apr_pool_t *p, char **result,
1994 const char *input, const char *source,
1996 ap_regmatch_t pmatch[],
2000 * We want to downcase the type/subtype for comparison purposes
2001 * but nothing else because ;parameter=foo values are case sensitive.
2002 * @param s The content-type to convert to lowercase
2004 AP_DECLARE(void) ap_content_type_tolower(char *s);
2007 * convert a string to all lowercase
2008 * @param s The string to convert to lowercase
2010 AP_DECLARE(void) ap_str_tolower(char *s);
2013 * convert a string to all uppercase
2014 * @param s The string to convert to uppercase
2016 AP_DECLARE(void) ap_str_toupper(char *s);
2019 * Search a string from left to right for the first occurrence of a
2020 * specific character
2021 * @param str The string to search
2022 * @param c The character to search for
2023 * @return The index of the first occurrence of c in str
2025 AP_DECLARE(int) ap_ind(const char *str, char c); /* Sigh... */
2028 * Search a string from right to left for the first occurrence of a
2029 * specific character
2030 * @param str The string to search
2031 * @param c The character to search for
2032 * @return The index of the first occurrence of c in str
2034 AP_DECLARE(int) ap_rind(const char *str, char c);
2037 * Given a string, replace any bare " with \\" .
2038 * @param p The pool to allocate memory from
2039 * @param instring The string to search for "
2040 * @return A copy of the string with escaped quotes
2041 * @deprecated Replaced by apr_pescape_echo() in APR
2043 AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring);
2046 * Given a string, append the PID deliminated by delim.
2047 * Usually used to create a pid-appended filepath name
2048 * (eg: /a/b/foo -> /a/b/foo.6726). A function, and not
2049 * a macro, to avoid unistd.h dependency
2050 * @param p The pool to allocate memory from
2051 * @param string The string to append the PID to
2052 * @param delim The string to use to deliminate the string from the PID
2053 * @return A copy of the string with the PID appended
2055 AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string,
2059 * Parse a given timeout parameter string into an apr_interval_time_t value.
2060 * The unit of the time interval is given as postfix string to the numeric
2061 * string. Currently the following units are understood:
2068 * If no unit is contained in the given timeout parameter the default_time_unit
2069 * will be used instead.
2070 * @param timeout_parameter The string containing the timeout parameter.
2071 * @param timeout The timeout value to be returned.
2072 * @param default_time_unit The default time unit to use if none is specified
2073 * in timeout_parameter.
2074 * @return Status value indicating whether the parsing was successful or not.
2076 AP_DECLARE(apr_status_t) ap_timeout_parameter_parse(
2077 const char *timeout_parameter,
2078 apr_interval_time_t *timeout,
2079 const char *default_time_unit);
2082 * Determine if a request has a request body or not.
2084 * @param r the request_rec of the request
2085 * @return truth value
2087 AP_DECLARE(int) ap_request_has_body(request_rec *r);
2090 * Cleanup a string (mainly to be filesystem safe)
2091 * We only allow '_' and alphanumeric chars. Non-printable
2092 * map to 'x' and all others map to '_'
2094 * @param p pool to use to allocate dest
2095 * @param src string to clean up
2096 * @param dest cleaned up, allocated string
2097 * @return Status value indicating whether the cleaning was successful or not.
2099 AP_DECLARE(apr_status_t) ap_pstr2_alnum(apr_pool_t *p, const char *src,
2103 * Cleanup a string (mainly to be filesystem safe)
2104 * We only allow '_' and alphanumeric chars. Non-printable
2105 * map to 'x' and all others map to '_'
2107 * @param src string to clean up
2108 * @param dest cleaned up, pre-allocated string
2109 * @return Status value indicating whether the cleaning was successful or not.
2111 AP_DECLARE(apr_status_t) ap_str2_alnum(const char *src, char *dest);
2114 * Structure to store the contents of an HTTP form of the type
2115 * application/x-www-form-urlencoded.
2117 * Currently it contains the name as a char* of maximum length
2118 * HUGE_STRING_LEN, and a value in the form of a bucket brigade
2119 * of arbitrary length.
2123 apr_bucket_brigade *value;
2127 * Read the body and parse any form found, which must be of the
2128 * type application/x-www-form-urlencoded.
2129 * @param r request containing POSTed form data
2131 * @param ptr returned array of ap_form_pair_t
2132 * @param num max num of params or -1 for unlimited
2133 * @param size max size allowed for parsed data
2134 * @return OK or HTTP error
2136 AP_DECLARE(int) ap_parse_form_data(request_rec *r, struct ap_filter_t *f,
2137 apr_array_header_t **ptr,
2138 apr_size_t num, apr_size_t size);
2140 /* Misc system hackery */
2142 * Given the name of an object in the file system determine if it is a directory
2143 * @param p The pool to allocate from
2144 * @param name The name of the object to check
2145 * @return 1 if it is a directory, 0 otherwise
2147 AP_DECLARE(int) ap_is_rdirectory(apr_pool_t *p, const char *name);
2150 * Given the name of an object in the file system determine if it is a directory - this version is symlink aware
2151 * @param p The pool to allocate from
2152 * @param name The name of the object to check
2153 * @return 1 if it is a directory, 0 otherwise
2155 AP_DECLARE(int) ap_is_directory(apr_pool_t *p, const char *name);
2158 extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
2159 #endif /* _OSD_POSIX */
2162 * Determine the local host name for the current machine
2163 * @param p The pool to allocate from
2164 * @return A copy of the local host name
2166 char *ap_get_local_host(apr_pool_t *p);
2169 * Log an assertion to the error log
2170 * @param szExp The assertion that failed
2171 * @param szFile The file the assertion is in
2172 * @param nLine The line the assertion is defined on
2174 AP_DECLARE(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
2175 __attribute__((noreturn));
2178 * @internal Internal Assert function
2180 #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
2183 * Redefine assert() to something more useful for an Apache...
2185 * Use ap_assert() if the condition should always be checked.
2186 * Use AP_DEBUG_ASSERT() if the condition should only be checked when AP_DEBUG
2190 #define AP_DEBUG_ASSERT(exp) ap_assert(exp)
2192 #define AP_DEBUG_ASSERT(exp) ((void)0)
2196 * @defgroup stopsignal Flags which indicate places where the server should stop for debugging.
2198 * A set of flags which indicate places where the server should raise(SIGSTOP).
2199 * This is useful for debugging, because you can then attach to that process
2200 * with gdb and continue. This is important in cases where one_process
2201 * debugging isn't possible.
2203 /** stop on a Detach */
2204 #define SIGSTOP_DETACH 1
2205 /** stop making a child process */
2206 #define SIGSTOP_MAKE_CHILD 2
2207 /** stop spawning a child process */
2208 #define SIGSTOP_SPAWN_CHILD 4
2209 /** stop spawning a child process with a piped log */
2210 #define SIGSTOP_PIPED_LOG_SPAWN 8
2211 /** stop spawning a CGI child process */
2212 #define SIGSTOP_CGI_CHILD 16
2214 /** Macro to get GDB started */
2215 #ifdef DEBUG_SIGSTOP
2216 extern int raise_sigstop_flags;
2217 #define RAISE_SIGSTOP(x) do { \
2218 if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
2221 #define RAISE_SIGSTOP(x)
2225 * Get HTML describing the address and (optionally) admin of the server.
2226 * @param prefix Text which is prepended to the return value
2227 * @param r The request_rec
2228 * @return HTML describing the server, allocated in @a r's pool.
2230 AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r);
2232 /* The C library has functions that allow const to be silently dropped ...
2233 these macros detect the drop in maintainer mode, but use the native
2234 methods for normal builds
2236 Note that on some platforms (e.g., AIX with gcc, Solaris with gcc), string.h needs
2237 to be included before the macros are defined or compilation will fail.
2241 AP_DECLARE(char *) ap_strchr(char *s, int c);
2242 AP_DECLARE(const char *) ap_strchr_c(const char *s, int c);
2243 AP_DECLARE(char *) ap_strrchr(char *s, int c);
2244 AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c);
2245 AP_DECLARE(char *) ap_strstr(char *s, const char *c);
2246 AP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c);
2247 AP_DECLARE(void *) ap_palloc_debug(apr_pool_t *p, apr_size_t size);
2248 AP_DECLARE(void *) ap_pcalloc_debug(apr_pool_t *p, apr_size_t size);
2253 # define strchr(s, c) ap_strchr(s,c)
2255 # define strrchr(s, c) ap_strrchr(s,c)
2257 # define strstr(s, c) ap_strstr(s,c)
2259 #if !defined(AP_DEBUG_NO_ALLOC_POISON) && !APR_POOL_DEBUG
2261 * ap_palloc_debug initializes allocated memory to non-zero
2263 #define apr_palloc ap_palloc_debug
2265 * this is necessary to avoid useless double memset of memory
2266 * with ap_palloc_debug
2271 #define apr_pcalloc ap_pcalloc_debug
2276 /** use this instead of strchr */
2277 # define ap_strchr(s, c) strchr(s, c)
2278 /** use this instead of strchr */
2279 # define ap_strchr_c(s, c) strchr(s, c)
2280 /** use this instead of strrchr */
2281 # define ap_strrchr(s, c) strrchr(s, c)
2282 /** use this instead of strrchr */
2283 # define ap_strrchr_c(s, c) strrchr(s, c)
2284 /** use this instead of strrstr*/
2285 # define ap_strstr(s, c) strstr(s, c)
2286 /** use this instead of strrstr*/
2287 # define ap_strstr_c(s, c) strstr(s, c)
2292 * Generate pseudo random bytes.
2293 * This is a convenience interface to apr_random. It is cheaper but less
2294 * secure than apr_generate_random_bytes().
2295 * @param buf where to store the bytes
2296 * @param size number of bytes to generate
2297 * @note ap_random_insecure_bytes() is thread-safe, it uses a mutex on
2300 AP_DECLARE(void) ap_random_insecure_bytes(void *buf, apr_size_t size);
2303 * Get a pseudo random number in a range.
2304 * @param min low end of range
2305 * @param max high end of range
2306 * @return a number in the range
2308 AP_DECLARE(apr_uint32_t) ap_random_pick(apr_uint32_t min, apr_uint32_t max);
2311 * Abort with a error message signifying out of memory
2313 AP_DECLARE(void) ap_abort_on_oom(void) __attribute__((noreturn));
2316 * Wrapper for malloc() that calls ap_abort_on_oom() if out of memory
2317 * @param size size of the memory block
2318 * @return pointer to the allocated memory
2319 * @note ap_malloc may be implemented as a macro
2321 AP_DECLARE(void *) ap_malloc(size_t size)
2322 __attribute__((malloc))
2323 AP_FN_ATTR_ALLOC_SIZE(1);
2326 * Wrapper for calloc() that calls ap_abort_on_oom() if out of memory
2327 * @param nelem number of elements to allocate memory for
2328 * @param size size of a single element
2329 * @return pointer to the allocated memory
2330 * @note ap_calloc may be implemented as a macro
2332 AP_DECLARE(void *) ap_calloc(size_t nelem, size_t size)
2333 __attribute__((malloc))
2334 AP_FN_ATTR_ALLOC_SIZE2(1,2);
2337 * Wrapper for realloc() that calls ap_abort_on_oom() if out of memory
2338 * @param ptr pointer to the old memory block (or NULL)
2339 * @param size new size of the memory block
2340 * @return pointer to the reallocated memory
2341 * @note ap_realloc may be implemented as a macro
2343 AP_DECLARE(void *) ap_realloc(void *ptr, size_t size)
2344 AP_FN_ATTR_WARN_UNUSED_RESULT
2345 AP_FN_ATTR_ALLOC_SIZE(2);
2348 * Get server load params
2349 * @param ld struct to populate: -1 in fields means error
2351 AP_DECLARE(void) ap_get_sload(ap_sload_t *ld)
2352 AP_FN_ATTR_NONNULL_ALL;
2355 * Get server load averages (ala getloadavg)
2356 * @param ld struct to populate: -1 in fields means error
2358 AP_DECLARE(void) ap_get_loadavg(ap_loadavg_t *ld)
2359 AP_FN_ATTR_NONNULL_ALL;
2362 * Convert binary data into a hex string
2363 * @param src pointer to the data
2364 * @param srclen length of the data
2365 * @param dest pointer to buffer of length (2 * srclen + 1). The resulting
2366 * string will be NUL-terminated.
2367 * @deprecated Replaced by apr_escape_hex() in APR
2369 AP_DECLARE(void) ap_bin2hex(const void *src, apr_size_t srclen, char *dest)
2370 AP_FN_ATTR_NONNULL_ALL;
2373 * Check if string contains a control character
2374 * @param str the string to check
2375 * @return 1 if yes, 0 if no control characters
2377 AP_DECLARE(int) ap_has_cntrl(const char *str)
2378 AP_FN_ATTR_NONNULL_ALL;
2381 * Wrapper for @a apr_password_validate() to cache expensive calculations
2382 * @param r the current request
2383 * @param username username of the user
2384 * @param passwd password string
2385 * @param hash hash string to be passwd to @a apr_password_validate()
2386 * @return APR_SUCCESS if passwords match, APR_EMISMATCH or error otherwise
2387 * @note Currently, ap_password_validate() only caches the result of the
2388 * most recent call with the same connection as @a r.
2389 * In the future, it may also do rate-limiting against brute-force
2392 AP_DECLARE(apr_status_t) ap_password_validate(request_rec *r,
2393 const char *username,
2398 * Short function to execute a command and return the first line of
2399 * output minus \\r \\n. Useful for "obscuring" passwords via exec calls
2400 * @param p the pool to allocate from
2401 * @param cmd the command to execute
2402 * @param argv the arguments to pass to the cmd
2403 * @return ptr to characters or NULL on any error
2405 AP_DECLARE(char *) ap_get_exec_line(apr_pool_t *p,
2407 const char * const *argv);
2410 #define AP_NORESTART APR_OS_START_USEERR + 1
2413 * Get the first index of the string in the array or -1 if not found. Start
2414 * searching a start.
2415 * @param array The array the check
2416 * @param s The string to find
2417 * @param start Start index for search. If start is out of bounds (negative or
2418 equal to array length or greater), -1 will be returned.
2419 * @return index of string in array or -1
2421 AP_DECLARE(int) ap_array_str_index(const apr_array_header_t *array,
2426 * Check if the string is member of the given array by strcmp.
2427 * @param array The array the check
2428 * @param s The string to find
2429 * @return !=0 iff string is member of array (via strcmp)
2431 AP_DECLARE(int) ap_array_str_contains(const apr_array_header_t *array,
2438 #endif /* !APACHE_HTTPD_H */
2440 /** @} //APACHE Daemon */
2441 /** @} //APACHE Core */
2442 /** @} //APACHE super group */