Hi/2.

Bruno Haible wrote:
> KO Myung-Hun wrote:
>>>> +        if (DosQueryModuleName (hModule, sizeof (location), location))
>>>
>>> Can you add a comment with the URL of the specification of the
>>> DosQueryModuleName function (if possible), please?
>>
>> See
>>
>> http://cyberkinetica.homeunix.net/os2tk45/cp1/1247_L2H_DosQueryModuleNameSy.html
> 
> Thanks. Can you please add this URL as a comment in the patch? For future
> reference.
> 

Of course. Added.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

>From 497ab87be2ca2fc7c907c4f416f42cf5df4a7b3a Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <k...@chollian.net>
Date: Tue, 30 Apr 2013 22:06:01 +0900
Subject: [PATCH] get_shared_library_fullname: port to EMX

* lib/relocatable.c: Define strcmp and strncmp to stricmp and strnicmp
on EMX, respectively.
(_DLL_InitTerm): New on EMX.
(get_shared_library_fullname): Implement on EMX.
---
 lib/relocatable.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 3 deletions(-)

diff --git a/lib/relocatable.c b/lib/relocatable.c
index 81dcaeb..b51f5f4 100644
--- a/lib/relocatable.c
+++ b/lib/relocatable.c
@@ -47,6 +47,14 @@
 # include <windows.h>
 #endif
 
+#ifdef __EMX__
+# define INCL_DOS
+# include <os2.h>
+
+# define strcmp  stricmp
+# define strncmp strnicmp
+#endif
+
 #if DEPENDS_ON_LIBCHARSET
 # include <libcharset.h>
 #endif
@@ -335,6 +343,45 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID 
reserved)
   return TRUE;
 }
 
+#elif defined __EMX__
+
+extern int  _CRT_init (void);
+extern void _CRT_term (void);
+extern void __ctordtorInit (void);
+extern void __ctordtorTerm (void);
+
+unsigned long _System
+_DLL_InitTerm (unsigned long hModule, unsigned long ulFlag)
+{
+  static char location[CCHMAXPATH];
+
+  switch (ulFlag)
+    {
+      case 0:
+        if (_CRT_init () == -1)
+          return 0;
+
+        __ctordtorInit();
+
+        /* See 
http://cyberkinetica.homeunix.net/os2tk45/cp1/1247_L2H_DosQueryModuleNameSy.html
+           for specifications of DosQueryModuleName(). */
+        if (DosQueryModuleName (hModule, sizeof (location), location))
+          return 0;
+
+        _fnslashify (location);
+        shared_library_fullname = strdup (location);
+        break;
+
+      case 1:
+        __ctordtorTerm();
+
+        _CRT_term ();
+        break;
+    }
+
+  return 1;
+}
+
 #else /* Unix */
 
 static void
@@ -390,15 +437,16 @@ find_shared_library_fullname ()
 #endif
 }
 
-#endif /* Native Windows / Unix */
+#endif /* Native Windows / EMX / Unix */
 
 /* Return the full pathname of the current shared library.
    Return NULL if unknown.
-   Guaranteed to work only on Linux, Cygwin, and native Windows.  */
+   Guaranteed to work only on Linux, EMX, Cygwin, and native Windows.  */
 static char *
 get_shared_library_fullname ()
 {
-#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
+#if (!((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) \
+     && !defined __EMX__)
   static bool tried_find_shared_library_fullname;
   if (!tried_find_shared_library_fullname)
     {
-- 
1.8.5.2

Reply via email to