New function that returns the message string for a Win32 error code.

2000-03-04  Tor Lillqvist  <tml@iki.fi>

* gwin32.c (g_win32_error_message): New function that returns the
message string for a Win32 error code.

* glib.h: Declare it.

* glib.def: Export it, plus g_node_copy.

* gmodule-win32.c: Call g_win32_error_message() to get the error
message strings.

* libgplugin_a.c
* libgplugin_b.c
* gmodule.c: Remove LibMain functions that were needed by LCC,
which is not a supported compiler.

* testgmodule.c (main): Test for G_MODULE_IMPL ==
G_MODULE_IMPL_WIN32, not G_OS_WIN32.

* gmoduleconf.h.win32: Remove LCC stuff from here, too.
This commit is contained in:
Tor Lillqvist 2000-03-01 04:57:07 +00:00 committed by Tor Lillqvist
parent 5991248acf
commit 549faafc02
4 changed files with 14 additions and 56 deletions

View File

@ -1,7 +1,7 @@
/* GMODULE - GLIB wrapper code for dynamic module loading /* GMODULE - GLIB wrapper code for dynamic module loading
* Copyright (C) 1998, 2000 Tim Janik * Copyright (C) 1998, 2000 Tim Janik
* *
* WIN32 GMODULE implementation * Win32 GMODULE implementation
* Copyright (C) 1998 Tor Lillqvist * Copyright (C) 1998 Tor Lillqvist
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -34,6 +34,15 @@
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <windows.h>
static void
set_error (void)
{
gchar *error = g_win32_error_message (GetLastError ());
g_module_set_error (error);
g_free (error);
}
/* --- functions --- */ /* --- functions --- */
static gpointer static gpointer
_g_module_open (const gchar *file_name, _g_module_open (const gchar *file_name,
@ -43,13 +52,8 @@ _g_module_open (const gchar *file_name,
handle = LoadLibrary (file_name); handle = LoadLibrary (file_name);
if (!handle) if (!handle)
{ set_error ();
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
return handle; return handle;
} }
@ -60,12 +64,7 @@ _g_module_self (void)
handle = GetModuleHandle (NULL); handle = GetModuleHandle (NULL);
if (!handle) if (!handle)
{ set_error ();
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
return handle; return handle;
} }
@ -75,12 +74,7 @@ _g_module_close (gpointer handle,
gboolean is_unref) gboolean is_unref)
{ {
if (!FreeLibrary (handle)) if (!FreeLibrary (handle))
{ set_error ();
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
} }
static gpointer static gpointer
@ -91,13 +85,8 @@ _g_module_symbol (gpointer handle,
p = GetProcAddress (handle, symbol_name); p = GetProcAddress (handle, symbol_name);
if (!p) if (!p)
{ set_error ();
gchar error[100];
sprintf (error, "Error code %d", GetLastError ());
g_module_set_error (error);
}
return p; return p;
} }

View File

@ -168,17 +168,6 @@ _g_module_build_path (const gchar *directory,
} }
#endif /* no implementation */ #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 --- */ /* --- functions --- */
gboolean gboolean
g_module_supported (void) g_module_supported (void)

View File

@ -27,16 +27,6 @@
#include <gmodule.h> #include <gmodule.h>
#include <stdlib.h> #include <stdlib.h>
#if defined (NATIVE_WIN32) && defined (__LCC__)
int __stdcall
LibMain(void *hinstDll,
unsigned long dwReason,
void *reserved)
{
return 1;
}
#endif /* NATIVE_WIN32 && __LCC__ */
G_MODULE_EXPORT void G_MODULE_EXPORT void
gplugin_a_func (void) gplugin_a_func (void)
{ {

View File

@ -26,16 +26,6 @@
#include <gmodule.h> #include <gmodule.h>
#if defined (NATIVE_WIN32) && defined (__LCC__)
int __stdcall
LibMain(void *hinstDll,
unsigned long dwReason,
void *reserved)
{
return 1;
}
#endif /* NATIVE_WIN32 && __LCC__ */
G_MODULE_EXPORT const gchar* G_MODULE_EXPORT const gchar*
g_module_check_init (GModule *module) g_module_check_init (GModule *module)
{ {