Remove the nvlist_.*[fv] functions.
Those functions are problematic, because there is no way to report memory allocation problems without complicating the API, so we can either abort or potentially return invalid results. None of which is acceptable. In most cases the caller knows the size of the name, so he can allocate buffer on the stack and use snprintf(3) to prepare the name. After some discussion the conclusion is to removed those functions, which also simplifies the API. Discussed with: pjd, rstone Approved by: pjd (mentor)
This commit is contained in:
parent
681476b551
commit
0bb5e6ef80
@ -81,88 +81,6 @@ MLINKS+=nv.3 nvlist_create.3 \
|
||||
nv.3 nvlist_free_nvlist.3 \
|
||||
nv.3 nvlist_free_descriptor.3 \
|
||||
nv.3 nvlist_free_binary.3
|
||||
MLINKS+=nv.3 nvlist_existsf.3 \
|
||||
nv.3 nvlist_existsf_type.3 \
|
||||
nv.3 nvlist_existsf_null.3 \
|
||||
nv.3 nvlist_existsf_bool.3 \
|
||||
nv.3 nvlist_existsf_number.3 \
|
||||
nv.3 nvlist_existsf_string.3 \
|
||||
nv.3 nvlist_existsf_nvlist.3 \
|
||||
nv.3 nvlist_existsf_descriptor.3 \
|
||||
nv.3 nvlist_existsf_binary.3 \
|
||||
nv.3 nvlist_addf_null.3 \
|
||||
nv.3 nvlist_addf_bool.3 \
|
||||
nv.3 nvlist_addf_number.3 \
|
||||
nv.3 nvlist_addf_string.3 \
|
||||
nv.3 nvlist_addf_nvlist.3 \
|
||||
nv.3 nvlist_addf_descriptor.3 \
|
||||
nv.3 nvlist_addf_binary.3 \
|
||||
nv.3 nvlist_movef_string.3 \
|
||||
nv.3 nvlist_movef_nvlist.3 \
|
||||
nv.3 nvlist_movef_descriptor.3 \
|
||||
nv.3 nvlist_movef_binary.3 \
|
||||
nv.3 nvlist_getf_bool.3 \
|
||||
nv.3 nvlist_getf_number.3 \
|
||||
nv.3 nvlist_getf_string.3 \
|
||||
nv.3 nvlist_getf_nvlist.3 \
|
||||
nv.3 nvlist_getf_descriptor.3 \
|
||||
nv.3 nvlist_getf_binary.3 \
|
||||
nv.3 nvlist_takef_bool.3 \
|
||||
nv.3 nvlist_takef_number.3 \
|
||||
nv.3 nvlist_takef_string.3 \
|
||||
nv.3 nvlist_takef_nvlist.3 \
|
||||
nv.3 nvlist_takef_descriptor.3 \
|
||||
nv.3 nvlist_takef_binary.3 \
|
||||
nv.3 nvlist_freef.3 \
|
||||
nv.3 nvlist_freef_type.3 \
|
||||
nv.3 nvlist_freef_null.3 \
|
||||
nv.3 nvlist_freef_bool.3 \
|
||||
nv.3 nvlist_freef_number.3 \
|
||||
nv.3 nvlist_freef_string.3 \
|
||||
nv.3 nvlist_freef_nvlist.3 \
|
||||
nv.3 nvlist_freef_descriptor.3 \
|
||||
nv.3 nvlist_freef_binary.3
|
||||
MLINKS+=nv.3 nvlist_existsv.3 \
|
||||
nv.3 nvlist_existsv_type.3 \
|
||||
nv.3 nvlist_existsv_null.3 \
|
||||
nv.3 nvlist_existsv_bool.3 \
|
||||
nv.3 nvlist_existsv_number.3 \
|
||||
nv.3 nvlist_existsv_string.3 \
|
||||
nv.3 nvlist_existsv_nvlist.3 \
|
||||
nv.3 nvlist_existsv_descriptor.3 \
|
||||
nv.3 nvlist_existsv_binary.3 \
|
||||
nv.3 nvlist_addv_null.3 \
|
||||
nv.3 nvlist_addv_bool.3 \
|
||||
nv.3 nvlist_addv_number.3 \
|
||||
nv.3 nvlist_addv_string.3 \
|
||||
nv.3 nvlist_addv_nvlist.3 \
|
||||
nv.3 nvlist_addv_descriptor.3 \
|
||||
nv.3 nvlist_addv_binary.3 \
|
||||
nv.3 nvlist_movev_string.3 \
|
||||
nv.3 nvlist_movev_nvlist.3 \
|
||||
nv.3 nvlist_movev_descriptor.3 \
|
||||
nv.3 nvlist_movev_binary.3 \
|
||||
nv.3 nvlist_getv_bool.3 \
|
||||
nv.3 nvlist_getv_number.3 \
|
||||
nv.3 nvlist_getv_string.3 \
|
||||
nv.3 nvlist_getv_nvlist.3 \
|
||||
nv.3 nvlist_getv_descriptor.3 \
|
||||
nv.3 nvlist_getv_binary.3 \
|
||||
nv.3 nvlist_takev_bool.3 \
|
||||
nv.3 nvlist_takev_number.3 \
|
||||
nv.3 nvlist_takev_string.3 \
|
||||
nv.3 nvlist_takev_nvlist.3 \
|
||||
nv.3 nvlist_takev_descriptor.3 \
|
||||
nv.3 nvlist_takev_binary.3 \
|
||||
nv.3 nvlist_freev.3 \
|
||||
nv.3 nvlist_freev_type.3 \
|
||||
nv.3 nvlist_freev_null.3 \
|
||||
nv.3 nvlist_freev_bool.3 \
|
||||
nv.3 nvlist_freev_number.3 \
|
||||
nv.3 nvlist_freev_string.3 \
|
||||
nv.3 nvlist_freev_nvlist.3 \
|
||||
nv.3 nvlist_freev_descriptor.3 \
|
||||
nv.3 nvlist_freev_binary.3
|
||||
|
||||
WARNS?= 6
|
||||
|
||||
|
@ -89,89 +89,6 @@ dnvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep,
|
||||
return (value);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
#define DNVLIST_GETF(ftype, type) \
|
||||
ftype \
|
||||
dnvlist_getf_##type(const nvlist_t *nvl, ftype defval, \
|
||||
const char *namefmt, ...) \
|
||||
{ \
|
||||
va_list nameap; \
|
||||
ftype value; \
|
||||
\
|
||||
va_start(nameap, namefmt); \
|
||||
value = dnvlist_getv_##type(nvl, defval, namefmt, nameap); \
|
||||
va_end(nameap); \
|
||||
\
|
||||
return (value); \
|
||||
}
|
||||
|
||||
DNVLIST_GETF(bool, bool)
|
||||
DNVLIST_GETF(uint64_t, number)
|
||||
DNVLIST_GETF(const char *, string)
|
||||
DNVLIST_GETF(const nvlist_t *, nvlist)
|
||||
DNVLIST_GETF(int, descriptor)
|
||||
|
||||
#undef DNVLIST_GETF
|
||||
|
||||
const void *
|
||||
dnvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const void *defval,
|
||||
size_t defsize, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
const void *value;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
value = dnvlist_getv_binary(nvl, sizep, defval, defsize, namefmt,
|
||||
nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
#define DNVLIST_GETV(ftype, type) \
|
||||
ftype \
|
||||
dnvlist_getv_##type(const nvlist_t *nvl, ftype defval, \
|
||||
const char *namefmt, va_list nameap) \
|
||||
{ \
|
||||
char *name; \
|
||||
ftype value; \
|
||||
\
|
||||
vasprintf(&name, namefmt, nameap); \
|
||||
if (name == NULL) \
|
||||
return (defval); \
|
||||
value = dnvlist_get_##type(nvl, name, defval); \
|
||||
free(name); \
|
||||
return (value); \
|
||||
}
|
||||
|
||||
DNVLIST_GETV(bool, bool)
|
||||
DNVLIST_GETV(uint64_t, number)
|
||||
DNVLIST_GETV(const char *, string)
|
||||
DNVLIST_GETV(const nvlist_t *, nvlist)
|
||||
DNVLIST_GETV(int, descriptor)
|
||||
|
||||
#undef DNVLIST_GETV
|
||||
|
||||
const void *
|
||||
dnvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const void *defval,
|
||||
size_t defsize, const char *namefmt, va_list nameap)
|
||||
{
|
||||
char *name;
|
||||
const void *value;
|
||||
|
||||
nv_vasprintf(&name, namefmt, nameap);
|
||||
if (name != NULL) {
|
||||
value = dnvlist_get_binary(nvl, name, sizep, defval, defsize);
|
||||
nv_free(name);
|
||||
} else {
|
||||
if (sizep != NULL)
|
||||
*sizep = defsize;
|
||||
value = defval;
|
||||
}
|
||||
return (value);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define DNVLIST_TAKE(ftype, type) \
|
||||
ftype \
|
||||
dnvlist_take_##type(nvlist_t *nvl, const char *name, ftype defval) \
|
||||
@ -209,86 +126,3 @@ dnvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep,
|
||||
return (value);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
#define DNVLIST_TAKEF(ftype, type) \
|
||||
ftype \
|
||||
dnvlist_takef_##type(nvlist_t *nvl, ftype defval, \
|
||||
const char *namefmt, ...) \
|
||||
{ \
|
||||
va_list nameap; \
|
||||
ftype value; \
|
||||
\
|
||||
va_start(nameap, namefmt); \
|
||||
value = dnvlist_takev_##type(nvl, defval, namefmt, nameap); \
|
||||
va_end(nameap); \
|
||||
\
|
||||
return (value); \
|
||||
}
|
||||
|
||||
DNVLIST_TAKEF(bool, bool)
|
||||
DNVLIST_TAKEF(uint64_t, number)
|
||||
DNVLIST_TAKEF(char *, string)
|
||||
DNVLIST_TAKEF(nvlist_t *, nvlist)
|
||||
DNVLIST_TAKEF(int, descriptor)
|
||||
|
||||
#undef DNVLIST_TAKEF
|
||||
|
||||
void *
|
||||
dnvlist_takef_binary(nvlist_t *nvl, size_t *sizep, void *defval,
|
||||
size_t defsize, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
void *value;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
value = dnvlist_takev_binary(nvl, sizep, defval, defsize, namefmt,
|
||||
nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
#define DNVLIST_TAKEV(ftype, type) \
|
||||
ftype \
|
||||
dnvlist_takev_##type(nvlist_t *nvl, ftype defval, const char *namefmt, \
|
||||
va_list nameap) \
|
||||
{ \
|
||||
char *name; \
|
||||
ftype value; \
|
||||
\
|
||||
vasprintf(&name, namefmt, nameap); \
|
||||
if (name == NULL) \
|
||||
return (defval); \
|
||||
value = dnvlist_take_##type(nvl, name, defval); \
|
||||
free(name); \
|
||||
return (value); \
|
||||
}
|
||||
|
||||
DNVLIST_TAKEV(bool, bool)
|
||||
DNVLIST_TAKEV(uint64_t, number)
|
||||
DNVLIST_TAKEV(char *, string)
|
||||
DNVLIST_TAKEV(nvlist_t *, nvlist)
|
||||
DNVLIST_TAKEV(int, descriptor)
|
||||
|
||||
#undef DNVLIST_TAKEV
|
||||
|
||||
void *
|
||||
dnvlist_takev_binary(nvlist_t *nvl, size_t *sizep, void *defval,
|
||||
size_t defsize, const char *namefmt, va_list nameap)
|
||||
{
|
||||
char *name;
|
||||
void *value;
|
||||
|
||||
nv_vasprintf(&name, namefmt, nameap);
|
||||
if (name != NULL) {
|
||||
value = dnvlist_take_binary(nvl, name, sizep, defval, defsize);
|
||||
nv_free(name);
|
||||
} else {
|
||||
if (sizep != NULL)
|
||||
*sizep = defsize;
|
||||
value = defval;
|
||||
}
|
||||
|
||||
return (value);
|
||||
}
|
||||
#endif
|
||||
|
@ -281,37 +281,6 @@ nvlist_exists_type(const nvlist_t *nvl, const char *name, int type)
|
||||
return (nvlist_find(nvl, type, name) != NULL);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
bool
|
||||
nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
bool ret;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
ret = nvlist_existsv_type(nvl, type, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
bool
|
||||
nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt,
|
||||
va_list nameap)
|
||||
{
|
||||
char *name;
|
||||
bool exists;
|
||||
|
||||
nv_vasprintf(&name, namefmt, nameap);
|
||||
if (name == NULL)
|
||||
return (false);
|
||||
|
||||
exists = nvlist_exists_type(nvl, name, type);
|
||||
nv_free(name);
|
||||
return (exists);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_free_type(nvlist_t *nvl, const char *name, int type)
|
||||
{
|
||||
@ -329,30 +298,6 @@ nvlist_free_type(nvlist_t *nvl, const char *name, int type)
|
||||
nvlist_report_missing(type, name);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_freev_type(nvl, type, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap)
|
||||
{
|
||||
char *name;
|
||||
|
||||
nv_vasprintf(&name, namefmt, nameap);
|
||||
if (name == NULL)
|
||||
nvlist_report_missing(type, "<unknown>");
|
||||
nvlist_free_type(nvl, name, type);
|
||||
nv_free(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
nvlist_t *
|
||||
nvlist_clone(const nvlist_t *nvl)
|
||||
{
|
||||
@ -1099,86 +1044,6 @@ NVLIST_EXISTS(binary, BINARY)
|
||||
|
||||
#undef NVLIST_EXISTS
|
||||
|
||||
#ifndef _KERNEL
|
||||
bool
|
||||
nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
bool ret;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
ret = nvlist_existsv(nvl, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#define NVLIST_EXISTSF(type) \
|
||||
bool \
|
||||
nvlist_existsf_##type(const nvlist_t *nvl, const char *namefmt, ...) \
|
||||
{ \
|
||||
va_list nameap; \
|
||||
bool ret; \
|
||||
\
|
||||
va_start(nameap, namefmt); \
|
||||
ret = nvlist_existsv_##type(nvl, namefmt, nameap); \
|
||||
va_end(nameap); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
NVLIST_EXISTSF(null)
|
||||
NVLIST_EXISTSF(bool)
|
||||
NVLIST_EXISTSF(number)
|
||||
NVLIST_EXISTSF(string)
|
||||
NVLIST_EXISTSF(nvlist)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_EXISTSF(descriptor)
|
||||
#endif
|
||||
NVLIST_EXISTSF(binary)
|
||||
|
||||
#undef NVLIST_EXISTSF
|
||||
|
||||
bool
|
||||
nvlist_existsv(const nvlist_t *nvl, const char *namefmt, va_list nameap)
|
||||
{
|
||||
char *name;
|
||||
bool exists;
|
||||
|
||||
nv_vasprintf(&name, namefmt, nameap);
|
||||
if (name == NULL)
|
||||
return (false);
|
||||
|
||||
exists = nvlist_exists(nvl, name);
|
||||
nv_free(name);
|
||||
return (exists);
|
||||
}
|
||||
|
||||
#define NVLIST_EXISTSV(type) \
|
||||
bool \
|
||||
nvlist_existsv_##type(const nvlist_t *nvl, const char *namefmt, \
|
||||
va_list nameap) \
|
||||
{ \
|
||||
char *name; \
|
||||
bool exists; \
|
||||
\
|
||||
vasprintf(&name, namefmt, nameap); \
|
||||
if (name == NULL) \
|
||||
return (false); \
|
||||
exists = nvlist_exists_##type(nvl, name); \
|
||||
free(name); \
|
||||
return (exists); \
|
||||
}
|
||||
|
||||
NVLIST_EXISTSV(null)
|
||||
NVLIST_EXISTSV(bool)
|
||||
NVLIST_EXISTSV(number)
|
||||
NVLIST_EXISTSV(string)
|
||||
NVLIST_EXISTSV(nvlist)
|
||||
NVLIST_EXISTSV(descriptor)
|
||||
NVLIST_EXISTSV(binary)
|
||||
|
||||
#undef NVLIST_EXISTSV
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
|
||||
{
|
||||
@ -1206,34 +1071,6 @@ nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
|
||||
nvpair_insert(&nvl->nvl_head, newnvp, nvl);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_null(nvlist_t *nvl, const char *name)
|
||||
{
|
||||
|
||||
nvlist_addf_null(nvl, "%s", name);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_bool(nvlist_t *nvl, const char *name, bool value)
|
||||
{
|
||||
|
||||
nvlist_addf_bool(nvl, value, "%s", name);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value)
|
||||
{
|
||||
|
||||
nvlist_addf_number(nvl, value, "%s", name);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_string(nvlist_t *nvl, const char *name, const char *value)
|
||||
{
|
||||
|
||||
nvlist_addf_string(nvl, value, "%s", name);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...)
|
||||
{
|
||||
@ -1264,206 +1101,104 @@ nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_null(nvlist_t *nvl, const char *name)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_create_null(name);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_bool(nvlist_t *nvl, const char *name, bool value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_create_bool(name, value);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_create_number(name, value);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_string(nvlist_t *nvl, const char *name, const char *value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_create_string(name, value);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
nvlist_addf_nvlist(nvl, value, "%s", name);
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_create_nvlist(name, value);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value)
|
||||
{
|
||||
|
||||
nvlist_addf_descriptor(nvl, value, "%s", name);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value,
|
||||
size_t size)
|
||||
{
|
||||
|
||||
nvlist_addf_binary(nvl, value, size, "%s", name);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addf_null(nvlist_t *nvl, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_addv_null(nvl, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addf_bool(nvlist_t *nvl, bool value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_addv_bool(nvl, value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addf_number(nvlist_t *nvl, uint64_t value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_addv_number(nvl, value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addf_string(nvlist_t *nvl, const char *value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_addv_string(nvl, value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addf_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt,
|
||||
...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_addv_nvlist(nvl, value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_addv_descriptor(nvl, value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size,
|
||||
const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_addv_binary(nvl, value, size, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addv_null(nvlist_t *nvl, const char *namefmt, va_list nameap)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_createv_null(namefmt, nameap);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addv_bool(nvlist_t *nvl, bool value, const char *namefmt, va_list nameap)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_createv_bool(value, namefmt, nameap);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addv_number(nvlist_t *nvl, uint64_t value, const char *namefmt,
|
||||
va_list nameap)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_createv_number(value, namefmt, nameap);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addv_string(nvlist_t *nvl, const char *value, const char *namefmt,
|
||||
va_list nameap)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_createv_string(value, namefmt, nameap);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_addv_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt,
|
||||
va_list nameap)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
if (nvlist_error(nvl) != 0) {
|
||||
RESTORE_ERRNO(nvlist_error(nvl));
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_createv_nvlist(value, namefmt, nameap);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
} else {
|
||||
nvlist_move_nvpair(nvl, nvp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt,
|
||||
va_list nameap)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1472,7 +1207,7 @@ nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt,
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_createv_descriptor(value, namefmt, nameap);
|
||||
nvp = nvpair_create_descriptor(name, value);
|
||||
if (nvp == NULL)
|
||||
nvl->nvl_error = errno = (errno != 0 ? errno : ENOMEM);
|
||||
else
|
||||
@ -1481,8 +1216,8 @@ nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt,
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size,
|
||||
const char *namefmt, va_list nameap)
|
||||
nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value,
|
||||
size_t size)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1491,7 +1226,7 @@ nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size,
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_createv_binary(value, size, namefmt, nameap);
|
||||
nvp = nvpair_create_binary(name, value, size);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
@ -1522,63 +1257,8 @@ nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp)
|
||||
nvpair_insert(&nvl->nvl_head, nvp, nvl);
|
||||
}
|
||||
|
||||
#define NVLIST_MOVE(vtype, type) \
|
||||
void \
|
||||
nvlist_move_##type(nvlist_t *nvl, const char *name, vtype value) \
|
||||
{ \
|
||||
\
|
||||
nvlist_movef_##type(nvl, value, "%s", name); \
|
||||
}
|
||||
|
||||
NVLIST_MOVE(char *, string)
|
||||
NVLIST_MOVE(nvlist_t *, nvlist)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_MOVE(int, descriptor)
|
||||
#endif
|
||||
|
||||
#undef NVLIST_MOVE
|
||||
|
||||
void
|
||||
nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
|
||||
{
|
||||
|
||||
nvlist_movef_binary(nvl, value, size, "%s", name);
|
||||
}
|
||||
|
||||
#define NVLIST_MOVEF(vtype, type) \
|
||||
void \
|
||||
nvlist_movef_##type(nvlist_t *nvl, vtype value, const char *namefmt, \
|
||||
...) \
|
||||
{ \
|
||||
va_list nameap; \
|
||||
\
|
||||
va_start(nameap, namefmt); \
|
||||
nvlist_movev_##type(nvl, value, namefmt, nameap); \
|
||||
va_end(nameap); \
|
||||
}
|
||||
|
||||
NVLIST_MOVEF(char *, string)
|
||||
NVLIST_MOVEF(nvlist_t *, nvlist)
|
||||
#ifndef _KERNEL
|
||||
NVLIST_MOVEF(int, descriptor)
|
||||
#endif
|
||||
|
||||
#undef NVLIST_MOVEF
|
||||
|
||||
void
|
||||
nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size,
|
||||
const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_movev_binary(nvl, value, size, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt,
|
||||
va_list nameap)
|
||||
nvlist_move_string(nvlist_t *nvl, const char *name, char *value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1588,7 +1268,7 @@ nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt,
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_movev_string(value, namefmt, nameap);
|
||||
nvp = nvpair_move_string(name, value);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
@ -1598,8 +1278,7 @@ nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt,
|
||||
}
|
||||
|
||||
void
|
||||
nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt,
|
||||
va_list nameap)
|
||||
nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1610,7 +1289,7 @@ nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt,
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_movev_nvlist(value, namefmt, nameap);
|
||||
nvp = nvpair_move_nvlist(name, value);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
@ -1621,8 +1300,7 @@ nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt,
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt,
|
||||
va_list nameap)
|
||||
nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1632,7 +1310,7 @@ nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt,
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_movev_descriptor(value, namefmt, nameap);
|
||||
nvp = nvpair_move_descriptor(name, value);
|
||||
if (nvp == NULL)
|
||||
nvl->nvl_error = errno = (errno != 0 ? errno : ENOMEM);
|
||||
else
|
||||
@ -1641,8 +1319,7 @@ nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt,
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size,
|
||||
const char *namefmt, va_list nameap)
|
||||
nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1652,7 +1329,7 @@ nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size,
|
||||
return;
|
||||
}
|
||||
|
||||
nvp = nvpair_movev_binary(value, size, namefmt, nameap);
|
||||
nvp = nvpair_move_binary(name, value, size);
|
||||
if (nvp == NULL) {
|
||||
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
|
||||
RESTORE_ERRNO(nvl->nvl_error);
|
||||
@ -1702,84 +1379,6 @@ nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep)
|
||||
return (nvpair_get_binary(nvp, sizep));
|
||||
}
|
||||
|
||||
#define NVLIST_GETF(ftype, type) \
|
||||
ftype \
|
||||
nvlist_getf_##type(const nvlist_t *nvl, const char *namefmt, ...) \
|
||||
{ \
|
||||
va_list nameap; \
|
||||
ftype value; \
|
||||
\
|
||||
va_start(nameap, namefmt); \
|
||||
value = nvlist_getv_##type(nvl, namefmt, nameap); \
|
||||
va_end(nameap); \
|
||||
\
|
||||
return (value); \
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
NVLIST_GETF(bool, bool)
|
||||
NVLIST_GETF(uint64_t, number)
|
||||
NVLIST_GETF(const char *, string)
|
||||
NVLIST_GETF(const nvlist_t *, nvlist)
|
||||
NVLIST_GETF(int, descriptor)
|
||||
|
||||
#undef NVLIST_GETF
|
||||
|
||||
const void *
|
||||
nvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
const void *value;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
value = nvlist_getv_binary(nvl, sizep, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
#define NVLIST_GETV(ftype, type, TYPE) \
|
||||
ftype \
|
||||
nvlist_getv_##type(const nvlist_t *nvl, const char *namefmt, \
|
||||
va_list nameap) \
|
||||
{ \
|
||||
char *name; \
|
||||
ftype value; \
|
||||
\
|
||||
vasprintf(&name, namefmt, nameap); \
|
||||
if (name == NULL) \
|
||||
nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>"); \
|
||||
value = nvlist_get_##type(nvl, name); \
|
||||
free(name); \
|
||||
\
|
||||
return (value); \
|
||||
}
|
||||
|
||||
NVLIST_GETV(bool, bool, BOOL)
|
||||
NVLIST_GETV(uint64_t, number, NUMBER)
|
||||
NVLIST_GETV(const char *, string, STRING)
|
||||
NVLIST_GETV(const nvlist_t *, nvlist, NVLIST)
|
||||
NVLIST_GETV(int, descriptor, DESCRIPTOR)
|
||||
|
||||
#undef NVLIST_GETV
|
||||
|
||||
const void *
|
||||
nvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt,
|
||||
va_list nameap)
|
||||
{
|
||||
char *name;
|
||||
const void *binary;
|
||||
|
||||
nv_vasprintf(&name, namefmt, nameap);
|
||||
if (name == NULL)
|
||||
nvlist_report_missing(NV_TYPE_BINARY, "<unknown>");
|
||||
|
||||
binary = nvlist_get_binary(nvl, name, sizep);
|
||||
nv_free(name);
|
||||
return (binary);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NVLIST_TAKE(ftype, type, TYPE) \
|
||||
ftype \
|
||||
nvlist_take_##type(nvlist_t *nvl, const char *name) \
|
||||
@ -1822,82 +1421,6 @@ nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep)
|
||||
return (value);
|
||||
}
|
||||
|
||||
#define NVLIST_TAKEF(ftype, type) \
|
||||
ftype \
|
||||
nvlist_takef_##type(nvlist_t *nvl, const char *namefmt, ...) \
|
||||
{ \
|
||||
va_list nameap; \
|
||||
ftype value; \
|
||||
\
|
||||
va_start(nameap, namefmt); \
|
||||
value = nvlist_takev_##type(nvl, namefmt, nameap); \
|
||||
va_end(nameap); \
|
||||
\
|
||||
return (value); \
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
NVLIST_TAKEF(bool, bool)
|
||||
NVLIST_TAKEF(uint64_t, number)
|
||||
NVLIST_TAKEF(char *, string)
|
||||
NVLIST_TAKEF(nvlist_t *, nvlist)
|
||||
NVLIST_TAKEF(int, descriptor)
|
||||
|
||||
#undef NVLIST_TAKEF
|
||||
|
||||
void *
|
||||
nvlist_takef_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
void *value;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
value = nvlist_takev_binary(nvl, sizep, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (value);
|
||||
}
|
||||
|
||||
#define NVLIST_TAKEV(ftype, type, TYPE) \
|
||||
ftype \
|
||||
nvlist_takev_##type(nvlist_t *nvl, const char *namefmt, va_list nameap) \
|
||||
{ \
|
||||
char *name; \
|
||||
ftype value; \
|
||||
\
|
||||
vasprintf(&name, namefmt, nameap); \
|
||||
if (name == NULL) \
|
||||
nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>"); \
|
||||
value = nvlist_take_##type(nvl, name); \
|
||||
free(name); \
|
||||
return (value); \
|
||||
}
|
||||
|
||||
NVLIST_TAKEV(bool, bool, BOOL)
|
||||
NVLIST_TAKEV(uint64_t, number, NUMBER)
|
||||
NVLIST_TAKEV(char *, string, STRING)
|
||||
NVLIST_TAKEV(nvlist_t *, nvlist, NVLIST)
|
||||
NVLIST_TAKEV(int, descriptor, DESCRIPTOR)
|
||||
|
||||
#undef NVLIST_TAKEV
|
||||
|
||||
void *
|
||||
nvlist_takev_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt,
|
||||
va_list nameap)
|
||||
{
|
||||
char *name;
|
||||
void *binary;
|
||||
|
||||
nv_vasprintf(&name, namefmt, nameap);
|
||||
if (name == NULL)
|
||||
nvlist_report_missing(NV_TYPE_BINARY, "<unknown>");
|
||||
|
||||
binary = nvlist_take_binary(nvl, name, sizep);
|
||||
nv_free(name);
|
||||
return (binary);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp)
|
||||
{
|
||||
@ -1936,68 +1459,6 @@ NVLIST_FREE(binary, BINARY)
|
||||
|
||||
#undef NVLIST_FREE
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
nvlist_freef(nvlist_t *nvl, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvlist_freev(nvl, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
}
|
||||
|
||||
#define NVLIST_FREEF(type) \
|
||||
void \
|
||||
nvlist_freef_##type(nvlist_t *nvl, const char *namefmt, ...) \
|
||||
{ \
|
||||
va_list nameap; \
|
||||
\
|
||||
va_start(nameap, namefmt); \
|
||||
nvlist_freev_##type(nvl, namefmt, nameap); \
|
||||
va_end(nameap); \
|
||||
}
|
||||
|
||||
NVLIST_FREEF(null)
|
||||
NVLIST_FREEF(bool)
|
||||
NVLIST_FREEF(number)
|
||||
NVLIST_FREEF(string)
|
||||
NVLIST_FREEF(nvlist)
|
||||
NVLIST_FREEF(descriptor)
|
||||
NVLIST_FREEF(binary)
|
||||
|
||||
#undef NVLIST_FREEF
|
||||
|
||||
void
|
||||
nvlist_freev(nvlist_t *nvl, const char *namefmt, va_list nameap)
|
||||
{
|
||||
|
||||
nvlist_freev_type(nvl, NV_TYPE_NONE, namefmt, nameap);
|
||||
}
|
||||
|
||||
#define NVLIST_FREEV(type, TYPE) \
|
||||
void \
|
||||
nvlist_freev_##type(nvlist_t *nvl, const char *namefmt, va_list nameap) \
|
||||
{ \
|
||||
char *name; \
|
||||
\
|
||||
vasprintf(&name, namefmt, nameap); \
|
||||
if (name == NULL) \
|
||||
nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>"); \
|
||||
nvlist_free_##type(nvl, name); \
|
||||
free(name); \
|
||||
}
|
||||
|
||||
NVLIST_FREEV(null, NULL)
|
||||
NVLIST_FREEV(bool, BOOL)
|
||||
NVLIST_FREEV(number, NUMBER)
|
||||
NVLIST_FREEV(string, STRING)
|
||||
NVLIST_FREEV(nvlist, NVLIST)
|
||||
NVLIST_FREEV(descriptor, DESCRIPTOR)
|
||||
NVLIST_FREEV(binary, BINARY)
|
||||
#undef NVLIST_FREEV
|
||||
#endif
|
||||
|
||||
void
|
||||
nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp)
|
||||
{
|
||||
@ -2009,3 +1470,4 @@ nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp)
|
||||
nvlist_remove_nvpair(nvl, nvp);
|
||||
nvpair_free(nvp);
|
||||
}
|
||||
|
||||
|
@ -716,22 +716,15 @@ nvpair_name(const nvpair_t *nvp)
|
||||
}
|
||||
|
||||
static nvpair_t *
|
||||
nvpair_allocv(int type, uint64_t data, size_t datasize, const char *namefmt,
|
||||
va_list nameap)
|
||||
nvpair_allocv(const char *name, int type, uint64_t data, size_t datasize)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
char *name;
|
||||
int namelen;
|
||||
size_t namelen;
|
||||
|
||||
PJDLOG_ASSERT(type >= NV_TYPE_FIRST && type <= NV_TYPE_LAST);
|
||||
|
||||
namelen = nv_vasprintf(&name, namefmt, nameap);
|
||||
if (namelen < 0)
|
||||
return (NULL);
|
||||
|
||||
PJDLOG_ASSERT(namelen > 0);
|
||||
namelen = strlen(name);
|
||||
if (namelen >= NV_NAME_MAX) {
|
||||
nv_free(name);
|
||||
RESTORE_ERRNO(ENAMETOOLONG);
|
||||
return (NULL);
|
||||
}
|
||||
@ -739,45 +732,17 @@ nvpair_allocv(int type, uint64_t data, size_t datasize, const char *namefmt,
|
||||
nvp = nv_calloc(1, sizeof(*nvp) + namelen + 1);
|
||||
if (nvp != NULL) {
|
||||
nvp->nvp_name = (char *)(nvp + 1);
|
||||
memcpy(nvp->nvp_name, name, namelen + 1);
|
||||
memcpy(nvp->nvp_name, name, namelen);
|
||||
nvp->nvp_name[namelen + 1] = '\0';
|
||||
nvp->nvp_type = type;
|
||||
nvp->nvp_data = data;
|
||||
nvp->nvp_datasize = datasize;
|
||||
nvp->nvp_magic = NVPAIR_MAGIC;
|
||||
}
|
||||
nv_free(name);
|
||||
|
||||
return (nvp);
|
||||
};
|
||||
|
||||
nvpair_t *
|
||||
nvpair_create_null(const char *name)
|
||||
{
|
||||
|
||||
return (nvpair_createf_null("%s", name));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_create_bool(const char *name, bool value)
|
||||
{
|
||||
|
||||
return (nvpair_createf_bool(value, "%s", name));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_create_number(const char *name, uint64_t value)
|
||||
{
|
||||
|
||||
return (nvpair_createf_number(value, "%s", name));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_create_string(const char *name, const char *value)
|
||||
{
|
||||
|
||||
return (nvpair_createf_string(value, "%s", name));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_create_stringf(const char *name, const char *valuefmt, ...)
|
||||
{
|
||||
@ -808,146 +773,29 @@ nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap)
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_create_nvlist(const char *name, const nvlist_t *value)
|
||||
nvpair_create_null(const char *name)
|
||||
{
|
||||
|
||||
return (nvpair_createf_nvlist(value, "%s", name));
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
nvpair_t *
|
||||
nvpair_create_descriptor(const char *name, int value)
|
||||
{
|
||||
|
||||
return (nvpair_createf_descriptor(value, "%s", name));
|
||||
}
|
||||
#endif
|
||||
|
||||
nvpair_t *
|
||||
nvpair_create_binary(const char *name, const void *value, size_t size)
|
||||
{
|
||||
|
||||
return (nvpair_createf_binary(value, size, "%s", name));
|
||||
return (nvpair_allocv(name, NV_TYPE_NULL, 0, 0));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createf_null(const char *namefmt, ...)
|
||||
nvpair_create_bool(const char *name, bool value)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_createv_null(namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
return (nvpair_allocv(name, NV_TYPE_BOOL, value ? 1 : 0,
|
||||
sizeof(uint8_t)));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createf_bool(bool value, const char *namefmt, ...)
|
||||
nvpair_create_number(const char *name, uint64_t value)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_createv_bool(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
return (nvpair_allocv(name, NV_TYPE_NUMBER, value, sizeof(value)));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createf_number(uint64_t value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_createv_number(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createf_string(const char *value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_createv_string(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createf_nvlist(const nvlist_t *value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_createv_nvlist(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
nvpair_t *
|
||||
nvpair_createf_descriptor(int value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_createv_descriptor(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
#endif
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createf_binary(const void *value, size_t size, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_createv_binary(value, size, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createv_null(const char *namefmt, va_list nameap)
|
||||
{
|
||||
|
||||
return (nvpair_allocv(NV_TYPE_NULL, 0, 0, namefmt, nameap));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createv_bool(bool value, const char *namefmt, va_list nameap)
|
||||
{
|
||||
|
||||
return (nvpair_allocv(NV_TYPE_BOOL, value ? 1 : 0, sizeof(uint8_t),
|
||||
namefmt, nameap));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createv_number(uint64_t value, const char *namefmt, va_list nameap)
|
||||
{
|
||||
|
||||
return (nvpair_allocv(NV_TYPE_NUMBER, value, sizeof(value), namefmt,
|
||||
nameap));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createv_string(const char *value, const char *namefmt, va_list nameap)
|
||||
nvpair_create_string(const char *name, const char *value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
size_t size;
|
||||
@ -963,8 +811,8 @@ nvpair_createv_string(const char *value, const char *namefmt, va_list nameap)
|
||||
return (NULL);
|
||||
size = strlen(value) + 1;
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_STRING, (uint64_t)(uintptr_t)data, size,
|
||||
namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_STRING, (uint64_t)(uintptr_t)data,
|
||||
size);
|
||||
if (nvp == NULL)
|
||||
nv_free(data);
|
||||
|
||||
@ -972,8 +820,7 @@ nvpair_createv_string(const char *value, const char *namefmt, va_list nameap)
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt,
|
||||
va_list nameap)
|
||||
nvpair_create_nvlist(const char *name, const nvlist_t *value)
|
||||
{
|
||||
nvlist_t *nvl;
|
||||
nvpair_t *nvp;
|
||||
@ -987,8 +834,7 @@ nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt,
|
||||
if (nvl == NULL)
|
||||
return (NULL);
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_NVLIST, (uint64_t)(uintptr_t)nvl, 0,
|
||||
namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_NVLIST, (uint64_t)(uintptr_t)nvl, 0);
|
||||
if (nvp == NULL)
|
||||
nvlist_destroy(nvl);
|
||||
else
|
||||
@ -999,7 +845,7 @@ nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt,
|
||||
|
||||
#ifndef _KERNEL
|
||||
nvpair_t *
|
||||
nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap)
|
||||
nvpair_create_descriptor(const char *name, int value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1012,8 +858,8 @@ nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap)
|
||||
if (value < 0)
|
||||
return (NULL);
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_DESCRIPTOR, (uint64_t)value,
|
||||
sizeof(int64_t), namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_DESCRIPTOR, (uint64_t)value,
|
||||
sizeof(int64_t));
|
||||
if (nvp == NULL)
|
||||
close(value);
|
||||
|
||||
@ -1022,8 +868,7 @@ nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap)
|
||||
#endif
|
||||
|
||||
nvpair_t *
|
||||
nvpair_createv_binary(const void *value, size_t size, const char *namefmt,
|
||||
va_list nameap)
|
||||
nvpair_create_binary(const char *name, const void *value, size_t size)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
void *data;
|
||||
@ -1038,8 +883,8 @@ nvpair_createv_binary(const void *value, size_t size, const char *namefmt,
|
||||
return (NULL);
|
||||
memcpy(data, value, size);
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_BINARY, (uint64_t)(uintptr_t)data, size,
|
||||
namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_BINARY, (uint64_t)(uintptr_t)data,
|
||||
size);
|
||||
if (nvp == NULL)
|
||||
nv_free(data);
|
||||
|
||||
@ -1048,90 +893,6 @@ nvpair_createv_binary(const void *value, size_t size, const char *namefmt,
|
||||
|
||||
nvpair_t *
|
||||
nvpair_move_string(const char *name, char *value)
|
||||
{
|
||||
|
||||
return (nvpair_movef_string(value, "%s", name));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_move_nvlist(const char *name, nvlist_t *value)
|
||||
{
|
||||
|
||||
return (nvpair_movef_nvlist(value, "%s", name));
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
nvpair_t *
|
||||
nvpair_move_descriptor(const char *name, int value)
|
||||
{
|
||||
|
||||
return (nvpair_movef_descriptor(value, "%s", name));
|
||||
}
|
||||
#endif
|
||||
|
||||
nvpair_t *
|
||||
nvpair_move_binary(const char *name, void *value, size_t size)
|
||||
{
|
||||
|
||||
return (nvpair_movef_binary(value, size, "%s", name));
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_movef_string(char *value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_movev_string(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_movef_nvlist(nvlist_t *value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_movev_nvlist(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
nvpair_t *
|
||||
nvpair_movef_descriptor(int value, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_movev_descriptor(value, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
#endif
|
||||
|
||||
nvpair_t *
|
||||
nvpair_movef_binary(void *value, size_t size, const char *namefmt, ...)
|
||||
{
|
||||
va_list nameap;
|
||||
nvpair_t *nvp;
|
||||
|
||||
va_start(nameap, namefmt);
|
||||
nvp = nvpair_movev_binary(value, size, namefmt, nameap);
|
||||
va_end(nameap);
|
||||
|
||||
return (nvp);
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_movev_string(char *value, const char *namefmt, va_list nameap)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
int serrno;
|
||||
@ -1141,8 +902,8 @@ nvpair_movev_string(char *value, const char *namefmt, va_list nameap)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_STRING, (uint64_t)(uintptr_t)value,
|
||||
strlen(value) + 1, namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_STRING, (uint64_t)(uintptr_t)value,
|
||||
strlen(value) + 1);
|
||||
if (nvp == NULL) {
|
||||
SAVE_ERRNO(serrno);
|
||||
nv_free(value);
|
||||
@ -1153,7 +914,7 @@ nvpair_movev_string(char *value, const char *namefmt, va_list nameap)
|
||||
}
|
||||
|
||||
nvpair_t *
|
||||
nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap)
|
||||
nvpair_move_nvlist(const char *name, nvlist_t *value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
|
||||
@ -1168,8 +929,8 @@ nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_NVLIST, (uint64_t)(uintptr_t)value, 0,
|
||||
namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_NVLIST, (uint64_t)(uintptr_t)value,
|
||||
0);
|
||||
if (nvp == NULL)
|
||||
nvlist_destroy(value);
|
||||
else
|
||||
@ -1180,7 +941,7 @@ nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap)
|
||||
|
||||
#ifndef _KERNEL
|
||||
nvpair_t *
|
||||
nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap)
|
||||
nvpair_move_descriptor(const char *name, int value)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
int serrno;
|
||||
@ -1190,8 +951,8 @@ nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_DESCRIPTOR, (uint64_t)value,
|
||||
sizeof(int64_t), namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_DESCRIPTOR, (uint64_t)value,
|
||||
sizeof(int64_t));
|
||||
if (nvp == NULL) {
|
||||
serrno = errno;
|
||||
close(value);
|
||||
@ -1203,8 +964,7 @@ nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap)
|
||||
#endif
|
||||
|
||||
nvpair_t *
|
||||
nvpair_movev_binary(void *value, size_t size, const char *namefmt,
|
||||
va_list nameap)
|
||||
nvpair_move_binary(const char *name, void *value, size_t size)
|
||||
{
|
||||
nvpair_t *nvp;
|
||||
int serrno;
|
||||
@ -1214,8 +974,8 @@ nvpair_movev_binary(void *value, size_t size, const char *namefmt,
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
nvp = nvpair_allocv(NV_TYPE_BINARY, (uint64_t)(uintptr_t)value, size,
|
||||
namefmt, nameap);
|
||||
nvp = nvpair_allocv(name, NV_TYPE_BINARY, (uint64_t)(uintptr_t)value,
|
||||
size);
|
||||
if (nvp == NULL) {
|
||||
SAVE_ERRNO(serrno);
|
||||
nv_free(value);
|
||||
@ -1348,3 +1108,4 @@ nvpair_type_string(int type)
|
||||
return ("<UNKNOWN>");
|
||||
}
|
||||
}
|
||||
|
||||
|
123
sys/sys/nv.h
123
sys/sys/nv.h
@ -194,129 +194,6 @@ void nvlist_free_descriptor(nvlist_t *nvl, const char *name);
|
||||
#endif
|
||||
void nvlist_free_binary(nvlist_t *nvl, const char *name);
|
||||
|
||||
/*
|
||||
* Below are the same functions, but which operate on format strings and
|
||||
* variable argument lists.
|
||||
*
|
||||
* Functions that are not inserting a new pair into the nvlist cannot handle
|
||||
* a failure to allocate the memory to hold the new name. Therefore these
|
||||
* functions are not provided in the kernel.
|
||||
*/
|
||||
|
||||
#ifndef _KERNEL
|
||||
bool nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
bool nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4);
|
||||
|
||||
bool nvlist_existsf_null(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
bool nvlist_existsf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
bool nvlist_existsf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
bool nvlist_existsf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
bool nvlist_existsf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
bool nvlist_existsf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
bool nvlist_existsf_binary(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
|
||||
bool nvlist_existsv(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
bool nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
|
||||
bool nvlist_existsv_null(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
bool nvlist_existsv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
bool nvlist_existsv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
bool nvlist_existsv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
bool nvlist_existsv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
bool nvlist_existsv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
bool nvlist_existsv_binary(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
#endif
|
||||
|
||||
void nvlist_addf_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_addf_bool(nvlist_t *nvl, bool value, const char *namefmt, ...) __printflike(3, 4);
|
||||
void nvlist_addf_number(nvlist_t *nvl, uint64_t value, const char *namefmt, ...) __printflike(3, 4);
|
||||
void nvlist_addf_string(nvlist_t *nvl, const char *value, const char *namefmt, ...) __printflike(3, 4);
|
||||
void nvlist_addf_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, ...) __printflike(3, 4);
|
||||
#ifndef _KERNEL
|
||||
void nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4);
|
||||
#endif
|
||||
void nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, ...) __printflike(4, 5);
|
||||
|
||||
#if !defined(_KERNEL) || defined(_VA_LIST_DECLARED)
|
||||
void nvlist_addv_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_addv_bool(nvlist_t *nvl, bool value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
void nvlist_addv_number(nvlist_t *nvl, uint64_t value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
void nvlist_addv_string(nvlist_t *nvl, const char *value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
void nvlist_addv_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
#ifndef _KERNEL
|
||||
void nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
#endif
|
||||
void nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0);
|
||||
#endif
|
||||
|
||||
void nvlist_movef_string(nvlist_t *nvl, char *value, const char *namefmt, ...) __printflike(3, 4);
|
||||
void nvlist_movef_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, ...) __printflike(3, 4);
|
||||
#ifndef _KERNEL
|
||||
void nvlist_movef_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4);
|
||||
#endif
|
||||
void nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, ...) __printflike(4, 5);
|
||||
|
||||
#if !defined(_KERNEL) || defined(_VA_LIST_DECLARED)
|
||||
void nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
void nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
#ifndef _KERNEL
|
||||
void nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
#endif
|
||||
void nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0);
|
||||
#endif
|
||||
|
||||
#ifndef _KERNEL
|
||||
bool nvlist_getf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
uint64_t nvlist_getf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
const char *nvlist_getf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
const nvlist_t *nvlist_getf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
int nvlist_getf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
const void *nvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4);
|
||||
|
||||
bool nvlist_getv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
uint64_t nvlist_getv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
const char *nvlist_getv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
const nvlist_t *nvlist_getv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
int nvlist_getv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
const void *nvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
|
||||
bool nvlist_takef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
uint64_t nvlist_takef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
char *nvlist_takef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvlist_t *nvlist_takef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
int nvlist_takef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void *nvlist_takef_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4);
|
||||
|
||||
bool nvlist_takev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
uint64_t nvlist_takev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
char *nvlist_takev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvlist_t *nvlist_takev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
int nvlist_takev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void *nvlist_takev_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
|
||||
void nvlist_freef(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4);
|
||||
|
||||
void nvlist_freef_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_freef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_freef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_freef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_freef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_freef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
void nvlist_freef_binary(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
|
||||
|
||||
void nvlist_freev(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
|
||||
void nvlist_freev_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_freev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_freev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_freev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_freev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_freev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
void nvlist_freev_binary(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
#endif /* _KERNEL */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_NV_H_ */
|
||||
|
@ -128,30 +128,4 @@ const void *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
|
||||
|
||||
void nvpair_free(nvpair_t *nvp);
|
||||
|
||||
nvpair_t *nvpair_createf_null(const char *namefmt, ...) __printflike(1, 2);
|
||||
nvpair_t *nvpair_createf_bool(bool value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_createf_number(uint64_t value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_createf_string(const char *value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_createf_nvlist(const nvlist_t *value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_createf_descriptor(int value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_createf_binary(const void *value, size_t size, const char *namefmt, ...) __printflike(3, 4);
|
||||
|
||||
nvpair_t *nvpair_createv_null(const char *namefmt, va_list nameap) __printflike(1, 0);
|
||||
nvpair_t *nvpair_createv_bool(bool value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_createv_number(uint64_t value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_createv_string(const char *value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_createv_binary(const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
|
||||
nvpair_t *nvpair_movef_string(char *value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_movef_nvlist(nvlist_t *value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_movef_descriptor(int value, const char *namefmt, ...) __printflike(2, 3);
|
||||
nvpair_t *nvpair_movef_binary(void *value, size_t size, const char *namefmt, ...) __printflike(3, 4);
|
||||
|
||||
nvpair_t *nvpair_movev_string(char *value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap) __printflike(2, 0);
|
||||
nvpair_t *nvpair_movev_binary(void *value, size_t size, const char *namefmt, va_list nameap) __printflike(3, 0);
|
||||
|
||||
#endif /* !_NV_IMPL_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user