|
|
#include <prototypes.h>int defopen(filename) char *filename;
char *defread(pattern) char *pattern;
int defcntl(int req, int arg)
defopen( ) opens the default file named by the pathname in filename. defopen( ) returns null if it is successful in opening the file, or the fopen failure code (errno) if the open fails.
defread( ) reads the previously opened file from the beginning until it encounters a line beginning with pattern. defread( ) then returns a pointer to the first character in the line after the initial pattern. If a trailing newline character is read it is replaced by a null byte.
defcntl( ) gets or sets the flags controlling how the defread( ) operation works. req can be set to either of the following:
The return value is the previous value of the flags. Note that these flags are defined internally and not in a header file.
When all items of interest have been extracted from the opened file the program may call defopen with the name of another file to be searched, or it may call defopen with NULL, which closes the default file without opening another.
defread( ) returns NULL if a default file is not open, if the indicated pattern could not be found, or if it encounters any line in the file greater than the maximum length of 128 characters.
defcntl( ) returns the previous value of flags on success, or -1 on error.