NAME
wantwrite, fwantwrite - open file for writing

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

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

FILE *fwantwrite (searchlist,filename,fullname,prompt,warn);
const char *searchlist,*filename,*fullname,*prompt;
int warn;

DESCRIPTION
Wantwrite attempts to open a file for output, asking the user for
an alternate file name over and over again until a file is
successfully opened for writing.

Searchlist is a list of directories which may be 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.

For each directory whose name appears in searchlist, the complete
filename will be formed by contatenating a slash (/) and filename.
Then, an attempt will be made to creat(2) the file. If warn is
TRUE, then a check will first be made to ensure that the file does
not already exist. If it does, the user will be asked if he wants
to delete it; if he says "no", then no attempt will be made to
creat (2) the file and searching will continue with the next
directory.

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

Fwantwrite is the same as wantwrite, but uses fopen(3) to create a
buffered file, and returns a FILE pointer.

SEE ALSO
open(3), fopen(3), searchp(3), wantread(3), fwantread(3)

DIAGNOSTICS
Wantwrite returns -1 on error; otherwise the file descriptor of the
successfully created file.

Fwantwrite returns 0 on error, or the FILE pointer of the
successfully created 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.