Deleted Added
full compact
nv_impl.h (286645) nv_impl.h (286796)
1/*-
2 * Copyright (c) 2013 The FreeBSD Foundation
1/*-
2 * Copyright (c) 2013 The FreeBSD Foundation
3 * Copyright (c) 2013-2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
3 * All rights reserved.
4 *
5 * This software was developed by Pawel Jakub Dawidek under sponsorship from
6 * the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:

--- 10 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:

--- 10 unchanged lines hidden (view full) ---

22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
29 * $FreeBSD: head/sys/contrib/libnv/nv_impl.h 286645 2015-08-11 18:01:10Z oshogbo $
30 * $FreeBSD: head/sys/contrib/libnv/nv_impl.h 286796 2015-08-15 06:34:49Z oshogbo $
30 */
31
32#ifndef _NV_IMPL_H_
33#define _NV_IMPL_H_
34
35#ifndef _NVPAIR_T_DECLARED
36#define _NVPAIR_T_DECLARED
37struct nvpair;
38
39typedef struct nvpair nvpair_t;
40#endif
41
31 */
32
33#ifndef _NV_IMPL_H_
34#define _NV_IMPL_H_
35
36#ifndef _NVPAIR_T_DECLARED
37#define _NVPAIR_T_DECLARED
38struct nvpair;
39
40typedef struct nvpair nvpair_t;
41#endif
42
43#define NV_TYPE_NVLIST_ARRAY_NEXT 254
42#define NV_TYPE_NVLIST_UP 255
43
44#define NV_TYPE_FIRST NV_TYPE_NULL
44#define NV_TYPE_NVLIST_UP 255
45
46#define NV_TYPE_FIRST NV_TYPE_NULL
45#define NV_TYPE_LAST NV_TYPE_BINARY
47#define NV_TYPE_LAST NV_TYPE_DESCRIPTOR_ARRAY
46
48
47#define NV_FLAG_BIG_ENDIAN 0x80
49#define NV_FLAG_BIG_ENDIAN 0x080
50#define NV_FLAG_IN_ARRAY 0x100
48
49#ifdef _KERNEL
50#define nv_malloc(size) malloc((size), M_NVLIST, M_WAITOK)
51#define nv_calloc(n, size) malloc((n) * (size), M_NVLIST, \
52 M_WAITOK | M_ZERO)
53#define nv_realloc(buf, size) realloc((buf), (size), M_NVLIST, \
54 M_WAITOK)
55#define nv_free(buf) free((buf), M_NVLIST)

--- 25 unchanged lines hidden (view full) ---

81 } while (0)
82
83#define ERRNO_OR_DEFAULT(default) (errno == 0 ? (default) : errno)
84
85#endif
86
87int *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp);
88size_t nvlist_ndescriptors(const nvlist_t *nvl);
51
52#ifdef _KERNEL
53#define nv_malloc(size) malloc((size), M_NVLIST, M_WAITOK)
54#define nv_calloc(n, size) malloc((n) * (size), M_NVLIST, \
55 M_WAITOK | M_ZERO)
56#define nv_realloc(buf, size) realloc((buf), (size), M_NVLIST, \
57 M_WAITOK)
58#define nv_free(buf) free((buf), M_NVLIST)

--- 25 unchanged lines hidden (view full) ---

84 } while (0)
85
86#define ERRNO_OR_DEFAULT(default) (errno == 0 ? (default) : errno)
87
88#endif
89
90int *nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp);
91size_t nvlist_ndescriptors(const nvlist_t *nvl);
92void nvlist_set_flags(nvlist_t *nvl, int flags);
89
90nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl);
91nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
92nvpair_t *nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
93
94void nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp);
95
96bool nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp);
97
98void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent);
93
94nvpair_t *nvlist_first_nvpair(const nvlist_t *nvl);
95nvpair_t *nvlist_next_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
96nvpair_t *nvlist_prev_nvpair(const nvlist_t *nvl, const nvpair_t *nvp);
97
98void nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp);
99
100bool nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp);
101
102void nvlist_set_parent(nvlist_t *nvl, nvpair_t *parent);
103void nvlist_set_array_next(nvlist_t *nvl, nvpair_t *ele);
99
100const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name);
101
102nvpair_t *nvlist_take_nvpair(nvlist_t *nvl, const char *name);
103
104/* Function removes the given nvpair from the nvlist. */
105void nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp);
106

--- 8 unchanged lines hidden (view full) ---

