1 /* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING
2 file accompanying popt source distributions, available from
3 ftp://ftp.redhat.com/pub/code/popt */
14 /* access macros are not declared in non posix mode in unistd.h -
15 don't try to use posix on NeXTstep 3.3 ! */
25 char * findProgramPath(char * argv0) {
26 char * path = getenv("PATH");
28 char * start, * chptr;
31 /* If there is a / in the argv[0], it has to be an absolute
33 if (strchr(argv0, '/'))
36 if (!path) return NULL;
38 start = pathbuf = alloca(strlen(path) + 1);
39 buf = malloc(strlen(path) + strlen(argv0) + 2);
40 strcpy(pathbuf, path);
44 if ((chptr = strchr(start, ':')))
46 sprintf(buf, "%s/%s", start, argv0);
48 if (!access(buf, X_OK))
55 } while (start && *start);