Apache Portable Runtime Utility Library
apr_optional_hooks.h
Go to the documentation of this file.
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
22 #ifndef APR_OPTIONAL_HOOK_H
23 #define APR_OPTIONAL_HOOK_H
24 
25 #include "apr_tables.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
48 APU_DECLARE(void) apr_optional_hook_add(const char *szName,void (*pfn)(void),
49  const char * const *aszPre,
50  const char * const *aszSucc,
51  int nOrder);
52 
64 #define APR_OPTIONAL_HOOK(ns,name,pfn,aszPre,aszSucc,nOrder) do { \
65  ns##_HOOK_##name##_t *apu__hook = pfn; \
66  apr_optional_hook_add(#name,(void (*)(void))apu__hook,aszPre, aszSucc, nOrder); \
67 } while (0)
68 
74 APU_DECLARE(apr_array_header_t *) apr_optional_hook_get(const char *szName);
75 
90 #define APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \
91 link##_DECLARE(ret) ns##_run_##name args_decl \
92  { \
93  ns##_LINK_##name##_t *pHook; \
94  int n; \
95  ret rv; \
96  apr_array_header_t *pHookArray=apr_optional_hook_get(#name); \
97 \
98  if(!pHookArray) \
99  return ok; \
100 \
101  pHook=(ns##_LINK_##name##_t *)pHookArray->elts; \
102  for(n=0 ; n < pHookArray->nelts ; ++n) \
103  { \
104  rv=(pHook[n].pFunc)args_use; \
105 \
106  if(rv != ok && rv != decline) \
107  return rv; \
108  } \
109  return ok; \
110  }
111 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif /* APR_OPTIONAL_HOOK_H */
void apr_optional_hook_add(const char *szName, void(*pfn)(void), const char *const *aszPre, const char *const *aszSucc, int nOrder)