/* GMODULE - GLIB wrapper code for dynamic module loading
- * Copyright (C) 1998 Tim Janik
+ * Copyright (C) 1998, 2000 Tim Janik
+ *
+ * WIN32 GMODULE implementation
* Copyright (C) 1998 Tor Lillqvist
*
* This library is free software; you can redistribute it and/or
/* --- functions --- */
static gpointer
-_g_module_open (const gchar *file_name,
- gboolean bind_lazy)
+_g_module_open (const gchar *file_name,
+ gboolean bind_lazy)
{
HINSTANCE handle;
handle = LoadLibrary (file_name);
if (!handle)
{
- char error[100];
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
- 0, error, sizeof (error), NULL);
+ gchar error[100];
+
+ sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
handle = GetModuleHandle (NULL);
if (!handle)
{
- char error[100];
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
- 0, error, sizeof (error), NULL);
+ gchar error[100];
+
+ sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
}
static void
-_g_module_close (gpointer handle,
- gboolean is_unref)
+_g_module_close (gpointer handle,
+ gboolean is_unref)
{
if (!FreeLibrary (handle))
{
- char error[100];
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
- 0, error, sizeof (error), NULL);
+ gchar error[100];
+
+ sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
}
static gpointer
-_g_module_symbol (gpointer handle,
- const gchar *symbol_name)
+_g_module_symbol (gpointer handle,
+ const gchar *symbol_name)
{
gpointer p;
p = GetProcAddress (handle, symbol_name);
if (!p)
{
- char error[100];
- FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError (),
- 0, error, sizeof (error), NULL);
+ gchar error[100];
+
+ sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
+
return p;
}
const gchar *module_name)
{
gint k;
-
+
k = strlen (module_name);
if (directory && *directory)
if (k > 4 && g_strcasecmp (module_name + k - 4, ".dll") == 0)
#include "gmodule-dld.c"
#elif (G_MODULE_IMPL == G_MODULE_IMPL_WIN32)
#include "gmodule-win32.c"
-#elif (G_MODULE_IMPL == G_MODULE_IMPL_OS2)
-#include "gmodule-os2.c"
-#elif (G_MODULE_IMPL == G_MODULE_IMPL_BEOS)
-#include "gmodule-beos.c"
#else
#undef SUPPORT_OR_RETURN
#define SUPPORT_OR_RETURN(rv) { g_module_set_error ("dynamic modules are " \
}
#endif /* no implementation */
+#if defined (NATIVE_WIN32) && defined (__LCC__)
+int __stdcall
+LibMain (void *hinstDll,
+ unsigned long dwReason,
+ void *reserved)
+{
+ return 1;
+}
+#endif /* NATIVE_WIN32 && __LCC__ */
+
+
/* --- functions --- */
gboolean
g_module_supported (void)
/* check initialization */
if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init))
- if (check_init)
- check_failed = check_init (module);
+ check_failed = check_init (module);
/* we don't call unload() if the initialization check failed. */
if (!check_failed)
*symbol = _g_module_symbol (module->handle, symbol_name);
#endif /* !G_MODULE_NEED_USCORE */
- module_error = g_module_error();
+ module_error = g_module_error ();
if (module_error)
{
gchar *error;
g_module_set_error (error);
g_free (error);
*symbol = NULL;
+
return FALSE;
}