2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2009-2010 The FreeBSD Foundation
7 * This software was developed by Pawel Jakub Dawidek under sponsorship from
8 * the FreeBSD Foundation.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
46 struct nv *nv_alloc(void);
47 void nv_free(struct nv *nv);
48 int nv_error(const struct nv *nv);
49 int nv_set_error(struct nv *nv, int error);
50 int nv_validate(struct nv *nv, size_t *extrap);
52 struct ebuf *nv_hton(struct nv *nv);
53 struct nv *nv_ntoh(struct ebuf *eb);
55 void nv_add_int8(struct nv *nv, int8_t value, const char *namefmt, ...)
57 void nv_add_uint8(struct nv *nv, uint8_t value, const char *namefmt, ...)
59 void nv_add_int16(struct nv *nv, int16_t value, const char *namefmt, ...)
61 void nv_add_uint16(struct nv *nv, uint16_t value, const char *namefmt, ...)
63 void nv_add_int32(struct nv *nv, int32_t value, const char *namefmt, ...)
65 void nv_add_uint32(struct nv *nv, uint32_t value, const char *namefmt, ...)
67 void nv_add_int64(struct nv *nv, int64_t value, const char *namefmt, ...)
69 void nv_add_uint64(struct nv *nv, uint64_t value, const char *namefmt, ...)
71 void nv_add_int8_array(struct nv *nv, const int8_t *value, size_t size,
72 const char *namefmt, ...) __printflike(4, 5);
73 void nv_add_uint8_array(struct nv *nv, const uint8_t *value, size_t size,
74 const char *namefmt, ...) __printflike(4, 5);
75 void nv_add_int16_array(struct nv *nv, const int16_t *value, size_t size,
76 const char *namefmt, ...) __printflike(4, 5);
77 void nv_add_uint16_array(struct nv *nv, const uint16_t *value, size_t size,
78 const char *namefmt, ...) __printflike(4, 5);
79 void nv_add_int32_array(struct nv *nv, const int32_t *value, size_t size,
80 const char *namefmt, ...) __printflike(4, 5);
81 void nv_add_uint32_array(struct nv *nv, const uint32_t *value, size_t size,
82 const char *namefmt, ...) __printflike(4, 5);
83 void nv_add_int64_array(struct nv *nv, const int64_t *value, size_t size,
84 const char *namefmt, ...) __printflike(4, 5);
85 void nv_add_uint64_array(struct nv *nv, const uint64_t *value, size_t size,
86 const char *namefmt, ...) __printflike(4, 5);
87 void nv_add_string(struct nv *nv, const char *value, const char *namefmt, ...)
89 void nv_add_stringf(struct nv *nv, const char *name, const char *valuefmt, ...)
91 void nv_add_stringv(struct nv *nv, const char *name, const char *valuefmt,
92 va_list valueap) __printflike(3, 0);
94 int8_t nv_get_int8(struct nv *nv, const char *namefmt, ...)
96 uint8_t nv_get_uint8(struct nv *nv, const char *namefmt, ...)
98 int16_t nv_get_int16(struct nv *nv, const char *namefmt, ...)
100 uint16_t nv_get_uint16(struct nv *nv, const char *namefmt, ...)
102 int32_t nv_get_int32(struct nv *nv, const char *namefmt, ...)
104 uint32_t nv_get_uint32(struct nv *nv, const char *namefmt, ...)
106 int64_t nv_get_int64(struct nv *nv, const char *namefmt, ...)
108 uint64_t nv_get_uint64(struct nv *nv, const char *namefmt, ...)
110 const int8_t *nv_get_int8_array(struct nv *nv, size_t *sizep,
111 const char *namefmt, ...) __printflike(3, 4);
112 const uint8_t *nv_get_uint8_array(struct nv *nv, size_t *sizep,
113 const char *namefmt, ...) __printflike(3, 4);
114 const int16_t *nv_get_int16_array(struct nv *nv, size_t *sizep,
115 const char *namefmt, ...) __printflike(3, 4);
116 const uint16_t *nv_get_uint16_array(struct nv *nv, size_t *sizep,
117 const char *namefmt, ...) __printflike(3, 4);
118 const int32_t *nv_get_int32_array(struct nv *nv, size_t *sizep,
119 const char *namefmt, ...) __printflike(3, 4);
120 const uint32_t *nv_get_uint32_array(struct nv *nv, size_t *sizep,
121 const char *namefmt, ...) __printflike(3, 4);
122 const int64_t *nv_get_int64_array(struct nv *nv, size_t *sizep,
123 const char *namefmt, ...) __printflike(3, 4);
124 const uint64_t *nv_get_uint64_array(struct nv *nv, size_t *sizep,
125 const char *namefmt, ...) __printflike(3, 4);
126 const char *nv_get_string(struct nv *nv, const char *namefmt, ...)
129 bool nv_exists(struct nv *nv, const char *namefmt, ...) __printflike(2, 3);
130 void nv_assert(struct nv *nv, const char *namefmt, ...) __printflike(2, 3);
131 void nv_dump(struct nv *nv);