xref: /minix3/common/lib/libprop/prop_string.3 (revision 6b6d114a21a24bee45291fa4af8899e108396c4a)
1*6b6d114aSBen Gras.\"	$NetBSD: prop_string.3,v 1.8 2011/02/26 12:56:36 wiz Exp $
2*6b6d114aSBen Gras.\"
3*6b6d114aSBen Gras.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
4*6b6d114aSBen Gras.\" All rights reserved.
5*6b6d114aSBen Gras.\"
6*6b6d114aSBen Gras.\" This code is derived from software contributed to The NetBSD Foundation
7*6b6d114aSBen Gras.\" by Jason R. Thorpe.
8*6b6d114aSBen Gras.\"
9*6b6d114aSBen Gras.\" Redistribution and use in source and binary forms, with or without
10*6b6d114aSBen Gras.\" modification, are permitted provided that the following conditions
11*6b6d114aSBen Gras.\" are met:
12*6b6d114aSBen Gras.\" 1. Redistributions of source code must retain the above copyright
13*6b6d114aSBen Gras.\" notice, this list of conditions and the following disclaimer.
14*6b6d114aSBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
15*6b6d114aSBen Gras.\" notice, this list of conditions and the following disclaimer in the
16*6b6d114aSBen Gras.\" documentation and/or other materials provided with the distribution.
17*6b6d114aSBen Gras.\"
18*6b6d114aSBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19*6b6d114aSBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20*6b6d114aSBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21*6b6d114aSBen Gras.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22*6b6d114aSBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23*6b6d114aSBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24*6b6d114aSBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25*6b6d114aSBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26*6b6d114aSBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27*6b6d114aSBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28*6b6d114aSBen Gras.\" POSSIBILITY OF SUCH DAMAGE.
29*6b6d114aSBen Gras.\"
30*6b6d114aSBen Gras.Dd January 21, 2008
31*6b6d114aSBen Gras.Dt PROP_STRING 3
32*6b6d114aSBen Gras.Os
33*6b6d114aSBen Gras.Sh NAME
34*6b6d114aSBen Gras.Nm prop_string ,
35*6b6d114aSBen Gras.Nm prop_string_create ,
36*6b6d114aSBen Gras.Nm prop_string_create_cstring ,
37*6b6d114aSBen Gras.Nm prop_string_create_cstring_nocopy ,
38*6b6d114aSBen Gras.Nm prop_string_copy ,
39*6b6d114aSBen Gras.Nm prop_string_copy_mutable ,
40*6b6d114aSBen Gras.Nm prop_string_size ,
41*6b6d114aSBen Gras.Nm prop_string_mutable ,
42*6b6d114aSBen Gras.Nm prop_string_cstring ,
43*6b6d114aSBen Gras.Nm prop_string_cstring_nocopy ,
44*6b6d114aSBen Gras.Nm prop_string_append ,
45*6b6d114aSBen Gras.Nm prop_string_append_cstring ,
46*6b6d114aSBen Gras.Nm prop_string_equals ,
47*6b6d114aSBen Gras.Nm prop_string_equals_cstring
48*6b6d114aSBen Gras.Nd string value property object
49*6b6d114aSBen Gras.Sh LIBRARY
50*6b6d114aSBen Gras.Lb libprop
51*6b6d114aSBen Gras.Sh SYNOPSIS
52*6b6d114aSBen Gras.In prop/proplib.h
53*6b6d114aSBen Gras.\"
54*6b6d114aSBen Gras.Ft prop_string_t
55*6b6d114aSBen Gras.Fn prop_string_create "void"
56*6b6d114aSBen Gras.Ft prop_string_t
57*6b6d114aSBen Gras.Fn prop_string_create_cstring "const char *cstring"
58*6b6d114aSBen Gras.Ft prop_string_t
59*6b6d114aSBen Gras.Fn prop_string_create_cstring_nocopy "const char *cstring"
60*6b6d114aSBen Gras.\"
61*6b6d114aSBen Gras.Ft prop_string_t
62*6b6d114aSBen Gras.Fn prop_string_copy "prop_string_t string"
63*6b6d114aSBen Gras.Ft prop_string_t
64*6b6d114aSBen Gras.Fn prop_string_copy_mutable "prop_string_t string"
65*6b6d114aSBen Gras.\"
66*6b6d114aSBen Gras.Ft size_t
67*6b6d114aSBen Gras.Fn prop_string_size "prop_string_t string"
68*6b6d114aSBen Gras.Ft bool
69*6b6d114aSBen Gras.Fn prop_string_mutable "prop_string_t string"
70*6b6d114aSBen Gras.\"
71*6b6d114aSBen Gras.Ft char *
72*6b6d114aSBen Gras.Fn prop_string_cstring "prop_string_t string"
73*6b6d114aSBen Gras.Ft const char *
74*6b6d114aSBen Gras.Fn prop_string_cstring_nocopy "prop_string_t string"
75*6b6d114aSBen Gras.\"
76*6b6d114aSBen Gras.Ft bool
77*6b6d114aSBen Gras.Fn prop_string_append "prop_string_t str1" "prop_string_t str2"
78*6b6d114aSBen Gras.Ft bool
79*6b6d114aSBen Gras.Fn prop_string_append_cstring "prop_string_t string" "const char *cstring"
80*6b6d114aSBen Gras.\"
81*6b6d114aSBen Gras.Ft bool
82*6b6d114aSBen Gras.Fn prop_string_equals "prop_string_t str1" "prop_string_t str2"
83*6b6d114aSBen Gras.Ft bool
84*6b6d114aSBen Gras.Fn prop_string_equals_cstring "prop_string_t string" "const char *cstring"
85*6b6d114aSBen Gras.Sh DESCRIPTION
86*6b6d114aSBen GrasThe
87*6b6d114aSBen Gras.Nm prop_string
88*6b6d114aSBen Grasfamily of functions operate on a string value property object type.
89*6b6d114aSBen Gras.Bl -tag -width "xxxxx"
90*6b6d114aSBen Gras.It Fn prop_string_create "void"
91*6b6d114aSBen GrasCreate an empty mutable string.
92*6b6d114aSBen GrasReturns
93*6b6d114aSBen Gras.Dv NULL
94*6b6d114aSBen Grason failure.
95*6b6d114aSBen Gras.It Fn prop_string_create_cstring "const char *cstring"
96*6b6d114aSBen GrasCreate a mutable string that contains a copy of
97*6b6d114aSBen Gras.Fa cstring .
98*6b6d114aSBen GrasReturns
99*6b6d114aSBen Gras.Dv NULL
100*6b6d114aSBen Grason failure.
101*6b6d114aSBen Gras.It Fn prop_string_create_cstring_nocopy "const char *cstring"
102*6b6d114aSBen GrasCreate an immutable string that contains a reference to
103*6b6d114aSBen Gras.Fa cstring .
104*6b6d114aSBen GrasReturns
105*6b6d114aSBen Gras.Dv NULL
106*6b6d114aSBen Grason failure.
107*6b6d114aSBen Gras.It Fn prop_string_copy "prop_string_t string"
108*6b6d114aSBen GrasCopy a string.
109*6b6d114aSBen GrasIf the string being copied is an immutable external C string reference,
110*6b6d114aSBen Grasthen the copy is also immutable and references the same external C string.
111*6b6d114aSBen GrasReturns
112*6b6d114aSBen Gras.Dv NULL
113*6b6d114aSBen Grason failure.
114*6b6d114aSBen Gras.It Fn prop_string_copy_mutable "prop_string_t string"
115*6b6d114aSBen GrasCopy a string, always creating a mutable copy.
116*6b6d114aSBen GrasReturns
117*6b6d114aSBen Gras.Dv NULL
118*6b6d114aSBen Grason failure.
119*6b6d114aSBen Gras.It Fn prop_string_size "prop_string_t string"
120*6b6d114aSBen GrasReturns the size of the string, not including the terminating NUL.
121*6b6d114aSBen GrasIf the supplied object isn't a string, zero is returned.
122*6b6d114aSBen Gras.It Fn prop_string_mutable "prop_string_t string"
123*6b6d114aSBen GrasReturns
124*6b6d114aSBen Gras.Dv true
125*6b6d114aSBen Grasif the string is mutable.
126*6b6d114aSBen GrasIf the supplied object isn't a string,
127*6b6d114aSBen Gras.Dv false
128*6b6d114aSBen Grasis returned.
129*6b6d114aSBen Gras.It Fn prop_string_cstring "prop_string_t string"
130*6b6d114aSBen GrasReturns a copy of the string's contents as a C string.
131*6b6d114aSBen GrasThe caller is responsible for freeing the returned buffer.
132*6b6d114aSBen Gras.Pp
133*6b6d114aSBen GrasIn user space, the buffer is allocated using
134*6b6d114aSBen Gras.Xr malloc 3 .
135*6b6d114aSBen GrasIn the kernel, the buffer is allocated using
136*6b6d114aSBen Gras.Xr malloc 9
137*6b6d114aSBen Grasusing the malloc type
138*6b6d114aSBen Gras.Dv M_TEMP .
139*6b6d114aSBen Gras.Pp
140*6b6d114aSBen GrasReturns
141*6b6d114aSBen Gras.Dv NULL
142*6b6d114aSBen Grason failure.
143*6b6d114aSBen Gras.It Fn prop_string_cstring_nocopy "prop_string_t string"
144*6b6d114aSBen GrasReturns an immutable reference to the contents of the string as a
145*6b6d114aSBen GrasC string.
146*6b6d114aSBen GrasIf the supplied object isn't a string,
147*6b6d114aSBen Gras.Dv NULL
148*6b6d114aSBen Grasis returned.
149*6b6d114aSBen Gras.It Fn prop_string_append "prop_string_t str1" "prop_string_t str2"
150*6b6d114aSBen GrasAppend the contents of
151*6b6d114aSBen Gras.Fa str2
152*6b6d114aSBen Grasto
153*6b6d114aSBen Gras.Fa str1 ,
154*6b6d114aSBen Graswhich must be mutable.
155*6b6d114aSBen GrasReturns
156*6b6d114aSBen Gras.Dv true
157*6b6d114aSBen Grasupon success and
158*6b6d114aSBen Gras.Dv false
159*6b6d114aSBen Grasotherwise.
160*6b6d114aSBen Gras.It Fn prop_string_append_cstring "prop_string_t string" "const char *cstring"
161*6b6d114aSBen GrasAppend the C string
162*6b6d114aSBen Gras.Fa cstring
163*6b6d114aSBen Grasto
164*6b6d114aSBen Gras.Fa string ,
165*6b6d114aSBen Graswhich must be mutable.
166*6b6d114aSBen GrasReturns
167*6b6d114aSBen Gras.Dv true
168*6b6d114aSBen Grasupon success and
169*6b6d114aSBen Gras.Dv false
170*6b6d114aSBen Grasotherwise.
171*6b6d114aSBen Gras.It Fn prop_string_equals "prop_string_t str1" "prop_string_t str2"
172*6b6d114aSBen GrasReturns
173*6b6d114aSBen Gras.Dv true
174*6b6d114aSBen Grasif the two string objects are equivalent.
175*6b6d114aSBen Gras.It Fn prop_string_equals_cstring "prop_string_t string" "const char *cstring"
176*6b6d114aSBen GrasReturns
177*6b6d114aSBen Gras.Dv true
178*6b6d114aSBen Grasif the string's value is equivalent to
179*6b6d114aSBen Gras.Fa cstring .
180*6b6d114aSBen Gras.El
181*6b6d114aSBen Gras.Sh SEE ALSO
182*6b6d114aSBen Gras.Xr prop_array 3 ,
183*6b6d114aSBen Gras.Xr prop_bool 3 ,
184*6b6d114aSBen Gras.Xr prop_data 3 ,
185*6b6d114aSBen Gras.Xr prop_dictionary 3 ,
186*6b6d114aSBen Gras.Xr prop_number 3 ,
187*6b6d114aSBen Gras.Xr prop_object 3 ,
188*6b6d114aSBen Gras.Xr proplib 3
189*6b6d114aSBen Gras.Sh HISTORY
190*6b6d114aSBen GrasThe
191*6b6d114aSBen Gras.Nm proplib
192*6b6d114aSBen Grasproperty container object library first appeared in
193*6b6d114aSBen Gras.Nx 4.0 .
194