--- a/components/visual-panels/smf/src/cmd/rad/mod/smf/datatype.c Fri Jun 29 12:23:11 2012 -0700
+++ b/components/visual-panels/smf/src/cmd/rad/mod/smf/datatype.c Sat Jun 30 06:30:16 2012 -0700
@@ -51,7 +51,7 @@
* Consumed by the API entry points.
*/
-data_t *
+adr_data_t *
create_SMFState(const char *state)
{
if (strcmp(state, SCF_STATE_STRING_UNINIT) == 0) {
@@ -61,11 +61,11 @@
} else if (strcmp(state, SCF_STATE_STRING_LEGACY) == 0) {
return (&e__SMFState_LEGACY);
} else {
- return (data_new_enum_byname(&t__SMFState, state));
+ return (adr_data_new_enum_byname(&t__SMFState, state));
}
}
-static data_t *
+static adr_data_t *
create_DepGrouping(const char *grouping)
{
if (strcmp(grouping, SCF_DEP_REQUIRE_ALL) == 0)
@@ -79,7 +79,7 @@
return (NULL);
}
-static data_t *
+static adr_data_t *
create_DepRestart(const char *restarton)
{
if (strcmp(restarton, SCF_DEP_RESET_ON_ERROR) == 0)
@@ -93,21 +93,21 @@
return (NULL);
}
-static data_t *
+static adr_data_t *
create_PropertyType(scf_type_t type)
{
- data_t *result = data_new_enum(&t__PropertyType, type);
+ adr_data_t *result = adr_data_new_enum(&t__PropertyType, type);
assert(result != NULL);
return (result);
}
scf_type_t
-from_PropertyType(data_t *type)
+from_PropertyType(adr_data_t *type)
{
- return (enum_tovalue(type));
+ return (adr_enum_tovalue(type));
}
-static data_t *
+static adr_data_t *
create_PropertyVisibility(uint8_t visibility)
{
switch (visibility) {
@@ -129,7 +129,7 @@
*/
svcerr_t
create_Dependency(scf_handle_t *scfhandle, scf_propertygroup_t *pg,
- data_t **ret)
+ adr_data_t **ret)
{
svcerr_t se = SE_OK;
char type[max_pgtype + 1];
@@ -159,31 +159,31 @@
goto out;
}
- data_t *group = create_DepGrouping(grouping);
- data_t *restart = create_DepRestart(restarton);
+ adr_data_t *group = create_DepGrouping(grouping);
+ adr_data_t *restart = create_DepRestart(restarton);
if (group == NULL || restart == NULL) {
se = SE_NOTFOUND;
goto out;
}
- data_t *result = data_new_struct(&t__Dependency);
- struct_set(result, "name", data_new_string(pgname, lt_copy));
- struct_set(result, "grouping", group);
- struct_set(result, "restartOn", restart);
- data_t *array = data_new_array(&t_array_string, 5);
- struct_set(result, "target", array);
+ adr_data_t *result = adr_data_new_struct(&t__Dependency);
+ adr_struct_set(result, "name", adr_data_new_string(pgname, LT_COPY));
+ adr_struct_set(result, "grouping", group);
+ adr_struct_set(result, "restartOn", restart);
+ adr_data_t *array = adr_data_new_array(&adr_t_array_string, 5);
+ adr_struct_set(result, "target", array);
while (scf_iter_next_value(iter, val) > 0) {
if (scf_value_get_as_string(val, type, sizeof (type)) == -1) {
se = smfu_maperr(scf_error());
- data_free(result);
+ adr_data_free(result);
goto out;
}
- (void) array_add(array, data_new_string(type, lt_copy));
+ (void) adr_array_add(array, adr_data_new_string(type, LT_COPY));
}
- if (!data_verify(result, NULL, B_TRUE)) {
+ if (!adr_data_verify(result, NULL, B_TRUE)) {
se = SE_FATAL;
- data_free(result);
+ adr_data_free(result);
goto out;
}
@@ -202,7 +202,8 @@
* a man page and should be skipped.
*/
svcerr_t
-create_Manpage(scf_handle_t *scfhandle, scf_propertygroup_t *pg, data_t **ret)
+create_Manpage(scf_handle_t *scfhandle, scf_propertygroup_t *pg,
+ adr_data_t **ret)
{
char manpath[max_value + 1];
char section[max_value + 1];
@@ -239,22 +240,24 @@
goto out;
}
- data_t *result = data_new_struct(&t__Manpage);
- struct_set(result, "title", data_new_string(title, lt_copy));
- struct_set(result, "section", data_new_string(section, lt_copy));
+ adr_data_t *result = adr_data_new_struct(&t__Manpage);
+ adr_struct_set(result, "title", adr_data_new_string(title, LT_COPY));
+ adr_struct_set(result, "section",
+ adr_data_new_string(section, LT_COPY));
if (strcmp(manpath, ":default") != 0) {
- data_t *mp = data_new_string(manpath, lt_copy);
+ adr_data_t *mp = adr_data_new_string(manpath, LT_COPY);
if (mp == NULL) {
se = SE_FATAL;
- data_free(result);
+ adr_data_free(result);
goto out;
}
- struct_set(result, "path", data_new_string(manpath, lt_copy));
+ adr_struct_set(result, "path",
+ adr_data_new_string(manpath, LT_COPY));
}
- if (!data_verify(result, NULL, B_TRUE)) {
+ if (!adr_data_verify(result, NULL, B_TRUE)) {
se = SE_FATAL;
- data_free(result);
+ adr_data_free(result);
goto out;
}
@@ -272,7 +275,8 @@
* a doclink and should be skipped.
*/
svcerr_t
-create_Doclink(scf_handle_t *scfhandle, scf_propertygroup_t *pg, data_t **ret)
+create_Doclink(scf_handle_t *scfhandle, scf_propertygroup_t *pg,
+ adr_data_t **ret)
{
char name[max_value + 1];
char uri[max_value + 1];
@@ -304,13 +308,13 @@
goto out;
}
- data_t *result = data_new_struct(&t__Doclink);
- struct_set(result, "name", data_new_string(name, lt_copy));
- struct_set(result, "uri", data_new_string(uri, lt_copy));
+ adr_data_t *result = adr_data_new_struct(&t__Doclink);
+ adr_struct_set(result, "name", adr_data_new_string(name, LT_COPY));
+ adr_struct_set(result, "uri", adr_data_new_string(uri, LT_COPY));
- if (!data_verify(result, NULL, B_TRUE)) {
+ if (!adr_data_verify(result, NULL, B_TRUE)) {
se = SE_FATAL;
- data_free(result);
+ adr_data_free(result);
goto out;
}
@@ -322,7 +326,7 @@
}
svcerr_t
-create_PropertyGroup(scf_propertygroup_t *pg, data_t **ret)
+create_PropertyGroup(scf_propertygroup_t *pg, adr_data_t **ret)
{
char name[max_value + 1];
char type[max_pgtype + 1];
@@ -336,14 +340,14 @@
goto out;
}
- data_t *result = data_new_struct(&t__PropertyGroup);
- struct_set(result, "name", data_new_string(name, lt_copy));
- struct_set(result, "type", data_new_string(type, lt_copy));
- struct_set(result, "flags", data_new_uinteger(flags));
+ adr_data_t *result = adr_data_new_struct(&t__PropertyGroup);
+ adr_struct_set(result, "name", adr_data_new_string(name, LT_COPY));
+ adr_struct_set(result, "type", adr_data_new_string(type, LT_COPY));
+ adr_struct_set(result, "flags", adr_data_new_uinteger(flags));
- if (!data_verify(result, NULL, B_TRUE)) {
+ if (!adr_data_verify(result, NULL, B_TRUE)) {
se = SE_FATAL;
- data_free(result);
+ adr_data_free(result);
goto out;
}
@@ -354,7 +358,7 @@
svcerr_t
create_Property(scf_property_t *prop, scf_iter_t *iter, scf_value_t *value,
- data_t **ret, data_t **error)
+ adr_data_t **ret, adr_data_t **error)
{
char name[max_name + 1];
scf_type_t type;
@@ -364,15 +368,16 @@
scf_iter_property_values(iter, prop))
return (smfu_maperr(scf_error()));
- data_t *values = data_new_array(&t_array_string, 5);
+ adr_data_t *values = adr_data_new_array(&adr_t_array_string, 5);
int err;
while ((err = scf_iter_next_value(iter, value)) > 0) {
char *valstr;
if (smfu_value_get_string(value, &valstr) != 0) {
- data_free(values);
+ adr_data_free(values);
return (SE_FATAL);
}
- (void) array_add(values, data_new_string(valstr, lt_free));
+ (void) adr_array_add(values,
+ adr_data_new_string(valstr, LT_FREE));
}
if (err != 0) {
if (scf_error() == SCF_ERROR_PERMISSION_DENIED)
@@ -382,10 +387,10 @@
return (smfu_maperr(scf_error()));
}
- data_t *result = data_new_struct(&t__Property);
- struct_set(result, "name", data_new_string(name, lt_copy));
- struct_set(result, "type", create_PropertyType(type));
- struct_set(result, "values", values);
+ adr_data_t *result = adr_data_new_struct(&t__Property);
+ adr_struct_set(result, "name", adr_data_new_string(name, LT_COPY));
+ adr_struct_set(result, "type", create_PropertyType(type));
+ adr_struct_set(result, "values", values);
*ret = result;
return (SE_OK);
@@ -393,14 +398,14 @@
svcerr_t
create_Properties(scf_handle_t *scfhandle, scf_propertygroup_t *pg,
- data_t **ret, data_t **error)
+ adr_data_t **ret, adr_data_t **error)
{
svcerr_t se = SE_OK;
scf_iter_t *piter = scf_iter_create(scfhandle);
scf_iter_t *viter = scf_iter_create(scfhandle);
scf_value_t *value = scf_value_create(scfhandle);
scf_property_t *prop = scf_property_create(scfhandle);
- data_t *result = data_new_array(&t_array__Property, 5);
+ adr_data_t *result = adr_data_new_array(&t_array__Property, 5);
if (piter == NULL || viter == NULL || value == NULL || prop == NULL) {
se = SE_FATAL;
@@ -414,18 +419,18 @@
int err;
while ((err = scf_iter_next_property(piter, prop)) > 0) {
- data_t *propdata = NULL;
+ adr_data_t *propdata = NULL;
if ((se = create_Property(prop, viter, value, &propdata,
error)) != SE_OK)
goto out;
- (void) array_add(result, propdata);
+ (void) adr_array_add(result, propdata);
}
if (err != 0)
se = smfu_maperr(scf_error());
out:
if (se != SE_OK)
- data_free(result);
+ adr_data_free(result);
else
*ret = result;
@@ -439,15 +444,15 @@
svcerr_t
create_ExtendedState(scf_handle_t *scfhandle, scf_instance_t *instance,
- data_t **ret)
+ adr_data_t **ret)
{
scf_propertygroup_t *pg = scf_pg_create(scfhandle);
scf_property_t *prop = scf_property_create(scfhandle);
scf_value_t *value = scf_value_create(scfhandle);
- data_t *result = data_new_struct(&t__ExtendedState);
+ adr_data_t *result = adr_data_new_struct(&t__ExtendedState);
svcerr_t se = SE_FATAL;
int serr;
- data_t *dstr;
+ adr_data_t *dstr;
char *str;
int64_t sec;
int32_t nsec;
@@ -465,7 +470,7 @@
goto scferror;
if (smfu_value_get_string(value, &str) != 0)
goto error;
- struct_set(result, "state", create_SMFState(str));
+ adr_struct_set(result, "state", create_SMFState(str));
free(str);
if (scf_pg_get_property(pg, SCF_PROPERTY_NEXT_STATE, prop) == -1 ||
@@ -473,7 +478,7 @@
goto scferror;
if (smfu_value_get_string(value, &str) != 0)
goto error;
- struct_set(result, "nextState", create_SMFState(str));
+ adr_struct_set(result, "nextState", create_SMFState(str));
free(str);
if (scf_pg_get_property(pg, SCF_PROPERTY_AUX_STATE, prop) == -1 ||
@@ -481,27 +486,28 @@
goto scferror;
if (smfu_value_get_string(value, &str) != 0)
goto error;
- if ((dstr = data_new_string(str, lt_free)) == NULL)
+ if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL)
goto error;
- struct_set(result, "auxstate", dstr);
+ adr_struct_set(result, "auxstate", dstr);
if (scf_pg_get_property(pg, SCF_PROPERTY_STATE_TIMESTAMP, prop) == -1 ||
scf_property_get_value(prop, value) == -1 ||
scf_value_get_time(value, &sec, &nsec) == -1)
goto scferror;
- struct_set(result, "stime", data_new_time(sec, nsec));
+ adr_struct_set(result, "stime", adr_data_new_time(sec, nsec));
if (scf_pg_get_property(pg, SCF_PROPERTY_CONTRACT, prop) == -1 ||
scf_property_get_value(prop, value) == -1) {
if (scf_error() == SCF_ERROR_NOT_FOUND)
- struct_set(result, "contractid", data_new_integer(-1));
+ adr_struct_set(result, "contractid",
+ adr_data_new_integer(-1));
else
goto scferror;
} else if (scf_value_get_count(value, &ctid) == -1) {
goto scferror;
} else {
- struct_set(result, "contractid",
- data_new_integer(ctid <= INT_MAX ? ctid : -1));
+ adr_struct_set(result, "contractid",
+ adr_data_new_integer(ctid <= INT_MAX ? ctid : -1));
}
if ((serr = smfu_read_enabled(instance, pg, prop, value, SCF_PG_GENERAL,
@@ -509,14 +515,15 @@
se = smfu_maperr(serr);
goto error;
}
- data_t *persist = data_new_boolean(bool > 0);
- struct_set(result, "enabled", persist);
+ adr_data_t *persist = adr_data_new_boolean(bool > 0);
+ adr_struct_set(result, "enabled", persist);
if ((serr = smfu_read_enabled(instance, pg, prop, value,
SCF_PG_GENERAL_OVR, &bool)) == 0) {
- struct_set(result, "enabled_temp", data_new_boolean(bool > 0));
+ adr_struct_set(result, "enabled_temp",
+ adr_data_new_boolean(bool > 0));
} else if (serr == SCF_ERROR_NOT_FOUND) {
- struct_set(result, "enabled_temp", data_ref(persist));
+ adr_struct_set(result, "enabled_temp", adr_data_ref(persist));
} else {
se = smfu_maperr(serr);
goto error;
@@ -529,42 +536,42 @@
scferror:
se = smfu_maperr(scf_error());
error:
- data_free(result);
+ adr_data_free(result);
return (se);
}
svcerr_t
-create_PGTemplate(scf_pg_tmpl_t *pgtmpl, const char *locale, data_t **ret)
+create_PGTemplate(scf_pg_tmpl_t *pgtmpl, const char *locale, adr_data_t **ret)
{
- data_t *pt = data_new_struct(&t__PGTemplate);
- data_t *dstr;
+ adr_data_t *pt = adr_data_new_struct(&t__PGTemplate);
+ adr_data_t *dstr;
char *str;
svcerr_t se = SE_FATAL;
if (scf_tmpl_pg_name(pgtmpl, &str) == -1)
goto scferror;
- struct_set(pt, "pgname", data_new_string(str, lt_free));
+ adr_struct_set(pt, "pgname", adr_data_new_string(str, LT_FREE));
if (scf_tmpl_pg_type(pgtmpl, &str) == -1)
goto scferror;
- struct_set(pt, "pgtype", data_new_string(str, lt_free));
+ adr_struct_set(pt, "pgtype", adr_data_new_string(str, LT_FREE));
if (scf_tmpl_pg_common_name(pgtmpl, locale, &str) == -1) {
if (scf_error() != SCF_ERROR_NOT_FOUND)
goto scferror;
} else {
- if ((dstr = data_new_string(str, lt_free)) == NULL)
+ if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL)
goto error;
- struct_set(pt, "name", dstr);
+ adr_struct_set(pt, "name", dstr);
}
if (scf_tmpl_pg_description(pgtmpl, locale, &str) == -1) {
if (scf_error() != SCF_ERROR_NOT_FOUND)
goto scferror;
} else {
- if ((dstr = data_new_string(str, lt_free)) == NULL)
+ if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL)
goto error;
- struct_set(pt, "description", dstr);
+ adr_struct_set(pt, "description", dstr);
}
uint8_t req;
@@ -573,7 +580,7 @@
goto scferror;
req = 0;
}
- struct_set(pt, "required", data_new_boolean(req > 0));
+ adr_struct_set(pt, "required", adr_data_new_boolean(req > 0));
*ret = pt;
return (SE_OK);
@@ -581,21 +588,22 @@
scferror:
se = smfu_maperr(scf_error());
error:
- data_free(pt);
+ adr_data_free(pt);
return (se);
}
svcerr_t
-create_PropTemplate(scf_prop_tmpl_t *proptmpl, const char *locale, data_t **ret)
+create_PropTemplate(scf_prop_tmpl_t *proptmpl, const char *locale,
+ adr_data_t **ret)
{
- data_t *pt = data_new_struct(&t__PropTemplate);
- data_t *dstr;
+ adr_data_t *pt = adr_data_new_struct(&t__PropTemplate);
+ adr_data_t *dstr;
char *str;
svcerr_t se = SE_FATAL;
if (scf_tmpl_prop_name(proptmpl, &str) == -1)
goto error;
- struct_set(pt, "propname", data_new_string(str, lt_free));
+ adr_struct_set(pt, "propname", adr_data_new_string(str, LT_FREE));
scf_type_t type;
if (scf_tmpl_prop_type(proptmpl, &type) == -1) {
@@ -603,33 +611,33 @@
goto scferror;
type = SCF_TYPE_INVALID;
}
- struct_set(pt, "proptype", create_PropertyType(type));
+ adr_struct_set(pt, "proptype", create_PropertyType(type));
if (scf_tmpl_prop_common_name(proptmpl, locale, &str) == -1) {
if (scf_error() != SCF_ERROR_NOT_FOUND)
goto scferror;
} else {
- if ((dstr = data_new_string(str, lt_free)) == NULL)
+ if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL)
goto error;
- struct_set(pt, "name", dstr);
+ adr_struct_set(pt, "name", dstr);
}
if (scf_tmpl_prop_description(proptmpl, locale, &str) == -1) {
if (scf_error() != SCF_ERROR_NOT_FOUND)
goto scferror;
} else {
- if ((dstr = data_new_string(str, lt_free)) == NULL)
+ if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL)
goto error;
- struct_set(pt, "description", dstr);
+ adr_struct_set(pt, "description", dstr);
}
if (scf_tmpl_prop_units(proptmpl, locale, &str) == -1) {
if (scf_error() != SCF_ERROR_NOT_FOUND)
goto scferror;
} else {
- if ((dstr = data_new_string(str, lt_free)) == NULL)
+ if ((dstr = adr_data_new_string(str, LT_FREE)) == NULL)
goto error;
- struct_set(pt, "units", dstr);
+ adr_struct_set(pt, "units", dstr);
}
uint8_t req;
@@ -638,7 +646,7 @@
goto scferror;
req = 0;
}
- struct_set(pt, "required", data_new_boolean(req > 0));
+ adr_struct_set(pt, "required", adr_data_new_boolean(req > 0));
uint64_t min, max;
if (scf_tmpl_prop_cardinality(proptmpl, &min, &max) == -1) {
@@ -646,8 +654,8 @@
goto scferror;
min = max = 0;
}
- struct_set(pt, "cardinality_min", data_new_ulong(min));
- struct_set(pt, "cardinality_max", data_new_ulong(max));
+ adr_struct_set(pt, "cardinality_min", adr_data_new_ulong(min));
+ adr_struct_set(pt, "cardinality_max", adr_data_new_ulong(max));
uint8_t vis;
if (scf_tmpl_prop_visibility(proptmpl, &vis) == -1) {
@@ -655,20 +663,20 @@
goto scferror;
vis = SCF_TMPL_VISIBILITY_READWRITE;
}
- struct_set(pt, "visibility", create_PropertyVisibility(vis));
+ adr_struct_set(pt, "visibility", create_PropertyVisibility(vis));
scf_values_t values;
if (scf_tmpl_prop_internal_seps(proptmpl, &values) == 0) {
- data_t *array =
- data_new_array(&t_array_string, values.value_count);
+ adr_data_t *array =
+ adr_data_new_array(&adr_t_array_string, values.value_count);
for (int i = 0; i < values.value_count; i++)
- (void) array_add(array, data_new_string(
- values.values_as_strings[i], lt_copy));
- if (!data_verify(array, NULL, B_TRUE)) {
- data_free(array);
+ (void) adr_array_add(array, adr_data_new_string(
+ values.values_as_strings[i], LT_COPY));
+ if (!adr_data_verify(array, NULL, B_TRUE)) {
+ adr_data_free(array);
goto error;
}
- struct_set(pt, "separators", array);
+ adr_struct_set(pt, "separators", array);
scf_values_destroy(&values);
} else {
if (scf_error() != SCF_ERROR_NOT_FOUND)
@@ -681,14 +689,14 @@
scferror:
se = smfu_maperr(scf_error());
error:
- data_free(pt);
+ adr_data_free(pt);
return (se);
}
svcerr_t
create_Instance(scf_instance_t *instance, const char *sname, const char *iname,
- data_t **data, scf_propertygroup_t *pg, scf_property_t *prop,
+ adr_data_t **data, scf_propertygroup_t *pg, scf_property_t *prop,
scf_value_t *val)
{
char statestr[MAX_SCF_STATE_STRING_SZ];
@@ -713,16 +721,16 @@
scf_value_get_time(val, &seconds, &nsec) != 0)
return (smfu_maperr(scf_error()));
- data_t *inst = data_new_struct(&t__Instance);
- struct_set(inst, "fmri",
- data_new_string(smfu_fmri_alloc(sname, iname), lt_free));
- struct_set(inst, "objectName",
- data_new_name(smfu_name_alloc(sname, iname)));
- struct_set(inst, "stime", data_new_time(seconds, nsec));
- struct_set(inst, "state", create_SMFState(statestr));
+ adr_data_t *inst = adr_data_new_struct(&t__Instance);
+ adr_struct_set(inst, "fmri",
+ adr_data_new_string(smfu_fmri_alloc(sname, iname), LT_FREE));
+ adr_struct_set(inst, "objectName",
+ adr_data_new_name(smfu_name_alloc(sname, iname)));
+ adr_struct_set(inst, "stime", adr_data_new_time(seconds, nsec));
+ adr_struct_set(inst, "state", create_SMFState(statestr));
- if (!data_verify(inst, NULL, B_TRUE)) {
- data_free(inst);
+ if (!adr_data_verify(inst, NULL, B_TRUE)) {
+ adr_data_free(inst);
return (SE_FATAL);
}