ap_hooks.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. */
  16. /**
  17. * @file ap_hooks.h
  18. * @brief ap hook functions and macros
  19. */
  20. #ifndef AP_HOOKS_H
  21. #define AP_HOOKS_H
  22. /* Although this file doesn't declare any hooks, declare the hook group here */
  23. /**
  24. * @defgroup hooks Apache Hooks
  25. * @ingroup APACHE_CORE
  26. */
  27. #if defined(AP_HOOK_PROBES_ENABLED) && !defined(APR_HOOK_PROBES_ENABLED)
  28. #define APR_HOOK_PROBES_ENABLED 1
  29. #endif
  30. #ifdef APR_HOOK_PROBES_ENABLED
  31. #include "ap_hook_probes.h"
  32. #endif
  33. #include "apr.h"
  34. #include "apr_hooks.h"
  35. #include "apr_optional_hooks.h"
  36. #ifdef DOXYGEN
  37. /* define these just so doxygen documents them */
  38. /**
  39. * AP_DECLARE_STATIC is defined when including Apache's Core headers,
  40. * to provide static linkage when the dynamic library may be unavailable.
  41. *
  42. * @see AP_DECLARE_EXPORT
  43. *
  44. * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
  45. * including Apache's Core headers, to import and link the symbols from the
  46. * dynamic Apache Core library and assure appropriate indirection and calling
  47. * conventions at compile time.
  48. */
  49. # define AP_DECLARE_STATIC
  50. /**
  51. * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
  52. * library, so that all public symbols are exported.
  53. *
  54. * @see AP_DECLARE_STATIC
  55. */
  56. # define AP_DECLARE_EXPORT
  57. #endif /* def DOXYGEN */
  58. /**
  59. * Declare a hook function
  60. * @param ret The return type of the hook
  61. * @param name The hook's name (as a literal)
  62. * @param args The arguments the hook function takes, in brackets.
  63. */
  64. #define AP_DECLARE_HOOK(ret,name,args) \
  65. APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args)
  66. /** @internal */
  67. #define AP_IMPLEMENT_HOOK_BASE(name) \
  68. APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name)
  69. /**
  70. * Implement an Apache core hook that has no return code, and
  71. * therefore runs all of the registered functions. The implementation
  72. * is called ap_run_<i>name</i>.
  73. *
  74. * @param name The name of the hook
  75. * @param args_decl The declaration of the arguments for the hook, for example
  76. * "(int x,void *y)"
  77. * @param args_use The arguments for the hook as used in a call, for example
  78. * "(x,y)"
  79. * @note If IMPLEMENTing a hook that is not linked into the Apache core,
  80. * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID.
  81. */
  82. #define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
  83. APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use)
  84. /**
  85. * Implement an Apache core hook that runs until one of the functions
  86. * returns something other than ok or decline. That return value is
  87. * then returned from the hook runner. If the hooks run to completion,
  88. * then ok is returned. Note that if no hook runs it would probably be
  89. * more correct to return decline, but this currently does not do
  90. * so. The implementation is called ap_run_<i>name</i>.
  91. *
  92. * @param ret The return type of the hook (and the hook runner)
  93. * @param name The name of the hook
  94. * @param args_decl The declaration of the arguments for the hook, for example
  95. * "(int x,void *y)"
  96. * @param args_use The arguments for the hook as used in a call, for example
  97. * "(x,y)"
  98. * @param ok The "ok" return value
  99. * @param decline The "decline" return value
  100. * @return ok, decline or an error.
  101. * @note If IMPLEMENTing a hook that is not linked into the Apache core,
  102. * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL.
  103. */
  104. #define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
  105. APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
  106. args_use,ok,decline)
  107. /**
  108. * Implement a hook that runs until a function returns something other than
  109. * decline. If all functions return decline, the hook runner returns decline.
  110. * The implementation is called ap_run_<i>name</i>.
  111. *
  112. * @param ret The return type of the hook (and the hook runner)
  113. * @param name The name of the hook
  114. * @param args_decl The declaration of the arguments for the hook, for example
  115. * "(int x,void *y)"
  116. * @param args_use The arguments for the hook as used in a call, for example
  117. * "(x,y)"
  118. * @param decline The "decline" return value
  119. * @return decline or an error.
  120. * @note If IMPLEMENTing a hook that is not linked into the Apache core
  121. * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST.
  122. */
  123. #define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
  124. APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
  125. args_use,decline)
  126. /* Note that the other optional hook implementations are straightforward but
  127. * have not yet been needed
  128. */
  129. /**
  130. * Implement an optional hook. This is exactly the same as a standard hook
  131. * implementation, except the hook is optional.
  132. * @see AP_IMPLEMENT_HOOK_RUN_ALL
  133. */
  134. #define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \
  135. decline) \
  136. APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
  137. args_use,ok,decline)
  138. /**
  139. * Hook an optional hook. Unlike static hooks, this uses a macro instead of a
  140. * function.
  141. */
  142. #define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \
  143. APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order)
  144. #endif /* AP_HOOKS_H */