openbsd-ports/x11/ogle_gui/patches/patch-src_my_glade_c
espie c59be8204d update ogle_gui to 0.9.2, to synch with ogle.
Minor improvement: ogle_gui now uses gnome2 base libraries.
This unconfuses our linker, that now has one single libxml to take
care of.

(temporary gtk1 flavor, which will probably vanish soon).

okay'ed MAINTAINER.
2003-11-13 18:48:38 +00:00

68 lines
1.6 KiB
Plaintext

$OpenBSD: patch-src_my_glade_c,v 1.3 2003/11/13 18:48:38 espie Exp $
--- src/my_glade.c.orig 2003-11-05 20:06:51.000000000 +0100
+++ src/my_glade.c 2003-11-06 07:42:54.000000000 +0100
@@ -70,6 +70,51 @@ static void *my_dlsym(void *handle, char
// location of the standard ogle_gui.glade file
#define OGLE_GLADE_FILE PACKAGE_PIXMAPS_DIR "/ogle_gui." GLADE_EXT
+#ifdef __OpenBSD__
+#include <string.h>
+#include <dirent.h>
+#include <libgen.h>
+/* Quick and dirty: settle for any libglade */
+static void *findlibrary(char *template)
+{
+ char *name;
+ char *sopart;
+ size_t len;
+ DIR *d;
+ struct dirent *de;
+ void *lib;
+
+ name = dirname(template);
+ if (!name)
+ return NULL;
+ template = basename(template);
+ if (!template)
+ return NULL;
+ sopart = strstr(template, ".so.");
+ if (!sopart)
+ return NULL;
+
+ len = sopart-template+4;
+
+ d = opendir(name);
+ if (!d)
+ return NULL;
+ while ((de = readdir(d)) != NULL) {
+ if (strncmp(de->d_name, template, len) == 0) {
+ lib = dlopen(de->d_name, DL_LAZY);
+ closedir(d);
+ return lib;
+ }
+ }
+ closedir(d);
+ return NULL;
+}
+#endif
+
+#ifndef RTLD_NOW
+#define RTLD_NOW 0
+#endif
+
// to be called first
void my_glade_setup ()
{
@@ -83,6 +128,10 @@ void my_glade_setup ()
// next, try without path
glade_lib = dlopen (LIBGLADE_LIB, RTLD_NOW);
}
+#ifdef __OpenBSD__
+ if (glade_lib == NULL)
+ glade_lib = findlibrary(LIBGLADE_LIBDIR "/" LIBGLADE_LIB);
+#endif
if (glade_lib == NULL) {
fprintf(stderr, "Error during dlopen: %s\n", dlerror());
gtk_exit(1);