As was discussed earlier this week, I'd like to have a function that allows my
application to enumerate the modules that have been preloaded after lt_dlinit()
has been called. The patches below add a function called lt_dlopen_preloaded,
with no arguments, that just walks the preloaded symbols lists and lt_dlopen()
each modules it finds there. The handle returned from lt_dlopen() is not preserved,
but the handle is checked for errors and an aggregate error count is returned to the 
caller.

With this function in the API, the application can subsequently call lt_dlforeach
to enumerate all the modules (since they have now been opened), and do whatever
it likes with them.


--- ltdl.h.dist Thu Oct 16 12:23:29 2003 +++ ltdl.h Thu Oct 16 11:25:50 2003 @@ -221,6 +221,7 @@ extern int lt_dlpreload LT_PARAMS((const lt_dlsymlist *preloaded)); extern int lt_dlpreload_default LT_PARAMS((const lt_dlsymlist *preloaded)); +extern int lt_dlopen_preloaded LT_PARAMS((void));

 #define LTDL_SET_PRELOADED_SYMBOLS()           LT_STMT_START{  \
        extern const lt_dlsymlist lt_preloaded_symbols[];               \
--- ltdl.c.dist Wed Oct 15 07:11:08 2003
+++ ltdl.c      Thu Oct 16 11:43:01 2003
@@ -2269,6 +2269,34 @@
 }

 int
+lt_dlopen_preloaded ()
+{
+  lt_dlsymlists_t     *list;
+  int                errors   = 0;
+  unsigned int        index;
+  const lt_dlsymlist *symbol;
+  lt_dlhandle         handle;
+
+  LT_DLMUTEX_LOCK ();
+
+  list = preloaded_symbols;
+  while (list)
+    {
+      for (index = 0; (symbol = &list->syms[index])->name != 0; index++) {
+       if ((symbol->address == 0) && strcmp(symbol->name, "@PROGRAM@"))
+         {
+       if ((handle = lt_dlopen(symbol->name)) == NULL)
+           errors++;
+         }
+      }
+      list = list->next;
+    }
+
+  LT_DLMUTEX_UNLOCK ();
+  return errors;
+}
+
+int
 lt_dlexit ()
 {
   /* shut down libltdl */




_______________________________________________ Libtool mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/libtool

Reply via email to