2 * Copyright (C) 1998 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
44 /* access macros are not declared in non posix mode in unistd.h -
45 don't try to use posix on NeXTstep 3.3 ! */
55 char * findProgramPath(char * argv0) {
56 char * path = getenv("PATH");
58 char * start, * chptr;
61 /* If there is a / in the argv[0], it has to be an absolute
63 if (strchr(argv0, '/'))
66 if (!path) return NULL;
68 start = pathbuf = alloca(strlen(path) + 1);
69 buf = malloc(strlen(path) + strlen(argv0) + 2);
70 strcpy(pathbuf, path);
74 if ((chptr = strchr(start, ':')))
76 sprintf(buf, "%s/%s", start, argv0);
78 if (!access(buf, X_OK))
85 } while (start && *start);