libscf.h revision 7475:9a5f7406e094
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef	_LIBSCF_H
27#define	_LIBSCF_H
28
29
30#include <stddef.h>
31#include <sys/types.h>
32
33#ifdef	__cplusplus
34extern "C" {
35#endif
36
37typedef struct scf_version *scf_version_t;
38#define	SCF_VERSION	((scf_version_t)1UL)
39
40/*
41 * Opaque structures
42 */
43typedef struct scf_handle scf_handle_t;
44typedef struct scf_scope scf_scope_t;
45typedef struct scf_service scf_service_t;
46typedef struct scf_instance scf_instance_t;
47typedef struct scf_propertygroup scf_propertygroup_t;
48typedef struct scf_property scf_property_t;
49
50typedef struct scf_snapshot scf_snapshot_t;
51typedef struct scf_snaplevel scf_snaplevel_t;
52
53typedef struct scf_transaction scf_transaction_t;
54typedef struct scf_transaction_entry scf_transaction_entry_t;
55typedef struct scf_value scf_value_t;
56
57typedef struct scf_iter scf_iter_t;
58
59typedef struct scf_simple_app_props scf_simple_app_props_t;
60typedef struct scf_simple_prop scf_simple_prop_t;
61
62/*
63 * Types
64 */
65typedef enum {
66	SCF_TYPE_INVALID = 0,
67
68	SCF_TYPE_BOOLEAN,
69	SCF_TYPE_COUNT,
70	SCF_TYPE_INTEGER,
71	SCF_TYPE_TIME,
72	SCF_TYPE_ASTRING,
73	SCF_TYPE_OPAQUE,
74
75	SCF_TYPE_USTRING = 100,
76
77	SCF_TYPE_URI = 200,
78	SCF_TYPE_FMRI,
79
80	SCF_TYPE_HOST = 300,
81	SCF_TYPE_HOSTNAME,
82	SCF_TYPE_NET_ADDR_V4,
83	SCF_TYPE_NET_ADDR_V6
84} scf_type_t;
85
86/*
87 * Return codes
88 */
89#define	SCF_SUCCESS			0
90#define	SCF_COMPLETE			1
91#define	SCF_FAILED			-1
92
93typedef enum scf_error {
94	SCF_ERROR_NONE = 1000,		/* no error */
95	SCF_ERROR_NOT_BOUND,		/* handle not bound */
96	SCF_ERROR_NOT_SET,		/* cannot use unset argument */
97	SCF_ERROR_NOT_FOUND,		/* nothing of that name found */
98	SCF_ERROR_TYPE_MISMATCH,	/* type does not match value */
99	SCF_ERROR_IN_USE,		/* cannot modify while in-use */
100	SCF_ERROR_CONNECTION_BROKEN,	/* repository connection gone */
101	SCF_ERROR_INVALID_ARGUMENT,	/* bad argument */
102	SCF_ERROR_NO_MEMORY,		/* no memory available */
103	SCF_ERROR_CONSTRAINT_VIOLATED,	/* required constraint not met */
104	SCF_ERROR_EXISTS,		/* object already exists */
105	SCF_ERROR_NO_SERVER,		/* repository server unavailable */
106	SCF_ERROR_NO_RESOURCES,		/* server has insufficient resources */
107	SCF_ERROR_PERMISSION_DENIED,	/* insufficient privileges for action */
108	SCF_ERROR_BACKEND_ACCESS,	/* backend refused access */
109	SCF_ERROR_HANDLE_MISMATCH,	/* mismatched SCF handles */
110	SCF_ERROR_HANDLE_DESTROYED,	/* object bound to destroyed handle */
111	SCF_ERROR_VERSION_MISMATCH,	/* incompatible SCF version */
112	SCF_ERROR_BACKEND_READONLY,	/* backend is read-only */
113	SCF_ERROR_DELETED,		/* object has been deleted */
114
115	SCF_ERROR_CALLBACK_FAILED = 1080, /* user callback function failed */
116
117	SCF_ERROR_INTERNAL = 1101	/* internal error */
118} scf_error_t;
119
120/*
121 * Standard services
122 */
123#define	SCF_SERVICE_STARTD	((const char *) \
124				    "svc:/system/svc/restarter:default")
125#define	SCF_SERVICE_CONFIGD	((const char *) \
126				    "svc:/system/svc/repository:default")
127
128/*
129 * Major milestones
130 */
131#define	SCF_MILESTONE_SINGLE_USER \
132	((const char *) "svc:/milestone/single-user:default")
133#define	SCF_MILESTONE_MULTI_USER \
134	((const char *) "svc:/milestone/multi-user:default")
135#define	SCF_MILESTONE_MULTI_USER_SERVER \
136	((const char *) "svc:/milestone/multi-user-server:default")
137
138/*
139 * standard scope names
140 */
141#define	SCF_SCOPE_LOCAL			((const char *)"localhost")
142
143/*
144 * Property group types
145 */
146#define	SCF_GROUP_APPLICATION		((const char *)"application")
147#define	SCF_GROUP_FRAMEWORK		((const char *)"framework")
148#define	SCF_GROUP_DEPENDENCY		((const char *)"dependency")
149#define	SCF_GROUP_METHOD		((const char *)"method")
150#define	SCF_GROUP_TEMPLATE		((const char *)"template")
151
152/*
153 * Dependency types
154 */
155#define	SCF_DEP_REQUIRE_ALL		((const char *)"require_all")
156#define	SCF_DEP_REQUIRE_ANY		((const char *)"require_any")
157#define	SCF_DEP_EXCLUDE_ALL		((const char *)"exclude_all")
158#define	SCF_DEP_OPTIONAL_ALL		((const char *)"optional_all")
159
160#define	SCF_DEP_RESET_ON_ERROR		((const char *)"error")
161#define	SCF_DEP_RESET_ON_RESTART	((const char *)"restart")
162#define	SCF_DEP_RESET_ON_REFRESH	((const char *)"refresh")
163#define	SCF_DEP_RESET_ON_NONE		((const char *)"none")
164
165/*
166 * Standard property group names
167 */
168#define	SCF_PG_GENERAL			((const char *)"general")
169#define	SCF_PG_GENERAL_OVR		((const char *)"general_ovr")
170#define	SCF_PG_RESTARTER		((const char *)"restarter")
171#define	SCF_PG_RESTARTER_ACTIONS	((const char *)"restarter_actions")
172#define	SCF_PG_METHOD_CONTEXT		((const char *)"method_context")
173#define	SCF_PG_APP_DEFAULT		((const char *)"application")
174#define	SCF_PG_DEPENDENTS		((const char *)"dependents")
175#define	SCF_PG_OPTIONS			((const char *)"options")
176#define	SCF_PG_OPTIONS_OVR		((const char *)"options_ovr")
177#define	SCF_PG_STARTD			((const char *)"startd")
178#define	SCF_PG_STARTD_PRIVATE		((const char *)"svc-startd-private")
179#define	SCF_PG_DEATHROW			((const char *)"deathrow")
180
181/*
182 * Template property group names and prefix
183 */
184#define	SCF_PG_TM_COMMON_NAME		((const char *)"tm_common_name")
185#define	SCF_PG_TM_DESCRIPTION		((const char *)"tm_description")
186
187#define	SCF_PG_TM_MAN_PREFIX		((const char *)"tm_man_")
188#define	SCF_PG_TM_DOC_PREFIX		((const char *)"tm_doc_")
189
190/*
191 * Standard property names
192 */
193#define	SCF_PROPERTY_AUX_STATE		((const char *)"auxiliary_state")
194#define	SCF_PROPERTY_CONTRACT		((const char *)"contract")
195#define	SCF_PROPERTY_COREFILE_PATTERN	((const char *)"corefile_pattern")
196#define	SCF_PROPERTY_DEGRADED		((const char *)"degraded")
197#define	SCF_PROPERTY_DEGRADE_IMMEDIATE	((const char *)"degrade_immediate")
198#define	SCF_PROPERTY_DURATION		((const char *)"duration")
199#define	SCF_PROPERTY_ENABLED		((const char *)"enabled")
200#define	SCF_PROPERTY_DEATHROW		((const char *)"deathrow")
201#define	SCF_PROPERTY_ENTITY_STABILITY	((const char *)"entity_stability")
202#define	SCF_PROPERTY_ENTITIES		((const char *)"entities")
203#define	SCF_PROPERTY_EXEC		((const char *)"exec")
204#define	SCF_PROPERTY_GROUP		((const char *)"group")
205#define	SCF_PROPERTY_GROUPING		((const char *)"grouping")
206#define	SCF_PROPERTY_IGNORE		((const char *)"ignore_error")
207#define	SCF_PROPERTY_LIMIT_PRIVILEGES	((const char *)"limit_privileges")
208#define	SCF_PROPERTY_MAINT_OFF		((const char *)"maint_off")
209#define	SCF_PROPERTY_MAINT_ON		((const char *)"maint_on")
210#define	SCF_PROPERTY_MAINT_ON_IMMEDIATE	((const char *)"maint_on_immediate")
211#define	SCF_PROPERTY_MAINT_ON_IMMTEMP	((const char *)"maint_on_immtemp")
212#define	SCF_PROPERTY_MAINT_ON_TEMPORARY	((const char *)"maint_on_temporary")
213#define	SCF_PROPERTY_METHOD_PID		((const char *)"method_pid")
214#define	SCF_PROPERTY_MILESTONE		((const char *)"milestone")
215#define	SCF_PROPERTY_NEED_SESSION	((const char *)"need_session")
216#define	SCF_PROPERTY_NEXT_STATE		((const char *)"next_state")
217#define	SCF_PROPERTY_PACKAGE		((const char *)"package")
218#define	SCF_PROPERTY_PRIVILEGES		((const char *)"privileges")
219#define	SCF_PROPERTY_PROFILE		((const char *)"profile")
220#define	SCF_PROPERTY_PROJECT		((const char *)"project")
221#define	SCF_PROPERTY_REFRESH		((const char *)"refresh")
222#define	SCF_PROPERTY_RESOURCE_POOL	((const char *)"resource_pool")
223#define	SCF_PROPERTY_ENVIRONMENT	((const char *)"environment")
224#define	SCF_PROPERTY_RESTART		((const char *)"restart")
225#define	SCF_PROPERTY_RESTARTER		((const char *)"restarter")
226#define	SCF_PROPERTY_RESTART_INTERVAL	((const char *)"restart_interval")
227#define	SCF_PROPERTY_RESTART_ON		((const char *)"restart_on")
228#define	SCF_PROPERTY_RESTORE		((const char *)"restore")
229#define	SCF_PROPERTY_SINGLE_INSTANCE	((const char *)"single_instance")
230#define	SCF_PROPERTY_START_METHOD_TIMESTAMP	\
231	((const char *)"start_method_timestamp")
232#define	SCF_PROPERTY_START_METHOD_WAITSTATUS	\
233	((const char *)"start_method_waitstatus")
234#define	SCF_PROPERTY_START_PID		((const char *)"start_pid")
235#define	SCF_PROPERTY_STATE		((const char *)"state")
236#define	SCF_PROPERTY_STABILITY		((const char *)"stability")
237#define	SCF_PROPERTY_STATE_TIMESTAMP	((const char *)"state_timestamp")
238#define	SCF_PROPERTY_SUPP_GROUPS	((const char *)"supp_groups")
239#define	SCF_PROPERTY_TIMEOUT		((const char *)"timeout_seconds")
240#define	SCF_PROPERTY_TIMEOUT_RETRY	((const char *)"timeout_retry")
241#define	SCF_PROPERTY_TRANSIENT_CONTRACT	((const char *)"transient_contract")
242#define	SCF_PROPERTY_TYPE		((const char *)"type")
243#define	SCF_PROPERTY_USE_PROFILE	((const char *)"use_profile")
244#define	SCF_PROPERTY_USER		((const char *)"user")
245#define	SCF_PROPERTY_UTMPX_PREFIX	((const char *)"utmpx_prefix")
246#define	SCF_PROPERTY_WORKING_DIRECTORY	((const char *)"working_directory")
247
248/*
249 * Template property names
250 */
251#define	SCF_PROPERTY_TM_MANPATH		((const char *)"manpath")
252#define	SCF_PROPERTY_TM_SECTION		((const char *)"section")
253#define	SCF_PROPERTY_TM_TITLE		((const char *)"title")
254#define	SCF_PROPERTY_TM_NAME		((const char *)"name")
255#define	SCF_PROPERTY_TM_URI		((const char *)"uri")
256
257/*
258 * Strings used by restarters for state and next_state properties.
259 * MAX_SCF_STATE_STRING holds the max length of a state string, including the
260 * terminating null.
261 */
262
263#define	MAX_SCF_STATE_STRING_SZ		14
264
265#define	SCF_STATE_STRING_NONE		((const char *)"none")
266#define	SCF_STATE_STRING_UNINIT		((const char *)"uninitialized")
267#define	SCF_STATE_STRING_MAINT		((const char *)"maintenance")
268#define	SCF_STATE_STRING_OFFLINE	((const char *)"offline")
269#define	SCF_STATE_STRING_DISABLED	((const char *)"disabled")
270#define	SCF_STATE_STRING_ONLINE		((const char *)"online")
271#define	SCF_STATE_STRING_DEGRADED	((const char *)"degraded")
272#define	SCF_STATE_STRING_LEGACY		((const char *)"legacy_run")
273
274#define	SCF_STATE_UNINIT		0x00000001
275#define	SCF_STATE_MAINT			0x00000002
276#define	SCF_STATE_OFFLINE		0x00000004
277#define	SCF_STATE_DISABLED		0x00000008
278#define	SCF_STATE_ONLINE		0x00000010
279#define	SCF_STATE_DEGRADED		0x00000020
280#define	SCF_STATE_ALL			0x0000003F
281
282#define	SCF_PG_FLAG_NONPERSISTENT	0x1
283
284#define	SCF_TRACE_LIBRARY		0x1
285#define	SCF_TRACE_DAEMON		0x2
286
287#define	SMF_IMMEDIATE			0x1
288#define	SMF_TEMPORARY			0x2
289#define	SMF_AT_NEXT_BOOT		0x4
290
291scf_error_t scf_error(void);
292const char *scf_strerror(scf_error_t);
293
294ssize_t scf_limit(uint32_t code);
295#define	SCF_LIMIT_MAX_NAME_LENGTH	-2000U
296#define	SCF_LIMIT_MAX_VALUE_LENGTH	-2001U
297#define	SCF_LIMIT_MAX_PG_TYPE_LENGTH	-2002U
298#define	SCF_LIMIT_MAX_FMRI_LENGTH	-2003U
299
300scf_handle_t *scf_handle_create(scf_version_t);
301
302int scf_handle_decorate(scf_handle_t *, const char *, scf_value_t *);
303#define	SCF_DECORATE_CLEAR	((scf_value_t *)0)
304
305int scf_handle_bind(scf_handle_t *);
306int scf_handle_unbind(scf_handle_t *);
307void scf_handle_destroy(scf_handle_t *);
308
309int scf_type_base_type(scf_type_t type, scf_type_t *out);
310
311/* values */
312scf_value_t *scf_value_create(scf_handle_t *);
313scf_handle_t *scf_value_handle(const scf_value_t *);
314void scf_value_destroy(scf_value_t *);
315
316scf_type_t scf_value_base_type(const scf_value_t *);
317scf_type_t scf_value_type(const scf_value_t *);
318int scf_value_is_type(const scf_value_t *, scf_type_t);
319
320void scf_value_reset(scf_value_t *);
321
322int scf_value_get_boolean(const scf_value_t *, uint8_t *);
323int scf_value_get_count(const scf_value_t *, uint64_t *);
324int scf_value_get_integer(const scf_value_t *, int64_t *);
325int scf_value_get_time(const scf_value_t *, int64_t *, int32_t *);
326ssize_t scf_value_get_astring(const scf_value_t *, char *, size_t);
327ssize_t scf_value_get_ustring(const scf_value_t *, char *, size_t);
328ssize_t scf_value_get_opaque(const scf_value_t *, void *, size_t);
329
330void scf_value_set_boolean(scf_value_t *, uint8_t);
331void scf_value_set_count(scf_value_t *, uint64_t);
332void scf_value_set_integer(scf_value_t *, int64_t);
333int scf_value_set_time(scf_value_t *, int64_t, int32_t);
334int scf_value_set_astring(scf_value_t *, const char *);
335int scf_value_set_ustring(scf_value_t *, const char *);
336int scf_value_set_opaque(scf_value_t *, const void *, size_t);
337
338ssize_t scf_value_get_as_string(const scf_value_t *, char *, size_t);
339ssize_t scf_value_get_as_string_typed(const scf_value_t *, scf_type_t,
340    char *, size_t);
341int scf_value_set_from_string(scf_value_t *, scf_type_t, const char *);
342
343scf_iter_t *scf_iter_create(scf_handle_t *);
344scf_handle_t *scf_iter_handle(const scf_iter_t *);
345void scf_iter_reset(scf_iter_t *);
346void scf_iter_destroy(scf_iter_t *);
347
348int scf_iter_handle_scopes(scf_iter_t *, const scf_handle_t *);
349int scf_iter_scope_services(scf_iter_t *, const scf_scope_t *);
350int scf_iter_service_instances(scf_iter_t *, const scf_service_t *);
351int scf_iter_service_pgs(scf_iter_t *, const scf_service_t *);
352int scf_iter_instance_pgs(scf_iter_t *, const scf_instance_t *);
353int scf_iter_instance_pgs_composed(scf_iter_t *, const scf_instance_t *,
354    const scf_snapshot_t *);
355int scf_iter_service_pgs_typed(scf_iter_t *, const scf_service_t *,
356    const char *);
357int scf_iter_instance_pgs_typed(scf_iter_t *, const scf_instance_t *,
358    const char *);
359int scf_iter_instance_pgs_typed_composed(scf_iter_t *, const scf_instance_t *,
360    const scf_snapshot_t *, const char *);
361int scf_iter_snaplevel_pgs(scf_iter_t *, const scf_snaplevel_t *);
362int scf_iter_snaplevel_pgs_typed(scf_iter_t *, const scf_snaplevel_t *,
363    const char *);
364int scf_iter_instance_snapshots(scf_iter_t *, const scf_instance_t *);
365int scf_iter_pg_properties(scf_iter_t *, const scf_propertygroup_t *);
366int scf_iter_property_values(scf_iter_t *, const scf_property_t *);
367
368int scf_iter_next_scope(scf_iter_t *, scf_scope_t *);
369int scf_iter_next_service(scf_iter_t *, scf_service_t *);
370int scf_iter_next_instance(scf_iter_t *, scf_instance_t *);
371int scf_iter_next_pg(scf_iter_t *, scf_propertygroup_t *);
372int scf_iter_next_property(scf_iter_t *, scf_property_t *);
373int scf_iter_next_snapshot(scf_iter_t *, scf_snapshot_t *);
374int scf_iter_next_value(scf_iter_t *, scf_value_t *);
375
376scf_scope_t *scf_scope_create(scf_handle_t *);
377scf_handle_t *scf_scope_handle(const scf_scope_t *);
378
379/* XXX eventually remove this */
380#define	scf_handle_get_local_scope(h, s) \
381	scf_handle_get_scope((h), SCF_SCOPE_LOCAL, (s))
382
383int scf_handle_get_scope(scf_handle_t *, const char *, scf_scope_t *);
384void scf_scope_destroy(scf_scope_t *);
385ssize_t scf_scope_get_name(const scf_scope_t *, char *, size_t);
386
387ssize_t scf_scope_to_fmri(const scf_scope_t *, char *, size_t);
388
389scf_service_t *scf_service_create(scf_handle_t *);
390scf_handle_t *scf_service_handle(const scf_service_t *);
391void scf_service_destroy(scf_service_t *);
392int scf_scope_get_parent(const scf_scope_t *, scf_scope_t *);
393ssize_t scf_service_get_name(const scf_service_t *, char *, size_t);
394ssize_t scf_service_to_fmri(const scf_service_t *, char *, size_t);
395int scf_service_get_parent(const scf_service_t *, scf_scope_t *);
396int scf_scope_get_service(const scf_scope_t *, const char *, scf_service_t *);
397int scf_scope_add_service(const scf_scope_t *, const char *, scf_service_t *);
398int scf_service_delete(scf_service_t *);
399
400scf_instance_t *scf_instance_create(scf_handle_t *);
401scf_handle_t *scf_instance_handle(const scf_instance_t *);
402void scf_instance_destroy(scf_instance_t *);
403ssize_t scf_instance_get_name(const scf_instance_t *, char *, size_t);
404ssize_t scf_instance_to_fmri(const scf_instance_t *, char *, size_t);
405int scf_service_get_instance(const scf_service_t *, const char *,
406    scf_instance_t *);
407int scf_service_add_instance(const scf_service_t *, const char *,
408    scf_instance_t *);
409int scf_instance_delete(scf_instance_t *);
410
411scf_snapshot_t *scf_snapshot_create(scf_handle_t *);
412scf_handle_t *scf_snapshot_handle(const scf_snapshot_t *);
413void scf_snapshot_destroy(scf_snapshot_t *);
414ssize_t scf_snapshot_get_name(const scf_snapshot_t *, char *, size_t);
415int scf_snapshot_get_parent(const scf_snapshot_t *, scf_instance_t *);
416int scf_instance_get_snapshot(const scf_instance_t *, const char *,
417    scf_snapshot_t *);
418int scf_snapshot_update(scf_snapshot_t *);
419
420scf_snaplevel_t *scf_snaplevel_create(scf_handle_t *);
421scf_handle_t *scf_snaplevel_handle(const scf_snaplevel_t *);
422void scf_snaplevel_destroy(scf_snaplevel_t *);
423int scf_snaplevel_get_parent(const scf_snaplevel_t *, scf_snapshot_t *);
424ssize_t scf_snaplevel_get_scope_name(const scf_snaplevel_t *, char *, size_t);
425ssize_t scf_snaplevel_get_service_name(const scf_snaplevel_t *, char *, size_t);
426ssize_t scf_snaplevel_get_instance_name(const scf_snaplevel_t *, char *,
427    size_t);
428int scf_snaplevel_get_pg(const scf_snaplevel_t *, const char *,
429    scf_propertygroup_t *pg);
430int scf_snapshot_get_base_snaplevel(const scf_snapshot_t *, scf_snaplevel_t *);
431int scf_snaplevel_get_next_snaplevel(const scf_snaplevel_t *,
432    scf_snaplevel_t *);
433
434scf_propertygroup_t *scf_pg_create(scf_handle_t *);
435scf_handle_t *scf_pg_handle(const scf_propertygroup_t *);
436void scf_pg_destroy(scf_propertygroup_t *);
437ssize_t scf_pg_to_fmri(const scf_propertygroup_t *,  char *, size_t);
438ssize_t scf_pg_get_name(const scf_propertygroup_t *, char *, size_t);
439ssize_t scf_pg_get_type(const scf_propertygroup_t *, char *, size_t);
440int scf_pg_get_flags(const scf_propertygroup_t *, uint32_t *);
441int scf_pg_get_parent_service(const scf_propertygroup_t *, scf_service_t *);
442int scf_pg_get_parent_instance(const scf_propertygroup_t *, scf_instance_t *);
443int scf_pg_get_parent_snaplevel(const scf_propertygroup_t *, scf_snaplevel_t *);
444int scf_service_get_pg(const scf_service_t *, const char *,
445    scf_propertygroup_t *);
446int scf_instance_get_pg(const scf_instance_t *, const char *,
447    scf_propertygroup_t *);
448int scf_instance_get_pg_composed(const scf_instance_t *, const scf_snapshot_t *,
449    const char *, scf_propertygroup_t *);
450int scf_service_add_pg(const scf_service_t *,  const char *, const char *,
451    uint32_t, scf_propertygroup_t *);
452int scf_instance_add_pg(const scf_instance_t *,  const char *, const char *,
453    uint32_t, scf_propertygroup_t *);
454int scf_pg_delete(scf_propertygroup_t *);
455
456int scf_pg_get_underlying_pg(const scf_propertygroup_t *,
457    scf_propertygroup_t *);
458int scf_instance_get_parent(const scf_instance_t *, scf_service_t *);
459
460int scf_pg_update(scf_propertygroup_t *);
461
462scf_property_t *scf_property_create(scf_handle_t *);
463scf_handle_t *scf_property_handle(const scf_property_t *);
464void scf_property_destroy(scf_property_t *);
465int scf_property_is_type(const scf_property_t *, scf_type_t);
466int scf_property_type(const scf_property_t *, scf_type_t *);
467ssize_t scf_property_get_name(const scf_property_t *, char *, size_t);
468int scf_property_get_value(const scf_property_t *, scf_value_t *);
469ssize_t scf_property_to_fmri(const scf_property_t *, char *, size_t);
470int scf_pg_get_property(const scf_propertygroup_t *,  const char *,
471    scf_property_t *);
472
473scf_transaction_t *scf_transaction_create(scf_handle_t *);
474scf_handle_t *scf_transaction_handle(const scf_transaction_t *);
475int scf_transaction_start(scf_transaction_t *, scf_propertygroup_t *);
476void scf_transaction_destroy(scf_transaction_t *);
477void scf_transaction_destroy_children(scf_transaction_t *);
478
479void scf_transaction_reset(scf_transaction_t *);
480void scf_transaction_reset_all(scf_transaction_t *);
481
482int scf_transaction_commit(scf_transaction_t *);
483
484scf_transaction_entry_t *scf_entry_create(scf_handle_t *);
485scf_handle_t *scf_entry_handle(const scf_transaction_entry_t *);
486void scf_entry_reset(scf_transaction_entry_t *);
487void scf_entry_destroy(scf_transaction_entry_t *);
488void scf_entry_destroy_children(scf_transaction_entry_t *);
489
490int scf_transaction_property_change(scf_transaction_t *,
491    scf_transaction_entry_t *, const char *, scf_type_t);
492int scf_transaction_property_delete(scf_transaction_t *,
493    scf_transaction_entry_t *, const char *);
494int scf_transaction_property_new(scf_transaction_t *,
495    scf_transaction_entry_t *, const char *, scf_type_t);
496int scf_transaction_property_change_type(scf_transaction_t *,
497    scf_transaction_entry_t *, const char *, scf_type_t);
498
499int scf_entry_add_value(scf_transaction_entry_t *, scf_value_t *);
500
501int scf_handle_decode_fmri(scf_handle_t *, const char *, scf_scope_t *,
502    scf_service_t *, scf_instance_t *, scf_propertygroup_t *, scf_property_t *,
503    int);
504#define	SCF_DECODE_FMRI_EXACT			0x00000001
505#define	SCF_DECODE_FMRI_TRUNCATE		0x00000002
506#define	SCF_DECODE_FMRI_REQUIRE_INSTANCE	0x00000004
507#define	SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE	0x00000008
508
509ssize_t scf_myname(scf_handle_t *, char *, size_t);
510
511/*
512 * Simplified calls
513 */
514
515int smf_enable_instance(const char *, int);
516int smf_disable_instance(const char *, int);
517int smf_refresh_instance(const char *);
518int smf_restart_instance(const char *);
519int smf_maintain_instance(const char *, int);
520int smf_degrade_instance(const char *, int);
521int smf_restore_instance(const char *);
522char *smf_get_state(const char *);
523
524int scf_simple_walk_instances(uint_t, void *,
525    int (*inst_callback)(scf_handle_t *, scf_instance_t *, void *));
526
527scf_simple_prop_t *scf_simple_prop_get(scf_handle_t *, const char *,
528    const char *, const char *);
529void scf_simple_prop_free(scf_simple_prop_t *);
530scf_simple_app_props_t *scf_simple_app_props_get(scf_handle_t *, const char *);
531void scf_simple_app_props_free(scf_simple_app_props_t *);
532const scf_simple_prop_t *scf_simple_app_props_next(
533    const scf_simple_app_props_t *, scf_simple_prop_t *);
534const scf_simple_prop_t *scf_simple_app_props_search(
535    const scf_simple_app_props_t *, const char *, const char *);
536ssize_t scf_simple_prop_numvalues(const scf_simple_prop_t *);
537scf_type_t scf_simple_prop_type(const scf_simple_prop_t *);
538char *scf_simple_prop_name(const scf_simple_prop_t *);
539char *scf_simple_prop_pgname(const scf_simple_prop_t *);
540uint8_t *scf_simple_prop_next_boolean(scf_simple_prop_t *);
541uint64_t *scf_simple_prop_next_count(scf_simple_prop_t *);
542int64_t *scf_simple_prop_next_integer(scf_simple_prop_t *);
543int64_t *scf_simple_prop_next_time(scf_simple_prop_t *, int32_t *);
544char *scf_simple_prop_next_astring(scf_simple_prop_t *);
545char *scf_simple_prop_next_ustring(scf_simple_prop_t *);
546void *scf_simple_prop_next_opaque(scf_simple_prop_t *, size_t *);
547void scf_simple_prop_next_reset(scf_simple_prop_t *);
548
549/*
550 * SMF exit status definitions
551 */
552#define	SMF_EXIT_OK		  0
553#define	SMF_EXIT_ERR_FATAL	 95
554#define	SMF_EXIT_ERR_CONFIG	 96
555#define	SMF_EXIT_MON_DEGRADE	 97
556#define	SMF_EXIT_MON_OFFLINE	 98
557#define	SMF_EXIT_ERR_NOSMF	 99
558#define	SMF_EXIT_ERR_PERM	100
559
560#ifdef	__cplusplus
561}
562#endif
563
564#endif	/* _LIBSCF_H */
565