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.
21 #include "apr_hooks.h"
22 #include "apr_optional_hooks.h"
26 * @brief Symbol export macros and hook functions
29 /* Although this file doesn't declare any hooks, declare the hook group here */
30 /** @defgroup hooks Apache Hooks */
33 /* define these just so doxygen documents them */
36 * AP_DECLARE_STATIC is defined when including Apache's Core headers,
37 * to provide static linkage when the dynamic library may be unavailable.
39 * @see AP_DECLARE_EXPORT
41 * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
42 * including Apache's Core headers, to import and link the symbols from the
43 * dynamic Apache Core library and assure appropriate indirection and calling
44 * conventions at compile time.
46 # define AP_DECLARE_STATIC
48 * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
49 * library, so that all public symbols are exported.
51 * @see AP_DECLARE_STATIC
53 # define AP_DECLARE_EXPORT
55 #endif /* def DOXYGEN */
59 * Apache Core dso functions are declared with AP_DECLARE(), so they may
60 * use the most appropriate calling convention. Hook functions and other
61 * Core functions with variable arguments must use AP_DECLARE_NONSTD().
63 * AP_DECLARE(rettype) ap_func(args)
66 #define AP_DECLARE(type) type
69 * Apache Core dso variable argument and hook functions are declared with
70 * AP_DECLARE_NONSTD(), as they must use the C language calling convention.
73 * AP_DECLARE_NONSTD(rettype) ap_func(args [...])
76 #define AP_DECLARE_NONSTD(type) type
79 * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA.
80 * This assures the appropriate indirection is invoked at compile time.
82 * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for
83 * declarations within headers to properly import the variable.
85 * AP_DECLARE_DATA type apr_variable
88 #define AP_DECLARE_DATA
90 #elif defined(AP_DECLARE_STATIC)
91 #define AP_DECLARE(type) type __stdcall
92 #define AP_DECLARE_NONSTD(type) type
93 #define AP_DECLARE_DATA
94 #elif defined(AP_DECLARE_EXPORT)
95 #define AP_DECLARE(type) __declspec(dllexport) type __stdcall
96 #define AP_DECLARE_NONSTD(type) __declspec(dllexport) type
97 #define AP_DECLARE_DATA __declspec(dllexport)
99 #define AP_DECLARE(type) __declspec(dllimport) type __stdcall
100 #define AP_DECLARE_NONSTD(type) __declspec(dllimport) type
101 #define AP_DECLARE_DATA __declspec(dllimport)
104 #if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC)
106 * Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA.
108 * Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols
109 * declared with AP_MODULE_DECLARE_DATA are always exported.
111 * module AP_MODULE_DECLARE_DATA mod_tag
115 #define AP_MODULE_DECLARE(type) type __stdcall
117 #define AP_MODULE_DECLARE(type) type
119 #define AP_MODULE_DECLARE_NONSTD(type) type
120 #define AP_MODULE_DECLARE_DATA
123 * AP_MODULE_DECLARE_EXPORT is a no-op. Unless contradicted by the
124 * AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined.
126 * The old SHARED_MODULE compile-time symbol is now the default behavior,
127 * so it is no longer referenced anywhere with Apache 2.0.
129 #define AP_MODULE_DECLARE_EXPORT
130 #define AP_MODULE_DECLARE(type) __declspec(dllexport) type __stdcall
131 #define AP_MODULE_DECLARE_NONSTD(type) __declspec(dllexport) type
132 #define AP_MODULE_DECLARE_DATA __declspec(dllexport)
136 * Declare a hook function
137 * @param ret The return type of the hook
138 * @param name The hook's name (as a literal)
139 * @param args The arguments the hook function takes, in brackets.
141 #define AP_DECLARE_HOOK(ret,name,args) \
142 APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args)
145 #define AP_IMPLEMENT_HOOK_BASE(name) \
146 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name)
149 * Implement an Apache core hook that has no return code, and
150 * therefore runs all of the registered functions. The implementation
151 * is called ap_run_<i>name</i>.
153 * @param name The name of the hook
154 * @param args_decl The declaration of the arguments for the hook, for example
156 * @param args_use The arguments for the hook as used in a call, for example
158 * @note If IMPLEMENTing a hook that is not linked into the Apache core,
159 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID.
161 #define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
162 APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use)
165 * Implement an Apache core hook that runs until one of the functions
166 * returns something other than ok or decline. That return value is
167 * then returned from the hook runner. If the hooks run to completion,
168 * then ok is returned. Note that if no hook runs it would probably be
169 * more correct to return decline, but this currently does not do
170 * so. The implementation is called ap_run_<i>name</i>.
172 * @param ret The return type of the hook (and the hook runner)
173 * @param name The name of the hook
174 * @param args_decl The declaration of the arguments for the hook, for example
176 * @param args_use The arguments for the hook as used in a call, for example
178 * @param ok The "ok" return value
179 * @param decline The "decline" return value
180 * @return ok, decline or an error.
181 * @note If IMPLEMENTing a hook that is not linked into the Apache core,
182 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL.
184 #define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
185 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
189 * Implement a hook that runs until a function returns something other than
190 * decline. If all functions return decline, the hook runner returns decline.
191 * The implementation is called ap_run_<i>name</i>.
193 * @param ret The return type of the hook (and the hook runner)
194 * @param name The name of the hook
195 * @param args_decl The declaration of the arguments for the hook, for example
197 * @param args_use The arguments for the hook as used in a call, for example
199 * @param decline The "decline" return value
200 * @return decline or an error.
201 * @note If IMPLEMENTing a hook that is not linked into the Apache core
202 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST.
204 #define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
205 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
208 /* Note that the other optional hook implementations are straightforward but
209 * have not yet been needed
213 * Implement an optional hook. This is exactly the same as a standard hook
214 * implementation, except the hook is optional.
215 * @see AP_IMPLEMENT_HOOK_RUN_ALL
217 #define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \
219 APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
223 * Hook an optional hook. Unlike static hooks, this uses a macro instead of a
226 #define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \
227 APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order)
230 #if !defined(WIN32) && !defined(NETWARE)
231 #include "ap_config_auto.h"
232 #include "ap_config_layout.h"
235 #define AP_NONBLOCK_WHEN_MULTI_LISTEN 1
238 /* TODO - We need to put OS detection back to make all the following work */
240 #if defined(SUNOS4) || defined(IRIX) || defined(NEXT) || defined(AUX3) \
241 || defined (UW) || defined(LYNXOS) || defined(TPF)
242 /* These systems don't do well with any lingering close code; I don't know
247 /* If APR has OTHER_CHILD logic, use reliable piped logs. */
248 #if APR_HAS_OTHER_CHILD
249 #define AP_HAVE_RELIABLE_PIPED_LOGS TRUE
252 #if APR_CHARSET_EBCDIC && !defined(APACHE_XLATE)
256 #endif /* AP_CONFIG_H */