Merge commit 'dc97a43d4a70c8773a619f11b95b07a787f6f5b7' into merges
[unleashed.git] / share / man / man3scf / scf_tmpl_prop_name.3scf
blobbf3f08a4ef8422292f7e74d890871fa192d136f9
1 '\" te
2 .\" Copyright (c) 2008, 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_TMPL_PROP_NAME 3SCF "Oct 28, 2008"
7 .SH NAME
8 scf_tmpl_prop_name, scf_tmpl_prop_type, scf_tmpl_prop_required,
9 scf_tmpl_prop_common_name, scf_tmpl_prop_description, scf_tmpl_prop_units,
10 scf_tmpl_prop_visibility, scf_tmpl_visibility_to_string,
11 scf_tmpl_prop_cardinality, scf_tmpl_prop_internal_seps,
12 scf_tmpl_value_name_constraints, scf_count_ranges_destroy,
13 scf_int_ranges_destroy, scf_tmpl_value_count_range_constraints,
14 scf_tmpl_value_int_range_constraints, scf_tmpl_value_name_choices,
15 scf_values_destroy, scf_tmpl_value_count_range_choices,
16 scf_tmpl_value_int_range_choices, scf_tmpl_value_common_name,
17 scf_tmpl_value_description, scf_tmpl_value_in_constraint \- retrieve the
18 metadata about a specific property
19 .SH SYNOPSIS
20 .LP
21 .nf
22 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lscf\fR [ \fIlibrary\fR\&.\|.\|. ]
23 #include <libscf.h>
25 \fBssize_t\fR \fBscf_tmpl_prop_name\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
26      \fBchar **\fR\fIout\fR);
27 .fi
29 .LP
30 .nf
31 \fBint\fR \fBscf_tmpl_prop_type\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
32      \fBscf_type_t *\fR\fIout\fR);
33 .fi
35 .LP
36 .nf
37 \fBint\fR \fBscf_tmpl_prop_required\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
38      \fBuint8_t *\fR\fIout\fR)
39 .fi
41 .LP
42 .nf
43 \fBssize_t\fR \fBscf_tmpl_prop_common_name\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
44      \fBchar *\fR\fIlocale\fR, \fBchar **\fR\fIout\fR);
45 .fi
47 .LP
48 .nf
49 \fBssize_t\fR \fBscf_tmpl_prop_description\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
50      \fBchar *\fR \fIlocale\fR, \fBchar **\fR\fIout\fR);
51 .fi
53 .LP
54 .nf
55 \fBssize_t\fR \fBscf_tmpl_prop_units\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
56      \fBconst char *\fR\fIlocale\fR, \fBchar **\fR\fIout\fR);
57 .fi
59 .LP
60 .nf
61 \fBint\fR \fBscf_tmpl_prop_visibility\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
62      \fBuint8_t *\fR\fIout\fR);
63 .fi
65 .LP
66 .nf
67 \fBconst char *\fR\fBscf_tmpl_visibility_to_string\fR(\fBuint8_t\fR \fIvisibility\fR);
68 .fi
70 .LP
71 .nf
72 \fBint\fR \fBscf_tmpl_prop_cardinality\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
73      \fBuint64_t *\fR\fImin\fR, \fBuint64_t *\fR\fImax\fR);
74 .fi
76 .LP
77 .nf
78 \fBint\fR \fBscf_tmpl_prop_internal_seps\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
79      \fBscf_values_t *\fR\fIout\fR);
80 .fi
82 .LP
83 .nf
84 \fBint\fR \fBscf_tmpl_value_name_constraints\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
85      \fBscf_values_t *\fR\fIout\fR);
86 .fi
88 .LP
89 .nf
90 \fBvoid\fR \fBscf_count_ranges_destroy\fR(\fBscf_count_ranges_t *\fR\fIranges\fR);
91 .fi
93 .LP
94 .nf
95 \fBvoid\fR \fBscf_int_ranges_destroy\fR(\fBscf_int_ranges_t *\fR\fIranges\fR);
96 .fi
98 .LP
99 .nf
100 \fBint\fR \fBscf_tmpl_value_count_range_constraints\fR(
101      \fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR, \fBscf_count_ranges_t *\fR\fIranges\fR);
106 \fBint\fR \fBscf_tmpl_value_int_range_constraints\fR(
107      \fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR, \fBscf_int_ranges_t *\fR\fIranges\fR);
112 \fBint\fR \fBscf_tmpl_value_name_choices\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
113      \fBscf_values_t *\fR\fIvals\fR);
118 \fBvoid\fR \fBscf_values_destroy\fR(\fBscf_values_t *\fR\fIvals\fR);
123 \fBint\fR \fBscf_tmpl_value_count_range_choices\fR(
124      \fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR, \fBscf_count_ranges_t *\fR\fIranges\fR);
129 \fBint\fR \fBscf_tmpl_value_int_range_choices\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
130      \fBscf_int_ranges_t *\fR\fIranges\fR);
135 \fBssize_t\fR \fBscf_tmpl_value_common_name\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
136      \fBconst char *\fR\fIlocale\fR, \fBconst char *\fR\fIvalue\fR, \fBchar **\fR\fIout\fR);
141 \fBssize_t\fR \fBscf_tmpl_value_description\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
142      \fBconst char *\fR\fIlocale\fR, \fBconst char *\fR\fIvalue\fR, \fBchar **\fR\fIout\fR);
147 \fBint\fR \fBscf_tmpl_value_in_constraint\fR(\fBconst scf_prop_tmpl_t *\fR\fIprop_tmpl\fR,
148      \fBscf_value_t *\fR\fIvalue\fR, \fBscf_tmpl_errors_t **\fR\fIerrs\fR);
151 .SH DESCRIPTION
154 These functions retrieve the metadata about a specific property. They require
155 that the template for the property has already been located by one of the
156 \fBscf_tmpl_prop_create\fR(3SCF) suite of functions.
159 The \fBscf_tmpl_prop_name()\fR function will retrieve the property's name as
160 currently templated and place it in *\fIout\fR. The caller is responsible for
161 freeing the *\fIout\fR buffer on success.
164 The \fBscf_tmpl_prop_type()\fR function will retrieve the type of the property
165 as templated and place the type in out.
168 The \fBscf_tmpl_prop_required()\fR function will determine whether the property
169 is required in this property group and place the result of that check in out.
170 If required is unset, out will be the default, 0. If the property is explicitly
171 set to required, out will be 1.
174 The \fBscf_tmpl_prop_common_name()\fR function will retrieve the property's
175 localized common name as currently templated and place it in *\fIout\fR. A
176 locale (as described in \fBsetlocale\fR(3C)) can be specified, or if the
177 supplied locale is \fINULL\fR, the current locale will be used. If a common
178 name in the specified locale is not found, the function will also look for a
179 common name in the C locale. Some templates will not specify the property
180 common name. The caller is responsible for freeing the *\fIout\fR buffer on
181 success.
184 The \fBscf_tmpl_prop_description()\fR function will retrieve the property's
185 localized description as currently templated and place it in *\fIout\fR. A
186 locale (as described in \fBsetlocale\fR(3C)) can be specified, or if the
187 supplied locale is \fINULL\fR, the current locale will be used. If a
188 description in the specified locale is not found, the function will also look
189 for a description in the C locale. Some templates will not specify the property
190 description. The caller is responsible for freeing the *\fIout\fR buffer on
191 success.
194 The \fBscf_tmpl_prop_visibility()\fR function will retrieve the visibility of
195 the property as currently templated and place it in out. A property can be
196 \fBSCF_TMPL_VISIBILITY_HIDDEN\fR, \fBSCF_TMPL_VISIBILITY_READONLY\fR, or
197 \fBSCF_TMPL_VISIBILITY_READWRITE\fR. If the visibility is unset, this function
198 will return the default, \fBSCF_TMPL_VISIBILITY_READWRITE\fR.
201 The \fBscf_tmpl_prop_cardinality()\fR function will retrieve the minimum number
202 of values and maximum number of values allowed for this property and place them
203 in \fImin\fR and \fImax\fR, respectively. If the values are unset, the defaults
204 of 0 for \fImin\fR and \fBUINT64_MAX\fR for \fImax\fR.
207 The \fBscf_values_destroy()\fR function destroys an \fBscf_values_t\fR
208 structure and all memory associated with it.
211 The \fBscf_values_t\fR structure is populated by a number of functions. Based
212 on the value type, it is populated with an array of the values. It is also
213 always populated with an array of \fIastring\fR translations of those values.
215 .in +2
217 typedef struct scf_time {
218       int64_t         t_seconds;
219       int32_t         t_ns;
220 } scf_time_t;
222 typedef struct scf_values {
223       scf_type_t              value_type;
224       char                    *reserved;
225       int                     value_count;
226       const char              **values_as_astring;
227       union {
228               uint64_t        *v_count;
229               uint8_t         *v_boolean;
230               int64_t         *v_integer;
231               char            **v_astring;
232               char            **v_ustring;
233               char            **v_opaque;
234               scf_time_t      *v_time;
235       } sv_data;
236 } scf_values_t;
238 .in -2
242 The \fBscf_tmpl_prop_internal_seps()\fR function will retrieve the list of
243 internal separators as currently defined in the template. Each separator will
244 be a single string character in a different element of out. Some templates will
245 not specify any internal separators. The caller is responsible for calling
246 \fBscf_values_destroy()\fR on success.
249 The \fBscf_tmpl_value_name_constraints()\fR function will retrieve the set of
250 property values the property is expected to be part of. Some templates will not
251 specify any constraints. The caller is responsible for calling
252 \fBscf_values_destroy()\fR on success.
255 The \fBscf_tmpl_value_count_range_constraints()\fR function will retrieve the
256 set of defined lower and upper bounds as defined by the property template and
257 place them in \fIranges\fR. Some templates will not specify any range
258 constraints.
261 The \fBscf_count_ranges_t\fR structure is populated by the
262 \fBscf_tmpl_value_count_range_constraints()\fR and
263 \fBscf_tmpl_value_count_range_choices()\fR functions.
264 \fBscf_count_ranges_destroy()\fR destroys an \fBscf_count_ranges_t\fR and all
265 memory associated with it.
267 .in +2
269 typedef struct scf_count_ranges {
270         int             scr_num_ranges;
271         uint64_t        *scr_min;
272         uint64_t        *scr_max;
273 } scf_count_ranges_t;
275 .in -2
279 The \fBscf_tmpl_value_int_range_constraints()\fR function will retrieve the set
280 of defined lower and upper bounds as defined by the property template and place
281 them in \fIranges\fR. Some templates will not specify any range constraints.
284 The \fBscf_int_ranges_t\fR structure is populated by the
285 \fBscf_tmpl_value_int_range_constraints()\fR and
286 \fBscf_tmpl_value_int_range_choices()\fR functions. The
287 \fBscf_int_ranges_destroy()\fR function destroys an \fBscf_int_ranges_t\fR and
288 all memory associated with it.
290 .in +2
292 typedef struct scf_int_ranges {
293         int             scr_num_ranges;
294         int64_t         *scr_min;
295         int64_t         *scr_max;
296 } scf_int_ranges_t;
298 .in -2
302 The \fBscf_tmpl_value_name_choices()\fR function will retrieve the set of
303 property value choices that should be offered to a user. Some templates will
304 not specify any choices. The caller is responsible for calling
305 \fBscf_values_destroy()\fR on success.
308 The \fBscf_tmpl_value_count_range_choices()\fR function will retrieve the set
309 of defined lower and upper bounds as defined by the property template and place
310 them in ranges\fI\fR. Some templates will not specify any range choices.
313 The \fBscf_tmpl_value_int_range_constraints()\fR function will retrieve the set
314 of defined lower and upper bounds as defined by the property template and place
315 them in \fIranges\fR. Some templates will not specify any range constraints.
318 The \fBscf_tmpl_value_common_name()\fR function will retrieve the value's
319 common name as currently templated and place it in *\fIout\fR. A locale (as
320 described in \fBsetlocale\fR(3C)) can be specified, or if the supplied locale
321 is \fINULL\fR, the current locale will be used. If a common name in the
322 specified locale is not found, the function will also look for a common name in
323 the C locale. Some templates will not specify the value common name. The caller
324 is responsible for freeing the *\fIout\fR buffer on success.
327 The \fBscf_tmpl_value_description()\fR function will retrieve the value's
328 description as currently templated and place it in *\fIout\fR. A locale (as
329 described in \fBsetlocale\fR(3C)) can be specified, or if the supplied locale
330 is \fINULL\fR, the current locale will be used. If a description in the
331 specified locale is not found, the function will also look for a description in
332 the C locale. Some templates will not specify the value description. The caller
333 is responsible for freeing the *\fIout\fR buffer on success.
336 The \fBscf_tmpl_value_in_constraint()\fR function will check that the value
337 provided matches the constraints as defined in the property template provided.
338 This currently means it will determine if the value provided:
339 .RS +4
341 .ie t \(bu
342 .el o
343 is of the proper type for the property template defined,
345 .RS +4
347 .ie t \(bu
348 .el o
349 is within a range defined, if it is a numeric type, and
351 .RS +4
353 .ie t \(bu
354 .el o
355 is within the name constraints, if name constraints are defined.
359 If the template property does not define a type, ranges will be considered of
360 the same type as the numeric values being checked. Some ranges might consider
361 the value out of constraint when tested as one numeric type but within
362 constraint if tested as other numeric type. Refer to \fBstrtoull\fR(3C) and
363 \fBstrtoll\fR(3C) to see the implications when retrieving numeric values from
364 the repository or converting strings to numeric values in \fBlibscf\fR(3LIB).
367 If \fIerrs\fR is not \fINULL\fR, an \fBscf_tmpl_error_t\fR will be created,
368 populated and added to \fIerrs\fR in case of a constraint violation. The caller
369 is responsible for calling \fBscf_tmpl_errors_destroy()\fR to free memory
370 allocated for all \fBscf_tmpl_error_t\fR associated to \fIerrs\fR.
371 .SH RETURN VALUES
374 Upon successful completion, \fBscf_tmpl_prop_name()\fR,
375 \fBscf_tmpl_prop_common_name()\fR, \fBscf_tmpl_prop_description()\fR,
376 \fBscf_tmpl_prop_units()\fR, \fBscf_tmpl_value_common_name()\fR, and
377 \fBscf_tmpl_value_description()\fR return the length of the string written, not
378 including the terminating null byte. Otherwise, they return -1.
381 Upon successful completion, \fBscf_tmpl_prop_type()\fR,
382 \fBscf_tmpl_prop_required()\fR, \fBscf_tmpl_prop_visibility()\fR,
383 \fBscf_tmpl_prop_cardinality()\fR, \fBscf_tmpl_prop_internal_seps()\fR,
384 \fBscf_tmpl_value_name_constraints()\fR,
385 \fBscf_tmpl_value_count_range_constraints()\fR,
386 \fBscf_tmpl_value_int_range_constraints()\fR,
387 \fBscf_tmpl_value_name_choices()\fR,
388 \fBscf_tmpl_value_count_range_choices()\fR,
389 \fBscf_tmpl_value_int_range_choices()\fR return 0. Otherwise, they return -1.
392 The \fBscf_tmpl_value_in_constraint()\fR functions returns 0 on success, 1 if
393 the value is not in the constraint, and -1 on failure.
396 Upon successful completion, \fBscf_tmpl_visibility_to_string()\fR returns a
397 string of the visibility supplied.
398 .SH ERRORS
401 The \fBscf_tmpl_prop_name()\fR, \fBscf_tmpl_prop_type()\fR,
402 \fBscf_tmpl_prop_required()\fR, \fBscf_tmpl_prop_common_name()\fR,
403 \fBscf_tmpl_prop_description()\fR, \fBscf_tmpl_prop_units()\fR,
404 \fBscf_tmpl_prop_visibility()\fR, \fBscf_tmpl_prop_cardinality()\fR,
405 \fBscf_tmpl_prop_internal_seps()\fR, \fBscf_tmpl_value_name_constraints()\fR,
406 \fBscf_tmpl_value_count_range_constraints()\fR,
407 \fBscf_tmpl_value_int_range_constraints()\fR,
408 \fBscf_tmpl_value_name_choices()\fR,
409 \fBscf_tmpl_value_count_range_choices()\fR,
410 \fBscf_tmpl_value_int_range_choices()\fR, \fBscf_tmpl_value_common_name()\fR,
411 \fBscf_tmpl_value_description()\fR, and \fBscf_tmpl_value_in_constraint()\fR
412 functions will fail if:
414 .ne 2
416 \fB\fBSCF_ERROR_BACKEND_ACCESS\fR\fR
418 .sp .6
419 .RS 4n
420 The storage mechanism that the repository server (\fBsvc.configd\fR(8)) chose
421 for the operation denied access.
425 .ne 2
427 \fB\fBSCF_ERROR_CONNECTION_BROKEN\fR\fR
429 .sp .6
430 .RS 4n
431 The connection to the repository was lost.
435 .ne 2
437 \fB\fBSCF_ERROR_DELETED\fR\fR
439 .sp .6
440 .RS 4n
441 The template property group has been deleted.
445 .ne 2
447 \fB\fBSCF_ERROR_HANDLE_DESTROYED\fR\fR
449 .sp .6
450 .RS 4n
451 The handle passed in has been destroyed.
455 .ne 2
457 \fB\fBSCF_ERROR_INTERNAL\fR\fR
459 .sp .6
460 .RS 4n
461 An internal error occurred.
465 .ne 2
467 \fB\fBSCF_ERROR_NO_MEMORY\fR\fR
469 .sp .6
470 .RS 4n
471 There is not enough memory to populate the \fBscf_pg_tmpl_t\fR.
475 .ne 2
477 \fB\fBSCF_ERROR_NO_RESOURCES\fR\fR
479 .sp .6
480 .RS 4n
481 The server does not have adequate resources to complete the request.
485 .ne 2
487 \fB\fBSCF_ERROR_NOT_BOUND\fR\fR
489 .sp .6
490 .RS 4n
491 The handle is not currently bound.
495 .ne 2
497 \fB\fBSCF_ERROR_PERMISSION_DENIED\fR\fR
499 .sp .6
500 .RS 4n
501 The template could not be read due to access restrictions.
505 .ne 2
507 \fB\fBSCF_ERROR_TEMPLATE_INVALID\fR\fR
509 .sp .6
510 .RS 4n
511 The template data is invalid.
516 The \fBscf_tmpl_prop_type()\fR, \fBscf_tmpl_prop_common_name()\fR,
517 \fBscf_tmpl_prop_description()\fR, \fBscf_tmpl_prop_units()\fR,
518 \fBscf_tmpl_prop_cardinality()\fR, \fBscf_tmpl_prop_internal_seps()\fR,
519 \fBscf_tmpl_value_name_constraints()\fR,
520 \fBscf_tmpl_value_count_range_constraints()\fR,
521 \fBscf_tmpl_value_int_range_constraints()\fR,
522 \fBscf_tmpl_value_name_choices()\fR,
523 \fBscf_tmpl_value_count_range_choices()\fR,
524 \fBscf_tmpl_value_int_range_choices()\fR, \fBscf_tmpl_value_common_name()\fR,
525 and \fBscf_tmpl_value_description()\fR, functions will fail if:
527 .ne 2
529 \fB\fBSCF_ERROR_NOT_FOUND\fR\fR
531 .RS 23n
532 The property does not exist or exists and has no value.
537 The \fBscf_tmpl_value_in_constraint()\fR function will fail if:
539 .ne 2
541 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
543 .RS 30n
544 Value is not a valid \fBscf_value_t\fR.
549 The \fBscf_tmpl_prop_common_name()\fR, \fBscf_tmpl_prop_description()\fR and
550 \fBscf_tmpl_prop_units()\fR functions will fail if:
552 .ne 2
554 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
556 .RS 30n
557 The locale string is too long to make a property name.
562 The \fBscf_tmpl_value_common_name()\fR and \fBscf_tmpl_value_description()\fR
563 functions will fail if:
565 .ne 2
567 \fB\fBSCF_ERROR_INVALID_ARGUMENT\fR\fR
569 .RS 30n
570 The value and locale strings are too long to make a property name.
575 The \fBscf_tmpl_value_count_range_constraints()\fR and
576 \fBscf_tmpl_value_count_range_choices()\fR functions will fail if:
578 .ne 2
580 \fB\fBSCF_ERROR_CONSTRAINT_VIOLATED\fR\fR
582 .sp .6
583 .RS 4n
584 The range has negative values.
589 The \fBscf_tmpl_value_int_range_constraints()\fR and
590 \fBscf_tmpl_value_int_range_choices()\fR functions will fail if:
592 .ne 2
594 \fB\fBSCF_ERROR_CONSTRAINT_VIOLATED\fR\fR
596 .sp .6
597 .RS 4n
598 The range values don't fit in a \fBint64_t\fR.
603 The \fBscf_tmpl_value_count_range_constraints()\fR,
604 \fBscf_tmpl_value_int_range_constraints()\fR,
605 \fBscf_tmpl_value_count_range_choices()\fR and
606 \fBscf_tmpl_value_int_range_choices()\fR functions will fail if:
608 .ne 2
610 \fB\fBSCF_ERROR_CONSTRAINT_VIOLATED\fR\fR
612 .sp .6
613 .RS 4n
614 A range with \fImin\fR value > \fImax\fR value is found.
617 .SH ATTRIBUTES
620 See \fBattributes\fR(5) for descriptions of the following attributes:
625 box;
626 c | c
627 l | l .
628 ATTRIBUTE TYPE  ATTRIBUTE VALUE
630 Interface Stability     Committed
632 MT-Level        Safe
635 .SH SEE ALSO
638 \fBsvc.configd\fR(8), \fBscf_tmpl_prop_create\fR(3SCF), \fBsetlocale\fR(3C),
639 \fBstrtoll\fR(3C), \fBstrtoull\fR(3C), \fBattributes\fR(5),
640 \fBsmf_template\fR(5)