115nvpair_t *nvpair_create_bool(const char *name, bool value);
116nvpair_t *nvpair_create_number(const char *name, uint64_t value);
117nvpair_t *nvpair_create_string(const char *name, const char *value);
118nvpair_t *nvpair_create_stringf(const char *name, const char *valuefmt, ...) __printflike(2, 3);
119nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap) __printflike(2, 0);
120nvpair_t *nvpair_create_nvlist(const char *name, const nvlist_t *value);
121nvpair_t *nvpair_create_descriptor(const char *name, int value);
122nvpair_t *nvpair_create_binary(const char *name, const void *value, size_t size);
104
105const nvpair_t *nvlist_get_nvpair(const nvlist_t *nvl, const char *name);
106
107nvpair_t *nvlist_take_nvpair(nvlist_t *nvl, const char *name);
108
109/* Function removes the given nvpair from the nvlist. */
110void nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp);
111

--- 8 unchanged lines hidden (view full) ---

120nvpair_t *nvpair_create_bool(const char *name, bool value);
121nvpair_t *nvpair_create_number(const char *name, uint64_t value);
122nvpair_t *nvpair_create_string(const char *name, const char *value);
123nvpair_t *nvpair_create_stringf(const char *name, const char *valuefmt, ...) __printflike(2, 3);
124nvpair_t *nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap) __printflike(2, 0);
125nvpair_t *nvpair_create_nvlist(const char *name, const nvlist_t *value);
126nvpair_t *nvpair_create_descriptor(const char *name, int value);
127nvpair_t *nvpair_create_binary(const char *name, const void *value, size_t size);
128nvpair_t *nvpair_create_bool_array(const char *name, const bool *value, size_t nitems);
129nvpair_t *nvpair_create_number_array(const char *name, const uint64_t *value, size_t nitems);
130nvpair_t *nvpair_create_string_array(const char *name, const char * const *value, size_t nitems);
131nvpair_t *nvpair_create_nvlist_array(const char *name, const nvlist_t * const *value, size_t nitems);
132nvpair_t *nvpair_create_descriptor_array(const char *name, const int *value, size_t nitems);
123
124nvpair_t *nvpair_move_string(const char *name, char *value);
125nvpair_t *nvpair_move_nvlist(const char *name, nvlist_t *value);
126nvpair_t *nvpair_move_descriptor(const char *name, int value);
127nvpair_t *nvpair_move_binary(const char *name, void *value, size_t size);
133
134nvpair_t *nvpair_move_string(const char *name, char *value);
135nvpair_t *nvpair_move_nvlist(const char *name, nvlist_t *value);
136nvpair_t *nvpair_move_descriptor(const char *name, int value);
137nvpair_t *nvpair_move_binary(const char *name, void *value, size_t size);
138nvpair_t *nvpair_move_bool_array(const char *name, bool *value, size_t nitems);
139nvpair_t *nvpair_move_nvlist_array(const char *name, nvlist_t **value, size_t nitems);
140nvpair_t *nvpair_move_descriptor_array(const char *name, int *value, size_t nitems);
141nvpair_t *nvpair_move_number_array(const char *name, uint64_t *value, size_t nitems);
142nvpair_t *nvpair_move_string_array(const char *name, char **value, size_t nitems);
128
143
129bool nvpair_get_bool(const nvpair_t *nvp);
130uint64_t nvpair_get_number(const nvpair_t *nvp);
131const char *nvpair_get_string(const nvpair_t *nvp);
132const nvlist_t *nvpair_get_nvlist(const nvpair_t *nvp);
133int nvpair_get_descriptor(const nvpair_t *nvp);
134const void *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
144bool nvpair_get_bool(const nvpair_t *nvp);
145uint64_t nvpair_get_number(const nvpair_t *nvp);
146const char *nvpair_get_string(const nvpair_t *nvp);
147const nvlist_t *nvpair_get_nvlist(const nvpair_t *nvp);
148int nvpair_get_descriptor(const nvpair_t *nvp);
149const void *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
150const bool *nvpair_get_bool_array(const nvpair_t *nvp, size_t *nitemsp);
151const uint64_t *nvpair_get_number_array(const nvpair_t *nvp, size_t *nitemsp);
152const char * const *nvpair_get_string_array(const nvpair_t *nvp, size_t *nitemsp);
153const nvlist_t * const *nvpair_get_nvlist_array(const nvpair_t *nvp, size_t *nitemsp);
154const int *nvpair_get_descriptor_array(const nvpair_t *nvp, size_t *nitemsp);
135
136void nvpair_free(nvpair_t *nvp);
137
138#endif /* !_NV_IMPL_H_ */
155
156void nvpair_free(nvpair_t *nvp);
157
158#endif /* !_NV_IMPL_H_ */