15ec81a23SMariusz Zaborski.\" 25ec81a23SMariusz Zaborski.\" Copyright (c) 2016 Adam Starak <starak.adam@gmail.com> 35ec81a23SMariusz Zaborski.\" All rights reserved. 45ec81a23SMariusz Zaborski.\" 55ec81a23SMariusz Zaborski.\" Redistribution and use in source and binary forms, with or without 65ec81a23SMariusz Zaborski.\" modification, are permitted provided that the following conditions 75ec81a23SMariusz Zaborski.\" are met: 85ec81a23SMariusz Zaborski.\" 1. Redistributions of source code must retain the above copyright 95ec81a23SMariusz Zaborski.\" notice, this list of conditions and the following disclaimer. 105ec81a23SMariusz Zaborski.\" 2. Redistributions in binary form must reproduce the above copyright 115ec81a23SMariusz Zaborski.\" notice, this list of conditions and the following disclaimer in the 125ec81a23SMariusz Zaborski.\" documentation and/or other materials provided with the distribution. 135ec81a23SMariusz Zaborski.\" 145ec81a23SMariusz Zaborski.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 155ec81a23SMariusz Zaborski.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 165ec81a23SMariusz Zaborski.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 175ec81a23SMariusz Zaborski.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 185ec81a23SMariusz Zaborski.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 195ec81a23SMariusz Zaborski.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 205ec81a23SMariusz Zaborski.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 215ec81a23SMariusz Zaborski.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 225ec81a23SMariusz Zaborski.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 235ec81a23SMariusz Zaborski.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 245ec81a23SMariusz Zaborski.\" SUCH DAMAGE. 255ec81a23SMariusz Zaborski.\" 265ec81a23SMariusz Zaborski.Dd July 26, 2016 275ec81a23SMariusz Zaborski.Dt DNV 9 285ec81a23SMariusz Zaborski.Os 295ec81a23SMariusz Zaborski.Sh NAME 305ec81a23SMariusz Zaborski.Nm dnvlist_get , 31*054cb42fSEnji Cooper.Nm dnvlist_take 325ec81a23SMariusz Zaborski.Nd "API for getting name/value pairs. Nonexistent pairs do not raise an error." 335ec81a23SMariusz Zaborski.Sh LIBRARY 345ec81a23SMariusz Zaborski.Lb libnv 355ec81a23SMariusz Zaborski.Sh SYNOPSIS 365ec81a23SMariusz Zaborski.In sys/dnv.h 375ec81a23SMariusz Zaborski.Ft bool 385ec81a23SMariusz Zaborski.Fn dnvlist_get_bool "const nvlist_t *nvl" "const char *name" "bool defval" 395ec81a23SMariusz Zaborski.Ft uint64_t 405ec81a23SMariusz Zaborski.Fn dnvlist_get_number "const nvlist_t *nvl" "const char *name" "uint64_t defval" 415ec81a23SMariusz Zaborski.Ft char * 425ec81a23SMariusz Zaborski.Fn dnvlist_get_string "const nvlist_t *nvl" "const char *name" "const char *defval" 435ec81a23SMariusz Zaborski.Ft nvlist_t * 445ec81a23SMariusz Zaborski.Fn dnvlist_get_nvlist "const nvlist_t *nvl" "const char *name" "nvlist_t *defval" 455ec81a23SMariusz Zaborski.Ft int 465ec81a23SMariusz Zaborski.Fn dnvlist_get_descriptor "const nvlist_t *nvl" "const char *name" "int defval" 475ec81a23SMariusz Zaborski.Ft void * 485ec81a23SMariusz Zaborski.Fn dnvlist_get_binary "const nvlist_t *nvl" "const char *name" "size_t *sizep" "void *defval" "size_t defsize" 495ec81a23SMariusz Zaborski.Ft bool 505ec81a23SMariusz Zaborski.Fn dnvlist_take_bool "const nvlist_t *nvl" "const char *name" "bool defval" 515ec81a23SMariusz Zaborski.Ft uint64_t 525ec81a23SMariusz Zaborski.Fn dnvlist_take_number "const nvlist_t *nvl" "const char *name" "uint64_t defval" 535ec81a23SMariusz Zaborski.Ft char * 545ec81a23SMariusz Zaborski.Fn dnvlist_take_string "const nvlist_t *nvl" "const char *name" "const char *defval" 555ec81a23SMariusz Zaborski.Ft nvlist_t * 565ec81a23SMariusz Zaborski.Fn dnvlist_take_nvlist "const nvlist_t *nvl" "const char *name" "nvlist_t *defval" 575ec81a23SMariusz Zaborski.Ft int 585ec81a23SMariusz Zaborski.Fn dnvlist_take_descriptor "const nvlist_t *nvl" "const char *name" "int defval" 595ec81a23SMariusz Zaborski.Ft void * 605ec81a23SMariusz Zaborski.Fn dnvlist_take_binary "const nvlist_t *nvl" "const char *name" "size_t *sizep" "void *defval" "size_t defsize" 615ec81a23SMariusz Zaborski.Sh DESCRIPTION 625ec81a23SMariusz ZaborskiThe 635ec81a23SMariusz Zaborski.Nm libnv 645ec81a23SMariusz Zaborskilibrary permits easy management of name/value pairs and can send and receive 655ec81a23SMariusz Zaborskithem over sockets. 665ec81a23SMariusz ZaborskiFor more information, also see 675ec81a23SMariusz Zaborski.Xr nv 9 . 685ec81a23SMariusz Zaborski.Pp 695ec81a23SMariusz ZaborskiThe 705ec81a23SMariusz Zaborski.Nm dnvlist_get 715ec81a23SMariusz Zaborskifamily of functions returns the value associated with the specified name. 725ec81a23SMariusz ZaborskiIf an element of the specified name does not exist, the function returns the 735ec81a23SMariusz Zaborskivalue provided in 745ec81a23SMariusz Zaborski.Fa defval . 755ec81a23SMariusz ZaborskiReturned strings, nvlists, descriptors, binaries, or arrays must not be modified 765ec81a23SMariusz Zaborskiby the user. 775ec81a23SMariusz ZaborskiThey still belong to the nvlist. 785ec81a23SMariusz ZaborskiIf the nvlist is in an error state, attempts to use any of these functions will 795ec81a23SMariusz Zaborskicause the program to abort. 805ec81a23SMariusz Zaborski.Pp 815ec81a23SMariusz ZaborskiThe 825ec81a23SMariusz Zaborski.Nm dnvlist_take 835ec81a23SMariusz Zaborskifamily of functions returns the value associated with the specified name and 845ec81a23SMariusz Zaborskiremoves the element from the nvlist. 855ec81a23SMariusz ZaborskiIf an element of the supplied name does not exist, the value provided in 865ec81a23SMariusz Zaborski.Nm defval 875ec81a23SMariusz Zaborskiis returned. 885ec81a23SMariusz ZaborskiWhen the value is a string, binary, or array value, the caller is 895ec81a23SMariusz Zaborskiresponsible for freeing returned memory with 905ec81a23SMariusz Zaborski.Fn free 3 . 915ec81a23SMariusz ZaborskiWhen the value is an nvlist, the caller is responsible for destroying the 925ec81a23SMariusz Zaborskireturned nvlist with 935ec81a23SMariusz Zaborski.Fn nvlist_destroy . 945ec81a23SMariusz ZaborskiWhen the value is a descriptor, the caller is responsible for closing the 955ec81a23SMariusz Zaborskireturned descriptor with 965ec81a23SMariusz Zaborski.Fn close 2 . 975ec81a23SMariusz Zaborski.Sh SEE ALSO 985ec81a23SMariusz Zaborski.Xr close 2 , 995ec81a23SMariusz Zaborski.Xr free 3 , 1005ec81a23SMariusz Zaborski.Xr nv 9 1015ec81a23SMariusz Zaborski.Sh HISTORY 1025ec81a23SMariusz ZaborskiThe 1035ec81a23SMariusz Zaborski.Nm dnv 1045ec81a23SMariusz ZaborskiAPI appeared in 1055ec81a23SMariusz Zaborski.Fx 11.0 . 1065ec81a23SMariusz Zaborski.Sh AUTHORS 1075ec81a23SMariusz Zaborski.An -nosplit 1085ec81a23SMariusz ZaborskiThe 1095ec81a23SMariusz Zaborski.Nm dnv 1105ec81a23SMariusz ZaborskiAPI was implemented by 1115ec81a23SMariusz Zaborski.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net 1125ec81a23SMariusz Zaborskiunder sponsorship from the FreeBSD Foundation. 1135ec81a23SMariusz ZaborskiThis manual page was written by 1145ec81a23SMariusz Zaborski.An Adam Starak Aq Mt starak.adam@gmail.com 115