version 1.18, 2003/04/19 17:22:29 |
version 1.19, 2003/05/06 21:52:25 |
|
|
extern char *searchpath(path) |
extern char *searchpath(path) |
char *path; |
char *path; |
{ |
{ |
char *cp; |
|
char *file; |
char *file; |
|
char *space; |
|
int found; |
struct stat statbuf; |
struct stat statbuf; |
|
|
for (; ;) { |
for (found = 0; !found && (file = strsep(&path, ":")) != NULL; ) { |
if (!path) |
if ((space = strchr(file, ' ')) != NULL) |
return(NULL); |
*space = CNULL; |
file = path; |
found = stat(file, &statbuf) == 0; |
cp = strchr(path, ':'); |
if (space) |
if (cp) { |
*space = ' '; /* Put back what we zapped */ |
path = cp + 1; |
|
*cp = CNULL; |
|
} else |
|
path = NULL; |
|
if (stat(file, &statbuf) == 0) |
|
return(file); |
|
/* Put back what we zapped */ |
|
if (path) |
|
*cp = ':'; |
|
} |
} |
|
return (file); |
} |
} |
|
|
/* |
/* |