Example #1
0
static struct oval_record_field *oval_record_field_ITEM_from_sexp(SEXP_t *sexp)
{
	struct oval_sysent *sysent;
	struct oval_record_field *rf;

	sysent = oval_sexp_to_sysent(NULL, NULL, sexp, NULL);
	if (sysent == NULL)
		return NULL;

	rf = oval_record_field_new(OVAL_RECORD_FIELD_ITEM);
	oval_record_field_set_name(rf, oval_sysent_get_name(sysent));
	oval_record_field_set_value(rf, oval_sysent_get_value(sysent));
	oval_record_field_set_datatype(rf, oval_sysent_get_datatype(sysent));
	oval_record_field_set_mask(rf, oval_sysent_get_mask(sysent));
	oval_record_field_set_status(rf, oval_sysent_get_status(sysent));

	oval_sysent_free(sysent);

	return rf;
}
Example #2
0
int oval_record_field_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context,
				oscap_consumer_func consumer, void *user,
				oval_record_field_type_t record_field_type)
{
	int ret = 0, mask;
	char *name;
	oval_datatype_t datatype;
	struct oval_record_field *rf;

	rf = oval_record_field_new(record_field_type);
	if (rf == NULL)
		return -1;

	name = (char *) xmlTextReaderGetAttribute(reader, BAD_CAST "name");
	datatype = oval_datatype_parse(reader, "datatype", OVAL_DATATYPE_STRING);
	mask = oval_parser_boolean_attribute(reader, "mask", 0);

	oval_record_field_set_name(rf, name);
	xmlFree(name);
	oval_record_field_set_datatype(rf, datatype);
	oval_record_field_set_mask(rf, mask);

	switch (record_field_type) {
	case OVAL_RECORD_FIELD_STATE:
	{
		oval_operation_t opr;
		oval_check_t var_check;
		oval_check_t ent_check;
		char *var_ref;

		opr = oval_operation_parse(reader, "operation", OVAL_OPERATION_EQUALS);
		oval_record_field_set_operation(rf, opr);
		var_check = oval_check_parse(reader, "var_check", OVAL_CHECK_ALL);
		oval_record_field_set_var_check(rf, var_check);
		ent_check = oval_check_parse(reader, "entity_check", OVAL_CHECK_ALL);
		oval_record_field_set_ent_check(rf, ent_check);

		var_ref = (char *) xmlTextReaderGetAttribute(reader, BAD_CAST "var_ref");
		if (var_ref == NULL) {
			ret = oscap_parser_text_value(reader, &_oval_record_field_value_consumer, rf);
		} else {
			struct oval_definition_model *model;
			struct oval_variable *var;

			model = context->definition_model;
			var = oval_definition_model_get_new_variable(model, var_ref, OVAL_VARIABLE_UNKNOWN);
			oval_record_field_set_variable(rf, var);
			xmlFree(var_ref);
		}
		break;
	}
	case OVAL_RECORD_FIELD_ITEM:
	{
		oval_syschar_status_t status;

		status = oval_syschar_status_parse(reader, "status", SYSCHAR_STATUS_EXISTS);
		oval_record_field_set_status(rf, status);
		ret = oscap_parser_text_value(reader, &_oval_record_field_value_consumer, rf);
		break;
	}
	default:
		dE("Impossible happened.\n");
	}

	(*consumer) (rf, user);

	return ret;
}