diff options
author | Pierre Ossman <ossman@cendio.se> | 2006-06-01 13:49:10 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2006-06-01 13:49:10 +0000 |
commit | 7a52eab5968ff6974c3585659acadd0c0d04715e (patch) | |
tree | 1778a7fcb00a94c08d2f5421b4e73b87ddd374dc | |
parent | 8ca956892ef71cf93e97c8f94c4c64d979f9a128 (diff) |
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
-rw-r--r-- | src/polypcore/module.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/polypcore/module.c b/src/polypcore/module.c index b938750c8..47a878fba 100644 --- a/src/polypcore/module.c +++ b/src/polypcore/module.c @@ -29,6 +29,7 @@ #include <assert.h> #include <string.h> #include <errno.h> +#include <ctype.h> #include <polyp/timeval.h> #include <polyp/xmalloc.h> @@ -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; } |