xref: /minix3/common/lib/libprop/prop_array_util.3 (revision 6b6d114a21a24bee45291fa4af8899e108396c4a)
1*6b6d114aSBen Gras.\"	$NetBSD: prop_array_util.3,v 1.7 2011/10/17 09:24:54 wiz Exp $
2*6b6d114aSBen Gras.\"
3*6b6d114aSBen Gras.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
4*6b6d114aSBen Gras.\" All rights reserved.
5*6b6d114aSBen Gras.\"
6*6b6d114aSBen Gras.\" This code is derived from software contributed to The NetBSD Foundation
7*6b6d114aSBen Gras.\" by Jason R. Thorpe.
8*6b6d114aSBen Gras.\"
9*6b6d114aSBen Gras.\" Redistribution and use in source and binary forms, with or without
10*6b6d114aSBen Gras.\" modification, are permitted provided that the following conditions
11*6b6d114aSBen Gras.\" are met:
12*6b6d114aSBen Gras.\" 1. Redistributions of source code must retain the above copyright
13*6b6d114aSBen Gras.\" notice, this list of conditions and the following disclaimer.
14*6b6d114aSBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
15*6b6d114aSBen Gras.\" notice, this list of conditions and the following disclaimer in the
16*6b6d114aSBen Gras.\" documentation and/or other materials provided with the distribution.
17*6b6d114aSBen Gras.\"
18*6b6d114aSBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19*6b6d114aSBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20*6b6d114aSBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21*6b6d114aSBen Gras.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22*6b6d114aSBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*6b6d114aSBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*6b6d114aSBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*6b6d114aSBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*6b6d114aSBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*6b6d114aSBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*6b6d114aSBen Gras.\" POSSIBILITY OF SUCH DAMAGE.
29*6b6d114aSBen Gras.\"
30*6b6d114aSBen Gras.Dd March 12, 2011
31*6b6d114aSBen Gras.Dt PROP_ARRAY_UTIL 3
32*6b6d114aSBen Gras.Os
33*6b6d114aSBen Gras.Sh NAME
34*6b6d114aSBen Gras.Nm prop_array_util ,
35*6b6d114aSBen Gras.Nm prop_array_get_bool ,
36*6b6d114aSBen Gras.Nm prop_array_set_bool ,
37*6b6d114aSBen Gras.Nm prop_array_get_int8 ,
38*6b6d114aSBen Gras.Nm prop_array_get_uint8 ,
39*6b6d114aSBen Gras.Nm prop_array_set_int8 ,
40*6b6d114aSBen Gras.Nm prop_array_set_uint8 ,
41*6b6d114aSBen Gras.Nm prop_array_get_int16 ,
42*6b6d114aSBen Gras.Nm prop_array_get_uint16 ,
43*6b6d114aSBen Gras.Nm prop_array_set_int16 ,
44*6b6d114aSBen Gras.Nm prop_array_set_uint16 ,
45*6b6d114aSBen Gras.Nm prop_array_get_int32 ,
46*6b6d114aSBen Gras.Nm prop_array_get_uint32 ,
47*6b6d114aSBen Gras.Nm prop_array_set_int32 ,
48*6b6d114aSBen Gras.Nm prop_array_set_uint32 ,
49*6b6d114aSBen Gras.Nm prop_array_get_int64 ,
50*6b6d114aSBen Gras.Nm prop_array_get_uint64 ,
51*6b6d114aSBen Gras.Nm prop_array_set_int64 ,
52*6b6d114aSBen Gras.Nm prop_array_set_uint64 ,
53*6b6d114aSBen Gras.Nm prop_array_add_int8 ,
54*6b6d114aSBen Gras.Nm prop_array_add_uint8 ,
55*6b6d114aSBen Gras.Nm prop_array_add_int16 ,
56*6b6d114aSBen Gras.Nm prop_array_add_uint16 ,
57*6b6d114aSBen Gras.Nm prop_array_add_int32 ,
58*6b6d114aSBen Gras.Nm prop_array_add_uint32 ,
59*6b6d114aSBen Gras.Nm prop_array_add_int64 ,
60*6b6d114aSBen Gras.Nm prop_array_add_uint64 ,
61*6b6d114aSBen Gras.Nm prop_array_get_cstring ,
62*6b6d114aSBen Gras.Nm prop_array_set_cstring ,
63*6b6d114aSBen Gras.Nm prop_array_get_cstring_nocopy ,
64*6b6d114aSBen Gras.Nm prop_array_set_cstring_nocopy ,
65*6b6d114aSBen Gras.Nm prop_array_add_and_rel
66*6b6d114aSBen Gras.Nd array property collection object utility functions
67*6b6d114aSBen Gras.Sh LIBRARY
68*6b6d114aSBen Gras.Lb libprop
69*6b6d114aSBen Gras.Sh SYNOPSIS
70*6b6d114aSBen Gras.In prop/proplib.h
71*6b6d114aSBen Gras.\"
72*6b6d114aSBen Gras.Ft bool
73*6b6d114aSBen Gras.Fn prop_array_get_bool "prop_array_t dict" "unsigned int indx" \
74*6b6d114aSBen Gras    "bool *valp"
75*6b6d114aSBen Gras.Ft bool
76*6b6d114aSBen Gras.Fn prop_array_set_bool "prop_array_t dict" "unsigned int indx" \
77*6b6d114aSBen Gras    "bool val"
78*6b6d114aSBen Gras.\"
79*6b6d114aSBen Gras.Ft bool
80*6b6d114aSBen Gras.Fn prop_array_get_int8 "prop_array_t dict" "unsigned int indx" \
81*6b6d114aSBen Gras    "int8_t *valp"
82*6b6d114aSBen Gras.Ft bool
83*6b6d114aSBen Gras.Fn prop_array_get_uint8 "prop_array_t dict" "unsigned int indx" \
84*6b6d114aSBen Gras    "uint8_t *valp"
85*6b6d114aSBen Gras.Ft bool
86*6b6d114aSBen Gras.Fn prop_array_set_int8 "prop_array_t dict" "unsigned int indx" \
87*6b6d114aSBen Gras    "int8_t val"
88*6b6d114aSBen Gras.Ft bool
89*6b6d114aSBen Gras.Fn prop_array_set_uint8 "prop_array_t dict" "unsigned int indx" \
90*6b6d114aSBen Gras    "uint8_t val"
91*6b6d114aSBen Gras.\"
92*6b6d114aSBen Gras.Ft bool
93*6b6d114aSBen Gras.Fn prop_array_get_int16 "prop_array_t dict" "unsigned int indx" \
94*6b6d114aSBen Gras    "int16_t *valp"
95*6b6d114aSBen Gras.Ft bool
96*6b6d114aSBen Gras.Fn prop_array_get_uint16 "prop_array_t dict" "unsigned int indx" \
97*6b6d114aSBen Gras    "uint16_t *valp"
98*6b6d114aSBen Gras.Ft bool
99*6b6d114aSBen Gras.Fn prop_array_set_int16 "prop_array_t dict" "unsigned int indx" \
100*6b6d114aSBen Gras    "int16_t val"
101*6b6d114aSBen Gras.Ft bool
102*6b6d114aSBen Gras.Fn prop_array_set_uint16 "prop_array_t dict" "unsigned int indx" \
103*6b6d114aSBen Gras    "uint16_t val"
104*6b6d114aSBen Gras.\"
105*6b6d114aSBen Gras.Ft bool
106*6b6d114aSBen Gras.Fn prop_array_get_int32 "prop_array_t dict" "unsigned int indx" \
107*6b6d114aSBen Gras    "int32_t *valp"
108*6b6d114aSBen Gras.Ft bool
109*6b6d114aSBen Gras.Fn prop_array_get_uint32 "prop_array_t dict" "unsigned int indx" \
110*6b6d114aSBen Gras    "uint32_t *valp"
111*6b6d114aSBen Gras.Ft bool
112*6b6d114aSBen Gras.Fn prop_array_set_int32 "prop_array_t dict" "unsigned int indx" \
113*6b6d114aSBen Gras    "int32_t val"
114*6b6d114aSBen Gras.Ft bool
115*6b6d114aSBen Gras.Fn prop_array_set_uint32 "prop_array_t dict" "unsigned int indx" \
116*6b6d114aSBen Gras    "uint32_t val"
117*6b6d114aSBen Gras.\"
118*6b6d114aSBen Gras.Ft bool
119*6b6d114aSBen Gras.Fn prop_array_get_int64 "prop_array_t dict" "unsigned int indx" \
120*6b6d114aSBen Gras    "int64_t *valp"
121*6b6d114aSBen Gras.Ft bool
122*6b6d114aSBen Gras.Fn prop_array_get_uint64 "prop_array_t dict" "unsigned int indx" \
123*6b6d114aSBen Gras    "uint64_t *valp"
124*6b6d114aSBen Gras.Ft bool
125*6b6d114aSBen Gras.Fn prop_array_set_int64 "prop_array_t dict" "unsigned int indx" \
126*6b6d114aSBen Gras    "int64_t val"
127*6b6d114aSBen Gras.Ft bool
128*6b6d114aSBen Gras.Fn prop_array_set_uint64 "prop_array_t dict" "unsigned int indx" \
129*6b6d114aSBen Gras    "uint64_t val"
130*6b6d114aSBen Gras.\"
131*6b6d114aSBen Gras.Ft bool
132*6b6d114aSBen Gras.Fn prop_array_set_int32 "prop_array_t dict" "unsigned int indx" \
133*6b6d114aSBen Gras    "int32_t val"
134*6b6d114aSBen Gras.Ft bool
135*6b6d114aSBen Gras.Fn prop_array_set_uint32 "prop_array_t dict" "unsigned int indx" \
136*6b6d114aSBen Gras    "uint32_t val"
137*6b6d114aSBen Gras.\"
138*6b6d114aSBen Gras.Ft bool
139*6b6d114aSBen Gras.Fn prop_array_add_int8 "prop_array_t dict" "int8_t val"
140*6b6d114aSBen Gras.Ft bool
141*6b6d114aSBen Gras.Fn prop_array_add_uint8 "prop_array_t dict" "uint8_t val"
142*6b6d114aSBen Gras.Ft bool
143*6b6d114aSBen Gras.Fn prop_array_add_int16 "prop_array_t dict"  "int16_t val"
144*6b6d114aSBen Gras.Ft bool
145*6b6d114aSBen Gras.Fn prop_array_add_uint16 "prop_array_t dict" "uint16_t val"
146*6b6d114aSBen Gras.Ft bool
147*6b6d114aSBen Gras.Fn prop_array_add_int32 "prop_array_t dict" "int32_t val"
148*6b6d114aSBen Gras.Ft bool
149*6b6d114aSBen Gras.Fn prop_array_add_uint32 "prop_array_t dict" "uint32_t val"
150*6b6d114aSBen Gras.Ft bool
151*6b6d114aSBen Gras.Fn prop_array_add_int64 "prop_array_t dict"  "int64_t val"
152*6b6d114aSBen Gras.Ft bool
153*6b6d114aSBen Gras.Fn prop_array_add_uint64 "prop_array_t dict" "uint64_t val"
154*6b6d114aSBen Gras.\"
155*6b6d114aSBen Gras.Ft bool
156*6b6d114aSBen Gras.Fn prop_array_get_cstring "prop_array_t dict" "unsigned int indx" \
157*6b6d114aSBen Gras    "char **strp"
158*6b6d114aSBen Gras.Ft bool
159*6b6d114aSBen Gras.Fn prop_array_set_cstring "prop_array_t dict" "unsigned int indx" \
160*6b6d114aSBen Gras    "const char *str"
161*6b6d114aSBen Gras.\"
162*6b6d114aSBen Gras.Ft bool
163*6b6d114aSBen Gras.Fn prop_array_get_cstring_nocopy "prop_array_t dict" \
164*6b6d114aSBen Gras    "unsigned int indx" "const char **strp"
165*6b6d114aSBen Gras.Ft bool
166*6b6d114aSBen Gras.Fn prop_array_set_cstring_nocopy "prop_array_t dict" \
167*6b6d114aSBen Gras    "unsigned int indx" "const char *strp"
168*6b6d114aSBen Gras.Ft bool
169*6b6d114aSBen Gras.Fn prop_array_add_and_rel "prop_array_t dict" \
170*6b6d114aSBen Gras    "prop_object_t obj"
171*6b6d114aSBen Gras.Sh DESCRIPTION
172*6b6d114aSBen GrasThe
173*6b6d114aSBen Gras.Nm prop_array_util
174*6b6d114aSBen Grasfamily of functions are provided to make getting and setting values in
175*6b6d114aSBen Grasarrays more convenient in some applications.
176*6b6d114aSBen Gras.Pp
177*6b6d114aSBen GrasThe getters check the type of the returned object and, in some cases, also
178*6b6d114aSBen Grasensure that the returned value is within the range implied by the getter's
179*6b6d114aSBen Grasvalue type.
180*6b6d114aSBen Gras.Pp
181*6b6d114aSBen GrasThe setters handle object creation and release for the caller.
182*6b6d114aSBen Gras.Pp
183*6b6d114aSBen GrasThe
184*6b6d114aSBen Gras.Fn prop_array_get_cstring
185*6b6d114aSBen Grasfunction returns dynamically allocated memory.
186*6b6d114aSBen GrasSee
187*6b6d114aSBen Gras.Xr prop_string 3
188*6b6d114aSBen Grasfor more information.
189*6b6d114aSBen Gras.Pp
190*6b6d114aSBen GrasThe
191*6b6d114aSBen Gras.Fn prop_array_get_cstring_nocopy
192*6b6d114aSBen Grasand
193*6b6d114aSBen Gras.Fn prop_array_set_cstring_nocopy
194*6b6d114aSBen Grasfunctions do not copy the string that is set or returned.
195*6b6d114aSBen GrasSee
196*6b6d114aSBen Gras.Xr prop_string 3
197*6b6d114aSBen Grasfor more information.
198*6b6d114aSBen Gras.Pp
199*6b6d114aSBen GrasThe
200*6b6d114aSBen Gras.Fn prop_array_add_and_rel
201*6b6d114aSBen Grasfunction adds the object to the end of the array and releases it.
202*6b6d114aSBen GrasThe object is also released on failure.
203*6b6d114aSBen Gras.Sh RETURN VALUES
204*6b6d114aSBen GrasThe
205*6b6d114aSBen Gras.Nm prop_array_util
206*6b6d114aSBen Grasgetter functions return
207*6b6d114aSBen Gras.Dv true
208*6b6d114aSBen Grasif the object exists in the array and the value is in-range, or
209*6b6d114aSBen Gras.Dv false
210*6b6d114aSBen Grasotherwise.
211*6b6d114aSBen Gras.Pp
212*6b6d114aSBen GrasThe
213*6b6d114aSBen Gras.Nm prop_array_util
214*6b6d114aSBen Grassetter functions return
215*6b6d114aSBen Gras.Dv true
216*6b6d114aSBen Grasif creating the object and storing it in the array is successful, or
217*6b6d114aSBen Gras.Dv false
218*6b6d114aSBen Grasotherwise.
219*6b6d114aSBen Gras.Sh SEE ALSO
220*6b6d114aSBen Gras.Xr prop_array 3 ,
221*6b6d114aSBen Gras.Xr prop_bool 3 ,
222*6b6d114aSBen Gras.Xr prop_number 3 ,
223*6b6d114aSBen Gras.Xr proplib 3
224*6b6d114aSBen Gras.Sh HISTORY
225*6b6d114aSBen GrasThe
226*6b6d114aSBen Gras.Nm proplib
227*6b6d114aSBen Grasproperty container object library first appeared in
228*6b6d114aSBen Gras.Nx 4.0 .
229