Date: Tue, 30 Jul 2013 15:08:17 GMT From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255350 - in soc2013/dpl: . libnv Message-ID: <201307301508.r6UF8HkF008754@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dpl Date: Tue Jul 30 15:08:17 2013 New Revision: 255350 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255350 Log: Adding pjd's libnv, since it will be used from now on to serializing the commands arguments sent to the client. Added: soc2013/dpl/libnv/ soc2013/dpl/libnv/Makefile soc2013/dpl/libnv/msgio.c soc2013/dpl/libnv/msgio.h soc2013/dpl/libnv/nv.h soc2013/dpl/libnv/nv_impl.h soc2013/dpl/libnv/nvlist.c soc2013/dpl/libnv/nvlist_impl.h soc2013/dpl/libnv/nvpair.c soc2013/dpl/libnv/nvpair_impl.h Modified: soc2013/dpl/caller.c Modified: soc2013/dpl/caller.c ============================================================================== --- soc2013/dpl/caller.c Tue Jul 30 14:50:44 2013 (r255349) +++ soc2013/dpl/caller.c Tue Jul 30 15:08:17 2013 (r255350) @@ -11,12 +11,9 @@ #include <strings.h> -struct pollfd fdread[1], fdwrite[1]; pid_t child = 0; int sv[2], i; -int *buf[32]; - pid_t startChild(); void waitCommand(); void killChild(); @@ -30,19 +27,17 @@ { int ret, a = 1; ret = sum(a); - fflush(stdout); printf("ret: %d (should be 2)\n", ret); - fflush(stdout); - atexit(killChild); return 0; } int sum(int a) { + struct pollfd fdread[1], fdwrite[1]; + int buf[32]; /* Caller overhead */ /* Much better if we do this in a function */ - int ptr = (int)sum_; fdwrite[0].fd = sv[0]; fdwrite[0].events = POLLOUT; fdwrite[0].revents = 0; @@ -53,8 +48,8 @@ startChild(); /* Real stuff */ - buf[0] = &ptr; - buf[1] = &a; + buf[0] = 1; + buf[1] = a; /* Should be in a function as well */ /* sendAndWait() (?) */ @@ -71,9 +66,9 @@ break; } } - printf("done: %d\n", *buf[0]); + printf("done: %d\n", buf[0]); - return *buf[0]; + return buf[0]; } int sum_(int a) @@ -90,7 +85,9 @@ close(STDERR_FILENO); cap_enter(); waitCommand(); - } + } else + atexit(killChild); + return child; } @@ -100,6 +97,7 @@ waitCommand() { struct pollfd fdread[1], fdwrite[1]; + int buf[32]; fdread[0].fd = sv[1]; fdread[0].events = POLLIN|POLLPRI; fdread[0].revents = 0; @@ -114,14 +112,13 @@ } } - if( (void *)*buf[0] == (void *) sum_ ){ - /* This is a C exercise }:-) */ - int ret = ((int (*) (int)) *buf[0])(*buf[1]); - /* int ret = sum_(*buf[1]); */ + if( buf[0] == 1 ){ + /* We still have to take recv nvlist */ + int ret = sum(buf[1]); printf("ret:%d\n", ret); fflush(stdout); bzero(&buf, sizeof(buf)); - buf[0] = &ret; + buf[0] = ret; } while(1) { @@ -136,5 +133,5 @@ void killChild() { - kill(child, SIGINT); + kill(child, SIGKILL); } \ No newline at end of file Added: soc2013/dpl/libnv/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/Makefile Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,14 @@ +# $FreeBSD$ + +LIB= nv +SHLIBDIR?= /lib +SHLIB_MAJOR= 0 + +SRCS= msgio.c +SRCS+= nvlist.c +SRCS+= nvpair.c +INCS= nv.h + +CFLAGS+=-ggdb + +.include <bsd.lib.mk> Added: soc2013/dpl/libnv/msgio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/msgio.c Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,350 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/socket.h> + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#ifdef HAVE_PJDLOG +#include <pjdlog.h> +#endif + +#include "msgio.h" + +#ifndef HAVE_PJDLOG +#include <assert.h> +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#define PJDLOG_RASSERT(expr, ...) assert(expr) +#define PJDLOG_ABORT(...) abort() +#endif + +int +msghdr_allocate(size_t datasize, size_t nfds, struct msghdr *msg, + struct iovec *iov) +{ + int serrno; + + bzero(msg, sizeof(*msg)); + bzero(iov, sizeof(*iov)); + + msg->msg_iov = iov; + msg->msg_iovlen = 1; + + if (datasize == 0) + return (0); + + if (nfds > 0) { + msg->msg_controllen = nfds * CMSG_SPACE(sizeof(int)); + msg->msg_control = calloc(1, msg->msg_controllen); + if (msg->msg_control == NULL) + return (-1); + } + + iov->iov_len = datasize; + iov->iov_base = malloc(iov->iov_len); + if (iov->iov_base == NULL) { + serrno = errno; + free(msg->msg_control); + errno = serrno; + return (-1); + } + + return (0); +} + +static bool +fd_is_valid(int fd) +{ + + return (fcntl(fd, F_GETFL) != -1 || errno != EBADF); +} + +static int +msghdr_add_fd(struct msghdr *msg, struct cmsghdr **cmsgp, int fd) +{ + struct cmsghdr *cmsg; + + PJDLOG_ASSERT(fd >= 0); + + if (!fd_is_valid(fd)) { + errno = EBADF; + return (-1); + } + + cmsg = *cmsgp; + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); + bcopy(&fd, CMSG_DATA(cmsg), sizeof(fd)); + *cmsgp = CMSG_NXTHDR(msg, cmsg); + + return (0); +} + +int +msghdr_fds_from_array(const int *fds, size_t nfds, struct msghdr *msg) +{ + struct cmsghdr *cmsg; + unsigned int ii; + int serrno; + + if (nfds == 0) { + msg->msg_control = NULL; + msg->msg_controllen = 0; + return (0); + } + + msg->msg_controllen = nfds * CMSG_SPACE(sizeof(int)); + msg->msg_control = calloc(1, msg->msg_controllen); + if (msg->msg_control == NULL) + return (-1); + + cmsg = CMSG_FIRSTHDR(msg); + for (ii = 0; ii < nfds; ii++) { + if (msghdr_add_fd(msg, &cmsg, fds[ii]) == -1) { + serrno = errno; + free(msg->msg_control); + errno = serrno; + return (-1); + } + } + + return (0); +} + +static struct cmsghdr * +msghdr_get_fd(struct msghdr *msg, struct cmsghdr *cmsg, int *fdp) +{ + + if (cmsg == NULL || cmsg->cmsg_level != SOL_SOCKET || + cmsg->cmsg_type != SCM_RIGHTS) { + return (NULL); + } + + bcopy(CMSG_DATA(cmsg), fdp, sizeof(*fdp)); +#ifndef MSG_CMSG_CLOEXEC + /* + * If the MSG_CMSG_CLOEXEC flag is not available we cannot set the + * close-on-exec flag atomically, but we still want to set it for + * consistency. + */ + (void) fcntl(*fdp, F_SETFD, FD_CLOEXEC); +#endif + + return (CMSG_NXTHDR(msg, cmsg)); +} + +int * +msghdr_fds_to_array(struct msghdr *msg, size_t nfds) +{ + struct cmsghdr *cmsg; + unsigned int ii; + int *fds; + + fds = malloc(sizeof(fds[0]) * nfds); + if (fds == NULL) + return (NULL); + cmsg = CMSG_FIRSTHDR(msg); + for (ii = 0; ii < nfds && cmsg != NULL; ii++) + cmsg = msghdr_get_fd(msg, cmsg, &fds[ii]); + if (cmsg != NULL || ii < nfds) { + free(fds); + fds = NULL; + } + + return (fds); +} + +void +msghdr_fds_free(struct msghdr *msg) +{ + struct cmsghdr *cmsg; + int fd; + + for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; + cmsg = CMSG_NXTHDR(msg, cmsg)) { + if (cmsg->cmsg_level == SOL_SOCKET && + cmsg->cmsg_type == SCM_RIGHTS) { + bcopy(CMSG_DATA(cmsg), &fd, sizeof(fd)); + close(fd); + } + } +} + +static void +fd_wait(int fd, bool doread) +{ + fd_set fds; + + PJDLOG_ASSERT(fd >= 0); + + FD_ZERO(&fds); + FD_SET(fd, &fds); + (void)select(fd + 1, doread ? &fds : NULL, doread ? NULL : &fds, + NULL, NULL); +} + +int +msg_peek(int sock, void *buf, size_t size) +{ + unsigned char *ptr; + ssize_t done; + + PJDLOG_ASSERT(sock >= 0); + PJDLOG_ASSERT(size > 0); + + ptr = buf; + do { + fd_wait(sock, true); + done = recv(sock, ptr, size, MSG_PEEK); + if (done == -1) { + if (errno == EINTR) + continue; + return (-1); + } else if (done == 0) { + errno = ENOTCONN; + return (-1); + } + size -= done; + ptr += done; + } while (size > 0); + + return (0); +} + +int +msg_recv(int sock, struct msghdr *msg) +{ + int flags; + + PJDLOG_ASSERT(sock >= 0); + +#ifdef MSG_CMSG_CLOEXEC + flags = MSG_CMSG_CLOEXEC; +#else + flags = 0; +#endif + + for (;;) { + fd_wait(sock, true); + if (recvmsg(sock, msg, flags) == -1) { + if (errno == EINTR) + continue; + return (-1); + } + break; + } + + return (0); +} + +int +msg_send(int sock, const struct msghdr *msg) +{ + + PJDLOG_ASSERT(sock >= 0); + + for (;;) { + fd_wait(sock, false); + if (sendmsg(sock, msg, 0) == -1) { + if (errno == EINTR) + continue; + return (-1); + } + break; + } + + return (0); +} + +int +cred_send(int sock) +{ + struct msghdr msg; + struct cmsghdr *cmsg; + unsigned char credbuf[CMSG_SPACE(sizeof(struct cmsgcred))]; + + bzero(credbuf, sizeof(credbuf)); + bzero(&msg, sizeof(msg)); + + msg.msg_iov = NULL; + msg.msg_iovlen = 0; + msg.msg_control = credbuf; + msg.msg_controllen = sizeof(credbuf); + + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(struct cmsgcred)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_CREDS; + + if (msg_send(sock, &msg) == -1) + return (-1); + + return (0); +} + +int +cred_recv(int sock, struct cmsgcred *cred) +{ + unsigned char credbuf[CMSG_SPACE(sizeof(struct cmsgcred))]; + struct msghdr msg; + struct cmsghdr *cmsg; + + bzero(credbuf, sizeof(credbuf)); + bzero(&msg, sizeof(msg)); + + msg.msg_iov = NULL; + msg.msg_iovlen = 0; + msg.msg_control = credbuf; + msg.msg_controllen = sizeof(credbuf); + + if (msg_recv(sock, &msg) == -1) + return (-1); + + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct cmsgcred)) || + cmsg->cmsg_level != SOL_SOCKET || + cmsg->cmsg_type != SCM_CREDS) { + errno = EINVAL; + return (-1); + } + bcopy(CMSG_DATA(cmsg), cred, sizeof(*cred)); + + return (0); +} Added: soc2013/dpl/libnv/msgio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/msgio.h Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MSGIO_H_ +#define _MSGIO_H_ + +struct cmsgcred; +struct iovec; +struct msghdr; + +int msghdr_allocate(size_t datasize, size_t nfds, struct msghdr *msg, + struct iovec *iov); + +int msghdr_fds_from_array(const int *fds, size_t nfds, struct msghdr *msg); +int *msghdr_fds_to_array(struct msghdr *msg, size_t nfds); +void msghdr_fds_free(struct msghdr *msg); + +int msg_peek(int sock, void *buf, size_t size); +int msg_recv(int sock, struct msghdr *msg); +int msg_send(int sock, const struct msghdr *msg); + +int cred_send(int sock); +int cred_recv(int sock, struct cmsgcred *cred); + +#endif /* !_MSGIO_H_ */ Added: soc2013/dpl/libnv/nv.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/libnv/nv.h Tue Jul 30 15:08:17 2013 (r255350) @@ -0,0 +1,477 @@ +/*- + * Copyright (c) 2009-2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Pawel Jakub Dawidek under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _NV_H_ +#define _NV_H_ + +#include <sys/cdefs.h> + +#include <stdarg.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> + +#ifndef _NVPAIR_T_DECLARED +#define _NVPAIR_T_DECLARED +struct nvpair; + +typedef struct nvpair nvpair_t; +#endif + +#ifndef _NVLIST_T_DECLARED +#define _NVLIST_T_DECLARED +struct nvlist; + +typedef struct nvlist nvlist_t; +#endif + +#define NVPAIR_NAME_MAX 256 + +#define NV_TYPE_NONE 0 + +#define NV_TYPE_NULL 1 +#define NV_TYPE_BOOL 2 +#define NV_TYPE_NUMBER 3 +#define NV_TYPE_STRING 4 +#define NV_TYPE_NVLIST 5 +#define NV_TYPE_DESCRIPTOR 6 +#define NV_TYPE_BINARY 7 +#define NV_TYPE_ARRAY_BOOL 8 +#define NV_TYPE_ARRAY_NUMBER 9 +#define NV_TYPE_ARRAY_STRING 10 +#define NV_TYPE_ARRAY_NVLIST 11 +#define NV_TYPE_ARRAY_DESCRIPTOR 12 + +/* Duplicated names are not allowed. */ +#define NV_FLAG_UNIQUE_NAME 0x01 +/* Duplicated names of the same type are not allowed. */ +#define NV_FLAG_UNIQUE_NAME_TYPE 0x02 +/* + * NULL values for arrays and strings as well as -1 for descriptors + * are allowed. Note that individual entries in nvlist array, string + * array or descriptor array can still be NULL/-1. + */ +#define NV_FLAG_NO_VALUE 0x04 + +nvlist_t *nvlist_create(int flags); +void nvlist_destroy(nvlist_t *nvl); +int nvlist_error(const nvlist_t *nvl); + +bool nvlist_exists_type(const nvlist_t *nvl, const char *name, int type); +bool nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4); +bool nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0); + +int nvlist_free_type(nvlist_t *nvl, const char *name, int type); +int nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4); +int nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0); + +nvlist_t *nvlist_clone(const nvlist_t *nvl); + +void nvlist_dump(const nvlist_t *nvl, int fd); +void nvlist_fdump(const nvlist_t *nvl, FILE *out); + +size_t nvlist_size(const nvlist_t *nvl); +int *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp); +size_t nvlist_ndescriptors(const nvlist_t *nvl); +void *nvlist_pack(const nvlist_t *nvl, size_t *sizep); +nvlist_t *nvlist_unpack(const void *buf, size_t size); + +int nvlist_send(int sock, const nvlist_t *nvl); +nvlist_t *nvlist_recv(int sock); +nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl); + +nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl); +nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp); +nvpair_t *nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp); + +/* + * The nvlist_exists functions check if the given name (optionally of the given + * type) exists on nvlist. + */ + +bool nvlist_exists(const nvlist_t *nvl, const char *name); +bool nvlist_exists_null(const nvlist_t *nvl, const char *name); +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_descriptor(const nvlist_t *nvl, const char *name); +bool nvlist_exists_binary(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_bool(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_number(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_string(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_nvlist(const nvlist_t *nvl, const char *name); +bool nvlist_exists_array_descriptor(const nvlist_t *nvl, const char *name); + +bool nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +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_existsf_array_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +bool nvlist_existsf_array_descriptor(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_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); +bool nvlist_existsv_array_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +bool nvlist_existsv_array_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); + +/* + * The nvlist_add functions add the given name/value pair. + * If a pointer is provided, nvlist_add will internally allocate memory for the + * given data (in other words it won't consume provided buffer). + */ + +void nvlist_add_nvpair(nvlist_t *nvl, nvpair_t *nvp); +void nvlist_add_null(nvlist_t *nvl, const char *name); +void nvlist_add_bool(nvlist_t *nvl, const char *name, bool value); +void nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value); +void nvlist_add_string(nvlist_t *nvl, const char *name, const char *value); +void nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...) __printflike(3, 4); +void nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt, va_list valueap) __printflike(3, 0); +void nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value); +void nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value, size_t size); +void nvlist_add_array_bool(nvlist_t *nvl, const char *name, const bool *value, size_t nitems); +void nvlist_add_array_number(nvlist_t *nvl, const char *name, const uint64_t *value, size_t nitems); +void nvlist_add_array_string(nvlist_t *nvl, const char *name, const char * const *value, size_t nitems); +void nvlist_add_array_nvlist(nvlist_t *nvl, const char *name, const nvlist_t * const *value, size_t nitems); +void nvlist_add_array_descriptor(nvlist_t *nvl, const char *name, const int *value, size_t nitems); + +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); +void nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_bool(nvlist_t *nvl, const bool *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_number(nvlist_t *nvl, const uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_string(nvlist_t *nvl, const char * const *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_nvlist(nvlist_t *nvl, const nvlist_t * const *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_addf_array_descriptor(nvlist_t *nvl, const int *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); + +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); +void nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_bool(nvlist_t *nvl, const bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_number(nvlist_t *nvl, const uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_string(nvlist_t *nvl, const char * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_nvlist(nvlist_t *nvl, const nvlist_t * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_addv_array_descriptor(nvlist_t *nvl, const int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); + +/* + * The nvlist_move functions add the given name/value pair. + * The functions consumes provided buffer. + */ + +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_descriptor(nvlist_t *nvl, const char *name, int value); +void nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size); +void nvlist_move_array_bool(nvlist_t *nvl, const char *name, bool *value, size_t nitems); +void nvlist_move_array_number(nvlist_t *nvl, const char *name, uint64_t *value, size_t nitems); +void nvlist_move_array_string(nvlist_t *nvl, const char *name, char **value, size_t nitems); +void nvlist_move_array_nvlist(nvlist_t *nvl, const char *name, nvlist_t **value, size_t nitems); +void nvlist_move_array_descriptor(nvlist_t *nvl, const char *name, int *value, size_t nitems); + +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); +void nvlist_movef_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4); +void nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_bool(nvlist_t *nvl, bool *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_number(nvlist_t *nvl, uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_string(nvlist_t *nvl, char **value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_nvlist(nvlist_t *nvl, nvlist_t **value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); +void nvlist_movef_array_descriptor(nvlist_t *nvl, int *value, size_t nitems, const char *namefmt, ...) __printflike(4, 5); + +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); +void nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0); +void nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_bool(nvlist_t *nvl, bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_number(nvlist_t *nvl, uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_string(nvlist_t *nvl, char **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_nvlist(nvlist_t *nvl, nvlist_t **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); +void nvlist_movev_array_descriptor(nvlist_t *nvl, int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(4, 0); + +/* + * The nvlist_get functions returns value associated with the given name. + * If it returns a pointer, the pointer represents internal buffer and should + * not be freed by the caller. + */ + +nvpair_t *nvlist_get_nvpair(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); +int nvlist_get_descriptor(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_array_bool(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const uint64_t *nvlist_get_array_number(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const char * const *nvlist_get_array_string(const nvlist_t *nvl, const char *name, size_t *nitemsp); +nvlist_t * const *nvlist_get_array_nvlist(const nvlist_t *nvl, const char *name, size_t *nitemsp); +const int *nvlist_get_array_descriptor(const nvlist_t *nvl, const char *name, size_t *nitemsp); + +nvpair_t *nvlist_getf_nvpair(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +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); +const bool *nvlist_getf_array_bool(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const uint64_t *nvlist_getf_array_number(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const char * const *nvlist_getf_array_string(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +nvlist_t * const *nvlist_getf_array_nvlist(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +const int *nvlist_getf_array_descriptor(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvlist_getv_nvpair(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +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); +const bool *nvlist_getv_array_bool(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const uint64_t *nvlist_getv_array_number(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const char * const *nvlist_getv_array_string(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +nvlist_t * const *nvlist_getv_array_nvlist(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +const int *nvlist_getv_array_descriptor(const nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); + +/* + * The nvlist_take functions returns value associated with the given name and + * remove the given entry from the nvlist. + * The caller is responsible for freeing received data. + */ + +nvpair_t *nvlist_take_nvpair(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); +int nvlist_take_descriptor(nvlist_t *nvl, const char *name); +void *nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep); +bool *nvlist_take_array_bool(nvlist_t *nvl, const char *name, size_t *nitemsp); +uint64_t *nvlist_take_array_number(nvlist_t *nvl, const char *name, size_t *nitemsp); +char **nvlist_take_array_string(nvlist_t *nvl, const char *name, size_t *nitemsp); +nvlist_t **nvlist_take_array_nvlist(nvlist_t *nvl, const char *name, size_t *nitemsp); +int *nvlist_take_array_descriptor(nvlist_t *nvl, const char *name, size_t *nitemsp); + +nvpair_t *nvlist_takef_nvpair(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +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_takef_array_bool(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +uint64_t *nvlist_takef_array_number(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +char **nvlist_takef_array_string(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +nvlist_t **nvlist_takef_array_nvlist(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); +int *nvlist_takef_array_descriptor(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, ...) __printflike(3, 4); + +nvpair_t *nvlist_takev_nvpair(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +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); +bool *nvlist_takev_array_bool(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +uint64_t *nvlist_takev_array_number(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +char **nvlist_takev_array_string(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +nvlist_t **nvlist_takev_array_nvlist(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); +int *nvlist_takev_array_descriptor(nvlist_t *nvl, size_t *nitemsp, const char *namefmt, va_list nameap) __printflike(3, 0); + +/* Function removes the given nvpair from the nvlist. */ +void nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp); + +/* + * The nvlist_free functions removes the given name/value pair from the nvlist + * and frees memory associated with it. + */ + +int nvlist_free(nvlist_t *nvl, const char *name); +int nvlist_free_null(nvlist_t *nvl, const char *name); +int nvlist_free_bool(nvlist_t *nvl, const char *name); +int nvlist_free_number(nvlist_t *nvl, const char *name); +int nvlist_free_string(nvlist_t *nvl, const char *name); +int nvlist_free_nvlist(nvlist_t *nvl, const char *name); +int nvlist_free_descriptor(nvlist_t *nvl, const char *name); +int nvlist_free_binary(nvlist_t *nvl, const char *name); +int nvlist_free_array_bool(nvlist_t *nvl, const char *name); +int nvlist_free_array_number(nvlist_t *nvl, const char *name); +int nvlist_free_array_string(nvlist_t *nvl, const char *name); +int nvlist_free_array_nvlist(nvlist_t *nvl, const char *name); +int nvlist_free_array_descriptor(nvlist_t *nvl, const char *name); + +int nvlist_freef(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_binary(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); +int nvlist_freef_array_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3); + +int nvlist_freev(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_binary(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); +int nvlist_freev_array_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0); + +void nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp); + +int nvpair_type(const nvpair_t *nvp); +const char *nvpair_name(const nvpair_t *nvp); + +nvpair_t *nvpair_clone(const nvpair_t *nvp); + +nvpair_t *nvpair_create_null(const char *name); +nvpair_t *nvpair_create_bool(const char *name, bool value); +nvpair_t *nvpair_create_number(const char *name, uint64_t value); +nvpair_t *nvpair_create_string(const char *name, const char *value); +nvpair_t *nvpair_create_stringf(const char *name, const char *valuefmt, ...) __printflike(2, 3); +nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap) __printflike(2, 0); +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_array_bool(const char *name, const bool *value, size_t nitems); +nvpair_t *nvpair_create_array_number(const char *name, const uint64_t *value, size_t nitems); +nvpair_t *nvpair_create_array_string(const char *name, const char * const *value, size_t nitems); +nvpair_t *nvpair_create_array_nvlist(const char *name, const nvlist_t * const *value, size_t nitems); +nvpair_t *nvpair_create_array_descriptor(const char *name, const int *value, size_t nitems); + +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_createf_array_bool(const bool *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_number(const uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_string(const char * const *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_nvlist(const nvlist_t * const *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_createf_array_descriptor(const int *value, size_t nitems, 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_createv_array_bool(const bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_number(const uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_string(const char * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_nvlist(const nvlist_t * const *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_createv_array_descriptor(const int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); + +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_array_bool(const char *name, bool *value, size_t nitems); +nvpair_t *nvpair_move_array_number(const char *name, uint64_t *value, size_t nitems); +nvpair_t *nvpair_move_array_string(const char *name, char **value, size_t nitems); +nvpair_t *nvpair_move_array_nvlist(const char *name, nvlist_t **value, size_t nitems); +nvpair_t *nvpair_move_array_descriptor(const char *name, int *value, size_t nitems); + +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_movef_array_bool(bool *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_number(uint64_t *value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_string(char **value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_nvlist(nvlist_t **value, size_t nitems, const char *namefmt, ...) __printflike(3, 4); +nvpair_t *nvpair_movef_array_descriptor(int *value, size_t nitems, 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); +nvpair_t *nvpair_movev_array_bool(bool *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_number(uint64_t *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_string(char **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_nvlist(nvlist_t **value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); +nvpair_t *nvpair_movev_array_descriptor(int *value, size_t nitems, const char *namefmt, va_list nameap) __printflike(3, 0); + +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); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307301508.r6UF8HkF008754>