From 549faafc021d87b1c4700294debdf3e4b85ed7e1 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 1 Mar 2000 04:57:07 +0000 Subject: [PATCH] New function that returns the message string for a Win32 error code. 2000-03-04 Tor Lillqvist * 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. --- gmodule/gmodule-win32.c | 39 ++++++++++++++------------------------- gmodule/gmodule.c | 11 ----------- gmodule/libgplugin_a.c | 10 ---------- gmodule/libgplugin_b.c | 10 ---------- 4 files changed, 14 insertions(+), 56 deletions(-) diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c index 8d021e10..5654ce08 100644 --- a/gmodule/gmodule-win32.c +++ b/gmodule/gmodule-win32.c @@ -1,7 +1,7 @@ /* GMODULE - GLIB wrapper code for dynamic module loading * Copyright (C) 1998, 2000 Tim Janik * - * WIN32 GMODULE implementation + * Win32 GMODULE implementation * Copyright (C) 1998 Tor Lillqvist * * This library is free software; you can redistribute it and/or @@ -34,6 +34,15 @@ #include #include +static void +set_error (void) +{ + gchar *error = g_win32_error_message (GetLastError ()); + + g_module_set_error (error); + g_free (error); +} + /* --- functions --- */ static gpointer _g_module_open (const gchar *file_name, @@ -43,13 +52,8 @@ _g_module_open (const gchar *file_name, handle = LoadLibrary (file_name); if (!handle) - { - gchar error[100]; + set_error (); - sprintf (error, "Error code %d", GetLastError ()); - g_module_set_error (error); - } - return handle; } @@ -60,12 +64,7 @@ _g_module_self (void) handle = GetModuleHandle (NULL); if (!handle) - { - gchar error[100]; - - sprintf (error, "Error code %d", GetLastError ()); - g_module_set_error (error); - } + set_error (); return handle; } @@ -75,12 +74,7 @@ _g_module_close (gpointer handle, gboolean is_unref) { if (!FreeLibrary (handle)) - { - gchar error[100]; - - sprintf (error, "Error code %d", GetLastError ()); - g_module_set_error (error); - } + set_error (); } static gpointer @@ -91,13 +85,8 @@ _g_module_symbol (gpointer handle, p = GetProcAddress (handle, symbol_name); if (!p) - { - gchar error[100]; + set_error (); - sprintf (error, "Error code %d", GetLastError ()); - g_module_set_error (error); - } - return p; } diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index dcd04dd9..11bd50cc 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -168,17 +168,6 @@ _g_module_build_path (const gchar *directory, } #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) diff --git a/gmodule/libgplugin_a.c b/gmodule/libgplugin_a.c index 3da2da4a..2a4ced70 100644 --- a/gmodule/libgplugin_a.c +++ b/gmodule/libgplugin_a.c @@ -27,16 +27,6 @@ #include #include -#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 gplugin_a_func (void) { diff --git a/gmodule/libgplugin_b.c b/gmodule/libgplugin_b.c index 109e0485..be2795b6 100644 --- a/gmodule/libgplugin_b.c +++ b/gmodule/libgplugin_b.c @@ -26,16 +26,6 @@ #include -#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_check_init (GModule *module) { -- 2.34.1