1 /*
2  * Portability wrapper around Apache headers.
3  *
4  * This header includes the following Apache headers:
5  *
6  *     #include <httpd_h>
7  *     #include <http_config.h>
8  *     #include <http_core.h>
9  *     #include <http_log.h>
10  *     #include <http_protocol.h>
11  *     #include <http_request.h>
12  *     #include <unixd.h>
13  *
14  * and then attempts to adjust for older versions of Apache 2.x.  One will
15  * generally want to include config-mod.h instead of config.h before this
16  * header, since config.h normally defines PACKAGE_* symbols that will
17  * conflict with Apache's defines.
18  *
19  * The canonical version of this file is maintained in the rra-c-util package,
20  * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
21  *
22  * Written by Russ Allbery <eagle@eyrie.org>
23  *
24  * The authors hereby relinquish any claim to any copyright that they may have
25  * in this work, whether granted under contract or by operation of law or
26  * international treaty, and hereby commit to the public, at large, that they
27  * shall not, at any time in the future, seek to enforce any copyright in this
28  * work against any person or entity, or prevent any person or entity from
29  * copying, publishing, distributing or creating derivative works of this
30  * work.
31  */
32 
33 #ifndef PORTABLE_APACHE_H
34 #define PORTABLE_APACHE_H 1
35 
36 /*
37  * Allow inclusion of config.h to be skipped, since sometimes we have to use a
38  * stripped-down version of config.h with a different name.
39  */
40 #ifndef CONFIG_H_INCLUDED
41 # include <config.h>
42 #endif
43 
44 /*
45  * Automake always defines this, which causes Heimdal to pull in its config.h
46  * and leak Autoconf definitions into the package namespace, which in turn
47  * conflicts with Apache's own definitions.  Undefine it to work around that
48  * problem.
49  *
50  * Arguably, this should be in portable/krb5.h, since the problem is actually
51  * in the Heimdal headers, but it only poses problems when using the Apache
52  * includes, which also leak the package defines.
53  */
54 #undef HAVE_CONFIG_H
55 
56 #include <httpd.h>
57 #include <http_config.h>
58 #include <http_core.h>
59 #include <http_log.h>
60 #include <http_protocol.h>
61 #include <http_request.h>
62 #include <unixd.h>
63 
64 /* Apache 2.0 did not have ap_get_server_description. */
65 #if !HAVE_DECL_AP_GET_SERVER_DESCRIPTION
66 # define ap_get_server_description() ap_get_server_version()
67 #endif
68 
69 /* Apache 2.2 renamed the incorrect ap_http_method to ap_http_scheme. */
70 #ifndef ap_http_scheme
71 # define ap_http_scheme(r) ap_http_method(r)
72 #endif
73 
74 /*
75  * Apache 2.2 and earlier used check_user_id instead of check_authn, which
76  * doesn't take the final flag saying whether to do checks per URI.
77  */
78 #if !HAVE_DECL_AP_HOOK_CHECK_AUTHN
79 # define ap_hook_check_authn(f, b, a, o, t) \
80     ap_hook_check_user_id((f), (b), (a), (o))
81 #endif
82 
83 /* The useragent_ip request member is new in Apache 2.4. */
84 #if !HAVE_REQUEST_REC_USERAGENT_IP
85 # define useragent_ip connection->remote_ip
86 #endif
87 
88 /* Apache 2.4 renamed this to stay in the ap_* namespace. */
89 #if !HAVE_DECL_AP_UNIXD_CONFIG
90 # define ap_unixd_config unixd_config
91 #endif
92 
93 /*
94  * This macro was added in Apache 2.4.  It declares both the per-module
95  * logging data and the module data struct.  In earlier versions, declare the
96  * data struct so that we can rely on it being declared for other purposes.
97  */
98 #ifndef APLOG_USE_MODULE
99 # define APLOG_USE_MODULE(foo) \
100     extern module AP_MODULE_DECLARE_DATA foo##_module;
101 #endif
102 
103 /*
104  * Apache 2.4 introduced granular levels of trace logging.  For older
105  * versions, collapse them all into APLOG_DEBUG.
106  */
107 #ifndef APLOG_TRACE1
108 # define APLOG_TRACE1 APLOG_DEBUG
109 # define APLOG_TRACE2 APLOG_DEBUG
110 # define APLOG_TRACE3 APLOG_DEBUG
111 # define APLOG_TRACE4 APLOG_DEBUG
112 # define APLOG_TRACE5 APLOG_DEBUG
113 # define APLOG_TRACE6 APLOG_DEBUG
114 # define APLOG_TRACE7 APLOG_DEBUG
115 # define APLOG_TRACE8 APLOG_DEBUG
116 #endif
117 
118 #endif /* !PORTABLE_APACHE_H */
119