scf_iter_instance_pgs_typed(3scf) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

scf_iter_instance_pgs_typed(3scf)

Service Configuration Facility Library Functions         scf_iter_create(3SCF)



NAME
       scf_iter_create,   scf_iter_handle,  scf_iter_destroy,  scf_iter_reset,
       scf_iter_handle_scopes,     scf_iter_scope_services,      scf_iter_ser‐
       vice_instances,    scf_iter_service_pgs,    scf_iter_service_pgs_typed,
       scf_iter_instance_snapshots,                    scf_iter_snaplevel_pgs,
       scf_iter_snaplevel_pgs_typed,                    scf_iter_instance_pgs,
       scf_iter_instance_pgs_typed,            scf_iter_instance_pgs_composed,
       scf_iter_instance_pgs_typed_composed,                  scf_iter_pg_pgs,
       scf_iter_pg_pgs_typed,                        scf_iter_pg_pgs_composed,
       scf_iter_pg_pgs_typed_composed,  scf_iter_pg_properties, scf_iter_prop‐
       erty_values,        scf_iter_next_scope,         scf_iter_next_service,
       scf_iter_next_instance,    scf_iter_next_snapshot,    scf_iter_next_pg,
       scf_iter_next_property, scf_iter_next_value - iterate through the  Ser‐
       vice Configuration Facility repository

SYNOPSIS
       cc [ flag... ] file... -lscf [ library... ]
              #include <libscf.h>


       scf_iter_t *scf_iter_create(scf_handle_t *handle);


       scf_handle_t *scf_iter_handle(scf_iter_t *iter);


       void scf_iter_destroy(scf_iter_t *iter);


       void scf_iter_reset(scf_iter_t *iter);


       int scf_iter_handle_scopes(scf_iter_t *iter, const scf_handle_t *h);


       int scf_iter_scope_services(scf_iter_t *iter, const scf_scope_t *parent);


       int scf_iter_service_instances(scf_iter_t *iter,
                const scf_service_t *parent);


       int scf_iter_service_pgs(scf_iter_t *iter, const scf_service_t *parent);


       int scf_iter_service_pgs_typed(scf_iter_t *iter,
                const scf_service_t *parent, const char *pgtype);


       int scf_iter_instance_snapshots(scf_iter_t *iter,
                const scf_instance_t *parent);


       int scf_iter_snaplevel_pgs(scf_iter_t *iter,
                const scf_snaplevel_t *parent);


       int scf_iter_snaplevel_pgs_typed(scf_iter_t *iter,
                const scf_snaplevel_t *parent, const char *pgtype);


       int scf_iter_instance_pgs(scf_iter_t *iter, scf_instance_t *parent);


       int scf_iter_instance_pgs_typed(scf_iter_t *iter,
                scf_instance_t *parent, const char *pgtype);


       int scf_iter_instance_pgs_composed(scf_iter_t *iter,
                const scf_instance_t *instance, const scf_snapshot_t *snapshot);


       int scf_iter_instance_pgs_typed_composed(scf_iter_t *iter,
                const scf_instance_t *instance, const scf_snapshot_t *snapshot,
                const char *pgtype);


       int scf_iter_pg_pgs(scf_iter_t *iter,
               scf_propertygroup_t *pg);


       int scf_iter_pg_pgs_typed(scf_iter_t *iter,
               scf_propertygroup_t *pg, const char *pgtype);


       int scf_iter_pg_pgs_composed(scf_iter_t *iter,
               scf_propertygroup_t *pg, scf_snapshot_t *snapshot);


       int scf_iter_pg_pgs_typed_composed(scf_iter_t *iter,
               scf_propertygroup_t *pg,
               scf_snapshot_t *snapshot, const char *pgtype);


       int scf_iter_pg_properties(scf_iter_t *iter,
                const scf_propertygroup_t *parent);


       int scf_iter_property_values(scf_iter_t *iter,
                const scf_property_t *parent);


       int scf_iter_next_scope(scf_iter_t *iter, scf_scope_t *out);


       int scf_iter_next_service(scf_iter_t *iter, scf_service_t *out);


       int scf_iter_next_instance(scf_iter_t *iter, scf_instance_t *out);


       int scf_iter_next_snapshot(scf_iter_t *iter, scf_snapshot_t *out);


       int scf_iter_next_pg(scf_iter_t *iter, scf_propertygroup_t  *out);


       int scf_iter_next_property(scf_iter_t *iter, scf_property_t *out);


       int scf_iter_next_value(scf_iter_t *iter, scf_value_t *out);

