>From e0c96755bd69ced4cfaaed608460d86d35791e7a Mon Sep 17 00:00:00 2001
From: KO Myung-Hun
Date: Tue, 30 Apr 2013 22:01:05 +0900
Subject: [PATCH] find_executable: port to EMX
* lib/progreloc.c (find_executable): Implement on EMX.
---
lib/progreloc.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/lib/progreloc.c b/lib/progreloc.c
index 3d7b6a9..73d4abb 100644
--- a/lib/progreloc.c
+++ b/lib/progreloc.c
@@ -44,6 +44,11 @@
# include
#endif
+#ifdef __EMX__
+# define INCL_DOS
+# include
+#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 specifications of DosGetInfoBlocks(). */
+ if (DosGetInfoBlocks (NULL, &ppib))
+ return NULL;
+
+ /* See http://cyberkinetica.homeunix.net/os2tk45/cp1/1247_L2H_DosQueryModuleNameSy.html
+ for specifications 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//exe. In newer Linux
--
1.8.5.2