NAME
wantread, fwantread - open file for reading

SYNOPSIS
#include <stdio.h>
#include <sys/file.h>

int wantread (searchlist,filename,fullname,prompt);
const char *searchlist,*filename,*fullname,*prompt;

FILE *fwantread (searchlist,filename,fullname,prompt);
const char *searchlist,*filename,*fullname,*prompt;

DESCRIPTION
Wantread attempts to open a file for input, asking the user for an
alternate filename over and over again until a file is successfully
opened for reading.

Searchlist is a list of directories which may contain the file,
with the directory names separated by colons. Filename is the name
of the file the program wishes to open; if filename is the null
string, then the user will be asked immediately for the name of a
file to open. When a file is opened, the complete filename is
copied into fullname, which must be a string provided by the user.

If openp(3) fails to open the desired file, then an error message
is printed along with the message prompt, and the user can type in
an alternate filename. The new file name is searched for using the
same searchlist. The user may also indicate that no file is
acceptable; in this case, wantread will return an error indication.

Fwantread is the same as wantread, but uses fopenp(3) to open a
buffered file, and returns a FILE pointer.

SEE ALSO
openp(3), fopenp(3), wantwrite(3), fwantwrite(3)

DIAGNOSTICS
Wantread returns -1 on error; otherwise, the file descriptor of the
successfully opened file.

Fwantread returns 0 on error, or the FILE pointer of the
successfully fopened file.

BUGS
Fullname must be long enough to hold the complete filename of the
opened file.

There should be a way to change the value of searchlist if the
search for a file is unsuccessful.