1
{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* 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.
18
#include "apr_hooks.h"
19
#include "apr_optional_hooks.h"}
23
* @brief Symbol export macros and hook functions
26
{ Although this file doesn't declare any hooks, declare the hook group here }
27
{ @defgroup hooks Apache Hooks }
30
{ define these just so doxygen documents them }
33
* AP_DECLARE_STATIC is defined when including Apache's Core headers,
34
* to provide static linkage when the dynamic library may be unavailable.
36
* @see AP_DECLARE_EXPORT
38
* AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
39
* including Apache's Core headers, to import and link the symbols from the
40
* dynamic Apache Core library and assure appropriate indirection and calling
41
* conventions at compile time.
43
{$define AP_DECLARE_STATIC}
45
* AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
46
* library, so that all public symbols are exported.
48
* @see AP_DECLARE_STATIC
50
{$define AP_DECLARE_EXPORT}
52
{$endif} { def DOXYGEN }
56
* Apache Core dso functions are declared with AP_DECLARE(), so they may
57
* use the most appropriate calling convention. Hook functions and other
58
* Core functions with variable arguments must use AP_DECLARE_NONSTD().
60
* AP_DECLARE(rettype) ap_func(args)
63
//#define AP_DECLARE(type) type
66
* Apache Core dso variable argument and hook functions are declared with
67
* AP_DECLARE_NONSTD(), as they must use the C language calling convention.
70
* AP_DECLARE_NONSTD(rettype) ap_func(args [...])
73
//#define AP_DECLARE_NONSTD(type) type
76
* Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA.
77
* This assures the appropriate indirection is invoked at compile time.
79
* @note AP_DECLARE_DATA extern type apr_variable; syntax is required for
80
* declarations within headers to properly import the variable.
82
* AP_DECLARE_DATA type apr_variable
85
{#define AP_DECLARE_DATA
87
#elif defined(AP_DECLARE_STATIC)
88
#define AP_DECLARE(type) type __stdcall
89
#define AP_DECLARE_NONSTD(type) type
90
#define AP_DECLARE_DATA
91
#elif defined(AP_DECLARE_EXPORT)
92
#define AP_DECLARE(type) __declspec(dllexport) type __stdcall
93
#define AP_DECLARE_NONSTD(type) __declspec(dllexport) type
94
#define AP_DECLARE_DATA __declspec(dllexport)
96
#define AP_DECLARE(type) __declspec(dllimport) type __stdcall
97
#define AP_DECLARE_NONSTD(type) __declspec(dllimport) type
98
#define AP_DECLARE_DATA __declspec(dllimport)
101
#if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC)}
103
* Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA.
105
* Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols
106
* declared with AP_MODULE_DECLARE_DATA are always exported.
108
* module AP_MODULE_DECLARE_DATA mod_tag
112
#define AP_MODULE_DECLARE(type) type __stdcall
114
#define AP_MODULE_DECLARE(type) type
116
#define AP_MODULE_DECLARE_NONSTD(type) type
117
#define AP_MODULE_DECLARE_DATA
120
* AP_MODULE_DECLARE_EXPORT is a no-op. Unless contradicted by the
121
* AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined.
123
* The old SHARED_MODULE compile-time symbol is now the default behavior,
124
* so it is no longer referenced anywhere with Apache 2.0.
126
{#define AP_MODULE_DECLARE_EXPORT
127
#define AP_MODULE_DECLARE(type) __declspec(dllexport) type __stdcall
128
#define AP_MODULE_DECLARE_NONSTD(type) __declspec(dllexport) type
129
#define AP_MODULE_DECLARE_DATA __declspec(dllexport)
133
* Declare a hook function
134
* @param ret The return type of the hook
135
* @param name The hook's name (as a literal)
136
* @param args The arguments the hook function takes, in brackets.
138
{#define AP_DECLARE_HOOK(ret,name,args) \
139
APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args)
142
{#define AP_IMPLEMENT_HOOK_BASE(name) \
143
APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name)
146
* Implement an Apache core hook that has no return code, and
147
* therefore runs all of the registered functions. The implementation
148
* is called ap_run_<i>name</i>.
150
* @param name The name of the hook
151
* @param args_decl The declaration of the arguments for the hook, for example
153
* @param args_use The arguments for the hook as used in a call, for example
155
* @note If IMPLEMENTing a hook that is not linked into the Apache core,
156
* (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID.
158
{#define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
159
APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use)
162
* Implement an Apache core hook that runs until one of the functions
163
* returns something other than ok or decline. That return value is
164
* then returned from the hook runner. If the hooks run to completion,
165
* then ok is returned. Note that if no hook runs it would probably be
166
* more correct to return decline, but this currently does not do
167
* so. The implementation is called ap_run_<i>name</i>.
169
* @param ret The return type of the hook (and the hook runner)
170
* @param name The name of the hook
171
* @param args_decl The declaration of the arguments for the hook, for example
173
* @param args_use The arguments for the hook as used in a call, for example
175
* @param ok The "ok" return value
176
* @param decline The "decline" return value
177
* @return ok, decline or an error.
178
* @note If IMPLEMENTing a hook that is not linked into the Apache core,
179
* (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL.
181
{#define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
182
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
186
* Implement a hook that runs until a function returns something other than
187
* decline. If all functions return decline, the hook runner returns decline.
188
* The implementation is called ap_run_<i>name</i>.
190
* @param ret The return type of the hook (and the hook runner)
191
* @param name The name of the hook
192
* @param args_decl The declaration of the arguments for the hook, for example
194
* @param args_use The arguments for the hook as used in a call, for example
196
* @param decline The "decline" return value
197
* @return decline or an error.
198
* @note If IMPLEMENTing a hook that is not linked into the Apache core
199
* (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST.
201
{#define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
202
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
205
{ Note that the other optional hook implementations are straightforward but
206
* have not yet been needed
210
* Implement an optional hook. This is exactly the same as a standard hook
211
* implementation, except the hook is optional.
212
* @see AP_IMPLEMENT_HOOK_RUN_ALL
214
{#define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \
216
APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
220
* Hook an optional hook. Unlike static hooks, this uses a macro instead of a
223
{#define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \
224
APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order)
227
#if !defined(WIN32) && !defined(NETWARE)
228
#include "ap_config_auto.h"
229
#include "ap_config_layout.h"
232
#define AP_NONBLOCK_WHEN_MULTI_LISTEN 1
235
{ TODO - We need to put OS detection back to make all the following work }
237
{$if defined(SUNOS) or defined(IRIX) or defined(NEXT) or defined(AUX)
238
or defined (UW) or defined(LYNXOS) or defined(TPF)}
239
{ These systems don't do well with any lingering close code; I don't know
241
{$define NO_LINGCLOSE}
244
{ If APR has OTHER_CHILD logic, use reliable piped logs. }
245
{$ifdef APR_HAS_OTHER_CHILD}
246
{$define AP_HAVE_RELIABLE_PIPED_LOGS}