NAME
searchp - search for file using searchlist

SYNOPSIS
int searchp (searchlist,filename,buffer,function);
char *searchlist,*filename,*buffer;
int (*function)();

DESCRIPTION
Searchp looks for an acceptable filename by concatenating a name
onto each directory name within a given searchlist.

Searchlist is a list of directory names, separated by colons (:).
Searchp will parse these names, prepending each in turn to
filename, the name of the file being sought. The resulting
pathname is passed as an argument to function, a function provided
by the user. This function will receive one parameter -- the
pathname -- and must return an integer telling whether this
filename is acceptable or not. If a non-zero value is returned,
then the search continues with the next directory name from
searchlist. If the value 0 is returned, then searching stops. In
this case, the full filename is copied into the string buffer, and
searchp returns 0.

If all the directories are unsuccessfully searched, then searchp
returns the value -1.

If filename begins with a slash, it is assumed to be an absolute
pathname and searchlist is not used.

SEE ALSO
openp(3), fopenp(3), wantread(3), wantwrite(3), fwantread(3),
fwantwrite(3), execlp(3), execvp(3), runp(3), runvp(3)

DIAGNOSTICS
-1 is returned if no filename is satisfactory; 0 otherwise.

BUGS
UNIX from Bell Labs uses three different searching algorithms in
three different contexts. In the SHELL, executable programs are
sought, but are considered absolute pathnames if they contain a
slash, even if it is not the first character (bogus, in my opinion
-- sas). The routines execvp and execlp use the same rule, but
also accept the minus sign (-) as a separator in the pathlist. The
C compiler, in searching for macro files, uses the rule of searchp
-- a filename is only absolute if it begins with a slash.

Users normally do not need to use searchp; there are other,
higher-level routines (runp, runvp, openp, fopenp) which should
normally be used. There are, however, occasions in which such
routines are not powerful enough; then, searchp is appropriate.