DESCRIPTION
       The  scf_iter_create()  function creates a new iterator associated with
       handle.


       The scf_iter_destroy() function destroys an iteration. The  scf_error()
       function is not modified by this call.


       The  scf_iter_reset()  function releases any resources involved with an
       active iteration, and returns the iterator to its initial state.


       The scf_iter_handle_scopes(), scf_iter_scope_services(),  scf_iter_ser‐
       vice_instances(),      scf_iter_instance_snapshots(),     scf_iter_ser‐
       vice_pgs(),         scf_iter_instance_pgs(),         scf_iter_pg_pgs(),
       scf_iter_snaplevel_pgs(),  scf_iter_pg_properties(), and scf_iter_prop‐
       erty_values() functions each set up a new iteration.


       The scf_iter_handle_scopes() function sets up an iterator of all scopes
       for a given handle.


       The  scf_iter_scope_services() function sets up an iterator of all ser‐
       vices for a given scope.


       The scf_iter_service_instances() function sets up an  iterator  of  all
       instances for a given service.


       The  scf_iter_instance_snapshots()  function sets up an iterator of all
       snapshots for a given instance.


       The scf_iter_service_pgs() function sets up an iterator of all property
       groups for a given service.


       The  scf_iter_instance_pgs()  function sets up an iterator of all prop‐
       erty groups for a given instance.


       The scf_iter_pg_pgs() function sets up  an  iterator  of  all  property
       groups  that  directly parented by the given property group. Therefore,
       only those property groups at the next level are considered.


       The scf_iter_pg_properties() function sets up an iterator of all  prop‐
       erties for a given property group.


       The scf_iter_property_values() function sets up an iterator of all val‐
       ues for a given property (in the order in which they are specified with
       scf_entry_add_value(3SCF)).


       The     scf_iter_service_pgs_typed(),    scf_iter_instance_pgs_typed(),
       scf_iter_pg_pgs_typed(), and  scf_iter_snaplevel_pgs_typed()  functions
       iterate over the child property groups of the parent, but restrict them
       to a particular property group type. The scf_iter_pg_pgs_typed()  func‐
       tion  will  iterate  over  the property groups directly parented by the
       given property group. Therefore, only those property groups at the next
       level are considered.


       The   scf_iter_instance_pgs_composed()  and  scf_iter_pg_pgs_composed()
       functions set up a new iteration of the composed view of an instance or
       a  property  group's children at the time the snapshot is taken. If the
       snapshot is NULL, the current properties are used.


       The composed view of properties is  the  union  of  properties  of  the
       instance  and its ancestors within any given property group. Properties
       of the instance take precedence over properties of the service with the
       same  name  and ancestry. Properties and property groups retrieved with
       this iterator might not have the instance as  their  ancestor  if  they
       exist only in the service. If the instance and its parent have property
       groups with the same name but different types, the  properties  in  the
       property group of the parent are excluded.


       The              scf_iter_instance_pgs_typed_composed()             and
       scf_iter_pg_pgs_typed_composed()       functions       behave        as
       scf_iter_instance_pgs_composed() and scf_iter_pg_pgs_composed() respec‐
       tively, except  only  the  property  groups  of  the  type  pgtype  are
       returned. The scf_iter_pg_pgs_composed() and scf_iter_pg_pgs_typed_com‐
       posed() functions will iterate over the property groups  directly  par‐
       ented  by  the  given  property  group.  Therefore, only those property
       groups at the next level are considered.


       The           scf_iter_next_scope(),           scf_iter_next_service(),
       scf_iter_next_instance(), scf_iter_next_snapshot(), scf_iter_next_pg(),
       scf_iter_next_property(), and scf_iter_next_value() functions  retrieve
       the next element of the iteration.

RETURN VALUES
       Upon  successful  completion,  the scf_iter_create() function returns a
       pointer to a new iterator. Otherwise, it returns NULL.


       Upon successful completion, the scf_iter_handle() function returns  the
       handle associated with iter. Otherwise, it returns NULL.


       Upon     successful     completion,    the    scf_iter_handle_scopes(),
       scf_iter_scope_services(),                scf_iter_service_instances(),
       scf_iter_instance_snapshots(),                  scf_iter_service_pgs(),
       scf_iter_instance_pgs(),  scf_iter_pg_pgs(),  scf_iter_snaplevel_pgs(),
       scf_iter_pg_properties(),   scf_iter_property_values(),   scf_iter_ser‐
       vice_pgs_typed(),                     scf_iter_instance_pgs_composed(),
       scf_iter_instance_pgs_typed(),  scf_iter_instance_pgs_typed_composed(),
       scf_iter_pg_pgs_typed(),                    scf_iter_pg_pgs_composed(),
       scf_iter_pg_pgs_typed_composed(),   and  scf_iter_snaplevel_pgs_typed()
       functions return 0. Otherwise, they return -1.


       Upon     successful     completion,     the      scf_iter_next_scope(),
       scf_iter_next_service(),  scf_iter_next_instance(), scf_iter_next_snap‐
       shot(),     scf_iter_next_pg(),      scf_iter_next_property(),      and
       scf_iter_next_value()  functions return 1. If the iterator is complete,
       the functions return 0. Otherwise, they return -1.

