157 scf_iter_property_values(iter, prop) != 0) { |
157 scf_iter_property_values(iter, prop) != 0) { |
158 se = smfu_maperr(scf_error()); |
158 se = smfu_maperr(scf_error()); |
159 goto out; |
159 goto out; |
160 } |
160 } |
161 |
161 |
162 data_t *group = create_DepGrouping(grouping); |
162 adr_data_t *group = create_DepGrouping(grouping); |
163 data_t *restart = create_DepRestart(restarton); |
163 adr_data_t *restart = create_DepRestart(restarton); |
164 if (group == NULL || restart == NULL) { |
164 if (group == NULL || restart == NULL) { |
165 se = SE_NOTFOUND; |
165 se = SE_NOTFOUND; |
166 goto out; |
166 goto out; |
167 } |
167 } |
168 |
168 |
169 data_t *result = data_new_struct(&t__Dependency); |
169 adr_data_t *result = adr_data_new_struct(&t__Dependency); |
170 struct_set(result, "name", data_new_string(pgname, lt_copy)); |
170 adr_struct_set(result, "name", adr_data_new_string(pgname, LT_COPY)); |
171 struct_set(result, "grouping", group); |
171 adr_struct_set(result, "grouping", group); |
172 struct_set(result, "restartOn", restart); |
172 adr_struct_set(result, "restartOn", restart); |
173 data_t *array = data_new_array(&t_array_string, 5); |
173 adr_data_t *array = adr_data_new_array(&adr_t_array_string, 5); |
174 struct_set(result, "target", array); |
174 adr_struct_set(result, "target", array); |
175 |
175 |
176 while (scf_iter_next_value(iter, val) > 0) { |
176 while (scf_iter_next_value(iter, val) > 0) { |
177 if (scf_value_get_as_string(val, type, sizeof (type)) == -1) { |
177 if (scf_value_get_as_string(val, type, sizeof (type)) == -1) { |
178 se = smfu_maperr(scf_error()); |
178 se = smfu_maperr(scf_error()); |
179 data_free(result); |
179 adr_data_free(result); |
180 goto out; |
180 goto out; |
181 } |
181 } |
182 (void) array_add(array, data_new_string(type, lt_copy)); |
182 (void) adr_array_add(array, adr_data_new_string(type, LT_COPY)); |
183 } |
183 } |
184 if (!data_verify(result, NULL, B_TRUE)) { |
184 if (!adr_data_verify(result, NULL, B_TRUE)) { |
185 se = SE_FATAL; |
185 se = SE_FATAL; |
186 data_free(result); |
186 adr_data_free(result); |
187 goto out; |
187 goto out; |
188 } |
188 } |
189 |
189 |
190 *ret = result; |
190 *ret = result; |
191 out: |
191 out: |
334 scf_pg_get_flags(pg, &flags) == -1) { |
338 scf_pg_get_flags(pg, &flags) == -1) { |
335 se = smfu_maperr(scf_error()); |
339 se = smfu_maperr(scf_error()); |
336 goto out; |
340 goto out; |
337 } |
341 } |
338 |
342 |
339 data_t *result = data_new_struct(&t__PropertyGroup); |
343 adr_data_t *result = adr_data_new_struct(&t__PropertyGroup); |
340 struct_set(result, "name", data_new_string(name, lt_copy)); |
344 adr_struct_set(result, "name", adr_data_new_string(name, LT_COPY)); |
341 struct_set(result, "type", data_new_string(type, lt_copy)); |
345 adr_struct_set(result, "type", adr_data_new_string(type, LT_COPY)); |
342 struct_set(result, "flags", data_new_uinteger(flags)); |
346 adr_struct_set(result, "flags", adr_data_new_uinteger(flags)); |
343 |
347 |
344 if (!data_verify(result, NULL, B_TRUE)) { |
348 if (!adr_data_verify(result, NULL, B_TRUE)) { |
345 se = SE_FATAL; |
349 se = SE_FATAL; |
346 data_free(result); |
350 adr_data_free(result); |
347 goto out; |
351 goto out; |
348 } |
352 } |
349 |
353 |
350 *ret = result; |
354 *ret = result; |
351 out: |
355 out: |
352 return (se); |
356 return (se); |
353 } |
357 } |
354 |
358 |
355 svcerr_t |
359 svcerr_t |
356 create_Property(scf_property_t *prop, scf_iter_t *iter, scf_value_t *value, |
360 create_Property(scf_property_t *prop, scf_iter_t *iter, scf_value_t *value, |
357 data_t **ret, data_t **error) |
361 adr_data_t **ret, adr_data_t **error) |
358 { |
362 { |
359 char name[max_name + 1]; |
363 char name[max_name + 1]; |
360 scf_type_t type; |
364 scf_type_t type; |
361 |
365 |
362 if (scf_property_get_name(prop, name, sizeof (name)) == -1 || |
366 if (scf_property_get_name(prop, name, sizeof (name)) == -1 || |
363 scf_property_type(prop, &type) == -1 || |
367 scf_property_type(prop, &type) == -1 || |
364 scf_iter_property_values(iter, prop)) |
368 scf_iter_property_values(iter, prop)) |
365 return (smfu_maperr(scf_error())); |
369 return (smfu_maperr(scf_error())); |
366 |
370 |
367 data_t *values = data_new_array(&t_array_string, 5); |
371 adr_data_t *values = adr_data_new_array(&adr_t_array_string, 5); |
368 int err; |
372 int err; |
369 while ((err = scf_iter_next_value(iter, value)) > 0) { |
373 while ((err = scf_iter_next_value(iter, value)) > 0) { |
370 char *valstr; |
374 char *valstr; |
371 if (smfu_value_get_string(value, &valstr) != 0) { |
375 if (smfu_value_get_string(value, &valstr) != 0) { |
372 data_free(values); |
376 adr_data_free(values); |
373 return (SE_FATAL); |
377 return (SE_FATAL); |
374 } |
378 } |
375 (void) array_add(values, data_new_string(valstr, lt_free)); |
379 (void) adr_array_add(values, |
|
380 adr_data_new_string(valstr, LT_FREE)); |
376 } |
381 } |
377 if (err != 0) { |
382 if (err != 0) { |
378 if (scf_error() == SCF_ERROR_PERMISSION_DENIED) |
383 if (scf_error() == SCF_ERROR_PERMISSION_DENIED) |
379 return (error_scf(error, &e__ErrorCode_DENIED, NULL, |
384 return (error_scf(error, &e__ErrorCode_DENIED, NULL, |
380 NULL, NULL)); |
385 NULL, NULL)); |
381 else |
386 else |
382 return (smfu_maperr(scf_error())); |
387 return (smfu_maperr(scf_error())); |
383 } |
388 } |
384 |
389 |
385 data_t *result = data_new_struct(&t__Property); |
390 adr_data_t *result = adr_data_new_struct(&t__Property); |
386 struct_set(result, "name", data_new_string(name, lt_copy)); |
391 adr_struct_set(result, "name", adr_data_new_string(name, LT_COPY)); |
387 struct_set(result, "type", create_PropertyType(type)); |
392 adr_struct_set(result, "type", create_PropertyType(type)); |
388 struct_set(result, "values", values); |
393 adr_struct_set(result, "values", values); |
389 *ret = result; |
394 *ret = result; |
390 |
395 |
391 return (SE_OK); |
396 return (SE_OK); |
392 } |
397 } |
393 |
398 |
394 svcerr_t |
399 svcerr_t |
395 create_Properties(scf_handle_t *scfhandle, scf_propertygroup_t *pg, |
400 create_Properties(scf_handle_t *scfhandle, scf_propertygroup_t *pg, |
396 data_t **ret, data_t **error) |
401 adr_data_t **ret, adr_data_t **error) |
397 { |
402 { |
398 svcerr_t se = SE_OK; |
403 svcerr_t se = SE_OK; |
399 scf_iter_t *piter = scf_iter_create(scfhandle); |
404 scf_iter_t *piter = scf_iter_create(scfhandle); |
400 scf_iter_t *viter = scf_iter_create(scfhandle); |
405 scf_iter_t *viter = scf_iter_create(scfhandle); |
401 scf_value_t *value = scf_value_create(scfhandle); |
406 scf_value_t *value = scf_value_create(scfhandle); |
402 scf_property_t *prop = scf_property_create(scfhandle); |
407 scf_property_t *prop = scf_property_create(scfhandle); |
403 data_t *result = data_new_array(&t_array__Property, 5); |
408 adr_data_t *result = adr_data_new_array(&t_array__Property, 5); |
404 |
409 |
405 if (piter == NULL || viter == NULL || value == NULL || prop == NULL) { |
410 if (piter == NULL || viter == NULL || value == NULL || prop == NULL) { |
406 se = SE_FATAL; |
411 se = SE_FATAL; |
407 goto out; |
412 goto out; |
408 } |
413 } |
463 if (scf_pg_get_property(pg, SCF_PROPERTY_STATE, prop) == -1 || |
468 if (scf_pg_get_property(pg, SCF_PROPERTY_STATE, prop) == -1 || |
464 scf_property_get_value(prop, value) == -1) |
469 scf_property_get_value(prop, value) == -1) |
465 goto scferror; |
470 goto scferror; |
466 if (smfu_value_get_string(value, &str) != 0) |
471 if (smfu_value_get_string(value, &str) != 0) |
467 goto error; |
472 goto error; |
468 struct_set(result, "state", create_SMFState(str)); |
473 adr_struct_set(result, "state", create_SMFState(str)); |
469 free(str); |
474 free(str); |
470 |
475 |
471 if (scf_pg_get_property(pg, SCF_PROPERTY_NEXT_STATE, prop) == -1 || |
476 if (scf_pg_get_property(pg, SCF_PROPERTY_NEXT_STATE, prop) == -1 || |
472 scf_property_get_value(prop, value) == -1) |
477 scf_property_get_value(prop, value) == -1) |
473 goto scferror; |
478 goto scferror; |
474 if (smfu_value_get_string(value, &str) != 0) |
479 if (smfu_value_get_string(value, &str) != 0) |
475 goto error; |
480 goto error; |
476 struct_set(result, "nextState", create_SMFState(str)); |
481 adr_struct_set(result, "nextState", create_SMFState(str)); |
477 free(str); |
482 free(str); |
478 |
483 |
479 if (scf_pg_get_property(pg, SCF_PROPERTY_AUX_STATE, prop) == -1 || |
484 if (scf_pg_get_property(pg, SCF_PROPERTY_AUX_STATE, prop) == -1 || |
480 scf_property_get_value(prop, value) == -1) |
485 scf_property_get_value(prop, value) == -1) |
481 goto scferror; |
486 goto scferror; |
482 if (smfu_value_get_string(value, &str) != 0) |
487 if (smfu_value_get_string(value, &str) != 0) |
483 goto error; |
488 goto error; |
484 if ((dstr = data_new_string(str, lt_free)) == NULL) |
489 if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL) |
485 goto error; |
490 goto error; |
486 struct_set(result, "auxstate", dstr); |
491 adr_struct_set(result, "auxstate", dstr); |
487 |
492 |
488 if (scf_pg_get_property(pg, SCF_PROPERTY_STATE_TIMESTAMP, prop) == -1 || |
493 if (scf_pg_get_property(pg, SCF_PROPERTY_STATE_TIMESTAMP, prop) == -1 || |
489 scf_property_get_value(prop, value) == -1 || |
494 scf_property_get_value(prop, value) == -1 || |
490 scf_value_get_time(value, &sec, &nsec) == -1) |
495 scf_value_get_time(value, &sec, &nsec) == -1) |
491 goto scferror; |
496 goto scferror; |
492 struct_set(result, "stime", data_new_time(sec, nsec)); |
497 adr_struct_set(result, "stime", adr_data_new_time(sec, nsec)); |
493 |
498 |
494 if (scf_pg_get_property(pg, SCF_PROPERTY_CONTRACT, prop) == -1 || |
499 if (scf_pg_get_property(pg, SCF_PROPERTY_CONTRACT, prop) == -1 || |
495 scf_property_get_value(prop, value) == -1) { |
500 scf_property_get_value(prop, value) == -1) { |
496 if (scf_error() == SCF_ERROR_NOT_FOUND) |
501 if (scf_error() == SCF_ERROR_NOT_FOUND) |
497 struct_set(result, "contractid", data_new_integer(-1)); |
502 adr_struct_set(result, "contractid", |
|
503 adr_data_new_integer(-1)); |
498 else |
504 else |
499 goto scferror; |
505 goto scferror; |
500 } else if (scf_value_get_count(value, &ctid) == -1) { |
506 } else if (scf_value_get_count(value, &ctid) == -1) { |
501 goto scferror; |
507 goto scferror; |
502 } else { |
508 } else { |
503 struct_set(result, "contractid", |
509 adr_struct_set(result, "contractid", |
504 data_new_integer(ctid <= INT_MAX ? ctid : -1)); |
510 adr_data_new_integer(ctid <= INT_MAX ? ctid : -1)); |
505 } |
511 } |
506 |
512 |
507 if ((serr = smfu_read_enabled(instance, pg, prop, value, SCF_PG_GENERAL, |
513 if ((serr = smfu_read_enabled(instance, pg, prop, value, SCF_PG_GENERAL, |
508 &bool)) != 0) { |
514 &bool)) != 0) { |
509 se = smfu_maperr(serr); |
515 se = smfu_maperr(serr); |
510 goto error; |
516 goto error; |
511 } |
517 } |
512 data_t *persist = data_new_boolean(bool > 0); |
518 adr_data_t *persist = adr_data_new_boolean(bool > 0); |
513 struct_set(result, "enabled", persist); |
519 adr_struct_set(result, "enabled", persist); |
514 |
520 |
515 if ((serr = smfu_read_enabled(instance, pg, prop, value, |
521 if ((serr = smfu_read_enabled(instance, pg, prop, value, |
516 SCF_PG_GENERAL_OVR, &bool)) == 0) { |
522 SCF_PG_GENERAL_OVR, &bool)) == 0) { |
517 struct_set(result, "enabled_temp", data_new_boolean(bool > 0)); |
523 adr_struct_set(result, "enabled_temp", |
|
524 adr_data_new_boolean(bool > 0)); |
518 } else if (serr == SCF_ERROR_NOT_FOUND) { |
525 } else if (serr == SCF_ERROR_NOT_FOUND) { |
519 struct_set(result, "enabled_temp", data_ref(persist)); |
526 adr_struct_set(result, "enabled_temp", adr_data_ref(persist)); |
520 } else { |
527 } else { |
521 se = smfu_maperr(serr); |
528 se = smfu_maperr(serr); |
522 goto error; |
529 goto error; |
523 } |
530 } |
524 |
531 |
527 return (SE_OK); |
534 return (SE_OK); |
528 |
535 |
529 scferror: |
536 scferror: |
530 se = smfu_maperr(scf_error()); |
537 se = smfu_maperr(scf_error()); |
531 error: |
538 error: |
532 data_free(result); |
539 adr_data_free(result); |
533 return (se); |
540 return (se); |
534 } |
541 } |
535 |
542 |
536 svcerr_t |
543 svcerr_t |
537 create_PGTemplate(scf_pg_tmpl_t *pgtmpl, const char *locale, data_t **ret) |
544 create_PGTemplate(scf_pg_tmpl_t *pgtmpl, const char *locale, adr_data_t **ret) |
538 { |
545 { |
539 data_t *pt = data_new_struct(&t__PGTemplate); |
546 adr_data_t *pt = adr_data_new_struct(&t__PGTemplate); |
540 data_t *dstr; |
547 adr_data_t *dstr; |
541 char *str; |
548 char *str; |
542 svcerr_t se = SE_FATAL; |
549 svcerr_t se = SE_FATAL; |
543 |
550 |
544 if (scf_tmpl_pg_name(pgtmpl, &str) == -1) |
551 if (scf_tmpl_pg_name(pgtmpl, &str) == -1) |
545 goto scferror; |
552 goto scferror; |
546 struct_set(pt, "pgname", data_new_string(str, lt_free)); |
553 adr_struct_set(pt, "pgname", adr_data_new_string(str, LT_FREE)); |
547 |
554 |
548 if (scf_tmpl_pg_type(pgtmpl, &str) == -1) |
555 if (scf_tmpl_pg_type(pgtmpl, &str) == -1) |
549 goto scferror; |
556 goto scferror; |
550 struct_set(pt, "pgtype", data_new_string(str, lt_free)); |
557 adr_struct_set(pt, "pgtype", adr_data_new_string(str, LT_FREE)); |
551 |
558 |
552 if (scf_tmpl_pg_common_name(pgtmpl, locale, &str) == -1) { |
559 if (scf_tmpl_pg_common_name(pgtmpl, locale, &str) == -1) { |
553 if (scf_error() != SCF_ERROR_NOT_FOUND) |
560 if (scf_error() != SCF_ERROR_NOT_FOUND) |
554 goto scferror; |
561 goto scferror; |
555 } else { |
562 } else { |
556 if ((dstr = data_new_string(str, lt_free)) == NULL) |
563 if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL) |
557 goto error; |
564 goto error; |
558 struct_set(pt, "name", dstr); |
565 adr_struct_set(pt, "name", dstr); |
559 } |
566 } |
560 |
567 |
561 if (scf_tmpl_pg_description(pgtmpl, locale, &str) == -1) { |
568 if (scf_tmpl_pg_description(pgtmpl, locale, &str) == -1) { |
562 if (scf_error() != SCF_ERROR_NOT_FOUND) |
569 if (scf_error() != SCF_ERROR_NOT_FOUND) |
563 goto scferror; |
570 goto scferror; |
564 } else { |
571 } else { |
565 if ((dstr = data_new_string(str, lt_free)) == NULL) |
572 if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL) |
566 goto error; |
573 goto error; |
567 struct_set(pt, "description", dstr); |
574 adr_struct_set(pt, "description", dstr); |
568 } |
575 } |
569 |
576 |
570 uint8_t req; |
577 uint8_t req; |
571 if (scf_tmpl_pg_required(pgtmpl, &req) == -1) { |
578 if (scf_tmpl_pg_required(pgtmpl, &req) == -1) { |
572 if (scf_error() != SCF_ERROR_NOT_FOUND) |
579 if (scf_error() != SCF_ERROR_NOT_FOUND) |
573 goto scferror; |
580 goto scferror; |
574 req = 0; |
581 req = 0; |
575 } |
582 } |
576 struct_set(pt, "required", data_new_boolean(req > 0)); |
583 adr_struct_set(pt, "required", adr_data_new_boolean(req > 0)); |
577 |
584 |
578 *ret = pt; |
585 *ret = pt; |
579 return (SE_OK); |
586 return (SE_OK); |
580 |
587 |
581 scferror: |
588 scferror: |
582 se = smfu_maperr(scf_error()); |
589 se = smfu_maperr(scf_error()); |
583 error: |
590 error: |
584 data_free(pt); |
591 adr_data_free(pt); |
585 return (se); |
592 return (se); |
586 } |
593 } |
587 |
594 |
588 svcerr_t |
595 svcerr_t |
589 create_PropTemplate(scf_prop_tmpl_t *proptmpl, const char *locale, data_t **ret) |
596 create_PropTemplate(scf_prop_tmpl_t *proptmpl, const char *locale, |
590 { |
597 adr_data_t **ret) |
591 data_t *pt = data_new_struct(&t__PropTemplate); |
598 { |
592 data_t *dstr; |
599 adr_data_t *pt = adr_data_new_struct(&t__PropTemplate); |
|
600 adr_data_t *dstr; |
593 char *str; |
601 char *str; |
594 svcerr_t se = SE_FATAL; |
602 svcerr_t se = SE_FATAL; |
595 |
603 |
596 if (scf_tmpl_prop_name(proptmpl, &str) == -1) |
604 if (scf_tmpl_prop_name(proptmpl, &str) == -1) |
597 goto error; |
605 goto error; |
598 struct_set(pt, "propname", data_new_string(str, lt_free)); |
606 adr_struct_set(pt, "propname", adr_data_new_string(str, LT_FREE)); |
599 |
607 |
600 scf_type_t type; |
608 scf_type_t type; |
601 if (scf_tmpl_prop_type(proptmpl, &type) == -1) { |
609 if (scf_tmpl_prop_type(proptmpl, &type) == -1) { |
602 if (scf_error() != SCF_ERROR_NOT_FOUND) |
610 if (scf_error() != SCF_ERROR_NOT_FOUND) |
603 goto scferror; |
611 goto scferror; |
604 type = SCF_TYPE_INVALID; |
612 type = SCF_TYPE_INVALID; |
605 } |
613 } |
606 struct_set(pt, "proptype", create_PropertyType(type)); |
614 adr_struct_set(pt, "proptype", create_PropertyType(type)); |
607 |
615 |
608 if (scf_tmpl_prop_common_name(proptmpl, locale, &str) == -1) { |
616 if (scf_tmpl_prop_common_name(proptmpl, locale, &str) == -1) { |
609 if (scf_error() != SCF_ERROR_NOT_FOUND) |
617 if (scf_error() != SCF_ERROR_NOT_FOUND) |
610 goto scferror; |
618 goto scferror; |
611 } else { |
619 } else { |
612 if ((dstr = data_new_string(str, lt_free)) == NULL) |
620 if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL) |
613 goto error; |
621 goto error; |
614 struct_set(pt, "name", dstr); |
622 adr_struct_set(pt, "name", dstr); |
615 } |
623 } |
616 |
624 |
617 if (scf_tmpl_prop_description(proptmpl, locale, &str) == -1) { |
625 if (scf_tmpl_prop_description(proptmpl, locale, &str) == -1) { |
618 if (scf_error() != SCF_ERROR_NOT_FOUND) |
626 if (scf_error() != SCF_ERROR_NOT_FOUND) |
619 goto scferror; |
627 goto scferror; |
620 } else { |
628 } else { |
621 if ((dstr = data_new_string(str, lt_free)) == NULL) |
629 if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL) |
622 goto error; |
630 goto error; |
623 struct_set(pt, "description", dstr); |
631 adr_struct_set(pt, "description", dstr); |
624 } |
632 } |
625 |
633 |
626 if (scf_tmpl_prop_units(proptmpl, locale, &str) == -1) { |
634 if (scf_tmpl_prop_units(proptmpl, locale, &str) == -1) { |
627 if (scf_error() != SCF_ERROR_NOT_FOUND) |
635 if (scf_error() != SCF_ERROR_NOT_FOUND) |
628 goto scferror; |
636 goto scferror; |
629 } else { |
637 } else { |
630 if ((dstr = data_new_string(str, lt_free)) == NULL) |
638 if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL) |
631 goto error; |
639 goto error; |
632 struct_set(pt, "units", dstr); |
640 adr_struct_set(pt, "units", dstr); |
633 } |
641 } |
634 |
642 |
635 uint8_t req; |
643 uint8_t req; |
636 if (scf_tmpl_prop_required(proptmpl, &req) == -1) { |
644 if (scf_tmpl_prop_required(proptmpl, &req) == -1) { |
637 if (scf_error() != SCF_ERROR_NOT_FOUND) |
645 if (scf_error() != SCF_ERROR_NOT_FOUND) |
638 goto scferror; |
646 goto scferror; |
639 req = 0; |
647 req = 0; |
640 } |
648 } |
641 struct_set(pt, "required", data_new_boolean(req > 0)); |
649 adr_struct_set(pt, "required", adr_data_new_boolean(req > 0)); |
642 |
650 |
643 uint64_t min, max; |
651 uint64_t min, max; |
644 if (scf_tmpl_prop_cardinality(proptmpl, &min, &max) == -1) { |
652 if (scf_tmpl_prop_cardinality(proptmpl, &min, &max) == -1) { |
645 if (scf_error() != SCF_ERROR_NOT_FOUND) |
653 if (scf_error() != SCF_ERROR_NOT_FOUND) |
646 goto scferror; |
654 goto scferror; |
647 min = max = 0; |
655 min = max = 0; |
648 } |
656 } |
649 struct_set(pt, "cardinality_min", data_new_ulong(min)); |
657 adr_struct_set(pt, "cardinality_min", adr_data_new_ulong(min)); |
650 struct_set(pt, "cardinality_max", data_new_ulong(max)); |
658 adr_struct_set(pt, "cardinality_max", adr_data_new_ulong(max)); |
651 |
659 |
652 uint8_t vis; |
660 uint8_t vis; |
653 if (scf_tmpl_prop_visibility(proptmpl, &vis) == -1) { |
661 if (scf_tmpl_prop_visibility(proptmpl, &vis) == -1) { |
654 if (scf_error() != SCF_ERROR_NOT_FOUND) |
662 if (scf_error() != SCF_ERROR_NOT_FOUND) |
655 goto scferror; |
663 goto scferror; |
656 vis = SCF_TMPL_VISIBILITY_READWRITE; |
664 vis = SCF_TMPL_VISIBILITY_READWRITE; |
657 } |
665 } |
658 struct_set(pt, "visibility", create_PropertyVisibility(vis)); |
666 adr_struct_set(pt, "visibility", create_PropertyVisibility(vis)); |
659 |
667 |
660 scf_values_t values; |
668 scf_values_t values; |
661 if (scf_tmpl_prop_internal_seps(proptmpl, &values) == 0) { |
669 if (scf_tmpl_prop_internal_seps(proptmpl, &values) == 0) { |
662 data_t *array = |
670 adr_data_t *array = |
663 data_new_array(&t_array_string, values.value_count); |
671 adr_data_new_array(&adr_t_array_string, values.value_count); |
664 for (int i = 0; i < values.value_count; i++) |
672 for (int i = 0; i < values.value_count; i++) |
665 (void) array_add(array, data_new_string( |
673 (void) adr_array_add(array, adr_data_new_string( |
666 values.values_as_strings[i], lt_copy)); |
674 values.values_as_strings[i], LT_COPY)); |
667 if (!data_verify(array, NULL, B_TRUE)) { |
675 if (!adr_data_verify(array, NULL, B_TRUE)) { |
668 data_free(array); |
676 adr_data_free(array); |
669 goto error; |
677 goto error; |
670 } |
678 } |
671 struct_set(pt, "separators", array); |
679 adr_struct_set(pt, "separators", array); |
672 scf_values_destroy(&values); |
680 scf_values_destroy(&values); |
673 } else { |
681 } else { |
674 if (scf_error() != SCF_ERROR_NOT_FOUND) |
682 if (scf_error() != SCF_ERROR_NOT_FOUND) |
675 goto scferror; |
683 goto scferror; |
676 } |
684 } |
711 if (scf_pg_get_property(pg, SCF_PROPERTY_STATE_TIMESTAMP, prop) != 0 || |
719 if (scf_pg_get_property(pg, SCF_PROPERTY_STATE_TIMESTAMP, prop) != 0 || |
712 scf_property_get_value(prop, val) != 0 || |
720 scf_property_get_value(prop, val) != 0 || |
713 scf_value_get_time(val, &seconds, &nsec) != 0) |
721 scf_value_get_time(val, &seconds, &nsec) != 0) |
714 return (smfu_maperr(scf_error())); |
722 return (smfu_maperr(scf_error())); |
715 |
723 |
716 data_t *inst = data_new_struct(&t__Instance); |
724 adr_data_t *inst = adr_data_new_struct(&t__Instance); |
717 struct_set(inst, "fmri", |
725 adr_struct_set(inst, "fmri", |
718 data_new_string(smfu_fmri_alloc(sname, iname), lt_free)); |
726 adr_data_new_string(smfu_fmri_alloc(sname, iname), LT_FREE)); |
719 struct_set(inst, "objectName", |
727 adr_struct_set(inst, "objectName", |
720 data_new_name(smfu_name_alloc(sname, iname))); |
728 adr_data_new_name(smfu_name_alloc(sname, iname))); |
721 struct_set(inst, "stime", data_new_time(seconds, nsec)); |
729 adr_struct_set(inst, "stime", adr_data_new_time(seconds, nsec)); |
722 struct_set(inst, "state", create_SMFState(statestr)); |
730 adr_struct_set(inst, "state", create_SMFState(statestr)); |
723 |
731 |
724 if (!data_verify(inst, NULL, B_TRUE)) { |
732 if (!adr_data_verify(inst, NULL, B_TRUE)) { |
725 data_free(inst); |
733 adr_data_free(inst); |
726 return (SE_FATAL); |
734 return (SE_FATAL); |
727 } |
735 } |
728 |
736 |
729 *data = inst; |
737 *data = inst; |
730 return (SE_OK); |
738 return (SE_OK); |