2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SCF_VALUE_CREATE 3SCF "May 28, 2009"
8 scf_value_create, scf_value_handle, scf_value_reset, scf_value_destroy,
9 scf_value_type, scf_value_base_type, scf_value_is_type, scf_type_base_type,
10 scf_value_get_boolean, scf_value_get_count, scf_value_get_integer,
11 scf_value_get_time, scf_value_get_astring, scf_value_get_ustring,
12 scf_value_get_opaque, scf_value_get_as_string, scf_value_get_as_string_typed,
13 scf_value_set_boolean, scf_value_set_count, scf_value_set_integer,
14 scf_value_set_time, scf_value_set_from_string, scf_value_set_astring,
15 scf_value_set_ustring, scf_value_set_opaque \- manipulate values in the Service
16 Configuration Facility
20 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lscf\fR [ \fIlibrary\fR\&.\|.\|. ]
23 \fBscf_value_t *\fR\fBscf_value_create\fR(\fBscf_handle_t *\fR\fIh\fR);
28 \fBscf_handle_t *\fR\fBscf_value_handle\fR(\fBscf_value_t *\fR\fIv\fR);
33 \fBvoid\fR \fBscf_value_reset\fR(\fBscf_value_t *\fR\fIv\fR);
38 \fBvoid\fR \fBscf_value_destroy\fR(\fBscf_value_t *\fR\fIv\fR);
43 \fBint\fR \fBscf_value_type\fR(\fBscf_value_t *\fR\fIv\fR);
48 \fBint\fR \fBscf_value_base_type\fR(\fBscf_value_t *\fR\fIv\fR);
53 \fBint\fR \fBscf_value_is_type\fR(\fBscf_value_t *\fR\fIv\fR, \fBscf_type_t\fR \fItype\fR);
58 \fBint\fR \fBscf_type_base_type\fR(\fBscf_type_t\fR \fItype\fR, \fBscf_type_t *\fR\fIout\fR);
63 \fBint\fR \fBscf_value_get_boolean\fR(\fBscf_value_t *\fR\fIv\fR, \fBuint8_t *\fR\fIout\fR);
68 \fBint\fR \fBscf_value_get_count\fR(\fBscf_value_t *\fR\fIv\fR, \fBuint64_t *\fR\fIout\fR);
73 \fBint\fR \fBscf_value_get_integer\fR(\fBscf_value_t *\fR\fIv\fR, \fBint64_t *\fR\fIout\fR);
78 \fBint\fR \fBscf_value_get_time\fR(\fBscf_value_t *\fR\fIv\fR, \fBint64_t *\fR\fIseconds\fR,
79 \fBint32_t *\fR\fIns\fR);
84 \fBssize_t\fR \fBscf_value_get_astring\fR(\fBscf_value_t *\fR\fIv\fR, \fBchar *\fR\fIbuf\fR,
85 \fBsize_t\fR \fIsize\fR);
90 \fBssize_t\fR \fBscf_value_get_ustring\fR(\fBscf_value_t *\fR\fIv\fR, \fBchar *\fR\fIbuf\fR,
91 \fBsize_t\fR \fIsize\fR);
96 \fBssize_t\fR \fBscf_value_get_opaque\fR(\fBscf_value_t *\fR\fIv\fR, \fBchar *\fR\fIout\fR,
97 \fBsize_t\fR \fIlen\fR);
102 \fBssize_t\fR \fBscf_value_get_as_string\fR(\fBscf_value_t *\fR\fIv\fR, \fBchar *\fR\fIbuf\fR,
103 \fBsize_t\fR \fIsize\fR);
108 \fBssize_t\fR \fBscf_value_get_as_string_typed\fR(\fBscf_value_t *\fR\fIv\fR,
109 \fBscf_type_t\fR \fItype\fR, \fBchar *\fR\fIbuf\fR, \fBsize_t\fR \fIsize\fR);
114 \fBvoid\fR \fBscf_value_set_boolean\fR(\fBscf_value_t *\fR\fIv\fR, \fBuint8_t\fR \fIin\fR);
119 \fBvoid\fR \fBscf_value_set_count\fR(\fBscf_value_t *\fR\fIv\fR, \fBuint64_t\fR \fIin\fR);
124 \fBvoid\fR \fBscf_value_set_integer\fR(\fBscf_value_t *\fR\fIv\fR, \fBint64_t\fR \fIin\fR);
129 \fBint\fR \fBscf_value_set_time\fR(\fBscf_value_t *\fR\fIv\fR, \fBint64_t\fR \fIseconds\fR,
130 \fBint32_t\fR \fIns\fR);
135 \fBint\fR \fBscf_value_set_from_string\fR(\fBscf_value_t *\fR\fIv\fR, \fBscf_type_t\fR \fItype\fR,
136 \fBchar *\fR\fIin\fR);
141 \fBint\fR \fBscf_value_set_astring\fR(\fBscf_value_t *\fR\fIv\fR, \fBconst char *\fR\fIin\fR);
146 \fBint\fR \fBscf_value_set_ustring\fR(\fBscf_value_t *\fR\fIv\fR, \fBconst char *\fR\fIin\fR);
151 \fBint\fR \fBscf_value_set_opaque\fR(\fBscf_value_t *\fR\fIv\fR, \fBvoid *\fR\fIin\fR, \fBsize_t\fR \fIsz\fR);
157 The \fBscf_value_create()\fR function creates a new, reset \fBscf_value_t\fR
158 that holds a single typed value. The value can be used only with the handle
159 specified by \fIh\fR and objects associated with \fIh\fR.
162 The \fBscf_value_reset()\fR function resets the value to the uninitialized
163 state. The \fBscf_value_destroy()\fR function deallocates the object.
166 The \fBscf_value_type()\fR function retrieves the type of the contents of
167 \fIv\fR. The \fBscf_value_is_type()\fR function determines if a value is of a
168 particular type or any of its subtypes. The \fBscf_type_base_type()\fR function
169 returns the base type of \fItype\fR. The \fBscf_value_base_type()\fR function
170 returns the true base type of the value (the highest type reachable from the
178 Type Identifier Base Type Type Description
180 \fBSCF_TYPE_INVALID\fR reserved invalid type
181 \fBSCF_TYPE_BOOLEAN\fR single bit
182 \fBSCF_TYPE_COUNT\fR unsigned 64-bit quantity
183 \fBSCF_TYPE_INTEGER\fR signed 64-bit quantity
184 \fBSCF_TYPE_TIME\fR T{
185 signed 64-bit seconds, signed 32-bit nanoseconds in the range 0 <= \fIns\fR < 1,000,000,000
187 \fBSCF_TYPE_ASTRING\fR 8-bit NUL-terminated string
188 \fBSCF_TYPE_OPAQUE\fR opaque 8-bit data
189 \fBSCF_TYPE_USTRING\fR \fBASTRING\fR 8-bit UTF-8 string
190 \fBSCF_TYPE_URI\fR \fBUSTRING\fR a URI string
191 \fBSCF_TYPE_FMRI\fR \fBURI\fR a Fault Management Resource Identifier
192 \fBSCF_TYPE_HOST\fR \fBUSTRING\fR T{
193 either a hostname, IPv4 address, or IPv6 address
195 \fBSCF_TYPE_HOSTNAME\fR \fBHOST\fR a fully-qualified domain name
196 \fBSCF_TYPE_NET_ADDR_V4\fR \fBHOST\fR T{
197 a dotted-quad IPv4 address with optional network portion
199 \fBSCF_TYPE_NET_ADDR_V6\fR \fBHOST\fR legal IPv6 address
204 The \fBscf_value_get_boolean()\fR, \fBscf_value_get_count()\fR,
205 \fBscf_value_get_integer()\fR, \fBscf_value_get_time()\fR,
206 \fBscf_value_get_astring()\fR, \fBscf_value_get_ustring()\fR, and
207 \fBscf_value_get_opaque()\fR functions read a particular type of value from
211 The \fBscf_value_get_as_string()\fR and \fBscf_value_get_as_string_typed()\fR
212 functions convert the value to a string form. For
213 \fBscf_value_get_as_string_typed()\fR, the value must be a reachable subtype of
217 The \fBscf_value_set_boolean()\fR, \fBscf_value_set_count()\fR,
218 \fBscf_value_set_integer()\fR, \fBscf_value_set_time()\fR,
219 \fBscf_value_set_astring()\fR, \fBscf_value_set_ustring()\fR, and
220 \fBscf_value_set_opaque()\fR functions set \fIv\fR to a particular value of a
224 The \fBscf_value_set_from_string()\fR function is the inverse of
225 \fBscf_value_get_as_string()\fR. It sets \fIv\fR to the value encoded in
226 \fIbuf\fR of type \fItype\fR.
229 The \fBscf_value_set_*()\fR functions will succeed on \fBscf_value_t\fR objects
230 that have already been set.
234 Upon successful completion, \fBscf_value_create()\fR returns a new, reset
235 \fBscf_value_t\fR. Otherwise, it returns \fINULL\fR.
238 Upon successful completion, \fBscf_value_handle()\fR returns the handle
239 associated with \fIv\fR. Otherwise, it returns \fINULL\fR.
242 The \fBscf_value_base_type()\fR function returns the base type of the value, or
243 \fBSCF_TYPE_INVALID\fR on failure.
246 Upon successful completion, \fBscf_value_type()\fR returns the type of the
247 value. Otherwise, it returns \fBSCF_TYPE_INVALID\fR.
250 Upon successful completion, \fBscf_value_is_type()\fR,
251 \fBscf_value_get_boolean()\fR, \fBscf_value_get_count()\fR,
252 \fBscf_value_get_integer()\fR, \fBscf_value_get_time()\fR,
253 \fBscf_value_set_time()\fR, \fBscf_value_set_from_string()\fR,
254 \fBscf_value_set_astring()\fR, \fBscf_value_set_ustring()\fR, and
255 \fBscf_value_set_opaque()\fR return 0. Otherwise, they return -1.
258 Upon successful completion, \fBscf_value_get_astring()\fR,
259 \fBscf_value_get_ustring()\fR, \fBscf_value_get_as_string()\fR, and
260 \fBscf_value_get_as_string_typed()\fR return the length of the source string,
261 not including the terminating null byte. Otherwise, they return -1.
264 Upon successful completion, \fBscf_value_get_opaque()\fR returns the number of
265 bytes written. Otherwise, it returns -1.
269 The \fBscf_value_create()\fR function will fail if:
273 \fB\fBSCF_ERROR_HANDLE_DESTROYED\fR\fR
276 The handle associated with \fIh\fR has been destroyed.
282 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
285 The handle is \fINULL\fR.
291 \fB\fBSCF_ERROR_NO_MEMORY\fR\fR
294 There is not enough memory to allocate an \fBscf_value_t\fR.
299 The \fBscf_value_handle()\fR function will fail if:
303 \fB\fBSCF_ERROR_HANDLE_DESTROYED\fR\fR
306 The handle associated with \fIv\fR has been destroyed.
311 The \fBscf_value_set_time()\fR function will fail if:
315 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
318 The nanoseconds field is not in the range 0 <= \fIns\fR < 1,000,000,000.
323 The \fBscf_type_base_type()\fR function will fail if:
327 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
330 The \fItype\fR argument is not a valid type.
335 The \fBscf_value_set_astring()\fR, \fBscf_value_set_ustring()\fR,
336 \fBscf_value_set_opaque()\fR, and \fBscf_value_set_from_string()\fR functions
341 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
344 The \fIin\fR argument is not a valid value for the specified type or is longer
345 than the maximum supported value length.
350 The \fBscf_type_base_type()\fR, \fBscf_value_is_type()\fR, and
351 \fBscf_value_get_as_string_typed()\fR functions will fail if:
355 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
358 The \fItype\fR argument is not a valid type.
363 The \fBscf_value_type()\fR, \fBscf_value_base_type()\fR,
364 \fBscf_value_get_boolean()\fR, \fBscf_value_get_count()\fR,
365 \fBscf_value_get_integer()\fR, \fBscf_value_get_time()\fR,
366 \fBscf_value_get_astring()\fR, \fBscf_value_get_ustring()\fR,
367 \fBscf_value_get_as_string()\fR, and\fBscf_value_get_as_string_typed()\fR
368 functions will fail if:
372 \fB\fBSCF_ERROR_NOT_SET\fR\fR
375 The \fIv\fR argument has not been set to a value.
380 The \fBscf_value_get_boolean()\fR, \fBscf_value_get_count()\fR,
381 \fBscf_value_get_integer()\fR, \fBscf_value_get_time()\fR,
382 \fBscf_value_get_astring()\fR, \fBscf_value_get_ustring()\fR, and
383 \fBscf_value_get_as_string_typed()\fR functions will fail if:
387 \fB\fBSCF_ERROR_TYPE_MISMATCH\fR\fR
390 The requested type is not the same as the value's type and is not in the
396 The \fBscf_error\fR(3SCF) function can be used to retrieve the error value.
400 See \fBattributes\fR(5) for descriptions of the following attributes:
408 ATTRIBUTE TYPE ATTRIBUTE VALUE
410 Interface Stability Committed
418 \fBlibscf\fR(3LIB), \fBscf_entry_add_value\fR(3SCF), \fBscf_error\fR(3SCF),