]> Savannah Git Hosting - gnulib.git/commitdiff
find_executable: port to EMX
authorKO Myung-Hun <komh78@gmail.com>
Wed, 3 Dec 2014 07:02:50 +0000 (16:02 +0900)
committerEric Blake <eblake@redhat.com>
Mon, 8 Dec 2014 20:45:54 +0000 (13:45 -0700)
* lib/progreloc.c (find_executable): Implement on EMX.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/progreloc.c

index 533add96f2ea5cd735c81555fe611380b643a7e7..3cb3c688b86a5ee8335cb4d45c49b1ee8f894390 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2014-12-08  KO Myung-Hun  <komh78@gmail.com>
 
+       find_executable: port to EMX
+       * lib/progreloc.c (find_executable): Implement on EMX.
+
        sched: check struct sched_param in spawn.h as well
        * lib/sched.in.h: Include spawn.h on kLIBC.
        * lib/sched_h.m4: Check struct sched_param in spawn.h as well.
index 3d7b6a902625775cea0ed2814d7cc7fdf952afee..8a55f6c36442cb4c821835e2bc8ccf6387e45fa2 100644 (file)
 # include <windows.h>
 #endif
 
+#ifdef __EMX__
+# define INCL_DOS
+# include <os2.h>
+#endif
+
 #include "relocatable.h"
 
 #ifdef NO_XMALLOC
@@ -157,6 +162,23 @@ find_executable (const char *argv0)
     /* Shouldn't happen.  */
     return NULL;
   return xstrdup (location);
+#elif defined __EMX__
+  PPIB ppib;
+  char location[CCHMAXPATH];
+
+  /* See http://cyberkinetica.homeunix.net/os2tk45/cp1/619_L2H_DosGetInfoBlocksSynt.html
+     for specification of DosGetInfoBlocks().  */
+  if (DosGetInfoBlocks (NULL, &ppib))
+    return NULL;
+
+  /* See http://cyberkinetica.homeunix.net/os2tk45/cp1/1247_L2H_DosQueryModuleNameSy.html
+     for specification of DosQueryModuleName().  */
+  if (DosQueryModuleName (ppib->pib_hmte, sizeof (location), location))
+    return NULL;
+
+  _fnslashify (location);
+
+  return xstrdup (location);
 #else /* Unix */
 # ifdef __linux__
   /* The executable is accessible as /proc/<pid>/exe.  In newer Linux