% limb manual
% autoopt_parse_buffer_dest(3)
% limb 0.1.0
% 2023-07-24
# NAME
autoopt\_parse\_buffer\_dest - parse destination for an output buffer
# SYNOPSIS
#include <limb/autoopt.h>
```pre hl
int autoopt_parse_buffer_dest(const struct option *<em>option</em>, const char *<em>arg</em>, u8 *<em>lvl</em>)
```
# DESCRIPTION
The `autoopt_parse_buffer_dest`() function parses `arg` to be the destination
for an output buffer. That is, it is expected to be either a file descriptor or
the name of a file that will be opened in append mode, parsed according to
[open_parsed_name](3).
Additionally, it may be prefixed with an at-sign (`@`) followed by an output
level (as described in [obuffer_parse_level](3)) and a colon (`:`), in order to
set the output level to specified level.
It is also possible not to specify a level (i.e. use `@:` as prefix) in order to
have the default level bumped (e.g. from *OLVL_NORMAL* to *OLVL_VERBOSE*).
To specify a file whose name begins with an at-sign, simply use two at-signs at
the beginning of the file.
The `option` argument is only used in case of an error, to include the option's
name in the emitted warning.
The `lvl` argument is expected to point to the default level of the output
buffer, and might be changed according to the parsed `arg`, or set to -1 in case
of error.
# RETURN VALUE
The function return the file descriptor to be used for the output buffer on
success. It can either be the specified file descriptor on `arg`, or - in case
of a file name - the file descriptor of the file opened in append mode.
Otherwise, it returns -1 and sets `errno` to indicate the error.
A warning it also emitted (through the [warn](3) family of functions) describing
the error.
# ERRORS
The function may fail if :
: *EINVAL*
:: Invalid output level specified, in which case the value pointed by `lvl` is
:: set to -1
It may also fail for the errors described for [open_parsed_name](3) and
[open_append](3).