You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jeffrey Walton <no...@gmail.com> on 2020/04/27 15:52:04 UTC

[users@httpd] What is n in a hook function?

Hi Everyone,

I'm reading https://httpd.apache.org/docs/2.4/developer/hooks.html. It
says to declare a hook function:

    AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))

But it does not explain the parameters. I know what request_rec is,
but I don't know what n is.

What is n in the hook function?

Thanks in advance.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] What is n in a hook function?

Posted by Eric Covener <co...@gmail.com>.
On Mon, Apr 27, 2020 at 12:09 PM Jeffrey Walton <no...@gmail.com> wrote:
>
> On Mon, Apr 27, 2020 at 12:01 PM Eric Covener <co...@gmail.com> wrote:
> >
> > On Mon, Apr 27, 2020 at 11:52 AM Jeffrey Walton <no...@gmail.com> wrote:
> > >
> > > I'm reading https://httpd.apache.org/docs/2.4/developer/hooks.html. It
> > > says to declare a hook function:
> > >
> > >     AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))
> > >
> > > But it does not explain the parameters. I know what request_rec is,
> > > but I don't know what n is.
> > >
> > > What is n in the hook function?
> >
> > It is just an example 2nd argument that each hook participant will
> > receive. In the doc it's a made-up hook with a made-up additional arg.
> > Many basic request-processing hooks just take a request_rec for example.
>
> Thanks Eric.
>
> ap_hook_quick_handler uses a function with that particular signature.
> Would you happen to know what the int is used for in that case?
>
> (ap_hook_quick_handler is the reason for the question. Also see
> https://httpd.apache.org/docs/2.4/developer/modguide.html).

You can find the doc for the built-in hooks in include/

/**
 * Run the quick handler functions for each module. The quick_handler
 * is run before any other requests hooks are called (location_walk,
 * directory_walk, access checking, et. al.). This hook was added
 * to provide a quick way to serve content from a URI keyed cache.
 *
 * @param r The request_rec
 * @param lookup_uri Controls whether the caller actually wants content or not.
 * lookup is set when the quick_handler is called out of
 * ap_sub_req_lookup_uri()
 */
AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))




-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] What is n in a hook function?

Posted by Jeffrey Walton <no...@gmail.com>.
On Mon, Apr 27, 2020 at 12:01 PM Eric Covener <co...@gmail.com> wrote:
>
> On Mon, Apr 27, 2020 at 11:52 AM Jeffrey Walton <no...@gmail.com> wrote:
> >
> > I'm reading https://httpd.apache.org/docs/2.4/developer/hooks.html. It
> > says to declare a hook function:
> >
> >     AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))
> >
> > But it does not explain the parameters. I know what request_rec is,
> > but I don't know what n is.
> >
> > What is n in the hook function?
>
> It is just an example 2nd argument that each hook participant will
> receive. In the doc it's a made-up hook with a made-up additional arg.
> Many basic request-processing hooks just take a request_rec for example.

Thanks Eric.

ap_hook_quick_handler uses a function with that particular signature.
Would you happen to know what the int is used for in that case?

(ap_hook_quick_handler is the reason for the question. Also see
https://httpd.apache.org/docs/2.4/developer/modguide.html).

Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] What is n in a hook function?

Posted by Eric Covener <co...@gmail.com>.
On Mon, Apr 27, 2020 at 11:52 AM Jeffrey Walton <no...@gmail.com> wrote:
>
> Hi Everyone,
>
> I'm reading https://httpd.apache.org/docs/2.4/developer/hooks.html. It
> says to declare a hook function:
>
>     AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))
>
> But it does not explain the parameters. I know what request_rec is,
> but I don't know what n is.
>
> What is n in the hook function?

It is just an example 2nd argument that each hook participant will
receive. In the doc it's a made-up hook with a made-up additional arg.
Many basic request-processing hooks just take a request_rec for example.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] What is n in a hook function?

Posted by Nick Kew <ni...@apache.org>.

> On 27 Apr 2020, at 16:52, Jeffrey Walton <no...@gmail.com> wrote:
> 
> Hi Everyone,
> 
> I'm reading https://httpd.apache.org/docs/2.4/developer/hooks.html. It
> says to declare a hook function:
> 
>    AP_DECLARE_HOOK(int, do_something, (request_rec *r, int n))

That declares a hook to enable modules to insert a function.
The r and the n are arguments to the function do_something.

Best way to get a feel for it is to look at examples in the core
server and standard modules, and match the declarations to
AP_IMPLEMENT_HOOK_* and ap_hook_*.
Hooks are pretty central to everything.

-- 
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org