10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55040Swesolows * Common Development and Distribution License (the "License"). 65040Swesolows * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 215040Swesolows 220Sstevel@tonic-gate /* 2312667SSean.Wilcox@Sun.COM * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _CMD_SVCCFG_H 270Sstevel@tonic-gate #define _CMD_SVCCFG_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate 300Sstevel@tonic-gate #include <sys/types.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <libxml/tree.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <libscf.h> 3511996SThomas.Whitten@Sun.COM #include <libscf_priv.h> 360Sstevel@tonic-gate #include <libtecla.h> 370Sstevel@tonic-gate #include <libuutil.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #ifdef __cplusplus 400Sstevel@tonic-gate extern "C" { 410Sstevel@tonic-gate #endif 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* Command scope bits for command tab completion */ 440Sstevel@tonic-gate #define CS_SCOPE 0x01 450Sstevel@tonic-gate #define CS_SVC 0x02 460Sstevel@tonic-gate #define CS_INST 0x04 470Sstevel@tonic-gate #define CS_SNAP 0x08 480Sstevel@tonic-gate #define CS_GLOBAL 0x0f 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* Flags for lscf_bundle_import() & co. */ 510Sstevel@tonic-gate #define SCI_NOREFRESH 0x01 /* Don't refresh instances */ 520Sstevel@tonic-gate #define SCI_GENERALLAST 0x04 /* Add general property group last */ 530Sstevel@tonic-gate #define SCI_NOENABLED 0x08 /* Don't import general/enabled. */ 540Sstevel@tonic-gate #define SCI_FRESH 0x10 /* Freshly imported service */ 550Sstevel@tonic-gate #define SCI_FORCE 0x20 /* Override-import. */ 560Sstevel@tonic-gate #define SCI_KEEP 0x40 /* Don't delete when SCI_FORCEing */ 575040Swesolows #define SCI_NOSNAP 0x80 /* Don't take last-import snapshot */ 588323SSean.Wilcox@Sun.COM #define SCI_DELAYENABLE 0x100 /* Delay the general/enable property */ 595040Swesolows 6012667SSean.Wilcox@Sun.COM #define SCI_OP_IMPORT 0x1000 6112667SSean.Wilcox@Sun.COM #define SCI_OP_APPLY 0x2000 6212667SSean.Wilcox@Sun.COM #define SCI_OP_RESTORE 0x4000 6312667SSean.Wilcox@Sun.COM 6411996SThomas.Whitten@Sun.COM #define HASH_SVC "smf/manifest" 6511996SThomas.Whitten@Sun.COM 6611996SThomas.Whitten@Sun.COM /* 6711996SThomas.Whitten@Sun.COM * If the filesystem/minimal service is not online, do not consider 6811996SThomas.Whitten@Sun.COM * manifests in the /var file system. 6911996SThomas.Whitten@Sun.COM */ 7011996SThomas.Whitten@Sun.COM #define IGNORE_VAR (!est->sc_fs_minimal) 7111996SThomas.Whitten@Sun.COM 725040Swesolows /* Flags for lscf_service_export() */ 735040Swesolows #define SCE_ALL_VALUES 0x01 /* Include all property values */ 740Sstevel@tonic-gate 750Sstevel@tonic-gate #ifdef lint 760Sstevel@tonic-gate extern int yyerror(const char *); 770Sstevel@tonic-gate extern int yyparse(void); 780Sstevel@tonic-gate #endif /* lint */ 790Sstevel@tonic-gate 800Sstevel@tonic-gate extern int lex_lineno; 810Sstevel@tonic-gate 820Sstevel@tonic-gate #define MANIFEST_DTD_PATH "/usr/share/lib/xml/dtd/service_bundle.dtd.1" 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * The following list must be kept in the same order as that of 850Sstevel@tonic-gate * lxml_prop_types[] 860Sstevel@tonic-gate */ 870Sstevel@tonic-gate typedef enum element { 8812691SAntonello.Cruz@Sun.COM SC_ASTRING = 0, 8912691SAntonello.Cruz@Sun.COM SC_BOOLEAN, 9012691SAntonello.Cruz@Sun.COM SC_CARDINALITY, 9112691SAntonello.Cruz@Sun.COM SC_CHOICES, 9212691SAntonello.Cruz@Sun.COM SC_COMMON_NAME, 9312691SAntonello.Cruz@Sun.COM SC_CONSTRAINTS, 9412691SAntonello.Cruz@Sun.COM SC_COUNT, 9512691SAntonello.Cruz@Sun.COM SC_INSTANCE_CREATE_DEFAULT, 9612691SAntonello.Cruz@Sun.COM SC_DEPENDENCY, 9712691SAntonello.Cruz@Sun.COM SC_DEPENDENT, 9812691SAntonello.Cruz@Sun.COM SC_DESCRIPTION, 9912691SAntonello.Cruz@Sun.COM SC_DOC_LINK, 10012691SAntonello.Cruz@Sun.COM SC_DOCUMENTATION, 10112691SAntonello.Cruz@Sun.COM SC_ENABLED, 102*12967Sgavin.maltby@oracle.com SC_EVENT, 10312691SAntonello.Cruz@Sun.COM SC_EXEC_METHOD, 10412691SAntonello.Cruz@Sun.COM SC_FMRI, 10512691SAntonello.Cruz@Sun.COM SC_HOST, 10612691SAntonello.Cruz@Sun.COM SC_HOSTNAME, 10712691SAntonello.Cruz@Sun.COM SC_INCLUDE_VALUES, 10812691SAntonello.Cruz@Sun.COM SC_INSTANCE, 10912691SAntonello.Cruz@Sun.COM SC_INTEGER, 11012691SAntonello.Cruz@Sun.COM SC_INTERNAL_SEPARATORS, 11112691SAntonello.Cruz@Sun.COM SC_LOCTEXT, 11212691SAntonello.Cruz@Sun.COM SC_MANPAGE, 11312691SAntonello.Cruz@Sun.COM SC_METHOD_CONTEXT, 11412691SAntonello.Cruz@Sun.COM SC_METHOD_CREDENTIAL, 11512691SAntonello.Cruz@Sun.COM SC_METHOD_PROFILE, 11612691SAntonello.Cruz@Sun.COM SC_METHOD_ENVIRONMENT, 11712691SAntonello.Cruz@Sun.COM SC_METHOD_ENVVAR, 11812691SAntonello.Cruz@Sun.COM SC_NET_ADDR, 11912691SAntonello.Cruz@Sun.COM SC_NET_ADDR_V4, 12012691SAntonello.Cruz@Sun.COM SC_NET_ADDR_V6, 121*12967Sgavin.maltby@oracle.com SC_NOTIFICATION_PARAMETERS, 12212691SAntonello.Cruz@Sun.COM SC_OPAQUE, 123*12967Sgavin.maltby@oracle.com SC_PARAMETER, 124*12967Sgavin.maltby@oracle.com SC_PARAMVAL, 12512691SAntonello.Cruz@Sun.COM SC_PG_PATTERN, 12612691SAntonello.Cruz@Sun.COM SC_PROP_PATTERN, 12712691SAntonello.Cruz@Sun.COM SC_PROPERTY, 12812691SAntonello.Cruz@Sun.COM SC_PROPERTY_GROUP, 12912691SAntonello.Cruz@Sun.COM SC_PROPVAL, 13012691SAntonello.Cruz@Sun.COM SC_RANGE, 13112691SAntonello.Cruz@Sun.COM SC_RESTARTER, 13212691SAntonello.Cruz@Sun.COM SC_SERVICE, 13312691SAntonello.Cruz@Sun.COM SC_SERVICE_BUNDLE, 13412691SAntonello.Cruz@Sun.COM SC_SERVICE_FMRI, 13512691SAntonello.Cruz@Sun.COM SC_INSTANCE_SINGLE, 13612691SAntonello.Cruz@Sun.COM SC_STABILITY, 13712691SAntonello.Cruz@Sun.COM SC_TEMPLATE, 13812691SAntonello.Cruz@Sun.COM SC_TIME, 139*12967Sgavin.maltby@oracle.com SC_TYPE, 14012691SAntonello.Cruz@Sun.COM SC_UNITS, 14112691SAntonello.Cruz@Sun.COM SC_URI, 14212691SAntonello.Cruz@Sun.COM SC_USTRING, 14312691SAntonello.Cruz@Sun.COM SC_VALUE, 14412691SAntonello.Cruz@Sun.COM SC_VALUE_NODE, 14512691SAntonello.Cruz@Sun.COM SC_VALUES, 14612691SAntonello.Cruz@Sun.COM SC_VISIBILITY, 14712691SAntonello.Cruz@Sun.COM SC_XI_FALLBACK, 14812691SAntonello.Cruz@Sun.COM SC_XI_INCLUDE 1490Sstevel@tonic-gate } element_t; 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate typedef enum bundle_type { 1520Sstevel@tonic-gate SVCCFG_UNKNOWN_BUNDLE, SVCCFG_MANIFEST, SVCCFG_PROFILE, SVCCFG_ARCHIVE 1530Sstevel@tonic-gate } bundle_type_t; 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate typedef struct bundle { 1560Sstevel@tonic-gate uu_list_t *sc_bundle_services; 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate xmlChar *sc_bundle_name; 1590Sstevel@tonic-gate bundle_type_t sc_bundle_type; 1600Sstevel@tonic-gate } bundle_t; 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate typedef enum service_type { 1630Sstevel@tonic-gate SVCCFG_UNKNOWN_SERVICE = 0x0, SVCCFG_SERVICE, SVCCFG_RESTARTER, 1640Sstevel@tonic-gate SVCCFG_MILESTONE 1650Sstevel@tonic-gate } service_type_t; 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate typedef enum entity_type { 1687887SLiane.Praza@Sun.COM SVCCFG_SERVICE_OBJECT = 0x0, SVCCFG_INSTANCE_OBJECT 1690Sstevel@tonic-gate } entity_type_t; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate enum import_state { 1720Sstevel@tonic-gate IMPORT_NONE = 0, 1730Sstevel@tonic-gate IMPORT_PREVIOUS, 1740Sstevel@tonic-gate IMPORT_PROP_BEGUN, 1750Sstevel@tonic-gate IMPORT_PROP_DONE, 1760Sstevel@tonic-gate IMPORT_COMPLETE, 1770Sstevel@tonic-gate IMPORT_REFRESHED 1780Sstevel@tonic-gate }; 1790Sstevel@tonic-gate 1805040Swesolows typedef enum svccfg_op { 18112667SSean.Wilcox@Sun.COM SVCCFG_OP_NONE = -1, 1825040Swesolows SVCCFG_OP_IMPORT = 0, 1835040Swesolows SVCCFG_OP_APPLY, 1845040Swesolows SVCCFG_OP_RESTORE 1855040Swesolows } svccfg_op_t; 1865040Swesolows 1877887SLiane.Praza@Sun.COM /* 1887887SLiane.Praza@Sun.COM * Return values for functions that validate an entity against the templates. 1897887SLiane.Praza@Sun.COM */ 1907887SLiane.Praza@Sun.COM typedef enum tmpl_validate_status { 1917887SLiane.Praza@Sun.COM TVS_SUCCESS = 0, 1927887SLiane.Praza@Sun.COM /* 1937887SLiane.Praza@Sun.COM * Either conversion of ASTRING property value to a number failed, 1947887SLiane.Praza@Sun.COM * or base 32 decoding of a property value failed. 1957887SLiane.Praza@Sun.COM */ 1967887SLiane.Praza@Sun.COM TVS_BAD_CONVERSION, 1977887SLiane.Praza@Sun.COM /* Template is defective. */ 1987887SLiane.Praza@Sun.COM TVS_BAD_TEMPLATE, 1997887SLiane.Praza@Sun.COM /* Template type spec is invalid. */ 2007887SLiane.Praza@Sun.COM TVS_INVALID_TYPE_SPECIFICATION, 2017887SLiane.Praza@Sun.COM /* Property group is missing a type specification. */ 2027887SLiane.Praza@Sun.COM TVS_MISSING_PG_TYPE, 2037887SLiane.Praza@Sun.COM /* Template with required == true is missing type specification. */ 2047887SLiane.Praza@Sun.COM TVS_MISSING_TYPE_SPECIFICATION, 2057887SLiane.Praza@Sun.COM /* No match was found for specified item. */ 2067887SLiane.Praza@Sun.COM TVS_NOMATCH, 2077887SLiane.Praza@Sun.COM /* Validation error occurred */ 2087887SLiane.Praza@Sun.COM TVS_VALIDATION, 2097887SLiane.Praza@Sun.COM /* Validation error that should not inhibit import. */ 2107887SLiane.Praza@Sun.COM TVS_WARN, 2117887SLiane.Praza@Sun.COM /* Could not validate because of fatal errors. */ 2127887SLiane.Praza@Sun.COM TVS_FATAL = -1 2137887SLiane.Praza@Sun.COM } tmpl_validate_status_t; 2147887SLiane.Praza@Sun.COM 2157887SLiane.Praza@Sun.COM /* 2167887SLiane.Praza@Sun.COM * The composed_pg structure is used for templates validation. It is 2177887SLiane.Praza@Sun.COM * defined in svccfg_tmpl.c 2187887SLiane.Praza@Sun.COM */ 2197887SLiane.Praza@Sun.COM typedef struct composed_pg composed_pg_t; 2207887SLiane.Praza@Sun.COM 2210Sstevel@tonic-gate typedef struct entity { 2220Sstevel@tonic-gate uu_list_node_t sc_node; 2230Sstevel@tonic-gate entity_type_t sc_etype; 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate /* Common fields to all entities. */ 2260Sstevel@tonic-gate const char *sc_name; 2270Sstevel@tonic-gate const char *sc_fmri; 2280Sstevel@tonic-gate uu_list_t *sc_pgroups; 2290Sstevel@tonic-gate uu_list_t *sc_dependents; 2300Sstevel@tonic-gate struct entity *sc_parent; 2310Sstevel@tonic-gate enum import_state sc_import_state; 23212667SSean.Wilcox@Sun.COM boolean_t sc_miss_type; 2330Sstevel@tonic-gate int sc_seen; 23412667SSean.Wilcox@Sun.COM svccfg_op_t sc_op; 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate union { 2370Sstevel@tonic-gate struct { 2380Sstevel@tonic-gate uu_list_t *sc_service_instances; 2390Sstevel@tonic-gate service_type_t sc_service_type; 2400Sstevel@tonic-gate uint_t sc_service_version; 2417887SLiane.Praza@Sun.COM /* Following used by template validation */ 2427887SLiane.Praza@Sun.COM struct entity *sc_restarter; 2437887SLiane.Praza@Sun.COM struct entity *sc_global; 2440Sstevel@tonic-gate } sc_service; 2450Sstevel@tonic-gate struct { 2467887SLiane.Praza@Sun.COM uu_avl_t *sc_composed; 2477887SLiane.Praza@Sun.COM /* Following used by template validation */ 2487887SLiane.Praza@Sun.COM struct entity *sc_instance_restarter; 2490Sstevel@tonic-gate } sc_instance; 2500Sstevel@tonic-gate } sc_u; 2510Sstevel@tonic-gate } entity_t; 2520Sstevel@tonic-gate 2537887SLiane.Praza@Sun.COM /* 2547887SLiane.Praza@Sun.COM * sc_pgroup_composed is only used for templates validation of properties. 2557887SLiane.Praza@Sun.COM * It is created in build_composed_property_groups() and destroyed in 2567887SLiane.Praza@Sun.COM * composed_pg_destroy(). It will only be set for property groups that are 2577887SLiane.Praza@Sun.COM * part of an instance -- not for service property groups. 2587887SLiane.Praza@Sun.COM */ 2590Sstevel@tonic-gate typedef struct pgroup { 2600Sstevel@tonic-gate uu_list_node_t sc_node; 2610Sstevel@tonic-gate uu_list_t *sc_pgroup_props; 2627887SLiane.Praza@Sun.COM composed_pg_t *sc_pgroup_composed; /* Composed properties */ 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate const char *sc_pgroup_name; 2650Sstevel@tonic-gate const char *sc_pgroup_type; 2660Sstevel@tonic-gate uint_t sc_pgroup_flags; 2670Sstevel@tonic-gate struct entity *sc_parent; 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate int sc_pgroup_delete; 2700Sstevel@tonic-gate int sc_pgroup_override; 2710Sstevel@tonic-gate const char *sc_pgroup_fmri; /* Used for dependents */ 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate int sc_pgroup_seen; 2740Sstevel@tonic-gate } pgroup_t; 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate typedef struct property { 2770Sstevel@tonic-gate uu_list_node_t sc_node; 2787887SLiane.Praza@Sun.COM uu_avl_node_t sc_composed_node; /* Composed props linkage */ 2790Sstevel@tonic-gate uu_list_t *sc_property_values; 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate char *sc_property_name; 2820Sstevel@tonic-gate scf_type_t sc_value_type; 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate int sc_property_override; 2850Sstevel@tonic-gate int sc_seen; 2860Sstevel@tonic-gate } property_t; 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate typedef struct value { 2890Sstevel@tonic-gate uu_list_node_t sc_node; 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate scf_type_t sc_type; 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate void (*sc_free)(struct value *); 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate union { 2960Sstevel@tonic-gate uint64_t sc_count; 2970Sstevel@tonic-gate int64_t sc_integer; 2980Sstevel@tonic-gate char *sc_string; 2990Sstevel@tonic-gate } sc_u; 3000Sstevel@tonic-gate } value_t; 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate typedef struct scf_callback { 3030Sstevel@tonic-gate scf_handle_t *sc_handle; 3040Sstevel@tonic-gate void *sc_parent; /* immediate parent: scope, service, */ 3050Sstevel@tonic-gate /* instance, property group, property */ 3060Sstevel@tonic-gate scf_transaction_t *sc_trans; 3070Sstevel@tonic-gate int sc_service; /* True if sc_parent is a service. */ 3080Sstevel@tonic-gate uint_t sc_flags; 3090Sstevel@tonic-gate pgroup_t *sc_general; /* pointer to general property group */ 3108323SSean.Wilcox@Sun.COM property_t *sc_enable; /* pointer to enable property */ 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate const char *sc_source_fmri; 3130Sstevel@tonic-gate const char *sc_target_fmri; 3140Sstevel@tonic-gate int sc_err; 3150Sstevel@tonic-gate } scf_callback_t; 3160Sstevel@tonic-gate 3177887SLiane.Praza@Sun.COM /* 3187887SLiane.Praza@Sun.COM * Collection of template validation errors. 3197887SLiane.Praza@Sun.COM */ 3207887SLiane.Praza@Sun.COM typedef struct tmpl_errors tmpl_errors_t; 3217887SLiane.Praza@Sun.COM 3220Sstevel@tonic-gate #ifndef NDEBUG 3230Sstevel@tonic-gate #define bad_error(func, err) { \ 3240Sstevel@tonic-gate (void) fprintf(stderr, "%s:%d: %s() failed with unexpected " \ 3250Sstevel@tonic-gate "error %d. Aborting.\n", __FILE__, __LINE__, (func), (err)); \ 3260Sstevel@tonic-gate abort(); \ 3270Sstevel@tonic-gate } 3280Sstevel@tonic-gate #else 3290Sstevel@tonic-gate #define bad_error(func, err) abort() 3300Sstevel@tonic-gate #endif 3310Sstevel@tonic-gate 3320Sstevel@tonic-gate #define SC_CMD_LINE 0x0 3330Sstevel@tonic-gate #define SC_CMD_FILE 0x1 3340Sstevel@tonic-gate #define SC_CMD_EOF 0x2 3350Sstevel@tonic-gate #define SC_CMD_IACTIVE 0x4 3360Sstevel@tonic-gate #define SC_CMD_DONT_EXIT 0x8 3370Sstevel@tonic-gate 3380Sstevel@tonic-gate typedef struct engine_state { 3390Sstevel@tonic-gate uint_t sc_cmd_flags; 3400Sstevel@tonic-gate FILE *sc_cmd_file; 3410Sstevel@tonic-gate uint_t sc_cmd_lineno; 3420Sstevel@tonic-gate const char *sc_cmd_filename; 3430Sstevel@tonic-gate char *sc_cmd_buf; 3440Sstevel@tonic-gate size_t sc_cmd_bufsz; 3450Sstevel@tonic-gate off_t sc_cmd_bufoff; 3460Sstevel@tonic-gate GetLine *sc_gl; 34711996SThomas.Whitten@Sun.COM boolean_t sc_fs_minimal; /* SCF_INSTANCE_FS_MINIMAL is online. */ 34811996SThomas.Whitten@Sun.COM boolean_t sc_in_emi; /* During early import */ 34912667SSean.Wilcox@Sun.COM boolean_t sc_miss_type; /* Apply profile found missing types */ 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate pid_t sc_repo_pid; 3520Sstevel@tonic-gate const char *sc_repo_filename; 3530Sstevel@tonic-gate const char *sc_repo_doordir; 3540Sstevel@tonic-gate const char *sc_repo_doorname; 3550Sstevel@tonic-gate const char *sc_repo_server; 3560Sstevel@tonic-gate } engine_state_t; 3570Sstevel@tonic-gate 3580Sstevel@tonic-gate extern engine_state_t *est; 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate typedef struct string_list { 3610Sstevel@tonic-gate uu_list_node_t node; 3620Sstevel@tonic-gate char *str; 3630Sstevel@tonic-gate } string_list_t; 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate extern uu_list_pool_t *string_pool; 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate struct help_message { 3680Sstevel@tonic-gate int token; 3690Sstevel@tonic-gate const char *message; 3700Sstevel@tonic-gate }; 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate extern struct help_message help_messages[]; 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate extern scf_handle_t *g_hndl; /* global repcached connection handle */ 3750Sstevel@tonic-gate extern int g_exitcode; 3760Sstevel@tonic-gate extern int g_verbose; 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate extern ssize_t max_scf_fmri_len; 3790Sstevel@tonic-gate extern ssize_t max_scf_name_len; 3800Sstevel@tonic-gate extern ssize_t max_scf_value_len; 3810Sstevel@tonic-gate extern ssize_t max_scf_pg_type_len; 3820Sstevel@tonic-gate 3830Sstevel@tonic-gate /* Common strings */ 3840Sstevel@tonic-gate extern const char * const name_attr; 3850Sstevel@tonic-gate extern const char * const type_attr; 3860Sstevel@tonic-gate extern const char * const value_attr; 3870Sstevel@tonic-gate extern const char * const enabled_attr; 388*12967Sgavin.maltby@oracle.com extern const char * const active_attr; 3890Sstevel@tonic-gate extern const char * const scf_pg_general; 3900Sstevel@tonic-gate extern const char * const scf_group_framework; 3910Sstevel@tonic-gate extern const char * const true; 3920Sstevel@tonic-gate extern const char * const false; 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate #define uu_list_append(list, elem) uu_list_insert_before(list, NULL, elem) 3950Sstevel@tonic-gate #define uu_list_prepend(list, elem) uu_list_insert_after(list, NULL, elem) 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate void *safe_malloc(size_t); 3980Sstevel@tonic-gate char *safe_strdup(const char *); 3990Sstevel@tonic-gate void warn(const char *, ...); 4000Sstevel@tonic-gate void synerr(int); 4010Sstevel@tonic-gate void semerr(const char *, ...); 4020Sstevel@tonic-gate 4030Sstevel@tonic-gate void internal_init(void); 4040Sstevel@tonic-gate void internal_dump(bundle_t *); 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate int value_cmp(const void *, const void *, void *); 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate bundle_t *internal_bundle_new(void); 4090Sstevel@tonic-gate void internal_bundle_free(bundle_t *); 4100Sstevel@tonic-gate entity_t *internal_service_new(const char *); 4110Sstevel@tonic-gate void internal_service_free(entity_t *); 4120Sstevel@tonic-gate entity_t *internal_instance_new(const char *); 4130Sstevel@tonic-gate void internal_instance_free(entity_t *); 4140Sstevel@tonic-gate entity_t *internal_template_new(void); 4150Sstevel@tonic-gate pgroup_t *internal_pgroup_new(void); 4160Sstevel@tonic-gate void internal_pgroup_free(pgroup_t *); 4170Sstevel@tonic-gate pgroup_t *internal_pgroup_find(entity_t *, const char *, const char *); 4180Sstevel@tonic-gate pgroup_t *internal_dependent_find(entity_t *, const char *); 4190Sstevel@tonic-gate pgroup_t *internal_pgroup_find_or_create(entity_t *, const char *, 4200Sstevel@tonic-gate const char *); 4217887SLiane.Praza@Sun.COM pgroup_t *internal_pgroup_create_strict(entity_t *, const char *, 4227887SLiane.Praza@Sun.COM const char *); 4230Sstevel@tonic-gate property_t *internal_property_new(void); 4240Sstevel@tonic-gate void internal_property_free(property_t *); 4250Sstevel@tonic-gate property_t *internal_property_find(pgroup_t *, const char *); 4260Sstevel@tonic-gate property_t *internal_property_create(const char *, scf_type_t, uint_t, ...); 4270Sstevel@tonic-gate value_t *internal_value_new(void); 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate int internal_attach_service(bundle_t *, entity_t *); 4300Sstevel@tonic-gate int internal_attach_entity(entity_t *, entity_t *); 4310Sstevel@tonic-gate int internal_attach_pgroup(entity_t *, pgroup_t *); 4327887SLiane.Praza@Sun.COM void internal_detach_pgroup(entity_t *, pgroup_t *); 4330Sstevel@tonic-gate int internal_attach_dependent(entity_t *, pgroup_t *); 4340Sstevel@tonic-gate int internal_attach_property(pgroup_t *, property_t *); 4357887SLiane.Praza@Sun.COM void internal_detach_property(pgroup_t *, property_t *); 4360Sstevel@tonic-gate void internal_attach_value(property_t *, value_t *); 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate int load_init(void); 4390Sstevel@tonic-gate void load_fini(void); 4407887SLiane.Praza@Sun.COM int load_instance(const char *, const char *, entity_t **); 4410Sstevel@tonic-gate int load_pg_attrs(const scf_propertygroup_t *, pgroup_t **); 4420Sstevel@tonic-gate int load_pg(const scf_propertygroup_t *, pgroup_t **, const char *, 4430Sstevel@tonic-gate const char *); 4440Sstevel@tonic-gate int prop_equal(property_t *, property_t *, const char *, const char *, int); 445306Sbustos int pg_attrs_equal(const pgroup_t *, const pgroup_t *, const char *, int); 4460Sstevel@tonic-gate int pg_equal(pgroup_t *, pgroup_t *); 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate void lscf_cleanup(void); 4490Sstevel@tonic-gate void lscf_prep_hndl(void); 4500Sstevel@tonic-gate void lscf_init(void); 4510Sstevel@tonic-gate int lscf_bundle_import(bundle_t *, const char *, uint_t); 4525777Stw21770 int lscf_bundle_apply(bundle_t *, const char *); 4530Sstevel@tonic-gate void lscf_delete(const char *, int); 4540Sstevel@tonic-gate void lscf_list(const char *); 4550Sstevel@tonic-gate void lscf_select(const char *); 4560Sstevel@tonic-gate void lscf_unselect(); 4570Sstevel@tonic-gate void lscf_get_selection_str(char *, size_t); 4580Sstevel@tonic-gate void lscf_add(const char *); 4590Sstevel@tonic-gate void lscf_listpg(const char *); 4600Sstevel@tonic-gate void lscf_addpg(const char *, const char *, const char *); 4610Sstevel@tonic-gate void lscf_delpg(char *); 4627475SPhilippe.Jung@Sun.COM void lscf_delhash(char *, int); 4630Sstevel@tonic-gate void lscf_listprop(const char *); 4640Sstevel@tonic-gate void lscf_addprop(char *, const char *, const uu_list_t *); 4650Sstevel@tonic-gate void lscf_delprop(char *); 4667887SLiane.Praza@Sun.COM int lscf_describe(uu_list_t *, int); 4670Sstevel@tonic-gate void lscf_listsnap(); 4680Sstevel@tonic-gate void lscf_selectsnap(const char *); 4690Sstevel@tonic-gate void lscf_revert(const char *); 4705841Samaguire void lscf_refresh(); 4710Sstevel@tonic-gate char *filename_to_propname(const char *); 4720Sstevel@tonic-gate int lscf_retrieve_hash(const char *, unsigned char *); 4730Sstevel@tonic-gate int lscf_store_hash(const char *, unsigned char *); 47411996SThomas.Whitten@Sun.COM int lscf_service_cleanup(void *, scf_walkinfo_t *); 47511996SThomas.Whitten@Sun.COM int lscf_hash_cleanup(); 476*12967Sgavin.maltby@oracle.com void lscf_delnotify(const char *, int); 477*12967Sgavin.maltby@oracle.com void lscf_listnotify(const char *, int); 478*12967Sgavin.maltby@oracle.com int lscf_setnotify(uu_list_t *); 479*12967Sgavin.maltby@oracle.com 4800Sstevel@tonic-gate CPL_MATCH_FN(complete_select); 4810Sstevel@tonic-gate CPL_MATCH_FN(complete_command); 4820Sstevel@tonic-gate 4830Sstevel@tonic-gate int lxml_init(void); 4845040Swesolows int lxml_get_bundle_file(bundle_t *, const char *, svccfg_op_t); 48512667SSean.Wilcox@Sun.COM void lxml_store_value(value_t *, element_t, const xmlChar *); 4860Sstevel@tonic-gate 4870Sstevel@tonic-gate void engine_init(void); 4880Sstevel@tonic-gate int engine_exec_cmd(void); 4890Sstevel@tonic-gate int engine_exec(char *); 4900Sstevel@tonic-gate int add_cmd_matches(WordCompletion *, const char *, int, uint32_t); 4910Sstevel@tonic-gate int engine_interp(void); 4920Sstevel@tonic-gate int engine_source(const char *, boolean_t); 4930Sstevel@tonic-gate int engine_import(uu_list_t *); 49411996SThomas.Whitten@Sun.COM int engine_cleanup(int); 4950Sstevel@tonic-gate void help(int); 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate int engine_cmd_getc(engine_state_t *); 4980Sstevel@tonic-gate int engine_cmd_ungetc(engine_state_t *, char); 4990Sstevel@tonic-gate void engine_cmd_nputs(engine_state_t *, char *, size_t); 5000Sstevel@tonic-gate 5017887SLiane.Praza@Sun.COM void tmpl_errors_destroy(tmpl_errors_t *); 5027887SLiane.Praza@Sun.COM void tmpl_errors_print(FILE *, tmpl_errors_t *, const char *); 5037887SLiane.Praza@Sun.COM void tmpl_init(void); 5047887SLiane.Praza@Sun.COM void tmpl_property_fini(property_t *); 5057887SLiane.Praza@Sun.COM void tmpl_property_init(property_t *); 5067887SLiane.Praza@Sun.COM tmpl_validate_status_t tmpl_validate_bundle(bundle_t *, tmpl_errors_t **); 5077887SLiane.Praza@Sun.COM 508*12967Sgavin.maltby@oracle.com #define FMA_TOKENS 0 509*12967Sgavin.maltby@oracle.com #define MIXED_TOKENS -1 510*12967Sgavin.maltby@oracle.com #define INVALID_TOKENS -2 511*12967Sgavin.maltby@oracle.com 512*12967Sgavin.maltby@oracle.com char **tokenize(char *, const char *); 513*12967Sgavin.maltby@oracle.com int32_t check_tokens(char **); 514*12967Sgavin.maltby@oracle.com const char *de_tag(const char *); 515*12967Sgavin.maltby@oracle.com const char *tset_to_string(int32_t); 516*12967Sgavin.maltby@oracle.com 5170Sstevel@tonic-gate #ifdef __cplusplus 5180Sstevel@tonic-gate } 5190Sstevel@tonic-gate #endif 5200Sstevel@tonic-gate 5210Sstevel@tonic-gate #endif /* _CMD_SVCCFG_H */ 522