NAME
open_read_closeat, open_read_close, open_saread_closeat, open_saread_close - open, read & close a file
SYNOPSIS
#include <limb/djbunix.h>
ssize_t open_read_closeat(char *dst, size_t dlen, int fd, const char *file) ssize_t open_read_close(char *dst, size_t dlen, const char *file) int open_saread_closeat(stralloc *sa, int fd, const char *file) int open_saread_close(stralloc *sa, const char *file)
DESCRIPTION
The open_read_closeat() function will open the file named file for reading
in blocking mode. If file describes a relative path, it is relative to the
directory associated with the file descriptor fd, which may be AT_FDCWD to
use the current working directory.
The content of the file will be read and copied into the memory pointed by dst
up to a maximum of dlen bytes, and the file be closed.
The open_read_close() macro is similar to open_read_closeat() only relative
paths are relative to the current working directory.
The open_saread_closeat() function is to open_read_closeat(), except the
entirety of the file will be placed into the stralloc pointed by sa,
allocating as much memory as needed.
The open_saread_close() macro is similar to open_saread_closeat() only
relative paths are relative to the current working directory.
RETURN VALUE
The open_read_close() and open_read_closeat() functions return the amount of
data read from the file, and written into dst, on success. Otherwise they
return -1 and set errno to indicate the error.
The open_saread_close() and open_saread_closeat() functions return 1 on
success. Otherwise they return 0 and set errno to indicate the error.
ERRORS
These functions may fail and set errno for the errors described for
openb_readat(3).
The open_read_close() and open_read_closeat() functions may also fail if :
ENOBUFS
Not enough space available in dst to store the entire file.
The open_read_close() and open_read_closeat() functions may also fail and
set errno for the errors described for allread(3).
The open_saread_close() and open_saread_closeat() fucntions may also fail
and set errno for the errors described for sa_read(3).