aboutsummaryrefslogtreecommitdiffstats
path: root/findexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'findexec.c')
-rw-r--r--findexec.c125
1 files changed, 74 insertions, 51 deletions
diff --git a/findexec.c b/findexec.c
index b6d648b..4992775 100644
--- a/findexec.c
+++ b/findexec.c
@@ -37,54 +37,72 @@ Wed Feb 21 23:06:35 1996 Aubrey Jaffer <jaffer@jacal.bertronics>
filename. A new copy of the complete path name of that file is
returned. This new string may be disposed by free() later on. */
-#include <sys/file.h>
-#include <sys/param.h>
-#ifdef linux
-# include <stdlib.h>
-# include <sys/stat.h>
-# include <unistd.h> /* for X_OK define */
-#endif
-#ifdef __svr4__
-# include <string.h>
-# include <stdlib.h>
-# include <sys/stat.h>
-# include <unistd.h> /* for X_OK define */
-#else
-# ifdef __sgi__
+#ifndef __MINGW32__
+# ifndef PLAN9
+# include <sys/file.h>
+# include <sys/param.h>
+# endif
+# ifdef linux
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <unistd.h> /* for X_OK define */
+# endif
+# ifdef __SVR4
# include <string.h>
# include <stdlib.h>
# include <sys/stat.h>
# include <unistd.h> /* for X_OK define */
# else
-# include <strings.h>
+# ifdef __sgi__
+# include <string.h>
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <unistd.h> /* for X_OK define */
+# else
+# ifdef PLAN9
+# include <u.h>
+# include <libc.h>
+# define getcwd getwd
+# define MAXPATHLEN 256 /* arbitrary? */
+# define X_OK AEXEC
+# else
+# include <strings.h>
+# endif
+# endif
+# endif
+# ifdef __amigaos__
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <unistd.h>
+# endif
+# ifndef __STDC__
+# define const /**/
+# endif
+# ifdef __FreeBSD__
+/* This might be same for 44bsd derived system. */
+# include <sys/types.h>
+# include <sys/stat.h>
# endif
-#endif
-#ifdef __amigados__
-# include <stdlib.h>
-# include <sys/stat.h>
-# include <unistd.h>
-#endif
-#ifndef __STDC__
-# define const /**/
-#endif
-#ifdef __FreeBSD__
+# ifdef __OpenBSD__
/* This might be same for 44bsd derived system. */
-# include <sys/types.h>
-# include <sys/stat.h>
-#endif
-#ifdef __alpha
-# include <string.h>
-# include <stdlib.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-#endif
-#ifdef GO32
-# include <sys/stat.h>
-#endif
-
-#ifndef DEFAULT_PATH
-# define DEFAULT_PATH ".:~/bin::/usr/local/bin:/usr/new:/usr/ucb:/usr/bin:/bin:/usr/hosts"
-#endif
+# include <stdlib.h>
+# include <unistd.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# endif
+# ifdef __alpha
+# include <string.h>
+# include <stdlib.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# endif
+# ifdef GO32
+# include <sys/stat.h>
+# endif
+
+# ifndef DEFAULT_PATH
+# define DEFAULT_PATH ".:~/bin::/usr/local/bin:/usr/new:/usr/ucb:/usr/bin:/bin:/usr/hosts"
+# endif
static char *copy_of(s)
register const char *s;
@@ -97,12 +115,12 @@ static char *copy_of(s)
}
/* ABSOLUTE_FILENAME_P(fname): True if fname is an absolute filename */
-#ifdef atarist
-# define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \
+# ifdef atarist
+# define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \
(fname[0] && (fname[1] == ':')))
-#else
-# define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
-#endif /* atarist */
+# else
+# define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
+# endif /* atarist */
char *dld_find_executable(name)
const char *name;
@@ -155,16 +173,21 @@ char *dld_find_executable(name)
strcat(tbuf, name);
if (access(tbuf, X_OK) == 0) {
-#ifndef hpux
-# ifndef ultrix
+# ifndef hpux
+# ifndef ultrix
+# ifndef __MACH__
+# ifndef PLAN9
struct stat stat_temp;
- if (stat(tbuf,&stat_temp)) continue;
+ if (stat(tbuf, &stat_temp)) continue;
if (S_IFREG != (S_IFMT & stat_temp.st_mode)) continue;
-# endif/* ultrix */
-#endif /* hpux */
+# endif /* PLAN9 */
+# endif /* __MACH__ */
+# endif/* ultrix */
+# endif /* hpux */
return copy_of(tbuf);
}
}
return 0;
}
+#endif /* ndef MSDOS */