Add support for the arrays in nvlist library.
- Add nvlist_{add,get,take,move,exists,free}_{number,bool,string,nvlist, descriptor} functions. - Add support for (un)packing arrays. - Add the nvl_array_next field to the nvlist structure. If an array is added by the nvlist_{move,add}_nvlist_array function this field will contains next element in the array. - Add the nitems field to the nvpair and nvpair_header structure. This field contains number of elements in the array. - Add special flag (NV_FLAG_IN_ARRAY) which is set if nvlist is a part of an array. - Add special type (NV_TYPE_NVLIST_ARRAY_NEXT).This type is used only on packing/unpacking. - Add new API for traversing arrays (nvlist_get_array_next). - Add the nvlist_get_pararr function which combines the nvlist_get_array_next and nvlist_get_parent functions. If nvlist is in the array it will return next element from array. If nvlist is last element in array or it isn't in array it will return his container (parent). This function should simplify traveling over nvlist. - Add tests for new features. - Add documentation for new functions. - Add my copyright. - Regenerate the sys/cddl/compat/opensolaris/sys/nvpair.h file. PR: 191083 Reviewed by: allanjude (doc) Approved by: pjd (mentor)
This commit is contained in:
parent
e678759c30
commit
347a39b4a6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286796
@ -4,6 +4,7 @@ TESTSDIR= ${TESTSBASE}/lib/libnv
|
||||
|
||||
ATF_TESTS_CXX= \
|
||||
dnv_tests \
|
||||
nv_array_tests \
|
||||
nv_tests \
|
||||
|
||||
TAP_TESTS_C+= nvlist_add_test
|
||||
|
1191
lib/libnv/tests/nv_array_tests.cc
Normal file
1191
lib/libnv/tests/nv_array_tests.cc
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2013 The FreeBSD Foundation
|
||||
.\" Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This documentation was written by Pawel Jakub Dawidek under sponsorship
|
||||
@ -28,7 +29,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd Aug 11, 2015
|
||||
.Dd August 15, 2015
|
||||
.Dt NV 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -49,6 +50,7 @@
|
||||
.Nm nvlist_send ,
|
||||
.Nm nvlist_recv ,
|
||||
.Nm nvlist_xfer ,
|
||||
.Nm nvlist_in_array ,
|
||||
.Nm nvlist_next ,
|
||||
.Nm nvlist_add ,
|
||||
.Nm nvlist_move ,
|
||||
@ -71,6 +73,8 @@
|
||||
.Fn nvlist_empty "const nvlist_t *nvl"
|
||||
.Ft int
|
||||
.Fn nvlist_flags "const nvlist_t *nvl"
|
||||
.Ft bool
|
||||
.Fn nvlist_in_array "const nvlist_t *nvl"
|
||||
.\"
|
||||
.Ft "nvlist_t *"
|
||||
.Fn nvlist_clone "const nvlist_t *nvl"
|
||||
@ -115,6 +119,16 @@
|
||||
.Fn nvlist_exists_descriptor "const nvlist_t *nvl" "const char *name"
|
||||
.Ft bool
|
||||
.Fn nvlist_exists_binary "const nvlist_t *nvl" "const char *name"
|
||||
.Ft bool
|
||||
.Fn nvlist_exists_bool_array "const nvlist_t *nvl" "const char *name"
|
||||
.Ft bool
|
||||
.Fn nvlist_exists_number_array "const nvlist_t *nvl" "const char *name"
|
||||
.Ft bool
|
||||
.Fn nvlist_exists_string_array "const nvlist_t *nvl" "const char *name"
|
||||
.Ft bool
|
||||
.Fn nvlist_exists_nvlist_array "const nvlist_t *nvl" "const char *name"
|
||||
.Ft bool
|
||||
.Fn nvlist_exists_descriptor_array "const nvlist_t *nvl" "const char *name"
|
||||
.\"
|
||||
.Ft void
|
||||
.Fn nvlist_add_null "nvlist_t *nvl" "const char *name"
|
||||
@ -134,6 +148,20 @@
|
||||
.Fn nvlist_add_descriptor "nvlist_t *nvl" "const char *name" "int value"
|
||||
.Ft void
|
||||
.Fn nvlist_add_binary "nvlist_t *nvl" "const char *name" "const void *value" "size_t size"
|
||||
.Ft void
|
||||
.Fn nvlist_add_bool_array "nvlist_t *nvl" "const char *name" "const bool *value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_add_number_array "nvlist_t *nvl" "const char *name" "const uint64_t *value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_add_string_array "nvlist_t *nvl" "const char *name" "const char * const * value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_add_nvlist_array "nvlist_t *nvl" "const char *name" "const nvlist_t * const * value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_add_descriptor_array "nvlist_t *nvl" "const char *name" "const int *value" "size_t nitems"
|
||||
.\"
|
||||
.Ft void
|
||||
.Fn nvlist_move_string "nvlist_t *nvl" "const char *name" "char *value"
|
||||
@ -143,6 +171,20 @@
|
||||
.Fn nvlist_move_descriptor "nvlist_t *nvl" "const char *name" "int value"
|
||||
.Ft void
|
||||
.Fn nvlist_move_binary "nvlist_t *nvl" "const char *name" "void *value" "size_t size"
|
||||
.Ft void
|
||||
.Fn nvlist_move_bool_array "nvlist_t *nvl" "const char *name" "bool *value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_move_number_array "nvlist_t *nvl" "const char *name" "uint64_t *value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_move_string_array "nvlist_t *nvl" "const char *name" "char **value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_move_nvlist_array "nvlist_t *nvl" "const char *name" "nvlist_t **value" "size_t nitems"
|
||||
.
|
||||
.Ft void
|
||||
.Fn nvlist_move_descriptor_array "nvlist_t *nvl" "const char *name" "int *value" "size_t nitems"
|
||||
.\"
|
||||
.Ft bool
|
||||
.Fn nvlist_get_bool "const nvlist_t *nvl" "const char *name"
|
||||
@ -156,8 +198,22 @@
|
||||
.Fn nvlist_get_descriptor "const nvlist_t *nvl" "const char *name"
|
||||
.Ft "const void *"
|
||||
.Fn nvlist_get_binary "const nvlist_t *nvl" "const char *name" "size_t *sizep"
|
||||
.Ft "const bool *"
|
||||
.Fn nvlist_get_bool_array "const nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "const uint64_t *"
|
||||
.Fn nvlist_get_number "const nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "const char * const *"
|
||||
.Fn nvlist_get_string "const nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "const nvlist_t * const *"
|
||||
.Fn nvlist_get_nvlist "const nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "const int *"
|
||||
.Fn nvlist_get_descriptor_array "const nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "const nvlist_t *"
|
||||
.Fn nvlist_get_parent "const nvlist_t *nvl" "void **cookiep"
|
||||
.Ft "const nvlist_t *"
|
||||
.Fn nvlist_get_array_next "const nvlist_t *nvl"
|
||||
.Ft "const nvlist_t *"
|
||||
.Fn nvlist_get_pararr "const nvlist_t *nvl" "void **cookiep"
|
||||
.\"
|
||||
.Ft bool
|
||||
.Fn nvlist_take_bool "nvlist_t *nvl" "const char *name"
|
||||
@ -171,6 +227,16 @@
|
||||
.Fn nvlist_take_descriptor "nvlist_t *nvl" "const char *name"
|
||||
.Ft "void *"
|
||||
.Fn nvlist_take_binary "nvlist_t *nvl" "const char *name" "size_t *sizep"
|
||||
.Ft "bool *"
|
||||
.Fn nvlist_take_bool_array "nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "uint64_t **"
|
||||
.Fn nvlist_take_number "nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "char **"
|
||||
.Fn nvlist_take_string "nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "nvlist_t **"
|
||||
.Fn nvlist_take_nvlist "nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.Ft "int *"
|
||||
.Fn nvlist_take_descriptor "nvlist_t *nvl" "const char *name" "size_t *nitems"
|
||||
.\"
|
||||
.Ft void
|
||||
.Fn nvlist_free "nvlist_t *nvl" "const char *name"
|
||||
@ -191,6 +257,16 @@
|
||||
.Fn nvlist_free_descriptor "nvlist_t *nvl" "const char *name"
|
||||
.Ft void
|
||||
.Fn nvlist_free_binary "nvlist_t *nvl" "const char *name"
|
||||
.Ft void
|
||||
.Fn nvlist_free_bool_array "nvlist_t *nvl" "const char *name"
|
||||
.Ft void
|
||||
.Fn nvlist_free_number_array "nvlist_t *nvl" "const char *name"
|
||||
.Ft void
|
||||
.Fn nvlist_free_string_array "nvlist_t *nvl" "const char *name"
|
||||
.Ft void
|
||||
.Fn nvlist_free_nvlist_array "nvlist_t *nvl" "const char *name"
|
||||
.Ft void
|
||||
.Fn nvlist_free_descriptor_array "nvlist_t *nvl" "const char *name"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm libnv
|
||||
@ -221,6 +297,23 @@ Note that file descriptors can be sent only over
|
||||
domain sockets.
|
||||
.It Sy binary ( NV_TYPE_BINARY )
|
||||
The value is a binary buffer.
|
||||
.It Sy bool array ( NV_TYPE_BOOL_ARRAY )
|
||||
The value is an array of boolean values.
|
||||
.It Sy number array ( NV_TYPE_NUMBER_ARRAY )
|
||||
The value is an array of numbers, each stored as
|
||||
.Vt uint64_t .
|
||||
.It Sy string array ( NV_TYPE_STRING_ARRAY )
|
||||
The value is an array of C strings.
|
||||
.It Sy nvlist array ( NV_TYPE_NVLIST_ARRAY )
|
||||
The value is an array of nvlists.
|
||||
When an nvlist is added to an array, it becomes part of the primary nvlist.
|
||||
Traversing these arrays can be done using the
|
||||
.Fn nvlist_get_array_next
|
||||
and
|
||||
.Fn nvlist_get_pararr
|
||||
functions.
|
||||
.It Sy descriptor array ( NV_TYPE_DESCRIPTOR_ARRAY )
|
||||
The value is an array of files descriptors.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
@ -280,6 +373,14 @@ function returns flags used to create the nvlist with the
|
||||
function.
|
||||
.Pp
|
||||
The
|
||||
.Fn nvlist_in_array
|
||||
function returns
|
||||
.Dv true
|
||||
if
|
||||
.Fa nvl
|
||||
is part of an array that is a member of another nvlist.
|
||||
.Pp
|
||||
The
|
||||
.Fn nvlist_clone
|
||||
functions clones the given nvlist.
|
||||
The clone shares no resources with its origin.
|
||||
@ -446,7 +547,12 @@ The
|
||||
.Fn nvlist_exists_string ,
|
||||
.Fn nvlist_exists_nvlist ,
|
||||
.Fn nvlist_exists_descriptor ,
|
||||
.Fn nvlist_exists_binary
|
||||
.Fn nvlist_exists_binary ,
|
||||
.Fn nvlist_exists_bool_array ,
|
||||
.Fn nvlist_exists_number_array ,
|
||||
.Fn nvlist_exists_string_array ,
|
||||
.Fn nvlist_exists_nvlist_array ,
|
||||
.Fn nvlist_exists_descriptor_array
|
||||
functions return
|
||||
.Dv true
|
||||
if element of the given name and the given type determined by the function name
|
||||
@ -464,7 +570,12 @@ The
|
||||
.Fn nvlist_add_stringv ,
|
||||
.Fn nvlist_add_nvlist ,
|
||||
.Fn nvlist_add_descriptor ,
|
||||
.Fn nvlist_add_binary
|
||||
.Fn nvlist_add_binary ,
|
||||
.Fn nvlist_add_bool_array ,
|
||||
.Fn nvlist_add_number_array ,
|
||||
.Fn nvlist_add_string_array ,
|
||||
.Fn nvlist_add_nvlist_array ,
|
||||
.Fn nvlist_add_descriptor_array
|
||||
functions add element to the given nvlist.
|
||||
When adding string or binary buffor the functions will allocate memory
|
||||
and copy the data over.
|
||||
@ -472,6 +583,10 @@ When adding nvlist, the nvlist will be cloned and clone will be added.
|
||||
When adding descriptor, the descriptor will be duplicated using the
|
||||
.Xr dup 2
|
||||
system call and the new descriptor will be added.
|
||||
The array functions will fail if there are any
|
||||
.Dv NULL
|
||||
elements in the array, or if the array pointer is
|
||||
.Dv NULL .
|
||||
If an error occurs while adding new element, internal error is set which can be
|
||||
examined using the
|
||||
.Fn nvlist_error
|
||||
@ -481,10 +596,21 @@ The
|
||||
.Fn nvlist_move_string ,
|
||||
.Fn nvlist_move_nvlist ,
|
||||
.Fn nvlist_move_descriptor ,
|
||||
.Fn nvlist_move_binary
|
||||
.Fn nvlist_move_binary ,
|
||||
.Fn nvlist_move_bool_array ,
|
||||
.Fn nvlist_move_number_array ,
|
||||
.Fn nvlist_move_string_array ,
|
||||
.Fn nvlist_move_nvlist_array ,
|
||||
.Fn nvlist_move_descriptor_array
|
||||
functions add new element to the given nvlist, but unlike
|
||||
.Fn nvlist_add_<type>
|
||||
functions they will consume the given resource.
|
||||
In the case of strings, descriptors, or nvlists every elements must be
|
||||
unique, or it could cause a double free.
|
||||
The array functions will fail if there are any
|
||||
.Dv NULL
|
||||
elements, or if the array pointer is
|
||||
.Dv NULL .
|
||||
If an error occurs while adding new element, the resource is destroyed and
|
||||
internal error is set which can be examined using the
|
||||
.Fn nvlist_error
|
||||
@ -496,20 +622,43 @@ The
|
||||
.Fn nvlist_get_string ,
|
||||
.Fn nvlist_get_nvlist ,
|
||||
.Fn nvlist_get_descriptor ,
|
||||
.Fn nvlist_get_binary
|
||||
functions allow to obtain value of the given name.
|
||||
In case of string, nvlist, descriptor or binary, returned resource should
|
||||
not be modified - it still belongs to the nvlist.
|
||||
If element of the given name does not exist, the program will be aborted.
|
||||
To avoid that the caller should check for existence before trying to obtain
|
||||
the value or use
|
||||
.Fn nvlist_get_binary ,
|
||||
.Fn nvlist_get_bool_array ,
|
||||
.Fn nvlist_get_number_array ,
|
||||
.Fn nvlist_get_string_array ,
|
||||
.Fn nvlist_get_nvlist_array ,
|
||||
.Fn nvlist_get_descriptor_array
|
||||
functions return the value that corresponds to the given key name.
|
||||
In the case of strings, nvlists, descriptors, binary, or arrays, the returned
|
||||
resource should not be modified - they still belong to the nvlist.
|
||||
If an element of the given name does not exist, the program will be aborted.
|
||||
To avoid this, the caller should check for the existence of the name before
|
||||
trying to obtain the value, or use the
|
||||
.Xr dnvlist 3
|
||||
extension, which allows to provide default value for a missing element.
|
||||
extension, which can provide a default value in the case of a missing element.
|
||||
The nvlist must not be in error state.
|
||||
.Pp
|
||||
The
|
||||
.Fn nvlist_get_parent
|
||||
function allows to obtain the parent nvlist from the nested nvlist.
|
||||
function returns the parent nvlist of the nested nvlist.
|
||||
.Pp
|
||||
The
|
||||
.Fn nvlist_get_array_next
|
||||
function returns the next element from the array or
|
||||
.Dv NULL
|
||||
if the nvlist is not in array or it is the last element.
|
||||
Note that
|
||||
.Fn nvlist_get_array_next
|
||||
only works if you added the nvlist array using the
|
||||
.Fn nvlist_move_nvlist_array
|
||||
or
|
||||
.Fn nvlist_add_nvlist_array
|
||||
functions.
|
||||
.Pp
|
||||
The
|
||||
.Fn nvlist_get_pararr
|
||||
function returns the next element in the array, or if not available
|
||||
the parent of the nested nvlist.
|
||||
.Pp
|
||||
The
|
||||
.Fn nvlist_take_bool ,
|
||||
@ -517,7 +666,12 @@ The
|
||||
.Fn nvlist_take_string ,
|
||||
.Fn nvlist_take_nvlist ,
|
||||
.Fn nvlist_take_descriptor ,
|
||||
.Fn nvlist_take_binary
|
||||
.Fn nvlist_take_binary ,
|
||||
.Fn nvlist_take_bool_array ,
|
||||
.Fn nvlist_take_number_array ,
|
||||
.Fn nvlist_take_string_array ,
|
||||
.Fn nvlist_take_nvlist_array ,
|
||||
.Fn nvlist_take_descriptor_array
|
||||
functions return value associated with the given name and remove the element
|
||||
from the nvlist.
|
||||
In case of string and binary values, the caller is responsible for free returned
|
||||
@ -532,11 +686,27 @@ In case of descriptor, the caller is responsible for closing returned descriptor
|
||||
using the
|
||||
.Fn close 2
|
||||
system call.
|
||||
If element of the given name does not exist, the program will be aborted.
|
||||
To avoid that the caller should check for existence before trying to obtain
|
||||
the value or use
|
||||
If an element of the given name does not exist, the program will be aborted.
|
||||
To avoid that the caller should check for the existence of the given name
|
||||
before trying to obtain the value, or use the
|
||||
.Xr dnvlist 3
|
||||
extension, which allows to provide default value for a missing element.
|
||||
extension, which can provide a default value in the case of a missing element.
|
||||
In the case of an array of strings or binary values, the caller is responsible
|
||||
for freeing every element of the array using the
|
||||
.Xr free 3
|
||||
function.
|
||||
In the case of an array of nvlists, the caller is responsible for destroying
|
||||
every element of array using the
|
||||
.Fn nvlist_destroy
|
||||
function.
|
||||
In the case of descriptors, the caller is responsible for closing every
|
||||
element of array using the
|
||||
.Fn close 2
|
||||
system call.
|
||||
In every case involving an array, the caller must also free the pointer to
|
||||
the array using the
|
||||
.Xr free 3
|
||||
function.
|
||||
The nvlist must not be in error state.
|
||||
.Pp
|
||||
The
|
||||
@ -561,7 +731,12 @@ The
|
||||
.Fn nvlist_free_string ,
|
||||
.Fn nvlist_free_nvlist ,
|
||||
.Fn nvlist_free_descriptor ,
|
||||
.Fn nvlist_free_binary
|
||||
.Fn nvlist_free_binary ,
|
||||
.Fn nvlist_free_bool_array ,
|
||||
.Fn nvlist_free_number_array ,
|
||||
.Fn nvlist_free_string_array ,
|
||||
.Fn nvlist_free_nvlist_array ,
|
||||
.Fn nvlist_free_descriptor_array
|
||||
functions remove element of the given name and the given type determined by the
|
||||
function name from the nvlist and free all resources associated with it.
|
||||
If element of the given name and the given type does not exist, the program
|
||||
@ -679,6 +854,65 @@ do {
|
||||
}
|
||||
} while ((nvl = nvlist_get_parent(nvl, &cookie)) != NULL);
|
||||
.Ed
|
||||
.Pp
|
||||
Iterating over every nested nvlist and every nvlist element:
|
||||
.Bd -literal
|
||||
nvlist_t *nvl;
|
||||
const nvlist_t * const *array;
|
||||
const char *name;
|
||||
void *cookie;
|
||||
int type;
|
||||
|
||||
nvl = nvlist_recv(sock, 0);
|
||||
if (nvl == null)
|
||||
err(1, "nvlist_recv() failed");
|
||||
|
||||
cookie = null;
|
||||
do {
|
||||
while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) {
|
||||
if (type == NV_TYPE_NVLIST) {
|
||||
nvl = nvlist_get_nvlist(nvl, name);
|
||||
cookie = NULL;
|
||||
} else if (type == NV_TYPE_NVLIST_ARRAY) {
|
||||
nvl = nvlist_get_nvlist_array(nvl, name, NULL)[0];
|
||||
cookie = NULL;
|
||||
}
|
||||
}
|
||||
} while ((nvl = nvlist_get_pararr(nvl, &cookie)) != NULL);
|
||||
.Ed
|
||||
.Pp
|
||||
Or alternatively:
|
||||
.Bd -literal
|
||||
nvlist_t *nvl, *tmp;
|
||||
const nvlist_t * const *array;
|
||||
const char *name;
|
||||
void *cookie;
|
||||
int type;
|
||||
|
||||
nvl = nvlist_recv(sock, 0);
|
||||
if (nvl == null)
|
||||
err(1, "nvlist_recv() failed");
|
||||
|
||||
cooke = NULL;
|
||||
tmp = nvl;
|
||||
do {
|
||||
do {
|
||||
nvl = tmp;
|
||||
while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) {
|
||||
if (type == NV_TYPE_NVLIST) {
|
||||
nvl = nvlist_get_nvlist(nvl,
|
||||
name);
|
||||
cookie = NULL;
|
||||
} else if (type == NV_TYPE_NVLIST_ARRAY) {
|
||||
nvl = nvlist_get_nvlist_array(nvl, name,
|
||||
NULL)[0];
|
||||
cookie = NULL;
|
||||
}
|
||||
}
|
||||
cookie = NULL;
|
||||
} while ((tmp = nvlist_get_array_next(nvl)) != NULL);
|
||||
} while ((tmp = nvlist_get_parent(nvl, &cookie)) != NULL);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr close 2 ,
|
||||
.Xr dup 2 ,
|
||||
|
@ -42,29 +42,19 @@
|
||||
*/
|
||||
#define nvlist_add_binary illumos_nvlist_add_binary
|
||||
#define nvlist_add_bool illumos_nvlist_add_bool
|
||||
#define nvlist_add_bool_array illumos_nvlist_add_bool_array
|
||||
#define nvlist_add_descriptor illumos_nvlist_add_descriptor
|
||||
#define nvlist_add_descriptor_array illumos_nvlist_add_descriptor_array
|
||||
#define nvlist_add_null illumos_nvlist_add_null
|
||||
#define nvlist_add_number illumos_nvlist_add_number
|
||||
#define nvlist_add_number_array illumos_nvlist_add_number_array
|
||||
#define nvlist_add_nvlist illumos_nvlist_add_nvlist
|
||||
#define nvlist_add_nvlist_array illumos_nvlist_add_nvlist_array
|
||||
#define nvlist_add_nvpair illumos_nvlist_add_nvpair
|
||||
#define nvlist_add_string illumos_nvlist_add_string
|
||||
#define nvlist_add_string_array illumos_nvlist_add_string_array
|
||||
#define nvlist_add_stringf illumos_nvlist_add_stringf
|
||||
#define nvlist_add_stringv illumos_nvlist_add_stringv
|
||||
#define nvlist_addf_binary illumos_nvlist_addf_binary
|
||||
#define nvlist_addf_bool illumos_nvlist_addf_bool
|
||||
#define nvlist_addf_descriptor illumos_nvlist_addf_descriptor
|
||||
#define nvlist_addf_null illumos_nvlist_addf_null
|
||||
#define nvlist_addf_number illumos_nvlist_addf_number
|
||||
#define nvlist_addf_nvlist illumos_nvlist_addf_nvlist
|
||||
#define nvlist_addf_string illumos_nvlist_addf_string
|
||||
#define nvlist_addv_binary illumos_nvlist_addv_binary
|
||||
#define nvlist_addv_bool illumos_nvlist_addv_bool
|
||||
#define nvlist_addv_descriptor illumos_nvlist_addv_descriptor
|
||||
#define nvlist_addv_null illumos_nvlist_addv_null
|
||||
#define nvlist_addv_number illumos_nvlist_addv_number
|
||||
#define nvlist_addv_nvlist illumos_nvlist_addv_nvlist
|
||||
#define nvlist_addv_string illumos_nvlist_addv_string
|
||||
#define nvlist_check_header illumos_nvlist_check_header
|
||||
#define nvlist_clone illumos_nvlist_clone
|
||||
#define nvlist_create illumos_nvlist_create
|
||||
#define nvlist_descriptors illumos_nvlist_descriptors
|
||||
@ -75,92 +65,61 @@
|
||||
#define nvlist_exists illumos_nvlist_exists
|
||||
#define nvlist_exists_binary illumos_nvlist_exists_binary
|
||||
#define nvlist_exists_bool illumos_nvlist_exists_bool
|
||||
#define nvlist_exists_bool_array illumos_nvlist_exists_bool_array
|
||||
#define nvlist_exists_descriptor illumos_nvlist_exists_descriptor
|
||||
#define nvlist_exists_descriptor_array illumos_nvlist_exists_descriptor_array
|
||||
#define nvlist_exists_null illumos_nvlist_exists_null
|
||||
#define nvlist_exists_number illumos_nvlist_exists_number
|
||||
#define nvlist_exists_number_array illumos_nvlist_exists_number_array
|
||||
#define nvlist_exists_nvlist illumos_nvlist_exists_nvlist
|
||||
#define nvlist_exists_nvlist_array illumos_nvlist_exists_nvlist_array
|
||||
#define nvlist_exists_string illumos_nvlist_exists_string
|
||||
#define nvlist_exists_string_array illumos_nvlist_exists_string_array
|
||||
#define nvlist_exists_type illumos_nvlist_exists_type
|
||||
#define nvlist_existsf illumos_nvlist_existsf
|
||||
#define nvlist_existsf_binary illumos_nvlist_existsf_binary
|
||||
#define nvlist_existsf_bool illumos_nvlist_existsf_bool
|
||||
#define nvlist_existsf_descriptor illumos_nvlist_existsf_descriptor
|
||||
#define nvlist_existsf_null illumos_nvlist_existsf_null
|
||||
#define nvlist_existsf_number illumos_nvlist_existsf_number
|
||||
#define nvlist_existsf_nvlist illumos_nvlist_existsf_nvlist
|
||||
#define nvlist_existsf_string illumos_nvlist_existsf_string
|
||||
#define nvlist_existsf_type illumos_nvlist_existsf_type
|
||||
#define nvlist_existsv illumos_nvlist_existsv
|
||||
#define nvlist_existsv_binary illumos_nvlist_existsv_binary
|
||||
#define nvlist_existsv_bool illumos_nvlist_existsv_bool
|
||||
#define nvlist_existsv_descriptor illumos_nvlist_existsv_descriptor
|
||||
#define nvlist_existsv_null illumos_nvlist_existsv_null
|
||||
#define nvlist_existsv_number illumos_nvlist_existsv_number
|
||||
#define nvlist_existsv_nvlist illumos_nvlist_existsv_nvlist
|
||||
#define nvlist_existsv_string illumos_nvlist_existsv_string
|
||||
#define nvlist_existsv_type illumos_nvlist_existsv_type
|
||||
#define nvlist_fdump illumos_nvlist_fdump
|
||||
#define nvlist_first_nvpair illumos_nvlist_first_nvpair
|
||||
#define nvlist_flags illumos_nvlist_flags
|
||||
#define nvlist_free illumos_nvlist_free
|
||||
#define nvlist_free_binary illumos_nvlist_free_binary
|
||||
#define nvlist_free_binary_array illumos_nvlist_free_binary_array
|
||||
#define nvlist_free_bool illumos_nvlist_free_bool
|
||||
#define nvlist_free_bool_array illumos_nvlist_free_bool_array
|
||||
#define nvlist_free_descriptor illumos_nvlist_free_descriptor
|
||||
#define nvlist_free_descriptor_array illumos_nvlist_free_descriptor_array
|
||||
#define nvlist_free_null illumos_nvlist_free_null
|
||||
#define nvlist_free_number illumos_nvlist_free_number
|
||||
#define nvlist_free_number_array illumos_nvlist_free_number_array
|
||||
#define nvlist_free_nvlist illumos_nvlist_free_nvlist
|
||||
#define nvlist_free_nvlist_array illumos_nvlist_free_nvlist_array
|
||||
#define nvlist_free_nvpair illumos_nvlist_free_nvpair
|
||||
#define nvlist_free_string illumos_nvlist_free_string
|
||||
#define nvlist_free_string_array illumos_nvlist_free_string_array
|
||||
#define nvlist_free_type illumos_nvlist_free_type
|
||||
#define nvlist_freef illumos_nvlist_freef
|
||||
#define nvlist_freef_binary illumos_nvlist_freef_binary
|
||||
#define nvlist_freef_bool illumos_nvlist_freef_bool
|
||||
#define nvlist_freef_descriptor illumos_nvlist_freef_descriptor
|
||||
#define nvlist_freef_null illumos_nvlist_freef_null
|
||||
#define nvlist_freef_number illumos_nvlist_freef_number
|
||||
#define nvlist_freef_nvlist illumos_nvlist_freef_nvlist
|
||||
#define nvlist_freef_string illumos_nvlist_freef_string
|
||||
#define nvlist_freef_type illumos_nvlist_freef_type
|
||||
#define nvlist_freev illumos_nvlist_freev
|
||||
#define nvlist_freev_binary illumos_nvlist_freev_binary
|
||||
#define nvlist_freev_bool illumos_nvlist_freev_bool
|
||||
#define nvlist_freev_descriptor illumos_nvlist_freev_descriptor
|
||||
#define nvlist_freev_null illumos_nvlist_freev_null
|
||||
#define nvlist_freev_number illumos_nvlist_freev_number
|
||||
#define nvlist_freev_nvlist illumos_nvlist_freev_nvlist
|
||||
#define nvlist_freev_string illumos_nvlist_freev_string
|
||||
#define nvlist_freev_type illumos_nvlist_freev_type
|
||||
#define nvlist_get_array_next illumos_nvlist_get_array_next
|
||||
#define nvlist_get_binary illumos_nvlist_get_binary
|
||||
#define nvlist_get_bool illumos_nvlist_get_bool
|
||||
#define nvlist_get_bool_array illumos_nvlist_get_bool_array
|
||||
#define nvlist_get_descriptor illumos_nvlist_get_descriptor
|
||||
#define nvlist_get_descriptor_array illumos_nvlist_get_descriptor_array
|
||||
#define nvlist_get_number illumos_nvlist_get_number
|
||||
#define nvlist_get_number_array illumos_nvlist_get_number_array
|
||||
#define nvlist_get_nvlist illumos_nvlist_get_nvlist
|
||||
#define nvlist_get_nvpair illumos_nvlist_get_nvpair
|
||||
#define nvlist_get_nvpair_parent illumos_nvlist_get_nvpair_parent
|
||||
#define nvlist_get_pararr illumos_nvlist_get_pararr
|
||||
#define nvlist_get_parent illumos_nvlist_get_parent
|
||||
#define nvlist_get_string illumos_nvlist_get_string
|
||||
#define nvlist_getf_binary illumos_nvlist_getf_binary
|
||||
#define nvlist_getf_bool illumos_nvlist_getf_bool
|
||||
#define nvlist_getf_descriptor illumos_nvlist_getf_descriptor
|
||||
#define nvlist_getf_number illumos_nvlist_getf_number
|
||||
#define nvlist_getf_nvlist illumos_nvlist_getf_nvlist
|
||||
#define nvlist_getf_string illumos_nvlist_getf_string
|
||||
#define nvlist_getv_binary illumos_nvlist_getv_binary
|
||||
#define nvlist_getv_bool illumos_nvlist_getv_bool
|
||||
#define nvlist_getv_descriptor illumos_nvlist_getv_descriptor
|
||||
#define nvlist_getv_number illumos_nvlist_getv_number
|
||||
#define nvlist_getv_nvlist illumos_nvlist_getv_nvlist
|
||||
#define nvlist_getv_string illumos_nvlist_getv_string
|
||||
#define nvlist_in_array illumos_nvlist_in_array
|
||||
#define nvlist_move_binary illumos_nvlist_move_binary
|
||||
#define nvlist_move_bool_array illumos_nvlist_move_bool_array
|
||||
#define nvlist_move_descriptor illumos_nvlist_move_descriptor
|
||||
#define nvlist_move_descriptor_array illumos_nvlist_move_descriptor_array
|
||||
#define nvlist_move_number_array illumos_nvlist_move_number_array
|
||||
#define nvlist_move_nvlist illumos_nvlist_move_nvlist
|
||||
#define nvlist_move_nvlist_array illumos_nvlist_move_nvlist_array
|
||||
#define nvlist_move_nvpair illumos_nvlist_move_nvpair
|
||||
#define nvlist_move_string illumos_nvlist_move_string
|
||||
#define nvlist_movef_binary illumos_nvlist_movef_binary
|
||||
#define nvlist_movef_descriptor illumos_nvlist_movef_descriptor
|
||||
#define nvlist_movef_nvlist illumos_nvlist_movef_nvlist
|
||||
#define nvlist_movef_string illumos_nvlist_movef_string
|
||||
#define nvlist_movev_binary illumos_nvlist_movev_binary
|
||||
#define nvlist_movev_descriptor illumos_nvlist_movev_descriptor
|
||||
#define nvlist_movev_nvlist illumos_nvlist_movev_nvlist
|
||||
#define nvlist_movev_string illumos_nvlist_movev_string
|
||||
#define nvlist_move_string_array illumos_nvlist_move_string_array
|
||||
#define nvlist_ndescriptors illumos_nvlist_ndescriptors
|
||||
#define nvlist_next illumos_nvlist_next
|
||||
#define nvlist_next_nvpair illumos_nvlist_next_nvpair
|
||||
@ -168,93 +127,101 @@
|
||||
#define nvlist_prev_nvpair illumos_nvlist_prev_nvpair
|
||||
#define nvlist_recv illumos_nvlist_recv
|
||||
#define nvlist_remove_nvpair illumos_nvlist_remove_nvpair
|
||||
#define nvlist_report_missing illumos_nvlist_report_missing
|
||||
#define nvlist_send illumos_nvlist_send
|
||||
#define nvlist_set_array_next illumos_nvlist_set_array_next
|
||||
#define nvlist_set_error illumos_nvlist_set_error
|
||||
#define nvlist_set_flags illumos_nvlist_set_flags
|
||||
#define nvlist_set_parent illumos_nvlist_set_parent
|
||||
#define nvlist_size illumos_nvlist_size
|
||||
#define nvlist_take_binary illumos_nvlist_take_binary
|
||||
#define nvlist_take_bool illumos_nvlist_take_bool
|
||||
#define nvlist_take_bool_array illumos_nvlist_take_bool_array
|
||||
#define nvlist_take_descriptor illumos_nvlist_take_descriptor
|
||||
#define nvlist_take_descriptor_array illumos_nvlist_take_descriptor_array
|
||||
#define nvlist_take_number illumos_nvlist_take_number
|
||||
#define nvlist_take_number_array illumos_nvlist_take_number_array
|
||||
#define nvlist_take_nvlist illumos_nvlist_take_nvlist
|
||||
#define nvlist_take_nvlist_array illumos_nvlist_take_nvlist_array
|
||||
#define nvlist_take_nvpair illumos_nvlist_take_nvpair
|
||||
#define nvlist_take_string illumos_nvlist_take_string
|
||||
#define nvlist_takef_binary illumos_nvlist_takef_binary
|
||||
#define nvlist_takef_bool illumos_nvlist_takef_bool
|
||||
#define nvlist_takef_descriptor illumos_nvlist_takef_descriptor
|
||||
#define nvlist_takef_number illumos_nvlist_takef_number
|
||||
#define nvlist_takef_nvlist illumos_nvlist_takef_nvlist
|
||||
#define nvlist_takef_string illumos_nvlist_takef_string
|
||||
#define nvlist_takev_binary illumos_nvlist_takev_binary
|
||||
#define nvlist_takev_bool illumos_nvlist_takev_bool
|
||||
#define nvlist_takev_descriptor illumos_nvlist_takev_descriptor
|
||||
#define nvlist_takev_number illumos_nvlist_takev_number
|
||||
#define nvlist_takev_nvlist illumos_nvlist_takev_nvlist
|
||||
#define nvlist_takev_string illumos_nvlist_takev_string
|
||||
#define nvlist_take_string_array illumos_nvlist_take_string_array
|
||||
#define nvlist_unpack illumos_nvlist_unpack
|
||||
#define nvlist_unpack_header illumos_nvlist_unpack_header
|
||||
#define nvlist_xfer illumos_nvlist_xfer
|
||||
#define nvlist_xpack illumos_nvlist_xpack
|
||||
#define nvlist_xunpack illumos_nvlist_xunpack
|
||||
#define nvpair_allocv illumos_nvpair_allocv
|
||||
#define nvpair_assert illumos_nvpair_assert
|
||||
#define nvpair_clone illumos_nvpair_clone
|
||||
#define nvpair_create_binary illumos_nvpair_create_binary
|
||||
#define nvpair_create_bool illumos_nvpair_create_bool
|
||||
#define nvpair_create_bool_array illumos_nvpair_create_bool_array
|
||||
#define nvpair_create_descriptor illumos_nvpair_create_descriptor
|
||||
#define nvpair_create_descriptor_array illumos_nvpair_create_descriptor_array
|
||||
#define nvpair_create_null illumos_nvpair_create_null
|
||||
#define nvpair_create_number illumos_nvpair_create_number
|
||||
#define nvpair_create_number_array illumos_nvpair_create_number_array
|
||||
#define nvpair_create_nvlist illumos_nvpair_create_nvlist
|
||||
#define nvpair_create_nvlist_array illumos_nvpair_create_nvlist_array
|
||||
#define nvpair_create_string illumos_nvpair_create_string
|
||||
#define nvpair_create_string_array illumos_nvpair_create_string_array
|
||||
#define nvpair_create_stringf illumos_nvpair_create_stringf
|
||||
#define nvpair_create_stringv illumos_nvpair_create_stringv
|
||||
#define nvpair_createf_binary illumos_nvpair_createf_binary
|
||||
#define nvpair_createf_bool illumos_nvpair_createf_bool
|
||||
#define nvpair_createf_descriptor illumos_nvpair_createf_descriptor
|
||||
#define nvpair_createf_null illumos_nvpair_createf_null
|
||||
#define nvpair_createf_number illumos_nvpair_createf_number
|
||||
#define nvpair_createf_nvlist illumos_nvpair_createf_nvlist
|
||||
#define nvpair_createf_string illumos_nvpair_createf_string
|
||||
#define nvpair_createv_binary illumos_nvpair_createv_binary
|
||||
#define nvpair_createv_bool illumos_nvpair_createv_bool
|
||||
#define nvpair_createv_descriptor illumos_nvpair_createv_descriptor
|
||||
#define nvpair_createv_null illumos_nvpair_createv_null
|
||||
#define nvpair_createv_number illumos_nvpair_createv_number
|
||||
#define nvpair_createv_nvlist illumos_nvpair_createv_nvlist
|
||||
#define nvpair_createv_string illumos_nvpair_createv_string
|
||||
#define nvpair_free illumos_nvpair_free
|
||||
#define nvpair_free_structure illumos_nvpair_free_structure
|
||||
#define nvpair_get_binary illumos_nvpair_get_binary
|
||||
#define nvpair_get_bool illumos_nvpair_get_bool
|
||||
#define nvpair_get_bool_array illumos_nvpair_get_bool_array
|
||||
#define nvpair_get_descriptor illumos_nvpair_get_descriptor
|
||||
#define nvpair_get_descriptor_array illumos_nvpair_get_descriptor_array
|
||||
#define nvpair_get_number illumos_nvpair_get_number
|
||||
#define nvpair_get_number_array illumos_nvpair_get_number_array
|
||||
#define nvpair_get_nvlist illumos_nvpair_get_nvlist
|
||||
#define nvpair_get_string illumos_nvpair_get_string
|
||||
#define nvpair_header_size illumos_nvpair_header_size
|
||||
#define nvpair_init_datasize illumos_nvpair_init_datasize
|
||||
#define nvpair_insert illumos_nvpair_insert
|
||||
#define nvpair_move_binary illumos_nvpair_move_binary
|
||||
#define nvpair_move_bool_array illumos_nvpair_move_bool_array
|
||||
#define nvpair_move_descriptor illumos_nvpair_move_descriptor
|
||||
#define nvpair_move_descriptor_array illumos_nvpair_move_descriptor_array
|
||||
#define nvpair_move_number_array illumos_nvpair_move_number_array
|
||||
#define nvpair_move_nvlist illumos_nvpair_move_nvlist
|
||||
#define nvpair_move_nvlist_array illumos_nvpair_move_nvlist_array
|
||||
#define nvpair_move_string illumos_nvpair_move_string
|
||||
#define nvpair_movef_binary illumos_nvpair_movef_binary
|
||||
#define nvpair_movef_descriptor illumos_nvpair_movef_descriptor
|
||||
#define nvpair_movef_nvlist illumos_nvpair_movef_nvlist
|
||||
#define nvpair_movef_string illumos_nvpair_movef_string
|
||||
#define nvpair_movev_binary illumos_nvpair_movev_binary
|
||||
#define nvpair_movev_descriptor illumos_nvpair_movev_descriptor
|
||||
#define nvpair_movev_nvlist illumos_nvpair_movev_nvlist
|
||||
#define nvpair_movev_string illumos_nvpair_movev_string
|
||||
#define nvpair_move_string_array illumos_nvpair_move_string_array
|
||||
#define nvpair_name illumos_nvpair_name
|
||||
#define nvpair_next illumos_nvpair_next
|
||||
#define nvpair_nvlist illumos_nvpair_nvlist
|
||||
#define nvpair_pack illumos_nvpair_pack
|
||||
#define nvpair_pack_binary illumos_nvpair_pack_binary
|
||||
#define nvpair_pack_bool illumos_nvpair_pack_bool
|
||||
#define nvpair_pack_bool_array illumos_nvpair_pack_bool_array
|
||||
#define nvpair_pack_descriptor illumos_nvpair_pack_descriptor
|
||||
#define nvpair_pack_descriptor_array illumos_nvpair_pack_descriptor_array
|
||||
#define nvpair_pack_header illumos_nvpair_pack_header
|
||||
#define nvpair_pack_null illumos_nvpair_pack_null
|
||||
#define nvpair_pack_number illumos_nvpair_pack_number
|
||||
#define nvpair_pack_number_array illumos_nvpair_pack_number_array
|
||||
#define nvpair_pack_nvlist_array_next illumos_nvpair_pack_nvlist_array_next
|
||||
#define nvpair_pack_nvlist_up illumos_nvpair_pack_nvlist_up
|
||||
#define nvpair_pack_string illumos_nvpair_pack_string
|
||||
#define nvpair_pack_string_array illumos_nvpair_pack_string_array
|
||||
#define nvpair_prev illumos_nvpair_prev
|
||||
#define nvpair_remove illumos_nvpair_remove
|
||||
#define nvpair_size illumos_nvpair_size
|
||||
#define nvpair_type illumos_nvpair_type
|
||||
#define nvpair_type_string illumos_nvpair_type_string
|
||||
#define nvpair_unpack illumos_nvpair_unpack
|
||||
#define nvpair_unpack_binary illumos_nvpair_unpack_binary
|
||||
#define nvpair_unpack_bool illumos_nvpair_unpack_bool
|
||||
#define nvpair_unpack_bool_array illumos_nvpair_unpack_bool_array
|
||||
#define nvpair_unpack_descriptor illumos_nvpair_unpack_descriptor
|
||||
#define nvpair_unpack_descriptor_array illumos_nvpair_unpack_descriptor_array
|
||||
#define nvpair_unpack_header illumos_nvpair_unpack_header
|
||||
#define nvpair_unpack_null illumos_nvpair_unpack_null
|
||||
#define nvpair_unpack_number illumos_nvpair_unpack_number
|
||||
#define nvpair_unpack_number_array illumos_nvpair_unpack_number_array
|
||||
#define nvpair_unpack_nvlist illumos_nvpair_unpack_nvlist
|
||||
#define nvpair_unpack_nvlist_array illumos_nvpair_unpack_nvlist_array
|
||||
#define nvpair_unpack_string illumos_nvpair_unpack_string
|
||||
#define nvpair_unpack_string_array illumos_nvpair_unpack_string_array
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 The FreeBSD Foundation
|
||||
* Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Pawel Jakub Dawidek under sponsorship from
|
||||
@ -39,12 +40,14 @@ struct nvpair;
|
||||
typedef struct nvpair nvpair_t;
|
||||
#endif
|
||||
|
||||
#define NV_TYPE_NVLIST_ARRAY_NEXT 254
|
||||
#define NV_TYPE_NVLIST_UP 255
|
||||
|
||||
#define NV_TYPE_FIRST NV_TYPE_NULL
|
||||
#define NV_TYPE_LAST NV_TYPE_BINARY
|
||||
#define NV_TYPE_LAST NV_TYPE_DESCRIPTOR_ARRAY
|
||||
|
||||
#define NV_FLAG_BIG_ENDIAN 0x80
|
||||
#define NV_FLAG_BIG_ENDIAN 0x080
|
||||
#define NV_FLAG_IN_ARRAY 0x100
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define nv_malloc(size) malloc((size), M_NVLIST, M_WAITOK)
|
||||
@ -86,6 +89,7 @@ typedef struct nvpair nvpair_t;
|
||||
|
||||
int *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp);
|
||||
size_t nvlist_ndescriptors(const nvlist_t *nvl);
|
||||
void nvlist_set_flags(nvlist_t *nvl, int flags);
|
||||
|
||||
nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl);
|
||||
nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
|
||||
@ -96,6 +100,7 @@ void nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp);
|
||||
bool nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp);
|
||||
|
||||
void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent);
|
||||
void nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele);
|
||||
|
||||
const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name);
|
||||
|
||||
@ -120,18 +125,33 @@ nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, va_list
|
||||
nvpair_t *nvpair_create_nvlist(const char *name, const nvlist_t *value);
|
||||
nvpair_t *nvpair_create_descriptor(const char *name, int value);
|
||||
nvpair_t *nvpair_create_binary(const char *name, const void *value, size_t size);
|
||||
nvpair_t *nvpair_create_bool_array(const char *name, const bool *value, size_t nitems);
|
||||
nvpair_t *nvpair_create_number_array(const char *name, const uint64_t *value, size_t nitems);
|
||||
nvpair_t *nvpair_create_string_array(const char *name, const char * const *value, size_t nitems);
|
||||
nvpair_t *nvpair_create_nvlist_array(const char *name, const nvlist_t * const *value, size_t nitems);
|
||||
nvpair_t *nvpair_create_descriptor_array(const char *name, const int *value, size_t nitems);
|
||||
|
||||
nvpair_t *nvpair_move_string(const char *name, char *value);
|
||||
nvpair_t *nvpair_move_nvlist(const char *name, nvlist_t *value);
|
||||
nvpair_t *nvpair_move_descriptor(const char *name, int value);
|
||||
nvpair_t *nvpair_move_binary(const char *name, void *value, size_t size);
|
||||
nvpair_t *nvpair_move_bool_array(const char *name, bool *value, size_t nitems);
|
||||
nvpair_t *nvpair_move_nvlist_array(const char *name, nvlist_t **value, size_t nitems);
|
||||
nvpair_t *nvpair_move_descriptor_array(const char *name, int *value, size_t nitems);
|
||||
nvpair_t *nvpair_move_number_array(const char *name, uint64_t *value, size_t nitems);
|
||||
nvpair_t *nvpair_move_string_array(const char *name, char **value, size_t nitems);
|
||||
|
||||
bool nvpair_get_bool(const nvpair_t *nvp);
|
||||
uint64_t nvpair_get_number(const nvpair_t *nvp);
|
||||
const char *nvpair_get_string(const nvpair_t *nvp);
|
||||
const nvlist_t *nvpair_get_nvlist(const nvpair_t *nvp);
|
||||
int nvpair_get_descriptor(const nvpair_t *nvp);
|
||||
const void *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
|
||||
bool nvpair_get_bool(const nvpair_t *nvp);
|
||||
uint64_t nvpair_get_number(const nvpair_t *nvp);
|
||||
const char *nvpair_get_string(const nvpair_t *nvp);
|
||||
const nvlist_t *nvpair_get_nvlist(const nvpair_t *nvp);
|
||||
int nvpair_get_descriptor(const nvpair_t *nvp);
|
||||
const void *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
|
||||
const bool *nvpair_get_bool_array(const nvpair_t *nvp, size_t *nitemsp);
|
||||
const uint64_t *nvpair_get_number_array(const nvpair_t *nvp, size_t *nitemsp);
|
||||
const char * const *nvpair_get_string_array(const nvpair_t *nvp, size_t *nitemsp);
|
||||
const nvlist_t * const *nvpair_get_nvlist_array(const nvpair_t *nvp, size_t *nitemsp);
|
||||
const int *nvpair_get_descriptor_array(const nvpair_t *nvp, size_t *nitemsp);
|
||||
|
||||
void nvpair_free(nvpair_t *nvp);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2013 The FreeBSD Foundation
|
||||
* Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Pawel Jakub Dawidek under sponsorship from
|
||||
@ -88,7 +89,7 @@ __FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define NV_FLAG_PRIVATE_MASK (NV_FLAG_BIG_ENDIAN)
|
||||
#define NV_FLAG_PRIVATE_MASK (NV_FLAG_BIG_ENDIAN | NV_FLAG_IN_ARRAY)
|
||||
#define NV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE | NV_FLAG_NO_UNIQUE)
|
||||
#define NV_FLAG_ALL_MASK (NV_FLAG_PRIVATE_MASK | NV_FLAG_PUBLIC_MASK)
|
||||
|
||||
@ -98,6 +99,7 @@ struct nvlist {
|
||||
int nvl_error;
|
||||
int nvl_flags;
|
||||
nvpair_t *nvl_parent;
|
||||
nvpair_t *nvl_array_next;
|
||||
struct nvl_head nvl_head;
|
||||
};
|
||||
|
||||
@ -135,6 +137,7 @@ nvlist_create(int flags)
|
||||
nvl->nvl_error = 0;
|
||||
nvl->nvl_flags = flags;
|
||||
nvl->nvl_parent = NULL;
|
||||
nvl->nvl_array_next = NULL;
|
||||
TAILQ_INIT(&nvl->nvl_head);
|
||||
nvl->nvl_magic = NVLIST_MAGIC;
|
||||
|
||||
@ -157,6 +160,10 @@ nvlist_destroy(nvlist_t *nvl)
|
||||
nvlist_remove_nvpair(nvl, nvp);
|
||||
nvpair_free(nvp);
|
||||
}
|
||||
if (nvl->nvl_array_next != NULL)
|
||||
nvpair_free_structure(nvl->nvl_array_next);
|
||||
nvl->nvl_array_next = NULL;
|
||||
nvl->nvl_parent = NULL;
|
||||
nvl->nvl_magic = 0;
|
||||
nv_free(nvl);
|
||||
|
||||
@ -223,6 +230,59 @@ nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent)
|
||||
nvl->nvl_parent = parent;
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele)
|
||||
{
|
||||
|
||||
NVLIST_ASSERT(nvl);
|
||||
|
||||
if (ele != NULL)
|
||||
nvl->nvl_flags |= NV_FLAG_IN_ARRAY;
|
||||
else
|
||||
nvl->nvl_flags &= ~NV_FLAG_IN_ARRAY;
|
||||
|
||||
nvl->nvl_array_next = ele;
|
||||
}
|
||||
|
||||
bool
|
||||
nvlist_in_array(const nvlist_t *nvl)
|
||||
{
|
||||
|
||||
NVLIST_ASSERT(nvl);
|
||||
|
||||
return ((nvl->nvl_flags & NV_FLAG_IN_ARRAY) != 0);
|
||||
}
|
||||
|
||||
const nvlist_t *
|
||||
nvlist_get_array_next(const nvlist_t *nvl)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
NVLIST_ASSERT(nvl);
|
||||
|
||||
nvp = nvl->nvl_array_next;
|
||||
if (nvp == NULL)
|
||||
return (NULL);
|
||||
|
||||
return (nvpair_get_nvlist(nvp));
|
||||
}
|
||||
|
||||
const nvlist_t *
|
||||
nvlist_get_pararr(const nvlist_t *nvl, void **cookiep)
|
||||
{
|
||||
const nvlist_t *ret;
|
||||
|
||||
ret = nvlist_get_array_next(nvl);
|
||||
if (ret != NULL) {
|
||||
if (cookiep != NULL)
|
||||
*cookiep = NULL;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
ret = nvlist_get_parent(nvl, cookiep);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
bool
|
||||
nvlist_empty(const nvlist_t *nvl)
|
||||
{
|
||||
@ -239,9 +299,18 @@ nvlist_flags(const nvlist_t *nvl)
|
||||
|
||||
NVLIST_ASSERT(nvl);
|
||||
PJDLOG_ASSERT(nvl->nvl_error == 0);
|
||||
PJDLOG_ASSERT((nvl->nvl_flags & ~(NV_FLAG_PUBLIC_MASK)) == 0);
|
||||
|
||||
return (nvl->nvl_flags);
|
||||
return (nvl->nvl_flags & NV_FLAG_PUBLIC_MASK);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_set_flags(nvlist_t *nvl, int flags)
|
||||
{
|
||||
|
||||
NVLIST_ASSERT(nvl);
|
||||
PJDLOG_ASSERT(nvl->nvl_error == 0);
|
||||
|
||||
nvl->nvl_flags = flags;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -418,17 +487,129 @@ nvlist_dump(const nvlist_t *nvl, int fd)
|
||||
dprintf(fd, "\n");
|
||||
break;
|
||||
}
|
||||
case NV_TYPE_BOOL_ARRAY:
|
||||
{
|
||||
const bool *value;
|
||||
unsigned int ii;
|
||||
size_t nitems;
|
||||
|
||||
value = nvpair_get_bool_array(nvp, &nitems);
|
||||
dprintf(fd, " [ ");
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
dprintf(fd, "%s", value[ii] ? "TRUE" : "FALSE");
|
||||
if (ii != nitems - 1)
|
||||
dprintf(fd, ", ");
|
||||
}
|
||||
dprintf(fd, " ]\n");
|
||||
break;
|
||||
}
|
||||
case NV_TYPE_STRING_ARRAY:
|
||||
{
|
||||
const char * const *value;
|
||||
unsigned int ii;
|
||||
size_t nitems;
|
||||
|
||||
value = nvpair_get_string_array(nvp, &nitems);
|
||||
dprintf(fd, " [ ");
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
if (value[ii] == NULL)
|
||||
dprintf(fd, "NULL");
|
||||
else
|
||||
dprintf(fd, "\"%s\"", value[ii]);
|
||||
if (ii != nitems - 1)
|
||||
dprintf(fd, ", ");
|
||||
}
|
||||
dprintf(fd, " ]\n");
|
||||
break;
|
||||
}
|
||||
case NV_TYPE_NUMBER_ARRAY:
|
||||
{
|
||||
const uint64_t *value;
|
||||
unsigned int ii;
|
||||
size_t nitems;
|
||||
|
||||
value = nvpair_get_number_array(nvp, &nitems);
|
||||
dprintf(fd, " [ ");
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
dprintf(fd, "%ju (%jd) (0x%jx)",
|
||||
value[ii], value[ii], value[ii]);
|
||||
if (ii != nitems - 1)
|
||||
dprintf(fd, ", ");
|
||||
}
|
||||
dprintf(fd, " ]\n");
|
||||
break;
|
||||
}
|
||||
case NV_TYPE_DESCRIPTOR_ARRAY:
|
||||
{
|
||||
const int *value;
|
||||
unsigned int ii;
|
||||
size_t nitems;
|
||||
|
||||
value = nvpair_get_descriptor_array(nvp, &nitems);
|
||||
dprintf(fd, " [ ");
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
dprintf(fd, "%d", value[ii]);
|
||||
if (ii != nitems - 1)
|
||||
dprintf(fd, ", ");
|
||||
}
|
||||
dprintf(fd, " ]\n");
|
||||
break;
|
||||
}
|
||||
case NV_TYPE_NVLIST_ARRAY:
|
||||
{
|
||||
const nvlist_t * const *value;
|
||||
unsigned int ii;
|
||||
size_t nitems;
|
||||
|
||||
value = nvpair_get_nvlist_array(nvp, &nitems);
|
||||
dprintf(fd, " %zu\n", nitems);
|
||||
tmpnvl = NULL;
|
||||
tmpnvp = NULL;
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
if (nvlist_dump_error_check(value[ii], fd,
|
||||
level + 1)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (tmpnvl == NULL) {
|
||||
tmpnvp = nvlist_first_nvpair(value[ii]);
|
||||
if (tmpnvp != NULL) {
|
||||
tmpnvl = value[ii];
|
||||
} else {
|
||||
dprintf(fd, "%*s,\n",
|
||||
(level + 1) * 4, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tmpnvp != NULL) {
|
||||
nvl = tmpnvl;
|
||||
nvp = tmpnvp;
|
||||
level++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
PJDLOG_ABORT("Unknown type: %d.", nvpair_type(nvp));
|
||||
}
|
||||
|
||||
while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) {
|
||||
cookie = NULL;
|
||||
nvl = nvlist_get_parent(nvl, &cookie);
|
||||
if (nvl == NULL)
|
||||
return;
|
||||
nvp = cookie;
|
||||
level--;
|
||||
do {
|
||||
cookie = NULL;
|
||||
if (nvlist_in_array(nvl))
|
||||
dprintf(fd, "%*s,\n", level * 4, "");
|
||||
nvl = nvlist_get_pararr(nvl, &cookie);
|
||||
if (nvl == NULL)
|
||||
return;
|
||||
if (nvlist_in_array(nvl) && cookie == NULL) {
|
||||
nvp = nvlist_first_nvpair(nvl);
|
||||
} else {
|
||||
nvp = cookie;
|
||||
level--;
|
||||
}
|
||||
} while (nvp == NULL);
|
||||
if (nvlist_in_array(nvl) && cookie == NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -449,9 +630,11 @@ size_t
|
||||
nvlist_size(const nvlist_t *nvl)
|
||||
{
|
||||
const nvlist_t *tmpnvl;
|
||||
const nvlist_t * const *nvlarray;
|
||||
const nvpair_t *nvp, *tmpnvp;
|
||||
void *cookie;
|
||||
size_t size;
|
||||
size_t size, nitems;
|
||||
unsigned int ii;
|
||||
|
||||
NVLIST_ASSERT(nvl);
|
||||
PJDLOG_ASSERT(nvl->nvl_error == 0);
|
||||
@ -472,16 +655,47 @@ nvlist_size(const nvlist_t *nvl)
|
||||
nvp = tmpnvp;
|
||||
continue;
|
||||
}
|
||||
} else if (nvpair_type(nvp) == NV_TYPE_NVLIST_ARRAY) {
|
||||
nvlarray = nvpair_get_nvlist_array(nvp, &nitems);
|
||||
PJDLOG_ASSERT(nitems > 0);
|
||||
|
||||
size += (nvpair_header_size() + 1) * nitems;
|
||||
size += sizeof(struct nvlist_header) * nitems;
|
||||
|
||||
tmpnvl = NULL;
|
||||
tmpnvp = NULL;
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
PJDLOG_ASSERT(nvlarray[ii]->nvl_error == 0);
|
||||
tmpnvp = nvlist_first_nvpair(nvlarray[ii]);
|
||||
if (tmpnvp != NULL) {
|
||||
tmpnvl = nvlarray[ii];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmpnvp != NULL) {
|
||||
nvp = tmpnvp;
|
||||
nvl = tmpnvl;
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
size += nvpair_size(nvp);
|
||||
}
|
||||
|
||||
while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) {
|
||||
cookie = NULL;
|
||||
nvl = nvlist_get_parent(nvl, &cookie);
|
||||
if (nvl == NULL)
|
||||
goto out;
|
||||
nvp = cookie;
|
||||
do {
|
||||
cookie = NULL;
|
||||
nvl = nvlist_get_pararr(nvl, &cookie);
|
||||
if (nvl == NULL)
|
||||
goto out;
|
||||
if (nvlist_in_array(nvl) && cookie == NULL) {
|
||||
nvp = nvlist_first_nvpair(nvl);
|
||||
} else {
|
||||
nvp = cookie;
|
||||
}
|
||||
} while (nvp == NULL);
|
||||
if (nvlist_in_array(nvl) && cookie == NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,13 +722,40 @@ nvlist_xdescriptors(const nvlist_t *nvl, int *descs)
|
||||
*descs = nvpair_get_descriptor(nvp);
|
||||
descs++;
|
||||
break;
|
||||
case NV_TYPE_DESCRIPTOR_ARRAY:
|
||||
{
|
||||
const int *value;
|
||||
size_t nitems;
|
||||
unsigned int ii;
|
||||
|
||||
value = nvpair_get_descriptor_array(nvp,
|
||||
&nitems);
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
*descs = value[ii];
|
||||
descs++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NV_TYPE_NVLIST:
|
||||
nvl = nvpair_get_nvlist(nvp);
|
||||
nvp = NULL;
|
||||
break;
|
||||
case NV_TYPE_NVLIST_ARRAY:
|
||||
{
|
||||
const nvlist_t * const *value;
|
||||
size_t nitems;
|
||||
|
||||
value = nvpair_get_nvlist_array(nvp, &nitems);
|
||||
PJDLOG_ASSERT(value != NULL);
|
||||
PJDLOG_ASSERT(nitems > 0);
|
||||
|
||||
nvl = value[0];
|
||||
nvp = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while ((nvl = nvlist_get_parent(nvl, (void**)&nvp)) != NULL);
|
||||
} while ((nvl = nvlist_get_pararr(nvl, (void**)&nvp)) != NULL);
|
||||
|
||||
return (descs);
|
||||
}
|
||||
@ -564,9 +805,31 @@ nvlist_ndescriptors(const nvlist_t *nvl)
|
||||
nvl = nvpair_get_nvlist(nvp);
|
||||
nvp = NULL;
|
||||
break;
|
||||
case NV_TYPE_NVLIST_ARRAY:
|
||||
{
|
||||
const nvlist_t * const *value;
|
||||
size_t nitems;
|
||||
|
||||
value = nvpair_get_nvlist_array(nvp, &nitems);
|
||||
PJDLOG_ASSERT(value != NULL);
|
||||
PJDLOG_ASSERT(nitems > 0);
|
||||
|
||||
nvl = value[0];
|
||||
nvp = NULL;
|
||||
break;
|
||||
}
|
||||
case NV_TYPE_DESCRIPTOR_ARRAY:
|
||||
{
|
||||
size_t nitems;
|
||||
|
||||
(void)nvpair_get_descriptor_array(nvp,
|
||||
&nitems);
|
||||
ndescs += nitems;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while ((nvl = nvlist_get_parent(nvl, (void**)&nvp)) != NULL);
|
||||
} while ((nvl = nvlist_get_pararr(nvl, (void**)&nvp)) != NULL);
|
||||
|
||||
return (ndescs);
|
||||
#else
|
||||
@ -661,24 +924,86 @@ nvlist_xpack(const nvlist_t *nvl, int64_t *fdidxp, size_t *sizep)
|
||||
case NV_TYPE_DESCRIPTOR:
|
||||
ptr = nvpair_pack_descriptor(nvp, ptr, fdidxp, &left);
|
||||
break;
|
||||
case NV_TYPE_DESCRIPTOR_ARRAY:
|
||||
ptr = nvpair_pack_descriptor_array(nvp, ptr, fdidxp,
|
||||
&left);
|
||||
break;
|
||||
#endif
|
||||
case NV_TYPE_BINARY:
|
||||
ptr = nvpair_pack_binary(nvp, ptr, &left);
|
||||
break;
|
||||
case NV_TYPE_BOOL_ARRAY:
|
||||
ptr = nvpair_pack_bool_array(nvp, ptr, &left);
|
||||
break;
|
||||
case NV_TYPE_NUMBER_ARRAY:
|
||||
ptr = nvpair_pack_number_array(nvp, ptr, &left);
|
||||
break;
|
||||
case NV_TYPE_STRING_ARRAY:
|
||||
ptr = nvpair_pack_string_array(nvp, ptr, &left);
|
||||
break;
|
||||
case NV_TYPE_NVLIST_ARRAY:
|
||||
{
|
||||
const nvlist_t * const * value;
|
||||
size_t nitems;
|
||||
unsigned int ii;
|
||||
|
||||
tmpnvl = NULL;
|
||||
value = nvpair_get_nvlist_array(nvp, &nitems);
|
||||
for (ii = 0; ii < nitems; ii++) {
|
||||
ptr = nvlist_pack_header(value[ii], ptr, &left);
|
||||
if (ptr == NULL)
|
||||
goto out;
|
||||
tmpnvp = nvlist_first_nvpair(value[ii]);
|
||||
if (tmpnvp != NULL) {
|
||||
tmpnvl = value[ii];
|
||||
break;
|
||||
}
|
||||
ptr = nvpair_pack_nvlist_array_next(ptr, &left);
|
||||
if (ptr == NULL)
|
||||
goto out;
|
||||
}
|
||||
if (tmpnvl != NULL) {
|
||||
nvl = tmpnvl;
|
||||
nvp = tmpnvp;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp));
|
||||
}
|
||||
if (ptr == NULL)
|
||||
goto fail;
|
||||
while ((nvp = nvlist_next_nvpair(nvl, nvp)) == NULL) {
|
||||
cookie = NULL;
|
||||
nvl = nvlist_get_parent(nvl, &cookie);
|
||||
if (nvl == NULL)
|
||||
goto out;
|
||||
nvp = cookie;
|
||||
ptr = nvpair_pack_nvlist_up(ptr, &left);
|
||||
if (ptr == NULL)
|
||||
goto fail;
|
||||
do {
|
||||
cookie = NULL;
|
||||
if (nvlist_in_array(nvl)) {
|
||||
ptr = nvpair_pack_nvlist_array_next(ptr,
|
||||
&left);
|
||||
if (ptr == NULL)
|
||||
goto fail;
|
||||
}
|
||||
nvl = nvlist_get_pararr(nvl, &cookie);
|
||||
if (nvl == NULL)
|
||||
goto out;
|
||||
if (nvlist_in_array(nvl) && cookie == NULL) {
|
||||
nvp = nvlist_first_nvpair(nvl);
|
||||
ptr = nvlist_pack_header(nvl, ptr,
|
||||
&left);
|
||||
if (ptr == NULL)
|
||||
goto fail;
|
||||
} else if (nvpair_type((nvpair_t *)cookie) !=
|
||||
NV_TYPE_NVLIST_ARRAY) {
|
||||
ptr = nvpair_pack_nvlist_up(ptr, &left);
|
||||
if (ptr == NULL)
|
||||
goto fail;
|
||||
nvp = cookie;
|
||||
} else {
|
||||
nvp = cookie;
|
||||
}
|
||||
} while (nvp == NULL);
|
||||
if (nvlist_in_array(nvl) && cookie == NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -741,6 +1066,7 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned char *ptr, size_t nfds,
|
||||
bool *isbep, size_t *leftp)
|
||||
{
|
||||
struct nvlist_header nvlhdr;
|
||||
int inarrayf;
|
||||
|
||||
if (*leftp < sizeof(nvlhdr))
|
||||
goto failed;
|
||||
@ -762,7 +1088,8 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned char *ptr, size_t nfds,
|
||||
if ((nvlhdr.nvlh_flags & ~NV_FLAG_ALL_MASK) != 0)
|
||||
goto failed;
|
||||
|
||||
nvl->nvl_flags = (nvlhdr.nvlh_flags & NV_FLAG_PUBLIC_MASK);
|
||||
inarrayf = (nvl->nvl_flags & NV_FLAG_IN_ARRAY);
|
||||
nvl->nvl_flags = (nvlhdr.nvlh_flags & NV_FLAG_PUBLIC_MASK) | inarrayf;
|
||||
|
||||
ptr += sizeof(nvlhdr);
|
||||
if (isbep != NULL)
|
||||
@ -780,7 +1107,7 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds,
|
||||
int flags)
|
||||
{
|
||||
const unsigned char *ptr;
|
||||
nvlist_t *nvl, *retnvl, *tmpnvl;
|
||||
nvlist_t *nvl, *retnvl, *tmpnvl, *array;
|
||||
nvpair_t *nvp;
|
||||
size_t left;
|
||||
bool isbe;
|
||||
@ -790,7 +1117,7 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds,
|
||||
left = size;
|
||||
ptr = buf;
|
||||
|
||||
tmpnvl = NULL;
|
||||
tmpnvl = array = NULL;
|
||||
nvl = retnvl = nvlist_create(0);
|
||||
if (nvl == NULL)
|
||||
goto failed;
|
||||
@ -832,6 +1159,10 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds,
|
||||
ptr = nvpair_unpack_descriptor(isbe, nvp, ptr, &left,
|
||||
fds, nfds);
|
||||
break;
|
||||
case NV_TYPE_DESCRIPTOR_ARRAY:
|
||||
ptr = nvpair_unpack_descriptor_array(isbe, nvp, ptr,
|
||||
&left, fds, nfds);
|
||||
break;
|
||||
#endif
|
||||
case NV_TYPE_BINARY:
|
||||
ptr = nvpair_unpack_binary(isbe, nvp, ptr, &left);
|
||||
@ -842,6 +1173,44 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds,
|
||||
nvl = nvpair_nvlist(nvl->nvl_parent);
|
||||
nvpair_free_structure(nvp);
|
||||
continue;
|
||||
case NV_TYPE_NVLIST_ARRAY_NEXT:
|
||||
if (nvl->nvl_array_next == NULL) {
|
||||
if (nvl->nvl_parent == NULL)
|
||||
goto failed;
|
||||
nvl = nvpair_nvlist(nvl->nvl_parent);
|
||||
} else {
|
||||
nvl = __DECONST(nvlist_t *,
|
||||
nvlist_get_array_next(nvl));
|
||||
ptr = nvlist_unpack_header(nvl, ptr, nfds,
|
||||
&isbe, &left);
|
||||
if (ptr == NULL)
|
||||
goto failed;
|
||||
}
|
||||
nvpair_free_structure(nvp);
|
||||
continue;
|
||||
case NV_TYPE_BOOL_ARRAY:
|
||||
ptr = nvpair_unpack_bool_array(isbe, nvp, ptr, &left);
|
||||
break;
|
||||
case NV_TYPE_NUMBER_ARRAY:
|
||||
ptr = nvpair_unpack_number_array(isbe, nvp, ptr, &left);
|
||||
break;
|
||||
case NV_TYPE_STRING_ARRAY:
|
||||
ptr = nvpair_unpack_string_array(isbe, nvp, ptr, &left);
|
||||
break;
|
||||
case NV_TYPE_NVLIST_ARRAY:
|
||||
ptr = nvpair_unpack_nvlist_array(isbe, nvp, ptr, &left,
|
||||
&array);
|
||||
if (ptr == NULL)
|
||||
goto failed;
|
||||
tmpnvl = array;
|
||||
while (array != NULL) {
|
||||
nvlist_set_parent(array, nvp);
|
||||
array = __DECONST(nvlist_t *,
|
||||
nvlist_get_array_next(array));
|
||||
}
|
||||
ptr = nvlist_unpack_header(tmpnvl, ptr, nfds, &isbe,
|
||||
&left);
|
||||
break;
|
||||
default:
|
||||
PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp));
|
||||
}
|
||||
@ -1062,10 +1431,15 @@ NVLIST_EXISTS(bool, BOOL)
|
||||
NVLIST_EXISTS(number, NUMBER)
|
||||
NVLIST_EXISTS(string, STRING)
|
||||
NVLIST_EXISTS(nvlist, NVLIST)
|
||||
NVLIST_EXISTS(binary, BINARY)
|
||||
NVLIST_EXISTS(bool_array, BOOL_ARRAY)
|
||||
NVLIST_EXISTS(number_array, NUMBER_ARRAY)
|
||||
NVLIST_EXISTS(string_array, STRING_ARRAY)
|
||||
NVLIST_EXISTS(nvlist_array, NVLIST_ARRAY)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_EXISTS(descriptor, DESCRIPTOR)
|
||||
NVLIST_EXISTS(descriptor_array, DESCRIPTOR_ARRAY)
|
||||
#endif
|
||||
NVLIST_EXISTS(binary, BINARY)
|
||||
|
||||
#undef NVLIST_EXISTS
|
||||
|
||||
@ -1198,6 +1572,37 @@ NVLIST_ADD(int, descriptor);
|
||||
|
||||
#undef NVLIST_ADD
|
||||
|
||||
#define NVLIST_ADD_ARRAY(vtype, type) \
|
||||
void \
|
||||
nvlist_add_##type##_array(nvlist_t *nvl, const char *name, vtype value, \
|
||||
size_t nitems) \
|
||||
{ \
|
||||
nvpair_t *nvp; \
|
||||
\
|
||||
if (nvlist_error(nvl) != 0) { \
|
||||
ERRNO_SET(nvlist_error(nvl)); \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
nvp = nvpair_create_##type##_array(name, value, nitems); \
|
||||
if (nvp == NULL) { \
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \
|
||||
ERRNO_SET(nvl->nvl_error); \
|
||||
} else { \
|
||||
(void)nvlist_move_nvpair(nvl, nvp); \
|
||||
} \
|
||||
}
|
||||
|
||||
NVLIST_ADD_ARRAY(const bool *, bool)
|
||||
NVLIST_ADD_ARRAY(const uint64_t *, number)
|
||||
NVLIST_ADD_ARRAY(const char * const *, string)
|
||||
NVLIST_ADD_ARRAY(const nvlist_t * const *, nvlist)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_ADD_ARRAY(const int *, descriptor)
|
||||
#endif
|
||||
|
||||
#undef NVLIST_ADD_ARRAY
|
||||
|
||||
bool
|
||||
nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp)
|
||||
{
|
||||
@ -1306,6 +1711,131 @@ nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_move_bool_array(nvlist_t *nvl, const char *name, bool *value,
|
||||
size_t nitems)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
nv_free(value);
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_move_bool_array(name, value, nitems);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
ERRNO_SET(nvl->nvl_error);
|
||||
} else {
|
||||
(void)nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_move_string_array(nvlist_t *nvl, const char *name, char **value,
|
||||
size_t nitems)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
size_t i;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
if (value != NULL) {
|
||||
for (i = 0; i < nitems; i++)
|
||||
nv_free(value[i]);
|
||||
nv_free(value);
|
||||
}
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_move_string_array(name, value, nitems);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
ERRNO_SET(nvl->nvl_error);
|
||||
} else {
|
||||
(void)nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_move_nvlist_array(nvlist_t *nvl, const char *name, nvlist_t **value,
|
||||
size_t nitems)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
size_t i;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
if (value != NULL) {
|
||||
for (i = 0; i < nitems; i++) {
|
||||
if (nvlist_get_pararr(value[i], NULL) == NULL)
|
||||
nvlist_destroy(value[i]);
|
||||
}
|
||||
}
|
||||
nv_free(value);
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_move_nvlist_array(name, value, nitems);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
ERRNO_SET(nvl->nvl_error);
|
||||
} else {
|
||||
(void)nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_move_number_array(nvlist_t *nvl, const char *name, uint64_t *value,
|
||||
size_t nitems)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
nv_free(value);
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_move_number_array(name, value, nitems);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
ERRNO_SET(nvl->nvl_error);
|
||||
} else {
|
||||
(void)nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
nvlist_move_descriptor_array(nvlist_t *nvl, const char *name, int *value,
|
||||
size_t nitems)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
size_t i;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
if (value != 0) {
|
||||
for (i = 0; i < nitems; i++)
|
||||
close(value[i]);
|
||||
nv_free(value);
|
||||
}
|
||||
|
||||
ERRNO_SET(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_move_descriptor_array(name, value, nitems);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
ERRNO_SET(nvl->nvl_error);
|
||||
} else {
|
||||
(void)nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
const nvpair_t *
|
||||
nvlist_get_nvpair(const nvlist_t *nvl, const char *name)
|
||||
{
|
||||
@ -1347,6 +1877,29 @@ nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep)
|
||||
return (nvpair_get_binary(nvp, sizep));
|
||||
}
|
||||
|
||||
#define NVLIST_GET_ARRAY(ftype, type, TYPE) \
|
||||
ftype \
|
||||
nvlist_get_##type##_array(const nvlist_t *nvl, const char *name, \
|
||||
size_t *nitems) \
|
||||
{ \
|
||||
const nvpair_t *nvp; \
|
||||
\
|
||||
nvp = nvlist_find(nvl, NV_TYPE_##TYPE##_ARRAY, name); \
|
||||
if (nvp == NULL) \
|
||||
nvlist_report_missing(NV_TYPE_##TYPE##_ARRAY, name); \
|
||||
return (nvpair_get_##type##_array(nvp, nitems)); \
|
||||
}
|
||||
|
||||
NVLIST_GET_ARRAY(const bool *, bool, BOOL)
|
||||
NVLIST_GET_ARRAY(const uint64_t *, number, NUMBER)
|
||||
NVLIST_GET_ARRAY(const char * const *, string, STRING)
|
||||
NVLIST_GET_ARRAY(const nvlist_t * const *, nvlist, NVLIST)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_GET_ARRAY(const int *, descriptor, DESCRIPTOR)
|
||||
#endif
|
||||
|
||||
#undef NVLIST_GET_ARRAY
|
||||
|
||||
#define NVLIST_TAKE(ftype, type, TYPE) \
|
||||
ftype \
|
||||
nvlist_take_##type(nvlist_t *nvl, const char *name) \
|
||||
@ -1389,6 +1942,31 @@ nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep)
|
||||
return (value);
|
||||
}
|
||||
|
||||
#define NVLIST_TAKE_ARRAY(ftype, type, TYPE) \
|
||||
ftype \
|
||||
nvlist_take_##type##_array(nvlist_t *nvl, const char *name, \
|
||||
size_t *nitems) \
|
||||
{ \
|
||||
nvpair_t *nvp; \
|
||||
ftype value; \
|
||||
\
|
||||
nvp = nvlist_find(nvl, NV_TYPE_##TYPE##_ARRAY, name); \
|
||||
if (nvp == NULL) \
|
||||
nvlist_report_missing(NV_TYPE_##TYPE##_ARRAY, name); \
|
||||
value = (ftype)(intptr_t)nvpair_get_##type##_array(nvp, nitems);\
|
||||
nvlist_remove_nvpair(nvl, nvp); \
|
||||
nvpair_free_structure(nvp); \
|
||||
return (value); \
|
||||
}
|
||||
|
||||
NVLIST_TAKE_ARRAY(bool *, bool, BOOL)
|
||||
NVLIST_TAKE_ARRAY(uint64_t *, number, NUMBER)
|
||||
NVLIST_TAKE_ARRAY(char **, string, STRING)
|
||||
NVLIST_TAKE_ARRAY(nvlist_t **, nvlist, NVLIST)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_TAKE_ARRAY(int *, descriptor, DESCRIPTOR)
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp)
|
||||
{
|
||||
@ -1420,10 +1998,15 @@ NVLIST_FREE(bool, BOOL)
|
||||
NVLIST_FREE(number, NUMBER)
|
||||
NVLIST_FREE(string, STRING)
|
||||
NVLIST_FREE(nvlist, NVLIST)
|
||||
NVLIST_FREE(binary, BINARY)
|
||||
NVLIST_FREE(bool_array, BOOL_ARRAY)
|
||||
NVLIST_FREE(number_array, NUMBER_ARRAY)
|
||||
NVLIST_FREE(string_array, STRING_ARRAY)
|
||||
NVLIST_FREE(nvlist_array, NVLIST_ARRAY)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_FREE(descriptor, DESCRIPTOR)
|
||||
NVLIST_FREE(descriptor_array, DESCRIPTOR_ARRAY)
|
||||
#endif
|
||||
NVLIST_FREE(binary, BINARY)
|
||||
|
||||
#undef NVLIST_FREE
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 The FreeBSD Foundation
|
||||
* Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Pawel Jakub Dawidek under sponsorship from
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2013 The FreeBSD Foundation
|
||||
* Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Pawel Jakub Dawidek under sponsorship from
|
||||
@ -71,6 +72,15 @@ unsigned char *nvpair_pack_descriptor(const nvpair_t *nvp, unsigned char *ptr,
|
||||
unsigned char *nvpair_pack_binary(const nvpair_t *nvp, unsigned char *ptr,
|
||||
size_t *leftp);
|
||||
unsigned char *nvpair_pack_nvlist_up(unsigned char *ptr, size_t *leftp);
|
||||
unsigned char *nvpair_pack_bool_array(const nvpair_t *nvp, unsigned char *ptr,
|
||||
size_t *leftp);
|
||||
unsigned char *nvpair_pack_number_array(const nvpair_t *nvp, unsigned char *ptr,
|
||||
size_t *leftp);
|
||||
unsigned char *nvpair_pack_string_array(const nvpair_t *nvp, unsigned char *ptr,
|
||||
size_t *leftp);
|
||||
unsigned char *nvpair_pack_descriptor_array(const nvpair_t *nvp,
|
||||
unsigned char *ptr, int64_t *fdidxp, size_t *leftp);
|
||||
unsigned char *nvpair_pack_nvlist_array_next(unsigned char *ptr, size_t *leftp);
|
||||
|
||||
/* Unpack data functions. */
|
||||
const unsigned char *nvpair_unpack_header(bool isbe, nvpair_t *nvp,
|
||||
@ -89,5 +99,15 @@ const unsigned char *nvpair_unpack_descriptor(bool isbe, nvpair_t *nvp,
|
||||
const unsigned char *ptr, size_t *leftp, const int *fds, size_t nfds);
|
||||
const unsigned char *nvpair_unpack_binary(bool isbe, nvpair_t *nvp,
|
||||
const unsigned char *ptr, size_t *leftp);
|
||||
const unsigned char *nvpair_unpack_bool_array(bool isbe, nvpair_t *nvp,
|
||||
const unsigned char *ptr, size_t *leftp);
|
||||
const unsigned char *nvpair_unpack_number_array(bool isbe, nvpair_t *nvp,
|
||||
const unsigned char *ptr, size_t *leftp);
|
||||
const unsigned char *nvpair_unpack_string_array(bool isbe, nvpair_t *nvp,
|
||||
const unsigned char *ptr, size_t *leftp);
|
||||
const unsigned char *nvpair_unpack_descriptor_array(bool isbe, nvpair_t *nvp,
|
||||
const unsigned char *ptr, size_t *leftp, const int *fds, size_t nfds);
|
||||
const unsigned char *nvpair_unpack_nvlist_array(bool isbe, nvpair_t *nvp,
|
||||
const unsigned char *ptr, size_t *leftp, nvlist_t **firstel);
|
||||
|
||||
#endif /* !_NVPAIR_IMPL_H_ */
|
||||
|
72
sys/sys/nv.h
72
sys/sys/nv.h
@ -1,5 +1,6 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2013 The FreeBSD Foundation
|
||||
* Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by Pawel Jakub Dawidek under sponsorship from
|
||||
@ -59,6 +60,11 @@ typedef struct nvlist nvlist_t;
|
||||
#define NV_TYPE_NVLIST 5
|
||||
#define NV_TYPE_DESCRIPTOR 6
|
||||
#define NV_TYPE_BINARY 7
|
||||
#define NV_TYPE_BOOL_ARRAY 8
|
||||
#define NV_TYPE_NUMBER_ARRAY 9
|
||||
#define NV_TYPE_STRING_ARRAY 10
|
||||
#define NV_TYPE_NVLIST_ARRAY 11
|
||||
#define NV_TYPE_DESCRIPTOR_ARRAY 12
|
||||
|
||||
/*
|
||||
* Perform case-insensitive lookups of provided names.
|
||||
@ -101,6 +107,11 @@ const char *nvlist_next(const nvlist_t *nvl, int *typep, void **cookiep);
|
||||
|
||||
const nvlist_t *nvlist_get_parent(const nvlist_t *nvl, void **cookiep);
|
||||
|
||||
const nvlist_t *nvlist_get_array_next(const nvlist_t *nvl);
|
||||
bool nvlist_in_array(const nvlist_t *nvl);
|
||||
|
||||
const nvlist_t *nvlist_get_pararr(const nvlist_t *nvl, void **cookiep);
|
||||
|
||||
/*
|
||||
* The nvlist_exists functions check if the given name (optionally of the given
|
||||
* type) exists on nvlist.
|
||||
@ -114,10 +125,15 @@ bool nvlist_exists_bool(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_number(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_string(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_nvlist(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_binary(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_bool_array(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_number_array(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_string_array(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_nvlist_array(const nvlist_t *nvl, const char *name);
|
||||
#ifndef _KERNEL
|
||||
bool nvlist_exists_descriptor(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_exists_descriptor_array(const nvlist_t *nvl, const char *name);
|
||||
#endif
|
||||
bool nvlist_exists_binary(const nvlist_t *nvl, const char *name);
|
||||
|
||||
/*
|
||||
* The nvlist_add functions add the given name/value pair.
|
||||
@ -134,10 +150,15 @@ void nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, .
|
||||
void nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt, va_list valueap) __printflike(3, 0);
|
||||
#endif
|
||||
void nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value);
|
||||
void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_t size);
|
||||
void nvlist_add_bool_array(nvlist_t *nvl, const char *name, const bool *value, size_t nitems);
|
||||
void nvlist_add_number_array(nvlist_t *nvl, const char *name, const uint64_t *value, size_t nitems);
|
||||
void nvlist_add_string_array(nvlist_t *nvl, const char *name, const char * const *value, size_t nitems);
|
||||
void nvlist_add_nvlist_array(nvlist_t *nvl, const char *name, const nvlist_t * const *value, size_t nitems);
|
||||
#ifndef _KERNEL
|
||||
void nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value);
|
||||
void nvlist_add_descriptor_array(nvlist_t *nvl, const char *name, const int *value, size_t nitems);
|
||||
#endif
|
||||
void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_t size);
|
||||
|
||||
/*
|
||||
* The nvlist_move functions add the given name/value pair.
|
||||
@ -146,10 +167,15 @@ void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_
|
||||
|
||||
void nvlist_move_string(nvlist_t *nvl, const char *name, char *value);
|
||||
void nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value);
|
||||
void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size);
|
||||
void nvlist_move_bool_array(nvlist_t *nvl, const char *name, bool *value, size_t nitems);
|
||||
void nvlist_move_string_array(nvlist_t *nvl, const char *name, char **value, size_t nitems);
|
||||
void nvlist_move_nvlist_array(nvlist_t *nvl, const char *name, nvlist_t **value, size_t nitems);
|
||||
void nvlist_move_number_array(nvlist_t *nvl, const char *name, uint64_t *value, size_t nitems);
|
||||
#ifndef _KERNEL
|
||||
void nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value);
|
||||
void nvlist_move_descriptor_array(nvlist_t *nvl, const char *name, int *value, size_t nitems);
|
||||
#endif
|
||||
void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size);
|
||||
|
||||
/*
|
||||
* The nvlist_get functions returns value associated with the given name.
|
||||
@ -157,14 +183,19 @@ void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t siz
|
||||
* not be freed by the caller.
|
||||
*/
|
||||
|
||||
bool nvlist_get_bool(const nvlist_t *nvl, const char *name);
|
||||
uint64_t nvlist_get_number(const nvlist_t *nvl, const char *name);
|
||||
const char *nvlist_get_string(const nvlist_t *nvl, const char *name);
|
||||
const nvlist_t *nvlist_get_nvlist(const nvlist_t *nvl, const char *name);
|
||||
bool nvlist_get_bool(const nvlist_t *nvl, const char *name);
|
||||
uint64_t nvlist_get_number(const nvlist_t *nvl, const char *name);
|
||||
const char *nvlist_get_string(const nvlist_t *nvl, const char *name);
|
||||
const nvlist_t *nvlist_get_nvlist(const nvlist_t *nvl, const char *name);
|
||||
const void *nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep);
|
||||
const bool *nvlist_get_bool_array(const nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
const uint64_t *nvlist_get_number_array(const nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
const char * const *nvlist_get_string_array(const nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
const nvlist_t * const *nvlist_get_nvlist_array(const nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
#ifndef _KERNEL
|
||||
int nvlist_get_descriptor(const nvlist_t *nvl, const char *name);
|
||||
int nvlist_get_descriptor(const nvlist_t *nvl, const char *name);
|
||||
const int *nvlist_get_descriptor_array(const nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
#endif
|
||||
const void *nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep);
|
||||
|
||||
/*
|
||||
* The nvlist_take functions returns value associated with the given name and
|
||||
@ -172,14 +203,19 @@ const void *nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *siz
|
||||
* The caller is responsible for freeing received data.
|
||||
*/
|
||||
|
||||
bool nvlist_take_bool(nvlist_t *nvl, const char *name);
|
||||
uint64_t nvlist_take_number(nvlist_t *nvl, const char *name);
|
||||
char *nvlist_take_string(nvlist_t *nvl, const char *name);
|
||||
nvlist_t *nvlist_take_nvlist(nvlist_t *nvl, const char *name);
|
||||
bool nvlist_take_bool(nvlist_t *nvl, const char *name);
|
||||
uint64_t nvlist_take_number(nvlist_t *nvl, const char *name);
|
||||
char *nvlist_take_string(nvlist_t *nvl, const char *name);
|
||||
nvlist_t *nvlist_take_nvlist(nvlist_t *nvl, const char *name);
|
||||
void *nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep);
|
||||
bool *nvlist_take_bool_array(nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
uint64_t *nvlist_take_number_array(nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
char **nvlist_take_string_array(nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
nvlist_t **nvlist_take_nvlist_array(nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
#ifndef _KERNEL
|
||||
int nvlist_take_descriptor(nvlist_t *nvl, const char *name);
|
||||
int *nvlist_take_descriptor_array(nvlist_t *nvl, const char *name, size_t *nitemsp);
|
||||
#endif
|
||||
void *nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep);
|
||||
|
||||
/*
|
||||
* The nvlist_free functions removes the given name/value pair from the nvlist
|
||||
@ -194,10 +230,16 @@ void nvlist_free_bool(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_number(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_string(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_nvlist(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_binary(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_bool_array(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_number_array(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_string_array(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_nvlist_array(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_binary_array(nvlist_t *nvl, const char *name);
|
||||
#ifndef _KERNEL
|
||||
void nvlist_free_descriptor(nvlist_t *nvl, const char *name);
|
||||
void nvlist_free_descriptor_array(nvlist_t *nvl, const char *name);
|
||||
#endif
|
||||
void nvlist_free_binary(nvlist_t *nvl, const char *name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user