Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / readopt.h / readopt.3.md

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

# NAME

readopt - read option from configuration directory

# SYNOPSIS

    #include <limb/readopt.h>

```pre hl
ssize_t readopt(char *<em>dst</em>, size_t <em>dlen</em>, int <em>fd</em>, const char *<em>name</em>)
```

# DESCRIPTION

The `readopt`() function will read the first line from file `name` and write it
into the memory pointed by `dst`, up to `dlen` bytes.

If `name` 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.

# RETURN VALUE

On success the function returns the number of bytes written into `dst` (which is
/not/ NUL-terminated). Otherwise, it returns -1 and sets `errno` to indicate the
error.

# ERRORS

This function may fail if :

: *ENOBUFS*
:: Not enough space in `dst` to write the full first line of the file.

This function may also fail for the errors described for [open_read_closeat](3).