1*f14fb602SLionel Sambuc.\" $NetBSD: proplib.3,v 1.8 2012/03/15 22:35:02 njoly Exp $ 26b6d114aSBen Gras.\" 36b6d114aSBen Gras.\" Copyright (c) 2006 The NetBSD Foundation, Inc. 46b6d114aSBen Gras.\" All rights reserved. 56b6d114aSBen Gras.\" 66b6d114aSBen Gras.\" This code is derived from software contributed to The NetBSD Foundation 76b6d114aSBen Gras.\" by Jason R. Thorpe. 86b6d114aSBen Gras.\" 96b6d114aSBen Gras.\" Redistribution and use in source and binary forms, with or without 106b6d114aSBen Gras.\" modification, are permitted provided that the following conditions 116b6d114aSBen Gras.\" are met: 126b6d114aSBen Gras.\" 1. Redistributions of source code must retain the above copyright 136b6d114aSBen Gras.\" notice, this list of conditions and the following disclaimer. 146b6d114aSBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 156b6d114aSBen Gras.\" notice, this list of conditions and the following disclaimer in the 166b6d114aSBen Gras.\" documentation and/or other materials provided with the distribution. 176b6d114aSBen Gras.\" 186b6d114aSBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 196b6d114aSBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 206b6d114aSBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 216b6d114aSBen Gras.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 226b6d114aSBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 236b6d114aSBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 246b6d114aSBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 256b6d114aSBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 266b6d114aSBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 276b6d114aSBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 286b6d114aSBen Gras.\" POSSIBILITY OF SUCH DAMAGE. 296b6d114aSBen Gras.\" 306b6d114aSBen Gras.Dd January 17, 2011 316b6d114aSBen Gras.Dt PROPLIB 3 326b6d114aSBen Gras.Os 336b6d114aSBen Gras.Sh NAME 346b6d114aSBen Gras.Nm proplib 356b6d114aSBen Gras.Nd property container object library 366b6d114aSBen Gras.Sh LIBRARY 376b6d114aSBen Gras.Lb libprop 386b6d114aSBen Gras.Sh SYNOPSIS 396b6d114aSBen Gras.In prop/proplib.h 406b6d114aSBen Gras.Sh DESCRIPTION 416b6d114aSBen GrasThe 426b6d114aSBen Gras.Nm 436b6d114aSBen Graslibrary provides an abstract interface for creating and manipulating 446b6d114aSBen Grasproperty lists. 456b6d114aSBen GrasProperty lists have object types for boolean values, opaque data, numbers, 466b6d114aSBen Grasand strings. 476b6d114aSBen GrasStructure is provided by the array and dictionary collection types. 486b6d114aSBen Gras.Pp 496b6d114aSBen GrasProperty lists can be passed across protection boundaries by translating 506b6d114aSBen Grasthem to an external representation. 516b6d114aSBen GrasThis external representation is an XML document whose format is described 526b6d114aSBen Grasby the following DTD: 536b6d114aSBen Gras.Bd -literal -offset indent 54*f14fb602SLionel Sambuc.Lk http://www.apple.com/DTDs/PropertyList-1.0.dtd 556b6d114aSBen Gras.Ed 566b6d114aSBen Gras.Pp 576b6d114aSBen GrasProperty container objects are reference counted. 586b6d114aSBen GrasWhen an object is created, its reference count is set to 1. 596b6d114aSBen GrasAny code that keeps a reference to an object, including the collection 606b6d114aSBen Grastypes 616b6d114aSBen Gras.Pq arrays and dictionaries , 626b6d114aSBen Grasmust 636b6d114aSBen Gras.Dq retain 646b6d114aSBen Grasthe object 656b6d114aSBen Gras.Pq increment its reference count . 666b6d114aSBen GrasWhen that reference is dropped, the object must be 676b6d114aSBen Gras.Dq released 686b6d114aSBen Gras.Pq reference count decremented . 696b6d114aSBen GrasWhen an object's reference count drops to 0, it is automatically freed. 706b6d114aSBen Gras.Pp 716b6d114aSBen GrasThe rules for managing reference counts are very simple: 726b6d114aSBen Gras.Bl -bullet 736b6d114aSBen Gras.It 746b6d114aSBen GrasIf you create an object and do not explicitly maintain a reference to it, 756b6d114aSBen Grasyou must release it. 766b6d114aSBen Gras.It 776b6d114aSBen GrasIf you get a reference to an object from other code and wish to maintain 786b6d114aSBen Grasa reference to it, you must retain the object. 796b6d114aSBen GrasYou are responsible for 806b6d114aSBen Grasreleasing the object once you drop that reference. 816b6d114aSBen Gras.It 826b6d114aSBen GrasYou must never release an object unless you create it or retain it. 836b6d114aSBen Gras.El 846b6d114aSBen Gras.Pp 856b6d114aSBen GrasObject collections may be iterated by creating a special iterator object. 866b6d114aSBen GrasIterator objects are special; they may not be retained, and they are 876b6d114aSBen Grasreleased using an iterator-specific release function. 886b6d114aSBen Gras.Sh SEE ALSO 896b6d114aSBen Gras.Xr prop_array 3 , 906b6d114aSBen Gras.Xr prop_bool 3 , 916b6d114aSBen Gras.Xr prop_data 3 , 926b6d114aSBen Gras.Xr prop_dictionary 3 , 936b6d114aSBen Gras.Xr prop_dictionary_util 3 , 946b6d114aSBen Gras.Xr prop_number 3 , 956b6d114aSBen Gras.Xr prop_object 3 , 966b6d114aSBen Gras.Xr prop_send_ioctl 3 , 976b6d114aSBen Gras.Xr prop_send_syscall 3 , 986b6d114aSBen Gras.Xr prop_string 3 996b6d114aSBen Gras.Sh HISTORY 1006b6d114aSBen GrasThe 1016b6d114aSBen Gras.Nm 1026b6d114aSBen Grasproperty container object library first appeared in 1036b6d114aSBen Gras.Nx 4.0 . 1046b6d114aSBen Gras.Sh CAVEATS 1056b6d114aSBen Gras.Nm 1066b6d114aSBen Grasdoes not have a 1076b6d114aSBen Gras.Sq date 1086b6d114aSBen Grasobject type, and thus will not parse 1096b6d114aSBen Gras.Sq date 1106b6d114aSBen Graselements from an Apple XML property list. 1116b6d114aSBen Gras.Pp 1126b6d114aSBen GrasThe 1136b6d114aSBen Gras.Nm 1146b6d114aSBen Gras.Sq number 1156b6d114aSBen Grasobject type differs from the Apple XML property list format in the following 1166b6d114aSBen Grasways: 1176b6d114aSBen Gras.Bl -bullet 1186b6d114aSBen Gras.It 1196b6d114aSBen GrasThe external representation is in base 16, not base 10. 1206b6d114aSBen Gras.Nm 1216b6d114aSBen Grasis able to parse base 8, base 10, and base 16 1226b6d114aSBen Gras.Sq integer 1236b6d114aSBen Graselements. 1246b6d114aSBen Gras.It 1256b6d114aSBen GrasInternally, integers are always stored as unsigned numbers 1266b6d114aSBen Gras.Pq uint64_t . 1276b6d114aSBen GrasTherefore, the external representation will never be negative. 1286b6d114aSBen Gras.It 1296b6d114aSBen GrasBecause floating point numbers are not supported, 1306b6d114aSBen Gras.Sq real 1316b6d114aSBen Graselements from an Apple XML property list will not be parsed. 1326b6d114aSBen Gras.El 1336b6d114aSBen Gras.Pp 1346b6d114aSBen GrasIn order to facilitate use of 1356b6d114aSBen Gras.Nm 1366b6d114aSBen Grasin kernel, standalone, and user space environments, the 1376b6d114aSBen Gras.Nm 1386b6d114aSBen Grasparser is not a real XML parser. 1396b6d114aSBen GrasIt is hard-coded to parse only the property list external representation. 140