---
name: "dnvlist_get_binary"
section: "9freebsd"
platform: "linux"
package: "freebsd-manpages"
version: "12.2-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/dnv/9freebsd"
---

# dnvlist\_get\_binary(9freebsd)

API for getting name/value pairs. Nonexistent pairs do not raise an error.

Part of [dnv(9freebsd)](/dnv/9freebsd.md).

## NAME

**dnvlist\_get**, **dnvlist\_take** – API for getting name/value pairs. Nonexistent pairs do not raise an error.

## 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, also see [nv(9)](/nv/9.md).

The **dnvlist\_get** family of functions returns the value associated with the specified name. If an element of the specified 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. 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** family of functions returns the value associated with the specified name and removes the element from the nvlist. If an element of the supplied 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*⟩
