1.\" $NetBSD: proplib.3,v 1.4 2007/06/21 12:02:31 xtraeme 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.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd June 21, 2007 38.Dt PROPLIB 3 39.Os 40.Sh NAME 41.Nm proplib 42.Nd property container object library 43.Sh LIBRARY 44.Lb libprop 45.Sh SYNOPSIS 46.In prop/proplib.h 47.Sh DESCRIPTION 48The 49.Nm 50library provides an abstract interface for creating and manipulating 51property lists. 52Property lists have object types for boolean values, opaque data, numbers, 53and strings. 54Structure is provided by the array and dictionary collection types. 55.Pp 56Property lists can be passed across protection boundaries by translating 57them to an external representation. 58This external representation is an XML document whose format is described 59by the following DTD: 60.Bd -literal -offset indent 61http://www.apple.com/DTDs/PropertyList-1.0.dtd 62.Ed 63.Pp 64Property container objects are reference counted. 65When an object is created, its reference count is set to 1. 66Any code that keeps a reference to an object, including the collection 67types 68.Pq arrays and dictionaries , 69must 70.Dq retain 71the object 72.Pq increment its reference count . 73When that reference is dropped, the object must be 74.Dq released 75.Pq reference count decremented . 76When an object's reference count drops to 0, it is automatically freed. 77.Pp 78The rules for managing reference counts are very simple: 79.Bl -bullet 80.It 81If you create an object and do not explicitly maintain a reference to it, 82you must release it. 83.It 84If you get a reference to an object from other code and wish to maintain 85a reference to it, you must retain the object. You are responsible for 86releasing the object once you drop that reference. 87.It 88You must never release an object unless you create it or retain it. 89.El 90.Pp 91Object collections may be iterated by creating a special iterator object. 92Iterator objects are special; they may not be retained, and they are 93released using an iterator-specific release function. 94.Sh SEE ALSO 95.Xr prop_array 3 , 96.Xr prop_bool 3 , 97.Xr prop_data 3 , 98.Xr prop_dictionary 3 , 99.Xr prop_dictionary_util 3 , 100.Xr prop_number 3 , 101.Xr prop_object 3 , 102.Xr prop_send_ioctl 3 , 103.Xr prop_string 3 104.Sh HISTORY 105The 106.Nm 107property container object library first appeared in 108.Nx 4.0 . 109.Sh CAVEATS 110.Nm 111does not have a 112.Sq date 113object type, and thus will not parse 114.Sq date 115elements from an Apple XML property list. 116.Pp 117The 118.Nm 119.Sq number 120object type differs from the Apple XML property list format in the following 121ways: 122.Bl -bullet 123.It 124The external representation is in base 16, not base 10. 125.Nm 126is able to parse base 8, base 10, and base 16 127.Sq integer 128elements. 129.It 130Internally, integers are always stored as unsigned numbers 131.Pq uint64_t . 132Therefore, the external representation will never be negative. 133.It 134Because floating point numbers are not supported, 135.Sq real 136elements from an Apple XML property list will not be parsed. 137.El 138.Pp 139In order to facilitate use of 140.Nm 141in kernel, standalone, and user space environments, the 142.Nm 143parser is not a real XML parser. 144It is hard-coded to parse only the property list external representation. 145