00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00022 #ifndef APR_OPTIONAL_HOOK_H
00023 #define APR_OPTIONAL_HOOK_H
00024
00025 #include "apr_tables.h"
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00048 APU_DECLARE(void) apr_optional_hook_add(const char *szName,void (*pfn)(void),
00049 const char * const *aszPre,
00050 const char * const *aszSucc,
00051 int nOrder);
00052
00064 #define APR_OPTIONAL_HOOK(ns,name,pfn,aszPre,aszSucc,nOrder) do { \
00065 ns##_HOOK_##name##_t *apu__hook = pfn; \
00066 apr_optional_hook_add(#name,(void (*)(void))apu__hook,aszPre, aszSucc, nOrder); \
00067 } while (0)
00068
00074 APU_DECLARE(apr_array_header_t *) apr_optional_hook_get(const char *szName);
00075
00090 #define APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \
00091 link##_DECLARE(ret) ns##_run_##name args_decl \
00092 { \
00093 ns##_LINK_##name##_t *pHook; \
00094 int n; \
00095 ret rv; \
00096 apr_array_header_t *pHookArray=apr_optional_hook_get(#name); \
00097 \
00098 if(!pHookArray) \
00099 return ok; \
00100 \
00101 pHook=(ns##_LINK_##name##_t *)pHookArray->elts; \
00102 for(n=0 ; n < pHookArray->nelts ; ++n) \
00103 { \
00104 rv=(pHook[n].pFunc)args_use; \
00105 \
00106 if(rv != ok && rv != decline) \
00107 return rv; \
00108 } \
00109 return ok; \
00110 }
00111
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116
00117 #endif