Lines Matching refs:handle

62  * smb_smf_scf_fini(handle)
64 * must be called when done. Called with the handle allocated in
69 smb_smf_scf_fini(smb_scfhandle_t *handle)
71 if (handle != NULL) {
73 if (handle->scf_pg_iter != NULL) {
74 scf_iter_destroy(handle->scf_pg_iter);
75 handle->scf_pg_iter = NULL;
77 if (handle->scf_inst_iter != NULL) {
78 scf_iter_destroy(handle->scf_inst_iter);
79 handle->scf_inst_iter = NULL;
81 if (handle->scf_scope != NULL) {
83 scf_scope_destroy(handle->scf_scope);
84 handle->scf_scope = NULL;
86 if (handle->scf_instance != NULL) {
87 scf_instance_destroy(handle->scf_instance);
88 handle->scf_instance = NULL;
90 if (handle->scf_service != NULL) {
91 scf_service_destroy(handle->scf_service);
92 handle->scf_service = NULL;
94 if (handle->scf_pg != NULL) {
95 scf_pg_destroy(handle->scf_pg);
96 handle->scf_pg = NULL;
98 if (handle->scf_handle != NULL) {
99 handle->scf_state = SCH_STATE_UNINIT;
101 (void) scf_handle_unbind(handle->scf_handle);
102 scf_handle_destroy(handle->scf_handle);
103 handle->scf_handle = NULL;
105 free(handle);
115 smb_smf_instance_exists(smb_scfhandle_t *handle, char *inst_name)
118 if (handle == NULL) {
122 handle->scf_instance = scf_instance_create(handle->scf_handle);
123 if (scf_service_get_instance(handle->scf_service, inst_name,
124 handle->scf_instance) != SCF_SUCCESS) {
127 scf_instance_destroy(handle->scf_instance);
128 handle->scf_instance = NULL;
137 smb_smf_instance_create(smb_scfhandle_t *handle, char *serv_prefix,
144 if (handle == NULL) {
157 handle->scf_instance = scf_instance_create(handle->scf_handle);
158 if (scf_service_get_instance(handle->scf_service, inst_name,
159 handle->scf_instance) != SCF_SUCCESS) {
160 if (scf_service_add_instance(handle->scf_service,
161 inst_name, handle->scf_instance) == SCF_SUCCESS) {
179 smb_smf_instance_delete(smb_scfhandle_t *handle, char *inst_name)
183 if (handle == NULL) {
187 handle->scf_instance = scf_instance_create(handle->scf_handle);
188 if (scf_service_get_instance(handle->scf_service, inst_name,
189 handle->scf_instance) == SCF_SUCCESS) {
190 if (scf_instance_delete(handle->scf_instance) == SCF_SUCCESS) {
211 smb_scfhandle_t *handle;
213 handle = malloc(sizeof (smb_scfhandle_t));
214 if (handle != NULL) {
215 bzero((char *)handle, sizeof (smb_scfhandle_t));
216 handle->scf_state = SCH_STATE_INITIALIZING;
217 handle->scf_handle = scf_handle_create(SCF_VERSION);
218 if (handle->scf_handle != NULL) {
219 if (scf_handle_bind(handle->scf_handle) == 0) {
220 handle->scf_scope =
221 scf_scope_create(handle->scf_handle);
223 handle->scf_handle, handle->scf_scope) != 0)
226 handle->scf_service =
227 scf_service_create(handle->scf_handle);
229 if (scf_scope_get_service(handle->scf_scope,
230 svc_name, handle->scf_service)
234 handle->scf_pg =
235 scf_pg_create(handle->scf_handle);
236 handle->scf_state = SCH_STATE_INIT;
241 free(handle);
242 handle = NULL;
247 return (handle);
251 (void) smb_smf_scf_fini(handle);
257 * smb_smf_create_service_pgroup(handle, pgroup)
262 smb_smf_create_service_pgroup(smb_scfhandle_t *handle, char *pgroup)
267 if (handle == NULL) {
272 * only create a handle if it doesn't exist. It is ok to exist
273 * since the pg handle will be set as a side effect.
275 if (handle->scf_pg == NULL) {
276 handle->scf_pg = scf_pg_create(handle->scf_handle);
282 if (scf_service_get_pg(handle->scf_service,
283 pgroup, handle->scf_pg) != 0) {
285 if (scf_service_add_pg(handle->scf_service, pgroup,
286 SCF_GROUP_FRAMEWORK, 0, handle->scf_pg) != 0) {
304 * smb_smf_create_instance_pgroup(handle, pgroup)
309 smb_smf_create_instance_pgroup(smb_scfhandle_t *handle, char *pgroup)
314 if (handle == NULL) {
319 * only create a handle if it doesn't exist. It is ok to exist
320 * since the pg handle will be set as a side effect.
322 if (handle->scf_pg == NULL) {
323 handle->scf_pg = scf_pg_create(handle->scf_handle);
330 if (scf_instance_get_pg(handle->scf_instance,
331 pgroup, handle->scf_pg) != 0) {
333 if (scf_instance_add_pg(handle->scf_instance, pgroup,
334 SCF_GROUP_APPLICATION, 0, handle->scf_pg) != 0) {
352 * smb_smf_delete_service_pgroup(handle, pgroup)
358 smb_smf_delete_service_pgroup(smb_scfhandle_t *handle, char *pgroup)
363 if (handle == NULL) {
368 * only create a handle if it doesn't exist. It is ok to exist
369 * since the pg handle will be set as a side effect.
371 if (handle->scf_pg == NULL) {
372 handle->scf_pg = scf_pg_create(handle->scf_handle);
378 if (scf_service_get_pg(handle->scf_service,
379 pgroup, handle->scf_pg) == 0) {
381 if (scf_pg_delete(handle->scf_pg) != 0) {
403 * smb_smf_delete_instance_pgroup(handle, pgroup)
409 smb_smf_delete_instance_pgroup(smb_scfhandle_t *handle, char *pgroup)
414 if (handle == NULL) {
419 * only create a handle if it doesn't exist. It is ok to exist
420 * since the pg handle will be set as a side effect.
422 if (handle->scf_pg == NULL) {
423 handle->scf_pg = scf_pg_create(handle->scf_handle);
429 if (scf_instance_get_pg(handle->scf_instance,
430 pgroup, handle->scf_pg) == 0) {
432 if (scf_pg_delete(handle->scf_pg) != 0) {
454 * Start transaction on current pg in handle.
456 * Must be called after pg handle is obtained
460 smb_smf_start_transaction(smb_scfhandle_t *handle)
464 if (!handle || (!handle->scf_pg)) {
471 if (handle->scf_state == SCH_STATE_INIT) {
473 handle->scf_trans =
474 scf_transaction_create(handle->scf_handle);
475 if (handle->scf_trans != NULL) {
476 if (scf_transaction_start(handle->scf_trans,
477 handle->scf_pg) != 0) {
480 handle->scf_trans);
481 handle->scf_trans = NULL;
496 * smb_smf_end_transaction(handle)
499 * handle. Do all necessary cleanup.
502 smb_smf_end_transaction(smb_scfhandle_t *handle)
506 if (handle == NULL) {
510 if (handle->scf_trans == NULL) {
513 if (scf_transaction_commit(handle->scf_trans) < 0) {
518 scf_transaction_destroy_children(handle->scf_trans);
519 scf_transaction_destroy(handle->scf_trans);
520 handle->scf_trans = NULL;
529 smb_smf_delete_property(smb_scfhandle_t *handle, char *propname)
534 if (handle == NULL) {
542 entry = scf_entry_create(handle->scf_handle);
544 if (scf_transaction_property_delete(handle->scf_trans, entry,
573 smb_smf_set_string_property(smb_scfhandle_t *handle,
580 if (handle == NULL) {
588 value = scf_value_create(handle->scf_handle);
589 entry = scf_entry_create(handle->scf_handle);
591 if (scf_transaction_property_change(handle->scf_trans, entry,
593 scf_transaction_property_new(handle->scf_trans, entry,
638 smb_smf_get_string_property(smb_scfhandle_t *handle, char *propname,
645 if (handle == NULL) {
649 value = scf_value_create(handle->scf_handle);
650 prop = scf_property_create(handle->scf_handle);
652 (scf_pg_get_property(handle->scf_pg, propname, prop) == 0)) {
676 smb_smf_set_integer_property(smb_scfhandle_t *handle, char *propname,
683 if (handle == NULL) {
691 value = scf_value_create(handle->scf_handle);
692 entry = scf_entry_create(handle->scf_handle);
694 if (scf_transaction_property_change(handle->scf_trans, entry,
696 scf_transaction_property_new(handle->scf_trans, entry,
734 smb_smf_get_integer_property(smb_scfhandle_t *handle, char *propname,
741 if (handle == NULL) {
745 value = scf_value_create(handle->scf_handle);
746 prop = scf_property_create(handle->scf_handle);
748 (scf_pg_get_property(handle->scf_pg, propname, prop) == 0)) {
773 smb_smf_set_boolean_property(smb_scfhandle_t *handle, char *propname,
780 if (handle == NULL) {
788 value = scf_value_create(handle->scf_handle);
789 entry = scf_entry_create(handle->scf_handle);
791 if (scf_transaction_property_change(handle->scf_trans, entry,
793 scf_transaction_property_new(handle->scf_trans, entry,
831 smb_smf_get_boolean_property(smb_scfhandle_t *handle, char *propname,
838 if (handle == NULL) {
842 value = scf_value_create(handle->scf_handle);
843 prop = scf_property_create(handle->scf_handle);
845 (scf_pg_get_property(handle->scf_pg, propname, prop) == 0)) {
868 smb_smf_set_opaque_property(smb_scfhandle_t *handle, char *propname,
875 if (handle == NULL) {
883 value = scf_value_create(handle->scf_handle);
884 entry = scf_entry_create(handle->scf_handle);
886 if (scf_transaction_property_change(handle->scf_trans, entry,
888 scf_transaction_property_new(handle->scf_trans, entry,
932 smb_smf_get_opaque_property(smb_scfhandle_t *handle, char *propname,
939 if (handle == NULL) {
943 value = scf_value_create(handle->scf_handle);
944 prop = scf_property_create(handle->scf_handle);
946 (scf_pg_get_property(handle->scf_pg, propname, prop) == 0)) {
970 smb_scfhandle_t *handle = NULL;
972 handle = smb_smf_scf_init(svc_name);
973 if (!handle) {
977 handle->scf_inst_iter = scf_iter_create(handle->scf_handle);
978 if (handle->scf_inst_iter) {
979 if (scf_iter_service_instances(handle->scf_inst_iter,
980 handle->scf_service) != 0) {
981 smb_smf_scf_fini(handle);
982 handle = NULL;
984 handle->scf_instance = NULL;
987 smb_smf_scf_fini(handle);
988 handle = NULL;
990 return (handle);