NAME
sa_readlink, sa_readlinkat, sa_readlink0, sa_readlinkat0 - read the content of a symbolic link into a stralloc
SYNOPSIS
#include <fcntl.h> /* AT_FDCWD */ #include <limb/djbunix.h>
int sa_readlinkat(stralloc *sa, int fd, const char *file) int sa_readlinkat0(stralloc *sa, int fd, const char *file) int sa_readlink(stralloc *sa, const char *file) int sa_readlink0(stralloc *sa, const char *file)
DESCRIPTION
The sa_readlinkat
() function places the content of the symbolic link referred
to by file
in the stralloc sa
. If file
specifies 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.
For more details, refer to readlinkat(3).
The sa_readlinkat0
() function is similar to sa_readlinkat
() except that it
ensures the content placed in sa
is NUL-terminated.
The sa_readlink
() macro is similar to sa_readlinkat
() except when file
specifies a relative path, in which case it is relative to the current working
directory.
The sa_readlink0
() macro is similar to sa_readlinkat0
() except when file
specifies a relative path, in which case it is relative to the current working
directory.
RETURN VALUE
On success these functions return 0. Otherwise they return -1 and set errno
to
indicate the error.
ERRORS
These functions may fail if:
ENOMEM
Insufficient memory available to grow sa
They may also fail and set errno
for any of the errors specified for the
function readlinkat(3).