ERRORS
       The scf_iter_create() function will fail if:


       SCF_ERROR_INVALID_ARGUMENT    The handle argument is NULL.


       SCF_ERROR_NO_MEMORY           There is no memory available.


       SCF_ERROR_NO_RESOURCES        The  server  does   not   have   adequate
                                     resources for a new iteration.




       The scf_iter_handle() function will fail if:


       SCF_ERROR_HANDLE_DESTROYED    The   handle   associated  with  iter  is
                                     destroyed.




       The scf_iter_next_value() function will fail if:


       SCF_ERROR_PERMISSION_DENIED

           The value cannot be read due to access restrictions.




       The scf_iter_handle_scopes(), scf_iter_scope_services(),  scf_iter_ser‐
       vice_instances(),      scf_iter_instance_snapshots(),     scf_iter_ser‐
       vice_pgs(), scf_iter_instance_pgs(),  scf_iter_instance_pgs_composed(),
       scf_iter_pg_pgs(),                          scf_iter_pg_pgs_composed(),
       scf_iter_snaplevel_pgs(),   scf_iter_pg_properties(),    scf_iter_prop‐
       erty_values(),                            scf_iter_service_pgs_typed(),
       scf_iter_instance_pgs_typed(),  scf_iter_instance_pgs_typed_composed(),
       scf_iter_pg_pgs_typed(),      scf_iter_pg_pgs_typed_composed(),     and
       scf_iter_snaplevel_pgs_typed() functions will fail if:


       SCF_ERROR_DELETED

           The parent is deleted.


       SCF_ERROR_NOT_SET

           The parent is not set.


       SCF_ERROR_NOT_BOUND

           The handle is not bound.


       SCF_ERROR_CONNECTION_BROKEN

           The connection to the repository is lost.


       SCF_ERROR_HANDLE_MISMATCH

           The iter and parent arguments are not derived from the same handle.




       The    scf_iter_service_pgs_typed(),     scf_iter_instance_pgs_typed(),
       scf_iter_instance_pgs_typed_composed(),        scf_iter_pg_pgs_typed(),
       scf_iter_pg_pgs_typed_composed(),  and   scf_iter_snaplevel_pgs_typed()
       functions will fail if:


       SCF_ERROR_INVALID_ARGUMENT    The  pgtype argument is not a valid prop‐
                                     erty group type.




       The         scf_iter_next_service(),          scf_iter_next_instance(),
       scf_iter_next_snapshot(), scf_iter_next_pg(), scf_iter_next_property(),
       and scf_iter_next_value() functions will fail if:


       SCF_ERROR_DELETED    The parent that the iterator is  attached  to,  is
                            deleted.




       The           scf_iter_next_scope(),           scf_iter_next_service(),
       scf_iter_next_instance(), scf_iter_next_snapshot(), scf_iter_next_pg(),
       scf_iter_next_property(), and scf_iter_next_value() functions will fail
       if:


       SCF_ERROR_NOT_SET

           The iterator is not set.


       SCF_ERROR_INVALID_ARGUMENT

           The requested object type does not match the type the  iterator  is
           walking.


       SCF_ERROR_NOT_BOUND

           The handle is not bound.


       SCF_ERROR_HANDLE_MISMATCH

           The iter and parent arguments are not derived from the same handle.


       SCF_ERROR_CONNECTION_BROKEN

           The connection to the repository is lost.




       The       scf_iter_scope_services(),      scf_iter_service_instances(),
       scf_iter_service_pgs(),                  scf_iter_instance_snapshots(),
       scf_iter_instance_snapshots(),        scf_iter_instance_pgs_composed(),
       scf_iter_pg_pgs(),                          scf_iter_pg_pgs_composed(),
       scf_iter_snaplevel_pgs(),    scf_iter_pg_properties(),   scf_iter_prop‐
       erty_values(),                            scf_iter_service_pgs_typed(),
       scf_iter_instance_pgs_typed(),  scf_iter_instance_pgs_typed_composed(),
       scf_iter_pg_pgs_typed(),              scf_iter_pg_pgs_typed_composed(),
       scf_iter_snaplevel_pgs_typed(),                scf_iter_next_service(),
       scf_iter_next_instance(), scf_iter_next_snapshot(), scf_iter_next_pg(),
       and scf_iter_next_property() functions will fail if:


       SCF_ERROR_NO_RESOURCES    The  server  does  not  have the resources to
                                 complete the request.




       The scf_error(3SCF) function can be used to retrieve the error value.

