Jordan Brown wrote:
> Given an FMRI and a property name (pg/name), I'm trying to retrieve a 
> string value.
> 
> It appears to me that this requires approximately 10 libscf calls, not 
> counting error handling:
> 
>         h = scf_handle_create(SCF_VERSION);
>         scf_handle_bind(h);
>         prop = scf_property_create(h);
>         sprintf(buf, "%s/:properties/%s", fmri, propname);
>         scf_handle_decode_fmri(h, buf, NULL, NULL,
>             NULL, NULL, prop, SCF_DECODE_FMRI_EXACT);
>         value = scf_value_create(h);
>         scf_property_get_value(prop, value);
>         scf_value_get_astring(value, buf, sizeof (buf));
>         scf_value_destroy(value);
>         scf_property_destroy(prop);
>         scf_handle_destroy(h);
> 
> Is there a simpler way?  Alternatively, is there anything missing from 
> that sequence?

You've basically got it.

You could try scf_simple_prop_get() and friends, but I don't recommend it 
as it doesn't tend to be that much simpler. :/

If you're in ON, dep was experimenting with scf_read_propvec() and friends 
as a simpler interface, which you could take a look at -- they're private 
functions in libscf.

liane

Reply via email to