Updated Galician Translation
[platform/upstream/glib.git] / gmodule / gmodule-win32.c
index 099f96a..3e8fe02 100644 (file)
@@ -5,23 +5,23 @@
  * Copyright (C) 1998 Tor Lillqvist
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
 
 /*
- * Modified by the GLib Team and others 1997-1999.  See the AUTHORS
+ * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GLib Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
 
 #include <stdio.h>
 #include <windows.h>
-#include <psapi.h>
+
 #include <tlhelp32.h>
 
+#ifdef G_WITH_CYGWIN
+#include <sys/cygwin.h>
+#endif
+
 static void
 set_error (void)
 {
@@ -48,11 +52,22 @@ set_error (void)
 /* --- functions --- */
 static gpointer
 _g_module_open (const gchar *file_name,
-               gboolean     bind_lazy)
+               gboolean     bind_lazy,
+               gboolean     bind_local)
 {
   HINSTANCE handle;
-  
-  handle = LoadLibrary (file_name);
+  wchar_t *wfilename;
+#ifdef G_WITH_CYGWIN
+  gchar tmp[MAX_PATH];
+
+  cygwin_conv_to_win32_path(file_name, tmp);
+  file_name = tmp;
+#endif
+  wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL);
+
+  handle = LoadLibraryW (wfilename);
+  g_free (wfilename);
+      
   if (!handle)
     set_error ();
 
@@ -83,10 +98,10 @@ find_in_any_module_using_toolhelp (const gchar *symbol_name)
   typedef HANDLE (WINAPI *PFNCREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
   static PFNCREATETOOLHELP32SNAPSHOT pfnCreateToolhelp32Snapshot = NULL;
 
-  typedef BOOL (WINAPI *PFNMODULE32FIRST)(HANDLE, LPMODULEENTRY32);
+  typedef BOOL (WINAPI *PFNMODULE32FIRST)(HANDLE, MODULEENTRY32*);
   static PFNMODULE32FIRST pfnModule32First= NULL;
 
-  typedef BOOL (WINAPI *PFNMODULE32NEXT)(HANDLE, LPMODULEENTRY32);
+  typedef BOOL (WINAPI *PFNMODULE32NEXT)(HANDLE, MODULEENTRY32*);
   static PFNMODULE32NEXT pfnModule32Next = NULL;
 
   static HMODULE kernel32;
@@ -213,15 +228,34 @@ _g_module_build_path (const gchar *directory,
                      const gchar *module_name)
 {
   gint k;
-  
+
   k = strlen (module_name);
+    
   if (directory && *directory)
-    if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
-      return g_strconcat (directory, "\\", module_name, NULL);
+    if (k > 4 && g_ascii_strcasecmp (module_name + k - 4, ".dll") == 0)
+      return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, NULL);
+#ifdef G_WITH_CYGWIN
+    else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "cyg", 3) == 0)
+      return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, ".dll", NULL);
+    else
+      return g_strconcat (directory, G_DIR_SEPARATOR_S, "cyg", module_name, ".dll", NULL);
+#else
+    else if (strncmp (module_name, "lib", 3) == 0)
+      return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, ".dll", NULL);
     else
-      return g_strconcat (directory, "\\", module_name, ".dll", NULL);
-  else if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
+      return g_strconcat (directory, G_DIR_SEPARATOR_S, "lib", module_name, ".dll", NULL);
+#endif
+  else if (k > 4 && g_ascii_strcasecmp (module_name + k - 4, ".dll") == 0)
     return g_strdup (module_name);
+#ifdef G_WITH_CYGWIN
+  else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "cyg", 3) == 0)
+    return g_strconcat (module_name, ".dll", NULL);
   else
+    return g_strconcat ("cyg", module_name, ".dll", NULL);
+#else
+  else if (strncmp (module_name, "lib", 3) == 0)
     return g_strconcat (module_name, ".dll", NULL);
+  else
+    return g_strconcat ("lib", module_name, ".dll", NULL);
+#endif
 }