mdoc.local: Indent with spaces like everywhere else.
[dragonfly.git] / common / lib / libprop / proplib.3
1 .\"     $NetBSD: proplib.3,v 1.6 2009/05/13 22:31:59 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 June 21, 2007
31 .Dt PROPLIB 3
32 .Os
33 .Sh NAME
34 .Nm proplib
35 .Nd property container object library
36 .Sh LIBRARY
37 .Lb libprop
38 .Sh SYNOPSIS
39 .In prop/proplib.h
40 .Sh DESCRIPTION
41 The
42 .Nm
43 library provides an abstract interface for creating and manipulating
44 property lists.
45 Property lists have object types for boolean values, opaque data, numbers,
46 and strings.
47 Structure is provided by the array and dictionary collection types.
48 .Pp
49 Property lists can be passed across protection boundaries by translating
50 them to an external representation.
51 This external representation is an XML document whose format is described
52 by the following DTD:
53 .Bd -literal -offset indent
54 http://www.apple.com/DTDs/PropertyList-1.0.dtd
55 .Ed
56 .Pp
57 Property container objects are reference counted.
58 When an object is created, its reference count is set to 1.
59 Any code that keeps a reference to an object, including the collection
60 types
61 .Pq arrays and dictionaries ,
62 must
63 .Dq retain
64 the object
65 .Pq increment its reference count .
66 When that reference is dropped, the object must be
67 .Dq released
68 .Pq reference count decremented .
69 When an object's reference count drops to 0, it is automatically freed.
70 .Pp
71 The rules for managing reference counts are very simple:
72 .Bl -bullet
73 .It
74 If you create an object and do not explicitly maintain a reference to it,
75 you must release it.
76 .It
77 If you get a reference to an object from other code and wish to maintain
78 a reference to it, you must retain the object.
79 You are responsible for
80 releasing the object once you drop that reference.
81 .It
82 You must never release an object unless you create it or retain it.
83 .El
84 .Pp
85 Object collections may be iterated by creating a special iterator object.
86 Iterator objects are special; they may not be retained, and they are
87 released using an iterator-specific release function.
88 .Sh SEE ALSO
89 .Xr prop_array 3 ,
90 .Xr prop_bool 3 ,
91 .Xr prop_data 3 ,
92 .Xr prop_dictionary 3 ,
93 .Xr prop_dictionary_util 3 ,
94 .Xr prop_number 3 ,
95 .Xr prop_object 3 ,
96 .Xr prop_send_ioctl 3 ,
97 .Xr prop_string 3
98 .Sh HISTORY
99 The
100 .Nm
101 property container object library first appeared in
102 .Nx 4.0 .
103 .Sh CAVEATS
104 .Nm
105 does not have a
106 .Sq date
107 object type, and thus will not parse
108 .Sq date
109 elements from an Apple XML property list.
110 .Pp
111 The
112 .Nm
113 .Sq number
114 object type differs from the Apple XML property list format in the following
115 ways:
116 .Bl -bullet
117 .It
118 The external representation is in base 16, not base 10.
119 .Nm
120 is able to parse base 8, base 10, and base 16
121 .Sq integer
122 elements.
123 .It
124 Internally, integers are always stored as unsigned numbers
125 .Pq uint64_t .
126 Therefore, the external representation will never be negative.
127 .It
128 Because floating point numbers are not supported,
129 .Sq real
130 elements from an Apple XML property list will not be parsed.
131 .El
132 .Pp
133 In order to facilitate use of
134 .Nm
135 in kernel, standalone, and user space environments, the
136 .Nm
137 parser is not a real XML parser.
138 It is hard-coded to parse only the property list external representation.