Introduce cnvlist_name() and cnvlist_type() functions.
Those function can be used when we are iterating over nvlist to reduce amount of extra variables we need to declare. MFC after: 1 month
This commit is contained in:
parent
df485bdb3c
commit
23c5a51e92
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325019
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd August 27, 2016
|
||||
.Dd October 26, 2017
|
||||
.Dt CNV 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -37,6 +37,11 @@
|
||||
.Lb libnv
|
||||
.Sh SYNOPSIS
|
||||
.In sys/cnv.h
|
||||
.Ft const char *
|
||||
.Fn cnvlist_name "void *cookiep"
|
||||
.Ft int
|
||||
.Fn cnvlist_type "void *cookiep"
|
||||
.\"
|
||||
.Ft bool
|
||||
.Fn cnvlist_get_bool "void *cookiep"
|
||||
.Ft uint64_t
|
||||
@ -124,6 +129,16 @@ from
|
||||
.Xr nv 9 .
|
||||
.Pp
|
||||
The
|
||||
.Fn cnvlist_name
|
||||
function returns the name of an element associated with the given cookie.
|
||||
.Pp
|
||||
The
|
||||
.Fn cnvlist_type
|
||||
function returns the type of an element associated with the given cookie.
|
||||
Types which can be returned are described in
|
||||
.Xr nv 9 .
|
||||
.Pp
|
||||
The
|
||||
.Nm cnvlist_get
|
||||
family of functions obtains the value associated with the given cookie.
|
||||
Returned strings, nvlists, descriptors, binaries, or arrays must not be modified
|
||||
|
@ -53,6 +53,20 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nvlist_impl.h"
|
||||
#include "nvpair_impl.h"
|
||||
|
||||
const char *
|
||||
cnvlist_name(void *cookiep)
|
||||
{
|
||||
|
||||
return (nvpair_name(cookiep));
|
||||
}
|
||||
|
||||
int
|
||||
cnvlist_type(void *cookiep)
|
||||
{
|
||||
|
||||
return (nvpair_type(cookiep));
|
||||
}
|
||||
|
||||
#define CNVLIST_GET(ftype, type, NVTYPE) \
|
||||
ftype \
|
||||
cnvlist_get_##type(void *cookiep) \
|
||||
|
@ -47,6 +47,12 @@ typedef struct nvlist nvlist_t;
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Functions which returns information about the given cookie.
|
||||
*/
|
||||
const char *cnvlist_name(void *cookiep);
|
||||
int cnvlist_type(void *cookiep);
|
||||
|
||||
/*
|
||||
* The cnvlist_get functions returns value associated with the given cookie.
|
||||
* If it returns a pointer, the pointer represents internal buffer and should
|
||||
|
Loading…
Reference in New Issue
Block a user