2008-10-11 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Sat, 11 Oct 2008 04:28:32 +0000 (04:28 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 11 Oct 2008 04:28:32 +0000 (04:28 -0000)
* src/gmodule-win32.c, src/gmisc-unix.c, src/gmisc-win32.c,
src/gmodule-unix.c: split functionality in platforms.

* src/goutput.c (g_logv): On some platforms, before we abort we
want to flush the stdout/stderr.

svn path=/trunk/mono/; revision=115504

eglib/ChangeLog
eglib/src/Makefile.am
eglib/src/gmisc-unix.c [new file with mode: 0644]
eglib/src/gmisc-win32.c [new file with mode: 0644]
eglib/src/gmisc.c [deleted file]
eglib/src/gmodule-unix.c [new file with mode: 0644]
eglib/src/gmodule-win32.c [new file with mode: 0644]
eglib/src/gmodule.c [deleted file]
eglib/src/gmodule.h
eglib/src/goutput.c

index bef4d9cf6e4790f2f698aff8964f3e831daf0d5f..2c4065b74622c22a13ccfb068ba37c1b4e132d35 100644 (file)
@@ -1,3 +1,11 @@
+2008-10-11  Miguel de Icaza  <miguel@novell.com>
+
+       * src/gmodule-win32.c, src/gmisc-unix.c, src/gmisc-win32.c,
+       src/gmodule-unix.c: split functionality in platforms.
+       
+       * src/goutput.c (g_logv): On some platforms, before we abort we
+       want to flush the stdout/stderr.
+
 2008-10-10  Miguel de Icaza  <miguel@novell.com>
 
        * Split functionality that is operating system specific into
index 586f6007307889e9acd4894ea7c411ddca07003c..f75ba695fb5edda84d000fc867b6c210202492eb 100644 (file)
@@ -1,7 +1,12 @@
 noinst_LTLIBRARIES = libeglib.la
 
-win_files  = gdate-win32.c gdir-win32.c gfile-win32.c
-unix_files = gdate-unix.c  gdir-unix.c  gfile-unix.c
+win_files  = \
+       gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c \
+       gmodule-win32.c
+
+unix_files = \
+       gdate-unix.c  gdir-unix.c  gfile-unix.c  gmisc-unix.c   \
+       gmodule-unix.c
 
 if PLATFORM_WIN32
 os_files = $(win_files)
@@ -17,7 +22,6 @@ libeglib_la_SOURCES = \
        gerror.c        \
        ghashtable.c    \
        gmem.c          \
-       gmodule.c       \
        gmodule.h       \
        goutput.c       \
        gstr.c          \
@@ -25,7 +29,6 @@ libeglib_la_SOURCES = \
        gstring.c       \
        gptrarray.c     \
        glist.c         \
-       gmisc.c         \
        gqueue.c        \
        gpath.c         \
        gshell.c        \
diff --git a/eglib/src/gmisc-unix.c b/eglib/src/gmisc-unix.c
new file mode 100644 (file)
index 0000000..8e85e63
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * gmisc.c: Misc functions with no place to go (right now)
+ *
+ * Author:
+ *   Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+
+const gchar *
+g_getenv(const gchar *variable)
+{
+       return getenv(variable);
+}
+
+gboolean
+g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
+{
+       return setenv(variable, value, overwrite) == 0;
+}
+
+void
+g_unsetenv(const gchar *variable)
+{
+       unsetenv(variable);
+}
+
+gchar*
+g_win32_getlocale(void)
+{
+       return NULL;
+}
+
+
+
diff --git a/eglib/src/gmisc-win32.c b/eglib/src/gmisc-win32.c
new file mode 100644 (file)
index 0000000..beaf9a0
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * gmisc.c: Misc functions with no place to go (right now)
+ *
+ * Author:
+ *   Aaron Bockover (abockover@novell.com)
+ *
+ * (C) 2006 Novell, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <glib.h>
+
+#include <windows.h>
+
+const gchar *
+g_getenv(const gchar *variable)
+{
+       gunichar2 *var, *buffer;
+       gchar* val = NULL;
+       gint32 buffer_size = 1024;
+       gint32 retval;
+       var = u8to16(variable); 
+       buffer = g_malloc(buffer_size*sizeof(gunichar2));
+       retval = GetEnvironmentVariable (var, buffer, buffer_size);
+       if (retval != 0) {
+               if (retval > buffer_size) {
+                       g_free (buffer);
+                       buffer_size = retval;
+                       buffer = g_malloc(buffer_size*sizeof(gunichar2));
+                       retval = GetEnvironmentVariable (var, buffer, buffer_size);
+               }
+               val = u16to8 (buffer);
+       }
+       g_free(var);
+       g_free(buffer);
+       return val; 
+}
+
+gboolean
+g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
+{
+       gunichar2 *var, *val;
+       gboolean result;
+       var = u8to16(variable); 
+       val = u8to16(value);
+       result = (SetEnvironmentVariable(var, val) != 0) ? TRUE : FALSE;
+       g_free(var);
+       g_free(val);
+       return result;
+}
+
+void
+g_unsetenv(const gchar *variable)
+{
+       gunichar2 *var;
+       var = u8to16(variable); 
+       SetEnvironmentVariable(var, TEXT(""));
+       g_free(var);
+}
+
+gchar*
+g_win32_getlocale(void)
+{
+       /* FIXME: Use GetThreadLocale
+        * and convert LCID to standard 
+        * string form, "en_US" */
+       return strdup ("en_US");
+}
+
+
diff --git a/eglib/src/gmisc.c b/eglib/src/gmisc.c
deleted file mode 100644 (file)
index 1256083..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * gmisc.c: Misc functions with no place to go (right now)
- *
- * Author:
- *   Aaron Bockover (abockover@novell.com)
- *
- * (C) 2006 Novell, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <glib.h>
-
-#ifdef G_OS_WIN32
-#include <windows.h>
-#endif
-
-const gchar *
-g_getenv(const gchar *variable)
-{
-#ifdef G_OS_WIN32
-       gunichar2 *var, *buffer;
-       gchar* val = NULL;
-       gint32 buffer_size = 1024;
-       gint32 retval;
-       var = u8to16(variable); 
-       buffer = g_malloc(buffer_size*sizeof(gunichar2));
-       retval = GetEnvironmentVariable (var, buffer, buffer_size);
-       if (retval != 0) {
-               if (retval > buffer_size) {
-                       g_free (buffer);
-                       buffer_size = retval;
-                       buffer = g_malloc(buffer_size*sizeof(gunichar2));
-                       retval = GetEnvironmentVariable (var, buffer, buffer_size);
-               }
-               val = u16to8 (buffer);
-       }
-       g_free(var);
-       g_free(buffer);
-       return val; 
-#else
-       return getenv(variable);
-#endif
-}
-
-gboolean
-g_setenv(const gchar *variable, const gchar *value, gboolean overwrite)
-{
-#ifdef G_OS_WIN32
-       gunichar2 *var, *val;
-       gboolean result;
-       var = u8to16(variable); 
-       val = u8to16(value);
-       result = (SetEnvironmentVariable(var, val) != 0) ? TRUE : FALSE;
-       g_free(var);
-       g_free(val);
-       return result;
-#else
-       return setenv(variable, value, overwrite) == 0;
-#endif
-}
-
-void
-g_unsetenv(const gchar *variable)
-{
-#ifdef G_OS_WIN32
-       gunichar2 *var;
-       var = u8to16(variable); 
-       SetEnvironmentVariable(var, TEXT(""));
-       g_free(var);
-#else
-       unsetenv(variable);
-#endif
-}
-
-gchar*
-g_win32_getlocale(void)
-{
-#ifdef G_OS_WIN32
-       /* FIXME: Use GetThreadLocale
-        * and convert LCID to standard 
-        * string form, "en_US" */
-       return strdup ("en_US");
-#else
-       return NULL;
-#endif
-}
-
-
diff --git a/eglib/src/gmodule-unix.c b/eglib/src/gmodule-unix.c
new file mode 100644 (file)
index 0000000..e8b6dea
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * gmodule.c: dl* functions, glib style
+ *
+ * Author:
+ *   Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *   Jonathan Chambers (joncham@gmail.com)
+ *   Robert Jordan (robertj@gmx.net)
+ *
+ * (C) 2006 Novell, Inc.
+ * (C) 2006 Jonathan Chambers
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <gmodule.h>
+
+#ifdef G_OS_UNIX
+#include <dlfcn.h>
+
+/* For Linux and Solaris, need to add others as we port this */
+#define LIBPREFIX "lib"
+#define LIBSUFFIX ".so"
+
+struct _GModule {
+       void *handle;
+};
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+       int f = 0;
+       GModule *module;
+       void *handle;
+       
+       flags &= G_MODULE_BIND_MASK;
+       if ((flags & G_MODULE_BIND_LAZY) != 0)
+               f |= RTLD_LAZY;
+       if ((flags & G_MODULE_BIND_LOCAL) != 0)
+               f |= RTLD_LOCAL;
+
+       handle = dlopen (file, f);
+       if (handle == NULL)
+               return NULL;
+       
+       module = g_new (GModule,1);
+       module->handle = handle;
+       
+       return module;
+}
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+       if (symbol_name == NULL || symbol == NULL)
+               return FALSE;
+
+       if (module == NULL || module->handle == NULL)
+               return FALSE;
+
+       *symbol = dlsym (module->handle, symbol_name);
+       return (*symbol != NULL);
+}
+
+const gchar *
+g_module_error (void)
+{
+       return dlerror ();
+}
+
+gboolean
+g_module_close (GModule *module)
+{
+       void *handle;
+       if (module == NULL || module->handle == NULL)
+               return FALSE;
+
+       handle = module->handle;
+       module->handle = NULL;
+       g_free (module);
+       return (0 == dlclose (handle));
+}
+
+#elif defined (G_OS_WIN32)
+#include <windows.h>
+#include <psapi.h>
+
+#define LIBSUFFIX ".dll"
+#define LIBPREFIX ""
+
+struct _GModule {
+       HMODULE handle;
+       int main_module;
+};
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+       GModule *module;
+       module = g_malloc (sizeof (GModule));
+       if (module == NULL)
+               return NULL;
+
+       if (file != NULL) {
+               gunichar2 *file16;
+               file16 = u8to16(file); 
+               module->main_module = FALSE;
+               module->handle = LoadLibrary (file16);
+               g_free(file16);
+               if (!module->handle) {
+                       g_free (module);
+                       return NULL;
+               }
+                       
+       } else {
+               module->main_module = TRUE;
+               module->handle = GetModuleHandle (NULL);
+       }
+
+       return module;
+}
+
+static gpointer
+w32_find_symbol (const gchar *symbol_name)
+{
+       HMODULE *modules;
+       DWORD buffer_size = sizeof (HMODULE) * 1024;
+       DWORD needed, i;
+
+       modules = (HMODULE *) g_malloc (buffer_size);
+
+       if (modules == NULL)
+               return NULL;
+
+       if (!EnumProcessModules (GetCurrentProcess (), modules,
+                                buffer_size, &needed)) {
+               g_free (modules);
+               return NULL;
+       }
+
+       /* check whether the supplied buffer was too small, realloc, retry */
+       if (needed > buffer_size) {
+               g_free (modules);
+
+               buffer_size = needed;
+               modules = (HMODULE *) g_malloc (buffer_size);
+
+               if (modules == NULL)
+                       return NULL;
+
+               if (!EnumProcessModules (GetCurrentProcess (), modules,
+                                        buffer_size, &needed)) {
+                       g_free (modules);
+                       return NULL;
+               }
+       }
+
+       for (i = 0; i < needed / sizeof (HANDLE); i++) {
+               gpointer proc = (gpointer)(intptr_t)GetProcAddress (modules [i], symbol_name);
+               if (proc != NULL) {
+                       g_free (modules);
+                       return proc;
+               }
+       }
+
+       g_free (modules);
+       return NULL;
+}
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+       if (module == NULL || symbol_name == NULL || symbol == NULL)
+               return FALSE;
+
+       if (module->main_module) {
+               *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+               if (*symbol != NULL)
+                       return TRUE;
+
+               *symbol = w32_find_symbol (symbol_name);
+               return *symbol != NULL;
+       } else {
+               *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+               return *symbol != NULL;
+       }
+}
+
+const gchar *
+g_module_error (void)
+{
+       gchar* ret = NULL;
+       TCHAR* buf = NULL;
+       DWORD code = GetLastError ();
+
+       FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 
+               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
+
+       ret = u16to8 (buf);
+       LocalFree(buf);
+
+       return ret;
+}
+
+gboolean
+g_module_close (GModule *module)
+{
+       HMODULE handle;
+       int main_module;
+
+       if (module == NULL || module->handle == NULL)
+               return FALSE;
+
+       handle = module->handle;
+       main_module = module->main_module;
+       module->handle = NULL;
+       g_free (module);
+       return (main_module ? 1 : (0 == FreeLibrary (handle)));
+}
+
+#else
+
+#define LIBSUFFIX ""
+#define LIBPREFIX ""
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+       g_error ("%s", "g_module_open not implemented on this platform");
+       return NULL;
+}
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+       g_error ("%s", "g_module_open not implemented on this platform");
+       return FALSE;
+}
+
+const gchar *
+g_module_error (void)
+{
+       g_error ("%s", "g_module_open not implemented on this platform");
+       return NULL;
+}
+
+gboolean
+g_module_close (GModule *module)
+{
+       g_error ("%s", "g_module_open not implemented on this platform");
+       return FALSE;
+}
+#endif
+
+gchar *
+g_module_build_path (const gchar *directory, const gchar *module_name)
+{
+       char *lib_prefix = "";
+       
+       if (module_name == NULL)
+               return NULL;
+
+       if (strncmp (module_name, "lib", 3) != 0)
+               lib_prefix = LIBPREFIX;
+       
+       if (directory && *directory){ 
+               
+               return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name);
+       }
+       return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); 
+}
+
diff --git a/eglib/src/gmodule-win32.c b/eglib/src/gmodule-win32.c
new file mode 100644 (file)
index 0000000..a51d500
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * gmodule.c: dl* functions, glib style
+ *
+ * Author:
+ *   Gonzalo Paniagua Javier (gonzalo@novell.com)
+ *   Jonathan Chambers (joncham@gmail.com)
+ *   Robert Jordan (robertj@gmx.net)
+ *
+ * (C) 2006 Novell, Inc.
+ * (C) 2006 Jonathan Chambers
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <glib.h>
+#include <gmodule.h>
+#include <windows.h>
+#include <psapi.h>
+
+#define LIBSUFFIX ".dll"
+#define LIBPREFIX ""
+
+struct _GModule {
+       HMODULE handle;
+       int main_module;
+};
+
+GModule *
+g_module_open (const gchar *file, GModuleFlags flags)
+{
+       GModule *module;
+       module = g_malloc (sizeof (GModule));
+       if (module == NULL)
+               return NULL;
+
+       if (file != NULL) {
+               gunichar2 *file16;
+               file16 = u8to16(file); 
+               module->main_module = FALSE;
+               module->handle = LoadLibrary (file16);
+               g_free(file16);
+               if (!module->handle) {
+                       g_free (module);
+                       return NULL;
+               }
+                       
+       } else {
+               module->main_module = TRUE;
+               module->handle = GetModuleHandle (NULL);
+       }
+
+       return module;
+}
+
+static gpointer
+w32_find_symbol (const gchar *symbol_name)
+{
+       HMODULE *modules;
+       DWORD buffer_size = sizeof (HMODULE) * 1024;
+       DWORD needed, i;
+
+       modules = (HMODULE *) g_malloc (buffer_size);
+
+       if (modules == NULL)
+               return NULL;
+
+       if (!EnumProcessModules (GetCurrentProcess (), modules,
+                                buffer_size, &needed)) {
+               g_free (modules);
+               return NULL;
+       }
+
+       /* check whether the supplied buffer was too small, realloc, retry */
+       if (needed > buffer_size) {
+               g_free (modules);
+
+               buffer_size = needed;
+               modules = (HMODULE *) g_malloc (buffer_size);
+
+               if (modules == NULL)
+                       return NULL;
+
+               if (!EnumProcessModules (GetCurrentProcess (), modules,
+                                        buffer_size, &needed)) {
+                       g_free (modules);
+                       return NULL;
+               }
+       }
+
+       for (i = 0; i < needed / sizeof (HANDLE); i++) {
+               gpointer proc = (gpointer)(intptr_t)GetProcAddress (modules [i], symbol_name);
+               if (proc != NULL) {
+                       g_free (modules);
+                       return proc;
+               }
+       }
+
+       g_free (modules);
+       return NULL;
+}
+
+gboolean
+g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
+{
+       if (module == NULL || symbol_name == NULL || symbol == NULL)
+               return FALSE;
+
+       if (module->main_module) {
+               *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+               if (*symbol != NULL)
+                       return TRUE;
+
+               *symbol = w32_find_symbol (symbol_name);
+               return *symbol != NULL;
+       } else {
+               *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
+               return *symbol != NULL;
+       }
+}
+
+const gchar *
+g_module_error (void)
+{
+       gchar* ret = NULL;
+       TCHAR* buf = NULL;
+       DWORD code = GetLastError ();
+
+       FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 
+               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
+
+       ret = u16to8 (buf);
+       LocalFree(buf);
+
+       return ret;
+}
+
+gboolean
+g_module_close (GModule *module)
+{
+       HMODULE handle;
+       int main_module;
+
+       if (module == NULL || module->handle == NULL)
+               return FALSE;
+
+       handle = module->handle;
+       main_module = module->main_module;
+       module->handle = NULL;
+       g_free (module);
+       return (main_module ? 1 : (0 == FreeLibrary (handle)));
+}
+
+gchar *
+g_module_build_path (const gchar *directory, const gchar *module_name)
+{
+       char *lib_prefix = "";
+       
+       if (module_name == NULL)
+               return NULL;
+
+       if (strncmp (module_name, "lib", 3) != 0)
+               lib_prefix = LIBPREFIX;
+       
+       if (directory && *directory){ 
+               
+               return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name);
+       }
+       return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); 
+}
diff --git a/eglib/src/gmodule.c b/eglib/src/gmodule.c
deleted file mode 100644 (file)
index f6d2d6b..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * gmodule.c: dl* functions, glib style
- *
- * Author:
- *   Gonzalo Paniagua Javier (gonzalo@novell.com)
- *   Jonathan Chambers (joncham@gmail.com)
- *   Robert Jordan (robertj@gmx.net)
- *
- * (C) 2006 Novell, Inc.
- * (C) 2006 Jonathan Chambers
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#include <glib.h>
-#include <gmodule.h>
-
-#ifdef G_OS_UNIX
-#include <dlfcn.h>
-
-/* For Linux and Solaris, need to add others as we port this */
-#define LIBPREFIX "lib"
-#define LIBSUFFIX ".so"
-
-struct _GModule {
-       void *handle;
-};
-
-GModule *
-g_module_open (const gchar *file, GModuleFlags flags)
-{
-       int f = 0;
-       GModule *module;
-       void *handle;
-       
-       flags &= G_MODULE_BIND_MASK;
-       if ((flags & G_MODULE_BIND_LAZY) != 0)
-               f |= RTLD_LAZY;
-       if ((flags & G_MODULE_BIND_LOCAL) != 0)
-               f |= RTLD_LOCAL;
-
-       handle = dlopen (file, f);
-       if (handle == NULL)
-               return NULL;
-       
-       module = g_new (GModule,1);
-       module->handle = handle;
-       
-       return module;
-}
-
-gboolean
-g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
-{
-       if (symbol_name == NULL || symbol == NULL)
-               return FALSE;
-
-       if (module == NULL || module->handle == NULL)
-               return FALSE;
-
-       *symbol = dlsym (module->handle, symbol_name);
-       return (*symbol != NULL);
-}
-
-const gchar *
-g_module_error (void)
-{
-       return dlerror ();
-}
-
-gboolean
-g_module_close (GModule *module)
-{
-       void *handle;
-       if (module == NULL || module->handle == NULL)
-               return FALSE;
-
-       handle = module->handle;
-       module->handle = NULL;
-       g_free (module);
-       return (0 == dlclose (handle));
-}
-
-#elif defined (G_OS_WIN32)
-#include <windows.h>
-#include <psapi.h>
-
-#define LIBSUFFIX ".dll"
-#define LIBPREFIX ""
-
-struct _GModule {
-       HMODULE handle;
-       int main_module;
-};
-
-GModule *
-g_module_open (const gchar *file, GModuleFlags flags)
-{
-       GModule *module;
-       module = g_malloc (sizeof (GModule));
-       if (module == NULL)
-               return NULL;
-
-       if (file != NULL) {
-               gunichar2 *file16;
-               file16 = u8to16(file); 
-               module->main_module = FALSE;
-               module->handle = LoadLibrary (file16);
-               g_free(file16);
-               if (!module->handle) {
-                       g_free (module);
-                       return NULL;
-               }
-                       
-       } else {
-               module->main_module = TRUE;
-               module->handle = GetModuleHandle (NULL);
-       }
-
-       return module;
-}
-
-static gpointer
-w32_find_symbol (const gchar *symbol_name)
-{
-       HMODULE *modules;
-       DWORD buffer_size = sizeof (HMODULE) * 1024;
-       DWORD needed, i;
-
-       modules = (HMODULE *) g_malloc (buffer_size);
-
-       if (modules == NULL)
-               return NULL;
-
-       if (!EnumProcessModules (GetCurrentProcess (), modules,
-                                buffer_size, &needed)) {
-               g_free (modules);
-               return NULL;
-       }
-
-       /* check whether the supplied buffer was too small, realloc, retry */
-       if (needed > buffer_size) {
-               g_free (modules);
-
-               buffer_size = needed;
-               modules = (HMODULE *) g_malloc (buffer_size);
-
-               if (modules == NULL)
-                       return NULL;
-
-               if (!EnumProcessModules (GetCurrentProcess (), modules,
-                                        buffer_size, &needed)) {
-                       g_free (modules);
-                       return NULL;
-               }
-       }
-
-       for (i = 0; i < needed / sizeof (HANDLE); i++) {
-               gpointer proc = (gpointer)(intptr_t)GetProcAddress (modules [i], symbol_name);
-               if (proc != NULL) {
-                       g_free (modules);
-                       return proc;
-               }
-       }
-
-       g_free (modules);
-       return NULL;
-}
-
-gboolean
-g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
-{
-       if (module == NULL || symbol_name == NULL || symbol == NULL)
-               return FALSE;
-
-       if (module->main_module) {
-               *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
-               if (*symbol != NULL)
-                       return TRUE;
-
-               *symbol = w32_find_symbol (symbol_name);
-               return *symbol != NULL;
-       } else {
-               *symbol = (gpointer)(intptr_t)GetProcAddress (module->handle, symbol_name);
-               return *symbol != NULL;
-       }
-}
-
-const gchar *
-g_module_error (void)
-{
-       gchar* ret = NULL;
-       TCHAR* buf = NULL;
-       DWORD code = GetLastError ();
-
-       FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, 
-               code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 0, NULL);
-
-       ret = u16to8 (buf);
-       LocalFree(buf);
-
-       return ret;
-}
-
-gboolean
-g_module_close (GModule *module)
-{
-       HMODULE handle;
-       int main_module;
-
-       if (module == NULL || module->handle == NULL)
-               return FALSE;
-
-       handle = module->handle;
-       main_module = module->main_module;
-       module->handle = NULL;
-       g_free (module);
-       return (main_module ? 1 : (0 == FreeLibrary (handle)));
-}
-
-#else
-
-#define LIBSUFFIX ""
-#define LIBPREFIX ""
-
-GModule *
-g_module_open (const gchar *file, GModuleFlags flags)
-{
-       g_error ("%s", "g_module_open not implemented on this platform");
-       return NULL;
-}
-
-gboolean
-g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
-{
-       g_error ("%s", "g_module_open not implemented on this platform");
-       return FALSE;
-}
-
-const gchar *
-g_module_error (void)
-{
-       g_error ("%s", "g_module_open not implemented on this platform");
-       return NULL;
-}
-
-gboolean
-g_module_close (GModule *module)
-{
-       g_error ("%s", "g_module_open not implemented on this platform");
-       return FALSE;
-}
-#endif
-
-gchar *
-g_module_build_path (const gchar *directory, const gchar *module_name)
-{
-       char *lib_prefix = "";
-       
-       if (module_name == NULL)
-               return NULL;
-
-       if (strncmp (module_name, "lib", 3) != 0)
-               lib_prefix = LIBPREFIX;
-       
-       if (directory && *directory){ 
-               
-               return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name);
-       }
-       return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); 
-}
index efbf141d4d92db53ea8fb5366c47c7b1da811930..ae52dcfdd7a8f2c7b600fa3ab47bd6341560a637 100644 (file)
@@ -27,4 +27,7 @@ const gchar *g_module_error (void);
 gboolean g_module_close (GModule *module);
 gchar *  g_module_build_path (const gchar *directory, const gchar *module_name);
 
+extern char *gmodule_libprefix;
+extern char *gmodule_libsuffix;
+
 #endif
index 3a5b6463909e61172b1e84ca82a7f38352ee179f..cd2f87f3e513953a62896a0f77c1c8557837caac 100644 (file)
@@ -73,8 +73,11 @@ g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format,
                log_domain != NULL ? ": " : "",
                msg);
        free (msg);
-       if (log_level & fatal)
+       if (log_level & fatal){
+               fflush (stdout);
+               fflush (stderr);
                abort ();
+       }
 }
 
 void