> -----Original Message-----
> From: Ben Noordhuis [mailto:[email protected]]
> Sent: Tuesday, March 09, 2010 1:34 PM
> To: [email protected]
> 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