[polypaudio-commits] r998 - /trunk/src/polypcore/module.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Jun 1 06:49:11 PDT 2006


Author: ossman
Date: Thu Jun  1 15:49:10 2006
New Revision: 998

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=998&root=polypaudio&view=rev
Log:
Try the ltdl mangled name ourselves so that .la files for modules are optional.

Modified:
    trunk/src/polypcore/module.c

Modified: trunk/src/polypcore/module.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polypcore/module.c?rev=998&root=polypaudio&r1=997&r2=998&view=diff
==============================================================================
--- trunk/src/polypcore/module.c (original)
+++ trunk/src/polypcore/module.c Thu Jun  1 15:49:10 2006
@@ -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 @@
     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 @@
         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;
     }




More information about the pulseaudio-commits mailing list