include/apr_optional_hooks.h

Go to the documentation of this file.
00001 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 /* APR_OPTIONAL_HOOK_H */

Generated on Tue Sep 11 08:13:14 2007 for Apache Portable Runtime Utility Library by  doxygen 1.5.2