httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas, Peter" <ptho...@HPTI.com>
Subject RE: DSO question
Date Tue, 09 Mar 2010 18:55:24 GMT
> -----Original Message-----
> From: Ben Noordhuis [mailto:info@bnoordhuis.nl] 
> Sent: Tuesday, March 09, 2010 1:34 PM
> To: modules-dev@httpd.apache.org
> Subject: Re: DSO question
> 
> > What I need is to tell to APR, hey APR please find the 
> function "f10" 
> > in all loaded libraries, then execute the function and give 
> me back the result.

Thankfully APR defines handy macros for such a purpose...

Look at the macros:

     APR_DECLARE_OPTIONAL_FN
     APR_REGISTER_OPTIONAL_FN
     APR_OPTIONAL_FN_TYPE
     APR_RETRIEVE_OPTIONAL_FN

As the other poster pointed out, there is no magic bullet for knowing
where the function is declared! You will have to include the relevant
header where the APR_DECLARE_OPTIONAL_FN appears.  So, if you want to
use ssl_var_lookup from mod_ssl.h you will still have to #include
"mod_ssl.h" in your module.

If you look at ./srclib/apr-util/include/apr_optional.h and
./srclib/apr-util/hooks/apr_hooks.c, you can see under the hood that the
implementation is much like the other respondent suggested, except that
an apr_hash is used to register and look up functions, instead of an
array.  See, for example, this line from apr_hooks.c:

     [...]     
     return
(void(*)(void))apr_hash_get(s_phOptionalFunctions,szName,strlen(szName))
;
     [...]

--Pete

Mime
View raw message