2 .\" Copyright (c) 2007, 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.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" 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 the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SCF_SIMPLE_PROP_GET 3SCF "Nov 7, 2007"
8 scf_simple_prop_get, scf_simple_prop_free, scf_simple_app_props_get,
9 scf_simple_app_props_free, scf_simple_app_props_next,
10 scf_simple_app_props_search, scf_simple_prop_numvalues, scf_simple_prop_type,
11 scf_simple_prop_name, scf_simple_prop_pgname, scf_simple_prop_next_boolean,
12 scf_simple_prop_next_count, scf_simple_prop_next_integer,
13 scf_simple_prop_next_time, scf_simple_prop_next_astring,
14 scf_simple_prop_next_ustring, scf_simple_prop_next_opaque,
15 scf_simple_prop_next_reset \- simplified property read interface to Service
16 Configuration Facility
20 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lscf\fR [ \fIlibrary\fR\&.\|.\|. ]
23 \fBscf_simple_prop_t *\fR\fBscf_simple_prop_get\fR(\fBscf_handle_t *\fR\fIhandle\fR,
24 \fBconst char *\fR\fIinstance\fR, \fBconst char *\fR\fIpgname\fR, \fBconst char *\fR\fIpropname\fR);
29 \fBvoid\fR \fBscf_simple_prop_free\fR(\fBscf_simple_prop_t *\fR\fIprop\fR);
34 \fBscf_simple_app_props_t *\fR\fBscf_simple_app_props_get\fR(\fBscf_handle_t *\fR\fIhandle\fR,
35 \fBconst char *\fR\fIinstance\fR);
40 \fBvoid\fR \fBscf_simple_app_props_free\fR(\fBscf_simple_app_props_t *\fR\fIpropblock\fR);
45 \fBconst scf_simple_prop_t *\fR\fBscf_simple_app_props_next\fR
46 (\fBconst scf_simple_app_props_t *\fR\fIpropblock\fR,\fBscf_simple_prop_t *\fR\fIlast\fR);
51 \fBconst scf_simple_prop_t *\fR\fBscf_simple_app_props_search\fR
52 (\fBconst scf_simple_app_props_t *\fR\fIpropblock\fR, \fBconst char *\fR\fIpgname\fR,
53 \fBconst char *\fR\fIpropname\fR);
58 \fBssize_t\fR \fBscf_simple_prop_numvalues\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
63 \fBscf_type_t\fR \fBscf_simple_prop_type\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
68 \fBconst char *\fR\fBscf_simple_prop_name\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
73 \fBconst char *\fR\fBscf_simple_prop_pgname\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
78 \fBuint8_t *\fR\fBscf_simple_prop_next_boolean\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
83 \fBuint64_t *\fR\fBscf_simple_prop_next_count\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
88 \fBint64_t *\fR\fBscf_simple_prop_next_integer\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
93 \fBint64_t *\fR\fBscf_simple_prop_next_time\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR,
94 \fBint32_t *\fR\fInsec\fR);
99 \fBchar *\fR\fBscf_simple_prop_next_astring\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
104 \fBchar *\fR\fBscf_simple_prop_next_ustring\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
109 \fBvoid *\fR\fBscf_simple_prop_next_opaque\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR,
110 \fBsize_t *\fR\fIlength\fR);
115 \fBvoid *\fR\fBscf_simple_prop_next_reset\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
121 The simplified read interface to the Service Configuration Facility deals with
122 properties and blocks of properties.
125 The \fBscf_simple_prop_get()\fR function pulls a single property. The
126 \fBscf_simple_prop_*()\fR functions operate on the resulting
127 \fBscf_simple_prop_t\fR.
130 The application might need to get many properties or iterate through all
131 properties. The \fBscf_simple_app_props_get()\fR function gets all properties
132 from the service instance that are in property groups of type 'application'.
133 Individual properties are pulled from the block using the
134 \fBscf_simple_app_props_next()\fR function for iteration or
135 \fBscf_simple_app_props_search()\fR to search. The pointer to the
136 \fBscf_simple_prop_t\fR returned from iteration or searching can be acted upon
137 using the \fBscf_simple_prop_*()\fR functions. Each \fBscf_*_get()\fR function
138 has an accompanying \fBscf_*_free\fR function. The application does not free
139 the pointer to the \fBscf_simple_prop_t\fR returned from the
140 \fBscf_simple_app_props_next()\fR and \fBscf_simple_app_props_search()\fR
141 calls. A free call is only used with a corresponding get call.
144 The \fBscf_simple_prop_*()\fR functions return references to the read-only
145 in-memory copy of the property information. Any changes to this information
146 results in unstable behavior and inaccurate results. The simplified read
147 interface provides read access only, with no provisions to modify data in the
148 service configuration facility repository.
151 The \fBscf_simple_prop_get()\fR function takes as arguments a bound handle, a
152 service instance FMRI, and the property group and property name of a property.
153 If \fIhandle\fR is \fINULL\fR, the library uses a temporary handle created for
154 the purpose. If \fIinstance\fR is \fINULL\fR the library automatically finds
155 the FMRI of the calling process. If \fIpgname\fR is \fINULL\fR, the library
156 uses the default application property group. The caller is responsible for
157 freeing the returned property with \fBscf_simple_prop_free()\fR.
160 The \fBscf_simple_prop_free()\fR function frees the \fBscf_simple_prop_t\fR
161 allocated by \fBscf_simple_prop_get()\fR.
164 The \fBscf_simple_app_props_get()\fR function takes a bound handle and a
165 service instance FMRI and pulls all the application properties into an
166 \fBscf_simple_app_props_t\fR. If \fIhandle\fR is \fINULL\fR, the library uses a
167 temporary handle created for the purpose. If \fIinstance\fR is \fINULL\fR, the
168 library looks up the instance FMRI of the process calling the function. The
169 caller is responsible for freeing the \fBscf_simple_app_props_t\fR with
170 \fBscf_simple_app_props_free()\fR.
173 The \fBscf_simple_app_props_free()\fR function frees the
174 \fBscf_simple_app_props_t\fR allocated by \fBscf_simple_app_props_get()\fR.
177 The \fBscf_simple_app_props_next()\fR function iterates over each property in
178 an \fBscf_simple_app_props_t\fR. It takes an \fBscf_simple_app_props_t\fR
179 pointer and the last property returned from the previous call and returns the
180 next property in the \fBscf_simple_app_props_t\fR. Because the property is a
181 reference into the \fBscf_simple_app_props_t\fR, its lifetime extends only
182 until that structure is freed.
185 The\fBscf_simple_app_props_search()\fR function queries for an exact match on a
186 property in a property group. It takes an apps prop object, a property group
187 name, and a property name, and returns a property pointer. Because the property
188 is a reference into the \fBscf_simple_app_props_t\fR, its lifetime extends only
189 until that structure is freed. If the property group name, \fIpgname\fR, is
190 \fINULL\fR, "application" is used.
193 The \fBscf_simple_prop_numvalues()\fR function takes a pointer to a property
194 and returns the number of values in that property.
197 The \fBscf_simple_prop_type()\fR function takes a pointer to a property and
198 returns the type of the property in an \fBscf_type_t\fR.
201 The \fBscf_simple_prop_name()\fR function takes a pointer to a property and
202 returns a pointer to the property name string.
205 The \fBscf_simple_prop_pgname()\fR function takes a pointer to a property and
206 returns a pointer to the property group name string. The
207 \fBscf_simple_prop_next_boolean()\fR, \fBscf_simple_prop_next_count()\fR,
208 \fBscf_simple_prop_next_integer()\fR, \fBscf_simple_prop_next_astring()\fR, and
209 \fBscf_simple_prop_next_ustring()\fR functions take a pointer to a property and
210 return the first value in the property. Subsequent calls iterate over all the
211 values in the property. The property's internal iteration can be reset with
212 \fBscf_simple_prop_next_reset()\fR.
215 The \fBscf_simple_prop_next_time()\fR function takes a pointer to a property
216 and the address of an allocated \fBint32_t\fR to hold the nanoseconds field,
217 and returns the first value in the property. Subsequent calls iterate over the
221 The \fBscf_simple_prop_next_opaque()\fR function takes a pointer to a property
222 and the address of an allocated integer to hold the size of the opaque buffer.
223 It returns the first value in the property. Subsequent calls iterate over the
224 property values, as do the \fBscf_simple_prop_next_*()\fR functions. The
225 \fBscf_simple_prop_next_opaque()\fR function writes the size of the opaque
226 buffer into the allocated integer.
229 The \fBscf_simple_prop_next_reset()\fR function resets iteration on a property,
230 so that a call to one of the \fBscf_simple_prop_next_*()\fR functions returns
231 the first value in the property.
235 Upon successful completion, \fBscf_simple_prop_get()\fR returns a pointer to an
236 allocated \fBscf_simple_prop_t\fR. Otherwise, it returns \fINULL\fR.
239 Upon successful completion, \fBscf_simple_app_props_get()\fR returns a pointer
240 to an allocated \fBscf_simple_app_props_t\fR. Otherwise, it returns \fINULL\fR.
243 Upon successful completion, \fBscf_simple_app_props_next()\fR returns a pointer
244 to an \fBscf_simple_prop_t\fR. Otherwise, it returns \fINULL\fR.
247 Upon successful completion, \fBscf_simple_app_props_search()\fR returns a
248 pointer to an \fBscf_simple_prop_t\fR. Otherwise, it returns \fINULL\fR.
251 Upon successful completion, \fBscf_simple_prop_numvalues()\fR returns the
252 number of values in a property. Otherwise, it returns -1.
255 Upon successful completion, \fBscf_simple_prop_type()\fR returns an
256 \fBscf_type_t\fR. Otherwise, it returns -1.
259 Upon successful completion, \fBscf_simple_prop_name()\fR and
260 \fBscf_simple_prop_pgname()\fR return character pointers. Otherwise, they
264 Upon successful completion, \fBscf_simple_prop_next_boolean()\fR,
265 \fBscf_simple_prop_next_count()\fR, \fBscf_simple_prop_next_integer()\fR,
266 \fBscf_simple_prop_next_time()\fR, \fBscf_simple_prop_next_astring()\fR,
267 \fBscf_simple_prop_next_ustring()\fR, and \fBscf_simple_prop_next_opaque()\fR
268 return a pointer to the next value in the property. After all values have been
269 returned, NULL is returned and \fBSCF_ERROR_NONE\fR is set. On failure,
270 \fINULL\fR is returned and the appropriate error value is set.
274 The \fBscf_simple_prop_get()\fR and \fBscf_simple_app_props_get()\fR functions
279 \fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
283 The connection to the datastore is broken.
289 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
293 The instance FMRI is invalid or property name is \fINULL\fR.
299 \fB\fBSCF_ERROR_NO_MEMORY\fR\fR
303 The memory allocation failed.
309 \fB\fBSCF_ERROR_NOT_BOUND\fR\fR
313 The connection handle is not bound.
319 \fB\fBSCF_ERROR_NOT_FOUND\fR\fR
323 The specified instance or property does not exist.
329 \fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
333 The caller is not authorized to read the property's value(s).
338 The \fBscf_simple_app_props_next()\fR function will fail if:
342 \fB\fBSCF_ERROR_NOT_SET\fR\fR
345 The value of the \fIpropblock\fR argument is \fINULL\fR.
350 The \fBscf_simple_app_props_search()\fR function will fail if:
354 \fB\fBSCF_ERROR_NOT_FOUND\fR\fR
357 The property was not found.
363 \fB\fBSCF_ERROR_NOT_SET\fR\fR
366 The value of the \fIpropblock\fR or \fIpropname\fR argument is \fINULL\fR.
371 The \fBscf_simple_prop_numvalues()\fR, \fBscf_simple_prop_type()\fR,
372 \fBscf_simple_prop_name()\fR, and \fBscf_simple_prop_pgname()\fR functions will
377 \fB\fBSCF_ERROR_NOT_SET\fR\fR
380 The property is \fINULL\fR.
385 The \fBscf_simple_prop_next_boolean()\fR, \fBscf_simple_prop_next_count()\fR,
386 \fBscf_simple_prop_next_integer()\fR, \fBscf_simple_prop_next_time()\fR,
387 \fBscf_simple_prop_next_astring()\fR, \fBscf_simple_prop_next_ustring()\fR, and
388 \fBscf_simple_prop_next_opaque()\fR functions will fail if:
392 \fB\fBSCF_ERROR_NOT_SET\fR\fR
395 The property is \fINULL\fR.
401 \fB\fBSCF_ERROR_TYPE_MISMATCH\fR\fR
404 The requested type does not match the property type.
409 \fBExample 1 \fRSimple Property Get
414 * In this example, we pull the property named "size" from the
415 * default property group. We make sure that the property
416 * isn't empty, and then copy it into the sizeval variable.
419 scf_simple_prop_t *prop;
423 prop = scf_simple_prop_get(
424 "svc://localhost/category/service/instance",
427 numvals = scf_simple_prop_numvalues(prop);
430 sizeval = scf_simple_prop_next_integer(prop);
433 scf_simple_prop_free(prop);
438 \fBExample 2 \fRProperty Iteration
442 scf_simple_prop_t *prop;
443 scf_simple_app_props_t *appprops;
445 appprops = scf_simple_app_props_get(
446 "svc://localhost/category/service/instance");
448 prop = scf_simple_app_props_next(appprops, NULL);
453 * This iteration will go through every property in the
454 * instance's application block. The user can use
455 * the set of property functions to pull the values out
456 * of prop, as seen in other examples.
459 (...code acting on each property...)
462 prop = scf_simple_app_props_next(appprops, prop);
466 scf_simple_app_props_free(appprops);
471 \fBExample 3 \fRProperty Searching
476 * In this example, we pull the property block from the instance,
477 * and then query it. Generally speaking, the simple get would
478 * be used for an example like this, but for the purposes of
479 * illustration, the non-simple approach is used. The property
480 * is a list of integers that are pulled into an array.
481 * Note how val is passed back into each call, as described above.
484 scf_simple_app_props_t *appprops;
485 scf_simple_prop_t *prop;
490 appprops = scf_simple_app_props_get(
491 "svc://localhost/category/service/instance");
493 prop = scf_simple_app_props_search(appprops, "appname", "numlist");
497 numvals = scf_simple_prop_numvalues(prop);
501 intlist = malloc(numvals * sizeof(int64_t));
503 val = scf_simple_prop_next_integer(prop);
505 for(i=0, i < numvals, i++){
507 val = scf_simple_prop_next_integer(prop);
512 scf_simple_app_props_free(appprops);
519 See \fBattributes\fR(5) for descriptions of the following attributes:
527 ATTRIBUTE TYPE ATTRIBUTE VALUE
529 Interface Stability Committed
537 \fBlibscf\fR(3LIB), \fBscf_error\fR(3SCF), \fBattributes\fR(5)