Main Page | Modules | Namespace List | Data Structures | File List | Data Fields | Globals | Related Pages

/home/cooker/rebuild/rpm/BUILD/apr-util-0.9.4/include/apr_hooks.h

Go to the documentation of this file.
00001 /* Copyright 2000-2004 The Apache Software Foundation 00002 * 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 */ 00015 00016 #ifndef APR_HOOKS_H 00017 #define APR_HOOKS_H 00018 00019 #include "apu.h" 00020 /* For apr_array_header_t */ 00021 #include "apr_tables.h" 00022 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00037 #define APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \ 00038 link##_DECLARE(apr_array_header_t *) ns##_hook_get_##name(void) 00039 00041 #define APR_DECLARE_EXTERNAL_HOOK(ns,link,ret,name,args) \ 00042 typedef ret ns##_HOOK_##name##_t args; \ 00043 link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf, \ 00044 const char * const *aszPre, \ 00045 const char * const *aszSucc, int nOrder); \ 00046 link##_DECLARE(ret) ns##_run_##name args; \ 00047 APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name); \ 00048 typedef struct ns##_LINK_##name##_t \ 00049 { \ 00050 ns##_HOOK_##name##_t *pFunc; \ 00051 const char *szName; \ 00052 const char * const *aszPredecessors; \ 00053 const char * const *aszSuccessors; \ 00054 int nOrder; \ 00055 } ns##_LINK_##name##_t; 00056 00058 #define APR_HOOK_STRUCT(members) \ 00059 static struct { members } _hooks; 00060 00062 #define APR_HOOK_LINK(name) \ 00063 apr_array_header_t *link_##name; 00064 00066 #define APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ 00067 link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf,const char * const *aszPre, \ 00068 const char * const *aszSucc,int nOrder) \ 00069 { \ 00070 ns##_LINK_##name##_t *pHook; \ 00071 if(!_hooks.link_##name) \ 00072 { \ 00073 _hooks.link_##name=apr_array_make(apr_hook_global_pool,1,sizeof(ns##_LINK_##name##_t)); \ 00074 apr_hook_sort_register(#name,&_hooks.link_##name); \ 00075 } \ 00076 pHook=apr_array_push(_hooks.link_##name); \ 00077 pHook->pFunc=pf; \ 00078 pHook->aszPredecessors=aszPre; \ 00079 pHook->aszSuccessors=aszSucc; \ 00080 pHook->nOrder=nOrder; \ 00081 pHook->szName=apr_hook_debug_current; \ 00082 if(apr_hook_debug_enabled) \ 00083 apr_hook_debug_show(#name,aszPre,aszSucc); \ 00084 } \ 00085 APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name) \ 00086 { \ 00087 return _hooks.link_##name; \ 00088 } 00089 00102 #define APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ns,link,name,args_decl,args_use) \ 00103 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ 00104 link##_DECLARE(void) ns##_run_##name args_decl \ 00105 { \ 00106 ns##_LINK_##name##_t *pHook; \ 00107 int n; \ 00108 \ 00109 if(!_hooks.link_##name) \ 00110 return; \ 00111 \ 00112 pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ 00113 for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ 00114 pHook[n].pFunc args_use; \ 00115 } 00116 00117 /* FIXME: note that this returns ok when nothing is run. I suspect it should 00118 really return decline, but that breaks Apache currently - Ben 00119 */ 00135 #define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \ 00136 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ 00137 link##_DECLARE(ret) ns##_run_##name args_decl \ 00138 { \ 00139 ns##_LINK_##name##_t *pHook; \ 00140 int n; \ 00141 ret rv; \ 00142 \ 00143 if(!_hooks.link_##name) \ 00144 return ok; \ 00145 \ 00146 pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ 00147 for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ 00148 { \ 00149 rv=pHook[n].pFunc args_use; \ 00150 \ 00151 if(rv != ok && rv != decline) \ 00152 return rv; \ 00153 } \ 00154 return ok; \ 00155 } 00156 00157 00172 #define APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ns,link,ret,name,args_decl,args_use,decline) \ 00173 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \ 00174 link##_DECLARE(ret) ns##_run_##name args_decl \ 00175 { \ 00176 ns##_LINK_##name##_t *pHook; \ 00177 int n; \ 00178 ret rv; \ 00179 \ 00180 if(!_hooks.link_##name) \ 00181 return decline; \ 00182 \ 00183 pHook=(ns##_LINK_##name##_t *)_hooks.link_##name->elts; \ 00184 for(n=0 ; n < _hooks.link_##name->nelts ; ++n) \ 00185 { \ 00186 rv=pHook[n].pFunc args_use; \ 00187 \ 00188 if(rv != decline) \ 00189 return rv; \ 00190 } \ 00191 return decline; \ 00192 } 00193 00194 /* Hook orderings */ 00196 #define APR_HOOK_REALLY_FIRST (-10) 00197 00198 #define APR_HOOK_FIRST 0 00199 00200 #define APR_HOOK_MIDDLE 10 00201 00202 #define APR_HOOK_LAST 20 00203 00204 #define APR_HOOK_REALLY_LAST 30 00205 00209 APU_DECLARE_DATA extern apr_pool_t *apr_hook_global_pool; 00210 00212 APU_DECLARE_DATA extern apr_pool_t *apr_global_hook_pool; 00213 00218 APU_DECLARE_DATA extern int apr_hook_debug_enabled; 00219 00221 APU_DECLARE_DATA extern int apr_debug_module_hooks; 00222 00226 APU_DECLARE_DATA extern const char *apr_hook_debug_current; 00227 00229 APU_DECLARE_DATA extern const char *apr_current_hooking_module; 00230 00236 APU_DECLARE(void) apr_hook_sort_register(const char *szHookName, 00237 apr_array_header_t **aHooks); 00241 APU_DECLARE(void) apr_hook_sort_all(void); 00242 00244 APU_DECLARE(void) apr_sort_hooks(void); 00245 00253 APU_DECLARE(void) apr_hook_debug_show(const char *szName, 00254 const char * const *aszPre, 00255 const char * const *aszSucc); 00256 00258 APU_DECLARE(void) apr_show_hook(const char *szName, 00259 const char * const *aszPre, 00260 const char * const *aszSucc); 00261 00265 APU_DECLARE(void) apr_hook_deregister_all(void); 00266 00268 #ifdef __cplusplus 00269 } 00270 #endif 00271 00272 #endif /* APR_HOOKS_H */

Generated on Mon Sep 27 05:05:29 2004 for Apache Portable Runtime Utility Library by doxygen 1.3.7