EXAMPLES
       Example 1 Iterate Overall Instances Under a Service.


         scf_iter_t *iter = scf_iter_create(handle);

               if (iter == NULL || scf_iter_service_instances(iter, parent) == -1) {
                    /* failure */
               }
               while ((r = scf_iter_next_instance(iter, child)) > 0) {
                    /* process child */
               }
               if (r < 0) {
                    /* failure */
               }
               scf_iter_destroy(iter);



       Example 2 Connect to the Repository, walk all  Services  and  Instances
       and Print their FMRIs.


         scf_handle_t *handle = scf_handle_create(SCF_VERSION);
               scf_scope_t *scope = scf_scope_create(handle);
               scf_service_t *svc = scf_service_create(handle);
               scf_instance_t *inst = scf_instance_create(handle);
               scf_iter_t *svc_iter = scf_iter_create(handle);
               scf_iter_t *inst_iter = scf_iter_create(handle);

               size_t sz = scf_limit(SCF_LIMIT_MAX_FMRI_LENGTH) + 1;
               char *fmri = malloc(sz + 1);

               int r;

               if (handle == NULL || scope == NULL || svc == NULL ||
                    inst == NULL || svc_iter == NULL || inst_iter == NULL ||
                    fmri == NULL) {
                     /* failure */
               }
               if (scf_handle_bind(handle) == -1 ||
                    scf_handle_get_scope(handle, SCF_SCOPE_LOCAL, scope) == -1 ||
                    scf_iter_scope_services(svc_iter, scope) ==-1) {
                      /* failure */
               }
               while ((r = scf_iter_next_service(svc_iter, svc)) > 0) {
                    if (scf_service_to_fmri(svc, fmri, sz) < 0) {
                      /* failure */
                    }
                    puts(fmri);
                    if (scf_iter_service_instances(inst_iter, svc) < 0) {
                      /* failure */
                    }
                    while ((r = scf_iter_next_instance(inst_iter, inst)) > 0)  {
                      if (scf_instance_to_fmri(inst, fmri, sz) < 0) {
                        /* failure */
                      }
                      puts(fmri);
                    }
                    if (r < 0)
                      break;
               }
               if (r < 0) {
                    /* failure */
               }

               scf_handle_destroy(handle);
               scf_scope_destroy(scope);
               scf_service_destroy(svc);
               scf_instance_destroy(inst);
               scf_iter_destroy(svc_iter);
               scf_iter_destroy(inst_iter);



       Example 3 walk All Property Groups and Print their FMRIs.


         int print_all_pgs(scf_handle_t *h, scf_propertygroup_t *parent_pg)
               {
                    scf_iter_t *iter = NULL;
                    scf_propertygroup_t *pg = NULL;

                    if (((pg = scf_pg_create(h)) == NULL) ||
                     ((iter = scf_iter_create(h)) == NULL))
                      /* failure */
                    }

                    /* this fails when there are no child pgs, so return */
                    if (scf_iter_pg_pgs(iter, parent_pg, NULL) != 0)
                      return (0);

                    while (scf_iter_next_pg(iter, pg) > 0) {
                      size_t sz = scf_limit(SCF_LIMIT_MAX_FMRI_LENGTH) + 1;
                      char *fmri = malloc(sz + 1);

                      if (scf_pg_to_fmri(pg, fmri, sz) < 0)
                        /* failure */

                      puts(fmri);

                      if (print_all_pgs(h, pg) != 0)
                        /* failure */

                      free(fmri);
                    }

                    scf_pg_destroy(pg);
                    scf_iter_destroy(iter);
                    return (0);
               }



ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _ MT-LevelSafe


SEE ALSO
       libscf(3LIB),  scf_entry_add_value(3SCF),   scf_error(3SCF),   scf_han‐
       dle_create(3SCF), attributes(7)



Oracle Solaris 11.4               14 Aug 2017            scf_iter_create(3SCF)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3