Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / cdb.h / cdb_init.3.md

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

# NAME

cdb_init, cdb_initat, cdb_init_fromfd - initialize a cdb

# SYNOPSIS

    #include <limb/cdb.h>

```pre hl
int cdb_init(cdb *<em>c</em>, const char *<em>file</em>)
int cdb_initat(cdb *<em>c</em>, int <em>dfd</em>, const char *<em>file</em>)
int cdb_init_fromfd(cdb *<em>c</em>, int <em>fd</em>)
```

# DESCRIPTION

The `cdb_init`() function initializes the cdb pointed to by `c`, which
must be `CDB_ZERO` before the call, by mapping the file named `file`, which must
be a valid cdb.

The `cdb_initat`() function is similar to `cdb_init`() except when `file` refer
to a relative path, in which case it is relative to the directory described by
the file descriptor `dfd`.

The `cdb_init_fromfd`() function is similar to `cdb_init`() except that the file
must already be opened and readable via file descriptor `fd`.

# RETURN VALUE

These functions return 1 on success. Otherwise, they return 0 and set `errno` to
indicate the error.

# ERRORS

These functions may fail if :

: *EOVERFLOW*
:: The file is too large. A cdb database must be under 4 GiB.

They may also fail and set `errno` for the errors described for [fstat](3) and
[mmap](3).

The `cdb_init`() function may also fail and set `errno` for the errors described
for [openc_read](3).

The `cdb_initat`() function may also fail and set `errno` for the errors
described for [openc_readat](3).

# SEE ALSO

[cdb_init_frommem](3)