hooks.html revision 4f1f0f9a56771adea88c7b3c1061f33d3dfe5c2c
f45a20d6ba9e8d695ec3ab707f0cc082999aa4a3Jakub Hrozek<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek BGCOLOR="#FFFFFF"
03532fb1cbb7e8c1d5cf2e93aa3719f926631cabStephen Gallagher TEXT="#000000"
8a2a49333b7df3a4b86db42cd20ec8286d2788d3Pavel Březina LINK="#0000FF"
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek VLINK="#000080"
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek ALINK="#FF0000"
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek<!--#include virtual="header.html" -->
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek<P>In general, a hook function is one that Apache will call at some
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozekpoint during the processing of a request. Modules can provide
46e44f86067b7f77c3f71cb7ac57456434e354dcStephen Gallagherfunctions that are called, and specify when they get called in
46e44f86067b7f77c3f71cb7ac57456434e354dcStephen Gallaghercomparison to other modules.</P>
46e44f86067b7f77c3f71cb7ac57456434e354dcStephen Gallagher<P>In order to create a new hook, four things need to be done:</P>
54c64aad71e6792edb7cf99988d9a7f4bc2b0c61Jakub Hrozek<P>Use the AP_DECLARE_HOOK macro, which needs to be given the return
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozektype of the hook function, the name of the hook, and the arguments. For
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozekexample, if the hook returns an <TT>int</TT> and takes a
6f51c802311fd81a409a26763ed45b28a3234d0dJakub Hrozek<TT>request_rec *</TT> and an <TT>int</TT> and is called
a23919ed39d212f9f5694d9b103c84641fdb7680Stephen Gallagher"do_something", then declare it like this:</P>
813086b16adabc6c1a0f37d7518c6a709ae1c57aJakub Hrozek<TT>AP_DECLARE_HOOK(int,do_something,(request_rec *r,int n))</TT>
11540d9efb85b9ed0341e8a1fc97fc078c6ce418Pavel Březina<P>This should go in a header which modules will include if they want
46e44f86067b7f77c3f71cb7ac57456434e354dcStephen Gallagherto use the hook.</P>
002dfe55ef258b73ca85eb813b1a156789b7702aJakub Hrozek<P>Each source file that exports a hook has a private structure which
b49d753b5a17c4092d8c24e84eea4400de39d341Sumit Boseis used to record the module functions that use the hook. This is
ae0a5011e2644eaa482ea1b9e1451eff05c676b9Lukas Slebodnikdeclared as follows:</P>
(after) the current module. For example, suppose we want "mod_xyz.c"
<!--#include virtual="footer.html" -->