int cil_resolve_classmapping(struct cil_tree_node *current, void *extra_args)
{
	int rc = SEPOL_ERR;
	struct cil_classmapping *mapping = current->data;
	struct cil_class *map = NULL;
	struct cil_perm *mp = NULL;
	struct cil_symtab_datum *datum = NULL;
	struct cil_list_item *curr;

	rc = cil_resolve_name(current, mapping->map_class_str, CIL_SYM_CLASSES, extra_args, &datum);
	if (rc != SEPOL_OK) {
		goto exit;
	}
	map = (struct cil_class*)datum;

	rc = cil_symtab_get_datum(&map->perms, mapping->map_perm_str, &datum);
	if (rc != SEPOL_OK) {
		goto exit;
	}

	mp = (struct cil_perm*)datum;

	rc = cil_resolve_classperms_list(current, mapping->classperms, extra_args);
	if (rc != SEPOL_OK) {
		goto exit;
	}

	if (mp->classperms == NULL) {
		cil_list_init(&mp->classperms, CIL_CLASSPERMS);
	}

	cil_list_for_each(curr, mapping->classperms) {
		cil_list_append(mp->classperms, curr->flavor, curr->data);
	}

	return SEPOL_OK;

exit:
	return rc;
}
int cil_resolve_classmapping(struct cil_tree_node *current, void *extra_args)
{
	int rc = SEPOL_ERR;
	struct cil_classmapping *mapping = current->data;
	struct cil_class *map = NULL;
	struct cil_perm *mp = NULL;
	struct cil_symtab_datum *datum = NULL;
	struct cil_list_item *curr;

	rc = cil_resolve_name(current, mapping->map_class_str, CIL_SYM_CLASSES, extra_args, &datum);
	if (rc != SEPOL_OK) {
		goto exit;
	}
	map = (struct cil_class*)datum;

	rc = cil_symtab_get_datum(&map->perms, mapping->map_perm_str, &datum);
	if (rc != SEPOL_OK) {
		goto exit;
	}

	mp = (struct cil_perm*)datum;

	rc = cil_resolve_classperms_list(current, mapping->classperms, extra_args);
	if (rc != SEPOL_OK) {
		goto exit;
	}

	if (mp->classperms == NULL) {
		cil_list_init(&mp->classperms, CIL_CLASSPERMS);
	}

	cil_list_for_each(curr, mapping->classperms) {
		cil_list_append(mp->classperms, curr->flavor, curr->data);
	}

	return SEPOL_OK;

exit:
	return rc;
}