xref: /netbsd-src/common/lib/libprop/proplib.3 (revision a792b8435ef0aa524ea0324495e533001a8cb8e6)
1*a792b843Sthorpej.\"	$NetBSD: proplib.3,v 1.9 2020/06/06 21:25:59 thorpej Exp $
2774eb1a3Sthorpej.\"
3774eb1a3Sthorpej.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
4774eb1a3Sthorpej.\" All rights reserved.
5774eb1a3Sthorpej.\"
6774eb1a3Sthorpej.\" This code is derived from software contributed to The NetBSD Foundation
7774eb1a3Sthorpej.\" by Jason R. Thorpe.
8774eb1a3Sthorpej.\"
9774eb1a3Sthorpej.\" Redistribution and use in source and binary forms, with or without
10774eb1a3Sthorpej.\" modification, are permitted provided that the following conditions
11774eb1a3Sthorpej.\" are met:
12774eb1a3Sthorpej.\" 1. Redistributions of source code must retain the above copyright
13774eb1a3Sthorpej.\" notice, this list of conditions and the following disclaimer.
14774eb1a3Sthorpej.\" 2. Redistributions in binary form must reproduce the above copyright
15774eb1a3Sthorpej.\" notice, this list of conditions and the following disclaimer in the
16774eb1a3Sthorpej.\" documentation and/or other materials provided with the distribution.
17774eb1a3Sthorpej.\"
18774eb1a3Sthorpej.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19774eb1a3Sthorpej.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20774eb1a3Sthorpej.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21774eb1a3Sthorpej.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22774eb1a3Sthorpej.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23774eb1a3Sthorpej.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24774eb1a3Sthorpej.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25774eb1a3Sthorpej.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26774eb1a3Sthorpej.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27774eb1a3Sthorpej.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28774eb1a3Sthorpej.\" POSSIBILITY OF SUCH DAMAGE.
29774eb1a3Sthorpej.\"
30*a792b843Sthorpej.Dd June 2, 2020
31774eb1a3Sthorpej.Dt PROPLIB 3
32774eb1a3Sthorpej.Os
33774eb1a3Sthorpej.Sh NAME
34774eb1a3Sthorpej.Nm proplib
35774eb1a3Sthorpej.Nd property container object library
36774eb1a3Sthorpej.Sh LIBRARY
37774eb1a3Sthorpej.Lb libprop
38774eb1a3Sthorpej.Sh SYNOPSIS
39774eb1a3Sthorpej.In prop/proplib.h
40774eb1a3Sthorpej.Sh DESCRIPTION
41774eb1a3SthorpejThe
42774eb1a3Sthorpej.Nm
43774eb1a3Sthorpejlibrary provides an abstract interface for creating and manipulating
44774eb1a3Sthorpejproperty lists.
45774eb1a3SthorpejProperty lists have object types for boolean values, opaque data, numbers,
46774eb1a3Sthorpejand strings.
47774eb1a3SthorpejStructure is provided by the array and dictionary collection types.
48774eb1a3Sthorpej.Pp
49774eb1a3SthorpejProperty lists can be passed across protection boundaries by translating
50774eb1a3Sthorpejthem to an external representation.
51774eb1a3SthorpejThis external representation is an XML document whose format is described
52774eb1a3Sthorpejby the following DTD:
53774eb1a3Sthorpej.Bd -literal -offset indent
54d0e00679Snjoly.Lk http://www.apple.com/DTDs/PropertyList-1.0.dtd
55774eb1a3Sthorpej.Ed
56774eb1a3Sthorpej.Pp
57774eb1a3SthorpejProperty container objects are reference counted.
58774eb1a3SthorpejWhen an object is created, its reference count is set to 1.
59774eb1a3SthorpejAny code that keeps a reference to an object, including the collection
60774eb1a3Sthorpejtypes
61774eb1a3Sthorpej.Pq arrays and dictionaries ,
62774eb1a3Sthorpejmust
63774eb1a3Sthorpej.Dq retain
64774eb1a3Sthorpejthe object
65774eb1a3Sthorpej.Pq increment its reference count .
66774eb1a3SthorpejWhen that reference is dropped, the object must be
67774eb1a3Sthorpej.Dq released
68774eb1a3Sthorpej.Pq reference count decremented .
69774eb1a3SthorpejWhen an object's reference count drops to 0, it is automatically freed.
70774eb1a3Sthorpej.Pp
71774eb1a3SthorpejThe rules for managing reference counts are very simple:
72774eb1a3Sthorpej.Bl -bullet
73774eb1a3Sthorpej.It
74774eb1a3SthorpejIf you create an object and do not explicitly maintain a reference to it,
75774eb1a3Sthorpejyou must release it.
76774eb1a3Sthorpej.It
77774eb1a3SthorpejIf you get a reference to an object from other code and wish to maintain
78e923b399Swiza reference to it, you must retain the object.
79e923b399SwizYou are responsible for
80774eb1a3Sthorpejreleasing the object once you drop that reference.
81774eb1a3Sthorpej.It
82774eb1a3SthorpejYou must never release an object unless you create it or retain it.
83774eb1a3Sthorpej.El
84774eb1a3Sthorpej.Pp
85774eb1a3SthorpejObject collections may be iterated by creating a special iterator object.
86774eb1a3SthorpejIterator objects are special; they may not be retained, and they are
87774eb1a3Sthorpejreleased using an iterator-specific release function.
88774eb1a3Sthorpej.Sh SEE ALSO
89774eb1a3Sthorpej.Xr prop_array 3 ,
90*a792b843Sthorpej.Xr prop_array_util 3 ,
91774eb1a3Sthorpej.Xr prop_bool 3 ,
92774eb1a3Sthorpej.Xr prop_data 3 ,
93774eb1a3Sthorpej.Xr prop_dictionary 3 ,
945386acb4Sxtraeme.Xr prop_dictionary_util 3 ,
95774eb1a3Sthorpej.Xr prop_number 3 ,
96774eb1a3Sthorpej.Xr prop_object 3 ,
975386acb4Sxtraeme.Xr prop_send_ioctl 3 ,
9807247bb7Sbouyer.Xr prop_send_syscall 3 ,
99774eb1a3Sthorpej.Xr prop_string 3
100774eb1a3Sthorpej.Sh HISTORY
101774eb1a3SthorpejThe
102774eb1a3Sthorpej.Nm
103774eb1a3Sthorpejproperty container object library first appeared in
104774eb1a3Sthorpej.Nx 4.0 .
105774eb1a3Sthorpej.Sh CAVEATS
106774eb1a3Sthorpej.Nm
107774eb1a3Sthorpejdoes not have a
108774eb1a3Sthorpej.Sq date
109774eb1a3Sthorpejobject type, and thus will not parse
110774eb1a3Sthorpej.Sq date
111774eb1a3Sthorpejelements from an Apple XML property list.
112774eb1a3Sthorpej.Pp
113774eb1a3SthorpejThe
114774eb1a3Sthorpej.Nm
115774eb1a3Sthorpej.Sq number
116774eb1a3Sthorpejobject type differs from the Apple XML property list format in the following
117774eb1a3Sthorpejways:
118774eb1a3Sthorpej.Bl -bullet
119774eb1a3Sthorpej.It
120774eb1a3SthorpejThe external representation is in base 16, not base 10.
121774eb1a3Sthorpej.Nm
122774eb1a3Sthorpejis able to parse base 8, base 10, and base 16
123774eb1a3Sthorpej.Sq integer
124774eb1a3Sthorpejelements.
125774eb1a3Sthorpej.It
126774eb1a3SthorpejInternally, integers are always stored as unsigned numbers
127*a792b843Sthorpej.Pq uintmax_t .
128774eb1a3SthorpejTherefore, the external representation will never be negative.
129774eb1a3Sthorpej.It
130774eb1a3SthorpejBecause floating point numbers are not supported,
131774eb1a3Sthorpej.Sq real
132774eb1a3Sthorpejelements from an Apple XML property list will not be parsed.
133774eb1a3Sthorpej.El
134774eb1a3Sthorpej.Pp
135774eb1a3SthorpejIn order to facilitate use of
136774eb1a3Sthorpej.Nm
137774eb1a3Sthorpejin kernel, standalone, and user space environments, the
138774eb1a3Sthorpej.Nm
139774eb1a3Sthorpejparser is not a real XML parser.
140774eb1a3SthorpejIt is hard-coded to parse only the property list external representation.
141