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 */
9 #include "poptalloca.h"
17 /* access macros are not declared in non posix mode in unistd.h -
18 don't try to use posix on NeXTstep 3.3 ! */
24 char * findProgramPath(char * argv0
) {
25 char * path
= getenv("PATH");
27 char * start
, * chptr
;
30 /* If there is a / in the argv[0], it has to be an absolute
32 if (strchr(argv0
, '/'))
35 if (!path
) return NULL
;
37 start
= pathbuf
= alloca(strlen(path
) + 1);
38 buf
= malloc(strlen(path
) + strlen(argv0
) + 2);
39 strcpy(pathbuf
, path
);
43 if ((chptr
= strchr(start
, ':')))
45 sprintf(buf
, "%s/%s", start
, argv0
);
47 if (!access(buf
, X_OK
))
54 } while (start
&& *start
);