Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / djbunix.h / open_parsed_name.3.md

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

# NAME

open_parsed_name - return given file descriptor, or opened file

# SYNOPSIS

    #include <limb/djbunix.h>

```pre hl
typedef int (*open_fn) (const char *file)

int open_parsed_name(const char *<em>name</em>, open_fn <em>open</em>)
```

# DESCRIPTION

The `open_parsed_name`() function parses `name` which is either a file name, or
a file descriptor.

In the later case, it must begins with a plus-sign (`+`) before the number of
the file descriptor, which will be returned.

In the former case, the file name will simply be passed to `open` which shall
open said file and return the resulting file descriptor, or -1 in case of error,
setting `errno` to indicate the error..

To specify a file whose name begins with a plus sign, simply use two plus-signs
as beginning of the file.

# RETURN VALUE

Upon successful completion, this function return the specified file descriptor,
or the file descriptor of the opened file. Otherwise, it returns -1 and sets
`errno` to indicate the error.

# ERRORS

This function may fail for the errors described for [u16_scan0](3) (when parsing
the file descriptor), or those for `open`.