From 7a52eab5968ff6974c3585659acadd0c0d04715e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 1 Jun 2006 13:49:10 +0000 Subject: Try the ltdl mangled name ourselves so that .la files for modules are optional. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@998 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/polypcore/module.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/polypcore/module.c b/src/polypcore/module.c index b938750c..47a878fb 100644 --- a/src/polypcore/module.c +++ b/src/polypcore/module.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -63,6 +64,39 @@ static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED m->time_restart(e, &ntv); } +static inline fnptr load_sym(lt_dlhandle handle, const char *module, const char *symbol) { + char *buffer, *ch; + size_t buflen; + fnptr res; + + res = lt_dlsym_fn(handle, symbol); + if (res) + return res; + + /* As the .la files might have been cleansed from the system, we should + * try with the ltdl prefix as well. */ + + buflen = strlen(symbol) + strlen(module) + strlen("_LTX_") + 1; + buffer = pa_xmalloc(buflen); + assert(buffer); + + strcpy(buffer, module); + + for (ch = buffer;*ch != '\0';ch++) { + if (!isalnum(*ch)) + *ch = '_'; + } + + strcat(buffer, "_LTX_"); + strcat(buffer, symbol); + + res = lt_dlsym_fn(handle, buffer); + + pa_xfree(buffer); + + return res; +} + pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { pa_module *m = NULL; int r; @@ -82,12 +116,12 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { goto fail; } - if (!(m->init = (int (*)(pa_core *_c, pa_module*_m)) lt_dlsym_fn(m->dl, PA_SYMBOL_INIT))) { + if (!(m->init = (int (*)(pa_core *_c, pa_module*_m)) load_sym(m->dl, name, PA_SYMBOL_INIT))) { pa_log(__FILE__": Failed to load module \"%s\": symbol \""PA_SYMBOL_INIT"\" not found.", name); goto fail; } - if (!(m->done = (void (*)(pa_core *_c, pa_module*_m)) lt_dlsym_fn(m->dl, PA_SYMBOL_DONE))) { + if (!(m->done = (void (*)(pa_core *_c, pa_module*_m)) load_sym(m->dl, name, PA_SYMBOL_DONE))) { pa_log(__FILE__": Failed to load module \"%s\": symbol \""PA_SYMBOL_DONE"\" not found.", name); goto fail; } -- cgit