---
name: "dnv"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/dnv"
---

# dnv(9)

API for getting name/value pairs with a default value

## NAME

**dnvlist\_get**, **dnvlist\_take** – API for getting name/value pairs with a default value

## LIBRARY

library “libnv”

## SYNOPSIS

**#include \<sys/dnv.h\>**

*bool*\

**dnvlist\_get\_bool**(*const nvlist\_t \*nvl*, *const char \*name*, *bool defval*);

*uint64\_t*\

**dnvlist\_get\_number**(*const nvlist\_t \*nvl*, *const char \*name*, *uint64\_t defval*);

*char* *\**\

**dnvlist\_get\_string**(*const nvlist\_t \*nvl*, *const char \*name*, *const char \*defval*);

*nvlist\_t* *\**\

**dnvlist\_get\_nvlist**(*const nvlist\_t \*nvl*, *const char \*name*, *nvlist\_t \*defval*);

*int*\

**dnvlist\_get\_descriptor**(*const nvlist\_t \*nvl*, *const char \*name*, *int defval*);

*void* *\**\

**dnvlist\_get\_binary**(*const nvlist\_t \*nvl*, *const char \*name*, *size\_t \*sizep*, *void \*defval*, *size\_t defsize*);

*bool*\

**dnvlist\_take\_bool**(*const nvlist\_t \*nvl*, *const char \*name*, *bool defval*);

*uint64\_t*\

**dnvlist\_take\_number**(*const nvlist\_t \*nvl*, *const char \*name*, *uint64\_t defval*);

*char* *\**\

**dnvlist\_take\_string**(*const nvlist\_t \*nvl*, *const char \*name*, *const char \*defval*);

*nvlist\_t* *\**\

**dnvlist\_take\_nvlist**(*const nvlist\_t \*nvl*, *const char \*name*, *nvlist\_t \*defval*);

*int*\

**dnvlist\_take\_descriptor**(*const nvlist\_t \*nvl*, *const char \*name*, *int defval*);

*void* *\**\

**dnvlist\_take\_binary**(*const nvlist\_t \*nvl*, *const char \*name*, *size\_t \*sizep*, *void \*defval*, *size\_t defsize*);

## DESCRIPTION

The **libnv** library permits easy management of name/value pairs and can send and receive them over sockets. For more information, see [nv(9)](/nv/9.md).

The **dnvlist\_get** functions return the value associated with *name*. If an element named *name* does not exist, the function returns the value provided in *defval*. Returned strings, nvlists, descriptors, binaries, or arrays must not be modified by the user since they still belong to the nvlist. If the nvlist is in an error state, attempts to use any of these functions will cause the program to abort.

The **dnvlist\_take** functions return the value associated with *name* and removes the associated element from *nvl*. If an element named *name* does not exist, the value provided in **defval** is returned. When the value is a string, binary, or array value, the caller is responsible for freeing returned memory with **free**(*3*). When the value is an nvlist, the caller is responsible for destroying the returned nvlist with **nvlist\_destroy**(). When the value is a descriptor, the caller is responsible for closing the returned descriptor with **close**(*2*).

## SEE ALSO

[close(2)](/close/2.md), [free(3)](/free/3.md), [nv(9)](/nv/9.md)

## HISTORY

The **dnv** API appeared in FreeBSD 11.0.

## AUTHORS

The **dnv** API was implemented by Pawel Jakub Dawidek ⟨*pawel@dawidek.net*⟩ under sponsorship from the FreeBSD Foundation. This manual page was written by Adam Starak ⟨*starak.adam@gmail.com*⟩
