1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" 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. 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 the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SCF_SIMPLE_PROP_GET 3SCF "June 20, 2021"
.SH NAME
scf_simple_prop_get, scf_simple_prop_free, scf_simple_app_props_get,
scf_simple_app_props_free, scf_simple_app_props_next,
scf_simple_app_props_search, scf_simple_prop_numvalues, scf_simple_prop_type,
scf_simple_prop_name, scf_simple_prop_pgname, scf_simple_prop_next_boolean,
scf_simple_prop_next_count, scf_simple_prop_next_integer,
scf_simple_prop_next_time, scf_simple_prop_next_astring,
scf_simple_prop_next_ustring, scf_simple_prop_next_opaque,
scf_simple_prop_next_reset \- simplified property read interface to Service
Configuration Facility
.SH SYNOPSIS
.nf
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lscf\fR [ \fIlibrary\fR\&.\|.\|. ]
#include <libscf.h>
\fBscf_simple_prop_t *\fR\fBscf_simple_prop_get\fR(\fBscf_handle_t *\fR\fIhandle\fR,
\fBconst char *\fR\fIinstance\fR, \fBconst char *\fR\fIpgname\fR, \fBconst char *\fR\fIpropname\fR);
.fi
.LP
.nf
\fBvoid\fR \fBscf_simple_prop_free\fR(\fBscf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBscf_simple_app_props_t *\fR\fBscf_simple_app_props_get\fR(\fBscf_handle_t *\fR\fIhandle\fR,
\fBconst char *\fR\fIinstance\fR);
.fi
.LP
.nf
\fBvoid\fR \fBscf_simple_app_props_free\fR(\fBscf_simple_app_props_t *\fR\fIpropblock\fR);
.fi
.LP
.nf
\fBconst scf_simple_prop_t *\fR\fBscf_simple_app_props_next\fR
(\fBconst scf_simple_app_props_t *\fR\fIpropblock\fR,\fBscf_simple_prop_t *\fR\fIlast\fR);
.fi
.LP
.nf
\fBconst scf_simple_prop_t *\fR\fBscf_simple_app_props_search\fR
(\fBconst scf_simple_app_props_t *\fR\fIpropblock\fR, \fBconst char *\fR\fIpgname\fR,
\fBconst char *\fR\fIpropname\fR);
.fi
.LP
.nf
\fBssize_t\fR \fBscf_simple_prop_numvalues\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBscf_type_t\fR \fBscf_simple_prop_type\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBconst char *\fR\fBscf_simple_prop_name\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBconst char *\fR\fBscf_simple_prop_pgname\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBuint8_t *\fR\fBscf_simple_prop_next_boolean\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBuint64_t *\fR\fBscf_simple_prop_next_count\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBint64_t *\fR\fBscf_simple_prop_next_integer\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBint64_t *\fR\fBscf_simple_prop_next_time\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR,
\fBint32_t *\fR\fInsec\fR);
.fi
.LP
.nf
\fBchar *\fR\fBscf_simple_prop_next_astring\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBchar *\fR\fBscf_simple_prop_next_ustring\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.LP
.nf
\fBvoid *\fR\fBscf_simple_prop_next_opaque\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR,
\fBsize_t *\fR\fIlength\fR);
.fi
.LP
.nf
\fBvoid *\fR\fBscf_simple_prop_next_reset\fR(\fBconst scf_simple_prop_t *\fR\fIprop\fR);
.fi
.SH DESCRIPTION
The simplified read interface to the Service Configuration Facility deals with
properties and blocks of properties.
.sp
.LP
The \fBscf_simple_prop_get()\fR function pulls a single property. The
\fBscf_simple_prop_*()\fR functions operate on the resulting
\fBscf_simple_prop_t\fR.
.sp
.LP
The application might need to get many properties or iterate through all
properties. The \fBscf_simple_app_props_get()\fR function gets all properties
from the service instance that are in property groups of type 'application'.
Individual properties are pulled from the block using the
\fBscf_simple_app_props_next()\fR function for iteration or
\fBscf_simple_app_props_search()\fR to search. The pointer to the
\fBscf_simple_prop_t\fR returned from iteration or searching can be acted upon
using the \fBscf_simple_prop_*()\fR functions. Each \fBscf_*_get()\fR function
has an accompanying \fBscf_*_free\fR function. The application does not free
the pointer to the \fBscf_simple_prop_t\fR returned from the
\fBscf_simple_app_props_next()\fR and \fBscf_simple_app_props_search()\fR
calls. A free call is only used with a corresponding get call.
.sp
.LP
The \fBscf_simple_prop_*()\fR functions return references to the read-only
in-memory copy of the property information. Any changes to this information
results in unstable behavior and inaccurate results. The simplified read
interface provides read access only, with no provisions to modify data in the
service configuration facility repository.
.sp
.LP
The \fBscf_simple_prop_get()\fR function takes as arguments a bound handle, a
service instance FMRI, and the property group and property name of a property.
If \fIhandle\fR is \fINULL\fR, the library uses a temporary handle created for
the purpose. If \fIinstance\fR is \fINULL\fR the library automatically finds
the FMRI of the calling process. If \fIpgname\fR is \fINULL\fR, the library
uses the default application property group. The caller is responsible for
freeing the returned property with \fBscf_simple_prop_free()\fR.
.sp
.LP
The \fBscf_simple_prop_free()\fR function frees the \fBscf_simple_prop_t\fR
allocated by \fBscf_simple_prop_get()\fR.
.sp
.LP
The \fBscf_simple_app_props_get()\fR function takes a bound handle and a
service instance FMRI and pulls all the application properties into an
\fBscf_simple_app_props_t\fR. If \fIhandle\fR is \fINULL\fR, the library uses a
temporary handle created for the purpose. If \fIinstance\fR is \fINULL\fR, the
library looks up the instance FMRI of the process calling the function. The
caller is responsible for freeing the \fBscf_simple_app_props_t\fR with
\fBscf_simple_app_props_free()\fR.
.sp
.LP
The \fBscf_simple_app_props_free()\fR function frees the
\fBscf_simple_app_props_t\fR allocated by \fBscf_simple_app_props_get()\fR.
.sp
.LP
The \fBscf_simple_app_props_next()\fR function iterates over each property in
an \fBscf_simple_app_props_t\fR. It takes an \fBscf_simple_app_props_t\fR
pointer and the last property returned from the previous call and returns the
next property in the \fBscf_simple_app_props_t\fR. Because the property is a
reference into the \fBscf_simple_app_props_t\fR, its lifetime extends only
until that structure is freed.
.sp
.LP
The \fBscf_simple_app_props_search()\fR function queries for an exact match on a
property in a property group. It takes an apps prop object, a property group
name, and a property name, and returns a property pointer. Because the property
is a reference into the \fBscf_simple_app_props_t\fR, its lifetime extends only
until that structure is freed. If the property group name, \fIpgname\fR, is
\fINULL\fR, "application" is used.
.sp
.LP
The \fBscf_simple_prop_numvalues()\fR function takes a pointer to a property
and returns the number of values in that property.
.sp
.LP
The \fBscf_simple_prop_type()\fR function takes a pointer to a property and
returns the type of the property in an \fBscf_type_t\fR.
.sp
.LP
The \fBscf_simple_prop_name()\fR function takes a pointer to a property and
returns a pointer to the property name string.
.sp
.LP
The \fBscf_simple_prop_pgname()\fR function takes a pointer to a property and
returns a pointer to the property group name string. The
\fBscf_simple_prop_next_boolean()\fR, \fBscf_simple_prop_next_count()\fR,
\fBscf_simple_prop_next_integer()\fR, \fBscf_simple_prop_next_astring()\fR, and
\fBscf_simple_prop_next_ustring()\fR functions take a pointer to a property and
return the first value in the property. Subsequent calls iterate over all the
values in the property. The property's internal iteration can be reset with
\fBscf_simple_prop_next_reset()\fR.
.sp
.LP
The \fBscf_simple_prop_next_time()\fR function takes a pointer to a property
and the address of an allocated \fBint32_t\fR to hold the nanoseconds field,
and returns the first value in the property. Subsequent calls iterate over the
property values.
.sp
.LP
The \fBscf_simple_prop_next_opaque()\fR function takes a pointer to a property
and the address of an allocated integer to hold the size of the opaque buffer.
It returns the first value in the property. Subsequent calls iterate over the
property values, as do the \fBscf_simple_prop_next_*()\fR functions. The
\fBscf_simple_prop_next_opaque()\fR function writes the size of the opaque
buffer into the allocated integer.
.sp
.LP
The \fBscf_simple_prop_next_reset()\fR function resets iteration on a property,
so that a call to one of the \fBscf_simple_prop_next_*()\fR functions returns
the first value in the property.
.SH RETURN VALUES
Upon successful completion, \fBscf_simple_prop_get()\fR returns a pointer to an
allocated \fBscf_simple_prop_t\fR. Otherwise, it returns \fINULL\fR.
.sp
.LP
Upon successful completion, \fBscf_simple_app_props_get()\fR returns a pointer
to an allocated \fBscf_simple_app_props_t\fR. Otherwise, it returns \fINULL\fR.
.sp
.LP
Upon successful completion, \fBscf_simple_app_props_next()\fR returns a pointer
to an \fBscf_simple_prop_t\fR. Otherwise, it returns \fINULL\fR.
.sp
.LP
Upon successful completion, \fBscf_simple_app_props_search()\fR returns a
pointer to an \fBscf_simple_prop_t\fR. Otherwise, it returns \fINULL\fR.
.sp
.LP
Upon successful completion, \fBscf_simple_prop_numvalues()\fR returns the
number of values in a property. Otherwise, it returns -1.
.sp
.LP
Upon successful completion, \fBscf_simple_prop_type()\fR returns an
\fBscf_type_t\fR. Otherwise, it returns -1.
.sp
.LP
Upon successful completion, \fBscf_simple_prop_name()\fR and
\fBscf_simple_prop_pgname()\fR return character pointers. Otherwise, they
return \fINULL\fR.
.sp
.LP
Upon successful completion, \fBscf_simple_prop_next_boolean()\fR,
\fBscf_simple_prop_next_count()\fR, \fBscf_simple_prop_next_integer()\fR,
\fBscf_simple_prop_next_time()\fR, \fBscf_simple_prop_next_astring()\fR,
\fBscf_simple_prop_next_ustring()\fR, and \fBscf_simple_prop_next_opaque()\fR
return a pointer to the next value in the property. After all values have been
returned, NULL is returned and \fBSCF_ERROR_NONE\fR is set. On failure,
\fINULL\fR is returned and the appropriate error value is set.
.SH ERRORS
The \fBscf_simple_prop_get()\fR and \fBscf_simple_app_props_get()\fR functions
will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
.ad
.sp .6
.RS 4n
The connection to the datastore is broken.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
.ad
.sp .6
.RS 4n
The instance FMRI is invalid or property name is \fINULL\fR.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NO_MEMORY\fR\fR
.ad
.sp .6
.RS 4n
The memory allocation failed.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_BOUND\fR\fR
.ad
.sp .6
.RS 4n
The connection handle is not bound.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_FOUND\fR\fR
.ad
.sp .6
.RS 4n
The specified instance or property does not exist.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
.ad
.sp .6
.RS 4n
The caller is not authorized to read the property's value(s).
.RE
.sp
.LP
The \fBscf_simple_app_props_next()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_SET\fR\fR
.ad
.RS 21n
The value of the \fIpropblock\fR argument is \fINULL\fR.
.RE
.sp
.LP
The \fBscf_simple_app_props_search()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_FOUND\fR\fR
.ad
.RS 23n
The property was not found.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_SET\fR\fR
.ad
.RS 23n
The value of the \fIpropblock\fR or \fIpropname\fR argument is \fINULL\fR.
.RE
.sp
.LP
The \fBscf_simple_prop_numvalues()\fR, \fBscf_simple_prop_type()\fR,
\fBscf_simple_prop_name()\fR, and \fBscf_simple_prop_pgname()\fR functions will
fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_SET\fR\fR
.ad
.RS 21n
The property is \fINULL\fR.
.RE
.sp
.LP
The \fBscf_simple_prop_next_boolean()\fR, \fBscf_simple_prop_next_count()\fR,
\fBscf_simple_prop_next_integer()\fR, \fBscf_simple_prop_next_time()\fR,
\fBscf_simple_prop_next_astring()\fR, \fBscf_simple_prop_next_ustring()\fR, and
\fBscf_simple_prop_next_opaque()\fR functions will fail if:
.sp
.ne 2
.na
\fB\fBSCF_ERROR_NOT_SET\fR\fR
.ad
.RS 27n
The property is \fINULL\fR.
.RE
.sp
.ne 2
.na
\fB\fBSCF_ERROR_TYPE_MISMATCH\fR\fR
.ad
.RS 27n
The requested type does not match the property type.
.RE
.SH EXAMPLES
\fBExample 1 \fRSimple Property Get
.sp
.in +2
.nf
/*
* In this example, we pull the property named "size" from the
* default property group. We make sure that the property
* isn't empty, and then copy it into the sizeval variable.
*/
scf_simple_prop_t *prop;
ssize_t numvals;
int64_t *sizeval;
prop = scf_simple_prop_get(
"svc://localhost/category/service/instance",
NULL, "size");
numvals = scf_simple_prop_numvalues(prop);
if(numvals > 0){
sizeval = scf_simple_prop_next_integer(prop);
}
scf_simple_prop_free(prop);
.fi
.in -2
.LP
\fBExample 2 \fRProperty Iteration
.sp
.in +2
.nf
scf_simple_prop_t *prop;
scf_simple_app_props_t *appprops;
appprops = scf_simple_app_props_get(
"svc://localhost/category/service/instance");
prop = scf_simple_app_props_next(appprops, NULL);
while(prop != NULL)
{
/*
* This iteration will go through every property in the
* instance's application block. The user can use
* the set of property functions to pull the values out
* of prop, as seen in other examples.
*/
(...code acting on each property...)
prop = scf_simple_app_props_next(appprops, prop);
}
scf_simple_app_props_free(appprops);
.fi
.in -2
.LP
\fBExample 3 \fRProperty Searching
.sp
.in +2
.nf
/*
* In this example, we pull the property block from the instance,
* and then query it. Generally speaking, the simple get would
* be used for an example like this, but for the purposes of
* illustration, the non-simple approach is used. The property
* is a list of integers that are pulled into an array.
* Note how val is passed back into each call, as described above.
*/
scf_simple_app_props_t *appprops;
scf_simple_prop_t *prop;
int i;
int64_t *intlist;
ssize_t numvals;
appprops = scf_simple_app_props_get(
"svc://localhost/category/service/instance");
prop = scf_simple_app_props_search(appprops, "appname", "numlist");
if(prop != NULL){
numvals = scf_simple_prop_numvalues(prop);
if(numvals > 0){
intlist = malloc(numvals * sizeof(int64_t));
val = scf_simple_prop_next_integer(prop);
for(i=0, i < numvals, i++){
intlist[i] = *val;
val = scf_simple_prop_next_integer(prop);
}
}
}
scf_simple_app_props_free(appprops);
.fi
.in -2
.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
_
MT-Level Safe
.TE
.SH SEE ALSO
.BR libscf (3LIB),
.BR scf_error (3SCF),
.BR attributes (7)
|