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 */
8 /* access macros are not declared in non posix mode in unistd.h -
9 don't try to use posix on NeXTstep 3.3 ! */
15 char * findProgramPath(char * argv0) {
16 char * path = getenv("PATH");
18 char * start, * chptr;
21 /* If there is a / in the argv[0], it has to be an absolute
23 if (strchr(argv0, '/'))
24 return g_strdup(argv0);
26 if (!path) return NULL;
28 start = pathbuf = g_strdup(path);
29 buf = g_malloc(strlen(path) + strlen(argv0) + 2);
33 if ((chptr = strchr(start, ':')))
35 sprintf(buf, "%s/%s", start, argv0);
38 if (!access(buf, X_OK)) {
48 } while (start && *start);