]> granicus.if.org Git - apache/blob - include/http_core.h
add comment about (not) using pools in error log format handlers
[apache] / include / http_core.h
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file  http_core.h
19  * @brief CORE HTTP Daemon
20  *
21  * @defgroup APACHE_CORE_HTTPD Core HTTP Daemon
22  * @ingroup  APACHE_CORE
23  * @{
24  */
25
26 #ifndef APACHE_HTTP_CORE_H
27 #define APACHE_HTTP_CORE_H
28
29 #include "apr.h"
30 #include "apr_hash.h"
31 #include "apr_optional.h"
32 #include "util_filter.h"
33 #include "ap_expr.h"
34
35 #include "http_config.h"
36
37 #if APR_HAVE_STRUCT_RLIMIT
38 #include <sys/time.h>
39 #include <sys/resource.h>
40 #endif
41
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 /* ****************************************************************
48  *
49  * The most basic server code is encapsulated in a single module
50  * known as the core, which is just *barely* functional enough to
51  * serve documents, though not terribly well.
52  *
53  * Largely for NCSA back-compatibility reasons, the core needs to
54  * make pieces of its config structures available to other modules.
55  * The accessors are declared here, along with the interpretation
56  * of one of them (allow_options).
57  */
58
59 /**
60  * @defgroup APACHE_CORE_HTTPD_ACESSORS Acessors
61  *
62  * @brief File/Directory Accessor directives
63  *
64  * @{
65  */
66
67 /** No directives */
68 #define OPT_NONE 0
69 /** Indexes directive */
70 #define OPT_INDEXES 1
71 /** SSI is enabled without exec= permission  */
72 #define OPT_INCLUDES 2
73 /**  FollowSymLinks directive */
74 #define OPT_SYM_LINKS 4
75 /**  ExecCGI directive */
76 #define OPT_EXECCGI 8
77 /**  directive unset */
78 #define OPT_UNSET 16
79 /**  SSI exec= permission is permitted, iff OPT_INCLUDES is also set */
80 #define OPT_INC_WITH_EXEC 32
81 /** SymLinksIfOwnerMatch directive */
82 #define OPT_SYM_OWNER 64
83 /** MultiViews directive */
84 #define OPT_MULTI 128
85 /**  All directives */
86 #define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_INC_WITH_EXEC|OPT_SYM_LINKS|OPT_EXECCGI)
87 /** @} */
88
89 /**
90  * @defgroup get_remote_host Remote Host Resolution 
91  * @ingroup APACHE_CORE_HTTPD
92  * @{
93  */
94 /** REMOTE_HOST returns the hostname, or NULL if the hostname
95  * lookup fails.  It will force a DNS lookup according to the
96  * HostnameLookups setting.
97  */
98 #define REMOTE_HOST (0)
99
100 /** REMOTE_NAME returns the hostname, or the dotted quad if the
101  * hostname lookup fails.  It will force a DNS lookup according
102  * to the HostnameLookups setting.
103  */
104 #define REMOTE_NAME (1)
105
106 /** REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
107  * never forced.
108  */
109 #define REMOTE_NOLOOKUP (2)
110
111 /** REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
112  * a double reverse lookup, regardless of the HostnameLookups
113  * setting.  The result is the (double reverse checked) hostname,
114  * or NULL if any of the lookups fail.
115  */
116 #define REMOTE_DOUBLE_REV (3)
117
118 /** @} // get_remote_host */
119
120 /** all of the requirements must be met */
121 #define SATISFY_ALL 0
122 /**  any of the requirements must be met */
123 #define SATISFY_ANY 1
124 /** There are no applicable satisfy lines */
125 #define SATISFY_NOSPEC 2
126
127 /** Make sure we don't write less than 8000 bytes at any one time.
128  */
129 #define AP_MIN_BYTES_TO_WRITE  8000
130
131 /** default maximum of internal redirects */
132 # define AP_DEFAULT_MAX_INTERNAL_REDIRECTS 10
133
134 /** default maximum subrequest nesting level */
135 # define AP_DEFAULT_MAX_SUBREQ_DEPTH 10
136
137 /**
138  * Retrieve the value of Options for this request
139  * @param r The current request
140  * @return the Options bitmask
141  */
142 AP_DECLARE(int) ap_allow_options(request_rec *r);
143
144 /**
145  * Retrieve the value of the AllowOverride for this request
146  * @param r The current request
147  * @return the overrides bitmask
148  */
149 AP_DECLARE(int) ap_allow_overrides(request_rec *r);
150
151 /**
152  * Retrieve the document root for this server
153  * @param r The current request
154  * @warning Don't use this!  If your request went through a Userdir, or 
155  * something like that, it'll screw you.  But it's back-compatible...
156  * @return The document root
157  */
158 AP_DECLARE(const char *) ap_document_root(request_rec *r);
159
160 /**
161  * Lookup the remote client's DNS name or IP address
162  * @ingroup get_remote_host
163  * @param conn The current connection
164  * @param dir_config The directory config vector from the request
165  * @param type The type of lookup to perform.  One of:
166  * <pre>
167  *     REMOTE_HOST returns the hostname, or NULL if the hostname
168  *                 lookup fails.  It will force a DNS lookup according to the
169  *                 HostnameLookups setting.
170  *     REMOTE_NAME returns the hostname, or the dotted quad if the
171  *                 hostname lookup fails.  It will force a DNS lookup according
172  *                 to the HostnameLookups setting.
173  *     REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
174  *                     never forced.
175  *     REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
176  *                   a double reverse lookup, regardless of the HostnameLookups
177  *                   setting.  The result is the (double reverse checked) 
178  *                   hostname, or NULL if any of the lookups fail.
179  * </pre>
180  * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address 
181  *        string is returned
182  * @return The remote hostname
183  */
184 AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip);
185
186 /**
187  * Retrieve the login name of the remote user.  Undef if it could not be
188  * determined
189  * @param r The current request
190  * @return The user logged in to the client machine
191  */
192 AP_DECLARE(const char *) ap_get_remote_logname(request_rec *r);
193
194 /* Used for constructing self-referencing URLs, and things like SERVER_PORT,
195  * and SERVER_NAME.
196  */
197 /**
198  * build a fully qualified URL from the uri and information in the request rec
199  * @param p The pool to allocate the URL from
200  * @param uri The path to the requested file
201  * @param r The current request
202  * @return A fully qualified URL
203  */
204 AP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r);
205
206 /**
207  * Get the current server name from the request
208  * @param r The current request
209  * @return the server name
210  */
211 AP_DECLARE(const char *) ap_get_server_name(request_rec *r);
212
213 /**
214  * Get the current server name from the request for the purposes
215  * of using in a URL.  If the server name is an IPv6 literal
216  * address, it will be returned in URL format (e.g., "[fe80::1]").
217  * @param r The current request
218  * @return the server name
219  */
220 AP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r);
221
222 /**
223  * Get the current server port
224  * @param r The current request
225  * @return The server's port
226  */
227 AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r);
228
229 /**
230  * Return the limit on bytes in request msg body 
231  * @param r The current request
232  * @return the maximum number of bytes in the request msg body
233  */
234 AP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r);
235
236 /**
237  * Return the limit on bytes in XML request msg body
238  * @param r The current request
239  * @return the maximum number of bytes in XML request msg body
240  */
241 AP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r);
242
243 /**
244  * Install a custom response handler for a given status
245  * @param r The current request
246  * @param status The status for which the custom response should be used
247  * @param string The custom response.  This can be a static string, a file
248  *               or a URL
249  */
250 AP_DECLARE(void) ap_custom_response(request_rec *r, int status, const char *string);
251
252 /**
253  * Check if the current request is beyond the configured max. number of redirects or subrequests
254  * @param r The current request
255  * @return true (is exceeded) or false
256  */
257 AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r);
258
259 /**
260  * Check for a definition from the server command line
261  * @param name The define to check for
262  * @return 1 if defined, 0 otherwise
263  */
264 AP_DECLARE(int) ap_exists_config_define(const char *name);
265 /* FIXME! See STATUS about how */
266 AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r);
267
268 /* Authentication stuff.  This is one of the places where compatibility
269  * with the old config files *really* hurts; they don't discriminate at
270  * all between different authentication schemes, meaning that we need
271  * to maintain common state for all of them in the core, and make it
272  * available to the other modules through interfaces.
273  */
274
275 /** @see require_line */
276 typedef struct require_line require_line;
277
278 /** 
279  * @brief A structure to keep track of authorization requirements 
280 */
281 struct require_line {
282     /** Where the require line is in the config file. */
283     apr_int64_t method_mask;
284     /** The complete string from the command line */
285     char *requirement;
286 };
287      
288 /**
289  * Return the type of authorization required for this request
290  * @param r The current request
291  * @return The authorization required
292  */
293 AP_DECLARE(const char *) ap_auth_type(request_rec *r);
294
295 /**
296  * Return the current Authorization realm
297  * @param r The current request
298  * @return The current authorization realm
299  */
300 AP_DECLARE(const char *) ap_auth_name(request_rec *r);     
301
302 /**
303  * How the requires lines must be met.
304  * @param r The current request
305  * @return How the requirements must be met.  One of:
306  * <pre>
307  *      SATISFY_ANY    -- any of the requirements must be met.
308  *      SATISFY_ALL    -- all of the requirements must be met.
309  *      SATISFY_NOSPEC -- There are no applicable satisfy lines
310  * </pre>
311  */
312 AP_DECLARE(int) ap_satisfies(request_rec *r);
313
314 /**
315  * Core is also unlike other modules in being implemented in more than
316  * one file... so, data structures are declared here, even though most of
317  * the code that cares really is in http_core.c.  Also, another accessor.
318  */
319 AP_DECLARE_DATA extern module core_module;
320
321 /**
322  * @brief  Per-request configuration 
323 */
324 typedef struct {
325     /** bucket brigade used by getline for look-ahead and 
326      * ap_get_client_block for holding left-over request body */
327     struct apr_bucket_brigade *bb;
328
329     /** an array of per-request working data elements, accessed
330      * by ID using ap_get_request_note()
331      * (Use ap_register_request_note() during initialization
332      * to add elements)
333      */
334     void **notes;
335
336     /** Custom response strings registered via ap_custom_response(),
337      * or NULL; check per-dir config if nothing found here
338      */
339     char **response_code_strings; /* from ap_custom_response(), not from
340                                    * ErrorDocument
341                                    */
342
343     /** There is a script processor installed on the output filter chain,
344      * so it needs the default_handler to deliver a (script) file into
345      * the chain so it can process it. Normally, default_handler only
346      * serves files on a GET request (assuming the file is actual content),
347      * since other methods are not content-retrieval. This flag overrides
348      * that behavior, stating that the "content" is actually a script and
349      * won't actually be delivered as the response for the non-GET method.
350      */
351     int deliver_script;
352
353     /** Should addition of charset= be suppressed for this request?
354      */
355     int suppress_charset;
356 } core_request_config;
357
358 /* Standard entries that are guaranteed to be accessible via
359  * ap_get_request_note() for each request (additional entries
360  * can be added with ap_register_request_note())
361  */
362 #define AP_NOTE_DIRECTORY_WALK 0
363 #define AP_NOTE_LOCATION_WALK  1
364 #define AP_NOTE_FILE_WALK      2
365 #define AP_NUM_STD_NOTES       3
366
367 /**
368  * Reserve an element in the core_request_config->notes array
369  * for some application-specific data
370  * @return An integer key that can be passed to ap_get_request_note()
371  *         during request processing to access this element for the
372  *         current request.
373  */
374 AP_DECLARE(apr_size_t) ap_register_request_note(void);
375
376 /**
377  * Retrieve a pointer to an element in the core_request_config->notes array
378  * @param r The request
379  * @param note_num  A key for the element: either a value obtained from
380  *        ap_register_request_note() or one of the predefined AP_NOTE_*
381  *        values.
382  * @return NULL if the note_num is invalid, otherwise a pointer to the
383  *         requested note element.
384  * @remark At the start of a request, each note element is NULL.  The
385  *         handle provided by ap_get_request_note() is a pointer-to-pointer
386  *         so that the caller can point the element to some app-specific
387  *         data structure.  The caller should guarantee that any such
388  *         structure will last as long as the request itself.
389  */
390 AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num);
391
392
393 typedef unsigned char allow_options_t;
394 typedef unsigned char overrides_t;
395
396 /*
397  * Bits of info that go into making an ETag for a file
398  * document.  Why a long?  Because char historically
399  * proved too short for Options, and int can be different
400  * sizes on different platforms.
401  */
402 typedef unsigned long etag_components_t;
403
404 #define ETAG_UNSET 0
405 #define ETAG_NONE  (1 << 0)
406 #define ETAG_MTIME (1 << 1)
407 #define ETAG_INODE (1 << 2)
408 #define ETAG_SIZE  (1 << 3)
409 #define ETAG_BACKWARD (ETAG_MTIME | ETAG_INODE | ETAG_SIZE)
410 #define ETAG_ALL   (ETAG_MTIME | ETAG_INODE | ETAG_SIZE)
411
412 /**
413  * @brief Server Signature Enumeration
414  */
415 typedef enum {
416     srv_sig_unset,
417     srv_sig_off,
418     srv_sig_on,
419     srv_sig_withmail
420 } server_signature_e;
421
422 /** 
423  * @brief Per-directory configuration 
424  */
425 typedef struct {
426     /** path of the directory/regex/etc. see also d_is_fnmatch/absolute below */
427     char *d;
428     /** the number of slashes in d */
429     unsigned d_components;
430
431     /** If (opts & OPT_UNSET) then no absolute assignment to options has
432      * been made.
433      * invariant: (opts_add & opts_remove) == 0
434      * Which said another way means that the last relative (options + or -)
435      * assignment made to each bit is recorded in exactly one of opts_add
436      * or opts_remove.
437      */
438     allow_options_t opts;
439     allow_options_t opts_add;
440     allow_options_t opts_remove;
441     overrides_t override;
442     allow_options_t override_opts;
443     
444     /* Custom response config. These can contain text or a URL to redirect to.
445      * if response_code_strings is NULL then there are none in the config,
446      * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
447      * This lets us do quick merges in merge_core_dir_configs().
448      */
449   
450     char **response_code_strings; /* from ErrorDocument, not from
451                                    * ap_custom_response() */
452
453     /* Hostname resolution etc */
454 #define HOSTNAME_LOOKUP_OFF     0
455 #define HOSTNAME_LOOKUP_ON      1
456 #define HOSTNAME_LOOKUP_DOUBLE  2
457 #define HOSTNAME_LOOKUP_UNSET   3
458     unsigned int hostname_lookups : 4;
459
460     unsigned int content_md5 : 2;  /* calculate Content-MD5? */
461
462 #define USE_CANONICAL_NAME_OFF   (0)
463 #define USE_CANONICAL_NAME_ON    (1)
464 #define USE_CANONICAL_NAME_DNS   (2)
465 #define USE_CANONICAL_NAME_UNSET (3)
466     unsigned use_canonical_name : 2;
467
468     /* since is_fnmatch(conf->d) was being called so frequently in
469      * directory_walk() and its relatives, this field was created and
470      * is set to the result of that call.
471      */
472     unsigned d_is_fnmatch : 1;
473
474     /* should we force a charset on any outgoing parameterless content-type?
475      * if so, which charset?
476      */
477 #define ADD_DEFAULT_CHARSET_OFF   (0)
478 #define ADD_DEFAULT_CHARSET_ON    (1)
479 #define ADD_DEFAULT_CHARSET_UNSET (2)
480     unsigned add_default_charset : 2;
481     const char *add_default_charset_name;
482
483     /* System Resource Control */
484 #ifdef RLIMIT_CPU
485     struct rlimit *limit_cpu;
486 #endif
487 #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)
488     struct rlimit *limit_mem;
489 #endif
490 #ifdef RLIMIT_NPROC
491     struct rlimit *limit_nproc;
492 #endif
493     apr_off_t limit_req_body;      /* limit on bytes in request msg body */
494     long limit_xml_body;           /* limit on bytes in XML request msg body */
495
496     /* logging options */
497
498     server_signature_e server_signature;
499
500     /* Access control */
501     apr_array_header_t *sec_file;
502     ap_regex_t *r;
503
504     const char *mime_type;       /* forced with ForceType  */
505     const char *handler;         /* forced with SetHandler */
506     const char *output_filters;  /* forced with SetOutputFilters */
507     const char *input_filters;   /* forced with SetInputFilters */
508     int accept_path_info;        /* forced with AcceptPathInfo */
509
510     /*
511      * What attributes/data should be included in ETag generation?
512      */
513     etag_components_t etag_bits;
514     etag_components_t etag_add;
515     etag_components_t etag_remove;
516
517     /*
518      * Run-time performance tuning
519      */
520 #define ENABLE_MMAP_OFF    (0)
521 #define ENABLE_MMAP_ON     (1)
522 #define ENABLE_MMAP_UNSET  (2)
523     unsigned int enable_mmap : 2;  /* whether files in this dir can be mmap'ed */
524
525 #define ENABLE_SENDFILE_OFF    (0)
526 #define ENABLE_SENDFILE_ON     (1)
527 #define ENABLE_SENDFILE_UNSET  (2)
528     unsigned int enable_sendfile : 2;  /* files in this dir can be sendfile'ed */
529     unsigned int allow_encoded_slashes : 1; /* URLs may contain %2f w/o being
530                                              * pitched indiscriminately */
531
532 #define USE_CANONICAL_PHYS_PORT_OFF   (0)
533 #define USE_CANONICAL_PHYS_PORT_ON    (1)
534 #define USE_CANONICAL_PHYS_PORT_UNSET (2)
535     unsigned use_canonical_phys_port : 2;
536
537     ap_parse_node_t *condition;   /* Conditionally merge <If> sections */
538
539     /** per-dir log config */
540     struct ap_logconf *log;
541 } core_dir_config;
542
543 /* macro to implement off by default behaviour */
544 #define AP_SENDFILE_ENABLED(x) \
545     ((x) == ENABLE_SENDFILE_ON ? APR_SENDFILE_ENABLED : 0)
546
547 /* Per-server core configuration */
548
549 typedef struct {
550   
551     char *gprof_dir;
552
553     /* Name translations --- we want the core to be able to do *something*
554      * so it's at least a minimally functional web server on its own (and
555      * can be tested that way).  But let's keep it to the bare minimum:
556      */
557     const char *ap_document_root;
558   
559     /* Access control */
560
561     char *access_name;
562     apr_array_header_t *sec_dir;
563     apr_array_header_t *sec_url;
564
565     /* recursion backstopper */
566     int redirect_limit; /* maximum number of internal redirects */
567     int subreq_limit;   /* maximum nesting level of subrequests */
568
569     const char *protocol;
570     apr_table_t *accf_map;
571
572     /* array of ap_errorlog_format_item for error log format string */
573     apr_array_header_t *error_log_format;
574     /*
575      * two arrays of arrays of ap_errorlog_format_item for additional information
576      * logged to the error log once per connection/request
577      */
578     apr_array_header_t *error_log_conn;
579     apr_array_header_t *error_log_req;
580
581     /* TRACE control */
582 #define AP_TRACE_UNSET    -1
583 #define AP_TRACE_DISABLE   0
584 #define AP_TRACE_ENABLE    1
585 #define AP_TRACE_EXTENDED  2
586     int trace_enable;
587
588 } core_server_config;
589
590 /* for AddOutputFiltersByType in core.c */
591 void ap_add_output_filters_by_type(request_rec *r);
592
593 /* for http_config.c */
594 void ap_core_reorder_directories(apr_pool_t *, server_rec *);
595
596 /* for mod_perl */
597 AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config);
598 AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config);
599 AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
600 AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);
601
602 /* Core filters; not exported. */
603 int ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
604                          ap_input_mode_t mode, apr_read_type_e block,
605                          apr_off_t readbytes);
606 apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *b);
607
608
609 AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s);
610 AP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto);
611
612 /* ----------------------------------------------------------------------
613  *
614  * Runtime status/management
615  */
616
617 typedef enum {
618     ap_mgmt_type_string,
619     ap_mgmt_type_long,
620     ap_mgmt_type_hash
621 } ap_mgmt_type_e;
622
623 typedef union {
624     const char *s_value;
625     long i_value;
626     apr_hash_t *h_value;
627 } ap_mgmt_value;
628
629 typedef struct {
630     const char *description;
631     const char *name;
632     ap_mgmt_type_e vtype;
633     ap_mgmt_value v;
634 } ap_mgmt_item_t;
635
636 /* Handles for core filters */
637 extern AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
638 extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
639 extern AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
640 extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;
641
642 /**
643  * This hook provdes a way for modules to provide metrics/statistics about
644  * their operational status.
645  *
646  * @param p A pool to use to create entries in the hash table
647  * @param val The name of the parameter(s) that is wanted. This is
648  *            tree-structured would be in the form ('*' is all the tree,
649  *            'module.*' all of the module , 'module.foo.*', or
650  *            'module.foo.bar' )
651  * @param ht The hash table to store the results. Keys are item names, and
652  *           the values point to ap_mgmt_item_t structures.
653  * @ingroup hooks
654  */
655 AP_DECLARE_HOOK(int, get_mgmt_items,
656                 (apr_pool_t *p, const char * val, apr_hash_t *ht))
657
658 /* ---------------------------------------------------------------------- */
659
660 /* ----------------------------------------------------------------------
661  *
662  * I/O logging with mod_logio
663  */
664
665 APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out,
666                         (conn_rec *c, apr_off_t bytes));
667
668 APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_in,
669                         (conn_rec *c, apr_off_t bytes));
670
671 APR_DECLARE_OPTIONAL_FN(apr_off_t, ap_logio_get_last_bytes, (conn_rec *c));
672
673 /* ----------------------------------------------------------------------
674  *
675  * Error log formats
676  */
677
678 /**
679  * info structure passed to callback functions of errorlog handlers
680  */
681 typedef struct ap_errorlog_info {
682     const server_rec *s;
683     const conn_rec *c;
684     const request_rec *r;
685     const request_rec *rmain;
686     const char *file;
687     int line;
688     int module_index;
689     int level;
690     apr_status_t status;
691     int using_syslog;
692     int startup;
693 } ap_errorlog_info;
694
695 /**
696  * callback function prototype for a external errorlog handler
697  * @note To avoid unbounded memory usage, these functions must not allocate
698  * memory from the server, connection, or request pools. If an errorlog
699  * handler absolutely needs a pool to pass to other functions, it must create
700  * and destroy a sub-pool.
701  */
702 typedef int ap_errorlog_handler_fn_t(const ap_errorlog_info *info,
703                                      const char *arg, char *buf, int buflen);
704
705 /**
706  * Register external errorlog handler
707  * @param p config pool to use
708  * @param tag the new format specifier (i.e. the letter after the %)
709  * @param handler the handler function
710  * @param flags flags (reserved, set to 0)
711  */
712 AP_DECLARE(void) ap_register_errorlog_handler(apr_pool_t *p, char *tag,
713                                               ap_errorlog_handler_fn_t *handler,
714                                               int flags);
715
716 typedef struct ap_errorlog_handler {
717     ap_errorlog_handler_fn_t *func;
718     int flags;
719 } ap_errorlog_handler;
720
721 typedef struct {
722     ap_errorlog_handler_fn_t *func;
723     const char *arg;
724 #define AP_ERRORLOG_FLAG_FIELD_SEP       1
725 #define AP_ERRORLOG_FLAG_MESSAGE         2
726 #define AP_ERRORLOG_FLAG_REQUIRED        4
727 #define AP_ERRORLOG_FLAG_NULL_AS_HYPHEN  8
728     unsigned int flags;
729 } ap_errorlog_format_item;
730
731 AP_DECLARE(void) ap_register_builtin_errorlog_handlers(apr_pool_t *p);
732
733 /* ----------------------------------------------------------------------
734  *
735  * ident lookups with mod_ident
736  */
737
738 APR_DECLARE_OPTIONAL_FN(const char *, ap_ident_lookup,
739                         (request_rec *r));
740
741 /* ----------------------------------------------------------------------
742  *
743  * authorization values with mod_authz_core
744  */
745
746 APR_DECLARE_OPTIONAL_FN(int, authz_some_auth_required, (request_rec *r));
747 APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_type, (request_rec *r));
748 APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_name, (request_rec *r));
749
750 /* ----------------------------------------------------------------------
751  *
752  * authorization values with mod_access_compat
753  */
754
755 APR_DECLARE_OPTIONAL_FN(int, access_compat_ap_satisfies, (request_rec *r));
756
757 /* ---------------------------------------------------------------------- */
758
759 #ifdef __cplusplus
760 }
761 #endif
762
763 #endif  /* !APACHE_HTTP_CORE_H */
764 /** @} */