1.\" $NetBSD: prop_array_util.3,v 1.7 2011/10/17 09:24:54 wiz 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.Nd array property collection object utility functions 67.Sh LIBRARY 68.Lb libprop 69.Sh SYNOPSIS 70.In libprop/proplib.h 71.\" 72.Ft bool 73.Fn prop_array_get_bool "prop_array_t dict" "unsigned int indx" \ 74 "bool *valp" 75.Ft bool 76.Fn prop_array_set_bool "prop_array_t dict" "unsigned int indx" \ 77 "bool val" 78.\" 79.Ft bool 80.Fn prop_array_get_int8 "prop_array_t dict" "unsigned int indx" \ 81 "int8_t *valp" 82.Ft bool 83.Fn prop_array_get_uint8 "prop_array_t dict" "unsigned int indx" \ 84 "uint8_t *valp" 85.Ft bool 86.Fn prop_array_set_int8 "prop_array_t dict" "unsigned int indx" \ 87 "int8_t val" 88.Ft bool 89.Fn prop_array_set_uint8 "prop_array_t dict" "unsigned int indx" \ 90 "uint8_t val" 91.\" 92.Ft bool 93.Fn prop_array_get_int16 "prop_array_t dict" "unsigned int indx" \ 94 "int16_t *valp" 95.Ft bool 96.Fn prop_array_get_uint16 "prop_array_t dict" "unsigned int indx" \ 97 "uint16_t *valp" 98.Ft bool 99.Fn prop_array_set_int16 "prop_array_t dict" "unsigned int indx" \ 100 "int16_t val" 101.Ft bool 102.Fn prop_array_set_uint16 "prop_array_t dict" "unsigned int indx" \ 103 "uint16_t val" 104.\" 105.Ft bool 106.Fn prop_array_get_int32 "prop_array_t dict" "unsigned int indx" \ 107 "int32_t *valp" 108.Ft bool 109.Fn prop_array_get_uint32 "prop_array_t dict" "unsigned int indx" \ 110 "uint32_t *valp" 111.Ft bool 112.Fn prop_array_set_int32 "prop_array_t dict" "unsigned int indx" \ 113 "int32_t val" 114.Ft bool 115.Fn prop_array_set_uint32 "prop_array_t dict" "unsigned int indx" \ 116 "uint32_t val" 117.\" 118.Ft bool 119.Fn prop_array_get_int64 "prop_array_t dict" "unsigned int indx" \ 120 "int64_t *valp" 121.Ft bool 122.Fn prop_array_get_uint64 "prop_array_t dict" "unsigned int indx" \ 123 "uint64_t *valp" 124.Ft bool 125.Fn prop_array_set_int64 "prop_array_t dict" "unsigned int indx" \ 126 "int64_t val" 127.Ft bool 128.Fn prop_array_set_uint64 "prop_array_t dict" "unsigned int indx" \ 129 "uint64_t val" 130.\" 131.Ft bool 132.Fn prop_array_set_int32 "prop_array_t dict" "unsigned int indx" \ 133 "int32_t val" 134.Ft bool 135.Fn prop_array_set_uint32 "prop_array_t dict" "unsigned int indx" \ 136 "uint32_t val" 137.\" 138.Ft bool 139.Fn prop_array_add_int8 "prop_array_t dict" "int8_t val" 140.Ft bool 141.Fn prop_array_add_uint8 "prop_array_t dict" "uint8_t val" 142.Ft bool 143.Fn prop_array_add_int16 "prop_array_t dict" "int16_t val" 144.Ft bool 145.Fn prop_array_add_uint16 "prop_array_t dict" "uint16_t val" 146.Ft bool 147.Fn prop_array_add_int32 "prop_array_t dict" "int32_t val" 148.Ft bool 149.Fn prop_array_add_uint32 "prop_array_t dict" "uint32_t val" 150.Ft bool 151.Fn prop_array_add_int64 "prop_array_t dict" "int64_t val" 152.Ft bool 153.Fn prop_array_add_uint64 "prop_array_t dict" "uint64_t val" 154.\" 155.Ft bool 156.Fn prop_array_get_cstring "prop_array_t dict" "unsigned int indx" \ 157 "char **strp" 158.Ft bool 159.Fn prop_array_set_cstring "prop_array_t dict" "unsigned int indx" \ 160 "const char *str" 161.\" 162.Ft bool 163.Fn prop_array_get_cstring_nocopy "prop_array_t dict" \ 164 "unsigned int indx" "const char **strp" 165.Ft bool 166.Fn prop_array_set_cstring_nocopy "prop_array_t dict" \ 167 "unsigned int indx" "const char *strp" 168.Ft bool 169.Fn prop_array_add_and_rel "prop_array_t dict" \ 170 "prop_object_t obj" 171.Sh DESCRIPTION 172The 173.Nm prop_array_util 174family of functions are provided to make getting and setting values in 175arrays more convenient in some applications. 176.Pp 177The getters check the type of the returned object and, in some cases, also 178ensure that the returned value is within the range implied by the getter's 179value type. 180.Pp 181The setters handle object creation and release for the caller. 182.Pp 183The 184.Fn prop_array_get_cstring 185function returns dynamically allocated memory. 186See 187.Xr prop_string 3 188for more information. 189.Pp 190The 191.Fn prop_array_get_cstring_nocopy 192and 193.Fn prop_array_set_cstring_nocopy 194functions do not copy the string that is set or returned. 195See 196.Xr prop_string 3 197for more information. 198.Pp 199The 200.Fn prop_array_add_and_rel 201function adds the object to the end of the array and releases it. 202The object is also released on failure. 203.Sh RETURN VALUES 204The 205.Nm prop_array_util 206getter functions return 207.Dv true 208if the object exists in the array and the value is in-range, or 209.Dv false 210otherwise. 211.Pp 212The 213.Nm prop_array_util 214setter functions return 215.Dv true 216if creating the object and storing it in the array is successful, or 217.Dv false 218otherwise. 219.Sh SEE ALSO 220.Xr prop_array 3 , 221.Xr prop_bool 3 , 222.Xr prop_number 3 , 223.Xr proplib 3 224.Sh HISTORY 225The 226.Nm proplib 227property container object library first appeared in 228.Nx 4.0 . 229