summaryrefslogtreecommitdiff
path: root/src/drivers/Posix
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-10-04 08:20:50 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-10-04 08:21:07 +0200
commit0c55cd1aca19b57a9b8837d1672ae260cfca4d78 (patch)
treea9f5b10b3ec558d7525f24037cafc86ce796d9e5 /src/drivers/Posix
parent46598229a9605b25e3da5e0d7ad41343cf429497 (diff)
Create Fl_X11_System_Driver::dlopen_or_dlsym() for run-time addresses.
The intent is to gather in a single place of the X11 platform source code all variable elements when using dlopen() and dlsym() system functions (e.g., .so vs .dylib extension name, is RTLD_DEFAULT available, locations to be sought). Member function Fl_System_Driver::load() is created only to support Fl_Plugin_Manager::load().
Diffstat (limited to 'src/drivers/Posix')
-rw-r--r--src/drivers/Posix/Fl_Posix_System_Driver.H4
-rw-r--r--src/drivers/Posix/Fl_Posix_System_Driver.cxx47
2 files changed, 6 insertions, 45 deletions
diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.H b/src/drivers/Posix/Fl_Posix_System_Driver.H
index 3f4cf72c8..3de26e5aa 100644
--- a/src/drivers/Posix/Fl_Posix_System_Driver.H
+++ b/src/drivers/Posix/Fl_Posix_System_Driver.H
@@ -65,7 +65,9 @@ public:
virtual int rename(const char* f, const char *n) {return ::rename(f, n);}
virtual const char *getpwnam(const char *login);
virtual int need_menu_handle_part2() {return 1;}
- virtual void *dlopen(const char *filename);
+#if HAVE_DLFCN_H
+ virtual void *load(const char *filename);
+#endif
// these 4 are implemented in Fl_lock.cxx
virtual void awake(void*);
virtual int lock();
diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx
index a05781d1b..20b7aef28 100644
--- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx
+++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx
@@ -1,7 +1,7 @@
//
// Definition of Apple Darwin system driver.
//
-// Copyright 1998-2017 by Bill Spitzak and others.
+// Copyright 1998-2020 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -47,52 +47,11 @@
#if HAVE_DLFCN_H
-static void* triple_dlopen(const char *filename1)
-{
- void *ptr = ::dlopen(filename1, RTLD_LAZY | RTLD_GLOBAL);
- if (!ptr) {
- char filename2[FL_PATH_MAX];
- sprintf(filename2, "%s.1", filename1);
- ptr = dlopen(filename2, RTLD_LAZY | RTLD_GLOBAL);
- if (!ptr) {
- sprintf(filename2, "%s.0", filename1);
- ptr = dlopen(filename2, RTLD_LAZY | RTLD_GLOBAL);
- }
- }
- return ptr;
+void *Fl_Posix_System_Driver::load(const char *filename) {
+ return ::dlopen(filename, RTLD_LAZY);
}
#endif
-void *Fl_Posix_System_Driver::dlopen(const char *filename)
-{
- void *ptr = NULL;
-#if HAVE_DLFCN_H
- ptr = triple_dlopen(filename);
-# ifdef __APPLE_CC__ // allows testing on Darwin + XQuartz + fink
- if (!ptr) {
- char *f_dylib = (char*)malloc(strlen(filename)+7);
- strcpy(f_dylib, filename);
- char *p = strrchr(f_dylib, '.');
- if (!p) p = f_dylib + strlen(f_dylib);
- strcpy(p, ".dylib");
- char path[FL_PATH_MAX];
- sprintf(path, "/sw/lib/%s", f_dylib);
- ptr = ::dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
- if (!ptr) {
- sprintf(path, "/opt/sw/lib/%s", f_dylib);
- ptr = ::dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
- }
- if (!ptr) {
- sprintf(path, "/opt/X11/lib/%s", f_dylib);
- ptr = ::dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
- }
- free(f_dylib);
- }
-# endif // __APPLE_CC__
-#endif // HAVE_DLFCN_H
- return ptr;
-}
-
int Fl_Posix_System_Driver::file_type(const char *filename)
{
int filetype;