summaryrefslogtreecommitdiff
path: root/usr/src/man/man3nvpair/nvlist_next_nvpair.3nvpair
blob: e66c3c33a5822ed6f169e2ebcb39c0a64629b615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
'\" te
.\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH NVLIST_NEXT_NVPAIR 3NVPAIR "Feb 2, 2004"
.SH NAME
nvlist_next_nvpair, nvpair_name, nvpair_type \- return data regarding
name-value pairs
.SH SYNOPSIS
.LP
.nf
\fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lnvpair\fR [ \fIlibrary\fR... ]
#include <libnvpair.h>

\fBnvpair_t *\fR\fBnvlist_next_nvpair\fR(\fBnvlist_t *\fR\fInvl\fR, \fBnvpair_t *\fR\fInvpair\fR);
.fi

.LP
.nf
\fBchar *\fR\fBnvpair_name\fR(\fBnvpair_t *\fR\fInvpair\fR);
.fi

.LP
.nf
\fBdata_type_t\fR \fBnvpair_type\fR(\fBnvpair_t *\fR\fInvpair\fR);
.fi

.SH PARAMETERS
.sp
.ne 2
.na
\fB\fInvl\fR\fR
.ad
.RS 10n
The \fBnvlist_t\fR to be processed.
.RE

.sp
.ne 2
.na
\fB\fInvpair\fR\fR
.ad
.RS 10n
Handle to a name-value pair.
.RE

.SH DESCRIPTION
.sp
.LP
The \fBnvlist_next_nvpair()\fR function returns a handle to the next
\fBnvpair\fR in the list following \fBnvpair\fR. If \fBnvpair\fR is \fINULL\fR,
the first pair is returned. If \fBnvpair\fR is the last pair in the
\fBnvlist\fR, \fINULL\fR is returned.
.sp
.LP
The \fBnvpair_name()\fR function returns a string containing the name of
\fBnvpair\fR.
.sp
.LP
The \fBnvpair_type()\fR function retrieves the value of the \fBnvpair\fR in the
form of enumerated type \fBdata_type_t\fR. This is used to determine the
appropriate \fBnvpair_*()\fR function to call for retrieving the value.
.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fBnvpair_name()\fR returns a string containing the
name of the name-value pair.
.sp
.LP
Upon successful completion, \fBnvpair_type()\fR returns an enumerated data type
\fBdata_type_t\fR. Possible values for \fBdata_type_t\fR are as follows:
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_BOOLEAN\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_BOOLEAN_VALUE\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_BYTE\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT8\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT8\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT16\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT16\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT32\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT32\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT64\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT64\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_STRING\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_NVLIST\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_BOOLEAN_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_BYTE_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT8_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT8_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT16_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT16_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT32_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT32_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_INT64_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_UINT64_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_STRING_ARRAY\fR
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBDATA_TYPE_NVLIST_ARRAY\fR
.RE
.sp
.LP
Upon reaching the end of a list, \fBnvlist_next_pair()\fR returns \fINULL\fR.
Otherwise, the function returns a handle to next \fBnvpair\fR in the list.
.sp
.LP
These and other \fBlibnvpair\fR(3LIB) functions cannot manipulate nvpairs after
they have been removed from or replaced in an nvlist. Replacement can occur
during pair additions to nvlists created with \fBNV_UNIQUE_NAME_TYPE\fR and
\fBNV_UNIQUE_NAME\fR. See \fBnvlist_alloc\fR(3NVPAIR).
.SH ERRORS
.sp
.LP
No errors are defined.
.SH EXAMPLES
.LP
\fBExample 1 \fRExample of usage of \fBnvlist_next_nvpair()\fR.
.sp
.in +2
.nf
/*
 * usage of nvlist_next_nvpair()
 */
 static int
 edit_nvl(nvlist_t *nvl)
 {
     nvpair_t *curr = nvlist_next_nvpair(nvl, NULL);

     while (curr != NULL) {
         int err;
        nvpair_t *next = nvlist_next_nvpair(nvl, curr);

        if (!nvl_check(curr))
            if ((err = nvlist_remove(nvl, nvpair_name(curr),
                nvpair_type(curr))) != 0)
                    return (err);

         curr = next;
     }
    return (0);
 }
.fi
.in -2

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Evolving
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR libnvpair (3LIB),
.BR nvlist_alloc (3NVPAIR),
.BR attributes (7)
.SH NOTES
.sp
.LP
The enumerated nvpair data types might not be an exhaustive list and new data
types can be added.  An application using the data type enumeration,
\fBdata_type_t\fR, should be written to expect or ignore new data types.