52 #ifdef APR_HOOK_PROBES_ENABLED
53 #define APR_HOOK_INT_DCL_UD void *ud = NULL
58 #define APR_HOOK_INT_DCL_UD
69 #define APR_HOOK_PROBE_ENTRY(ud,ns,name,args)
81 #define APR_HOOK_PROBE_RETURN(ud,ns,name,rv,args)
94 #define APR_HOOK_PROBE_INVOKE(ud,ns,name,src,args)
108 #define APR_HOOK_PROBE_COMPLETE(ud,ns,name,src,rv,args)
114 #define APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \
115 link##_DECLARE(apr_array_header_t *) ns##_hook_get_##name(void)
118 #define APR_DECLARE_EXTERNAL_HOOK(ns,link,ret,name,args) \
119 typedef ret ns##_HOOK_##name##_t args; \
120 link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf, \
121 const char * const *aszPre, \
122 const char * const *aszSucc, int nOrder); \
123 link##_DECLARE(ret) ns##_run_##name args; \
124 APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name); \
125 typedef struct ns##_LINK_##name##_t \
127 ns##_HOOK_##name##_t *pFunc; \
128 const char *szName; \
129 const char * const *aszPredecessors; \
130 const char * const *aszSuccessors; \
132 } ns##_LINK_##name##_t;
135 #define APR_HOOK_STRUCT(members) \
136 static struct { members } _hooks;
139 #define APR_HOOK_LINK(name) \
140 apr_array_header_t *link_##name;
143 #define APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \
144 link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf,const char * const *aszPre, \
145 const char * const *aszSucc,int nOrder) \
147 ns##_LINK_##name##_t *pHook; \
148 if(!_hooks.link_##name) \
150 _hooks.link_##name=apr_array_make(apr_hook_global_pool,1,sizeof(ns##_LINK_##name##_t)); \
151 apr_hook_sort_register(#name,&_hooks.link_##name); \
153 pHook=apr_array_push(_hooks.link_##name); \
155 pHook->aszPredecessors=aszPre; \
156 pHook->aszSuccessors=aszSucc; \
157 pHook->nOrder=nOrder; \
158 pHook->szName=apr_hook_debug_current; \
159 if(apr_hook_debug_enabled) \
160 apr_hook_debug_show(#name,aszPre,aszSucc); \
162 APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \
164 return _hooks.link_##name; \
179 #define APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ns,link,name,args_decl,args_use) \
180 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \
181 link##_DECLARE(void) ns##_run_##name args_decl \
183 ns##_LINK_##name##_t *pHook; \
185 APR_HOOK_INT_DCL_UD; \
187 APR_HOOK_PROBE_ENTRY(ud, ns, name, args_use); \
189 if(_hooks.link_##name) \
191 pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \
192 for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \
194 APR_HOOK_PROBE_INVOKE(ud, ns, name, (char *)pHook[n].szName, args_use); \
195 pHook[n].pFunc args_use; \
196 APR_HOOK_PROBE_COMPLETE(ud, ns, name, (char *)pHook[n].szName, 0, args_use); \
200 APR_HOOK_PROBE_RETURN(ud, ns, name, 0, args_use); \
222 #define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \
223 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \
224 link##_DECLARE(ret) ns##_run_##name args_decl \
226 ns##_LINK_##name##_t *pHook; \
229 APR_HOOK_INT_DCL_UD; \
231 APR_HOOK_PROBE_ENTRY(ud, ns, name, args_use); \
233 if(_hooks.link_##name) \
235 pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \
236 for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \
238 APR_HOOK_PROBE_INVOKE(ud, ns, name, (char *)pHook[n].szName, args_use); \
239 rv=pHook[n].pFunc args_use; \
240 APR_HOOK_PROBE_COMPLETE(ud, ns, name, (char *)pHook[n].szName, rv, args_use); \
241 if(rv != ok && rv != decline) \
247 APR_HOOK_PROBE_RETURN(ud, ns, name, rv, args_use); \
267 #define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ns,link,ret,name,args_decl,args_use,decline) \
268 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \
269 link##_DECLARE(ret) ns##_run_##name args_decl \
271 ns##_LINK_##name##_t *pHook; \
274 APR_HOOK_INT_DCL_UD; \
276 APR_HOOK_PROBE_ENTRY(ud, ns, name, args_use); \
278 if(_hooks.link_##name) \
280 pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \
281 for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \
283 APR_HOOK_PROBE_INVOKE(ud, ns, name, (char *)pHook[n].szName, args_use); \
284 rv=pHook[n].pFunc args_use; \
285 APR_HOOK_PROBE_COMPLETE(ud, ns, name, (char *)pHook[n].szName, rv, args_use); \
292 APR_HOOK_PROBE_RETURN(ud, ns, name, rv, args_use); \
299 #define APR_HOOK_REALLY_FIRST (-10)
301 #define APR_HOOK_FIRST 0
303 #define APR_HOOK_MIDDLE 10
305 #define APR_HOOK_LAST 20
307 #define APR_HOOK_REALLY_LAST 30
345 const char *
const *aszPre,
346 const char *
const *aszSucc);
void apr_hook_sort_register(const char *szHookName, apr_array_header_t **aHooks)
void apr_hook_debug_show(const char *szName, const char *const *aszPre, const char *const *aszSucc)
void apr_hook_sort_all(void)
APR_DECLARE_DATA int apr_hook_debug_enabled
void apr_hook_deregister_all(void)
APR_DECLARE_DATA apr_pool_t * apr_hook_global_pool
APR_DECLARE_DATA const char * apr_hook_debug_current
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
#define APR_DECLARE_DATA
Definition: macros.h:17
#define APR_DECLARE(x)
Definition: macros.h:6