From: Gary V. Vaughan Date: Mon, 21 Feb 2000 22:27:24 +0000 (+0000) Subject: * libltdl/ltdl.c (lt_find_dlhandle): New function. X-Git-Tag: release-1-3d~196 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65e997bb2c982b18581860b12b124c658361fd3b;p=thirdparty%2Flibtool.git * libltdl/ltdl.c (lt_find_dlhandle): New function. (tryall_dlopen): Use it. * libltdl/ltdl.h: Prototype it. * doc/libtool.texi: Document it. * NEWS: updated. --- diff --git a/ChangeLog b/ChangeLog index 4bd2bd46c..387b06bfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2000-02-21 Gary V. Vaughan + * libltdl/ltdl.c (lt_find_dlhandle): New function. + (tryall_dlopen): Use it. + * libltdl/ltdl.h: Prototype it. + * doc/libtool.texi: Document it. + * NEWS: updated. + * libltdl/ltdl.c (lt_dlinit): removed unused variable, `loader'. * libltdl/ltdl.c (lt_remove_dlloader): typo, s/=/==/g. diff --git a/NEWS b/NEWS index 797bd0a42..b7b868b37 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ New in 1.3d: 2000-??-??; CVS version 1.3c, Libtool team: loader to libltdl.. * New functions lt_dladderror, lt_dlseterror in libltdl can be used to integrate user module loaders with lt_dlerror. +* New function lt_find_dlhandle can be used to lookup the handle + associated with a previously dlopened filename. * "-Xcompiler" and "-Wc," does now work in compile mode, too. * Start of support code for cross-compiling to win32. * libltdl can now be built as a dll with win32. diff --git a/doc/libtool.texi b/doc/libtool.texi index f58b8fdc7..9162087c6 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -2918,6 +2918,14 @@ to be able to @code{dlopen} such libraries as well as libtool modules transparently. @end deftypefun +@deftypefun lt_dlhandle lt_find_dlhandle (const char *@var{name}) +Lookup the module handle for the module that was loaded from +@var{name}. @var{name} must be exactly the same as the name used to +open the module with @samp{lt_dlopen} or @samp{lt_dlopenext}. If +@var{name} was not previously used to open a module with either of those +functions, @code{NULL} is returned. +@end deftypefun + @deftypefun int lt_dlclose (lt_dlhandle @var{handle}) Decrement the reference count on the module @var{handle}. If it drops to zero and no other module depends on this module, diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index eb3a93b38..64d4c4ebf 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -908,12 +908,21 @@ tryall_dlopen (handle, filename) lt_dlhandle *handle; const char *filename; { - lt_dlhandle cur; + lt_dlhandle cur = handles; lt_dlloader_t *loader = loaders; const char *saved_error = last_error; /* check whether the module was already opened */ - cur = lt_find_dlhandle (filename); + while (cur) { + /* try to dlopen the program itself? */ + if (!cur->info.filename && !filename) + break; + if (cur->info.filename && filename && + strcmp(cur->info.filename, filename) == 0) + break; + cur = cur->next; + } + if (cur) { cur->info.ref_count++; *handle = cur; @@ -1594,18 +1603,18 @@ lt_dlopenext (filename) } lt_dlhandle -lt_find_dlhandle (filename) - const char *filename; +lt_find_dlhandle (name) + const char *name; { lt_dlhandle cur = handles; /* check whether the module was already opened */ while (cur) { /* try to dlopen the program itself? */ - if (!cur->info.filename && !filename) + if (!cur->info.name && !name) break; - if (cur->info.filename && filename && - strcmp(cur->info.filename, filename) == 0) + if (cur->info.name && name && + strcmp(cur->info.name, name) == 0) break; cur = cur->next; } diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h index 2a2a75b86..9a2494b71 100644 --- a/libltdl/ltdl.h +++ b/libltdl/ltdl.h @@ -195,7 +195,7 @@ __BEGIN_DECLS extern int lt_dlinit LTDL_PARAMS((void)); extern int lt_dlexit LTDL_PARAMS((void)); -/* Module search path manipultation. */ +/* Module search path manipulation. */ extern int lt_dladdsearchdir LTDL_PARAMS((const char *search_dir)); extern int lt_dlsetsearchpath LTDL_PARAMS((const char *search_path)); extern const char *lt_dlgetsearchpath LTDL_PARAMS((void)); @@ -203,6 +203,7 @@ extern const char *lt_dlgetsearchpath LTDL_PARAMS((void)); /* Portable libltdl versions of the system dlopen() API. */ extern lt_dlhandle lt_dlopen LTDL_PARAMS((const char *filename)); extern lt_dlhandle lt_dlopenext LTDL_PARAMS((const char *filename)); +extern lt_dlhandle lt_find_dlhandle LTDL_PARAMS((const char *name)); extern lt_ptr_t lt_dlsym LTDL_PARAMS((lt_dlhandle handle, const char *name)); extern const char *lt_dlerror LTDL_PARAMS((void)); extern int lt_dlclose LTDL_PARAMS((lt_dlhandle handle));