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 ap hook functions and macros
25 /* Although this file doesn't declare any hooks, declare the hook group here */
27 * @defgroup hooks Apache Hooks
28 * @ingroup APACHE_CORE
31 #if defined(AP_HOOK_PROBES_ENABLED) && !defined(APR_HOOK_PROBES_ENABLED)
32 #define APR_HOOK_PROBES_ENABLED 1
35 #ifdef APR_HOOK_PROBES_ENABLED
36 #include "ap_hook_probes.h"
40 #include "apr_hooks.h"
41 #include "apr_optional_hooks.h"
44 /* define these just so doxygen documents them */
47 * AP_DECLARE_STATIC is defined when including Apache's Core headers,
48 * to provide static linkage when the dynamic library may be unavailable.
50 * @see AP_DECLARE_EXPORT
52 * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
53 * including Apache's Core headers, to import and link the symbols from the
54 * dynamic Apache Core library and assure appropriate indirection and calling
55 * conventions at compile time.
57 # define AP_DECLARE_STATIC
59 * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
60 * library, so that all public symbols are exported.
62 * @see AP_DECLARE_STATIC
64 # define AP_DECLARE_EXPORT
66 #endif /* def DOXYGEN */
69 * Declare a hook function
70 * @param ret The return type of the hook
71 * @param name The hook's name (as a literal)
72 * @param args The arguments the hook function takes, in brackets.
74 #define AP_DECLARE_HOOK(ret,name,args) \
75 APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args)
78 #define AP_IMPLEMENT_HOOK_BASE(name) \
79 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name)
82 * Implement an Apache core hook that has no return code, and
83 * therefore runs all of the registered functions. The implementation
84 * is called ap_run_<i>name</i>.
86 * @param name The name of the hook
87 * @param args_decl The declaration of the arguments for the hook, for example
89 * @param args_use The arguments for the hook as used in a call, for example
91 * @note If IMPLEMENTing a hook that is not linked into the Apache core,
92 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID.
94 #define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
95 APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use)
98 * Implement an Apache core hook that runs until one of the functions
99 * returns something other than ok or decline. That return value is
100 * then returned from the hook runner. If the hooks run to completion,
101 * then ok is returned. Note that if no hook runs it would probably be
102 * more correct to return decline, but this currently does not do
103 * so. The implementation is called ap_run_<i>name</i>.
105 * @param ret The return type of the hook (and the hook runner)
106 * @param name The name of the hook
107 * @param args_decl The declaration of the arguments for the hook, for example
109 * @param args_use The arguments for the hook as used in a call, for example
111 * @param ok The "ok" return value
112 * @param decline The "decline" return value
113 * @return ok, decline or an error.
114 * @note If IMPLEMENTing a hook that is not linked into the Apache core,
115 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL.
117 #define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
118 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
122 * Implement a hook that runs until a function returns something other than
123 * decline. If all functions return decline, the hook runner returns decline.
124 * The implementation is called ap_run_<i>name</i>.
126 * @param ret The return type of the hook (and the hook runner)
127 * @param name The name of the hook
128 * @param args_decl The declaration of the arguments for the hook, for example
130 * @param args_use The arguments for the hook as used in a call, for example
132 * @param decline The "decline" return value
133 * @return decline or an error.
134 * @note If IMPLEMENTing a hook that is not linked into the Apache core
135 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST.
137 #define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
138 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
141 /* Note that the other optional hook implementations are straightforward but
142 * have not yet been needed
146 * Implement an optional hook. This is exactly the same as a standard hook
147 * implementation, except the hook is optional.
148 * @see AP_IMPLEMENT_HOOK_RUN_ALL
150 #define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \
152 APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
156 * Hook an optional hook. Unlike static hooks, this uses a macro instead of a
159 #define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \
160 APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order)
162 #endif /* AP_HOOKS_H */