logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

dnvlist_get, dnvlist_take — API for getting name/value pairs. Nonexistent pairs do not raise an error.

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>

Debian                                            July 26, 2016                                           DNV(9)

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).

       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).

History

       The dnv API appeared in FreeBSD 11.0.

Library

       library “libnv”

Name

       dnvlist_get, dnvlist_take — API for getting name/value pairs. Nonexistent pairs do not raise an error.

See Also

close(2), free(3), nv(9)

Synopsis

#include<sys/dnv.h>booldnvlist_get_bool(constnvlist_t*nvl, constchar*name, booldefval);

       uint64_tdnvlist_get_number(constnvlist_t*nvl, constchar*name, uint64_tdefval);

       char*dnvlist_get_string(constnvlist_t*nvl, constchar*name, constchar*defval);

       nvlist_t*dnvlist_get_nvlist(constnvlist_t*nvl, constchar*name, nvlist_t*defval);

       intdnvlist_get_descriptor(constnvlist_t*nvl, constchar*name, intdefval);

       void*dnvlist_get_binary(constnvlist_t*nvl, constchar*name, size_t*sizep, void*defval, size_tdefsize);

       booldnvlist_take_bool(constnvlist_t*nvl, constchar*name, booldefval);

       uint64_tdnvlist_take_number(constnvlist_t*nvl, constchar*name, uint64_tdefval);

       char*dnvlist_take_string(constnvlist_t*nvl, constchar*name, constchar*defval);

       nvlist_t*dnvlist_take_nvlist(constnvlist_t*nvl, constchar*name, nvlist_t*defval);

       intdnvlist_take_descriptor(constnvlist_t*nvl, constchar*name, intdefval);

       void*dnvlist_take_binary(constnvlist_t*nvl, constchar*name, size_t*sizep, void*defval, size_tdefsize);

See Also