openp, fopenp - search for file and open it

#include <sys/file.h>
int openp (searchlist, path, buffer, flags, mode);
const char *searchlist, *path;
char *buffer;
int flags, mode;

#include <sys/file.h>
#include <stdio.h>
FILE *fopenp (searchlist,path,buffer,type);
const char *searchlist, *path;
char *buffer ,*type;

Openp and fopenp use searchp(3) to search for a file, and open the
file when and if it is found. The value returned will be the
normal value of open(2) or fopen(3) -- a file descriptor or FILE
pointer on success, and a -1 or a 0 on failure.

Searchlist is assumed to be a list of directory path names
separated by colons; one by one, these names are parsed and
concatenated (with a separating slash) onto path to form a complete
file path name. An attempt is then made to open the file with this
name; if successful, openp and fopenp return with a success
indication; otherwise, searching continues. If success is
achieved, then the resulting pathname is copied into the string
buffer, provided by the user. The open and fopen calls are made
with the appropriate mode, flags and type as specified by the
parameter. The open(2) and fopen(3) define what mode, flags and
type should be respectively.

searchp(3), open(2), fopen(3), wantread(3), wantwrite(3),
fwantread(3), fwantwrite(3)

Openp returns -1 on error (no openable file found); fopenp returns