Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / djbunix.h / sa_readlinkat.3.md

% limb manual
% sa_readlinkat(3)
% limb 0.1.0
% 2023-07-24

# 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>

```pre hl
int sa_readlinkat(stralloc *<em>sa</em>, int <em>fd</em>, const char *<em>file</em>)
int sa_readlinkat0(stralloc *<em>sa</em>, int <em>fd</em>, const char *<em>file</em>)

int sa_readlink(stralloc *<em>sa</em>, const char *<em>file</em>)
int sa_readlink0(stralloc *<em>sa</em>, const char *<em>file</em>)
```

# 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).