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